Fixed up more things to do with JavaFX, and added some extra stuff for the MinecraftScreen

This commit is contained in:
coolGi
2023-03-17 22:29:28 +10:30
parent 2d8027cd28
commit 6d29f58ebd
4 changed files with 44 additions and 21 deletions
@@ -2,22 +2,25 @@ package com.seibel.lod.common.wrappers.gui;
import com.seibel.lod.core.ModInfo;
import com.seibel.lod.core.config.ConfigBase;
import com.seibel.lod.core.config.gui.ConfigScreen;
import com.seibel.lod.core.config.gui.JavaFXConfigScreen;
import com.seibel.lod.core.config.gui.OpenGLConfigScreen;
import net.minecraft.client.gui.screens.Screen;
public class GetConfigScreen {
public static type useScreen = type.Classic;
public static enum type {
Classic,
OpenGL;
@Deprecated
OpenGL, // This was jsut an attempt, it didnt work out and we are going to change to javafx soon
JavaFX;
}
public static Screen getScreen(Screen parent) {
if (useScreen == type.Classic) {
return ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
} else if (useScreen == type.OpenGL) {
return MinecraftScreen.getScreen(parent, new ConfigScreen(), ModInfo.ID + ".title");
}
return null;
return switch (useScreen) {
case Classic -> ClassicConfigGUI.getScreen(ConfigBase.INSTANCE, parent, "client");
case OpenGL -> MinecraftScreen.getScreen(parent, new OpenGLConfigScreen(), ModInfo.ID + ".title");
case JavaFX -> MinecraftScreen.getScreen(parent, new JavaFXConfigScreen(), ModInfo.ID + ".title");
default -> null;
};
}
}
@@ -5,7 +5,9 @@ import com.seibel.lod.core.config.gui.AbstractScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.NotNull;
import java.nio.file.Path;
import java.util.*;
public class MinecraftScreen {
@@ -53,8 +55,6 @@ public class MinecraftScreen {
this.renderBackground(matrices); // Render background
this.list.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
screen.width = this.width; // Is there a way to only call this when the window changes the size
screen.height = this.height; // Is there a way to only call this when the window changes the size
screen.mouseX = mouseX;
screen.mouseY = mouseY;
screen.render(delta); // Render everything on the main screen
@@ -62,6 +62,12 @@ public class MinecraftScreen {
super.render(matrices, mouseX, mouseY, delta); // Render the vanilla stuff (currently only used for the background and tint)
}
@Override
public void resize(Minecraft mc, int width, int height) {
screen.width = this.width;
screen.height = this.height;
}
@Override
public void tick() {
screen.tick();
@@ -75,6 +81,11 @@ public class MinecraftScreen {
Objects.requireNonNull(minecraft).setScreen(this.parent); // Goto the parent screen
}
@Override
public void onFilesDrop(@NotNull List<Path> files) {
screen.onFilesDrop(files);
}
// For checking if it should close when you press the escape key
@Override
public boolean shouldCloseOnEsc() {