diff --git a/assets/bundles/bundle-mdtx.properties b/assets/bundles/bundle-mdtx.properties index 93283fbe7ac5..695345bb9876 100644 --- a/assets/bundles/bundle-mdtx.properties +++ b/assets/bundles/bundle-mdtx.properties @@ -73,7 +73,6 @@ setting.deadOverlay.name = 死亡时(观战)仍然显示界面 setting.invertMapClick.name = 反转小地图的左右键点击 setting.arcSpecificTable.name = 学术信息显示(左上角) [orange][重启生效] setting.logicSupport.name = 逻辑辅助器 -setting.powerStatistic.name = 电量统计 [orange][重启生效] setting.showOtherTeamResource.name = 队伍资源显示(左中部) setting.showQuickToolTable.name = 快捷工具(右中部) [gray]快捷设置/工具箱/建筑工具 setting.quickToolOffset.name = 快捷工具偏置 @@ -126,6 +125,7 @@ setting.coreItems.columns.name = 显示列数 setting.coreItems.showItem.name = 显示核心物品 setting.coreItems.showUnit.name = 显示单位数量 setting.coreItems.showPlan.name = 显示建筑中数量 +setting.coreItems.showPower.name = 显示电网信息 setting.newWaveInfoDisplay.name = 新波次显示(中上部) #end SettingsV2 diff --git a/assets/bundles/bundle-mdtx_en.properties b/assets/bundles/bundle-mdtx_en.properties index 05dbd06b2f6b..355621709549 100644 --- a/assets/bundles/bundle-mdtx_en.properties +++ b/assets/bundles/bundle-mdtx_en.properties @@ -73,7 +73,6 @@ setting.deadOverlay.name = Show UI When Dead (Spectating) setting.invertMapClick.name = Invert Mini Map Left and Right Click setting.arcSpecificTable.name = Academic Information Display (Top Left) [orange][Restart Required] setting.logicSupport.name = Logic Support -setting.powerStatistic.name = Power Statistics [orange][Restart Required] setting.showOtherTeamResource.name = Team Resource Display (Middle Left) setting.showQuickToolTable.name = Quick Tools (Middle Right) [gray]Quick Settings/Toolbox/Building Tools setting.arcCoreItemsCol.name = Core Items Display Column Count diff --git a/patches/client/0061-ARC-merged.patch b/patches/client/0061-ARC-merged.patch index c8bed6e710a6..14d106e4f7ba 100644 --- a/patches/client/0061-ARC-merged.patch +++ b/patches/client/0061-ARC-merged.patch @@ -117,12 +117,12 @@ way-zer on 2024/9/8 .../ui/dialogs/SettingsMenuDialog.java | 28 +- .../mindustry/ui/fragments/ChatFragment.java | 9 +- .../ui/fragments/ConsoleFragment.java | 3 + - .../mindustry/ui/fragments/HudFragment.java | 186 ++++++++++++- + .../mindustry/ui/fragments/HudFragment.java | 174 +++++++++++- .../mindustry/ui/fragments/MenuFragment.java | 59 +++- .../ui/fragments/PlacementFragment.java | 169 ++++++++++-- .../ui/fragments/PlayerListFragment.java | 72 ++--- core/src/mindustry/world/Block.java | 7 +- - 29 files changed, 1560 insertions(+), 175 deletions(-) + 29 files changed, 1548 insertions(+), 175 deletions(-) diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 7f944a3eb06180f9e2b760bbd5aa41709ddf6611..4972f424edd41b8a29d926a09bc55987066d33aa 100644 @@ -2459,7 +2459,7 @@ index e74e6a12e3da57eb58598eb4e679a7990c109def..013255ce5aa828d538814fa25dc64c6a //special case for 'clear' command if(message.equals("clear")){ diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java -index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066f01142d1 100644 +index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..51c10a9342bd7a2610443c6b4b9885711aa4c15e 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -29,11 +29,13 @@ import mindustry.net.Packets.*; @@ -2487,20 +2487,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 //wave info button with text s.add(makeStatusTable()).grow().name("status"); -@@ -323,6 +329,12 @@ public class HudFragment{ - logic.skipWave(); - } - }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip").get().toBack(); -+ // Power bar display -+ if (Core.settings.getBool("powerStatistic")){ -+ s.row(); -+ s.add(ArcPowerInfo.getBars()).growX().colspan(s.getColumns()); -+ } -+ - }).width(dsize * 5 + 4f).name("statustable"); - - wavesMain.row(); -@@ -331,6 +343,7 @@ public class HudFragment{ +@@ -331,6 +337,7 @@ public class HudFragment{ editorMain.name = "editor"; editorMain.table(Tex.buttonEdge4, t -> { @@ -2508,7 +2495,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 t.name = "teams"; t.top().table(teams -> { teams.left(); -@@ -346,6 +359,7 @@ public class HudFragment{ +@@ -346,6 +353,7 @@ public class HudFragment{ teams.row(); } } @@ -2516,7 +2503,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 }).top().left(); t.row(); -@@ -417,6 +431,8 @@ public class HudFragment{ +@@ -417,6 +425,8 @@ public class HudFragment{ IntFormat mem = new IntFormat("memory"); IntFormat memnative = new IntFormat("memory2"); @@ -2525,7 +2512,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left().style(Styles.outlineLabel).name("fps"); info.row(); info.label(() -> Strings.format("LG/DW/UI(ms) @/@/@", Time.nanosToMillis(DebugUtil.logicTime), Time.nanosToMillis(DebugUtil.rendererTime), Time.nanosToMillis(DebugUtil.uiTime))) -@@ -426,6 +442,11 @@ public class HudFragment{ +@@ -426,6 +436,11 @@ public class HudFragment{ DebugUtil.lastDrawRequests, DebugUtil.lastVertices, DebugUtil.lastSwitchTexture, DebugUtil.lastFlushCount)).left().style(Styles.outlineLabel).name("draw"), ()->DebugUtil.renderDebug); info.row(); @@ -2537,7 +2524,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 if(android){ info.label(() -> memnative.get((int)(Core.app.getJavaHeap() / 1024 / 1024), (int)(Core.app.getNativeHeap() / 1024 / 1024))).left().style(Styles.outlineLabel).name("memory2"); }else{ -@@ -1038,6 +1059,169 @@ public class HudFragment{ +@@ -1038,6 +1053,163 @@ public class HudFragment{ return table; } @@ -2585,12 +2572,6 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 + + table.table(this::buildArcStatus).growX().pad(4f); + -+ // Power bar display -+ if (Core.settings.getBool("powerStatistic")){ -+ table.row(); -+ table.add(ArcPowerInfo.getBars()).growX().colspan(table.getColumns()); -+ } -+ + return table; + } + @@ -2707,7 +2688,7 @@ index ca1ef15de7fdf940eff0d1e1b1a9f36ebc78aafd..0fb8b07b1d30070ae7e3f924563ba066 private void addInfoTable(Table table){ table.name = "infotable"; table.left(); -@@ -1082,7 +1266,7 @@ public class HudFragment{ +@@ -1082,7 +1254,7 @@ public class HudFragment{ } private boolean canSkipWave(){ diff --git a/src/mindustryX/features/Settings.java b/src/mindustryX/features/Settings.java index 70ec3bc1a38c..58acb9ec3352 100644 --- a/src/mindustryX/features/Settings.java +++ b/src/mindustryX/features/Settings.java @@ -40,7 +40,6 @@ public static void addSettings(){ c.checkPref("invertMapClick", false); c.checkPref("arcSpecificTable", true); c.checkPref("logicSupport", true); - c.checkPref("powerStatistic", true); c.checkPref("showOtherTeamResource", false); c.checkPref("showQuickToolTable", true); c.sliderPref("itemSelectionHeight", 4, 4, 12, i -> i + "行"); diff --git a/src/mindustryX/features/ui/ArcPowerInfo.java b/src/mindustryX/features/ui/ArcPowerInfo.java deleted file mode 100644 index dd3b62f1dd73..000000000000 --- a/src/mindustryX/features/ui/ArcPowerInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -package mindustryX.features.ui; - -import arc.*; -import arc.math.*; -import arc.scene.*; -import arc.scene.ui.layout.*; -import mindustry.*; -import mindustry.core.*; -import mindustry.gen.*; -import mindustry.graphics.*; -import mindustry.ui.*; -import mindustryX.features.Settings; - -//move from mindustry.arcModule.ui.PowerInfo -public class ArcPowerInfo{ - public static float balance, stored, capacity, produced, need; - - public static void update(){ - balance = 0; - stored = 0; - capacity = 0; - produced = 0; - need = 0; - Groups.powerGraph.each(item -> { - var graph = item.graph(); - if(graph.all.isEmpty() || graph.all.first().team != Vars.player.team()) return; - balance += graph.getPowerBalance(); - stored += graph.getLastPowerStored(); - capacity += graph.getLastCapacity(); - produced += graph.getLastPowerProduced(); - need += graph.getLastPowerNeeded(); - }); - } - - public static int getPowerBalance(){ - return (int)(balance * 60); - } - - public static float getSatisfaction(){ - if(Mathf.zero(produced)){ - return 0f; - }else if(Mathf.zero(need)){ - return 1f; - } - return produced / need; - } - - - public static Element getBars(){ - Table power = new Table(Tex.wavepane).marginTop(6); - - Bar powerBar = new Bar( - () -> Core.bundle.format("bar.powerbalance", (getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount(getPowerBalance())) + - (getSatisfaction() >= 1 ? "" : " [gray]" + (int)(getSatisfaction() * 100) + "%"), - () -> Pal.powerBar, ArcPowerInfo::getSatisfaction); - Bar batteryBar = new Bar( - () -> Core.bundle.format("bar.powerstored", UI.formatAmount((long)stored), UI.formatAmount((long)capacity)), - () -> Pal.powerBar, - () -> stored / capacity); - - power.margin(0); - power.add(powerBar).height(18).growX().padBottom(1); - power.row(); - power.add(batteryBar).height(18).growX().padBottom(1); - - power.update(ArcPowerInfo::update); - return power; - } -} \ No newline at end of file diff --git a/src/mindustryX/features/ui/NewCoreItemsDisplay.java b/src/mindustryX/features/ui/NewCoreItemsDisplay.java index c64dd37a237c..bab35d92f4ff 100644 --- a/src/mindustryX/features/ui/NewCoreItemsDisplay.java +++ b/src/mindustryX/features/ui/NewCoreItemsDisplay.java @@ -2,14 +2,17 @@ import arc.*; import arc.graphics.*; +import arc.math.*; import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; import kotlin.collections.*; +import mindustry.*; import mindustry.core.*; import mindustry.entities.*; import mindustry.game.EventType.*; +import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -29,7 +32,7 @@ public class NewCoreItemsDisplay extends Table{ public static final float MIN_WIDTH = 64f; - private Table itemsTable, unitsTable, plansTable; + private Table itemsTable, unitsTable, plansTable, powerTable; private static final Interval timer = new Interval(2); @@ -45,7 +48,8 @@ public class NewCoreItemsDisplay extends Table{ private final SettingsV2.Data showItem = CheckPref.INSTANCE.create("coreItems.showItem", true); private final SettingsV2.Data showUnit = CheckPref.INSTANCE.create("coreItems.showUnit", true); private final SettingsV2.Data showPlan = CheckPref.INSTANCE.create("coreItems.showPlan", true); - final List> settings = CollectionsKt.listOf(columns, showItem, showUnit, showPlan); + private final SettingsV2.Data showPower = CheckPref.INSTANCE.create("coreItems.showPower", true); + final List> settings = CollectionsKt.listOf(columns, showItem, showUnit, showPlan, showPower); public NewCoreItemsDisplay(){ itemDelta = new int[content.items().size]; @@ -64,6 +68,7 @@ public NewCoreItemsDisplay(){ } private void setup(){ + collapser(powerTable = new Table(Styles.black3), showPower::getValue).growX().row(); collapser(itemsTable = new Table(Styles.black3), showItem::getValue).growX().row(); collapser(unitsTable = new Table(Styles.black3), showUnit::getValue).growX().row(); @@ -100,6 +105,41 @@ private void setup(){ rebuildPlans(); } }); + buildPower(); + } + + private float balance, stored, capacity, produced, need, satisfaction; + + private void buildPower(){ + powerTable.update(() -> { + balance = 0; + stored = 0; + capacity = 0; + produced = 0; + need = 0; + Groups.powerGraph.each(item -> { + var graph = item.graph(); + if(graph.all.isEmpty() || graph.all.first().team != Vars.player.team()) return; + balance += graph.getPowerBalance(); + stored += graph.getLastPowerStored(); + capacity += graph.getLastCapacity(); + produced += graph.getLastPowerProduced(); + need += graph.getLastPowerNeeded(); + }); + balance *= Time.toSeconds; + satisfaction = produced == 0 ? 1 : need == 0 ? 1 : Mathf.clamp(produced / need, 0, 1); + }); + powerTable.margin(2f).stack( + new Bar("", Pal.powerBar, () -> capacity == 0 ? (balance > 0 ? 1 : 0) : stored / capacity), + new Table(t -> { + t.add().growX(); + t.label(() -> Core.bundle.format("bar.powerbalance", (balance >= 0 ? "+" : "") + UI.formatAmount((long)balance)) + + (satisfaction >= 1 ? "" : " [gray]" + (int)(satisfaction * 100) + "%")); + t.add().width(16); + t.label(() -> Core.bundle.format("bar.powerstored", UI.formatAmount((long)stored), UI.formatAmount((long)capacity))); + t.add().growX(); + }) + ).growX(); } private void updateItemMeans(){