Skip to content

Commit 053861f

Browse files
committed
Migrate most sliders in ore settings away from MalisisCore
1 parent e924c74 commit 053861f

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/customcubic/gui/OreSettingsTab.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ class OreSettingsTab {
122122
: null;
123123
return CustomGenSettingsSerialization.MARSHALLER.serialize(biomes);
124124
})
125-
.setPrimitive("spawnSize", ore -> ore.size.getValue())
126-
.setPrimitive("spawnTries", ore -> ore.attempts.getValue())
127-
.setPrimitive("spawnProbability", ore -> ore.probability.getValue())
125+
.setPrimitive("spawnSize", ore -> (int) Math.round(ore.size.getSliderValue()))
126+
.setPrimitive("spawnTries", ore -> (int) Math.round(ore.attempts.getSliderValue()))
127+
.setPrimitive("spawnProbability", ore -> ore.probability.getSliderValue())
128128
.setPrimitive("minHeight", ore -> ore.heightRange.getMinValue())
129129
.setPrimitive("maxHeight", ore -> ore.heightRange.getMaxValue())
130130
.setPrimitiveIf(ore -> ore.genType == OreGenType.PERIODIC_GAUSSIAN, "heightMean", ore -> ore.mean.getSliderValue())
131-
.setPrimitiveIf(ore -> ore.genType == OreGenType.PERIODIC_GAUSSIAN, "heightStdDeviation", ore -> ore.stdDev.getValue())
131+
.setPrimitiveIf(ore -> ore.genType == OreGenType.PERIODIC_GAUSSIAN, "heightStdDeviation", ore -> ore.stdDev.getSliderValue())
132132
.setPrimitiveIf(ore -> ore.genType == OreGenType.PERIODIC_GAUSSIAN, "heightSpacing", ore -> ore.spacing.getValue())
133133
.build();
134134

@@ -251,15 +251,15 @@ private class UIOreOptionEntry extends UIVerticalTableLayout<UIOreOptionEntry> {
251251
private UIBlockStateButton<?> block;
252252
private UIComponent<?> name;
253253

254-
private UISlider<Integer> size;
255-
private UISlider<Integer> attempts;
254+
private CwgGuiSlider size;
255+
private CwgGuiSlider attempts;
256256

257257
private CwgGuiSlider mean;
258258
private UISlider<Float> spacing;
259259

260-
private UISlider<Float> stdDev;
260+
private CwgGuiSlider stdDev;
261261

262-
private UISlider<Float> probability;
262+
private CwgGuiSlider probability;
263263
private UICheckBox selectBiomes;
264264

265265
private UIRangeSlider<Float> heightRange;
@@ -282,21 +282,30 @@ private void init(ExtraGui gui) {
282282
this.name = makeLabel(gui);
283283
UIButton delete = new UIButton(gui, malisisText("delete")).setSize(10, 20).setAutoSize(false);
284284
UISelect<OreGenType> type = makeUISelect(gui, Arrays.asList(OreGenType.values()));
285-
this.size = makeIntSlider(gui, malisisText("spawn_size", " %d"), 1, 50, conf.getInt("spawnSize"));
286-
this.attempts = makeIntSlider(gui, malisisText("spawn_tries", " %d"), 1, 40, conf.getInt("spawnTries"));
285+
286+
this.size = GuiFactory.makeSlider(1, 50, conf.getDouble("spawnSize"),
287+
CustomCubicMod.MODID + ".gui.cubicgen.spawn_size",
288+
value -> Long.toString(Math.round(value)));
289+
this.attempts = GuiFactory.makeSlider(1, 40, conf.getDouble("spawnTries"),
290+
CustomCubicMod.MODID + ".gui.cubicgen.spawn_tries",
291+
value -> Long.toString(Math.round(value)));
287292
if (genType == OreGenType.PERIODIC_GAUSSIAN) {
288293
this.mean = GuiFactory.makeSlider(-4.0, 4.0, conf.getDouble("heightMean"),
289294
CustomCubicMod.MODID + ".gui.cubicgen.mean_height",
290295
value -> String.format("%.3f (%.1f)", value, value * heightVariation.getAsDouble()));
291296

292297
this.spacing = makePositiveExponentialSlider(gui, -1f, 6.0f, conf.getFloat("heightSpacing"), getTranslation("spacing_height"));
293-
this.stdDev = makeFloatSlider(gui, 0f, 1f, conf.getFloat("heightStdDeviation"), getTranslation("height_std_dev"));
298+
this.stdDev = GuiFactory.makeSlider(0, 1, conf.getDouble("heightStdDeviation"),
299+
CustomCubicMod.MODID + ".gui.cubicgen.height_std_dev",
300+
value -> String.format("%.3f (%.1f)", value, value * heightVariation.getAsDouble()));
294301
} else {
295302
this.mean = null;
296303
this.spacing = null;
297304
this.stdDev = null;
298305
}
299-
this.probability = makeFloatSlider(gui, malisisText("spawn_probability", " %.3f"), conf.getFloat("spawnProbability"));
306+
this.probability = GuiFactory.makeSlider(0, 1, conf.getDouble("spawnProbability"),
307+
CustomCubicMod.MODID + ".gui.cubicgen.spawn_probability",
308+
value -> String.format("%.3f", value));
300309
this.selectBiomes = makeCheckbox(gui, malisisText("select_biomes"), !conf.get("biomes").equals(JsonNull.INSTANCE));
301310
this.heightRange = makeOreHeightSlider(gui, vanillaText("spawn_range"), -2.0f, 2.0f,
302311
conf.getFloat("minHeight"), conf.getFloat("maxHeight"), baseHeight, heightVariation);
@@ -385,14 +394,14 @@ int writeJson(JsonObjectView rootJson) {
385394

386395
private void setupMainArea(UIVerticalTableLayout<?> mainArea) {
387396
int y = -1;
388-
mainArea.add(this.size, new GridLocation(0, ++y, 3));
389-
mainArea.add(this.attempts, new GridLocation(3, y, 3));
390-
mainArea.add(this.probability, new GridLocation(0, ++y, 3));
397+
mainArea.add(new WrappedVanillaButton<>(getGui(), this.size), new GridLocation(0, ++y, 3));
398+
mainArea.add(new WrappedVanillaButton<>(getGui(), this.attempts), new GridLocation(3, y, 3));
399+
mainArea.add(new WrappedVanillaButton<>(getGui(), this.probability), new GridLocation(0, ++y, 3));
391400
mainArea.add(this.selectBiomes, new GridLocation(3, y, 3));
392401
if (this.genType == OreGenType.PERIODIC_GAUSSIAN) {
393402
mainArea.add(new WrappedVanillaButton<>(getGui(), this.mean), new GridLocation(0, ++y, 3));
394403
mainArea.add(this.spacing, new GridLocation(3, y, 3));
395-
mainArea.add(this.stdDev, new GridLocation(0, ++y, 6));
404+
mainArea.add(new WrappedVanillaButton<>(getGui(), this.stdDev), new GridLocation(0, ++y, 6));
396405
}
397406
mainArea.add(this.heightRange, new GridLocation(0, ++y, 6));
398407
}

src/main/resources/assets/cubicgen/lang/en_us.lang

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ cubicgen.gui.cubicgen.delete=Delete
8080

8181
cubicgen.gui.cubicgen.select_biomes=Restrict to biomes...
8282

83-
cubicgen.gui.cubicgen.spawn_size=Spawn Size:
84-
cubicgen.gui.cubicgen.spawn_tries=Spawn Tries:
85-
cubicgen.gui.cubicgen.spawn_probability=Probability:
83+
cubicgen.gui.cubicgen.spawn_size=Spawn Size: %s
84+
cubicgen.gui.cubicgen.spawn_tries=Spawn Tries: %s
85+
cubicgen.gui.cubicgen.spawn_probability=Probability: %s
8686
cubicgen.gui.cubicgen.spawn_maxprobability=Max. Probability:
8787
cubicgen.gui.cubicgen.spawn_range=Height %s%%%% to %s%%%% (blocks: %s to %s)
8888

8989
cubicgen.gui.cubicgen.mean_height=Center of first belt: %s
90-
cubicgen.gui.cubicgen.height_std_dev=Height Std. Dev. Factor: %s%%%% (blocks: %s)
90+
cubicgen.gui.cubicgen.height_std_dev=Height Std. Dev. Factor: %s
9191
cubicgen.gui.cubicgen.spacing_height=Height Spacing: %s%%%% (blocks: %s)
9292

9393
#################################

0 commit comments

Comments
 (0)