Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
alexytomi committed Oct 29, 2024
1 parent e74675e commit 85deb4b
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/example/ExampleJavaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,38 @@ public void init() {
// break things on other platforms
// Events.on(ClientLoadEvent.class, null);

Events.on(WorldLoadEvent.class, e -> {
buildCoreItemsDisplay((Table) mobileUI);
});
}

private void createInGameGroup() {
Log.info("Loading UI stuff");
// don't mind me blatantly copying code from HudFragment on how it builds the
// coreinfo table
this.mobileUI.fill(mobileUI -> {
// for future me, this is where you put your UI stuff so they go in the mobileUI
// WidgetGroup instead of hudGroup which IMO is jank. Maybe make another
// WidgetGroup for non-gameplay UI elements in the future.
mobileUI.top();
if (Core.settings.getBool("macnotch"))
mobileUI.margin(Vars.macNotchHeight);
mobileUI.name = "ClutterUI";
mobileUI.visible(() -> true);
// pauseHeight is 36f according to
// mindustry.ui.fragments.HudFragment.pauseheght. It is private and final so I
// cannot call it.

Events.run(Trigger.update, () -> {

Log.info("update");
this.mobileUI.fill(mobileUI -> {
mobileUIProperties(mobileUI);
buildCoreItemsDisplay(mobileUI);

});
});

}

private void mobileUIProperties(Table mobileUI) {
// for future me, this is where you put your UI stuff so they go in the mobileUI
// WidgetGroup instead of hudGroup which IMO is jank. Maybe make another
// WidgetGroup for non-gameplay UI elements in the future.
mobileUI.top();
if (Core.settings.getBool("macnotch"))
mobileUI.margin(Vars.macNotchHeight);
mobileUI.name = "ClutterUI";
mobileUI.visible(() -> true);
// pauseHeight is 36f according to
// mindustry.ui.fragments.HudFragment.pauseheght. It is private and final so I
// cannot call it.
}

private void buildCoreItemsDisplay(Table mobileUI) {
this.mobileUI.addChild(coreItemsDisplay);
mobileUI.collapser(v -> v.add().height(36f), () -> state.isPaused() && !Vars.netServer.isWaitingForPlayers())
Expand Down

0 comments on commit 85deb4b

Please sign in to comment.