Skip to content

Commit 81053b7

Browse files
Fixed saving and loading of Rememberer cfg file
1 parent 18f1500 commit 81053b7

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

ChangeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
ChangeLog
22

3+
3.4.3.1
4+
Fixed saving and loading of Rememberer cfg file
5+
36
3.4.3
47
Added code from Rememberer mod at mod author @Krazy1 request, remembers the last sort setting for the Editor part list.
58
Original thread: https://forum.kerbalspaceprogram.com/index.php?/topic/203114-rememberer/&tab=comments#comment-3991624

EditorExtensionsRedux.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"MAJOR": 3,
77
"MINOR": 4,
88
"PATCH": 3,
9-
"BUILD": 0
9+
"BUILD": 1
1010
},
1111
"KSP_VERSION_MIN": {
1212
"MAJOR": 1,

EditorExtensionsRedux/AssemblyVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
using System.Reflection;
1212

13-
[assembly: AssemblyVersion("3.4.2.0")]
13+
[assembly: AssemblyVersion("3.4.3.0")]

EditorExtensionsRedux/Rememberer/Rememberer.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private void SortCB(int index, bool asc)
2020
sortAsc = asc;
2121
}
2222

23-
const string FILE = "GameData/EditorExtensionsRedux/RememEditor.cfg";
23+
const string FILE = "GameData/EditorExtensionsRedux/PluginData/RememEditor.cfg";
2424
const string SORTASC_NAME = "partListSortAsc";
2525
const string SORTINDEX_NAME = "partListSortIndex";
2626

@@ -30,7 +30,6 @@ static public bool hasMod(string modIdent)
3030
{
3131
if (modIdent == a.name)
3232
return true;
33-
3433
}
3534
return false;
3635
}
@@ -45,16 +44,19 @@ public void Start()
4544
{
4645
if (hasMod("PRUNE"))
4746
{
47+
EditorExtensionsRedux.Log.Info("Rememberer.Start, PRUNE found");
48+
4849
disabled = true;
4950
return;
5051
}
51-
EditorExtensionsRedux.Log.Info("RememEditor - Start");
5252

5353
// Imports initial sort settings from config file into a default "root" Config Node
5454
nodeFile = ConfigNode.Load(KSPUtil.ApplicationRootPath + FILE);
55-
sortAsc = Convert.ToBoolean(nodeFile.GetValue(SORTASC_NAME)); // true: ascending, false: descending
56-
sortIndex = Convert.ToInt32(nodeFile.GetValue(SORTINDEX_NAME)); // 0: mame, 1: mass, 2: cost, 3: size
57-
55+
if (nodeFile != null)
56+
{
57+
sortAsc = Convert.ToBoolean(nodeFile.GetValue(SORTASC_NAME)); // true: ascending, false: descending
58+
sortIndex = Convert.ToInt32(nodeFile.GetValue(SORTINDEX_NAME)); // 0: mame, 1: mass, 2: cost, 3: size
59+
}
5860
// set initial sort method
5961
EditorPartList.Instance.partListSorter.ClickButton(sortIndex);
6062
if (!sortAsc)
@@ -68,13 +70,12 @@ public void Start()
6870

6971
public void OnDisable()
7072
{
71-
if (nodeFile == null)
72-
return;
73+
nodeFile = new ConfigNode();
7374

74-
EditorExtensionsRedux.Log.Info("RememEditor - Disable");
75-
nodeFile.SetValue(SORTASC_NAME, sortAsc.ToString());
76-
nodeFile.SetValue(SORTINDEX_NAME, sortIndex.ToString());
75+
nodeFile.SetValue(SORTASC_NAME, sortAsc.ToString(), true);
76+
nodeFile.SetValue(SORTINDEX_NAME, sortIndex.ToString(), true);
7777
nodeFile.Save(KSPUtil.ApplicationRootPath + FILE);
78+
7879
//EditorPartList is already disabled when OnDisable is called so remove callback gives NRE
7980
//EditorPartList.Instance.partListSorter.RemoveOnSortCallback(SortCB);
8081
}

GameData/EditorExtensionsRedux/EditorExtensionsRedux.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"VERSION": {
66
"MAJOR": 3,
77
"MINOR": 4,
8-
"PATCH": 2,
8+
"PATCH": 3,
99
"BUILD": 0
1010
},
1111
"KSP_VERSION_MIN": {

deploy.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rem VERSIONFILE is the name of the version file, usually the same as GAMEDATA,
88
rem but not always
99

1010
set H=%KSPDIR%
11-
rem set H=%KSPDIR_1110%
11+
1212
set GAMEDIR=EditorExtensionsRedux
1313
set GAMEDATA="GameData"
1414
set VERSIONFILE=%GAMEDIR%.version

0 commit comments

Comments
 (0)