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
+19 -10
View File
@@ -99,14 +99,13 @@ subprojects { p ->
// Apply plugins
apply plugin: "java"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "org.openjfx.javafxplugin"
if (isMinecraftSubProject)
apply plugin: "systems.manifold.manifold-gradle-plugin"
apply plugin: "com.github.johnrengelman.shadow"
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
if (p == project(":core")) {
if (p == project(":core"))
apply plugin: "application"
apply plugin: "org.openjfx.javafxplugin"
}
// apply plugin: "org.spongepowered.gradle.vanilla" // Provides minecraft libraries
// Set the manifold version (may not be required tough)
@@ -139,11 +138,11 @@ subprojects { p ->
application {
mainClass.set("com.seibel.lod.core.jar.JarMain")
}
javafx {
version = "19"
modules = ["javafx.controls"]
}
}
// Remember, to shadow it you need to add it in the dependency part
javafx {
version = "${rootProject.javafx_version}"
modules = ["javafx.swing", "javafx.controls", "javafx.graphics"]
}
dependencies {
@@ -177,6 +176,16 @@ subprojects { p ->
// SVG
shadowMe("com.formdev:svgSalamander:${rootProject.svgSalamander_version}")
// JavaFX/OpenJFX
// Remember, you also need to define jfx modules in its own jfx thing
// This part of the code is just to shadow the libraries
// FIXME: This doesnt work, find a workaround
shadowMe("org.openjfx:javafx:${rootProject.javafx_version}")
shadowMe("org.openjfx:javafx-base:${rootProject.javafx_version}")
shadowMe("org.openjfx:javafx-swing:${rootProject.javafx_version}")
shadowMe("org.openjfx:javafx-controls:${rootProject.javafx_version}")
shadowMe("org.openjfx:javafx-graphics:${rootProject.javafx_version}")
@@ -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() {
+1 -1
View File
@@ -19,7 +19,7 @@ mod_discord=https://discord.gg/xAB8G4cENx
manifold_version=2023.1.0
toml_version=3.6.4
nightconfig_version=3.6.6
flatlaf_version=2.3
javafx_version=19
svgSalamander_version=1.1.3
log4j_version=2.19.0