Compare commits

...

1 commit

Author SHA1 Message Date
AxolotlMaid
b4595f1eb8 Port to 1.19.2 2024-01-23 21:09:47 +00:00
11 changed files with 107 additions and 89 deletions

View file

@ -28,7 +28,7 @@ dependencies {
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
// sodium
modImplementation "maven.modrinth:sodium:mc1.20.1-0.5.3"
modImplementation "maven.modrinth:sodium:mc1.19.2-0.4.4"
}
publishing {

View file

@ -1,8 +1,8 @@
package com.axolotlmaid.optionsprofiles.gui;
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen;
@ -10,46 +10,47 @@ import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
public class EditProfileScreen extends Screen {
private final Screen lastScreen;
private final Screen parent;
private final Component profileName;
private EditBox profileNameEdit;
private EditBox profileNameEditbox;
public EditProfileScreen(Screen screen, Component profileName) {
super(Component.literal(Component.translatable("gui.optionsprofiles.editing-profile-title").getString() + profileName.getString()));
this.lastScreen = screen;
this.parent = screen;
this.profileName = profileName;
}
protected void init() {
this.profileNameEdit = new EditBox(this.font, this.width / 2 - 102, this.height - 130, 204, 20, Component.empty());
this.profileNameEdit.setValue(profileName.getString());
this.addWidget(this.profileNameEdit);
this.profileNameEditbox = new EditBox(this.font, this.width / 2 - 102, this.height - 130, 204, 20, Component.empty());
this.profileNameEditbox.setValue(profileName.getString());
this.addWidget(this.profileNameEditbox);
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.overwrite-options"), (button) -> {
new Profiles().writeOptionsFilesIntoProfile(profileName.getString());
this.minecraft.setScreen(this.lastScreen);
}).size(100, 20).pos(this.width / 2 - 50, this.height - 85).build());
this.addRenderableWidget(new Button(this.width / 2 - 50, this.height - 85, 100, 20, Component.translatable("gui.optionsprofiles.overwrite-options"), (button) -> {
Profiles.writeOptionsFilesIntoProfile(profileName.getString());
this.minecraft.setScreen(this.parent);
}));
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.rename-profile"), (button) -> {
new Profiles().renameProfile(profileName.getString(), this.profileNameEdit.getValue());
this.minecraft.setScreen(new EditProfileScreen(lastScreen, Component.literal(this.profileNameEdit.getValue())));
}).size(100, 20).pos(this.width / 2 - 50, this.height - 65).build());
this.addRenderableWidget(new Button(this.width / 2 - 50, this.height - 65, 100, 20, Component.translatable("gui.optionsprofiles.rename-profile"), (button) -> {
Profiles.renameProfile(profileName.getString(), this.profileNameEditbox.getValue());
this.minecraft.setScreen(new EditProfileScreen(parent, Component.literal(this.profileNameEditbox.getValue())));
}));
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.delete-profile").withStyle(ChatFormatting.RED), (button) -> {
new Profiles().deleteProfile(profileName.getString());
this.minecraft.setScreen(this.lastScreen);
}).size(100, 20).pos(5, this.height - 25).build());
this.addRenderableWidget(new Button(5, this.height - 25, 100, 20, Component.translatable("gui.optionsprofiles.delete-profile").withStyle(ChatFormatting.RED), (button) -> {
Profiles.deleteProfile(profileName.getString());
this.minecraft.setScreen(this.parent);
}));
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.minecraft.setScreen(this.lastScreen);
}).size(100, 20).pos(this.width / 2 - 50, this.height - 40).build());
this.addRenderableWidget(new Button(this.width / 2 - 50, this.height - 40, 100, 20, CommonComponents.GUI_DONE, (button) -> {
this.minecraft.setScreen(this.parent);
}));
}
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
super.render(guiGraphics, mouseX, mouseY, delta);
this.profileNameEdit.render(guiGraphics, mouseX, mouseY, delta);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 16777215);
guiGraphics.drawCenteredString(this.font, Component.translatable("gui.optionsprofiles.profile-name-text"), this.width / 2, this.height - 145, 16777215);
public void render(PoseStack p_96249_, int p_96250_, int p_96251_, float delta) {
this.renderBackground(p_96249_);
this.profileNameEditbox.render(p_96249_, p_96250_, p_96251_, delta);
drawCenteredString(p_96249_, this.font, this.title, this.width / 2, 8, 16777215);
drawCenteredString(p_96249_, this.font, Component.translatable("gui.optionsprofiles.profile-name-text"), this.width / 2, this.height - 145, 16777215);
super.render(p_96249_, p_96250_, p_96251_, delta);
}
}

View file

@ -2,9 +2,9 @@ package com.axolotlmaid.optionsprofiles.gui;
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.components.events.GuiEventListener;
@ -22,7 +22,7 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
final ProfilesScreen profilesScreen;
public ProfilesList(ProfilesScreen profilesScreen, Minecraft minecraft) {
super(minecraft, profilesScreen.width + 45, profilesScreen.height - 52, 20, 20);
super(minecraft, profilesScreen.width + 45, profilesScreen.height, 20, profilesScreen.height - 32, 20);
this.profilesScreen = profilesScreen;
refreshEntries();
@ -56,15 +56,15 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
private final Button editButton;
private final Button loadButton;
ProfileEntry(Component profileName) {
ProfileEntry(final Component profileName) {
this.profileName = profileName;
this.editButton = Button.builder(Component.translatable("gui.optionsprofiles.edit-profile"), (button) -> {
minecraft.setScreen(new EditProfileScreen(profilesScreen, profileName));
}).size(75, 20).createNarration((supplier) -> Component.translatable("gui.optionsprofiles.edit-profile")).build();
this.editButton = new Button(0, 0, 75, 20, Component.translatable("gui.optionsprofiles.edit-profile"), (button) -> {
ProfilesList.this.minecraft.setScreen(new EditProfileScreen(profilesScreen, profileName));
});
this.loadButton = Button.builder(Component.translatable("gui.optionsprofiles.load-profile"), (button) -> {
new Profiles().loadProfile(profileName.getString());
this.loadButton = new Button(0, 0, 75, 20, Component.translatable("gui.optionsprofiles.load-profile"), (button) -> {
Profiles.loadProfile(profileName.getString());
minecraft.options.load();
minecraft.options.loadSelectedResourcePacks(minecraft.getResourcePackRepository());
@ -73,26 +73,21 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
minecraft.options.save();
button.active = false;
}).size(75, 20).createNarration((supplier) -> Component.translatable("gui.optionsprofiles.load-profile")).build();
});
this.loadButton.active = !new Profiles().isProfileLoaded(profileName.getString());
this.loadButton.active = !Profiles.isProfileLoaded(profileName.getString());
}
public void render(GuiGraphics guiGraphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
Font fontRenderer = ProfilesList.this.minecraft.font;
public void render(PoseStack p_193923_, int p_193924_, int p_193925_, int p_193926_, int p_193927_, int p_193928_, int p_193929_, int p_193930_, boolean p_193931_, float p_193932_) {
ProfilesList.this.minecraft.font.draw(p_193923_, this.profileName, p_193926_, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215);
int textY = y + entryHeight / 2;
this.loadButton.x = p_193926_ + 190;
this.loadButton.y = p_193925_;
this.loadButton.render(p_193923_, p_193929_, p_193930_, p_193932_);
Objects.requireNonNull(ProfilesList.this.minecraft.font);
guiGraphics.drawString(fontRenderer, this.profileName, x - 50, textY - 9 / 2, 16777215, false);
this.editButton.setX(x + 115);
this.editButton.setY(y);
this.editButton.render(guiGraphics, mouseX, mouseY, tickDelta);
this.loadButton.setX(x + 190);
this.loadButton.setY(y);
this.loadButton.render(guiGraphics, mouseX, mouseY, tickDelta);
this.editButton.x = p_193926_ + 115;
this.editButton.y = p_193925_;
this.editButton.render(p_193923_, p_193929_, p_193930_, p_193932_);
}
public List<? extends GuiEventListener> children() {
@ -102,6 +97,18 @@ public class ProfilesList extends ContainerObjectSelectionList<ProfilesList.Entr
public List<? extends NarratableEntry> narratables() {
return ImmutableList.of(this.editButton, this.loadButton);
}
public boolean mouseClicked(double p_193919_, double p_193920_, int p_193921_) {
if (this.editButton.mouseClicked(p_193919_, p_193920_, p_193921_)) {
return true;
} else {
return this.loadButton.mouseClicked(p_193919_, p_193920_, p_193921_);
}
}
public boolean mouseReleased(double p_193941_, double p_193942_, int p_193943_) {
return this.editButton.mouseReleased(p_193941_, p_193942_, p_193943_) || this.loadButton.mouseReleased(p_193941_, p_193942_, p_193943_);
}
}
public abstract static class Entry extends ContainerObjectSelectionList.Entry<ProfilesList.Entry> {

View file

@ -1,19 +1,21 @@
package com.axolotlmaid.optionsprofiles.gui;
import com.axolotlmaid.optionsprofiles.profiles.Profiles;
import net.minecraft.client.gui.GuiGraphics;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import java.util.ArrayList;
public class ProfilesScreen extends Screen {
private final Screen lastScreen;
private final Screen parent;
private ProfilesList profilesList;
public ProfilesScreen(Screen screen) {
public ProfilesScreen(Screen parent) {
super(Component.translatable("gui.optionsprofiles.profiles-menu"));
this.lastScreen = screen;
this.parent = parent;
}
protected void init() {
@ -21,19 +23,20 @@ public class ProfilesScreen extends Screen {
this.addWidget(this.profilesList);
// buttons
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.save-current-options"), (button) -> {
new Profiles().createProfile();
this.addRenderableWidget(new Button(this.width / 2 - 155, this.height - 29, 150, 20, Component.translatable("gui.optionsprofiles.save-current-options"), (button) -> {
Profiles.createProfile();
this.profilesList.refreshEntries();
}).size(150, 20).pos(this.width / 2 - 155, this.height - 29).build());
}));
this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (button) -> {
this.minecraft.setScreen(this.lastScreen);
}).size(150, 20).pos(this.width / 2 + 5, this.height - 29).build());
this.addRenderableWidget(new Button(this.width / 2 + 5, this.height - 29, 150, 20, CommonComponents.GUI_DONE, (button) -> {
this.minecraft.setScreen(this.parent);
}));
}
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
super.render(guiGraphics, mouseX, mouseY, delta);
this.profilesList.render(guiGraphics, mouseX, mouseY, delta);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 16777215);
public void render(PoseStack p_96249_, int p_96250_, int p_96251_, float p_96252_) {
this.renderBackground(p_96249_);
this.profilesList.render(p_96249_, p_96250_, p_96251_, p_96252_);
drawCenteredString(p_96249_, this.font, this.title, this.width / 2, 8, 16777215);
super.render(p_96249_, p_96250_, p_96251_, p_96252_);
}
}

View file

@ -10,6 +10,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
protected MixinOptionsScreen(Component component) {
@ -18,8 +20,8 @@ public class MixinOptionsScreen extends Screen {
@Inject(at = @At("HEAD"), method = "init")
private void init(CallbackInfo info) {
this.addRenderableWidget(Button.builder(Component.translatable("gui.optionsprofiles.profiles-menu"), (button) -> {
this.addRenderableWidget(new Button(5, 5, 100, 20, Component.translatable("gui.optionsprofiles.profiles-menu"), (button) -> {
this.minecraft.setScreen(new ProfilesScreen(this));
}).width(100).pos(5, 5).build());
}));
}
}

View file

@ -13,7 +13,7 @@ import java.util.List;
import java.util.stream.Stream;
public class Profiles {
public void createProfile() {
public static void createProfile() {
String profileName = "Profile 1";
Path profile = Paths.get("options-profiles/" + profileName);
@ -38,7 +38,7 @@ public class Profiles {
}
}
public void writeOptionsFilesIntoProfile(String profileName) {
public static void writeOptionsFilesIntoProfile(String profileName) {
Path profile = Paths.get("options-profiles/" + profileName);
// options.txt
@ -90,7 +90,7 @@ public class Profiles {
}
}
public boolean isProfileLoaded(String profileName) {
public static boolean isProfileLoaded(String profileName) {
Path profile = Paths.get("options-profiles/" + profileName);
Path options = Paths.get("options.txt");
@ -122,7 +122,7 @@ public class Profiles {
return false;
}
public void loadProfile(String profileName) {
public static void loadProfile(String profileName) {
Path profile = Paths.get("options-profiles/" + profileName);
// options.txt
@ -158,7 +158,7 @@ public class Profiles {
}
}
public void renameProfile(String profileName, String newProfileName) {
public static void renameProfile(String profileName, String newProfileName) {
Path profile = Paths.get("options-profiles/" + profileName);
Path newProfile = Paths.get("options-profiles/" + newProfileName);
@ -179,7 +179,7 @@ public class Profiles {
}
}
public void deleteProfile(String profileName) {
public static void deleteProfile(String profileName) {
Path profile = Paths.get("options-profiles/" + profileName);
try (Stream<Path> files = Files.walk(profile)) {

View file

@ -26,17 +26,20 @@ public class SodiumConfigLoader {
SodiumClientMod.options().quality.leavesQuality = SodiumGameOptions.GraphicsQuality.valueOf(configData.quality.leaves_quality);
SodiumClientMod.options().quality.enableVignette = configData.quality.enable_vignette;
SodiumClientMod.options().advanced.arenaMemoryAllocator = SodiumGameOptions.ArenaMemoryAllocator.valueOf(configData.advanced.arena_memory_allocator);
SodiumClientMod.options().advanced.allowDirectMemoryAccess = configData.advanced.allow_direct_memory_access;
SodiumClientMod.options().advanced.enableMemoryTracing = configData.advanced.enable_memory_tracing;
SodiumClientMod.options().advanced.useAdvancedStagingBuffers = configData.advanced.use_advanced_staging_buffers;
SodiumClientMod.options().advanced.cpuRenderAheadLimit = configData.advanced.cpu_render_ahead_limit;
SodiumClientMod.options().performance.chunkBuilderThreads = configData.performance.chunk_builder_threads;
SodiumClientMod.options().performance.alwaysDeferChunkUpdates = configData.performance.always_defer_chunk_updates_v2;
SodiumClientMod.options().performance.alwaysDeferChunkUpdates = configData.performance.always_defer_chunk_updates;
SodiumClientMod.options().performance.animateOnlyVisibleTextures = configData.performance.animate_only_visible_textures;
SodiumClientMod.options().performance.useEntityCulling = configData.performance.use_entity_culling;
SodiumClientMod.options().performance.useParticleCulling = configData.performance.use_particle_culling;
SodiumClientMod.options().performance.useFogOcclusion = configData.performance.use_fog_occlusion;
SodiumClientMod.options().performance.useBlockFaceCulling = configData.performance.use_block_face_culling;
SodiumClientMod.options().performance.useNoErrorGLContext = configData.performance.use_no_error_g_l_context;
// SodiumClientMod.options() = configData.performance.use_no_error_g_l_context;
SodiumClientMod.options().notifications.hideDonationButton = configData.notifications.hide_donation_button;
@ -60,6 +63,8 @@ public class SodiumConfigLoader {
}
public static class Advanced {
public String arena_memory_allocator;
public boolean allow_direct_memory_access;
public boolean enable_memory_tracing;
public boolean use_advanced_staging_buffers;
public int cpu_render_ahead_limit;
@ -67,12 +72,12 @@ public class SodiumConfigLoader {
public static class Performance {
public int chunk_builder_threads;
public boolean always_defer_chunk_updates_v2;
public boolean always_defer_chunk_updates;
public boolean animate_only_visible_textures;
public boolean use_entity_culling;
public boolean use_particle_culling;
public boolean use_fog_occlusion;
public boolean use_block_face_culling;
public boolean use_no_error_g_l_context;
}
public static class Notifications {

View file

@ -26,7 +26,7 @@
],
"depends": {
"fabric": "*",
"minecraft": ">=1.20.4",
"architectury": ">=11.0.10"
"minecraft": ">=1.19.2",
"architectury": ">=6.5.85"
}
}

View file

@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[49,)"
loaderVersion = "[43,)"
#issueTrackerURL = ""
license = "GNU GPL 3.0"
@ -16,20 +16,20 @@ logoFile = "icon.png"
[[dependencies.optionsprofiles]]
modId = "forge"
mandatory = true
versionRange = "[49,)"
versionRange = "[43,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.optionsprofiles]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20.4,)"
versionRange = "[1.19.2,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.optionsprofiles]]
modId = "architectury"
mandatory = true
versionRange = "[11.0.10,)"
versionRange = "[6.5.85,)"
ordering = "AFTER"
side = "BOTH"

View file

@ -1,15 +1,15 @@
org.gradle.jvmargs=-Xmx6G
minecraft_version=1.20.4
minecraft_version=1.19.2
enabled_platforms=fabric,forge
archives_base_name=optionsprofiles
mod_version=1.1
maven_group=com.axolotlmaid.optionsprofiles
architectury_version=11.0.10
architectury_version=6.5.85
fabric_loader_version=0.15.3
fabric_api_version=0.92.1+1.20.4
fabric_loader_version=0.15.4
fabric_api_version=0.77.0+1.19.2
forge_version=1.20.4-49.0.14
forge_version=1.19.2-43.3.7

View file

@ -11,4 +11,4 @@ include("common")
include("fabric")
include("forge")
rootProject.name = "optionsprofiles-v1.1-1.20.4"
rootProject.name = "optionsprofiles-v1.1-1.19.2"