From d8d11770ffd58bd2e8f06d18810752bb57f8a82e Mon Sep 17 00:00:00 2001 From: bebeli555 <62447014+bebeli555@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:53:22 +0300 Subject: [PATCH 1/4] New saturation and contrast config --- src/main/java/rs117/hd/HdPlugin.java | 48 +++++++++++-------- src/main/java/rs117/hd/HdPluginConfig.java | 54 +++++++++++----------- 2 files changed, 56 insertions(+), 46 deletions(-) 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..dacb3291e 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,40 +135,42 @@ default boolean flashingEffects() return false; } + @Range( + min = 1, + max = 25 + ) @ConfigItem( - keyName = "saturation", - name = "Saturation", - description = "Controls the saturation of the final rendered image.", - position = 7, - section = generalSettings + 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", - name = "Contrast", - description = "Controls the contrast of the final rendered image.", - position = 8, - section = generalSettings + 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, - max = 50 + min = 1, + max = 50 ) @ConfigItem( - keyName = "brightness2", - name = "Brightness", - description = "Controls the brightness of scene lighting.", - position = 9, - section = generalSettings + keyName = "brightness2", + name = "Brightness", + description = "Controls the brightness of scene lighting.", + position = 9, + section = generalSettings ) default int brightness() { return 20; } From e2fdcc165e7eb1ae58d0a0e93d3f58fc012bd73a Mon Sep 17 00:00:00 2001 From: bebeli555 <62447014+bebeli555@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:54:41 +0300 Subject: [PATCH 2/4] Delete Contrast.java --- src/main/java/rs117/hd/config/Contrast.java | 48 --------------------- 1 file changed, 48 deletions(-) delete mode 100644 src/main/java/rs117/hd/config/Contrast.java 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; - } -} From a7fc687b6f4843ad62e34ac33ac64b53fb22cd96 Mon Sep 17 00:00:00 2001 From: bebeli555 <62447014+bebeli555@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:54:53 +0300 Subject: [PATCH 3/4] Delete Saturation.java --- src/main/java/rs117/hd/config/Saturation.java | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 src/main/java/rs117/hd/config/Saturation.java 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; - } -} From ba6f06fb7936fd91eaa2e9c4acd2237e9d7f94da Mon Sep 17 00:00:00 2001 From: bebeli555 <62447014+bebeli555@users.noreply.github.com> Date: Wed, 22 Sep 2021 14:56:26 +0300 Subject: [PATCH 4/4] Remove extra tabs --- src/main/java/rs117/hd/HdPluginConfig.java | 52 +++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/rs117/hd/HdPluginConfig.java b/src/main/java/rs117/hd/HdPluginConfig.java index dacb3291e..0b7351cb8 100644 --- a/src/main/java/rs117/hd/HdPluginConfig.java +++ b/src/main/java/rs117/hd/HdPluginConfig.java @@ -136,41 +136,41 @@ default boolean flashingEffects() } @Range( - min = 1, - max = 25 + min = 1, + max = 25 ) @ConfigItem( - keyName = "saturation2", - name = "Saturation", - description = "Controls the saturation of the final rendered image.", - position = 7, - section = generalSettings + keyName = "saturation2", + name = "Saturation", + description = "Controls the saturation of the final rendered image.", + position = 7, + section = generalSettings ) default int saturation() { return 20; } @Range( - min = 1, - max = 25 + min = 1, + max = 25 ) @ConfigItem( - keyName = "contrast2", - name = "Contrast", - description = "Controls the contrast of the final rendered image.", - position = 8, - section = generalSettings + keyName = "contrast2", + name = "Contrast", + description = "Controls the contrast of the final rendered image.", + position = 8, + section = generalSettings ) default int contrast() { return 15; } @Range( - min = 1, - max = 50 + min = 1, + max = 50 ) @ConfigItem( - keyName = "brightness2", - name = "Brightness", - description = "Controls the brightness of scene lighting.", - position = 9, - section = generalSettings + keyName = "brightness2", + name = "Brightness", + description = "Controls the brightness of scene lighting.", + position = 9, + section = generalSettings ) default int brightness() { return 20; } @@ -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() {