Skip to content

Commit 18f1500

Browse files
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 Minor optimization of Rememberer initialization code Rememberer is automatically disabled if PRUNE is found
1 parent 06c87dd commit 18f1500

File tree

7 files changed

+100
-207
lines changed

7 files changed

+100
-207
lines changed

ChangeLog.txt

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

3+
3.4.3
4+
Added code from Rememberer mod at mod author @Krazy1 request, remembers the last sort setting for the Editor part list.
5+
Original thread: https://forum.kerbalspaceprogram.com/index.php?/topic/203114-rememberer/&tab=comments#comment-3991624
6+
Minor optimization of Rememberer initialization code
7+
Rememberer is automatically disabled if PRUNE is found
8+
39
3.4.2
410
Fixed fine adjust to dynamically get gizmo offsets. This fixes the broken FineAdjust in 1.11 and is compatible with 1.10
511

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": {

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.1.1")]
13+
[assembly: AssemblyVersion("3.4.2.0")]

EditorExtensionsRedux/EditorExtensionsRedux.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<Compile Include="Properties\AssemblyInfo.cs" />
6060
<Compile Include="EditorExtensionsRedux.cs" />
6161
<Compile Include="Logging.cs" />
62+
<Compile Include="Rememberer\Rememberer.cs" />
6263
<Compile Include="SettingsWindow.cs" />
6364
<Compile Include="AppLauncherButton.cs" />
6465
<Compile Include="DebugAutoLoadSave.cs" />
@@ -125,6 +126,7 @@
125126
</Reference>
126127
<Reference Include="System.Xml" />
127128
</ItemGroup>
129+
<ItemGroup />
128130
<PropertyGroup>
129131
<PostBuildEvent>
130132
set KSPDIR=$(KSPDIR)
@@ -152,4 +154,4 @@ if $(ConfigurationName) == Release (
152154
<PropertyGroup>
153155
<PreBuildEvent>"$(DevEnvDir)\texttransform.exe" "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
154156
</PropertyGroup>
155-
</Project>
157+
</Project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using UnityEngine;
3+
using KSP.UI.Screens; // has EditorPartList
4+
5+
namespace Rememberer
6+
{
7+
8+
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
9+
public class RememEditor : MonoBehaviour
10+
{
11+
private static bool sortAsc = true;
12+
private static int sortIndex = 1;
13+
private static ConfigNode nodeFile = null;
14+
private static bool disabled = false;
15+
16+
// capture part list sort method change
17+
private void SortCB(int index, bool asc)
18+
{
19+
sortIndex = index;
20+
sortAsc = asc;
21+
}
22+
23+
const string FILE = "GameData/EditorExtensionsRedux/RememEditor.cfg";
24+
const string SORTASC_NAME = "partListSortAsc";
25+
const string SORTINDEX_NAME = "partListSortIndex";
26+
27+
static public bool hasMod(string modIdent)
28+
{
29+
foreach (AssemblyLoader.LoadedAssembly a in AssemblyLoader.loadedAssemblies)
30+
{
31+
if (modIdent == a.name)
32+
return true;
33+
34+
}
35+
return false;
36+
}
37+
38+
39+
40+
public void Start()
41+
{
42+
if (disabled)
43+
return;
44+
if (nodeFile == null)
45+
{
46+
if (hasMod("PRUNE"))
47+
{
48+
disabled = true;
49+
return;
50+
}
51+
EditorExtensionsRedux.Log.Info("RememEditor - Start");
52+
53+
// Imports initial sort settings from config file into a default "root" Config Node
54+
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+
58+
// set initial sort method
59+
EditorPartList.Instance.partListSorter.ClickButton(sortIndex);
60+
if (!sortAsc)
61+
{
62+
EditorPartList.Instance.partListSorter.ClickButton(sortIndex);
63+
}
64+
}
65+
//Track the user's sort changes
66+
EditorPartList.Instance.partListSorter.AddOnSortCallback(SortCB);
67+
}
68+
69+
public void OnDisable()
70+
{
71+
if (nodeFile == null)
72+
return;
73+
74+
EditorExtensionsRedux.Log.Info("RememEditor - Disable");
75+
nodeFile.SetValue(SORTASC_NAME, sortAsc.ToString());
76+
nodeFile.SetValue(SORTINDEX_NAME, sortIndex.ToString());
77+
nodeFile.Save(KSPUtil.ApplicationRootPath + FILE);
78+
//EditorPartList is already disabled when OnDisable is called so remove callback gives NRE
79+
//EditorPartList.Instance.partListSorter.RemoveOnSortCallback(SortCB);
80+
}
81+
}
82+
83+
}

GameData/EditorExtensionsRedux/EditorExtensionsRedux.version

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

GameData/EditorExtensionsRedux/README.md

Lines changed: 4 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -2,207 +2,6 @@
22
## Editor Extensions
33
##
44
##
5-
3.3.20
6-
Added new feature activated by default letter B: Centers the vessel horizontally in the editor, and lowers it to 5m high
7-
8-
3.3.19.10
9-
Fixed issue when detaching a moving part in the editor (while it's snapping)
10-
Updated version info
11-
12-
3.3.19.9
13-
Fix flickering in editor when moving mouse over angle snap window
14-
15-
3.3.19.8
16-
Version bump for 1.5 rebuild
17-
18-
3.3.19.7
19-
Removed unnecessary line from AssemblyVersion.tt: <#@ assembly name="EnvDTE" #>
20-
From @lisias:
21-
Amending 4x4cheessecake fixe for the Mass AutoStrut problem. This allows to "recover" a mangled vessel.
22-
23-
3.3.19.6
24-
Thanks to 4x4cheesecake for these fixes:
25-
Added an additional logical operator to prevent autostruts beeing applied to parts which don't allow them.
26-
Fixed a visual issue regarding the 'Fine Adjustment' window. It's no longer flickering when dragging it around.
27-
28-
3.3.19.5
29-
Added button to Settings page 2 to "Reset Symmetry Mode & Angle Snap keys"
30-
31-
3.3.19.4
32-
Added some extra checking to be sure all needed Reflection values have been found
33-
34-
3.3.19.3
35-
Added code to dynamically assign Reflection offsets. Hopefully this will eliminate the need to do manual changes in the future
36-
Updated version to allow all 1.4.*
37-
38-
3.3.19.2
39-
Fixed fuzzy button
40-
41-
3.3.19.1
42-
Fixed issue when displaying autostruts, most got reset to Heaviest
43-
Fixed issue when setting AS to grandparent, was setting to Heaviest
44-
45-
3.3.19
46-
Updated obsolete Linerenderer calls
47-
Fixed NoOffsetLimit code to NOT activate when a compound part is being moved with the offset gizmo
48-
49-
3.3.18
50-
Changed resize of settings window from just before ClickThroughBlocker.GUILayoutWindow to after to toolbar, to avoid confusing the ClickThroughBlocker
51-
52-
3.3.17
53-
Updated for 1.4.1
54-
Added ClickThroughBlocker as a hard dependency
55-
56-
3.3.16
57-
Removed compound part check, was not working
58-
Hotkeys no longer trigger while text input field has focus
59-
60-
## Changes in 3.3.15
61-
Added check for compound part in NoOffsetLimits, will not work on compound parts
62-
63-
## Changes in 3.3.14
64-
Updated for KSP 1.3.1
65-
66-
## Changes in 3.3.13
67-
68-
69-
## Changes in 3.3.12
70-
Fixed issue where changing the Reroot setting in the settings window wasn't toggling the internal reroot flag
71-
Changed SelectRoot code from being a separate MonoBehaviour to being a part of the EditorExtensions class
72-
Updated buildRelease to use local GameData directory for release
73-
74-
## Changes in 3.3.11
75-
Fixed positioning of menu in Editor (it was too low)
76-
77-
## Changes in 3.3.10.1
78-
updated versioning for 1.2.2
79-
80-
## Changes in 3.3.10
81-
Fixed null ref when F is pressed and no part is selected
82-
83-
## Changes in 3.3.9
84-
Fixed (the right way) the no offset tool for local/absolute offsets
85-
86-
## changes in 3.3.8
87-
Fixed issue where NoOffsetLimits was not working upon entry into editor
88-
Added ability to disable Fine Adjust window
89-
Added window showing angle snaps, clickin on button will set that value
90-
91-
## Change in 3.3.7
92-
Added code to toggle no offset limit to settings window
93-
Fixed code for toggling the no offset Limit
94-
Added automatic updating of AssemblyVersion, from the .version file, displayed in the Settings window
95-
Removed extra set of configs for the Reflection offsets
96-
Fixed bug with local offset vs absolute offset; Code was not using the local setting, was always using the absolute setting
97-
98-
## Change in 3.3.6
99-
Fixed menu Show Tweakables, for when Advanced tweakables is enabled, to show at the right height
100-
Fixed resizing of menu
101-
102-
## Change in 3.3.5
103-
Added AnglesnapModIsToggle, if enabled, hitting the Mod-C (for Windows,ALT-C) will switch between 1 and the last setting
104-
Added CycleSymmetryModeModIsToggle , if enabled, hitting the Mod-X (for Windows, ALT-X) will switch between 1 and the last setting
105-
Reordered the settings windows, now all keystroke settings are on the Settings 2 window
106-
Commented out old code blocks: SymmetryModeCycle & AngleSnapCycle, which were replaced by Boop's code in Update()
107-
Updated for 1.2.1
108-
Fixed menu height to adjust depending on whether mass tweakables is on or off - Menu
109-
needs to be redisplayed by moving the mouse over the toolbar for height to be adjusted, only applies when Advanced
110-
Tweakables is off
111-
112-
## Change in 3.3.4
113-
Changed "No Show Autostruts" to "Hide Autostruts" text on buttons
114-
MasterSnap now can be turned off by clicking anywhere not on a part. Previously, had to click on another part
115-
116-
## Changes in 3.3.3
117-
Added Autostrut and Rigidity buttons, thanks @Boop:
118-
All Rigid
119-
Disable Rigid
120-
Toggle Rigid
121-
No Autostruts
122-
AS Grandparent
123-
AS Heaviest
124-
AS Root
125-
Show Autostruts
126-
Added No Offset Limit Toggle
127-
128-
## Changes in 3.3.2
129-
Added ability to disable the SelectRoot functionality, so you can use the stock SelectRoot to change the root on a shadow assembly
130-
Added Master Snap mode. This allows you to snap parts to any random part, not just the parent. This works for both horizontal and vertical snapping. The part selected as the master will be highlighted
131-
Snapping is shown visually via a smooth movement of the part from the original location to the destination
132-
133-
## Changes in 3.3.1
134-
Fixed bug with no offset limit preventing swap between local and absolute coordinates
135-
136-
## Changes in 3.3.0
137-
Added ability to disable internal reroot, so that you can use the stock reroot to reroot shadow part assemblies
138-
139-
## Changes in 3.2.15
140-
Boop's changes for more robust symmetry and angle snap cycling (thanks Boop and Fwiffo).
141-
142-
## Changes in 3.2.14
143-
Updated values for KSP 1.1.3
144-
center horizontally on z-axis with shift+H. (thanks OliverPA77)
145-
146-
## Changes in 3.2.13
147-
Fixed Fine Adjustments window (inability to close it or change the values)
148-
Now saves both angle snap value and whether it was on/off after exiting editor session
149-
Fixed issue with fine adjust translation wouldn't work if snap was on
150-
151-
## Changes in 3.2.12
152-
Fixed rotation gizmo to not angle snap when anglesnap is off
153-
Replaced code which did FindObjectsOftype with GizmoEvents class for performance improvement
154-
Updated FineAdjustments window to detect which gizmo is active
155-
156-
## Changes in 3.2.11
157-
Added 1/4 second delay in hiding menu
158-
159-
## Changes in 3.2.10
160-
Added UI scaling code to position of EEX menu
161-
Fixed accidently disabling the ability to change the anglesnap on/off by clicking the sprite
162-
163-
## Changes in 3.2.9
164-
Removed old code from the FineAdjust Update function which was causing an exception
165-
Reduced height of popup menu
166-
Fixed bug where clicking on the symmetry sprite (the one which changes the angle snap degrees) when the angle was zero
167-
would not allow surface attachments to anything other than the +z axis:
168-
"I can place the battery only on the +z axis of the structure. I cannot place it on -z, +x, -x"
169-
Removed performance issue when Fine Adjustments window was shown
170-
Reduced performance impact when fine adjustments are being done
171-
172-
## Changes in 3.2.8
173-
Added code from Fwiffo to fix bug where changing the angle snap while in rotate mode would not affect the rotate gizmo
174-
Added code from Fwiffo for Rapid Zoom
175-
Note: Code from Fwiffo was modified to use the Reflection offsets rather than names to maintain compatibility with Linux & OSX
176-
Fixed bug where going into the rotate gizmo the first time without changing the snap would have a rotation snap of 15 when it should have been zero
177-
178-
NEW FEATURE: Fine Adjust
179-
Fine Adjust window added
180-
New config window for fine adjust keys
181-
When Fine Adjust window is open, keys will do fine adjustments depending on which gizmo is selected:
182-
Default keys: arrow keys + rightShift & rightControl
183-
184-
## Changes in 3.2.7
185-
Added code so that typing in text fields will be ignored by mod
186-
187-
## Changes in 3.2.6
188-
Added compatility for 1.1.2
189-
190-
## Changes in 3.2.5
191-
Added back 1.1.0 compatiblity
192-
Added check for compatibility with specific KSP versions, currently 1.1.0 & 1.1.1
193-
194-
## Changes in 3.2.4
195-
Fixed offsets to eliminate nullrefs
196-
197-
## Changes in 3.2.3
198-
Updated for 1.1.1
199-
200-
## Changes in 3.2.2
201-
202-
Includes submods:
203-
Strip Symmetry
204-
No Offset Limits
205-
SelectRoot2Behaviour
2065

2076
### Features
2087
* Allows custom levels of radial symmetry beyond the stock limitations.
@@ -250,7 +49,10 @@ Includes submods:
25049
* **Space** - When no part is selected, resets camera pitch and heading (straight ahead and level)
25150

25251
### Warning on Keybindings
253-
* Note in very rare circumstances the symmetry and angle snap keybindings might be lost. This would only occur if another mod triggers the game to save its settings while in the VAB/SPH, *and* the game subsequently crashes or is killed before exiting the building. If it happens, you can easily restore the keybindings (X and C by default) in the game's settings menu.
52+
* Note in very rare circumstances the symmetry and angle snap keybindings might be lost. This would only occur
53+
if another mod triggers the game to save its settings while in the VAB/SPH, *and* the game subsequently crashes
54+
or is killed before exiting the building. If it happens, you can easily restore the keybindings (X and C by
55+
default) by hovering over the toolbar button and selecting the menu option "Reset Mode & Snap keys".
25456

25557
### Stock keybinding (change in stock config screen)
25658
* **R** - Toggle symmetry mode from SPH to VAB style (mirror to radial).

0 commit comments

Comments
 (0)