|
1 | 1 | package dev.ftb.mods.ftbquests.client;
|
2 | 2 |
|
3 |
| -import dev.architectury.networking.NetworkManager; |
4 |
| -import dev.ftb.mods.ftblibrary.config.ConfigGroup; |
5 |
| -import dev.ftb.mods.ftblibrary.config.ui.EditConfigScreen; |
| 3 | +import dev.ftb.mods.ftblibrary.config.manager.ConfigManager; |
6 | 4 | import dev.ftb.mods.ftblibrary.snbt.config.*;
|
7 | 5 | import dev.ftb.mods.ftblibrary.util.PanelPositioning;
|
8 | 6 | import dev.ftb.mods.ftbquests.api.FTBQuestsAPI;
|
9 | 7 | import dev.ftb.mods.ftbquests.client.config.LocaleValue;
|
10 |
| -import dev.ftb.mods.ftbquests.net.RequestTranslationTableMessage; |
11 |
| -import net.minecraft.client.Minecraft; |
12 |
| -import net.minecraft.client.gui.screens.Screen; |
13 |
| - |
14 |
| -import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.LOCAL_DIR; |
15 |
| -import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.loadDefaulted; |
| 8 | +import dev.ftb.mods.ftbquests.client.gui.QuestsClientConfigScreen; |
16 | 9 |
|
17 | 10 | public interface FTBQuestsClientConfig {
|
18 |
| - SNBTConfig CONFIG = SNBTConfig.create(FTBQuestsAPI.MOD_ID + "-client"); |
19 |
| - String CLIENT_CONFIG = "client-config.snbt"; |
| 11 | + String KEY = FTBQuestsAPI.MOD_ID + "-client"; |
| 12 | + SNBTConfig CONFIG = SNBTConfig.create(KEY); |
20 | 13 |
|
21 | 14 | SNBTConfig UI = CONFIG.addGroup("ui", 0);
|
22 | 15 | BooleanValue OLD_SCROLL_WHEEL = UI.addBoolean("old_scroll_wheel", false);
|
23 | 16 | EnumValue<PanelPositioning> PINNED_QUESTS_POS = UI.addEnum("pinned_quests_pos", PanelPositioning.NAME_MAP, PanelPositioning.RIGHT);
|
24 | 17 | IntValue PINNED_QUESTS_INSET_X = UI.addInt("pinned_quests_inset_x", 2);
|
25 | 18 | IntValue PINNED_QUESTS_INSET_Y = UI.addInt("pinned_quests_inset_y", 2);
|
26 | 19 | BooleanValue SHOW_LOCK_ICON = UI.addBoolean("show_lock_icon", true);
|
| 20 | + BooleanValue BACKSPACE_HISTORY = UI.addBoolean("backspace_history", true); |
27 | 21 |
|
28 | 22 | SNBTConfig XLATE = CONFIG.addGroup("xlate", 1);
|
29 | 23 | StringValue EDITING_LOCALE = XLATE.add(new LocaleValue(XLATE,"editing_locale", ""));
|
30 | 24 | BooleanValue HILITE_MISSING = XLATE.addBoolean("hilite_missing", true);
|
31 | 25 |
|
32 | 26 | // TODO migrate chapter-pinned and pinned-quests data out of per-player team data into here
|
33 | 27 |
|
34 |
| - static void openSettings(Screen screen) { |
35 |
| - String prevLocale = EDITING_LOCALE.get(); |
36 |
| - |
37 |
| - ConfigGroup group = new ConfigGroup("ftbquests", accepted -> { |
38 |
| - if (accepted) { |
39 |
| - saveConfig(); |
40 |
| - if (!prevLocale.equals(EDITING_LOCALE.get()) && ClientQuestFile.INSTANCE != null) { |
41 |
| - NetworkManager.sendToServer(new RequestTranslationTableMessage(ClientQuestFile.INSTANCE.getLocale())); |
42 |
| - ClientQuestFile.INSTANCE.clearCachedData(); |
43 |
| - } |
44 |
| - } |
45 |
| - Minecraft.getInstance().setScreen(screen); |
46 |
| - }); |
47 |
| - CONFIG.createClientConfig(group); |
48 |
| - EditConfigScreen gui = new EditConfigScreen(group) { |
49 |
| - @Override |
50 |
| - public boolean doesGuiPauseGame() { |
51 |
| - return screen.isPauseScreen(); |
52 |
| - } |
53 |
| - }; |
54 |
| - |
55 |
| - gui.openGui(); |
56 |
| - } |
57 |
| - |
58 |
| - static void init() { |
59 |
| - loadDefaulted(CONFIG, LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID), FTBQuestsAPI.MOD_ID, CLIENT_CONFIG); |
60 |
| - } |
61 |
| - |
62 |
| - static void saveConfig() { |
63 |
| - CONFIG.save(LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID).resolve(CLIENT_CONFIG)); |
| 28 | + static void openSettings(boolean pauseGame) { |
| 29 | + ConfigManager.getInstance().createConfigGroup(KEY) |
| 30 | + .ifPresent(group -> new QuestsClientConfigScreen(group, pauseGame).openGui()); |
64 | 31 | }
|
65 | 32 | }
|
0 commit comments