Fix incorrect layering of vanilla gui additions (fixes #385)

This commit is contained in:
Jonas Herzig
2020-11-05 15:27:49 +01:00
parent 8f094000fe
commit 6fc7b8fb0f
8 changed files with 19 additions and 11 deletions

2
jGui

Submodule jGui updated: 5e515a2ecc...5127217e0d

View File

@@ -38,7 +38,8 @@ public class GuiBackgroundProcesses extends EventRegistrations {
//#endif //#endif
if (guiScreen != getMinecraft().currentScreen) return; // people tend to construct GuiScreens without opening them if (guiScreen != getMinecraft().currentScreen) return; // people tend to construct GuiScreens without opening them
VanillaGuiScreen.setup(guiScreen).setLayout(new CustomLayout<GuiScreen>() { VanillaGuiScreen vanillaGui = VanillaGuiScreen.wrap(guiScreen);
vanillaGui.setLayout(new CustomLayout<GuiScreen>(vanillaGui.getLayout()) {
@Override @Override
protected void layout(GuiScreen container, int width, int height) { protected void layout(GuiScreen container, int width, int height) {
pos(panel, width - 5 - width(panel), 5); pos(panel, width - 5 - width(panel), 5);
@@ -76,6 +77,11 @@ public class GuiBackgroundProcesses extends EventRegistrations {
}); });
} }
@Override
public int getLayer() {
return 1;
}
@Override @Override
public ReadableDimension getMinSize() { public ReadableDimension getMinSize() {
ReadableDimension minSize = inner.getMinSize(); ReadableDimension minSize = inner.getMinSize();

View File

@@ -102,7 +102,7 @@ public class RestoreReplayGui extends AbstractGuiScreen<RestoreReplayGui> {
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Recovering replay file:", e); LOGGER.error("Recovering replay file:", e);
CrashReport crashReport = CrashReport.create(e, "Recovering replay file"); CrashReport crashReport = CrashReport.create(e, "Recovering replay file");
core.runLater(() -> Utils.error(LOGGER, VanillaGuiScreen.setup(getMinecraft().currentScreen), crashReport, () -> {})); core.runLater(() -> Utils.error(LOGGER, VanillaGuiScreen.wrap(getMinecraft().currentScreen), crashReport, () -> {}));
} finally { } finally {
core.runLater(() -> core.getBackgroundProcesses().removeProcess(savingProcess)); core.runLater(() -> core.getBackgroundProcesses().removeProcess(savingProcess));
} }

View File

@@ -107,7 +107,8 @@ public class GuiRecordingControls extends EventRegistrations {
.orElse(MCVer.findButton(buttonList, "menu.disconnect", 1)) .orElse(MCVer.findButton(buttonList, "menu.disconnect", 1))
.<Function<Integer, Integer>>map(it -> (height) -> it.y) .<Function<Integer, Integer>>map(it -> (height) -> it.y)
.orElse((height) -> height / 4 + 120 - 16); .orElse((height) -> height / 4 + 120 - 16);
VanillaGuiScreen.setup(guiScreen).setLayout(new CustomLayout<de.johni0702.minecraft.gui.container.GuiScreen>() { VanillaGuiScreen vanillaGui = VanillaGuiScreen.wrap(guiScreen);
vanillaGui.setLayout(new CustomLayout<de.johni0702.minecraft.gui.container.GuiScreen>(vanillaGui.getLayout()) {
@Override @Override
protected void layout(de.johni0702.minecraft.gui.container.GuiScreen container, int width, int height) { protected void layout(de.johni0702.minecraft.gui.container.GuiScreen container, int width, int height) {
pos(panel, width / 2 - 100, yPos.apply(height) + 16 + 8); pos(panel, width / 2 - 100, yPos.apply(height) + 16 + 8);

View File

@@ -140,7 +140,7 @@ public class GuiSavingReplay {
} catch (IOException e) { } catch (IOException e) {
logger.error("Deleting replay file:", e); logger.error("Deleting replay file:", e);
CrashReport crashReport = CrashReport.create(e, "Deleting replay file"); CrashReport crashReport = CrashReport.create(e, "Deleting replay file");
core.runLater(() -> Utils.error(logger, VanillaGuiScreen.setup(mc.currentScreen), crashReport, () -> {})); core.runLater(() -> Utils.error(logger, VanillaGuiScreen.wrap(mc.currentScreen), crashReport, () -> {}));
} }
return; return;
} }
@@ -155,7 +155,7 @@ public class GuiSavingReplay {
} catch (IOException e) { } catch (IOException e) {
logger.error("Renaming replay file:", e); logger.error("Renaming replay file:", e);
CrashReport crashReport = CrashReport.create(e, "Renaming replay file"); CrashReport crashReport = CrashReport.create(e, "Renaming replay file");
core.runLater(() -> Utils.error(logger, VanillaGuiScreen.setup(mc.currentScreen), crashReport, () -> {})); core.runLater(() -> Utils.error(logger, VanillaGuiScreen.wrap(mc.currentScreen), crashReport, () -> {}));
} }
} }
} }

View File

@@ -60,7 +60,8 @@ public class GuiHandler extends EventRegistrations {
settingsRegistry.save(); settingsRegistry.save();
}); });
VanillaGuiScreen.setup(gui).setLayout(new CustomLayout<GuiScreen>() { VanillaGuiScreen vanillaGui = VanillaGuiScreen.wrap(gui);
vanillaGui.setLayout(new CustomLayout<GuiScreen>(vanillaGui.getLayout()) {
@Override @Override
protected void layout(GuiScreen container, int width, int height) { protected void layout(GuiScreen container, int width, int height) {
//size(recordingCheckbox, 200, 20); //size(recordingCheckbox, 200, 20);
@@ -70,7 +71,7 @@ public class GuiHandler extends EventRegistrations {
} }
if (gui instanceof AddServerScreen) { if (gui instanceof AddServerScreen) {
VanillaGuiScreen vanillaGui = VanillaGuiScreen.setup(gui); VanillaGuiScreen vanillaGui = VanillaGuiScreen.wrap(gui);
GuiButton replayButton = new GuiReplayButton().onClick(() -> { GuiButton replayButton = new GuiReplayButton().onClick(() -> {
ServerInfo serverInfo = ((AddServerScreenAccessor) gui).getServer(); ServerInfo serverInfo = ((AddServerScreenAccessor) gui).getServer();
ServerInfoExt serverInfoExt = ServerInfoExt.from(serverInfo); ServerInfoExt serverInfoExt = ServerInfoExt.from(serverInfo);
@@ -89,7 +90,7 @@ public class GuiHandler extends EventRegistrations {
}); });
GuiInfoPopup.open(vanillaGui, autoRecording); GuiInfoPopup.open(vanillaGui, autoRecording);
}); });
vanillaGui.setLayout(new CustomLayout<GuiScreen>() { vanillaGui.setLayout(new CustomLayout<GuiScreen>(vanillaGui.getLayout()) {
@Override @Override
protected void layout(GuiScreen container, int width, int height) { protected void layout(GuiScreen container, int width, int height) {
size(replayButton, 20, 20); size(replayButton, 20, 20);

View File

@@ -277,7 +277,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
} catch (Exception e) { } catch (Exception e) {
logger.error("Saving replay file:", e); logger.error("Saving replay file:", e);
CrashReport crashReport = CrashReport.create(e, "Saving replay file"); CrashReport crashReport = CrashReport.create(e, "Saving replay file");
core.runLater(() -> Utils.error(logger, VanillaGuiScreen.setup(mc.currentScreen), crashReport, guiSavingReplay::close)); core.runLater(() -> Utils.error(logger, VanillaGuiScreen.wrap(mc.currentScreen), crashReport, guiSavingReplay::close));
return; return;
} }
} }

View File

@@ -88,7 +88,7 @@ public class ReplayModRender extends EventRegistrations implements Module {
RenderJob.writeQueue(replayFile, renderQueue); RenderJob.writeQueue(replayFile, renderQueue);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
VanillaGuiScreen screen = VanillaGuiScreen.setup(getCore().getMinecraft().currentScreen); VanillaGuiScreen screen = VanillaGuiScreen.wrap(getCore().getMinecraft().currentScreen);
CrashReport report = CrashReport.create(e, "Reading timeline"); CrashReport report = CrashReport.create(e, "Reading timeline");
Utils.error(LOGGER, screen, report, () -> {}); Utils.error(LOGGER, screen, report, () -> {});
} }