WI disable/constant checkboxes to tristate select

This commit is contained in:
RossAscends 2023-10-01 10:21:19 +09:00
parent 165997c791
commit 7771ecb0d0
3 changed files with 90 additions and 3 deletions

View File

@ -160,3 +160,12 @@
#world_info_search { #world_info_search {
width: 10em; width: 10em;
} }
.disabledWIEntry {
opacity: 0.2;
filter: grayscale(1);
}
.height32px {
height: 32px;
}

View File

@ -3910,7 +3910,13 @@
<span class="drag-handle">&#9776;</span> <span class="drag-handle">&#9776;</span>
<div class="gap5px world_entry_thin_controls wide100p alignitemscenter"> <div class="gap5px world_entry_thin_controls wide100p alignitemscenter">
<small> <small>
<span><span class="world_entry_form_position_value"></span> <span>
<span class="world_entry_form_position_value"></span>
<select name="entryStateSelector" class="widthNatural height32px margin0">
<option value="constant">!</option>
<option value="normal">O</option>
<option value="disabled">X</option>
</select>
</span> </span>
</small> </small>
<div class="world_entry_form_control flex1"> <div class="world_entry_form_control flex1">
@ -3996,6 +4002,7 @@
</div> </div>
<div name="WIEntryBottomControls" class="flex-container flex1 justifySpaceBetween world_entry_form_horizontal"> <div name="WIEntryBottomControls" class="flex-container flex1 justifySpaceBetween world_entry_form_horizontal">
<div class="flex-container flexFlowColumn flexNoGap wi-enter-footer-text "> <div class="flex-container flexFlowColumn flexNoGap wi-enter-footer-text ">
<!--
<label class="checkbox flex-container"> <label class="checkbox flex-container">
<input type="checkbox" name="constant" /> <input type="checkbox" name="constant" />
<span data-i18n="Constant">Constant</span> <span data-i18n="Constant">Constant</span>
@ -4004,6 +4011,7 @@
<input type="checkbox" name="disable" /> <input type="checkbox" name="disable" />
<span data-i18n="Disable">Disable</span> <span data-i18n="Disable">Disable</span>
</label> </label>
-->
<label class="checkbox flex-container"> <label class="checkbox flex-container">
<input type="checkbox" name="selective" /> <input type="checkbox" name="selective" />
<span data-i18n="Selective">Selective</span> <span data-i18n="Selective">Selective</span>

View File

@ -451,6 +451,10 @@ function getWorldEntry(name, data, entry) {
const selectiveLogicDropdown = template.find('select[name="entryLogicType"]'); const selectiveLogicDropdown = template.find('select[name="entryLogicType"]');
selectiveLogicDropdown.data("uid", entry.uid); selectiveLogicDropdown.data("uid", entry.uid);
selectiveLogicDropdown.on("click", function (event) {
event.stopPropagation();
})
selectiveLogicDropdown.on("input", function () { selectiveLogicDropdown.on("input", function () {
const uid = $(this).data("uid"); const uid = $(this).data("uid");
const value = Number($(this).val()); const value = Number($(this).val());
@ -662,6 +666,7 @@ function getWorldEntry(name, data, entry) {
// constant // constant
/*
const constantInput = template.find('input[name="constant"]'); const constantInput = template.find('input[name="constant"]');
constantInput.data("uid", entry.uid); constantInput.data("uid", entry.uid);
constantInput.on("input", function () { constantInput.on("input", function () {
@ -672,6 +677,7 @@ function getWorldEntry(name, data, entry) {
saveWorldInfo(name, data); saveWorldInfo(name, data);
}); });
constantInput.prop("checked", entry.constant).trigger("input"); constantInput.prop("checked", entry.constant).trigger("input");
*/
// order // order
const orderInput = template.find('input[name="order"]'); const orderInput = template.find('input[name="order"]');
@ -797,6 +803,7 @@ function getWorldEntry(name, data, entry) {
template.find(".world_entry_form_uid_value").text(`(UID: ${entry.uid})`); template.find(".world_entry_form_uid_value").text(`(UID: ${entry.uid})`);
// disable // disable
/*
const disableInput = template.find('input[name="disable"]'); const disableInput = template.find('input[name="disable"]');
disableInput.data("uid", entry.uid); disableInput.data("uid", entry.uid);
disableInput.on("input", function () { disableInput.on("input", function () {
@ -807,6 +814,70 @@ function getWorldEntry(name, data, entry) {
saveWorldInfo(name, data); saveWorldInfo(name, data);
}); });
disableInput.prop("checked", entry.disable).trigger("input"); disableInput.prop("checked", entry.disable).trigger("input");
*/
//new tri-state selector for constant/normal/disabled
const entryStateSelector = template.find('select[name="entryStateSelector"]');
entryStateSelector.data("uid", entry.uid);
console.log(entry.uid)
entryStateSelector.on("click", function (event) {
// Prevent closing the drawer on clicking the input
event.stopPropagation();
});
entryStateSelector.on("input", function () {
const uid = entry.uid;
const value = $(this).val();
switch (value) {
case "constant":
data.entries[uid].constant = true;
data.entries[uid].disable = false;
setOriginalDataValue(data, uid, "enabled", true);
setOriginalDataValue(data, uid, "constant", true);
template.removeClass('disabledWIEntry');
console.debug("set to constant")
break
case "normal":
data.entries[uid].constant = false;
data.entries[uid].disable = false;
setOriginalDataValue(data, uid, "enabled", true);
setOriginalDataValue(data, uid, "constant", false);
template.removeClass('disabledWIEntry');
console.debug("set to normal")
break
case "disabled":
data.entries[uid].constant = false;
data.entries[uid].disable = true;
setOriginalDataValue(data, uid, "enabled", false);
setOriginalDataValue(data, uid, "constant", false);
template.addClass('disabledWIEntry');
console.debug("set to disabled")
break
}
saveWorldInfo(name, data);
})
const entryState = function () {
console.log(`constant: ${entry.constant}, disabled: ${entry.disable}`)
if (entry.constant === true) {
console.debug('found constant')
return "constant"
} else if (entry.disable === true) {
console.debug('found disabled')
return "disabled"
} else {
console.debug('found normal')
return "normal"
}
}
template
.find(`select[name="entryStateSelector"] option[value=${entryState()}]`)
.prop("selected", true)
.trigger("input");
saveWorldInfo(name, data);
// exclude recursion // exclude recursion
const excludeRecursionInput = template.find('input[name="exclude_recursion"]'); const excludeRecursionInput = template.find('input[name="exclude_recursion"]');
@ -837,7 +908,6 @@ function getWorldEntry(name, data, entry) {
// display position/order info left of keyword box // display position/order info left of keyword box
let entry = data.entries[uid] let entry = data.entries[uid]
let posText = entry.position let posText = entry.position
console.log(posText)
switch (entry.position) { switch (entry.position) {
case 0: case 0:
posText = '↑CD'; posText = '↑CD';