mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
fixed bug
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
"displayName": "Unit Infomation",
|
"displayName": "Unit Infomation",
|
||||||
"author": "Sharlotte",
|
"author": "Sharlotte",
|
||||||
"description": "The mod displays more information in-game, such as unit/building, wave, core, tile, item/unit total info etc",
|
"description": "The mod displays more information in-game, such as unit/building, wave, core, tile, item/unit total info etc",
|
||||||
"version": "1.3.3.1",
|
"version": "1.3.4.2",
|
||||||
"main": "UnitInfo.core.Main",
|
"main": "UnitInfo.core.Main",
|
||||||
"minGameVersion": "130.1",
|
"minGameVersion": "130.1",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
|
|||||||
@@ -16,10 +16,8 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class SVars {
|
public class SVars {
|
||||||
public static Fi modRoot = modDirectory.child("UnitInfo");
|
public static Fi modRoot = modDirectory.child("UnitInfo");
|
||||||
public static Seq<PlayerParser.PlayerInfo> playerInfos = new Seq<>();
|
|
||||||
public static SettingS settingAdder = new SettingS();
|
public static SettingS settingAdder = new SettingS();
|
||||||
public static HudUi hud = new HudUi();
|
public static HudUi hud = new HudUi();
|
||||||
public static PlayerParser playerinfo = new PlayerParser();
|
|
||||||
public static TextureRegion clear = atlas.find("clear");
|
public static TextureRegion clear = atlas.find("clear");
|
||||||
public static TextureRegion error = atlas.find("error");
|
public static TextureRegion error = atlas.find("error");
|
||||||
public static float modUiScale = settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f;
|
public static float modUiScale = settings.getInt("infoUiScale") / 100f == 0 ? 1 : settings.getInt("infoUiScale") / 100f;
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ public class HudUi {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
Table pathlineTable = new Table(t -> {
|
Table pathlineTable = new Table(t -> {
|
||||||
t.left();
|
t.right();
|
||||||
|
|
||||||
Button pathBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
Button pathBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
||||||
Button unitBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
Button unitBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
|
||||||
@@ -453,11 +453,9 @@ public class HudUi {
|
|||||||
logicBtn.setChecked(logicLine);
|
logicBtn.setChecked(logicLine);
|
||||||
});
|
});
|
||||||
|
|
||||||
t.add(pathBtn).padLeft(16).size(24);
|
t.add(pathBtn).padLeft(4 * 8f).size(3 * 8f).row();
|
||||||
t.row();
|
t.add(unitBtn).padLeft(4 * 8f).size(3 * 8f).row();
|
||||||
t.add(unitBtn).padLeft(16).size(24);
|
t.add(logicBtn).padLeft(4 * 8f).size(3 * 8f).row();
|
||||||
t.row();
|
|
||||||
t.add(logicBtn).padLeft(16).size(24);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Table waveTable = (Table)((Group)((Group)ui.hudGroup.getChildren().get(5)) //HudFragment#118, name: overlaymarker
|
Table waveTable = (Table)((Group)((Group)ui.hudGroup.getChildren().get(5)) //HudFragment#118, name: overlaymarker
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ public class Main extends Mod {
|
|||||||
hud.addTable();
|
hud.addTable();
|
||||||
hud.addWaveInfoTable();
|
hud.addWaveInfoTable();
|
||||||
hud.setEvent();
|
hud.setEvent();
|
||||||
playerinfo.createFile();
|
|
||||||
playerinfo.setEvent();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, e -> {
|
Events.on(WorldLoadEvent.class, e -> {
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
package UnitInfo.core;
|
|
||||||
|
|
||||||
import UnitInfo.*;
|
|
||||||
import arc.*;
|
|
||||||
import arc.struct.*;
|
|
||||||
import mindustry.*;
|
|
||||||
import mindustry.game.*;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
import org.hjson.*;
|
|
||||||
|
|
||||||
import static UnitInfo.SVars.modRoot;
|
|
||||||
|
|
||||||
public class PlayerParser{
|
|
||||||
ObjectMap<Player, Seq<String>> chats = new ObjectMap<>();
|
|
||||||
|
|
||||||
public void setEvent() {
|
|
||||||
Events.on(EventType.PlayerChatEvent.class, e -> {
|
|
||||||
chats.get(e.player,Seq::new).add(e.message);
|
|
||||||
writeJson(e.player);
|
|
||||||
save();
|
|
||||||
});
|
|
||||||
|
|
||||||
Events.run(EventType.Trigger.update, ()->{
|
|
||||||
if(Vars.net.active()) Groups.player.each(this::writeJson);
|
|
||||||
|
|
||||||
save();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createFile() {
|
|
||||||
if(!modRoot.child("players.hjson").exists()) save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeJson(Player player1){
|
|
||||||
PlayerInfo info = SVars.playerInfos.find(pi -> pi.player == player1);
|
|
||||||
if(info != null){
|
|
||||||
if(!info.names.contains(player1.name)) info.names.add(player1.name);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
SVars.playerInfos.add(new PlayerInfo(){{
|
|
||||||
player = player1;
|
|
||||||
names.add(player1.name);
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
JsonObject data = new JsonObject();
|
|
||||||
SVars.playerInfos.each(pi->{
|
|
||||||
JsonArray arr = new JsonArray();
|
|
||||||
JsonArray chatArr = new JsonArray();
|
|
||||||
pi.names.each(arr::add);
|
|
||||||
if(chats.get(pi.player) != null) chats.get(pi.player).each(chatArr::add);
|
|
||||||
data.add("names", arr);
|
|
||||||
data.add("chats", chatArr);
|
|
||||||
});
|
|
||||||
modRoot.child("players.hjson").writeString(data.toString(Stringify.HJSON));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PlayerInfo{
|
|
||||||
Player player;
|
|
||||||
Seq<String> names = new Seq<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -71,12 +71,16 @@ public class SettingS {
|
|||||||
public void add(Table table) {
|
public void add(Table table) {
|
||||||
final String[] str = {""};
|
final String[] str = {""};
|
||||||
Table table1 = new Table(t -> {
|
Table table1 = new Table(t -> {
|
||||||
|
final float[] value = new float[1];
|
||||||
t.add(new Label(title + ": ")).left().padRight(5)
|
t.add(new Label(title + ": ")).left().padRight(5)
|
||||||
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
|
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
|
||||||
|
|
||||||
t.field((integer ? settings.getInt(key) : settings.getFloat(key)) + str[0], s -> {
|
t.field(value[0] + str[0], s -> {
|
||||||
settings.put(key, integer ? Strings.parseInt(s) : Strings.parseFloat(s));
|
value[0] = Strings.parseFloat(s);
|
||||||
str[0] = h.get(s);
|
str[0] = h.get(s);
|
||||||
|
|
||||||
|
if(integer) settings.put(key, Strings.parseInt(s.split("[.]")[0]));
|
||||||
|
else settings.put(key, Strings.parseFloat(s));
|
||||||
}).update(a -> a.setDisabled(!condition.get()))
|
}).update(a -> a.setDisabled(!condition.get()))
|
||||||
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
|
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user