use of org.blockartistry.Presets.api.PresetData in project DynamicSurroundings by OreCruncher.
the class MinecraftConfigHandler method onConfigSave.
@SubscribeEvent
public static void onConfigSave(@Nonnull final PresetEvent.Save event) {
final PresetData data = event.getModData(MINECRAFT);
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
for (final Options option : GameSettings.Options.values()) {
final String theName = option.getTranslation();
switch(option) {
case INVERT_MOUSE:
data.setBoolean(theName, settings.invertMouse);
break;
case SENSITIVITY:
data.setDouble(theName, settings.mouseSensitivity);
break;
case FOV:
data.setDouble(theName, settings.fovSetting);
break;
case GAMMA:
data.setDouble(theName, settings.gammaSetting);
break;
case SATURATION:
data.setDouble(theName, settings.saturation);
break;
case RENDER_DISTANCE:
data.setInt(theName, settings.renderDistanceChunks);
break;
case VIEW_BOBBING:
data.setBoolean(theName, settings.viewBobbing);
break;
case ANAGLYPH:
data.setBoolean(theName, settings.anaglyph);
break;
case FRAMERATE_LIMIT:
data.setInt(theName, settings.limitFramerate);
break;
case FBO_ENABLE:
data.setBoolean(theName, settings.fboEnable);
break;
case CHAT_COLOR:
data.setBoolean(theName, settings.chatColours);
break;
case CHAT_LINKS:
data.setBoolean(theName, settings.chatLinks);
break;
case CHAT_OPACITY:
data.setDouble(theName, settings.chatOpacity);
break;
case CHAT_LINKS_PROMPT:
data.setBoolean(theName, settings.chatLinksPrompt);
break;
case SNOOPER_ENABLED:
data.setBoolean(theName, settings.snooperEnabled);
break;
case USE_FULLSCREEN:
data.setBoolean(theName, settings.fullScreen);
break;
case ENABLE_VSYNC:
data.setBoolean(theName, settings.enableVsync);
break;
case USE_VBO:
data.setBoolean(theName, settings.useVbo);
break;
case TOUCHSCREEN:
data.setBoolean(theName, settings.touchscreen);
break;
case CHAT_SCALE:
data.setDouble(theName, settings.chatScale);
break;
case CHAT_WIDTH:
data.setDouble(theName, settings.chatWidth);
break;
case CHAT_HEIGHT_FOCUSED:
data.setDouble(theName, settings.chatHeightFocused);
break;
case CHAT_HEIGHT_UNFOCUSED:
data.setDouble(theName, settings.chatHeightUnfocused);
break;
case MIPMAP_LEVELS:
data.setInt(theName, settings.mipmapLevels);
break;
case FORCE_UNICODE_FONT:
data.setBoolean(theName, settings.forceUnicodeFont);
break;
case REDUCED_DEBUG_INFO:
data.setBoolean(theName, settings.reducedDebugInfo);
break;
case ENTITY_SHADOWS:
data.setBoolean(theName, settings.entityShadows);
break;
case ENABLE_WEAK_ATTACKS:
data.setBoolean(theName, settings.enableWeakAttacks);
break;
case SHOW_SUBTITLES:
data.setBoolean(theName, settings.showSubtitles);
break;
case REALMS_NOTIFICATIONS:
data.setBoolean(theName, settings.realmsNotifications);
break;
case AUTO_JUMP:
data.setBoolean(theName, settings.autoJump);
break;
case RENDER_CLOUDS:
data.setInt(theName, settings.clouds);
break;
case GRAPHICS:
data.setBoolean(theName, settings.fancyGraphics);
break;
case AMBIENT_OCCLUSION:
data.setInt(theName, settings.ambientOcclusion);
break;
case GUI_SCALE:
data.setInt(theName, settings.guiScale);
break;
case PARTICLES:
data.setInt(theName, settings.particleSetting);
break;
case CHAT_VISIBILITY:
data.setInt(theName, settings.chatVisibility.ordinal());
break;
case MAIN_HAND:
data.setString(theName, settings.mainHand.name());
break;
case ATTACK_INDICATOR:
data.setInt(theName, settings.attackIndicator);
break;
default:
}
}
// Not to forget sounds...
for (final SoundCategory cat : SoundCategory.values()) data.setDouble(SOUND_PREFIX + cat.getName(), settings.getSoundLevel(cat));
// ...and keybindings
for (final KeyBinding keybinding : settings.keyBindings) {
final String id = KEYBIND_PREFIX + keybinding.getKeyDescription();
String val = Integer.toString(keybinding.getKeyCode());
if (keybinding.getKeyModifier() != KeyModifier.NONE)
val += ":" + keybinding.getKeyModifier();
data.setString(id, val);
}
}
use of org.blockartistry.Presets.api.PresetData in project DynamicSurroundings by OreCruncher.
the class PresetHandler method presetLoad.
@Optional.Method(modid = "presets")
@SubscribeEvent
public static void presetLoad(@Nonnull final PresetEvent.Load event) {
final PresetData data = event.getModData(DSurround.MOD_ID);
if (data != null) {
final ConfigurationHelper helper = new ConfigurationHelper(data);
helper.load(DSurround.config(), FILTER);
DSurround.config().save();
ConfigProcessor.process(DSurround.config(), ModOptions.class);
MinecraftForge.EVENT_BUS.post(new ReloadEvent.Configuration());
}
}
use of org.blockartistry.Presets.api.PresetData in project DynamicSurroundings by OreCruncher.
the class PresetHandler method presetSave.
@Optional.Method(modid = "presets")
@SubscribeEvent
public static void presetSave(@Nonnull final PresetEvent.Save event) {
final PresetData data = event.getModData(DSurround.MOD_ID);
final ConfigurationHelper helper = new ConfigurationHelper(data);
helper.save(DSurround.config(), FILTER);
}
use of org.blockartistry.Presets.api.PresetData in project DynamicSurroundings by OreCruncher.
the class MinecraftConfigHandler method onConfigLoad.
@SubscribeEvent
public static void onConfigLoad(@Nonnull final PresetEvent.Load event) {
final PresetData data = event.getModData(MINECRAFT);
if (data != null) {
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
boolean refreshChat = false;
boolean refreshMipmaps = false;
boolean refreshRenderDistance = false;
boolean refreshRenderers = false;
boolean refreshUnicodeFlag = false;
boolean refreshResources = false;
boolean refreshVsync = false;
for (final Entry<String, String> e : data.getEntries()) {
if (e.getKey().startsWith(SOUND_PREFIX)) {
final String catName = e.getKey().replace(SOUND_PREFIX, "");
final SoundCategory sc = SoundCategory.getByName(catName);
if (sc != null) {
settings.setSoundLevel(sc, (float) Double.parseDouble(e.getValue()));
} else {
Presets.log().warn("Unknown sound category: %s", catName);
}
} else if (e.getKey().startsWith(KEYBIND_PREFIX)) {
boolean found = false;
final String keyName = e.getKey().replace(KEYBIND_PREFIX, "");
for (final KeyBinding binding : settings.keyBindings) {
if (keyName.equals(binding.getKeyDescription())) {
final String[] parts = StringUtils.split(e.getValue(), ':');
final int keyCode = Integer.parseInt(parts[0]);
final KeyModifier modifier = parts.length == 1 ? KeyModifier.NONE : KeyModifier.valueFromString(parts[1]);
binding.setKeyModifierAndCode(modifier, keyCode);
found = true;
break;
}
}
if (!found)
Presets.log().warn("Unknown keybinding found: %s", keyName);
} else {
final String theName = e.getKey();
final Options option = getOptionByName(theName);
if (option != null) {
switch(option) {
case INVERT_MOUSE:
settings.invertMouse = data.getBoolean(theName, settings.invertMouse);
break;
case SENSITIVITY:
settings.mouseSensitivity = (float) data.getDouble(theName, settings.mouseSensitivity);
break;
case FOV:
settings.fovSetting = (float) data.getDouble(theName, settings.fovSetting);
break;
case GAMMA:
settings.gammaSetting = (float) data.getDouble(theName, settings.gammaSetting);
break;
case SATURATION:
settings.saturation = (float) data.getDouble(theName, settings.saturation);
break;
case RENDER_DISTANCE:
final int rd = data.getInt(theName, settings.renderDistanceChunks);
if (settings.renderDistanceChunks != rd) {
settings.renderDistanceChunks = rd;
refreshRenderDistance = true;
}
break;
case VIEW_BOBBING:
settings.viewBobbing = data.getBoolean(theName, settings.viewBobbing);
break;
case ANAGLYPH:
final boolean anal = data.getBoolean(theName, settings.anaglyph);
if (settings.anaglyph != anal) {
settings.anaglyph = anal;
refreshResources = true;
}
break;
case FRAMERATE_LIMIT:
settings.limitFramerate = data.getInt(theName, settings.limitFramerate);
break;
case FBO_ENABLE:
settings.fboEnable = data.getBoolean(theName, settings.fboEnable);
break;
case CHAT_COLOR:
settings.chatColours = data.getBoolean(theName, settings.chatColours);
refreshChat = true;
break;
case CHAT_LINKS:
settings.chatLinks = data.getBoolean(theName, settings.chatLinks);
refreshChat = true;
break;
case CHAT_OPACITY:
settings.chatOpacity = (float) data.getDouble(theName, settings.chatOpacity);
refreshChat = true;
break;
case CHAT_LINKS_PROMPT:
settings.chatLinksPrompt = data.getBoolean(theName, settings.chatLinksPrompt);
refreshChat = true;
break;
case SNOOPER_ENABLED:
settings.snooperEnabled = data.getBoolean(theName, settings.snooperEnabled);
break;
case USE_FULLSCREEN:
settings.fullScreen = data.getBoolean(theName, settings.fullScreen);
break;
case ENABLE_VSYNC:
final boolean vsync = data.getBoolean(theName, settings.enableVsync);
if (settings.enableVsync != vsync) {
settings.enableVsync = vsync;
refreshVsync = true;
}
break;
case USE_VBO:
final boolean vbo = data.getBoolean(theName, settings.useVbo);
if (settings.useVbo != vbo) {
settings.useVbo = vbo;
refreshRenderers = true;
}
break;
case TOUCHSCREEN:
settings.touchscreen = data.getBoolean(theName, settings.touchscreen);
break;
case CHAT_SCALE:
settings.chatScale = (float) data.getDouble(theName, settings.chatScale);
refreshChat = true;
break;
case CHAT_WIDTH:
settings.chatWidth = (float) data.getDouble(theName, settings.chatWidth);
refreshChat = true;
break;
case CHAT_HEIGHT_FOCUSED:
settings.chatHeightFocused = (float) data.getDouble(theName, settings.chatHeightFocused);
refreshChat = true;
break;
case CHAT_HEIGHT_UNFOCUSED:
settings.chatHeightUnfocused = (float) data.getDouble(theName, settings.chatHeightUnfocused);
refreshChat = true;
break;
case MIPMAP_LEVELS:
final int mips = data.getInt(theName, settings.mipmapLevels);
if (settings.mipmapLevels != mips) {
settings.mipmapLevels = mips;
refreshMipmaps = true;
}
break;
case FORCE_UNICODE_FONT:
final boolean force = data.getBoolean(theName, settings.forceUnicodeFont);
if (settings.forceUnicodeFont != force) {
settings.forceUnicodeFont = force;
refreshUnicodeFlag = true;
}
break;
case REDUCED_DEBUG_INFO:
settings.reducedDebugInfo = data.getBoolean(theName, settings.reducedDebugInfo);
break;
case ENTITY_SHADOWS:
settings.entityShadows = data.getBoolean(theName, settings.entityShadows);
break;
case ENABLE_WEAK_ATTACKS:
settings.enableWeakAttacks = data.getBoolean(theName, settings.enableWeakAttacks);
break;
case SHOW_SUBTITLES:
settings.showSubtitles = data.getBoolean(theName, settings.showSubtitles);
break;
case REALMS_NOTIFICATIONS:
settings.realmsNotifications = data.getBoolean(theName, settings.realmsNotifications);
break;
case AUTO_JUMP:
settings.autoJump = data.getBoolean(theName, settings.autoJump);
break;
case RENDER_CLOUDS:
settings.clouds = data.getInt(theName, settings.clouds);
break;
case GRAPHICS:
final boolean fancy = data.getBoolean(theName, settings.fancyGraphics);
if (settings.fancyGraphics != fancy) {
settings.fancyGraphics = fancy;
refreshRenderers = true;
}
break;
case AMBIENT_OCCLUSION:
final int occlusion = data.getInt(theName, settings.ambientOcclusion);
if (settings.ambientOcclusion != occlusion) {
settings.ambientOcclusion = occlusion;
refreshRenderers = true;
}
break;
case GUI_SCALE:
settings.guiScale = data.getInt(theName, settings.guiScale);
break;
case PARTICLES:
settings.particleSetting = data.getInt(theName, settings.particleSetting);
break;
case CHAT_VISIBILITY:
settings.chatVisibility = EnumChatVisibility.getEnumChatVisibility(data.getInt(theName, settings.chatVisibility.ordinal()));
break;
case MAIN_HAND:
settings.mainHand = EnumHandSide.valueOf(data.getString(theName, settings.mainHand.name()));
break;
case ATTACK_INDICATOR:
settings.attackIndicator = data.getInt(theName, settings.attackIndicator);
break;
default:
}
} else {
Presets.log().warn("Unknown option value: %s", theName);
}
}
}
settings.saveOptions();
// Tickle the various modules of Minecraft to get the update
// settings since we bypassed the get/set of GameSettings.
final Minecraft mc = Minecraft.getMinecraft();
if (refreshChat)
mc.ingameGUI.getChatGUI().refreshChat();
if (refreshMipmaps) {
mc.getTextureMapBlocks().setMipmapLevels(settings.mipmapLevels);
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.getTextureMapBlocks().setBlurMipmapDirect(false, settings.mipmapLevels > 0);
refreshResources = true;
}
if (refreshRenderDistance)
mc.renderGlobal.setDisplayListEntitiesDirty();
if (refreshRenderers)
mc.renderGlobal.loadRenderers();
if (refreshUnicodeFlag)
mc.fontRenderer.setUnicodeFlag(mc.getLanguageManager().isCurrentLocaleUnicode() || settings.forceUnicodeFont);
if (refreshResources)
mc.refreshResources();
if (refreshVsync)
Display.setVSyncEnabled(settings.enableVsync);
if (settings.fullScreen != mc.isFullScreen())
mc.toggleFullscreen();
}
}
use of org.blockartistry.Presets.api.PresetData in project DynamicSurroundings by OreCruncher.
the class PresetInfo method set1.
PresetInfo set1(@Nonnull final Map<String, PresetData> data) {
this.data = data;
this.restartRequired = false;
for (final PresetData d : this.data.values()) if (d.isRestartRequired()) {
this.restartRequired = true;
break;
}
return this;
}
Aggregations