Skip to content

Commit

Permalink
fix[ui]:
Browse files Browse the repository at this point in the history
- add fixes for #94 to collection edit
- fix rarity casting from int to float
  • Loading branch information
sk33z3r committed Jun 26, 2022
1 parent 59e49a1 commit ab70a24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions php/edit/3.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
if (rarities[trait] === undefined) {
rarities[trait] = [];
}
rarities[trait][variation-1] = parseInt(input.value);
rarities[trait][variation-1] = parseFloat(input.value);
}
}
// Iterate through rarities backwards and make sure the sum is 100, or display message
Expand Down Expand Up @@ -91,7 +91,7 @@
<div class="trait-row">
<div data-tooltip="Rarity: Chance for this variation to be picked, in percent">
<label for="trait<?php echo $trait_var ?>_rarity">Set Rarity:</label><br />
<input required type="number" class="form small" id="trait<?php echo $trait_var ?>_rarity" min="0" max="100" name="trait<?php echo $trait_var ?>_rarity" placeholder="0-100" value="<?php echo isset($var_name) ? $layer['weights'][$v-1] : null; ?>">&nbsp;%
<input required type="number" step="any" class="form small" id="trait<?php echo $trait_var ?>_rarity" min="0" max="100" name="trait<?php echo $trait_var ?>_rarity" placeholder="0-100" value="<?php echo isset($var_name) ? $layer['weights'][$v-1] : null; ?>">&nbsp;%
</div>
<div data-tooltip="Color: The color of this background variation">
<label for="trait<?php echo $trait_var ?>_r">Color:</label><br />
Expand Down Expand Up @@ -128,7 +128,7 @@
<div class="trait-row">
<div data-tooltip="Rarity: Chance for this variation to be picked, in percent">
<label for="trait<?php echo $trait_var ?>_rarity">Set Rarity:</label><br />
<input required type="number" class="form small" id="trait<?php echo $trait_var ?>_rarity" min="0" max="100" name="trait<?php echo $trait_var ?>_rarity" placeholder="0-100" value="<?php echo isset($var_name) ? $layer['weights'][$v-1] : null; ?>">&nbsp;%
<input required type="number" step="any" class="form small" id="trait<?php echo $trait_var ?>_rarity" min="0" max="100" name="trait<?php echo $trait_var ?>_rarity" placeholder="0-100" value="<?php echo isset($var_name) ? $layer['weights'][$v-1] : null; ?>">&nbsp;%
</div>
<div data-tooltip="Image: Pick the image file for this variation.&#xa;(Browse or drag'n'drop)">
<label for="trait<?php echo $trait_var ?>_r">Filename:</label><br />
Expand Down Expand Up @@ -163,7 +163,7 @@
$trait_var = $s . "_" . $v;
$rgb = str_split(str_replace("#", "", $_POST["trait${trait_var}_color"]), 2);
$new_traits["image_layers"][$t]['rgba'][$_POST["trait${trait_var}_name"]] = array(hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]), (int)$_POST["trait${trait_var}_alpha"]);
array_push($new_traits["image_layers"][$t]['weights'], (int)$_POST["trait${trait_var}_rarity"]);
array_push($new_traits["image_layers"][$t]['weights'], (float)$_POST["trait${trait_var}_rarity"]);
$v = $v + 1;
}
} else {
Expand All @@ -173,7 +173,7 @@
while ($v <= $new_traits['image_layers'][$t]['variations']) {
$trait_var = $s . "_" . $v;
$var_name = $_POST["trait${trait_var}_name"];
$var_weight =(int)$_POST["trait${trait_var}_rarity"];
$var_weight =(float)$_POST["trait${trait_var}_rarity"];

if (isset($_FILES["trait${trait_var}_file"])) { // New file was uploaded
$filename = $_FILES["trait${trait_var}_file"]['name'];
Expand Down
4 changes: 2 additions & 2 deletions php/setup/3.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
$trait_var = $s . "_" . $v;
$rgb = str_split(str_replace("#", "", $_POST["trait${trait_var}_color"]), 2);
$traits["image_layers"][$t]['rgba'][$_POST["trait${trait_var}_name"]] = array(hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]), (int)$_POST["trait${trait_var}_alpha"]);
array_push($traits["image_layers"][$t]['weights'], (int)$_POST["trait${trait_var}_rarity"]);
array_push($traits["image_layers"][$t]['weights'], (float)$_POST["trait${trait_var}_rarity"]);
$v = $v + 1;
}
} else {
Expand All @@ -137,7 +137,7 @@
while ($v <= $traits['image_layers'][$t]['variations']) {
$trait_var = $s . "_" . $v;
$traits["image_layers"][$t]['filenames'][$_POST["trait${trait_var}_name"]] = $_FILES["trait${trait_var}_file"]['name'];
array_push($traits["image_layers"][$t]['weights'], (int)$_POST["trait${trait_var}_rarity"]);
array_push($traits["image_layers"][$t]['weights'], (float)$_POST["trait${trait_var}_rarity"]);
$target_file = $target_dir . "/" . $_FILES["trait${trait_var}_file"]['name'];
move_uploaded_file($_FILES["trait${trait_var}_file"]['tmp_name'], $target_file);
$v = $v + 1;
Expand Down

0 comments on commit ab70a24

Please sign in to comment.