Skip to content

Commit 41e6af8

Browse files
committed
Check if existing config is outdated
1 parent fb8af39 commit 41e6af8

5 files changed

Lines changed: 43 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.0.4
4+
5+
- Fixed schemes renamed to "Default" instead of the localized name if there was an existing config
6+
37
## v1.0.3
48

59
- Updated for patch 1.15.0

ExtendedColorSchemes/HarmonyPatches/ColorSchemesSettings.cs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,41 @@ private class PColorSchemesSettings
1212
internal static void Postfix(List<ColorScheme> ____colorSchemesList, string ____selectedColorSchemeId)
1313
{
1414
if (Plugin.Config.SelectedColorSchemeId == null)
15-
{
1615
Plugin.Config.SelectedColorSchemeId = ____selectedColorSchemeId;
1716

18-
if (Plugin.Config.ColorSchemesList.Count == 0)
17+
var isOutdated = Plugin.Config.ColorSchemesList.Any(x => x._colorSchemeNameLocalizationKey == "Default");
18+
19+
if (Plugin.Config.ColorSchemesList.Count == 0 || isOutdated)
20+
{
21+
for (int i = 0; i < 16; i++)
1922
{
20-
for (int i = 0; i < 16; i++)
21-
{
22-
Plugin.Config.ColorSchemesList.Add(new Utils.ExtendedColorScheme
23-
{
24-
_colorSchemeId = $"User{i + 4}",
25-
_colorSchemeNameLocalizationKey = $"CUSTOM_{i + 4}_COLOR_SCHEME",
26-
_isEditable = ____colorSchemesList[0].isEditable,
27-
_saberAColor = ____colorSchemesList[0].saberAColor,
28-
_saberBColor = ____colorSchemesList[0].saberBColor,
29-
_environmentColor0 = ____colorSchemesList[0].environmentColor0,
30-
_environmentColor1 = ____colorSchemesList[0].environmentColor1,
31-
_supportsEnvironmentColorBoost = ____colorSchemesList[0].supportsEnvironmentColorBoost,
32-
_environmentColor0Boost = ____colorSchemesList[0].environmentColor0Boost,
33-
_environmentColor1Boost = ____colorSchemesList[0].environmentColor1Boost,
34-
_obstaclesColor = ____colorSchemesList[0].obstaclesColor,
35-
});
36-
}
23+
Utils.ExtendedColorScheme oldColorScheme = null;
24+
25+
if (Plugin.Config.ColorSchemesList.Count > i)
26+
oldColorScheme = Plugin.Config.ColorSchemesList[i];
3727

38-
Plugin.Config.Changed();
28+
var newColorScheme = new Utils.ExtendedColorScheme
29+
{
30+
_colorSchemeId = $"User{i + 4}",
31+
_colorSchemeNameLocalizationKey = $"CUSTOM_{i + 4}_COLOR_SCHEME",
32+
_isEditable = oldColorScheme != null ? oldColorScheme._isEditable : ____colorSchemesList[0].isEditable,
33+
_saberAColor = oldColorScheme != null ? oldColorScheme._saberAColor : ____colorSchemesList[0].saberAColor,
34+
_saberBColor = oldColorScheme != null ? oldColorScheme._saberBColor : ____colorSchemesList[0].saberBColor,
35+
_environmentColor0 = oldColorScheme != null ? oldColorScheme._environmentColor0 : ____colorSchemesList[0].environmentColor0,
36+
_environmentColor1 = oldColorScheme != null ? oldColorScheme._environmentColor1 : ____colorSchemesList[0].environmentColor1,
37+
_supportsEnvironmentColorBoost = oldColorScheme != null ? oldColorScheme._supportsEnvironmentColorBoost : ____colorSchemesList[0].supportsEnvironmentColorBoost,
38+
_environmentColor0Boost = oldColorScheme != null ? oldColorScheme._environmentColor0Boost : ____colorSchemesList[0].environmentColor0Boost,
39+
_environmentColor1Boost = oldColorScheme != null ? oldColorScheme._environmentColor1Boost : ____colorSchemesList[0].environmentColor1Boost,
40+
_obstaclesColor = oldColorScheme != null ? oldColorScheme._obstaclesColor : ____colorSchemesList[0].obstaclesColor,
41+
};
42+
43+
if (oldColorScheme != null)
44+
Plugin.Config.ColorSchemesList.Remove(oldColorScheme);
45+
46+
Plugin.Config.ColorSchemesList.Insert(i, newColorScheme);
3947
}
48+
49+
Plugin.Config.Changed();
4050
}
4151
}
4252
}

ExtendedColorSchemes/Properties/AssemblyInfo.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
// General Information about an assembly is controlled through the following
5+
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
88
[assembly: AssemblyTitle("ExtendedColorSchemes")]
@@ -14,8 +14,8 @@
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
1919
// COM, set the ComVisible attribute to true on that type.
2020
[assembly: ComVisible(false)]
2121

@@ -25,12 +25,12 @@
2525
// Version information for an assembly consists of the following four values:
2626
//
2727
// Major Version
28-
// Minor Version
28+
// Minor Version
2929
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
32+
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.3")]
36-
[assembly: AssemblyFileVersion("1.0.3")]
35+
[assembly: AssemblyVersion("1.0.4")]
36+
[assembly: AssemblyFileVersion("1.0.4")]

ExtendedColorSchemes/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class Utils
88
// Wrapper class so that BSIPA can save the color schemes
99
internal class ExtendedColorScheme
1010
{
11-
public string _colorSchemeId = "Default";
11+
internal string _colorSchemeId = "Default";
1212
internal string _colorSchemeNameLocalizationKey = "Default";
1313
internal bool _isEditable = true;
1414
internal Color _saberAColor = Color.white;

ExtendedColorSchemes/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"id": "ExtendedColorSchemes",
44
"name": "ExtendedColorSchemes",
55
"author": "Meivyn",
6-
"version": "1.0.3",
6+
"version": "1.0.4",
77
"description": "Adds additional custom slots to color schemes.",
88
"gameVersion": "1.15.0",
99
"dependsOn": {

0 commit comments

Comments
 (0)