Skip to content

Commit

Permalink
Move settings to its own class
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Nov 18, 2024
1 parent f815e93 commit 77490db
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
41 changes: 1 addition & 40 deletions src/progressed/ProgMats.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import arc.*;
import arc.func.*;
import arc.math.*;
import arc.util.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.mod.*;
import mindustry.mod.Mods.*;
import mindustry.ui.dialogs.SettingsMenuDialog.*;
import mindustry.ui.dialogs.SettingsMenuDialog.SettingsTable.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import progressed.content.*;
import progressed.content.blocks.*;
Expand All @@ -34,7 +31,7 @@ public class ProgMats extends Mod{
public ProgMats(){
super();
Events.on(ClientLoadEvent.class, e -> {
loadSettings();
PMSettings.init();
PMPal.init();
hints.load();
});
Expand Down Expand Up @@ -137,47 +134,11 @@ public void loadContent(){
PMLoadouts.load();
}

void loadSettings(){
ui.settings.addCategory(bundle.get("setting.pm-title"), "prog-mats-settings-icon", t -> {
t.pref(new Separator("pm-graphics-settings"));
t.sliderPref("pm-sword-opacity", 100, 20, 100, 5, s -> s + "%");
t.sliderPref("pm-zone-opacity", 100, 0, 100, 5, s -> s + "%");
t.checkPref("pm-tesla-range", true);
t.pref(new Separator("pm-other-settings"));
t.checkPref("pm-farting", false, b -> Sounds.wind3.play(Interp.pow2In.apply(Core.settings.getInt("sfxvol") / 100f) * 5f));
});
}

public static boolean farting(){
return settings.getBool("pm-farting", false);
}

static boolean TUEnabled(){
return PMUtls.modEnabled("test-utils");
}

static class Separator extends Setting{
float height;

public Separator(String name){
super(name);
}

public Separator(float height){
this("");
this.height = height;
}

@Override
public void add(SettingsTable table){
if(name.isEmpty()){
table.image(Tex.clear).height(height).padTop(3f);
}else{
table.table(t -> {
t.add(title).padTop(3f);
}).get().background(Tex.underline);
}
table.row();
}
}
}
48 changes: 48 additions & 0 deletions src/progressed/util/PMSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package progressed.util;

import arc.*;
import arc.math.*;
import mindustry.gen.*;
import mindustry.ui.dialogs.SettingsMenuDialog.*;
import mindustry.ui.dialogs.SettingsMenuDialog.SettingsTable.*;

import static arc.Core.*;
import static mindustry.Vars.*;

public class PMSettings{
public static void init(){
ui.settings.addCategory(bundle.get("setting.pm-title"), "prog-mats-settings-icon", t -> {
t.pref(new Separator("pm-graphics-settings"));
t.sliderPref("pm-sword-opacity", 100, 20, 100, 5, s -> s + "%");
t.sliderPref("pm-zone-opacity", 100, 0, 100, 5, s -> s + "%");
t.checkPref("pm-tesla-range", true);
t.pref(new Separator("pm-other-settings"));
t.checkPref("pm-farting", false, b -> Sounds.wind3.play(Interp.pow2In.apply(Core.settings.getInt("sfxvol") / 100f) * 5f));
});
}

static class Separator extends Setting{
float height;

public Separator(String name){
super(name);
}

public Separator(float height){
this("");
this.height = height;
}

@Override
public void add(SettingsTable table){
if(name.isEmpty()){
table.image(Tex.clear).height(height).padTop(3f);
}else{
table.table(t -> {
t.add(title).padTop(3f);
}).get().background(Tex.underline);
}
table.row();
}
}
}

0 comments on commit 77490db

Please sign in to comment.