@@ -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 }
0 commit comments