From 319c3c6f3074a283b62a72e58308a9bbcc562a86 Mon Sep 17 00:00:00 2001 From: Vito Date: Wed, 14 Jan 2026 09:58:44 -0600 Subject: [PATCH 1/5] a --- mods/PRNGworldgenlib.js | 83 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/mods/PRNGworldgenlib.js b/mods/PRNGworldgenlib.js index 1125d637..ff3bca23 100644 --- a/mods/PRNGworldgenlib.js +++ b/mods/PRNGworldgenlib.js @@ -14,6 +14,89 @@ let oreChances = { uranium: 0.805, aluminum: 1 } + +let promptMenus = {}; +let keys = ["OK", "Cancel", "Confirm", "Input", "Choices", "Dirs", "Dropdown"]; + +runAfterLoad(()=>{ + let dropDown = document.createElement("select"); + dropDown.id = "promptDropdown"; + dropDown.style.position = "absolute"; + dropDown.style.top = "50%"; + dropDown.style.left = "50%"; + dropDown.title = "prompt"; + dropDown.style.display = "none"; + document.getElementById("promptParent").appendChild(dropDown); + + for(let key of keys){ + promptMenus[key] = document.getElementById(`prompt${key}`); + promptMenus[key].style.display = "none"; + } + + function prompt + + function showPromptScreen() { + if (!promptState) return; + closeMenu("prompt"); + paused = true; + checkPause(); + var promptParent = document.getElementById("promptParent"); + var menuTitle = document.querySelector("#promptMenu .menuTitle"); + menuTitle.innerText = promptState.title || "Notice"; + menuTitle.style.color = promptState.titleColor || "unset"; + var promptMenuText = document.getElementById("promptMenuText"); + promptMenuText.innerText = promptState.text || ""; + if (promptState.html) { + promptMenuText.insertAdjacentHTML("beforeend",promptState.html); + } + let promptOK = document.getElementById("promptOK"); + let promptCancel = document.getElementById("promptCancel"); + let promptConfirm = document.getElementById("promptConfirm"); + let promptInput = document.getElementById("promptInput"); + let promptChoices = document.getElementById("promptChoices"); + let promptDirs = document.getElementById("promptDirs"); + for(let key of promptMenus){ + promptMenus[key].style.display = "none"; + } + promptConfirm.classList.remove("danger"); + if (promptState.type === "text") { + promptOK.style.display = "block"; + } + else if (promptState.type === "confirm") { + promptCancel.style.display = "block"; + promptConfirm.style.display = "block"; + if (promptState.danger) promptConfirm.classList.add("danger"); + } + else if (promptState.type === "input") { + promptInput.value = ""; + promptInput.style.display = "block"; + if (promptState.defaultInput !== undefined) { + promptInput.value = ""+promptState.defaultInput; + } + } + else if (promptState.type === "choose" && promptState.choices) { + promptChoices.innerHTML = ""; + for (let i = 0; i < promptState.choices.length; i++) { + const choice = promptState.choices[i]; + let span = document.createElement("span"); + span.className = "promptChoice"; + span.onclick = function(){ handlePrompt(choice) }; + span.innerText = choice; + promptChoices.appendChild(span); + } + promptChoices.style.display = "block"; + } + else if (promptState.type === "dir") { + promptDirs.style.display = "block"; + } + promptParent.style.display = "block"; + showingMenu = "prompt"; + if (promptState.type === "input") { + document.getElementById("promptInput").focus(); + document.getElementById("promptInput").select(); + } + } +}); function makeCurve(pos, w, dir, div = 200){ let prevX = pos[0], prevY = pos[1]; let res = []; From 7fbee3ebf51f9076e0ce309b3f0ba43699d4487b Mon Sep 17 00:00:00 2001 From: Orchid Date: Thu, 15 Jan 2026 09:41:02 -0600 Subject: [PATCH 2/5] Added dropdown prompt menu --- mods/PRNGworldgenlib.js | 189 ++++++++++++++++++++++++---------------- 1 file changed, 116 insertions(+), 73 deletions(-) diff --git a/mods/PRNGworldgenlib.js b/mods/PRNGworldgenlib.js index ff3bca23..fc20bcb1 100644 --- a/mods/PRNGworldgenlib.js +++ b/mods/PRNGworldgenlib.js @@ -17,86 +17,130 @@ let oreChances = { let promptMenus = {}; let keys = ["OK", "Cancel", "Confirm", "Input", "Choices", "Dirs", "Dropdown"]; - +Object.defineProperty(String.prototype, 'capitalize', { + value: function() { + return this.charAt(0).toUpperCase() + this.slice(1); + }, + enumerable: false +}); runAfterLoad(()=>{ let dropDown = document.createElement("select"); dropDown.id = "promptDropdown"; dropDown.style.position = "absolute"; - dropDown.style.top = "50%"; - dropDown.style.left = "50%"; + dropDown.style.top = "15%"; + dropDown.style.left = "42.5%"; + dropDown.style.width = "15%"; dropDown.title = "prompt"; dropDown.style.display = "none"; - document.getElementById("promptParent").appendChild(dropDown); + document.getElementById("promptMenu").appendChild(dropDown); for(let key of keys){ promptMenus[key] = document.getElementById(`prompt${key}`); promptMenus[key].style.display = "none"; } - function prompt + //function prompt - function showPromptScreen() { - if (!promptState) return; - closeMenu("prompt"); - paused = true; - checkPause(); - var promptParent = document.getElementById("promptParent"); - var menuTitle = document.querySelector("#promptMenu .menuTitle"); - menuTitle.innerText = promptState.title || "Notice"; - menuTitle.style.color = promptState.titleColor || "unset"; - var promptMenuText = document.getElementById("promptMenuText"); - promptMenuText.innerText = promptState.text || ""; - if (promptState.html) { - promptMenuText.insertAdjacentHTML("beforeend",promptState.html); - } - let promptOK = document.getElementById("promptOK"); - let promptCancel = document.getElementById("promptCancel"); - let promptConfirm = document.getElementById("promptConfirm"); - let promptInput = document.getElementById("promptInput"); - let promptChoices = document.getElementById("promptChoices"); - let promptDirs = document.getElementById("promptDirs"); - for(let key of promptMenus){ - promptMenus[key].style.display = "none"; - } - promptConfirm.classList.remove("danger"); - if (promptState.type === "text") { - promptOK.style.display = "block"; - } - else if (promptState.type === "confirm") { - promptCancel.style.display = "block"; - promptConfirm.style.display = "block"; - if (promptState.danger) promptConfirm.classList.add("danger"); - } - else if (promptState.type === "input") { - promptInput.value = ""; - promptInput.style.display = "block"; - if (promptState.defaultInput !== undefined) { - promptInput.value = ""+promptState.defaultInput; - } - } - else if (promptState.type === "choose" && promptState.choices) { - promptChoices.innerHTML = ""; - for (let i = 0; i < promptState.choices.length; i++) { - const choice = promptState.choices[i]; - let span = document.createElement("span"); - span.className = "promptChoice"; - span.onclick = function(){ handlePrompt(choice) }; - span.innerText = choice; - promptChoices.appendChild(span); - } - promptChoices.style.display = "block"; - } - else if (promptState.type === "dir") { - promptDirs.style.display = "block"; - } - promptParent.style.display = "block"; - showingMenu = "prompt"; - if (promptState.type === "input") { - document.getElementById("promptInput").focus(); - document.getElementById("promptInput").select(); + +}); +function showPromptScreen() { + if (!promptState) return; + closeMenu("prompt"); + paused = true; + checkPause(); + var promptParent = document.getElementById("promptParent"); + var menuTitle = document.querySelector("#promptMenu .menuTitle"); + menuTitle.innerText = promptState.title || "Notice"; + menuTitle.style.color = promptState.titleColor || "unset"; + var promptMenuText = document.getElementById("promptMenuText"); + promptMenuText.innerText = promptState.text || ""; + if (promptState.html) { + promptMenuText.insertAdjacentHTML("beforeend",promptState.html); + } + let promptOK = document.getElementById("promptOK"); + let promptCancel = document.getElementById("promptCancel"); + let promptConfirm = document.getElementById("promptConfirm"); + let promptInput = document.getElementById("promptInput"); + let promptChoices = document.getElementById("promptChoices"); + let promptDirs = document.getElementById("promptDirs"); + let dropDown = document.getElementById("promptDropdown"); + for(let key in promptMenus){ + promptMenus[key].style.display = "none"; + } + promptConfirm.classList.remove("danger"); + if (promptState.type === "text") { + promptOK.style.display = "block"; + } + else if (promptState.type === "confirm") { + promptCancel.style.display = "block"; + promptConfirm.style.display = "block"; + if (promptState.danger) promptConfirm.classList.add("danger"); + } + else if (promptState.type === "input") { + promptInput.value = ""; + promptInput.style.display = "block"; + if (promptState.defaultInput !== undefined) { + promptInput.value = ""+promptState.defaultInput; } } -}); + else if (promptState.type === "choose" && promptState.choices) { + promptChoices.innerHTML = ""; + for (let i = 0; i < promptState.choices.length; i++) { + const choice = promptState.choices[i]; + let span = document.createElement("span"); + span.className = "promptChoice"; + span.onclick = function(){ handlePrompt(choice) }; + span.innerText = choice; + promptChoices.appendChild(span); + } + promptChoices.style.display = "block"; + } + else if (promptState.type == "dropdown" && promptState.choices != undefined) { + dropDown.innerHTML = ""; + //promptParent.appendChild(promptDropdown); + + for(let choice of promptState.choices){ + dropDown.innerHTML += ``; + } + let span = document.createElement("span"); + span.className = "promptOK"; + span.textContent = "Select"; + span.onclick = ()=>{ + let c = dropDown.value; + console.log(c); + handlePrompt(c); + document.getElementById("promptMenu").removeChild(span); + }; + document.getElementById("promptMenu").appendChild(span); + dropDown.style.display = "block"; + + } + else if (promptState.type === "dir") { + promptDirs.style.display = "block"; + } + promptParent.style.display = "block"; + showingMenu = "prompt"; + if (promptState.type === "input") { + document.getElementById("promptInput").focus(); + document.getElementById("promptInput").select(); + } +} + +function promptDropdown(title, choices, handler){ + let pause = false; + if (promptState) { pause = promptState.wasPaused } + else if (paused) { pause = true } + promptState = { + type: "dropdown", + text: "", + choices: choices, + handler: handler, + title: title || "Choose", + wasPaused: pause + } + showPromptScreen(); +} + function makeCurve(pos, w, dir, div = 200){ let prevX = pos[0], prevY = pos[1]; let res = []; @@ -408,16 +452,15 @@ elements.SeedGenerate = { let arr = []; let txt = shiftDown; Object.keys(biomes).forEach(function(b){arr.push(b);}); - txt = (arr.length >= 7) ? true : txt; promptInput("Leave blank to generate new seed or C to keep current seed. Your current seed is: " + seed, function(i){ seed = (i != null && i.toLowerCase() == "c") ? seed : parseFloat(i) || Math.random()*(2**32); seed = seed % (2**32); if(!txt){ - promptChoose("", arr, (choice)=>{ + promptDropdown( "Select a biome to generate: ", arr, (choice)=>{ biomes[choice].generate(seed); promptText("World generation complete."); selectElement('dirt'); - }, "Select a biome to generate: "); + }); } else { let str = ""; for(let key in biomes){ @@ -443,7 +486,6 @@ elements.RandomGen = { let arr = []; let txt = shiftDown; Object.keys(biomes).forEach(function(b){arr.push(b);}); - txt = (arr.length >= 7) ? true : txt; seed = Math.random()*(2**32); //seed %= 2**32; if(txt){ @@ -465,10 +507,11 @@ elements.RandomGen = { }, "Enter Biome Name: "); } else { - promptChoose("", arr, (choice)=>{ - biomes[choice].generate(seed); - selectElement("dirt"); - }, "Biome Selection"); + promptDropdown( "Select a biome to generate: ", arr, (choice)=>{ + biomes[choice].generate(seed); + promptText("World generation complete."); + selectElement('dirt'); + }); } }, } From 5e857a4a93ed7a1b08396671c908130ad1c9e835 Mon Sep 17 00:00:00 2001 From: Orchid Date: Thu, 15 Jan 2026 09:43:19 -0600 Subject: [PATCH 3/5] Added dropdown prompt --- mods/PRNGworldgenlib.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/PRNGworldgenlib.js b/mods/PRNGworldgenlib.js index fc20bcb1..67cf1b96 100644 --- a/mods/PRNGworldgenlib.js +++ b/mods/PRNGworldgenlib.js @@ -515,6 +515,7 @@ elements.RandomGen = { } }, } + elements.view_seed = { category: "edit", onSelect: function(){ From 63b6bddd69999e1fe0b90811e83965a6e6ea25cc Mon Sep 17 00:00:00 2001 From: Orchid Date: Thu, 15 Jan 2026 09:44:32 -0600 Subject: [PATCH 4/5] Added dropdown prompt --- mods/PRNGworldgenlib.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/PRNGworldgenlib.js b/mods/PRNGworldgenlib.js index 67cf1b96..0fcad410 100644 --- a/mods/PRNGworldgenlib.js +++ b/mods/PRNGworldgenlib.js @@ -43,6 +43,7 @@ runAfterLoad(()=>{ }); + function showPromptScreen() { if (!promptState) return; closeMenu("prompt"); From ac7317302294fecdee2fd4fb106f3204029e8c13 Mon Sep 17 00:00:00 2001 From: OrchidtheDev <124483815+orchidthedev@users.noreply.github.com> Date: Thu, 15 Jan 2026 09:45:57 -0600 Subject: [PATCH 5/5] updated version comment --- mods/PRNGworldgenlib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/PRNGworldgenlib.js b/mods/PRNGworldgenlib.js index 0fcad410..48d5d0e8 100644 --- a/mods/PRNGworldgenlib.js +++ b/mods/PRNGworldgenlib.js @@ -1,4 +1,4 @@ -/*Version 1.2.0 Pseudorandom world generator*/ +/*Version 1.2.1 Pseudorandom world generator*/ function pseudorandom(key, num, max = 1){ return (Math.log(key)*(num*Math.log(1625.4986772154357))) % max; };