Skip to content

Commit

Permalink
Merge pull request #332 from FTBTeam/bugfix/1.21/map-component-screen…
Browse files Browse the repository at this point in the history
…-fix

[1.21] Open minimap component screen from config screen
  • Loading branch information
desht authored Nov 27, 2024
2 parents a68a4e6 + e9852ef commit 25d42f4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, String> 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<Map<String, String>> {

@Override
public void onClicked(Widget clickedWidget, MouseButton button, ConfigCallback callback) {
new MinimapInfoSortScreen().openGui();
}

@Override
public Component getStringForGUI(@Nullable Map<String, String> v) {
if (v == null) {
return super.getStringForGUI(null);
}
return Component.translatable("ftbchunks.gui.sort_minimap_info");
}
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/assets/ftbchunks/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,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",
Expand Down

0 comments on commit 25d42f4

Please sign in to comment.