-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsettings.html
112 lines (98 loc) · 4.11 KB
/
settings.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body role="application" class="unselectable">
<script src="translate.js"></script>
<script>
const { ipcRenderer } = require("electron");
ipcRenderer.on("sendSettings", (e, params) => {
for (let key in params) {
setInnerHtml(key, params[key]);
}
});
function setInnerHtml(elementId, value) {
if(!document.getElementById(elementId)) return
if (document.getElementById(elementId).type == "checkbox") {
document.getElementById(elementId).checked = value;
} else {
document.getElementById(elementId).value = value;
}
}
function noWater() {
setSetting("seaLevel", -Infinity);
}
function setSetting(setting, value = document.getElementById(setting).value) {
ipcRenderer.send("setting", setting, parseFloat(value));
}
function settingsToggle(setting, value = document.getElementById(setting).checked) {
ipcRenderer.send("setting", setting, value);
}
function reset() {
ipcRenderer.send("resetSettings");
//seaLevel is separate from other settings
setTimeout(() => {
setInnerHtml("seaLevel", 0);
setSetting("seaLevel");
}, 200);
}
function randomize() {
let params = {
resolution: Math.floor(Math.random() * 462) + 50,
hilliness: Math.floor(Math.random() * 36) + 15,
baseHumidity: Math.floor(Math.random() * 500) - 250,
seaLevel: Math.floor(Math.random() * 600) - 300,
generateStructures: Math.random() >= 0.5
}
//only randomizes advanced settings if they are visible
if (document.getElementById("showless")) {
params = {
...params,
humidityRange: Math.floor(Math.random() * 17) + 3,
granularScale: (Math.random() * 0.08) + 0.02,
}
}
for (let key in params) {
setInnerHtml(key, params[key]);
if(document.getElementById(key).type == "checkbox"){
settingsToggle(key);
}else{
setSetting(key);
}
}
}
</script>
<script defer src="showhide.js"></script>
<h2><label for="hilliness" id="hillinessHeader">Hilliness</label></h2>
<input type="range" role="slider" min="15" step="0.5" max="50" id="hilliness" onInput="setSetting('hilliness');" />
<h2><label for="baseHumdity" id="humidityHeader">Humidity</label></h2>
<input type="range" min="-250" max="250" id="baseHumidity" onInput="setSetting('baseHumidity');" />
<h2><label for="seaLevel" id="seaLevelHeader">Sea Level</label></h2>
<input type="range" min="-300" max="300" id="seaLevel" onInput="setSetting('seaLevel');" />
<h2><label for="resolution" id="resolutionHeader">Map Size</label></h2>
<input type="range" min="50" max="512" id="resolution" onInput="setSetting('resolution');" />
<h2><label for="generateStructures" id="genStructuresHeader">Generate Structures</label></h2>
<input type="checkbox" id="generateStructures" value="true" onclick="settingsToggle('generateStructures')"/>
<hr />
<a id="showmore" tabindex="0" onkeypress="toggleShow('advanced')" onclick="toggleShow('advanced')">Show more</a>
<div id="advanced" style="display:none">
<h3 id="advancedSettings">Advanced Settings</h3>
<h2><label for="granularScale" id="granularHeader">Granular Scale</label></h2>
<input type="range" min="0.02" max="0.1" step="0.001" id="granularScale" onInput="setSetting('granularScale')" />
<h2><label for="humidityRange" id="humidityRangeHeader">Humidity Range</label></h2>
<input type="range" min="3" max="20" step="0.25" id="humidityRange" onInput="setSetting('humidityRange')" />
<h2><label for="waterDrawRate" id="waterDrawRateHeader">Water Draw Rate</label></h2>
<input type="range" min="300" max="1100" step="50" id="waterDrawRate" onInput="setSetting('waterDrawRate')" />
<button id="removeWater" onclick="noWater()">Remove Water</button>
<h2><label for="retainParams" id="retainParamsHeader">Retain Settings</label></h2>
<input type="checkbox" id="retainParams" value="true" onclick="settingsToggle('retainParams')"/>
</div>
<hr />
<div class="button-container">
<button id="resetSettings" onclick="reset()">Reset</button>
<button id="randomize" onclick="randomize()">Random Settings</button>
</div>
</body>
</html>