diff --git a/res/app.js b/res/app.js index 0146d95..b6f66b7 100755 --- a/res/app.js +++ b/res/app.js @@ -340,7 +340,7 @@ $(document).ready(function () { var parentFormId = $(this).closest("form").attr("id"); var parentFormClass = $(this).closest("form").attr("class"); - + var filePath = $(`#${parentFormId} input[name='filePath']`).val(); // Construct the URL for the GET request @@ -367,7 +367,7 @@ $(document).ready(function () { var parentFormId = $(this).closest("form").attr("id"); var parentFormClass = $(this).closest("form").attr("class"); - + var filePath = $(`#${parentFormId} input[name='filePath']`).val(); @@ -400,14 +400,14 @@ $(document).ready(function () { return "/saveCharacter.php?cmd=" + cmd + "&name=" + name + "&value=" + value + "&filePath=" + filePath; } - $(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input, .form-check-input, #statsdiv input").change(function () { + $(".charform input[name='Difficulty'], .charform .skill, #CharacterName, #CharacterClass, #CharacterLevel, #CharacterClass, .stats input, .form-check-input, #statsdiv input,#setallskills,.wp_all,.q_all").change(function () { var name = $(this).attr("name"); var newValue = $(this).val(); var cmd = $(this).attr("cmd") || $(this).attr("id") || name; var parentFormId = $(this).closest("form").attr("id"); var parentFormClass = $(this).closest("form").attr("class"); - + var filePath = $(`#${parentFormId} input[name='filePath']`).val(); var url = constructURL(cmd, name, newValue, filePath); @@ -423,13 +423,54 @@ $(document).ready(function () { }); }); -// colorize the acts - var acts = ['Act 1', 'Act 2', 'Act 3', 'Act 4', 'Act 5']; + $('.q_all, .wp_all').click(function () { + var parentFormId = $(this).closest("form").attr("id"); + var targetClass = $(this).attr('class') === 'q_all' ? `#${parentFormId} .qcheck` : `#${parentFormId} .wpcheck`; + var isChecked = $(this).prop('checked'); + + $(targetClass).prop('checked', isChecked); + }); + + $('.qcheck').change(function () { + var parentFormId = $(this).closest("form").attr("id"); + var qallChecked = $(`#${parentFormId} .qcheck:checked`).length === $(`#${parentFormId} .qcheck`).length; + if (qallChecked == true) { + var qchecked = 'checked'; + var val = 1; + } else { + qchecked = ''; + var val = 0; + } + $(`#${parentFormId} .q_all`).prop('checked', qchecked).val(val); + }); + + $('.wpcheck').change(function () { + var parentFormId = $(this).closest("form").attr("id"); + var wpallChecked = $(`#${parentFormId} .wpcheck:checked`).length === $(`#${parentFormId} .wpcheck`).length; + if (wpallChecked == true) { + var wpchecked = 'checked'; + var val = 1; + } else { + wpchecked = ''; + var val = 0; + } + $(`#${parentFormId} .wp_all`).prop('checked', wpchecked).val(val); + }); + + $('#setallskills').change(function () { + var value = $(this).val(); + var parentFormId = $(this).closest("form").attr("id"); + $(`#${parentFormId} .skill`).attr('value', value); + }); + + + + // colorize the acts + var acts = ['Act 1', 'Act 2', 'Act 3', 'Act 4', 'Act 5']; for (var i = 0; i < acts.length; i++) { var act = acts[i]; var className = 'act' + (i + 1); - // Find the checkbox with a label containing the act $('input[type="checkbox"] + label:contains("' + act + '")').each(function () { // Add a class to the parent div @@ -437,5 +478,4 @@ $(document).ready(function () { }); } - });// end document.ready \ No newline at end of file diff --git a/saveCharacter.php b/saveCharacter.php index a9de87b..5fd5c6a 100644 --- a/saveCharacter.php +++ b/saveCharacter.php @@ -115,7 +115,6 @@ switch ($cmd) { echo "Handling skills command - Skill: $name, Value: $value, File Path: $filePath"; break; - case "Died": $char->setChar("CharacterStatus", "Died", $value); // Set the "CharacterStatusDied" value to the provided value echo "Handling Died command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the Died command @@ -258,12 +257,60 @@ switch ($cmd) { fclose($fp); break; - // stats commands + // stats commands case "stats": echo "Handling $name command. New value: $value"; $char->setStat($name, $value); break; - + + // setallskills + case "setallskills": + echo "Handling $name command. New value: $value"; + $char->setAllSkills($value); + break; + + // q_all + case "q_all": + echo "Handling $name command. New value: $value"; + $fp = fopen($filePath, "rb+"); + $offsets = array_merge(array_keys($csData->qNorm), array_keys($csData->qNM), array_keys($csData->qHell)); + + $packValue1 = ($value == 1) ? 0xFE : 0x00; + $packValue2 = ($value == 1) ? 0xFF : 0x00; + foreach ($offsets as $k => $v) { + fseek($fp, $v); + fwrite($fp, pack('C', $packValue1)); + fseek($fp, $v + 1); + fwrite($fp, pack('C', $packValue2)); + } + + $checksum = (shell_exec("bin\d2scs.exe \"$filePath\"")); + break; + + // wp_all + case "wp_all": + echo "Handling $name command. New value: $value"; + $fp = fopen($filePath, "rb+"); + + // Determine the pack value based on the $value variable + $packValue = ($value == 1) ? 0xFF : 0x00; + + // Define the WP offsets + $wp_offsets = [ + 643, 644, 645, 646, 647, // Norm + 667, 668, 669, 670, 671, // NM + 691, 692, 693, 694, 695 // Hell + ]; + + // Iterate over the WP offsets + foreach ($wp_offsets as $offset) { + fseek($fp, $offset); + fwrite($fp, pack('C', $packValue)); + } + + $checksum = (shell_exec("bin\d2scs.exe \"$filePath\"")); + break; + // default command default: // Handle unknown command diff --git a/src/tabs/Chars.php b/src/tabs/Chars.php index fd8131f..a702b4c 100644 --- a/src/tabs/Chars.php +++ b/src/tabs/Chars.php @@ -294,8 +294,9 @@ HTML; foreach ($sortedArray as $index => $container) { $containerId = "container_" . $index; - if (empty($index)) $index = "Socketed"; - + if (empty($index)) + $index = "Socketed"; + // Create accordion card for the container $items .= "
"; $items .= "
"; @@ -341,6 +342,34 @@ HTML; $items .= "
"; + $qarray = ($c->cData['Quests'][0]); + $qallOnes = 1; + foreach ($qarray as $acts) { + $values = array_values($acts); + $result = array_reduce($values, function ($carry, $value) { + return $carry && ($value === '1'); + }, 1); + if (!$result) { + $qallOnes = 0; + break; + } + } + $qchecked = $qallOnes ? "checked" : ""; + + $wparray = ($c->cData['Waypoints']); + $wpallOnes = 1; + foreach ($wparray as $acts) { + $values = array_values($acts); + $result = array_reduce($values, function ($carry, $value) { + return $carry && ($value === '1'); + }, 1); + if (!$result) { + $wpallOnes = 0; + break; + } + } + $wpchecked = $wpallOnes ? "checked" : ""; + $tabContent .= <<
@@ -426,6 +455,11 @@ $checkboxes $stats

Skills

+
+ + +
+
$skillDivs
@@ -433,10 +467,23 @@ $checkboxes

Quests

+
+
+ + +
+
$quests

Waypoints

+
+
+ + +
+
+ $wps