Skip to content

Commit

Permalink
Fixed saving and loading of Rememberer cfg file
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxgurugamer committed Jun 23, 2021
1 parent 18f1500 commit 81053b7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ChangeLog

3.4.3.1
Fixed saving and loading of Rememberer cfg file

3.4.3
Added code from Rememberer mod at mod author @Krazy1 request, remembers the last sort setting for the Editor part list.
Original thread: https://forum.kerbalspaceprogram.com/index.php?/topic/203114-rememberer/&tab=comments#comment-3991624
Expand Down
2 changes: 1 addition & 1 deletion EditorExtensionsRedux.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"MAJOR": 3,
"MINOR": 4,
"PATCH": 3,
"BUILD": 0
"BUILD": 1
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion EditorExtensionsRedux/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

using System.Reflection;

[assembly: AssemblyVersion("3.4.2.0")]
[assembly: AssemblyVersion("3.4.3.0")]
23 changes: 12 additions & 11 deletions EditorExtensionsRedux/Rememberer/Rememberer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void SortCB(int index, bool asc)
sortAsc = asc;
}

const string FILE = "GameData/EditorExtensionsRedux/RememEditor.cfg";
const string FILE = "GameData/EditorExtensionsRedux/PluginData/RememEditor.cfg";
const string SORTASC_NAME = "partListSortAsc";
const string SORTINDEX_NAME = "partListSortIndex";

Expand All @@ -30,7 +30,6 @@ static public bool hasMod(string modIdent)
{
if (modIdent == a.name)
return true;

}
return false;
}
Expand All @@ -45,16 +44,19 @@ public void Start()
{
if (hasMod("PRUNE"))
{
EditorExtensionsRedux.Log.Info("Rememberer.Start, PRUNE found");

disabled = true;
return;
}
EditorExtensionsRedux.Log.Info("RememEditor - Start");

// Imports initial sort settings from config file into a default "root" Config Node
nodeFile = ConfigNode.Load(KSPUtil.ApplicationRootPath + FILE);
sortAsc = Convert.ToBoolean(nodeFile.GetValue(SORTASC_NAME)); // true: ascending, false: descending
sortIndex = Convert.ToInt32(nodeFile.GetValue(SORTINDEX_NAME)); // 0: mame, 1: mass, 2: cost, 3: size

if (nodeFile != null)
{
sortAsc = Convert.ToBoolean(nodeFile.GetValue(SORTASC_NAME)); // true: ascending, false: descending
sortIndex = Convert.ToInt32(nodeFile.GetValue(SORTINDEX_NAME)); // 0: mame, 1: mass, 2: cost, 3: size
}
// set initial sort method
EditorPartList.Instance.partListSorter.ClickButton(sortIndex);
if (!sortAsc)
Expand All @@ -68,13 +70,12 @@ public void Start()

public void OnDisable()
{
if (nodeFile == null)
return;
nodeFile = new ConfigNode();

EditorExtensionsRedux.Log.Info("RememEditor - Disable");
nodeFile.SetValue(SORTASC_NAME, sortAsc.ToString());
nodeFile.SetValue(SORTINDEX_NAME, sortIndex.ToString());
nodeFile.SetValue(SORTASC_NAME, sortAsc.ToString(), true);
nodeFile.SetValue(SORTINDEX_NAME, sortIndex.ToString(), true);
nodeFile.Save(KSPUtil.ApplicationRootPath + FILE);

//EditorPartList is already disabled when OnDisable is called so remove callback gives NRE
//EditorPartList.Instance.partListSorter.RemoveOnSortCallback(SortCB);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"VERSION": {
"MAJOR": 3,
"MINOR": 4,
"PATCH": 2,
"PATCH": 3,
"BUILD": 0
},
"KSP_VERSION_MIN": {
Expand Down
2 changes: 1 addition & 1 deletion deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rem VERSIONFILE is the name of the version file, usually the same as GAMEDATA,
rem but not always

set H=%KSPDIR%
rem set H=%KSPDIR_1110%

set GAMEDIR=EditorExtensionsRedux
set GAMEDATA="GameData"
set VERSIONFILE=%GAMEDIR%.version
Expand Down

0 comments on commit 81053b7

Please sign in to comment.