Item preview upgrade. Debug info/button added. Debug link when click on item pic. Proper descfuncs with sprintf.

This commit is contained in:
color.diff=auto 2021-05-04 07:42:24 -06:00
parent 13568c5b74
commit 21546a57db
10 changed files with 283 additions and 122 deletions

View File

@ -151,8 +151,6 @@ if ($cmd == "getUniqueItem") {
$counter = 1;
foreach ($props as $k => $v) { // for each property Prop1 Prop2
$value = $v['par1'] ?? $v['min1'];
$params = [
'string1' => $v['desc']['string1'],
'string2' => $v['desc']['string2'],
@ -164,8 +162,13 @@ if ($cmd == "getUniqueItem") {
"max" => $return['max' . $counter]
];
/*
* getDesc should process string1, not file guide copy pasta
*
*/
if (!empty($v['desc'])) {
$props[$k]['string'][] = $idesc->getDesc($value, $params);
$props[$k]['string'][] = $idesc->getDesc($params);
}
$counter++;
}
@ -176,7 +179,7 @@ if ($cmd == "getUniqueItem") {
header('Content-Type: application/json');
echo json_encode($return, JSON_INVALID_UTF8_IGNORE);
echo json_encode($return, JSON_INVALID_UTF8_IGNORE|JSON_PRETTY_PRINT);
}
/*
* @cmd = sortBy

Binary file not shown.

BIN
fonts/ExocetHeavy_.ttf Normal file

Binary file not shown.

BIN
fonts/ExocetLight.ttf Normal file

Binary file not shown.

View File

@ -39,6 +39,27 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function syntaxHighlight(json) {
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
function search() {
$.get("/ajax/uniqueitems.php?cmd=search&search=" + searchbox.value, function (data) {
$('.uniqueitems-select').html(data)
@ -167,24 +188,34 @@ $(document).ready(function () {
});
// cmd = getUniqueItem
$('.uniqueitems-select').change(function () {
$(".item").attr("src", "/img/items/1.png");
$(".item_debug_link").attr('href', "/ajax/uniqueitems.php?cmd=getUniqueItem&index=" + this.value)
$.get("/ajax/uniqueitems.php?cmd=getUniqueItem&index=" + this.value, function (data) {
debugData = (JSON.stringify(data, null, 4));
$('.debug, .debug_preview').html(syntaxHighlight(debugData));
props = data.props;
$('.item_desc').html("<p></p>");
$('.item_stats div').html("<p></p>");
type = data["*type"];
lvlreq = data["lvl req"];
$('.item_stats p').append(`<li class="statindex">${data.index}</li>`);
$('.item_stats p').append(`<li class="stattype">${type}</li>`);
$('.item_stats p').append(`<li class="statlvlreq">Level Required: ${lvlreq}</li>`);
// $('.item_stats p').append(`<li class="index">${data.index}</li>`);
// $('.item_stats p').append(`<li class="index">${data.index}</li>`);
// $('.item_stats p').append(`<li class="index">${data.index}</li>`);
// $('.item_stats p').append(`<li class="index">${data.index}</li>`);
$.each(props, function (i, v) {
if(v.string){
$('.item_desc p').append('<li class="'+i+'">'+v.string[0]+"</li>");
$('.item_stats p').append('<li class="'+i+'">'+v.string[0]+"</li>");
}
});
@ -197,10 +228,14 @@ $(document).ready(function () {
$('select[name="code[]"]').val(v);
$('select[name="code[]"]').prop('required', '');
}
})
});
});
});
$(".btnDebug").click(function(){
$(".debug_preview").slideToggle();
});
// cmd = sortBy
$('input[name="sort"]').change(function () {

View File

@ -40,7 +40,7 @@
*/
@font-face {
font-family: 'Exocet';
font-family: 'ExocetHeavy';
src: url('/fonts/ExocetHeavy.eot');
src: local('Exocet Heavy'), local('ExocetHeavy'),
url('/fonts/ExocetHeavy.eot?#iefix') format('embedded-opentype'),
@ -52,6 +52,15 @@
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'ExocetLight';
src: local('Exocet Light'), local('ExocetLight'),
url('/fonts/ExocetLight.ttf') format('truetype');
font-weight: 900;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Lato';
src: url('/fonts/Lato-Regular.ttf') format('truetype');
@ -111,8 +120,9 @@ body {
}
h1,h2,h3,h4,h5,h6, div > p {
font-family: Exocet;
font-family: ExocetLight;
color: #778;
text-transform: uppercase;
}
#loading {
margin-top: 40px;
@ -165,25 +175,60 @@ option {
margin: 15px 0;
}
.item {
text-align: left;
position:absolute;
right:282px;
}
.item_desc {
height: auto;
width: 640px;
height: 560px;
width: 620px;
position: absolute;
left: 110px;
top: 23px;
left: -80px;
top: 0px;
/* background: black url(/img/items/bg.png) center top no-repeat;*/
text-align: center;
background: black;
padding: 10px;
background: #333;
text-align: center;
padding: 10px;
text-transform: uppercase;
}
.item_desc p {
font-size: 13px;
font-size: 14px;
color: #4169E1;
letter-spacing: -1px;
}
.item_desc span {
}
ul, li, ul li {
list-style-type: none;
}
.debug {
height: 800px;
}
pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }
.statindex, .stattype{
color: #A59263;
font-weight: bold;
font-family: ExocetHeavy;
font-size: 1.2em;
}
.statlvlreq {
color: white;
}

View File

@ -172,28 +172,33 @@ class D2ItemDesc {
'19' => 'StrSklTabItem20',
'20' => 'StrSklTabItem21'
];
public $charClass = [
"ama" => "Amazon",
"sor" => "Sorceress",
"nec" => "Necromancer",
"pal" => "Paladin",
"bar" => "Barbarian",
"dru" => "Druid",
"ama" => "Amazon",
"sor" => "Sorceress",
"nec" => "Necromancer",
"pal" => "Paladin",
"bar" => "Barbarian",
"dru" => "Druid",
"ass" => "Assassin"
];
public function getDesc($value, $params = []) {
public function getDesc($params = []) {
if (empty($params))
return false;
$v = '<span style="font-family: Lato; color: white; font-weight: 900">' . $value . "</span>";
$s1 = $params['string1'];
$s2 = $params['string2'];
$prop = $params['prop'];
$par = $params['par'];
$min = '<span style="color: white; font-weight: 900">' . $params['min'] . "</span>";
$max = '<span style="color: white; font-weight: 900">' . $params['max'] . "</span>";
$min = (int) $params['min'];
$v = $min;
$max = (int) $params['max'];
if ($min == $max) {
$max = '';
}
foreach ($this->skilltabs as $s) {
$sql = "SELECT `String` FROM `strings` WHERE `Key`='$s'";
$this->skilltabsDesc[] = PDO_FetchRow($sql);
@ -205,11 +210,23 @@ class D2ItemDesc {
//ddump($this->skilltabsDescClean);
/*
* Descval 1
*
*
* $format = 'The %s contains %d monkeys';
echo sprintf($format, $num, $location);
*
*
*
*/
if ($params['descval'] == 1 || $params['descval'] == '') {
if ($params['descfunc'] == 1) {
$this->str = "+$v $s1";
if (!empty($max)) {
$max = "-" . $max;
}
$this->str = "+$min$max $s1";
}
if ($params['descfunc'] == 2) {
@ -229,7 +246,7 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 6) {
$this->str = "+$v $s1 $s2";
$this->str = "+$par $s1 $s2";
}
if ($params['descfunc'] == 7) {
@ -248,7 +265,7 @@ class D2ItemDesc {
}
if ($params['descfunc'] == 11) {
$this->str = "Repairs 1 Durability In " . (100 / $value) . " seconds";
$this->str = "Repairs 1 Durability In " . (100 / $par) . " seconds";
}
if ($params['descfunc'] == 12) {
@ -262,17 +279,18 @@ class D2ItemDesc {
if ($params['descfunc'] == 14) {
$sql = "SELECT class
FROM `charstats`
WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
`StrSkillTab2`='{$this->skilltabs[$par]}' OR
`StrSkillTab3`='{$this->skilltabs[$par]}'";
FROM `charstats`
WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
`StrSkillTab2`='{$this->skilltabs[$par]}' OR
`StrSkillTab3`='{$this->skilltabs[$par]}'";
$class = PDO_FetchOne($sql);
$this->str = "+$min-$max{$this->skilltabsDescClean[$par]['String']} Skill Levels ($class Only)";
$this->str = sprintf($s1, $min, $this->skilltabsDescClean[$par]['String']);
}
if ($params['descfunc'] == 15) {
$this->str = "[chance]% to case [slvl] [skill] on [event]";
$sql = "SELECT skill FROM `skills` WHERE `Id`='$par'";
$skill = PDO_FetchOne($sql);
$this->str = sprintf($s1, $min, $max, $skill);
}
if ($params['descfunc'] == 16) {
@ -292,7 +310,7 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 20) {
$this->str = ($v * -1) . "% $s1";
$this->str = ($v) . "% $s1";
}
if ($params['descfunc'] == 21) {
@ -307,7 +325,11 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 24) {
$this->str = "+$v to Skill Charges Or Something";
$string = str_replace("\\", "", $s1);
$sql = "SELECT skill FROM `skills` WHERE `Id`='$par'";
$skill = PDO_FetchOne($sql);
$this->str = "+$min to Skill Charges Or Something";
$this->str = sprintf("Level $max $skill ".$string,$min,$min);
}
if ($params['descfunc'] == 25) {
@ -319,17 +341,28 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 27) {
$this->str = "+$v to [skill] ([class] Only)";
$sql = "SELECT skill,charclass FROM `skills` WHERE `Id`='$par'";
$res = PDO_FetchRow($sql);
$this->str = "+$par to a Random Skill";
}
if ($params['descfunc'] == 28) {
$sql = "SELECT `skill` FROM `skills` WHERE `skilldesc`='$par'";
$skill = PDO_FetchOne($sql);
$this->str = "+$min to $skill ";
}
} else if ($params['descval'] == 0) {
}
/*
* Descval 0
*
*
*
*
*
*
*
*/ else if ($params['descval'] == 0) {
if ($params['descfunc'] == 1) {
$this->str = "$s1";
}
@ -432,13 +465,24 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 27) {
$this->str = "to [skill] ([class] Only)";
$sql = "SELECT skill,charclass FROM `skills` WHERE `Id`='$par'";
$res = PDO_FetchRow($sql);
$this->str = "+$min to {$res['skill']} ({$this->charClass[$res['charclass']]} Only)";
}
if ($params['descfunc'] == 28) {
$this->str = "to [skill] ";
}
} else if ($params['descval'] == 2) {
}
/*
* Descval 0
*
*
*
*
*
*
*/ else if ($params['descval'] == 2) {
if ($params['descfunc'] == 1) {
$this->str = "$s1 +$v";
}
@ -491,7 +535,16 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 14) {
$this->str = "to [skilltab] Skill Levels ([class] Only) +$v ";
$sql = "SELECT class
FROM `charstats`
WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
`StrSkillTab2`='{$this->skilltabs[$par]}' OR
`StrSkillTab3`='{$this->skilltabs[$par]}'";
$class = PDO_FetchOne($sql);
$this->str = "{$this->skilltabsDescClean[$par]['String']} ($class Only) +$max";
}
if ($params['descfunc'] == 15) {
$this->str = "[chance]% to case [slvl] [skill] on [event]";
@ -541,7 +594,9 @@ WHERE `StrSkillTab1`='{$this->skilltabs[$par]}' OR
}
if ($params['descfunc'] == 27) {
$this->str = "+$v to [skill] ([class] Only)";
$sql = "SELECT skill,charclass FROM `skills` WHERE `Id`='$par'";
$res = PDO_FetchRow($sql);
$this->str = "+$min to {$res['skill']} ({$this->charClass[$res['charclass']]} Only)";
}
if ($params['descfunc'] == 28) {

View File

@ -1,43 +1,43 @@
<?php
/*
Copyright (C) 2021 Hash Borgir
Copyright (C) 2021 Hash Borgir
This file is part of D2Modder
This file is part of D2Modder
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:
Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* This software must not be used for commercial purposes
* without my consent. Any sales or commercial use are prohibited
* without my express knowledge and consent.
* This software must not be used for commercial purposes
* without my consent. Any sales or commercial use are prohibited
* without my express knowledge and consent.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY!
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY!
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
?>
@ -56,7 +56,7 @@
<img src="/img/Diablo2.png" style="float:right"><h1 syle="display:inline; font-weight: 900;"><?php echo $title . " " . $version; ?><span style="font-family: Lato !important; font-size: 14px;"> <?php echo " By" . $author ?></span></h1>
<div style="font-family: Lato !important; text-align:right; color: tomato">
Active Mod: <span style="color: purple"><?php echo $_SESSION['modname'] ?></span>
<span style="color: #8888FF">[<?php echo $_SESSION['path'] ?>]</span>
<span style="color: #8888FF">[<?php echo $_SESSION['path'] ?>]</span>
</div>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
@ -67,7 +67,10 @@
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Gem-tab" data-toggle="tab" href="#Gem" role="tab" aria-controls="Set" aria-selected="false">Gems</a>
</li>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="Debug-tab" data-toggle="tab" href="#Debug" role="tab" aria-controls="Set" aria-selected="false">Debug</a>
</li>
</ul>
</div>
</div>
@ -80,6 +83,9 @@
</div>
<div class="tab-pane fade" id="Gem" role="tabpanel" aria-labelledby="Gem-tab">
<?php require_once 'tabs/Gems.php'; ?>
</div>
</div>
<div class="tab-pane fade" id="Debug" role="tabpanel" aria-labelledby="Debug-tab">
<?php require_once 'tabs/Debug.php'; ?>
</div>
</div>

6
src/tabs/Debug.php Normal file
View File

@ -0,0 +1,6 @@
<div class="row">
<div class="col">
<h2>Debug Output</h2>
<pre class="debug"></pre>
</div>
</div>

View File

@ -1,35 +1,7 @@
<div style="height: 40px; margin: 40px 10px;"><h2>Unique Item Maker</h2></div>
<div class="row">
<div class="offset-4 col"><h3 style="font-family:fixed; font-size:80%;">Preview</h3>
<div class="" style="height: 117px; background: url(/img/items/bg.png) no-repeat">
<img style="" class="item" src="">
<div class="item_desc">
<p></p>
</div>
</div>
</div>
</div>
<div class="row" style="margin-bottom:40px;">
<div class="col" style="">
<p>Search for Item</p>
<input style="border: 1px solid #999; padding: 10px;width: 440px;" id="search" type="text custom-control-inline" placeholder="Search item" name="search">
</div>
</div>
<div class="row" style="">
<div class="col-5">
<select style="height: 260px;padding:10px;margin-bottom: 20px;" name="uniqueitems" class="custom-select uniqueitems-select" multiple>
<!--<option value=""></option>-->
<?php foreach ($uniqueitems as $u) { ?>
<option value="<?php echo $u['index'] ?>"><?php echo $u['index'] ?></option>
<?php } ?>
</select>
</div>
<div class="col-7 sortby">
<p style="font-family:Exocet;">Sort By: </p>
<div class="col sortby">
<p style="">Sort By: </p>
<div class="custom-control custom-radio custom-control-inline">
<input name="sort" id="sort_0" type="radio" class="custom-control-input" value="lvl">
<label for="sort_0" class="custom-control-label">Level</label>
@ -47,7 +19,7 @@
<label for="sort_3" class="custom-control-label">Item Code</label>
</div>
<hr>
<p style="font-family:Exocet;">Filter By: </p>
<p style="">Filter By: </p>
<div class="custom-control custom-radio custom-control-inline">
<input name="view" id="view_0" type="radio" class="custom-control-input" value="rin">
<label for="view_0" class="custom-control-label">Rings</label>
@ -72,6 +44,45 @@
<input name="view" id="view_5" type="radio" class="custom-control-input" value="char">
<label for="view_5" class="custom-control-label">Charms</label>
</div>
</div>
<div class="col">
<div>
<div class="center item_desc" style="">
<div style="height: 116px;background: url(/img/items/bg.png) center top no-repeat;">
<a href="" target="_blank" class="item_debug_link">
<img style="" class="item img-fluid" src="">
</a>
</div>
<div class="item_stats" style="background: #222; margin: 20px; padding: 20px;">
<div class=""><p>ITEM PREVIEW</p></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<button style="margin: 20px;" class="btn btn-outline-warning btnDebug">Debug Info</button>
<pre class="debug_preview" style="display:none; background: #eee; height: 420px;width: 1123px;"></pre>
</div>
</div>
<div class="row" style="margin-bottom:40px;">
<div class="col" style="">
<p>Search for Item</p>
<input style="border: 1px solid #999; padding: 10px;width: 440px;" id="search" type="text custom-control-inline" placeholder="Search item" name="search">
</div>
</div>
<div class="row" style="">
<div class="col-5">
<select style="height: 160px;padding:10px;margin-bottom: 20px;" name="uniqueitems" class="custom-select uniqueitems-select" multiple>
<!--<option value=""></option>-->
<?php foreach ($uniqueitems as $u) { ?>
<option value="<?php echo $u['index'] ?>"><?php echo $u['index'] ?></option>
<?php } ?>
</select>
</div>
</div>
<form action="/index.php" method="post">