|
|
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..ed3778d
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,54 @@
+plugins {
+ id "architectury-plugin" version "3.4-SNAPSHOT"
+ id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
+}
+
+architectury {
+ minecraft = rootProject.minecraft_version
+}
+
+subprojects {
+ apply plugin: "dev.architectury.loom"
+
+ loom {
+ silentMojangMappingsLicense()
+ }
+
+ dependencies {
+ minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
+ // The following line declares the mojmap mappings, you may use other mappings as well
+ mappings loom.officialMojangMappings()
+ // The following line declares the yarn mappings you may select this one as well.
+ // mappings "net.fabricmc:yarn:1.20.1+build.10:v2"
+ }
+}
+
+allprojects {
+ apply plugin: "java"
+ apply plugin: "architectury-plugin"
+ apply plugin: "maven-publish"
+
+ base {
+ archivesName = rootProject.archives_base_name
+ }
+
+ version = rootProject.mod_version
+ group = rootProject.maven_group
+
+ repositories {
+ // Add repositories to retrieve artifacts from in here.
+ // You should only use this when depending on other mods because
+ // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
+ // See https://docs.gradle.org/current/userguide/declaring_repositories.html
+ // for more information about repositories.
+ }
+
+ tasks.withType(JavaCompile) {
+ options.encoding = "UTF-8"
+ options.release = 17
+ }
+
+ java {
+ withSourcesJar()
+ }
+}
diff --git a/common/build.gradle b/common/build.gradle
new file mode 100644
index 0000000..3772f38
--- /dev/null
+++ b/common/build.gradle
@@ -0,0 +1,46 @@
+architectury {
+ common(rootProject.enabled_platforms.split(","))
+}
+
+loom {
+ accessWidenerPath = file("src/main/resources/optionsprofiles.accesswidener")
+}
+
+repositories {
+ exclusiveContent {
+ forRepository {
+ maven {
+ name = "Modrinth"
+ url = "https://api.modrinth.com/maven"
+ }
+ }
+ filter {
+ includeGroup "maven.modrinth"
+ }
+ }
+}
+
+dependencies {
+ // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
+ // Do NOT use other classes from fabric loader
+ modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
+ // Remove the next line if you don't want to depend on the API
+ modApi "dev.architectury:architectury:${rootProject.architectury_version}"
+
+ // sodium
+ modImplementation "maven.modrinth:sodium:mc1.20.1-0.5.3"
+}
+
+publishing {
+ publications {
+ mavenCommon(MavenPublication) {
+ artifactId = rootProject.archives_base_name
+ from components.java
+ }
+ }
+
+ // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
+ repositories {
+ // Add repositories to publish to here.
+ }
+}
diff --git a/common/src/main/java/com/axolotlmaid/optionsprofiles/OptionsProfilesMod.java b/common/src/main/java/com/axolotlmaid/optionsprofiles/OptionsProfilesMod.java
new file mode 100644
index 0000000..07951b2
--- /dev/null
+++ b/common/src/main/java/com/axolotlmaid/optionsprofiles/OptionsProfilesMod.java
@@ -0,0 +1,23 @@
+package com.axolotlmaid.optionsprofiles;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class OptionsProfilesMod {
+ public static final String MOD_ID = "optionsprofiles";
+
+ public static void init() {
+ Path profilesDirectory = Paths.get("options-profiles");
+
+ if (Files.notExists(profilesDirectory)) {
+ try {
+ Files.createDirectory(profilesDirectory);
+ } catch (IOException e) {
+ System.out.println("An error occurred when creating the 'options-profiles' directory.");
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java b/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java
new file mode 100644
index 0000000..92c1f67
--- /dev/null
+++ b/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java
@@ -0,0 +1,55 @@
+package com.axolotlmaid.optionsprofiles.gui;
+
+import com.axolotlmaid.optionsprofiles.profiles.Profiles;
+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;
+import net.minecraft.network.chat.CommonComponents;
+import net.minecraft.network.chat.Component;
+
+public class EditProfileScreen extends Screen {
+ private final Screen lastScreen;
+ private final Component profileName;
+
+ private EditBox profileNameEdit;
+
+ public EditProfileScreen(Screen screen, Component profileName) {
+ super(Component.literal(Component.translatable("gui.optionsprofiles.editing-profile-title").getString() + profileName.getString()));
+ this.lastScreen = 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.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(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(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(Button.builder(CommonComponents.GUI_DONE, (button) -> {
+ this.minecraft.setScreen(this.lastScreen);
+ }).size(100, 20).pos(this.width / 2 - 50, this.height - 40).build());
+ }
+
+ 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);
+ }
+}
\ No newline at end of file
diff --git a/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/ProfilesList.java b/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/ProfilesList.java
new file mode 100644
index 0000000..a77c1a1
--- /dev/null
+++ b/common/src/main/java/com/axolotlmaid/optionsprofiles/gui/ProfilesList.java
@@ -0,0 +1,111 @@
+package com.axolotlmaid.optionsprofiles.gui;
+
+import com.axolotlmaid.optionsprofiles.profiles.Profiles;
+import com.google.common.collect.ImmutableList;
+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;
+import net.minecraft.client.gui.narration.NarratableEntry;
+import net.minecraft.network.chat.Component;
+
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Objects;
+
+public class ProfilesList extends ContainerObjectSelectionList)Txr=)%{qp`MU@4(H81@P2Nz_)a_3gY|TOaH`HUnCt9n>o16xbnuw`XX;>h
z4<7UlI ^e5b%fJ-cs12HWq9Q~iTbRz64~G7Pkr;HUJKmDYIJ0P@2#tk#H7J-b
z6Q@|u5)&a>7=lqWo$U6IAWq5IMM#8bItk;iB@5jqY^!-nN7VX|dL0^22NY6O%=XGR
z!diNH`$FZadAvzh!ZiAWB2Q+2&(jWyQAF>o@A-5XJ&)Feww9X5@?>lq0y&oN{!y_{
zW_{1+GFCe43SF^G^CJRQ)slV|!kkDoX{EpyMdLHkMWQ22LnGVB?i1w%BeS;~J3kO(
z42zwAA)@Gqp&J~*&O{>6{AYWK6NE~Ob~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