Fix #3 and add QOL feature
This commit is contained in:
parent
6c476c3ead
commit
a9dd4a6366
6 changed files with 23 additions and 68 deletions
|
|
@ -9,11 +9,7 @@ yarn_mappings=1.20+build.1
|
||||||
loader_version=0.14.21
|
loader_version=0.14.21
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
<<<<<<< Updated upstream
|
|
||||||
mod_version=1.0.2
|
|
||||||
=======
|
|
||||||
mod_version=1.0.3
|
mod_version=1.0.3
|
||||||
>>>>>>> Stashed changes
|
|
||||||
maven_group=dev.axolotlmaid.optionsprofiles
|
maven_group=dev.axolotlmaid.optionsprofiles
|
||||||
archives_base_name=options-profiles
|
archives_base_name=options-profiles
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,30 +66,6 @@ public class Profiles {
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
// Sodium
|
|
||||||
// The code below doesn't work
|
|
||||||
// if (FabricLoader.getInstance().isModLoaded("sodium")) {
|
|
||||||
// System.out.println("Found Sodium in mods.");
|
|
||||||
//
|
|
||||||
// File sodiumOptions = new File("config/sodium-options.json");
|
|
||||||
// File sodiumOptionsProfile = new File(path + profileName + "-sodium-options" + ".json");
|
|
||||||
//
|
|
||||||
// if (sodiumOptionsProfile.createNewFile())
|
|
||||||
// System.out.println("Sodium Options Profile was created successfully.");
|
|
||||||
//
|
|
||||||
// Scanner sodiumOptionsReader = new Scanner(sodiumOptions);
|
|
||||||
// FileWriter sodiumOptionsWriter = new FileWriter(sodiumOptionsProfile);
|
|
||||||
//
|
|
||||||
// while (sodiumOptionsReader.hasNextLine()) {
|
|
||||||
// String data = sodiumOptionsReader.nextLine();
|
|
||||||
// sodiumOptionsWriter.write(data);
|
|
||||||
// sodiumOptionsWriter.write("\n");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// sodiumOptionsWriter.close();
|
|
||||||
// sodiumOptionsReader.close();
|
|
||||||
// }
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("An error occurred when writing a profile.");
|
System.out.println("An error occurred when writing a profile.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -108,19 +84,6 @@ public class Profiles {
|
||||||
|
|
||||||
if (!profile.renameTo(newProfile))
|
if (!profile.renameTo(newProfile))
|
||||||
System.out.println("Profile was not renamed successfully.");
|
System.out.println("Profile was not renamed successfully.");
|
||||||
|
|
||||||
// Sodium
|
|
||||||
// The code below doesn't work
|
|
||||||
// if (FabricLoader.getInstance().isModLoaded("sodium")) {
|
|
||||||
// File sodiumOptionsProfile = new File(path + profileName + "-sodium-options" + ".json");
|
|
||||||
// File newSodiumOptionsProfile = new File(path + newProfileName + "-sodium-options" + ".json");
|
|
||||||
//
|
|
||||||
// if (newSodiumOptionsProfile.exists())
|
|
||||||
// System.out.println("New Sodium options profile already exists!");
|
|
||||||
//
|
|
||||||
// if (!sodiumOptionsProfile.renameTo(newSodiumOptionsProfile))
|
|
||||||
// System.out.println("Sodium options profile was not renamed successfully.");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteProfile(String profileName) {
|
public void deleteProfile(String profileName) {
|
||||||
|
|
@ -153,27 +116,6 @@ public class Profiles {
|
||||||
|
|
||||||
writer.close();
|
writer.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
// Sodium
|
|
||||||
// The code below doesn't work
|
|
||||||
// if (FabricLoader.getInstance().isModLoaded("sodium")) {
|
|
||||||
// System.out.println("Found Sodium in mods.");
|
|
||||||
//
|
|
||||||
// File sodiumOptions = new File("config/sodium-options.json");
|
|
||||||
// File sodiumOptionsProfile = new File(path + profileName + "-sodium-options" + ".json");
|
|
||||||
//
|
|
||||||
// Scanner sodiumOptionsReader = new Scanner(sodiumOptionsProfile);
|
|
||||||
// FileWriter sodiumOptionsWriter = new FileWriter(sodiumOptions);
|
|
||||||
//
|
|
||||||
// while (sodiumOptionsReader.hasNextLine()) {
|
|
||||||
// String data = sodiumOptionsReader.nextLine();
|
|
||||||
// sodiumOptionsWriter.write(data);
|
|
||||||
// sodiumOptionsWriter.write("\n");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// sodiumOptionsWriter.close();
|
|
||||||
// sodiumOptionsReader.close();
|
|
||||||
// }
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("An error occurred when creating a profile.");
|
System.out.println("An error occurred when creating a profile.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,10 @@ package dev.axolotlmaid.optionsprofiles.gui;
|
||||||
|
|
||||||
import dev.axolotlmaid.optionsprofiles.Profiles;
|
import dev.axolotlmaid.optionsprofiles.Profiles;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.screen.ScreenTexts;
|
import net.minecraft.screen.ScreenTexts;
|
||||||
import net.minecraft.text.OrderedText;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class EditProfileScreen extends Screen {
|
public class EditProfileScreen extends Screen {
|
||||||
|
|
@ -24,6 +21,7 @@ public class EditProfileScreen extends Screen {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
TextFieldWidget textfield = new TextFieldWidget(textRenderer, this.width / 2 - 102, this.height / 4 + 24, 204, 20, Text.translatable("profile-name-text-field"));
|
TextFieldWidget textfield = new TextFieldWidget(textRenderer, this.width / 2 - 102, this.height / 4 + 24, 204, 20, Text.translatable("profile-name-text-field"));
|
||||||
|
textfield.setText(profileName.getString());
|
||||||
this.addDrawableChild(textfield);
|
this.addDrawableChild(textfield);
|
||||||
|
|
||||||
this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.update-profile-text"), (button) -> {
|
this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.update-profile-text"), (button) -> {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package dev.axolotlmaid.optionsprofiles.gui;
|
package dev.axolotlmaid.optionsprofiles.gui;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import dev.axolotlmaid.optionsprofiles.Profiles;
|
import dev.axolotlmaid.optionsprofiles.Profiles;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
@ -11,6 +12,8 @@ import net.minecraft.client.gui.Element;
|
||||||
import net.minecraft.client.gui.Selectable;
|
import net.minecraft.client.gui.Selectable;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
import net.minecraft.client.gui.widget.ElementListWidget;
|
||||||
|
import net.minecraft.resource.ResourcePackManager;
|
||||||
|
import net.minecraft.resource.ResourcePackProfile;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
|
|
@ -63,6 +66,22 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
|
||||||
client.options.load();
|
client.options.load();
|
||||||
client.worldRenderer.reload();
|
client.worldRenderer.reload();
|
||||||
client.getSoundManager().reloadSounds();
|
client.getSoundManager().reloadSounds();
|
||||||
|
|
||||||
|
List<String> builtInResourcePacks = Arrays.asList("vanilla", "programmer_art", "fabric", "high_contrast");
|
||||||
|
|
||||||
|
for (ResourcePackProfile resourcePack : client.getResourcePackManager().getEnabledProfiles()) {
|
||||||
|
if (!(builtInResourcePacks.contains(resourcePack.getName()))) {
|
||||||
|
client.getResourcePackManager().disable(resourcePack.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String resourcePackName : client.options.resourcePacks) {
|
||||||
|
if (!(builtInResourcePacks.contains(resourcePackName))) {
|
||||||
|
client.getResourcePackManager().enable(resourcePackName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.reloadResources();
|
||||||
}).position(0, 0).size(75, 20).build();
|
}).position(0, 0).size(75, 20).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +89,7 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
|
||||||
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
||||||
TextRenderer textRenderer = ProfilesListWidget.this.client.textRenderer;
|
TextRenderer textRenderer = ProfilesListWidget.this.client.textRenderer;
|
||||||
int textY = y + entryHeight / 2;
|
int textY = y + entryHeight / 2;
|
||||||
context.drawText(textRenderer, profileName, x, textY - 9 / 2, 16777215, true);
|
context.drawText(textRenderer, profileName, x - 50, textY - 9 / 2, 16777215, true);
|
||||||
|
|
||||||
this.editButton.setX(x + 115);
|
this.editButton.setX(x + 115);
|
||||||
this.editButton.setY(y);
|
this.editButton.setY(y);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"gui.options-profiles.edit-profiles-screen-text": "Editing Profile: ",
|
"gui.options-profiles.edit-profiles-screen-text": "Editing Profile: ",
|
||||||
"gui.options-profiles.delete-profile-text": "Delete Profile",
|
"gui.options-profiles.delete-profile-text": "Delete Profile",
|
||||||
"gui.options-profiles.save-profile-text": "Save Profile",
|
"gui.options-profiles.save-profile-text": "Save Profile",
|
||||||
"gui.options-profiles.update-profile-text": "Overwrite",
|
"gui.options-profiles.update-profile-text": "Overwrite Options",
|
||||||
"gui.options-profiles.save-current-options": "Save Current Options",
|
"gui.options-profiles.save-current-options": "Save Current Options",
|
||||||
"gui.options-profiles.load-profile-text": "✔ (Load)",
|
"gui.options-profiles.load-profile-text": "✔ (Load)",
|
||||||
"gui.options-profiles.edit-profile-text": "✎ (Edit)",
|
"gui.options-profiles.edit-profile-text": "✎ (Edit)",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"gui.options-profiles.edit-profiles-screen-text": "Изменение профиля: ",
|
"gui.options-profiles.edit-profiles-screen-text": "Изменение профиля: ",
|
||||||
"gui.options-profiles.delete-profile-text": "Удалить профиль",
|
"gui.options-profiles.delete-profile-text": "Удалить профиль",
|
||||||
"gui.options-profiles.save-profile-text": "Сохранить",
|
"gui.options-profiles.save-profile-text": "Сохранить",
|
||||||
"gui.options-profiles.update-profile-text": "Перезаписать",
|
"gui.options-profiles.update-profile-text": "Перезаписать настройки",
|
||||||
"gui.options-profiles.save-current-options": "Сохранить настройки",
|
"gui.options-profiles.save-current-options": "Сохранить настройки",
|
||||||
"gui.options-profiles.load-profile-text": "✔ (Выбрать)",
|
"gui.options-profiles.load-profile-text": "✔ (Выбрать)",
|
||||||
"gui.options-profiles.edit-profile-text": "✎ (Изменить)",
|
"gui.options-profiles.edit-profile-text": "✎ (Изменить)",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue