crumblingstatue / FloweysTimeMachine

Undertale SAVE editor
http://crumblingstatue.github.io/FloweysTimeMachine
115 stars 37 forks source link

Numeric ID Location fields #77

Closed vinceh121 closed 2 years ago

vinceh121 commented 2 years ago

A lot of resources about Undertale, like the fandom wiki, reference rooms by their IDs, which makes finding the exact map referenced rather complicated with only names selectable. This PR implements a numeric field next to location inputs that allows users to directly input the location ID they want.

KockaAdmiralac commented 2 years ago

It looks like when an ID field is changed, the allowed location fields sync between themselves and both set the selected location to null. I'm not sure if this behavior was intentional in the first place (@Jacky720?) but it makes the feature this PR introduces pretty annoying (you change the INI location ID, the SAVE location resets to null, then you try to change the SAVE location ID and the INI location ID resets to null). Can you add a check for whether the allowed locations changed at all, and if they haven't don't update the values of selected locations?

Jacky720 commented 2 years ago

It's not intentional. The check on line 903 of main.js was dependent on null == undefined until we upgraded everything to ===. Kocka can fix the function calls with nulls to use undefined a lot easier than I can.

KockaAdmiralac commented 2 years ago

Or you can just apply the diff in this PR (instead of doing what I mentioned previously):

diff --git a/main.js b/main.js
index 7ba77b5..26a4598 100644
--- a/main.js
+++ b/main.js
@@ -1297,23 +1297,23 @@ function start() {
     var allowedLocations2 = document.getElementById("allowed-locations-2");
     const updateAllowedLocations1 = () => {
         allowedLocations2.value = allowedLocations1.value;
-        updateSelection("ini-location", null, rooms[allowedLocations1.value]);
-        updateSelection("sav-location", null, rooms[allowedLocations1.value]);
+        updateSelection("ini-location", undefined, rooms[allowedLocations1.value]);
+        updateSelection("sav-location", undefined, rooms[allowedLocations1.value]);
     };
     const updateAllowedLocations2 = () => {
         allowedLocations1.value = allowedLocations2.value;
-        updateSelection("ini-location", null, rooms[allowedLocations1.value]);
-        updateSelection("sav-location", null, rooms[allowedLocations1.value]);
+        updateSelection("ini-location", undefined, rooms[allowedLocations1.value]);
+        updateSelection("sav-location", undefined, rooms[allowedLocations1.value]);
     };
     allowedLocations1.addEventListener("change", updateAllowedLocations1);
     allowedLocations2.addEventListener("change", updateAllowedLocations2);
     document.getElementById("allow-non-equipables").addEventListener("change", function() {
         if (document.getElementById("allow-non-equipables").checked) {
-            updateSelection("sav-weapon", null, items);
-            updateSelection("sav-armor",  null, items);
+            updateSelection("sav-weapon", undefined, items);
+            updateSelection("sav-armor",  undefined, items);
         } else {
-            updateSelection("sav-weapon", null, weapons);
-            updateSelection("sav-armor",  null, armors);
+            updateSelection("sav-weapon", undefined, weapons);
+            updateSelection("sav-armor",  undefined, armors);
         }
     });
     document.getElementById("sav-havecell").addEventListener("change", function() {
vinceh121 commented 2 years ago

Indeed I hadn't noticed this bug. I've applied your diff.