From e9852ef483e97f80ff06f854650da5339f599f4e Mon Sep 17 00:00:00 2001 From: UnRealDinnerbone Date: Mon, 25 Nov 2024 10:18:52 -0600 Subject: [PATCH] Open minimap component screen from config screen --- .../client/FTBChunksClientConfig.java | 13 ++++-- .../minimap/MinimapComponentConfig.java | 44 +++++++++++++++++++ .../assets/ftbchunks/lang/en_us.json | 1 + 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/dev/ftb/mods/ftbchunks/client/minimap/MinimapComponentConfig.java diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClientConfig.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClientConfig.java index 0fc45261..22c6df91 100644 --- a/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClientConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClientConfig.java @@ -2,12 +2,13 @@ import dev.architectury.networking.NetworkManager; import dev.architectury.platform.Platform; +import dev.ftb.mods.ftbchunks.EntityTypeBoolMapValue; import dev.ftb.mods.ftbchunks.FTBChunks; import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig; -import dev.ftb.mods.ftbchunks.EntityTypeBoolMapValue; import dev.ftb.mods.ftbchunks.client.map.BiomeBlendMode; import dev.ftb.mods.ftbchunks.client.map.MapManager; import dev.ftb.mods.ftbchunks.client.map.MapMode; +import dev.ftb.mods.ftbchunks.client.minimap.MinimapComponentConfig; import dev.ftb.mods.ftbchunks.client.minimap.components.BiomeComponent; import dev.ftb.mods.ftbchunks.client.minimap.components.DebugComponent; import dev.ftb.mods.ftbchunks.client.minimap.components.FPSComponent; @@ -19,7 +20,13 @@ import dev.ftb.mods.ftblibrary.config.ConfigGroup; import dev.ftb.mods.ftblibrary.config.ui.EditConfigScreen; import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag; -import dev.ftb.mods.ftblibrary.snbt.config.*; +import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; +import dev.ftb.mods.ftblibrary.snbt.config.DoubleValue; +import dev.ftb.mods.ftblibrary.snbt.config.EnumValue; +import dev.ftb.mods.ftblibrary.snbt.config.IntValue; +import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig; +import dev.ftb.mods.ftblibrary.snbt.config.StringListValue; +import dev.ftb.mods.ftblibrary.snbt.config.StringMapValue; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.resources.ResourceLocation; @@ -82,7 +89,7 @@ public interface FTBChunksClientConfig { BooleanValue MINIMAP_PROPORTIONAL = MINIMAP.addBoolean("proportional", true).comment("Size minimap proportional to screen width (and scale)"); StringListValue MINIMAP_INFO_ORDER = MINIMAP.addStringList("info_order", Stream.of(PlayerPosInfoComponent.ID, BiomeComponent.ID, ZoneInfoComponent.ID, FPSComponent.ID, GameTimeComponent.ID, RealTimeComponent.ID, DebugComponent.ID).map(ResourceLocation::toString).toList()).excluded().comment("Info displayed under minimap"); StringListValue MINIMAP_INFO_HIDDEN = MINIMAP.addStringList("info_hidden", Stream.of(FPSComponent.ID, GameTimeComponent.ID, RealTimeComponent.ID, DebugComponent.ID).map(ResourceLocation::toString).toList()).excluded().comment("Info hidden under minimap"); - StringMapValue MINIMAP_SETTINGS = MINIMAP.add(new StringMapValue(MINIMAP, "info_settings", Collections.emptyMap())).comment("Settings for minimap info components"); + StringMapValue MINIMAP_SETTINGS = MINIMAP.add(new MinimapComponentConfig(MINIMAP, "info_settings", Collections.emptyMap())).comment("Settings for minimap info components"); EntityTypeBoolMapValue ENTITY_ICON = MINIMAP.add(new EntityTypeBoolMapValue(MINIMAP, "entity_icon", Collections.emptyMap())).comment("Entity icons on minimap"); SNBTConfig ADVANCED = CONFIG.addGroup("advanced", 3); diff --git a/common/src/main/java/dev/ftb/mods/ftbchunks/client/minimap/MinimapComponentConfig.java b/common/src/main/java/dev/ftb/mods/ftbchunks/client/minimap/MinimapComponentConfig.java new file mode 100644 index 00000000..7fac0ed1 --- /dev/null +++ b/common/src/main/java/dev/ftb/mods/ftbchunks/client/minimap/MinimapComponentConfig.java @@ -0,0 +1,44 @@ +package dev.ftb.mods.ftbchunks.client.minimap; + +import dev.ftb.mods.ftbchunks.client.gui.MinimapInfoSortScreen; +import dev.ftb.mods.ftblibrary.config.ConfigCallback; +import dev.ftb.mods.ftblibrary.config.ConfigGroup; +import dev.ftb.mods.ftblibrary.config.ConfigValue; +import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig; +import dev.ftb.mods.ftblibrary.snbt.config.StringMapValue; +import dev.ftb.mods.ftblibrary.ui.Widget; +import dev.ftb.mods.ftblibrary.ui.input.MouseButton; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; + +public class MinimapComponentConfig extends StringMapValue { + + public MinimapComponentConfig(@Nullable SNBTConfig c, String n, Map def) { + super(c, n, def); + } + + + @Override + public void createClientConfig(ConfigGroup group) { + group.add(key, new MinimapComponentConfigValue(), get(), stringBooleanMap -> { + }, defaultValue); + } + + public static class MinimapComponentConfigValue extends ConfigValue> { + + @Override + public void onClicked(Widget clickedWidget, MouseButton button, ConfigCallback callback) { + new MinimapInfoSortScreen().openGui(); + } + + @Override + public Component getStringForGUI(@Nullable Map v) { + if (v == null) { + return super.getStringForGUI(null); + } + return Component.translatable("ftbchunks.gui.sort_minimap_info"); + } + } +} diff --git a/common/src/main/resources/assets/ftbchunks/lang/en_us.json b/common/src/main/resources/assets/ftbchunks/lang/en_us.json index 05bb24cc..3b1db1ff 100644 --- a/common/src/main/resources/assets/ftbchunks/lang/en_us.json +++ b/common/src/main/resources/assets/ftbchunks/lang/en_us.json @@ -290,6 +290,7 @@ "ftbchunks.gui.sort_minimap_info": "Minimap Info Settings", "ftbchunks.minimap.info_hidden": "Hidden Minimap Info", "ftbchunks.minimap.info_order": "Minimap info order", + "ftbchunks.minimap.info_settings": "Info Settings", "ftbchunks.show_wilderness.show_wilderness": "Show Wilderness", "ftbchunks.show_wilderness.just_claimed": "Show only Claimed Chunks", "tag.item.ftbchunks.right_click_blacklist": "Right Click Blacklist",