Add MC Version locking to the config
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.seibel.distanthorizons.common;
|
package com.seibel.distanthorizons.common;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode;
|
||||||
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
|
||||||
|
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiAfterDhInitEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeDhInitEvent;
|
||||||
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
import com.seibel.distanthorizons.common.commands.CommandInitializer;
|
||||||
@@ -101,6 +103,7 @@ public abstract class AbstractModInitializer
|
|||||||
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
// Client uses config for auto-updater, so it's initialized here instead of post-init stage
|
||||||
this.initConfig();
|
this.initConfig();
|
||||||
logIncompatibilityWarnings(); // needs to be called after config loading
|
logIncompatibilityWarnings(); // needs to be called after config loading
|
||||||
|
setUnsupportedConfigsBasedOnMcVersion();
|
||||||
Initializer.postConfigInit();
|
Initializer.postConfigInit();
|
||||||
|
|
||||||
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
LOGGER.info(ModInfo.READABLE_NAME + " client Initialized.");
|
||||||
@@ -409,6 +412,24 @@ public abstract class AbstractModInitializer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some Minecraft versions don't support all
|
||||||
|
* DH options.
|
||||||
|
* In that case we need to override what options are available.
|
||||||
|
*/
|
||||||
|
private static void setUnsupportedConfigsBasedOnMcVersion()
|
||||||
|
{
|
||||||
|
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
||||||
|
Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.setMcVersionOverrideValue(EDhApiMcRenderingFadeMode.NONE);
|
||||||
|
Config.Common.WorldGenerator.distantGeneratorMode.setMcVersionOverrideValue(EDhApiDistantGeneratorMode.INTERNAL_SERVER);
|
||||||
|
#elif MC_VER <= MC_1_21_10
|
||||||
|
Config.Client.Advanced.Graphics.Experimental.renderingApi.setMcVersionOverrideValue(EDhApiRenderApi.OPEN_GL);
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+39
-8
@@ -565,6 +565,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
{
|
{
|
||||||
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
configEntry.uiSetWithoutSaving(configEntry.getDefaultValue());
|
||||||
this.reload = true;
|
this.reload = true;
|
||||||
|
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category));
|
Objects.requireNonNull(this.mc).displayGuiScreen(ClassicConfigGUI.getScreen(this.parent, this.category));
|
||||||
#else
|
#else
|
||||||
@@ -587,7 +588,18 @@ class DhConfigScreen extends DhScreen
|
|||||||
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.RESET_BUTTON_HEIGHT,
|
||||||
btnAction);
|
btnAction);
|
||||||
|
|
||||||
if (configEntry.apiIsOverriding())
|
|
||||||
|
if (configEntry.mcVersionOverridePresent())
|
||||||
|
{
|
||||||
|
#if MC_VER <= MC_1_12_2
|
||||||
|
resetButton.enabled = false;
|
||||||
|
resetButton.displayString = Translatable("distanthorizons.general.unsupportedMcVersion").setStyle(new Style().setColor(TextFormatting.DARK_GRAY)).getFormattedText();
|
||||||
|
#else
|
||||||
|
resetButton.active = false;
|
||||||
|
resetButton.setMessage(Translatable("distanthorizons.general.unsupportedMcVersion").withStyle(ChatFormatting.DARK_GRAY));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (configEntry.apiIsOverriding())
|
||||||
{
|
{
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
resetButton.enabled = false;
|
resetButton.enabled = false;
|
||||||
@@ -599,7 +611,11 @@ class DhConfigScreen extends DhScreen
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true;
|
#if MC_VER <= MC_1_12_2
|
||||||
|
resetButton.enabled = true;
|
||||||
|
#else
|
||||||
|
resetButton.active = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
@@ -648,12 +664,20 @@ class DhConfigScreen extends DhScreen
|
|||||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||||
widget.getKey());
|
widget.getKey());
|
||||||
|
|
||||||
|
|
||||||
// deactivate the button if the API is overriding it
|
// deactivate the button if the API is overriding it
|
||||||
#if MC_VER <= MC_1_12_2
|
// or the MC version doesn't support it
|
||||||
button.enabled = !configEntry.apiIsOverriding();
|
if (configEntry.mcVersionOverridePresent()
|
||||||
#else
|
|| configEntry.apiIsOverriding())
|
||||||
button.active = !configEntry.apiIsOverriding();
|
{
|
||||||
#endif
|
#if MC_VER <= MC_1_12_2
|
||||||
|
button.enabled = false;
|
||||||
|
#else
|
||||||
|
button.active = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.configListWidget.addButton(this, configEntry,
|
this.configListWidget.addButton(this, configEntry,
|
||||||
button,
|
button,
|
||||||
@@ -957,14 +981,21 @@ class DhConfigScreen extends DhScreen
|
|||||||
button.dhConfigType;
|
button.dhConfigType;
|
||||||
|
|
||||||
boolean apiOverrideActive = false;
|
boolean apiOverrideActive = false;
|
||||||
|
boolean unsupportedMcVersion = false;
|
||||||
if (configBase instanceof ConfigEntry)
|
if (configBase instanceof ConfigEntry)
|
||||||
{
|
{
|
||||||
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
apiOverrideActive = ((ConfigEntry<?>) configBase).apiIsOverriding();
|
||||||
|
unsupportedMcVersion = ((ConfigEntry<?>) configBase).mcVersionOverridePresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
String key = TRANSLATION_PREFIX + (configBase.category.isEmpty() ? "" : configBase.category + ".") + configBase.getName() + ".@tooltip";
|
||||||
|
|
||||||
if (apiOverrideActive)
|
if (unsupportedMcVersion)
|
||||||
|
{
|
||||||
|
key = "distanthorizons.general.unsupportedMcVersion.@tooltip";
|
||||||
|
}
|
||||||
|
else if (apiOverrideActive)
|
||||||
{
|
{
|
||||||
key = "distanthorizons.general.disabledByApi.@tooltip";
|
key = "distanthorizons.general.disabledByApi.@tooltip";
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule coreSubProjects updated: e3f586da56...fd3a8f7ddf
Reference in New Issue
Block a user