mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
overdraw refactoring
This commit is contained in:
@@ -5,54 +5,46 @@ import arc.scene.style.TextureRegionDrawable;
|
||||
import arc.scene.ui.CheckBox;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.struct.Seq;
|
||||
import mindustry.gen.Building;
|
||||
import mindustry.gen.Unit;
|
||||
import mindustry.ui.Styles;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static arc.Core.bundle;
|
||||
import static arc.Core.settings;
|
||||
|
||||
public class OverDraw {
|
||||
public TextureRegionDrawable icon;
|
||||
public String name;
|
||||
public boolean enabled = false;
|
||||
public Seq<String> options = new Seq<>();
|
||||
|
||||
OverDraw(String name, TextureRegionDrawable icon) {
|
||||
OverDraw(String name, OverDrawCategory category) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
|
||||
OverDraws.getDraws().get(category, new Seq<>()).add(this);
|
||||
}
|
||||
|
||||
public void displayStats(Table parent) {
|
||||
if(options.isEmpty()) return;
|
||||
parent.background(Styles.squarei.up);
|
||||
parent.left();
|
||||
options.each(name-> parent
|
||||
.check(bundle.get("setting."+name+".name"), settings.getBool(name), b->settings.put(name, b))
|
||||
.tooltip(t-> {
|
||||
if(bundle.has("setting."+name+".description"))
|
||||
t.background(Styles.black8).add(bundle.get("setting."+name+".description"));
|
||||
})
|
||||
.disabled(!enabled)
|
||||
.left().row());
|
||||
}
|
||||
/**
|
||||
* Groups.build 에서 각 건물에 대한 그리기를 처리합니다.
|
||||
* @param build 각 Building 엔티티
|
||||
*/
|
||||
public void onBuilding(Building build) { }
|
||||
|
||||
/**
|
||||
* Groups.unit 에서 각 유닛에 대한 그리기를 처리합니다.
|
||||
* @param unit 각 Unit 엔티티
|
||||
*/
|
||||
public void onUnit(Unit unit) { }
|
||||
|
||||
/**
|
||||
* Vars.world.tiles 에서 각 타일에 대한 그리기를 처리합니다.
|
||||
* @param tile 각 Tile 엔티티
|
||||
*/
|
||||
public void onTile(Tile tile) { }
|
||||
|
||||
/**
|
||||
* 매 프레임에 대한 그리기를 처리합니다.
|
||||
*/
|
||||
public void draw() {}
|
||||
|
||||
public <T> void onEnabled(T param) {
|
||||
if(param instanceof Table t) {
|
||||
for (int i = 0; i < t.getChildren().size; i++) {
|
||||
Element elem = t.getChildren().get(i);
|
||||
if (elem instanceof CheckBox cb) cb.setDisabled(!enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerOption(String name) {
|
||||
registerOption(name, settings.has(name) && settings.getBool(name));
|
||||
}
|
||||
|
||||
public void registerOption(String name, boolean defaults) {
|
||||
options.add(name);
|
||||
settings.put(name, defaults);
|
||||
}
|
||||
public void update() {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user