diff --git a/src/main/java/rs117/hd/HdPlugin.java b/src/main/java/rs117/hd/HdPlugin.java index 10845eb61..bcfd9f9bb 100644 --- a/src/main/java/rs117/hd/HdPlugin.java +++ b/src/main/java/rs117/hd/HdPlugin.java @@ -411,7 +411,7 @@ enum ComputeMode @Override protected void startUp() { - convertOldBrightnessConfig(); + convertOldConfigs(); configGroundTextures = config.groundTextures(); configGroundBlending = config.groundBlending(); @@ -1783,8 +1783,8 @@ else if (config.fogDepthMode() == FogDepthMode.NONE) gl.glUniform1i(uniPointLightsCount, config.maxDynamicLights().getValue() > 0 ? lightManager.visibleLightsCount : 0); gl.glUniform1i(uniWaterEffects, configWaterEffects.getMode()); - gl.glUniform1f(uniSaturation, config.saturation().getAmount()); - gl.glUniform1f(uniContrast, config.contrast().getAmount()); + gl.glUniform1f(uniSaturation, (float)config.saturation() / 20); + gl.glUniform1f(uniContrast, 0.8f + (float)config.contrast() / 70); double lightPitchRadians = Math.toRadians(lightPitch); double lightYawRadians = Math.toRadians(lightYaw); @@ -2473,32 +2473,42 @@ else if (data != null) } } - //Sets the new brightness setting from the old brightness setting. + //Sets the new brightness, saturation and contrast settings from the old ones //This can be removed later on when most people have updated the plugin - private void convertOldBrightnessConfig() + private void convertOldConfigs() { - try + String[] oldSettingNames = {"brightness", "saturation", "contrast"}; + + for (int i = 0; i < oldSettingNames.length; i++) { - String oldBrightnessValue = configManager.getConfiguration("hd", "brightness"); + String setting = oldSettingNames[i]; - if (!oldBrightnessValue.equals("set")) + try { - String[][] newBrightnessValues = {{"LOWEST", "10"}, {"LOWER", "15"}, {"DEFAULT", "20"}, {"HIGHER", "25"}, {"HIGHEST", "30"}}; - for (String[] newValue : newBrightnessValues) + String oldValue = configManager.getConfiguration("hd", setting); + if (!oldValue.equals("set")) { - if (newValue[0].equals(oldBrightnessValue)) + String[][][] newValues = + {{{"LOWEST", "10"}, {"LOWER", "15"}, {"DEFAULT", "20"}, {"HIGHER", "25"}, {"HIGHEST", "30"}}, //brightness + {{"NONE", "0"}, {"LOWEST", "16"}, {"LOWER", "18"}, {"DEFAULT", "20"}, {"HIGHER", "22"}, {"HIGHEST", "24"}}, //saturation + {{"LOWEST", "7"}, {"LOWER", "10"}, {"DEFAULT", "14"}, {"HIGHER", "21"}, {"HIGHEST", "17"}}}; //contrast + + for (String[] newValue : newValues[i]) { - configManager.setConfiguration("hd", "brightness2", newValue[1]); - break; + if (newValue[0].equals(oldValue)) + { + configManager.setConfiguration("hd", setting + "2", newValue[1]); + break; + } } - } - configManager.setConfiguration("hd", "brightness", "set"); + configManager.setConfiguration("hd", setting, "set"); + } + } + catch (Exception e) + { + //Happens if people don't have the old setting saved, then it doesn't need converting anyway. } - } - catch (Exception e) - { - //Happens if people don't have the old brightness setting, then it doesn't need converting anyway. } } diff --git a/src/main/java/rs117/hd/HdPluginConfig.java b/src/main/java/rs117/hd/HdPluginConfig.java index 82cb581f7..0b7351cb8 100644 --- a/src/main/java/rs117/hd/HdPluginConfig.java +++ b/src/main/java/rs117/hd/HdPluginConfig.java @@ -34,10 +34,8 @@ import static rs117.hd.HdPlugin.MAX_FOG_DEPTH; import rs117.hd.config.AntiAliasingMode; import rs117.hd.config.ColorBlindMode; -import rs117.hd.config.Contrast; import rs117.hd.config.LevelOfDetail; import rs117.hd.config.MaxDynamicLights; -import rs117.hd.config.Saturation; import rs117.hd.config.DefaultSkyColor; import rs117.hd.config.FogDepthMode; import rs117.hd.config.ShadowDistance; @@ -137,29 +135,31 @@ default boolean flashingEffects() return false; } + @Range( + min = 1, + max = 25 + ) @ConfigItem( - keyName = "saturation", + keyName = "saturation2", name = "Saturation", description = "Controls the saturation of the final rendered image.", position = 7, section = generalSettings ) - default Saturation saturation() - { - return Saturation.DEFAULT; - } + default int saturation() { return 20; } + @Range( + min = 1, + max = 25 + ) @ConfigItem( - keyName = "contrast", + keyName = "contrast2", name = "Contrast", description = "Controls the contrast of the final rendered image.", position = 8, section = generalSettings ) - default Contrast contrast() - { - return Contrast.DEFAULT; - } + default int contrast() { return 15; } @Range( min = 1, @@ -381,11 +381,11 @@ default boolean groundTextures() } @ConfigItem( - keyName = "groundBlending", - name = "Ground Blending", - description = "Affects the quality of blending between different ground/terrain textures.", - position = 207, - section = environmentSettings + keyName = "groundBlending", + name = "Ground Blending", + description = "Affects the quality of blending between different ground/terrain textures.", + position = 207, + section = environmentSettings ) default boolean groundBlending() { diff --git a/src/main/java/rs117/hd/config/Contrast.java b/src/main/java/rs117/hd/config/Contrast.java deleted file mode 100644 index ee603c178..000000000 --- a/src/main/java/rs117/hd/config/Contrast.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021, 117 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package rs117.hd.config; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum Contrast -{ - HIGHER("Highest", 1.1f), - HIGHEST("Higher", 1.05f), - DEFAULT("Default", 1.0f), - LOWER("Lower", 0.95f), - LOWEST("Lowest", 0.9f); - - private final String name; - private final float amount; - - @Override - public String toString() - { - return name; - } -} diff --git a/src/main/java/rs117/hd/config/Saturation.java b/src/main/java/rs117/hd/config/Saturation.java deleted file mode 100644 index 6c166ae33..000000000 --- a/src/main/java/rs117/hd/config/Saturation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021, 117 - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package rs117.hd.config; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum Saturation -{ - HIGHEST("Highest", 1.2f), - HIGHER("Higher", 1.1f), - DEFAULT("Default", 1.0f), - LOWER("Lower", 0.9f), - LOWEST("Lowest", 0.8f), - NONE("None", 0.0f); - - private final String name; - private final float amount; - - @Override - public String toString() - { - return name; - } -}