mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-09-18 01:22:08 +00:00
ajaxify d2s editor
This commit is contained in:
@@ -254,6 +254,7 @@ WHERE sk.charclass = '$class'";
|
||||
foreach ($skills as $k => $v) {
|
||||
if ($this->skillData[$k]['String']) {
|
||||
$cData['skills'][$k] = [
|
||||
'id' => $this->skillData[$k]['Id'],
|
||||
'skill' => $this->skillData[$k]['String'],
|
||||
'points' => $v,
|
||||
'page' => $this->skillData[$k]['SkillPage'],
|
||||
@@ -373,12 +374,23 @@ WHERE sk.charclass = '$class'";
|
||||
public function setChar(string $stat, mixed $val, mixed $val2 = null) {
|
||||
switch ($stat) {
|
||||
case 'CharacterName':
|
||||
if (strlen($val) < 1 || strlen($val) > 15) {
|
||||
return false;
|
||||
}
|
||||
$pack = $this->ByteReader->bitsToHexString($this->ByteReader->toBits(pack('Z16', $val)));
|
||||
$this->ByteReader->writeBytes(20, $pack);
|
||||
rename($this->filePath, $_SESSION['savepath'] . "$val.d2s");
|
||||
$this->data = $this->ByteReader->getData();
|
||||
$this->save();
|
||||
|
||||
// file is not being saved, and copied before being saved, hence the bug, fixed
|
||||
|
||||
$fileName = pathinfo($this->filePath, PATHINFO_FILENAME);
|
||||
$originalFileNames = glob($_SESSION['savepath'] . $fileName . '*');
|
||||
foreach ($originalFileNames as $originalFileName) {
|
||||
$newFileName = $_SESSION['savepath'] . $val . '.' . pathinfo($originalFileName, PATHINFO_EXTENSION);
|
||||
if ($originalFileName !== $newFileName) {
|
||||
copy($originalFileName, $newFileName);
|
||||
unlink($originalFileName);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "CharacterClass":
|
||||
@@ -398,6 +410,7 @@ WHERE sk.charclass = '$class'";
|
||||
if ($val > 99) {
|
||||
$val = 99;
|
||||
}
|
||||
|
||||
$this->ByteReader->writeByte(43, $val);
|
||||
$this->setStat('level', $val);
|
||||
|
||||
@@ -443,6 +456,21 @@ WHERE sk.charclass = '$class'";
|
||||
$this->save();
|
||||
break;
|
||||
|
||||
case 'Difficulty':
|
||||
switch ($val) {
|
||||
case "Normal":
|
||||
$this->data[168] = pack('C', 255); // 1000 0000 MSB = Difficulty
|
||||
break;
|
||||
case "NM":
|
||||
$this->data[169] = pack('C', 255);
|
||||
break;
|
||||
case "Hell":
|
||||
$this->data[170] = pack('C', 255);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'LeftmousebuttonskillID':
|
||||
$this->ByteReader->writeBytes(120, dechex($val));
|
||||
break;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
$tabs .= <<<EOT
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link btn btn-outline-danger" style="background: #ddd; border: 1px solid #888;" id="{$c->cData['CharacterName']}-tab" data-toggle="tab" href="#{$c->cData['CharacterName']}" role="tab" aria-controls="{$c->cData['CharacterName']}" aria-selected="true"><img height="64" width="" src="img/chars/{$c->cData['CharacterClass']}.gif">{$c->cData['CharacterName']}</a>
|
||||
<a class="nav-link btn btn-outline-danger" style="background: #ddd; border: 1px solid #888;" id="{$c->cData['CharacterName']}-tab" data-toggle="tab" href="#{$c->cData['CharacterName']}" role="tab" aria-controls="{$c->cData['CharacterName']}" aria-selected="true"><img height="64" width="" src="img/chars/{$c->cData['CharacterClass']}.gif"><span class="chartab">{$c->cData['CharacterName']}</span></a>
|
||||
</li>
|
||||
EOT;
|
||||
echo $tabs;
|
||||
@@ -39,19 +39,17 @@ EOT;
|
||||
}
|
||||
|
||||
$wps = '';
|
||||
$wps .= "<input type='radio' value='1' name='wp_all' id='wp_all'>";
|
||||
$wps .= "<label style='font-size: 1.3em;color:green;' for='wp_all'>Enable All Waypoints</label><br>";
|
||||
$wps .= "<input type='radio' value='0' name='wp_all' id='wp_all_off'>";
|
||||
$wps .= "<label style='font-size: 1.3em; color: red;' for='wp_all_off'>Disable All Waypoints</label><hr>";
|
||||
//$wps .= "<input type='radio' value='1' name='wp_all' id='wp_all'>";
|
||||
//$wps .= "<label style='font-size: 1.3em;color:green;' for='wp_all'>Enable All Waypoints</label><br>";
|
||||
//$wps .= "<input type='radio' value='0' name='wp_all' id='wp_all_off'>";
|
||||
//$wps .= "<label style='font-size: 1.3em; color: red;' for='wp_all_off'>Disable All Waypoints</label><hr>";
|
||||
|
||||
|
||||
|
||||
foreach ($c->cData['Waypoints'] as $diff => $waypoints) { // diff is difficulty
|
||||
$wps .= "<h2>$diff</h2>";
|
||||
array_pop($waypoints);
|
||||
$wp_count = 0;
|
||||
foreach ($waypoints as $k => $v) {
|
||||
|
||||
|
||||
$kD = str_replace("_", " ", $k);
|
||||
$kD = str_replace([" NM", " Hell"], "", $kD);
|
||||
$checked = ($v == 1 && $k != '') ? 'checked ' : '';
|
||||
@@ -60,7 +58,6 @@ EOT;
|
||||
$wps .= "<label for='$k'>$kD</label><br>";
|
||||
$wp_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$classOptions = [
|
||||
@@ -74,54 +71,77 @@ EOT;
|
||||
}
|
||||
|
||||
$difficulties = [
|
||||
'Normal' => 'DifficultyNormal',
|
||||
'NM' => 'DifficultyNM',
|
||||
'Hell' => 'DifficultyHell'
|
||||
'Normal' => '1',
|
||||
'NM' => '2',
|
||||
'Hell' => '3'
|
||||
];
|
||||
|
||||
$radio = '';
|
||||
|
||||
foreach ($difficulties as $difficulty => $id) {
|
||||
$checked = ($c->cData['Difficulty'][$difficulty] == 1) ? 'checked' : '';
|
||||
$radio .= "<input $checked type='radio' id='$id' name='Difficulty' value='$difficulty'>$difficulty<br>";
|
||||
$radio .= "<input $checked type='radio' id='$difficulty' name='Difficulty' value='$difficulty'>";
|
||||
$radio .= "<label for='$difficulty'>$difficulty</label><br>";
|
||||
}
|
||||
|
||||
$skills = '';
|
||||
/*
|
||||
'skills' =>
|
||||
array (size=1)
|
||||
'skills' =>
|
||||
array (size=52)
|
||||
0 =>
|
||||
array (size=7)
|
||||
'id' => int 36
|
||||
'skill' => string 'Fire Bolt' (length=9)
|
||||
'points' => int 0
|
||||
'page' => int 3
|
||||
'row' => int 1
|
||||
'col' => int 2
|
||||
'icon' => int 0
|
||||
*/
|
||||
$skillcounter = 1;
|
||||
foreach ($c->cData['skills']['skills'] as $k => $skill) {
|
||||
$skills .= "<input style='width: 64px;' class='skill-$k skill' name='skills[$k]' type='number' min='0' max='99' value='{$skill['points']}'>: {$skill['skill']}<hr>";
|
||||
$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++;
|
||||
}
|
||||
|
||||
|
||||
// dump($c['Waypoints']);
|
||||
$tabContent .= <<<EOT
|
||||
<div style="background: white;" class="tab-pane fade" id="{$c->cData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->cData['CharacterName']}-tab">
|
||||
<form class="charform" method="POST" action="/saveCharacter.php">
|
||||
<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">
|
||||
<input type="hidden" name="filePath" id="filePath" value="{$c->cData['filePath']}">
|
||||
<div class="container" style="font-size: 14px;">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1 style="margin: 15px;">{$c->cData['CharacterName']}</h1>
|
||||
<input class="btn btn-danger" style="" type="submit" value="Save Character">
|
||||
<img src="/img/chars/{$c->cData['CharacterClass']}.gif"><br>
|
||||
<input type="text" id="ChracterName" name="ChracterName" maxlength="16" value="{$c->cData['CharacterName']}">
|
||||
<select id='CharacterClass'>
|
||||
<!--<input class="btn btn-danger" style="" type="submit" value="Save Character">
|
||||
<img src="/img/chars/{$c->cData['CharacterClass']}.gif" style='height: 64px; width: 64px;'><br>-->
|
||||
Name: <input type="text" id="CharacterName" name="CharacterName" maxlength="16" value="{$c->cData['CharacterName']}" pattern="[A-Za-z0-9_-]+" title="Character name can only contain alphabets, numbers, underscore, and dash." data-oldvalue="{$c->cData['CharacterName']}">
|
||||
<br>
|
||||
<select id='CharacterClass' name='CharacterClass'>
|
||||
$option
|
||||
</select>
|
||||
Level: <input style="border: 1px solid black;width: 54px;" type="number" id="CharacterLevel" value="{$c->cData['CharacterLevel']}"><br>
|
||||
$radio
|
||||
$skills
|
||||
</select><br>
|
||||
Character Level: <input style="border: 1px solid black;width: 54px;" type="number" name="CharacterLevel" id="CharacterLevel" value="{$c->cData['CharacterLevel']}"><br>
|
||||
<hr>
|
||||
<!--Difficulty:<br>
|
||||
$radio-->
|
||||
<div>
|
||||
<h3>Skills</h3>
|
||||
$skills
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<h2>Quests</h2>
|
||||
<h3>Quests</h3>
|
||||
$quests
|
||||
</div>
|
||||
<div class="col">
|
||||
<h2>Waypoints</h2>
|
||||
<h3>Waypoints</h3>
|
||||
$wps
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input class="btn btn-danger" style="" type="submit" value="Save Character">
|
||||
<!--<input class="btn btn-danger" style="" type="submit" value="Save Character">-->
|
||||
</form>
|
||||
</div>
|
||||
EOT;
|
||||
|
Reference in New Issue
Block a user