Files
CustomNPC-Plus/src/main/java/noppes/npcs/config/ConfigClient.java
T

264 lines
11 KiB
Java
Raw Normal View History

2023-01-07 00:21:08 -05:00
package noppes.npcs.config;
import cpw.mods.fml.common.FMLLog;
import net.minecraftforge.common.config.Configuration;
2023-01-07 18:07:23 -05:00
import net.minecraftforge.common.config.Property;
import noppes.npcs.CustomNpcs;
import noppes.npcs.config.legacy.LegacyConfig;
2023-01-07 00:21:08 -05:00
import org.apache.logging.log4j.Level;
import java.io.File;
2025-03-12 20:12:01 -04:00
public class ConfigClient {
2023-01-07 00:21:08 -05:00
public static Configuration config;
2023-06-03 17:23:40 -04:00
public final static String GENERAL = "General";
2023-01-07 18:07:23 -05:00
public final static String VISUAL = "Visual";
2025-01-25 19:41:54 -05:00
public final static String MODEL = "Model";
2025-01-27 17:21:11 -05:00
public final static String TEXTURE = "Texture";
2025-02-23 05:58:56 -05:00
public final static String HUD = "Hud";
2023-01-07 18:07:23 -05:00
2023-06-03 17:23:40 -04:00
/**
2025-03-12 20:12:01 -04:00
* General Properties
2023-06-03 17:23:40 -04:00
**/
public static Property CacheLifeProperty;
public static int CacheLife = 10;
2023-01-07 18:07:23 -05:00
/**
2025-03-12 20:12:01 -04:00
* Visual Properties
2023-01-07 18:07:23 -05:00
**/
public static Property EnableChatBubblesProperty;
2023-01-07 00:21:08 -05:00
public static boolean EnableChatBubbles = true;
2023-01-07 18:07:23 -05:00
public static Property InventoryGuiEnabledProperty;
2023-01-07 00:21:08 -05:00
public static boolean InventoryGuiEnabled = true;
2023-01-07 18:07:23 -05:00
public static Property enableFactionTabProperty;
public static boolean enableFactionTab = true;
2023-01-07 18:07:23 -05:00
public static Property FontTypeProperty;
2023-01-07 00:21:08 -05:00
public static String FontType = "Default";
2023-01-07 18:07:23 -05:00
public static Property FontSizeProperty;
2023-01-07 00:21:08 -05:00
public static int FontSize = 18;
2023-01-07 18:07:23 -05:00
public static Property ChatBubblesFontTypeProperty;
public static boolean ChatBubblesFontType = false;
2025-02-21 18:13:08 -05:00
public static Property HideEffectsBarProperty;
public static boolean HideEffectsBar = false;
2023-01-07 18:07:23 -05:00
/**
2025-03-12 20:12:01 -04:00
* Questing Properties
2023-01-07 18:07:23 -05:00
**/
public static Property DialogSpeedProperty;
public static int DialogSpeed = 10;
public static Property DialogSoundProperty;
public static boolean DialogSound = true;
2024-03-15 17:54:01 -04:00
public static Property ChatAlertsProperty;
public static boolean ChatAlerts = true;
public static Property BannerAlertsProperty;
public static boolean BannerAlerts = true;
2025-02-23 05:58:56 -05:00
// HUD PROPERTIES
2025-02-22 23:58:56 -05:00
public static Property QuestOverlayXProperty;
2025-03-08 18:29:02 -05:00
public static int QuestOverlayX = 0;
2025-02-22 23:58:56 -05:00
public static Property QuestOverlayYProperty;
2025-03-08 18:29:02 -05:00
public static int QuestOverlayY = 31;
2025-02-22 23:58:56 -05:00
public static Property QuestOverlayScaleProperty;
2025-03-08 18:29:02 -05:00
public static int QuestOverlayScale = 223;
2025-02-22 23:58:56 -05:00
public static Property QuestOverlayTextAlignProperty;
2025-03-08 18:29:02 -05:00
public static int QuestOverlayTextAlign = 0; // 0: Left, 1: Center, 2: Right
2025-02-22 23:58:56 -05:00
2025-02-23 15:50:45 -05:00
public static Property CompassEnabledProperty;
2025-03-08 18:29:02 -05:00
public static boolean CompassEnabled = true;
2025-02-23 05:58:56 -05:00
2025-02-23 15:50:45 -05:00
public static Property CompassOverlayXProperty;
2025-03-08 18:29:02 -05:00
public static int CompassOverlayX = 37;
2025-02-23 15:50:45 -05:00
public static Property CompassOverlayYProperty;
2025-03-08 18:29:02 -05:00
public static int CompassOverlayY = 0;
2025-02-23 15:50:45 -05:00
public static Property CompassOverlayScaleProperty;
2025-03-08 18:29:02 -05:00
public static int CompassOverlayScale = 276;
2025-02-23 05:58:56 -05:00
2025-02-23 15:50:45 -05:00
public static Property CompassOverlayWidthProperty;
2025-03-08 18:29:02 -05:00
public static int CompassOverlayWidth = 200;
2025-02-22 23:58:56 -05:00
2025-01-27 17:21:11 -05:00
/**
2025-03-12 20:12:01 -04:00
* Texture Properties
2025-01-27 17:21:11 -05:00
**/
public static boolean WoodTextures = false;
2025-01-25 19:41:54 -05:00
/**
2025-03-12 20:12:01 -04:00
* Model Properties
2025-01-25 19:41:54 -05:00
**/
public static boolean LegacyCampfire = false;
2025-01-26 15:47:04 -05:00
public static boolean LegacyBanner = false;
2025-01-25 19:41:54 -05:00
public static boolean LegacyChair = false;
2025-01-26 17:55:25 -05:00
public static boolean LegacyStool = false;
2025-02-11 01:01:58 -05:00
public static boolean LegacyCouch = false;
2025-02-04 15:39:25 -05:00
public static boolean LegacyTable = false;
2025-01-25 19:41:54 -05:00
public static boolean LegacyBarrel = false;
public static boolean LegacyCarpentryBench = false;
2025-02-12 17:39:33 -05:00
public static boolean LegacyAnvil = false;
2025-02-12 02:34:05 -05:00
public static boolean LegacyLantern = false;
public static boolean LegacyCandle = false;
2025-02-12 21:44:14 -05:00
public static boolean LegacyTallLamp = false;
2025-02-12 22:29:16 -05:00
public static boolean LegacyPedestal = false;
2025-03-02 22:28:28 -05:00
public static boolean LegacyMailbox = false;
2025-01-25 19:41:54 -05:00
2025-03-12 20:12:01 -04:00
public static void init(File configFile) {
2023-01-07 00:21:08 -05:00
config = new Configuration(configFile);
2025-03-12 20:12:01 -04:00
try {
2023-01-07 00:21:08 -05:00
config.load();
2025-02-23 05:58:56 -05:00
// Hud Quest Overlay settings
2025-03-08 18:29:02 -05:00
QuestOverlayXProperty = config.get(HUD, "Quest Hud X", 0, "X position of the quest overlay.");
QuestOverlayX = QuestOverlayXProperty.getInt(0);
2025-02-22 23:58:56 -05:00
2025-03-08 18:29:02 -05:00
QuestOverlayYProperty = config.get(HUD, "Quest Hud Y", 31, "Y position of the quest overlay.");
QuestOverlayY = QuestOverlayYProperty.getInt(31);
2025-02-22 23:58:56 -05:00
2025-03-08 18:29:02 -05:00
QuestOverlayScaleProperty = config.get(HUD, "Quest Hud Scale", 223, "Scale percentage of the quest overlay.");
QuestOverlayScale = QuestOverlayScaleProperty.getInt(223);
2025-02-22 23:58:56 -05:00
2025-03-08 18:29:02 -05:00
QuestOverlayTextAlignProperty = config.get(HUD, "Quest Hud Text Alignment", 0, "Text alignment in quest overlay (0: Left, 1: Center, 2: Right).");
QuestOverlayTextAlign = QuestOverlayTextAlignProperty.getInt(0);
2025-02-22 23:58:56 -05:00
2025-02-23 15:50:45 -05:00
CompassEnabledProperty = config.get(
HUD,
"Compass Hud Enabled",
true,
"Enable Compass Hud Component"
);
CompassEnabled = CompassEnabledProperty.getBoolean();
2025-02-23 05:58:56 -05:00
// Compass HUD Configs
CompassOverlayXProperty = config.get(
HUD,
"Compass Hud X",
2025-03-08 18:29:02 -05:00
37,
2025-02-23 05:58:56 -05:00
"Horizontal position of compass overlay (0-100 percentage)",
0,
100
);
CompassOverlayX = CompassOverlayXProperty.getInt();
CompassOverlayYProperty = config.get(
HUD,
"Compass Hud Y",
2025-03-08 18:29:02 -05:00
0,
2025-02-23 05:58:56 -05:00
"Vertical position of compass overlay (0-100 percentage)",
0,
100
);
CompassOverlayY = CompassOverlayYProperty.getInt();
CompassOverlayScaleProperty = config.get(
HUD,
"Compass Hud Scale",
2025-03-08 18:29:02 -05:00
276,
2025-02-23 05:58:56 -05:00
"Scale percentage of compass overlay",
50,
300
);
CompassOverlayScale = CompassOverlayScaleProperty.getInt();
CompassOverlayWidthProperty = config.get(
HUD,
"Compass Hud Width",
200,
"Base width of compass bar in pixels",
100,
1000
);
CompassOverlayWidth = CompassOverlayWidthProperty.getInt();
2025-02-22 23:58:56 -05:00
2023-06-03 17:23:40 -04:00
// General
CacheLifeProperty = config.get(GENERAL, "Cache Life", 10, "How long should downloaded imagery data be saved client side? (In minutes)");
CacheLife = CacheLifeProperty.getInt(10);
2023-01-07 18:07:23 -05:00
// Visual
EnableChatBubblesProperty = config.get(VISUAL, "Enable Chat Bubbles", true, "Enable/Disable Chat Bubbles");
EnableChatBubbles = EnableChatBubblesProperty.getBoolean(true);
InventoryGuiEnabledProperty = config.get(VISUAL, "Enable Inventory Tabs", true, "Enable/Disable Inventory Tabs");
InventoryGuiEnabled = InventoryGuiEnabledProperty.getBoolean(true);
enableFactionTabProperty = config.get(VISUAL, "Enable Faction Tab", true, "Enable the Faction Tab");
enableFactionTab = enableFactionTabProperty.getBoolean(true);
2023-01-07 18:07:23 -05:00
FontTypeProperty = config.get(VISUAL, "Font Type", "Default", "When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC");
FontType = FontTypeProperty.getString();
FontSizeProperty = config.get(VISUAL, "Font Size", 18, "Font size for custom fonts (doesn't work with minecrafts font)");
FontSize = FontSizeProperty.getInt(18);
ChatBubblesFontTypeProperty = config.get(VISUAL, "Chat Bubbles Font Type", false, "Enable the use of Custom Font for Chat Bubbles");
ChatBubblesFontType = ChatBubblesFontTypeProperty.getBoolean(false);
2025-02-21 18:13:08 -05:00
HideEffectsBarProperty = config.get(VISUAL, "Hide Effects Bar", false, "Hides CNPC+ Inventory Effects Bar");
HideEffectsBar = HideEffectsBarProperty.getBoolean(false);
2024-03-15 17:54:01 -04:00
DialogSpeedProperty = config.get(VISUAL, "Dialog Speed", true, "Only set for gradual dialogs");
DialogSpeed = DialogSpeedProperty.getInt(10);
2024-03-15 17:54:01 -04:00
DialogSoundProperty = config.get(VISUAL, "Dialog Sound", true, "Only for dialogs with sounds");
DialogSound = DialogSoundProperty.getBoolean(true);
2024-03-15 17:54:01 -04:00
ChatAlertsProperty = config.get(VISUAL, "All Chat Alerts", true, "Universal enable/disable for Banner Alerts");
ChatAlerts = ChatAlertsProperty.getBoolean(true);
BannerAlertsProperty = config.get(VISUAL, "All Banner Alerts", true, "Universal enable/disable for Banner Alerts");
BannerAlerts = BannerAlertsProperty.getBoolean(true);
2025-01-27 17:21:11 -05:00
WoodTextures = config.get(TEXTURE, "Wood Textures", false, "Models like Chairs and Stools will use default MC Wood Textures").getBoolean(false);
2025-01-25 19:41:54 -05:00
LegacyCampfire = config.get(MODEL, "Legacy Campfire Model", false).getBoolean(false);
2025-01-26 15:47:04 -05:00
LegacyBanner = config.get(MODEL, "Legacy Banner Model", false).getBoolean(false);
2025-01-25 19:41:54 -05:00
LegacyBarrel = config.get(MODEL, "Legacy Barrel Model", false).getBoolean(false);
LegacyChair = config.get(MODEL, "Legacy Chair Model", false).getBoolean(false);
2025-01-26 17:55:25 -05:00
LegacyStool = config.get(MODEL, "Legacy Stool Model", false).getBoolean(false);
2025-02-11 01:01:58 -05:00
LegacyCouch = config.get(MODEL, "Legacy Couch Model", false).getBoolean(false);
2025-02-04 15:39:25 -05:00
LegacyTable = config.get(MODEL, "Legacy Table Model", false).getBoolean(false);
2025-02-12 17:39:33 -05:00
LegacyAnvil = config.get(MODEL, "Legacy Anvil Model", false).getBoolean(false);
2025-01-25 19:41:54 -05:00
LegacyCarpentryBench = config.get(MODEL, "Legacy Carpentry Bench Model", false).getBoolean(false);
2025-02-12 02:34:05 -05:00
LegacyLantern = config.get(MODEL, "Legacy Lantern Model", false).getBoolean(false);
LegacyCandle = config.get(MODEL, "Legacy Candle Model", false).getBoolean(false);
2025-02-12 21:44:14 -05:00
LegacyTallLamp = config.get(MODEL, "Legacy Tall Lamp Model", false).getBoolean(false);
2025-02-12 22:29:16 -05:00
LegacyPedestal = config.get(MODEL, "Legacy Pedestal Model", false).getBoolean(false);
2025-03-02 22:28:28 -05:00
LegacyMailbox = config.get(MODEL, "Legacy Mailbox Model", false).getBoolean(false);
2025-01-25 19:41:54 -05:00
2023-01-07 18:07:23 -05:00
// Convert to Legacy
2025-03-12 20:12:01 -04:00
if (CustomNpcs.legacyExist) {
2023-01-07 18:07:23 -05:00
EnableChatBubbles = LegacyConfig.EnableChatBubbles;
EnableChatBubblesProperty.set(EnableChatBubbles);
FontType = LegacyConfig.FontType;
FontTypeProperty.set(FontType);
InventoryGuiEnabled = LegacyConfig.InventoryGuiEnabled;
InventoryGuiEnabledProperty.set(InventoryGuiEnabled);
FontSize = LegacyConfig.FontSize;
FontSizeProperty.set(FontSize);
}
2025-03-12 20:12:01 -04:00
} catch (Exception e) {
2023-01-07 00:21:08 -05:00
FMLLog.log(Level.ERROR, e, "CNPC+ has had a problem loading its client configuration");
2025-03-12 20:12:01 -04:00
} finally {
2023-01-07 00:21:08 -05:00
if (config.hasChanged()) {
config.save();
}
}
}
}