Skip to content

Commit 77490db

Browse files
committed
Move settings to its own class
1 parent f815e93 commit 77490db

File tree

2 files changed

+49
-40
lines changed

2 files changed

+49
-40
lines changed

src/progressed/ProgMats.java

+1-40
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
import arc.*;
44
import arc.func.*;
5-
import arc.math.*;
65
import arc.util.*;
76
import mindustry.game.EventType.*;
87
import mindustry.gen.*;
98
import mindustry.mod.*;
109
import mindustry.mod.Mods.*;
11-
import mindustry.ui.dialogs.SettingsMenuDialog.*;
12-
import mindustry.ui.dialogs.SettingsMenuDialog.SettingsTable.*;
1310
import mindustry.world.blocks.storage.CoreBlock.*;
1411
import progressed.content.*;
1512
import progressed.content.blocks.*;
@@ -34,7 +31,7 @@ public class ProgMats extends Mod{
3431
public ProgMats(){
3532
super();
3633
Events.on(ClientLoadEvent.class, e -> {
37-
loadSettings();
34+
PMSettings.init();
3835
PMPal.init();
3936
hints.load();
4037
});
@@ -137,47 +134,11 @@ public void loadContent(){
137134
PMLoadouts.load();
138135
}
139136

140-
void loadSettings(){
141-
ui.settings.addCategory(bundle.get("setting.pm-title"), "prog-mats-settings-icon", t -> {
142-
t.pref(new Separator("pm-graphics-settings"));
143-
t.sliderPref("pm-sword-opacity", 100, 20, 100, 5, s -> s + "%");
144-
t.sliderPref("pm-zone-opacity", 100, 0, 100, 5, s -> s + "%");
145-
t.checkPref("pm-tesla-range", true);
146-
t.pref(new Separator("pm-other-settings"));
147-
t.checkPref("pm-farting", false, b -> Sounds.wind3.play(Interp.pow2In.apply(Core.settings.getInt("sfxvol") / 100f) * 5f));
148-
});
149-
}
150-
151137
public static boolean farting(){
152138
return settings.getBool("pm-farting", false);
153139
}
154140

155141
static boolean TUEnabled(){
156142
return PMUtls.modEnabled("test-utils");
157143
}
158-
159-
static class Separator extends Setting{
160-
float height;
161-
162-
public Separator(String name){
163-
super(name);
164-
}
165-
166-
public Separator(float height){
167-
this("");
168-
this.height = height;
169-
}
170-
171-
@Override
172-
public void add(SettingsTable table){
173-
if(name.isEmpty()){
174-
table.image(Tex.clear).height(height).padTop(3f);
175-
}else{
176-
table.table(t -> {
177-
t.add(title).padTop(3f);
178-
}).get().background(Tex.underline);
179-
}
180-
table.row();
181-
}
182-
}
183144
}

src/progressed/util/PMSettings.java

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package progressed.util;
2+
3+
import arc.*;
4+
import arc.math.*;
5+
import mindustry.gen.*;
6+
import mindustry.ui.dialogs.SettingsMenuDialog.*;
7+
import mindustry.ui.dialogs.SettingsMenuDialog.SettingsTable.*;
8+
9+
import static arc.Core.*;
10+
import static mindustry.Vars.*;
11+
12+
public class PMSettings{
13+
public static void init(){
14+
ui.settings.addCategory(bundle.get("setting.pm-title"), "prog-mats-settings-icon", t -> {
15+
t.pref(new Separator("pm-graphics-settings"));
16+
t.sliderPref("pm-sword-opacity", 100, 20, 100, 5, s -> s + "%");
17+
t.sliderPref("pm-zone-opacity", 100, 0, 100, 5, s -> s + "%");
18+
t.checkPref("pm-tesla-range", true);
19+
t.pref(new Separator("pm-other-settings"));
20+
t.checkPref("pm-farting", false, b -> Sounds.wind3.play(Interp.pow2In.apply(Core.settings.getInt("sfxvol") / 100f) * 5f));
21+
});
22+
}
23+
24+
static class Separator extends Setting{
25+
float height;
26+
27+
public Separator(String name){
28+
super(name);
29+
}
30+
31+
public Separator(float height){
32+
this("");
33+
this.height = height;
34+
}
35+
36+
@Override
37+
public void add(SettingsTable table){
38+
if(name.isEmpty()){
39+
table.image(Tex.clear).height(height).padTop(3f);
40+
}else{
41+
table.table(t -> {
42+
t.add(title).padTop(3f);
43+
}).get().background(Tex.underline);
44+
}
45+
table.row();
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)