Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Custom ###

companion/
all-traits.json
gen-stats.json
traits.json
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.1.0a
27 changes: 25 additions & 2 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ h3 {
}

h4 {
width: 500px;
width: 100%;
text-align: left;
font-size: 16px;
margin: 10px 0;
margin: 10px 0 0 10px;
}

h5 {
font-size: 16px;
}

a,
Expand All @@ -76,6 +80,25 @@ form {
justify-content: space-around;
}

hr {
width: calc(100% + 10px);
height: 5px;
margin: 8px 0;
border: 1px solid #000;
}

.hrbottom {
border-top: none;
border-radius: 0;
box-shadow: 0 3px 5px #22243a;
}

.hrtop {
border-bottom: none;
border-radius: 0;
box-shadow: 0 -3px 5px #22243a;
}

.content {
margin: 10px 0;
width: 950px;
Expand Down
86 changes: 57 additions & 29 deletions php/edit/3.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@
let rarities = [];
// Build rarities array (rarities[t][v] = r => Trair 't', variation 'v' has rarity 'r'%)
for (const input of form) {
const match = input.id.match(/trait(\d+)_(\d+)_rarity/);
const match = input.id.match(/trait(\d+)_(\d+|empty)_rarity/);
if (match) {
const [/*ignore*/, trait, variation] = match;
if (rarities[trait] === undefined) {
rarities[trait] = [];
}
rarities[trait][variation-1] = parseFloat(input.value);
if (variation === 'empty') {
rarities[trait]['empty'] = parseFloat(input.value);
} else {
rarities[trait][variation-1] = parseFloat(input.value);
}
}
}
// Iterate through rarities backwards and make sure the sum is 100, or display message
const first_t = (rarities[0] === undefined) ? 1 : 0;
for (let t = rarities.length - 1; t >= first_t; t--) {
console.log(t);
const errorH3 = document.getElementById(`trait${t}_error`);
const sum = rarities[t].reduce((cum, el) => cum + el, 0);
if (sum !== 100) {
const sum = rarities[t].reduce((cum, el) => cum + el, 0) + rarities[t]['empty'];
if (abs(sum - 100) > 1e-6) { // Float comparison for sum == 100, avoids rounding errors
errorH3.innerHTML = `The rarity percentages should add up to 100% (not ${sum}%)`;
errorH3.hidden = false;
window.location.hash = `trait${t}`;
Expand Down Expand Up @@ -82,14 +85,18 @@
<form enctype="multipart/form-data" onSubmit="return rarityCheck(this);" method="post" action="/edit/3?collection=<?php echo $collection; ?>">
<?php $t = 0;
while ($s <= $new_traits['trait_count']) {
if ($t == 0 and $new_traits['background_color'] === true) {
if ($t == 0 and $new_traits['background_color'] === true) { // Background color layer
unset($layer);
$weights_empty = false;
if (($traits['background_color'] === true) and isset($traits['image_layers'][$s])) {
$layer = $traits["image_layers"][$s];
if (isset($layer['weights_total']) && isset($layer['weights'])) {
$weights_empty = $layer['weights_total'] - array_sum($layer['weights']);
}
} ?>
<h3 class="trait-title" id="trait<?php echo $s; ?>">Setup Background Colors:</h3>
<h3 hidden class="error" id="trait<?php echo $s; ?>_error">No error</h3>
<?php $v = 1; while ($v <= $new_traits["image_layers"][$s]['variations']) {
<?php $v = 1; while ($v <= $new_traits["image_layers"][$s]['variations']) { // Background color variations
$trait_var = $s . "_" . $v;
unset($var_name);
if (isset($layer) and isset($layer['weights'][$v - 1])) {
Expand All @@ -100,35 +107,43 @@
}, $rgb));
$opacity = $layer['rgba'][$var_name][3];
} ?>
<h4>Color #<?php echo $v ?>:</h4>
<div data-tooltip="Display Name: The pretty name of this variation">
<input required type="text" class="form wide" id="trait<?php echo $trait_var ?>_name" name="trait<?php echo $trait_var ?>_name" placeholder="Color Display Name" value="<?php echo isset($var_name) ? $var_name : null; ?>" />
</div>
<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" 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 />
<input required type="color" class="form small" id="trait<?php echo $trait_var ?>_color" name="trait<?php echo $trait_var ?>_color" value="<?php echo isset($var_name) ? $color_hex : '#000000'; ?>" />
<hr class="hrtop" />
<div>
<h4>Color #<?php echo $v ?>:</h4>
<div data-tooltip="Display Name: The pretty name of this variation">
<input required type="text" class="form wide" id="trait<?php echo $trait_var ?>_name" name="trait<?php echo $trait_var ?>_name" placeholder="Color Display Name" value="<?php echo isset($var_name) ? $var_name : null; ?>" />
</div>
<div data-tooltip="Opacity: The transparency of this background variation&#xa;(0: invisible, 255: opaque)">
<label for="trait<?php echo $trait_var ?>_a">Opacity:</label><br />
<input required type="number" class="form small" id="trait<?php echo $trait_var ?>_alpha" min="0" max="255" name="trait<?php echo $trait_var ?>_alpha" placeholder="0-255" value="<?php echo isset($var_name) ? $opacity : 255; ?>" />
<div class="trait-row">
<div data-tooltip="Color: The color of this background variation">
<label for="trait<?php echo $trait_var ?>_r">Color:</label><br />
<input required type="color" class="form small" id="trait<?php echo $trait_var ?>_color" name="trait<?php echo $trait_var ?>_color" value="<?php echo isset($var_name) ? $color_hex : '#000000'; ?>" />
</div>
<div data-tooltip="Opacity: The transparency of this background variation&#xa;(0: invisible, 255: opaque)">
<label for="trait<?php echo $trait_var ?>_a">Opacity:</label><br />
<input required type="number" class="form small" id="trait<?php echo $trait_var ?>_alpha" min="0" max="255" name="trait<?php echo $trait_var ?>_alpha" placeholder="0-255" value="<?php echo isset($var_name) ? $opacity : 255; ?>" />
</div>
<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" 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>
</div>
<hr class="hrbottom" />
<?php $v = $v + 1; }
} else {
} else { // Image layers
$s_offset = 0;
if ($traits['background_color'] === false) { $s_offset = -1; }
unset($layer);
$weights_empty = false;
if (isset($traits['image_layers'][$s + $s_offset])) {
$layer = $traits["image_layers"][$s + $s_offset];
if (isset($layer['weights_total']) && isset($layer['weights'])) {
$weights_empty = $layer['weights_total'] - array_sum($layer['weights']);
}
} ?>
<h3 class="trait-title" id="trait<?php echo $s; ?>">Setup "<?php echo $new_traits['image_layers'][$t]['layer_name']; ?>" Trait:</h3>
<h3 hidden class="error" id="trait<?php echo $s; ?>_error">No error</h3>
<?php $v = 1; while ($v <= $new_traits['image_layers'][$t]['variations']) {
<?php $v = 1; while ($v <= $new_traits['image_layers'][$t]['variations']) { // Image layers variations
$trait_var = $s . "_" . $v;
unset($var_name);
if (isset($layer) and isset($layer['weights'][$v - 1])) {
Expand All @@ -137,15 +152,12 @@
$filepath = "./collections/" . $collection . "/config/source_layers/layer" . sprintf('%02d', $s) . "/" . $filename;
$file_exists = file_exists($filepath);
} ?>
<hr class="hrtop" />
<h4>Variation #<?php echo $v ?>:</h4>
<div data-tooltip="Display Name: The pretty name of this variation">
<input required type="text" class="form wide" id="trait<?php echo $trait_var ?>_name" name="trait<?php echo $trait_var ?>_name" placeholder="Variation #<?php echo $v ?> Name" value="<?php echo isset($var_name) ? $var_name : null; ?>" />
</div>
<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" 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 />
<?php if (isset($var_name) and $file_exists) { // File exists, pre-fill field with filename (no need to upload it again) ?>
Expand All @@ -154,9 +166,23 @@
<input required type="file" class="form med" id="trait<?php echo $trait_var ?>_file" name="trait<?php echo $trait_var ?>_file" onChange="setNameFromFilename(this);" />
<?php } ?>
</div>
<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" 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>
<hr class="hrbottom" />
<?php $v = $v + 1; }
}
$trait_var = $s . "_empty"; ?>
<div class="trait-row" data-tooltip="Chance for the whole layer to be skipped, in percent">
<h5 class="small">Skip layer:</h5>
<div>
<label for="trait<?php echo $trait_var ?>_rarity">Set Rarity:</label>
<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 $weights_empty === false ? null : $weights_empty; ?>">&nbsp;%
</div>
</div>
<?php
$t = $t + 1;
$s = $s + 1;
} ?>
Expand All @@ -182,14 +208,15 @@
array_push($new_traits["image_layers"][$t]['weights'], (float)$_POST["trait${trait_var}_rarity"]);
$v = $v + 1;
}
$new_traits["image_layers"][$t]['weights_total'] = (float)$_POST["trait${s}_empty_rarity"] + array_sum($new_traits["image_layers"][$t]['weights']); // Should be 100
} else {
$v = 1;
$new_traits["image_layers"][$t]['filenames'] = array();
$new_traits["image_layers"][$t]['weights'] = array();
while ($v <= $new_traits['image_layers'][$t]['variations']) {
$trait_var = $s . "_" . $v;
$var_name = $_POST["trait${trait_var}_name"];
$var_weight =(float)$_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 All @@ -205,6 +232,7 @@
array_push($new_traits["image_layers"][$t]['weights'], $var_weight); // Add weights to weight array
$v = $v + 1;
}
$new_traits["image_layers"][$t]['weights_total'] = (float)$_POST["trait${s}_empty_rarity"] + array_sum($new_traits["image_layers"][$t]['weights']); // Should be 100
}
$t = $t + 1;
$s = $s + 1;
Expand Down
2 changes: 1 addition & 1 deletion php/mint.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

if (empty($_GET['run']) and (empty($_POST['cid']) or empty($_POST['amount']))) { ?>
<form method="post" action="/mint">
<h3 class="warning">You will not receive estimated fees, this runs the commands with current prices.</h3>
<h3 class="warning">You will receive estimated fees in the review screen</h3>
<h3 class="info">Current Gas: <?php echo number_format((float)$gas, 2, '.', ''); ?> Gwei</h3>
<h3>Minter Options</h3>
<section id="artist">
Expand Down
Loading