Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b251d1f
Add undo button in VOptionScreen.java
NotNekodev Nov 30, 2025
b2e7a4a
Change position of tooltips to be slightly below the option and align…
NotNekodev Nov 30, 2025
2b37f17
make colors more welcoming, add VGuiConstants.java add hovering colors
NotNekodev Nov 30, 2025
54caebf
rewrite tooltip system, to support different translations based on di…
NotNekodev Nov 30, 2025
2aad69d
more compact page button layout
NotNekodev Nov 30, 2025
8efec30
fix hovering of the undo button even when its not visible
NotNekodev Nov 30, 2025
9da51ec
make scrolling strings for options that are too long
NotNekodev Nov 30, 2025
701cf4c
Apply italicised option name for options, where the changes havent be…
NotNekodev Dec 1, 2025
d797d1b
Make the icon and the pageButtons more compact
NotNekodev Dec 1, 2025
a5ace88
initial revision for the search area + some ui positioning improvemen…
NotNekodev Dec 1, 2025
59d5413
fix warnings in the java code
NotNekodev Dec 1, 2025
51de9bc
first real search version
NotNekodev Dec 1, 2025
cf86e8f
add some styling for selection
NotNekodev Dec 1, 2025
0c353b4
add selection and such UX + a blinking cursor
NotNekodev Dec 1, 2025
68c0198
add a keybind for returning to the vanilla settings (Shift + P) and a…
NotNekodev Dec 1, 2025
a50e6c7
fix a bug, where you cant change to the vanilla screen when there is …
NotNekodev Dec 2, 2025
b7436ef
add fovEffectScale option
NotNekodev Dec 2, 2025
cb4e1df
add glint options (glintSpeed and glintStrength) + change vulkanmod.o…
NotNekodev Dec 2, 2025
f4fc07c
WindowMode, VideoMode and all that has been rewritten and Config has …
NotNekodev Dec 2, 2025
f9f3845
make error logging in Config.java more robust
NotNekodev Dec 2, 2025
85ddb21
fix some small warnings
NotNekodev Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/main/java/net/vulkanmod/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,7 @@ public void onInitializeClient() {
}

private static Config loadConfig(Path path) {
Config config = Config.load(path);

if(config == null) {
config = new Config();
config.write();
}

return config;
return Config.load(path);
}

public static String getVersion() {
Expand Down
141 changes: 104 additions & 37 deletions src/main/java/net/vulkanmod/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,75 +1,142 @@
package net.vulkanmod.config;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.*;
import com.google.gson.annotations.JsonAdapter;
import net.vulkanmod.Initializer;
import net.vulkanmod.config.video.VideoMode;
import net.vulkanmod.config.video.VideoModeManager;
import net.vulkanmod.config.video.VideoModeSet;

import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;

@JsonAdapter(Config.GsonAdapter.class)
public class Config {
public VideoModeSet.VideoMode videoMode = VideoModeManager.getFirstAvailable().getVideoMode();

public VideoMode videoMode;
public int windowMode = 0;

public int advCulling = 2;
public boolean indirectDraw = true;

public boolean uniqueOpaqueLayer = true;
public boolean entityCulling = true;
public int device = -1;

public int ambientOcclusion = 1;
public int frameQueueSize = 2;
public int builderThreads = 0;

public boolean backFaceCulling = true;
public boolean textureAnimations = true;

public void write() {
public int device = -1;

if(!Files.exists(CONFIG_PATH.getParent())) {
try {
Files.createDirectories(CONFIG_PATH);
} catch (IOException e) {
e.printStackTrace();
}
}
private static Path CONFIG_PATH;
private static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
.registerTypeAdapter(Config.class, new GsonAdapter())
.create();

public void save() {
try {
Files.write(CONFIG_PATH, Collections.singleton(GSON.toJson(this)));
Files.createDirectories(CONFIG_PATH.getParent());
Files.writeString(CONFIG_PATH, GSON.toJson(this));
} catch (IOException e) {
e.printStackTrace();
Initializer.LOGGER.error("Error saving config file!", e);
}
}

private static Path CONFIG_PATH;

private static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
.excludeFieldsWithModifiers(Modifier.PRIVATE)
.create();

public static Config load(Path path) {
Config config;
Config.CONFIG_PATH = path;
CONFIG_PATH = path;

if (Files.exists(path)) {
try (FileReader fileReader = new FileReader(path.toFile())) {
config = GSON.fromJson(fileReader, Config.class);
try {
String content = Files.readString(path);
Config config = GSON.fromJson(content, Config.class);

if (config.videoMode == null ||
VideoModeManager.findSetFor(config.videoMode) == null) {
config.videoMode = VideoModeManager.currentOsMode();
}

return config;
} catch (IOException | JsonSyntaxException e) {
System.err.println("Failed to load config, using defaults: " + e.getMessage());
}
catch (IOException exception) {
throw new RuntimeException(exception.getMessage());
}

Config config = new Config();
config.videoMode = VideoModeManager.currentOsMode();
return config;
}

public static class GsonAdapter implements JsonSerializer<Config>, JsonDeserializer<Config> {

@Override
public JsonElement serialize(Config src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
JsonObject obj = new JsonObject();

if (src.videoMode != null) {
JsonObject vm = new JsonObject();
vm.addProperty("width", src.videoMode.width());
vm.addProperty("height", src.videoMode.height());
vm.addProperty("bitDepth", src.videoMode.bitDepth());
vm.addProperty("refreshRate", src.videoMode.refreshRate());
obj.add("videoMode", vm);
}

obj.addProperty("windowMode", src.windowMode);
obj.addProperty("advCulling", src.advCulling);
obj.addProperty("indirectDraw", src.indirectDraw);
obj.addProperty("uniqueOpaqueLayer", src.uniqueOpaqueLayer);
obj.addProperty("entityCulling", src.entityCulling);
obj.addProperty("ambientOcclusion", src.ambientOcclusion);
obj.addProperty("frameQueueSize", src.frameQueueSize);
obj.addProperty("builderThreads", src.builderThreads);
obj.addProperty("backFaceCulling", src.backFaceCulling);
obj.addProperty("textureAnimations", src.textureAnimations);
obj.addProperty("device", src.device);

return obj;
}
else {
config = null;

@Override
public Config deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
Config config = new Config();
JsonObject obj = json.getAsJsonObject();

if (obj.has("videoMode")) {
JsonObject vm = obj.getAsJsonObject("videoMode");
int w = getInt(vm, "width", 1920);
int h = getInt(vm, "height", 1080);
int bd = getInt(vm, "bitDepth", 8);
int rr = getInt(vm, "refreshRate", 60);
config.videoMode = new VideoMode(w, h, bd, rr);
} else {
config.videoMode = VideoModeManager.currentOsMode();
}

config.windowMode = getInt(obj, "windowMode", 0);
config.advCulling = getInt(obj, "advCulling", 2);
config.indirectDraw = getBoolean(obj, "indirectDraw");
config.uniqueOpaqueLayer = getBoolean(obj, "uniqueOpaqueLayer");
config.entityCulling = getBoolean(obj, "entityCulling");
config.ambientOcclusion = getInt(obj, "ambientOcclusion", 1);
config.frameQueueSize = getInt(obj, "frameQueueSize", 2);
config.builderThreads = getInt(obj, "builderThreads", 0);
config.backFaceCulling = getBoolean(obj, "backFaceCulling");
config.textureAnimations = getBoolean(obj, "textureAnimations");
config.device = getInt(obj, "device", -1);

return config;
}

return config;
private int getInt(JsonObject obj, String key, int def) {
JsonElement el = obj.get(key);
return el != null && el.isJsonPrimitive() ? el.getAsInt() : def;
}

private boolean getBoolean(JsonObject obj, String key) {
JsonElement el = obj.get(key);
return el == null || !el.isJsonPrimitive() || el.getAsBoolean();
}
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/net/vulkanmod/config/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void init() {
Configuration.STACK_SIZE.set(256);

GLFW.glfwInitHint(GLFW_PLATFORM, activePlat);
LOGGER.info("Selecting Platform: {}", getStringFromPlat(activePlat));
LOGGER.info("Selecting Platform: {}", getStringFromPlat());
LOGGER.info("GLFW: {}", GLFW.glfwGetVersionString());
GLFW.glfwInit();
}
Expand All @@ -43,14 +43,14 @@ private static int getSupportedPlat() {
return GLFW_ANY_PLATFORM; //Unknown platform
}

private static String getStringFromPlat(int plat) {
return switch (plat) {
private static String getStringFromPlat() {
return switch (Platform.activePlat) {
case GLFW_PLATFORM_WIN32 -> "WIN32";
case GLFW_PLATFORM_WAYLAND -> "WAYLAND";
case GLFW_PLATFORM_X11 -> "X11";
case GLFW_PLATFORM_COCOA -> "MACOS";
case GLFW_ANY_PLATFORM -> "ANDROID";
default -> throw new IllegalStateException("Unexpected value: " + plat);
default -> throw new IllegalStateException("Unexpected value: " + Platform.activePlat);
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/net/vulkanmod/config/gui/GuiElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.input.MouseButtonEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public abstract class GuiElement implements GuiEventListener, NarratableEntry {
Expand All @@ -22,6 +22,7 @@ public abstract class GuiElement implements GuiEventListener, NarratableEntry {
protected int hoverTime;
protected long hoverStopTime;

@SuppressWarnings("unused") // this will surely be used some day
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
Expand All @@ -34,6 +35,7 @@ public void setPosition(int x, int y, int width, int height) {
this.height = height;
}

@SuppressWarnings("unused") // this will surely be used someday
public void resize(int width, int height) {
this.width = width;
this.height = height;
Expand Down Expand Up @@ -102,7 +104,7 @@ public ComponentPath getCurrentFocusPath() {
}

@Override
public ScreenRectangle getRectangle() {
public @NotNull ScreenRectangle getRectangle() {
return GuiEventListener.super.getRectangle();
}

Expand All @@ -117,7 +119,7 @@ public boolean isFocused() {
}

@Override
public NarrationPriority narrationPriority() {
public @NotNull NarrationPriority narrationPriority() {
return NarrationPriority.NONE;
}

Expand Down
Loading