forked from CleanroomMC/ModularUI
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
49 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 18 additions & 109 deletions
127
src/main/java/com/cleanroommc/modularui/ModularUIConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,34 @@ | ||
package com.cleanroommc.modularui; | ||
|
||
import com.cleanroommc.modularui.screen.RichTooltip; | ||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import java.io.File; | ||
import com.gtnewhorizon.gtnhlib.config.Config; | ||
|
||
public class ModularUIConfig { | ||
|
||
public static Configuration config; | ||
@Config(modid = ModularUI.ID) | ||
public class ModularUIConfig { | ||
|
||
@Config.Comment("Amount of pixels scrolled") | ||
@Config.RangeInt(min = 1, max = 100) | ||
public static int defaultScrollSpeed = 30; | ||
|
||
@Config.Comment("If progress bar should step in texture pixels or screen pixels. (Screen pixels are way smaller and therefore smoother)") | ||
public static boolean smoothProgressBar = true; | ||
|
||
@Config.Comment("Time in 1/60 sec to open and close panels.") | ||
public static int panelOpenCloseAnimationTime = 0; | ||
|
||
// Default direction | ||
@Config.Comment("Default tooltip position around the widget or its panel.") | ||
public static RichTooltip.Pos tooltipPos = RichTooltip.Pos.NEXT_TO_MOUSE; | ||
public static boolean useDarkThemeByDefault = false; | ||
|
||
@Config.Comment("If true, widget outlines and widget information will be drawn.") | ||
public static boolean guiDebugMode = ModularUI.isDevEnv; | ||
public static boolean enableTestGuis = ModularUI.isDevEnv; | ||
|
||
public static final String CATEGORY_RENDERING = "rendering"; | ||
public static final String CATEGORY_DEBUG = "debug"; | ||
|
||
private static final String LANG_PREFIX = ModularUI.ID + ".config."; | ||
|
||
public static final String[] CATEGORIES = new String[] { | ||
CATEGORY_RENDERING, | ||
CATEGORY_DEBUG, | ||
}; | ||
|
||
public static void init(File configFile) { | ||
config = new Configuration(configFile); | ||
syncConfig(); | ||
} | ||
|
||
public static void syncConfig() { | ||
config.setCategoryComment(CATEGORY_RENDERING, "Rendering"); | ||
config.setCategoryLanguageKey(CATEGORY_RENDERING, LANG_PREFIX + CATEGORY_RENDERING); | ||
config.setCategoryComment(CATEGORY_DEBUG, "Debug"); | ||
config.setCategoryLanguageKey(CATEGORY_DEBUG, LANG_PREFIX + CATEGORY_DEBUG); | ||
|
||
// === Rendering === | ||
|
||
defaultScrollSpeed = config.get( | ||
CATEGORY_RENDERING, | ||
"defaultScrollSpeed", | ||
30, | ||
"Amount of pixels scrolled.", | ||
1, | ||
100 | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_RENDERING + ".defaultScrollSpeed") | ||
.getInt(); | ||
|
||
smoothProgressBar = config.get( | ||
CATEGORY_RENDERING, | ||
"smoothProgressBar", | ||
true, | ||
"If progress bar should step in texture pixels or screen pixels. (Screen pixels are way smaller and therefore smoother)" | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_RENDERING + ".smoothProgressBar") | ||
.getBoolean(); | ||
|
||
panelOpenCloseAnimationTime = config.get( | ||
CATEGORY_RENDERING, | ||
"panelOpenCloseAnimationTime", | ||
0, | ||
"Time in 1/60 sec to open and close panels." | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_RENDERING + ".panelOpenCloseAnimationTime") | ||
.getInt(); | ||
|
||
tooltipPos = RichTooltip.Pos.fromString( | ||
config.get( | ||
CATEGORY_RENDERING, | ||
"tooltipPos", | ||
"NEXT_TO_MOUSE", | ||
"Default tooltip position around the widget or its panel. Select: ABOVE, BELOW, LEFT, RIGHT, VERTICAL, HORIZONTAL, NEXT_TO_MOUSE", | ||
new String[] { | ||
"ABOVE", | ||
"BELOW", | ||
"LEFT", | ||
"RIGHT", | ||
"VERTICAL", | ||
"HORIZONTAL", | ||
"NEXT_TO_MOUSE", | ||
} | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_RENDERING + ".tooltipPos") | ||
.getString()); | ||
|
||
useDarkThemeByDefault = config.get( | ||
CATEGORY_RENDERING, | ||
"useDarkThemeByDefault", | ||
false, | ||
"If true and not specified otherwise, screens will try to use the 'vanilla_dark' theme." | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_RENDERING + ".useDarkThemeByDefault") | ||
.getBoolean(); | ||
|
||
// === Debug === | ||
|
||
guiDebugMode = config.get( | ||
CATEGORY_DEBUG, | ||
"guiDebugMode", | ||
ModularUI.isDevEnv, | ||
"If true, widget outlines and widget information will be drawn." | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_DEBUG + ".guiDebugMode") | ||
.getBoolean(); | ||
|
||
enableTestGuis = config.get( | ||
CATEGORY_DEBUG, | ||
"enableTestGuis", | ||
ModularUI.isDevEnv, | ||
"Enables a test block, test item with a test gui and opening a gui by right clicking a diamond." | ||
) | ||
.setLanguageKey(LANG_PREFIX + CATEGORY_DEBUG + ".enableTestGuis") | ||
.getBoolean(); | ||
@Config.Comment("If true and not specified otherwise, screens will try to use the 'vanilla_dark' theme.") | ||
public static boolean useDarkThemeByDefault = false; | ||
|
||
if (config.hasChanged()) { | ||
config.save(); | ||
} | ||
} | ||
@Config.RequiresMcRestart | ||
@Config.Comment("Enables a test block, test item with a test gui and opening a gui by right clicking a diamond.") | ||
public static boolean enableTestGuis = ModularUI.isDevEnv; | ||
} |
29 changes: 0 additions & 29 deletions
29
src/main/java/com/cleanroommc/modularui/config/GuiFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/cleanroommc/modularui/config/ModularUIGuiConfigFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.cleanroommc.modularui.config; | ||
|
||
import com.gtnewhorizon.gtnhlib.config.SimpleGuiFactory; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
@SuppressWarnings("unused") | ||
public class ModularUIGuiConfigFactory implements SimpleGuiFactory { | ||
|
||
@Override | ||
public Class<? extends GuiScreen> mainConfigGuiClass() { | ||
return ModularUIGuiConfig.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters