Skip to content

Commit

Permalink
✨ 移动电网信息条到核心资源显示中
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer committed Jan 17, 2025
1 parent df44a32 commit a19fce0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 102 deletions.
2 changes: 1 addition & 1 deletion assets/bundles/bundle-mdtx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 快捷工具偏置
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion assets/bundles/bundle-mdtx_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 9 additions & 28 deletions patches/client/0061-ARC-merged.patch
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ way-zer <himc.wicp@gmail.com> 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
Expand Down Expand Up @@ -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.*;
Expand Down Expand Up @@ -2487,36 +2487,23 @@ 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 -> {
+ t.visible(() -> UIExt.advanceToolTable != null && UIExt.advanceToolTable.parent.visible);
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();
}
}
+ teams.button("更多", () -> UIExt.teamSelect.pickOne(team -> Call.setPlayerTeamEditor(player, team), player.team())).center().row();
}).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");

Expand All @@ -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();

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
+ }
+
Expand Down Expand Up @@ -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(){
Expand Down
1 change: 0 additions & 1 deletion src/mindustryX/features/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "行");
Expand Down
69 changes: 0 additions & 69 deletions src/mindustryX/features/ui/ArcPowerInfo.java

This file was deleted.

44 changes: 42 additions & 2 deletions src/mindustryX/features/ui/NewCoreItemsDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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);

Expand All @@ -45,7 +48,8 @@ public class NewCoreItemsDisplay extends Table{
private final SettingsV2.Data<Boolean> showItem = CheckPref.INSTANCE.create("coreItems.showItem", true);
private final SettingsV2.Data<Boolean> showUnit = CheckPref.INSTANCE.create("coreItems.showUnit", true);
private final SettingsV2.Data<Boolean> showPlan = CheckPref.INSTANCE.create("coreItems.showPlan", true);
final List<Data<?>> settings = CollectionsKt.listOf(columns, showItem, showUnit, showPlan);
private final SettingsV2.Data<Boolean> showPower = CheckPref.INSTANCE.create("coreItems.showPower", true);
final List<Data<?>> settings = CollectionsKt.listOf(columns, showItem, showUnit, showPlan, showPower);

public NewCoreItemsDisplay(){
itemDelta = new int[content.items().size];
Expand All @@ -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();

Expand Down Expand Up @@ -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(){
Expand Down

0 comments on commit a19fce0

Please sign in to comment.