Skip to content

Commit

Permalink
GH-208 Simplify indentations of the galaxy subrenderers & share empty…
Browse files Browse the repository at this point in the history
… cell renderer
  • Loading branch information
mdziekon committed May 5, 2022
1 parent 928249c commit 720e5e4
Show file tree
Hide file tree
Showing 8 changed files with 498 additions and 503 deletions.
111 changes: 56 additions & 55 deletions includes/functions/GalaxyRowActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,77 @@ function GalaxyRowActions($GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System,
$TPL = gettemplate('galaxy_row_action');
}

if(isset($GalaxyRowPlanet['id']) && $GalaxyRowPlanet['id'] > 0 && $GalaxyRowPlayer['id'] != $_User['id'])
{
$HiddenOptions = $OptionsCount = 4;
if (
!isset($GalaxyRowPlanet['id']) ||
$GalaxyRowPlanet['id'] <= 0 ||
$GalaxyRowPlayer['id'] == $_User['id']
) {
return renderEmptyGalaxyCell();
}

$Parse = array
(
'Hide_Spy' => ' hide',
'Hide_Msg' => ' hide',
'Hide_Buddy' => ' hide',
'Hide_Rocket' => ' hide',
'Galaxy' => $Galaxy,
'System' => $System,
'Planet' => $Planet,
'SkinPath' => $_SkinPath,
'UserID' => $GalaxyRowPlayer['id'],
'Current' => $_User['current_planet'],
);
$HiddenOptions = $OptionsCount = 4;

if($_User['settings_mis'] == 1)
$Parse = array
(
'Hide_Spy' => ' hide',
'Hide_Msg' => ' hide',
'Hide_Buddy' => ' hide',
'Hide_Rocket' => ' hide',
'Galaxy' => $Galaxy,
'System' => $System,
'Planet' => $Planet,
'SkinPath' => $_SkinPath,
'UserID' => $GalaxyRowPlayer['id'],
'Current' => $_User['current_planet'],
);

if($_User['settings_mis'] == 1)
{
if($CurrentMIP > 0)
{
if($CurrentMIP > 0)
if($GalaxyRowPlanet['galaxy'] == $CurrentGalaxy)
{
if($GalaxyRowPlanet['galaxy'] == $CurrentGalaxy)
$MiRange = GetMissileRange();
$SystemLimitMin = $CurrentSystem - $MiRange;
if($SystemLimitMin < 1)
{
$MiRange = GetMissileRange();
$SystemLimitMin = $CurrentSystem - $MiRange;
if($SystemLimitMin < 1)
{
$SystemLimitMin = 1;
}
$SystemLimitMax = $CurrentSystem + $MiRange;
if($System <= $SystemLimitMax AND $System >= $SystemLimitMin)
{
--$HiddenOptions;
$Parse['Hide_Rocket'] = '';
}
$SystemLimitMin = 1;
}
$SystemLimitMax = $CurrentSystem + $MiRange;
if($System <= $SystemLimitMax AND $System >= $SystemLimitMin)
{
--$HiddenOptions;
$Parse['Hide_Rocket'] = '';
}
}
}
if($_User['settings_esp'] == 1)
{
--$HiddenOptions;
$Parse['Hide_Spy'] = '';
}
if($_User['settings_wri'] == 1 AND $GalaxyRowPlanet['id_owner'] > 0)
}
if($_User['settings_esp'] == 1)
{
--$HiddenOptions;
$Parse['Hide_Spy'] = '';
}
if($_User['settings_wri'] == 1 AND $GalaxyRowPlanet['id_owner'] > 0)
{
--$HiddenOptions;
$Parse['Hide_Msg'] = '';
}
if($_User['settings_bud'] == 1 AND $GalaxyRowPlanet['id_owner'] > 0)
{
if(!in_array($GalaxyRowPlayer['id'], $MyBuddies))
{
--$HiddenOptions;
$Parse['Hide_Msg'] = '';
}
if($_User['settings_bud'] == 1 AND $GalaxyRowPlanet['id_owner'] > 0)
{
if(!in_array($GalaxyRowPlayer['id'], $MyBuddies))
{
--$HiddenOptions;
$Parse['Hide_Buddy'] = '';
}
$Parse['Hide_Buddy'] = '';
}
}

if($OptionsCount == $HiddenOptions)
{
$Result = '<th class="hiFnt">&nbsp;</th>';
}
else
{
$Result = parsetemplate($TPL, $Parse);
}
if($OptionsCount == $HiddenOptions)
{
$Result = renderEmptyGalaxyCell();
}
else
{
$Result = '<th class="hiFnt">&nbsp;</th>';
$Result = parsetemplate($TPL, $Parse);
}

return $Result;
Expand Down
68 changes: 38 additions & 30 deletions includes/functions/GalaxyRowAlly.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,47 @@ function GalaxyRowAlly($GalaxyRowUser, $MyAllyPacts)
$TPL = gettemplate('galaxy_row_ally');
}

if(isset($GalaxyRowUser['ally_id']) && $GalaxyRowUser['ally_id'] > 0)
{
if(!empty($GalaxyRowUser['ally_web']) AND ($GalaxyRowUser['ally_web_reveal'] == 1 OR $GalaxyRowUser['ally_id'] == $_User['ally_id']))
{
$AllyWeb = $GalaxyRowUser['ally_web'];
}

$Parse = array
(
'AllyID' => $GalaxyRowUser['ally_id'],
'AllyClass' => ($GalaxyRowUser['ally_id'] == $_User['ally_id'] ? 'lime' : (isset($MyAllyPacts[$GalaxyRowUser['ally_id']]) && $MyAllyPacts[$GalaxyRowUser['ally_id']] > 0 ? 'skyblue' : '')),
'Lang_Ally' => $_Lang['Alliance'],
'AllyName' => $GalaxyRowUser['ally_name'],
'Lang_MemberCount' => $_Lang['gl_allymembers'],
'AllyMembers' => prettyNumber($GalaxyRowUser['ally_members']),
'Lang_Internal' => $_Lang['gl_ally_internal'],
'AllyPosition' => (string) ($GalaxyRowUser['ally_total_rank'] + 0),
'AllyPositionPretty' => (string) ($GalaxyRowUser['ally_total_rank'] + 0),
'Lang_Stats' => $_Lang['gl_stats'],
'AllyWeb' => (isset($AllyWeb) ? $AllyWeb : ''),
'Lang_Web' => $_Lang['gl_ally_web'],
'Hide_AllyWeb' => ($GalaxyRowUser['ally_web_reveal'] != 1 ? ' class=hide' : ''),
'AllyTag' => $GalaxyRowUser['ally_tag'],
);

$Result = parsetemplate($TPL, $Parse);
if (
!isset($GalaxyRowUser['ally_id']) ||
!($GalaxyRowUser['ally_id'] > 0)
) {
return renderEmptyGalaxyCell();
}
else
{
$Result = '<th class="hiFnt">&nbsp;</th>';

if (
!empty($GalaxyRowUser['ally_web']) &&
($GalaxyRowUser['ally_web_reveal'] == 1 || $GalaxyRowUser['ally_id'] == $_User['ally_id'])
) {
$AllyWeb = $GalaxyRowUser['ally_web'];
}

return $Result;
$Parse = array
(
'AllyID' => $GalaxyRowUser['ally_id'],
'AllyClass' => (
$GalaxyRowUser['ally_id'] == $_User['ally_id'] ?
'lime' :
(
isset($MyAllyPacts[$GalaxyRowUser['ally_id']]) && $MyAllyPacts[$GalaxyRowUser['ally_id']] > 0 ?
'skyblue' :
''
)
),
'Lang_Ally' => $_Lang['Alliance'],
'AllyName' => $GalaxyRowUser['ally_name'],
'Lang_MemberCount' => $_Lang['gl_allymembers'],
'AllyMembers' => prettyNumber($GalaxyRowUser['ally_members']),
'Lang_Internal' => $_Lang['gl_ally_internal'],
'AllyPosition' => (string) ($GalaxyRowUser['ally_total_rank'] + 0),
'AllyPositionPretty' => (string) ($GalaxyRowUser['ally_total_rank'] + 0),
'Lang_Stats' => $_Lang['gl_stats'],
'AllyWeb' => (isset($AllyWeb) ? $AllyWeb : ''),
'Lang_Web' => $_Lang['gl_ally_web'],
'Hide_AllyWeb' => ($GalaxyRowUser['ally_web_reveal'] != 1 ? ' class=hide' : ''),
'AllyTag' => $GalaxyRowUser['ally_tag'],
);

return parsetemplate($TPL, $Parse);
}

?>
92 changes: 39 additions & 53 deletions includes/functions/GalaxyRowDebris.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,57 @@

function GalaxyRowDebris($GalaxyRow, $Galaxy, $System, $Planet, $PlanetType)
{
global $_Lang, $_SkinPath, $CurrentRC, $_Vars_Prices;
global $_Lang, $_SkinPath;

static $TPL = false;
if($TPL === false)
{
$TPL = gettemplate('galaxy_row_debris');
}

$Result = '<th class="hiFnt">&nbsp;</th>';
if($GalaxyRow)
{
$TotalDebris = $GalaxyRow['metal'] + $GalaxyRow['crystal'];
if($TotalDebris > 0)
{
$RecNeeded = ceil($TotalDebris / $_Vars_Prices[209]['capacity']);
if($RecNeeded < $CurrentRC)
{
$RecSended = $RecNeeded;
}
else if($RecNeeded >= $CurrentRC)
{
$RecSended = $CurrentRC;
}
else
{
$RecSended = $RecyclerCount;
}
if (!$GalaxyRow) {
return renderEmptyGalaxyCell();
}

$BackgroundColor = null;
if($TotalDebris >= 10000000)
{
$BackgroundColor = 'bgBig';
}
else if($TotalDebris >= 1000000)
{
$BackgroundColor = 'bgMed';
}
else if($TotalDebris >= 100000)
{
$BackgroundColor = 'bgSmall';
}
$TotalDebris = $GalaxyRow['metal'] + $GalaxyRow['crystal'];

$Parse = array
(
'Lang_Debris' => $_Lang['Debris'],
'Galaxy' => $Galaxy,
'System' => $System,
'Planet' => $Planet,
'PlanetType' => $PlanetType,
'SkinPath' => $_SkinPath,
'Lang_Resource' => $_Lang['gl_ressource'],
'Lang_Metal' => $_Lang['Metal'],
'Metal' => prettyNumber($GalaxyRow['metal']),
'Lang_Crystal' => $_Lang['Crystal'],
'Crystal' => prettyNumber($GalaxyRow['crystal']),
'Lang_Actions' => $_Lang['Actions'],
'Lang_Mission' => $_Lang['type_mission'][8],
'BackgroundColor' => $BackgroundColor,
);
if ($TotalDebris <= 0) {
return renderEmptyGalaxyCell();
}

$Result = parsetemplate($TPL, $Parse);
}
$BackgroundColor = null;
if($TotalDebris >= 10000000)
{
$BackgroundColor = 'bgBig';
}
else if($TotalDebris >= 1000000)
{
$BackgroundColor = 'bgMed';
}
else if($TotalDebris >= 100000)
{
$BackgroundColor = 'bgSmall';
}

return $Result;
$Parse = array
(
'Lang_Debris' => $_Lang['Debris'],
'Galaxy' => $Galaxy,
'System' => $System,
'Planet' => $Planet,
'PlanetType' => $PlanetType,
'SkinPath' => $_SkinPath,
'Lang_Resource' => $_Lang['gl_ressource'],
'Lang_Metal' => $_Lang['Metal'],
'Metal' => prettyNumber($GalaxyRow['metal']),
'Lang_Crystal' => $_Lang['Crystal'],
'Crystal' => prettyNumber($GalaxyRow['crystal']),
'Lang_Actions' => $_Lang['Actions'],
'Lang_Mission' => $_Lang['type_mission'][8],
'BackgroundColor' => $BackgroundColor,
);

return parsetemplate($TPL, $Parse);
}

?>
Loading

0 comments on commit 720e5e4

Please sign in to comment.