]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blob - src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
Move displaying screens to ClientInterop
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / SettingsScreen.java
1 package com.irtimaled.bbor.client.gui;
2
3 import com.irtimaled.bbor.client.ClientRenderer;
4 import com.irtimaled.bbor.client.interop.ClientInterop;
5 import com.irtimaled.bbor.common.BoundingBoxType;
6 import com.irtimaled.bbor.config.ConfigManager;
7 import net.minecraft.client.gui.GuiScreen;
8 import net.minecraft.client.resources.I18n;
9
10 public class SettingsScreen extends ListScreen {
11     private static final String pillagerOutpostVersionPattern = "(?:1\\.1[4-9]|1\\.[2-9][0-9]|18w(?:4[7-9]|5[0-9])|19w|2[0-9]w).*";
12     private static final String bastionRemnantVersionPattern = "(?:1\\.1[6-9]|1\\.[2-9][0-9]|20w(?:1[6-9]|[2-5][0-9])|2[1-9]w).*";
13     private static final String netherFossilVersionPattern = "(?:1\\.1[6-9]|1\\.[2-9][0-9]|20w(?:1[1-9]|[2-5][0-9])|2[1-9]w).*";
14
15     public static void show() {
16         ClientInterop.displayScreen(new SettingsScreen(null));
17     }
18
19     SettingsScreen(GuiScreen lastScreen) {
20         super(lastScreen);
21     }
22
23     @Override
24     protected void onDoneClicked() {
25         ConfigManager.saveConfig();
26         super.onDoneClicked();
27     }
28
29     @Override
30     protected void setup() {
31         String version = this.mc.getVersion();
32         ControlList controlList = this.getControlList();
33         if (this.mc.world != null) controlList.setTransparentBackground();
34
35         controlList
36                 .section(null,
37                         (x, width) -> new BoolButton(width, I18n.format("bbor.options.active"), this.mc.world != null) {
38                             @Override
39                             public void onPressed() {
40                                 ClientRenderer.toggleActive();
41                             }
42
43                             @Override
44                             protected boolean getValue() {
45                                 return ClientRenderer.getActive();
46                             }
47                         },
48                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.options.outerBoxOnly"), ConfigManager.outerBoxesOnly),
49                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.options.fill"), ConfigManager.fill))
50                 .section(I18n.format("bbor.features.spawnChunks"),
51                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.spawnChunks"), BoundingBoxType.WorldSpawn),
52                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.lazyChunks"), BoundingBoxType.LazySpawnChunks),
53                         (x, width) -> new MaxYSettingSlider(width, 39, ConfigManager.worldSpawnMaxY))
54                 .section(I18n.format("bbor.features.slimeChunks"),
55                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.slimeChunks"), BoundingBoxType.SlimeChunks),
56                         (x, width) -> new MaxYSettingSlider(width, 39, ConfigManager.slimeChunkMaxY))
57                 .section(I18n.format("bbor.features.biomeBorders"),
58                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.biomeBorders"), BoundingBoxType.BiomeBorder),
59                         (x, width) -> new MaxYSettingSlider(width, 1, ConfigManager.biomeBordersMaxY),
60                         (x, width) -> new IntSettingSlider(width, 1, 3, "bbor.options.distance", ConfigManager.biomeBordersRenderDistance)
61                                 .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
62                                 .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
63                                 .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
64                 .section(I18n.format("bbor.features.mobSpawners"),
65                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
66                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
67                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.mobSpawners.activationLines"), ConfigManager.renderMobSpawnerActivationLines))
68                 .section(I18n.format("bbor.features.spawningSpheres"),
69                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere),
70                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.spawningSpheres.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks),
71                         (x, width) -> new IntSettingSlider(width, 1, 3, "bbor.options.distance", ConfigManager.afkSpawnableBlocksRenderDistance)
72                                 .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
73                                 .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
74                                 .addDisplayValue(3, I18n.format("bbor.options.distance.normal")))
75                 .section(I18n.format("bbor.tabs.structures"),
76                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple),
77                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple),
78                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.witchHuts"), BoundingBoxType.WitchHut),
79                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.mansions"), BoundingBoxType.Mansion),
80                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.monuments"), BoundingBoxType.OceanMonument),
81                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.igloos"), BoundingBoxType.Igloo),
82                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin),
83                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure),
84                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck),
85                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.strongholds"), BoundingBoxType.Stronghold),
86                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.mineshafts"), BoundingBoxType.MineShaft),
87                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.villages"), BoundingBoxType.Village),
88                         (x, width) -> version.matches(pillagerOutpostVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost) : null,
89                         (x, width) -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.ruinedPortal"), BoundingBoxType.RuinedPortal) : null,
90                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
91                         (x, width) -> version.matches(netherFossilVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.netherFossils"), BoundingBoxType.NetherFossil) : null,
92                         (x, width) -> version.matches(bastionRemnantVersionPattern) ? new BoundingBoxTypeButton(width, I18n.format("bbor.structures.bastionRemnants"), BoundingBoxType.BastionRemnant) : null,
93                         (x, width) -> new BoundingBoxTypeButton(width, I18n.format("bbor.structures.endCities"), BoundingBoxType.EndCity))
94                 .section(I18n.format("bbor.tabs.villages"),
95                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres"), ConfigManager.drawVillageSpheres),
96                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres.doorLines"), ConfigManager.drawVillageDoors),
97                         (x, width) -> new BoolSettingButton(width, I18n.format("bbor.features.villageSpheres.golemSpawn"), ConfigManager.drawIronGolemSpawnArea),
98                         (x, width) -> new IntSettingSlider(width, 1, 5, "bbor.features.villageSpheres.dotSize", ConfigManager.villageSphereDotSize),
99                         (x, width) -> new IntSettingSlider(width, 1, 5, "bbor.features.villageSpheres.density", ConfigManager.villageSphereDensity)
100                                 .addDisplayValue(1, I18n.format("bbor.features.villageSpheres.density.fewest"))
101                                 .addDisplayValue(2, I18n.format("bbor.features.villageSpheres.density.fewer"))
102                                 .addDisplayValue(3, I18n.format("bbor.features.villageSpheres.density.normal"))
103                                 .addDisplayValue(4, I18n.format("bbor.features.villageSpheres.density.more"))
104                                 .addDisplayValue(5, I18n.format("bbor.features.villageSpheres.density.most")));
105     }
106 }