Skip to content

Commit bf47629

Browse files
committed
Move settings to its own class
1 parent 05084af commit bf47629

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.*;
@@ -35,7 +32,7 @@ public class ProgMats extends Mod{
3532
public ProgMats(){
3633
super();
3734
Events.on(ClientLoadEvent.class, e -> {
38-
loadSettings();
35+
PMSettings.init();
3936
PMPal.init();
4037
hints.load();
4138
});
@@ -138,47 +135,11 @@ public void loadContent(){
138135
PMLoadouts.load();
139136
}
140137

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

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

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)