Skip to content

Commit

Permalink
GH-91 Cleanup slot renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Aug 1, 2022
1 parent de6fe86 commit d15f4cd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
62 changes: 34 additions & 28 deletions simulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,36 +510,42 @@ function ($value, $key) {
$TPL_Row = gettemplate('simulator_row');
$TPL_NoLeft = gettemplate('simulator_row_noleft');

for($i = 1; $i <= $MaxACSSlots; $i += 1)
{
$ThisSlot = [];
$ThisSlot['SlotID'] = $i;
$ThisSlot['txt'] = '';

$parse = $_Lang;
$parse['i'] = $i;
if($i > 1)
{
$ThisSlot['SlotHidden'] = 'hide';
}

if (MORALE_ENABLED) {
$ThisSlot['txt'] .= AttackSimulator\Components\MoraleInputsSection\render([
'slotIdx' => $i,
for (
$slotIdx = 1;
$slotIdx <= $MaxACSSlots;
$slotIdx += 1
) {
$thisSlotElements = [
(
MORALE_ENABLED ?
AttackSimulator\Components\MoraleInputsSection\render([
'slotIdx' => $slotIdx,
'input' => &$_POST,
])['componentHTML'] :
''
),
AttackSimulator\Components\TechInputsSection\render([
'slotIdx' => $slotIdx,
'input' => &$_POST,
])['componentHTML'];
}

$ThisSlot['txt'] .= AttackSimulator\Components\TechInputsSection\render([
'slotIdx' => $i,
'input' => &$_POST,
])['componentHTML'];
$ThisSlot['txt'] .= AttackSimulator\Components\UnitInputsSection\render([
'slotIdx' => $i,
'input' => &$_POST,
])['componentHTML'];
])['componentHTML'],
AttackSimulator\Components\UnitInputsSection\render([
'slotIdx' => $slotIdx,
'input' => &$_POST,
])['componentHTML'],
];
$isMainFleetsSlot = ($slotIdx === 1);

$thisSlotProps = [
'SlotID' => $slotIdx,
'SlotInitiallyHidden' => (
!$isMainFleetsSlot ?
'hide' :
''
),
'txt' => implode('', $thisSlotElements),
];

$_Lang['rows'] .= parsetemplate($TPL_Slot, $ThisSlot);
$_Lang['rows'] .= parsetemplate($TPL_Slot, $thisSlotProps);
}

$isUsingPrettyInputs = ($_User['settings_useprettyinputbox'] == 1);
Expand Down
2 changes: 1 addition & 1 deletion templates/default_template/simulator_slot.tpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<tbody id="slot_{SlotID}" class="{SlotHidden}">{txt}</tbody>
<tbody id="slot_{SlotID}" class="{SlotInitiallyHidden}">{txt}</tbody>

0 comments on commit d15f4cd

Please sign in to comment.