D2S chars reverted skills display

This commit is contained in:
Hash Borgir 2023-06-03 18:59:46 -06:00
parent 2a8ba701a7
commit dc7e046077

View File

@ -84,6 +84,7 @@ EOT;
$radio .= "<label for='$difficulty'>$difficulty</label><br>";
}
$skills = '';
/*
'skills' =>
array (size=1)
@ -99,76 +100,12 @@ EOT;
'col' => int 2
'icon' => int 0
*/
// $skillcounter = 1;
// foreach ($c->cData['skills']['skills'] as $k => $skill) {
// $skills .= "<input cmd='skills' style='width: 64px;' class='skill-$k skill' name='$skillcounter' type='number' min='0' max='255' value='{$skill['points']}'>: {$skill['skill']}<hr>";
// $skillcounter++;
// }
// Sort the skills array by page
usort($c->cData['skills']['skills'], function($a, $b) {
return $a['page'] <=> $b['page'];
});
$skills = '';
$skillcounter = 1;
$currentPage = null;
$tabLinks = '';
$tabContents = '';
foreach ($c->cData['skills']['skills'] as $k => $skill) {
// Check if the current skill is on a new page
if ($skill['page'] !== $currentPage) {
// Close the previous tab content (if any)
if ($currentPage !== null) {
$tabContents .= "</div>";
$skillcounter = 1;
foreach ($c->cData['skills']['skills'] as $k => $skill) {
$skills .= "<input cmd='skills' style='width: 64px;' class='skill-$k skill' name='$skillcounter' type='number' min='0' max='255' value='{$skill['points']}'>: {$skill['skill']}<hr>";
$skillcounter++;
}
// Generate tab link
$tabLinks .= "<li class='nav-item'>";
$tabLinks .= "<a class='nav-link" . ($currentPage === null ? " active" : "") . "' data-toggle='tab' href='#page{$skill['page']}'>Page {$skill['page']}</a>";
$tabLinks .= "</li>";
// Start a new tab content for the current page
$tabContents .= "<div id='page{$skill['page']}' class='tab-pane fade" . ($currentPage === null ? " show active" : "") . "' role='tabpanel'>";
$currentPage = $skill['page'];
}
// Append the skill to the current page content
$tabContents .= "<div class='row align-items-center'>";
$tabContents .= "<div class='col-md-3'>" . $skill['skill'] . "</div>";
$tabContents .= "<div class='col-md-9'>";
$tabContents .= "<input cmd='skills' style='width: 64px;' class='skill-$k skill' name='$skillcounter' type='number' min='0' max='255' value='{$skill['points']}'>";
$tabContents .= "</div>";
$tabContents .= "</div>";
$skillcounter++;
}
// Close the last tab content
if ($currentPage !== null) {
$tabContents .= "</div>";
}
// Generate the complete tabs structure
$tabs = "<ul class='nav nav-tabs' role='tablist'>";
$tabs .= $tabLinks;
$tabs .= "</ul>";
$tabs .= "<div class='tab-content'>";
$tabs .= $tabContents;
$tabs .= "</div>";
// Combine the tabs structure and skills content
$skillsMarkup = "<div class='container'>$tabs</div>";
// dump($c['Waypoints']);
$tabContent .= <<<EOT
<div style="background: white; margin-top: 10px;" class="tab-pane fade" id="{$c->cData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->cData['CharacterName']}-tab">
<form id='{$c->cData['CharacterName']}' class="charform {$c->cData['CharacterName']}" method="POST" action="/saveCharacter.php">
@ -242,7 +179,7 @@ $skillsMarkup = "<div class='container'>$tabs</div>";
$radio-->
<div>
<h3>Skills</h3>
$skillsMarkup
$skills
</div>
</div>
<div class="col">