Skip to content

Commit

Permalink
remove hidden buttons from the list
Browse files Browse the repository at this point in the history
  • Loading branch information
radistmorse committed Mar 7, 2018
1 parent 9beec16 commit 359433a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
37 changes: 19 additions & 18 deletions AdjustableModPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private class ModDescriptor {
public string method;
public uint textureHash;
public bool textureHashNeeded = false;
public bool unmaintainable = false;
public bool unmanageable = false;

public ApplicationLauncher.AppScenes defaultScenes;
public ApplicationLauncher.AppScenes requiredScenes;
Expand Down Expand Up @@ -181,7 +181,7 @@ private void OpenMainWindow () {

int num = 0;
foreach (var mod in descriptors) {
if (!mod.unmaintainable && mod.modIcon != null)
if (!mod.unmanageable && mod.defaultScenes != ApplicationLauncher.AppScenes.NEVER && mod.modIcon != null)
num++;
}

Expand Down Expand Up @@ -265,7 +265,7 @@ private void OpenMainWindow () {
}

foreach (var mod in descriptors) {
if (mod.unmaintainable || mod.modIcon == null)
if (mod.unmanageable || mod.modIcon == null || mod.defaultScenes == ApplicationLauncher.AppScenes.NEVER)
continue;
// mod lines
line = new GameObject ();
Expand Down Expand Up @@ -569,28 +569,29 @@ public void AppButtonEnable () {
// not needed, really
}

internal ApplicationLauncher.AppScenes GetModScenes (string module, string method, ApplicationLauncher.AppScenes scenes, uint hash) {
internal ApplicationLauncher.AppScenes GetModScenes (string module, string method, ApplicationLauncher.AppScenes currentScenes, uint hash) {
foreach (var mod in descriptors) {
if (mod.module == module && mod.method == method) {
if (!mod.textureHashNeeded || (mod.textureHash == hash)) {
if (mod.unmaintainable) {
return scenes;
if (mod.unmanageable) {
return currentScenes;
}
// lets check that the scenes didn't change while we were frolicking about
if (scenes != currentScenes[mod] && scenes != mod.defaultScenes) {
if (currentScenes != this.currentScenes[mod] && currentScenes != mod.defaultScenes) {
Debug.Log ("[Adjustable Mod Panel] WARNING: mod " + module + "+" + method + " changed visibility. This is unexpected, ignoring it.");
return scenes;
mod.unmanageable = true;
return currentScenes;
}
if (pendingChanges.ContainsKey (mod)) {
currentScenes[mod] = pendingChanges[mod];
this.currentScenes[mod] = pendingChanges[mod];
pendingChanges.Remove (mod);
}
return currentScenes[mod];
return this.currentScenes[mod];
}
}
}
Debug.Log ("[Adjustable Mod Panel] WARNING: mod " + module + "+" + method + " was not found.");
return scenes;
return currentScenes;
}

internal bool IsAppButton (ApplicationLauncherButton appButton) {
Expand Down Expand Up @@ -624,7 +625,7 @@ internal void RecordMod (string module, string method, ApplicationLauncher.AppSc
method = method,
textureHash = hash,
textureHashNeeded = false,
unmaintainable = false,
unmanageable = false,
defaultScenes = scenes,
requiredScenes = alwaysOn,
modIcon = texture
Expand Down Expand Up @@ -652,13 +653,13 @@ internal void EndRecordingMods () {
a.textureHashNeeded = b.textureHashNeeded = true;
if (a.textureHash == b.textureHash) {
Debug.Log ("[Adjustable Mod Panel] WARNING: " + a.module + " defines several app buttons that are exactly the same. We will ignore them from now on.");
a.unmaintainable = true;
a.unmanageable = true;
}
}
}
if (a.textureHashNeeded == false) {
easy.Add (a);
} else if (a.unmaintainable == false) {
} else if (a.unmanageable == false) {
hard.Add (a);
} else {
unmaintainable.Add (a);
Expand Down Expand Up @@ -717,7 +718,7 @@ internal void EndRecordingMods () {
bool add = true;
foreach (var modref in descriptors) {
if (mod.module == modref.module && mod.method == modref.method && mod.textureHash == modref.textureHash) {
modref.unmaintainable = true;
modref.unmanageable = true;
add = false;
}
}
Expand Down Expand Up @@ -745,7 +746,7 @@ internal void SaveConfig () {
KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType<AdjustableModPanel> (null);
int i = 1;
foreach (var mod in descriptors) {
if (mod.unmaintainable)
if (mod.unmanageable)
continue;
// artifact from an old config
if (mod.textureHashNeeded && mod.textureHash == 0u)
Expand Down Expand Up @@ -778,7 +779,7 @@ private void LoadConfig () {
method = vals[1],
textureHash = 0,
textureHashNeeded = false,
unmaintainable = false,
unmanageable = false,
modIcon = null,
defaultScenes = ApplicationLauncher.AppScenes.NEVER,
requiredScenes = ApplicationLauncher.AppScenes.NEVER
Expand All @@ -789,7 +790,7 @@ private void LoadConfig () {
method = config.GetValue<string> ("method" + i.ToString ()),
textureHashNeeded = config.GetValue<bool> ("hashNeeded" + i.ToString ()),
textureHash = (uint)config.GetValue<long> ("hash" + i.ToString (), 0u),
unmaintainable = false,
unmanageable = false,
modIcon = null,
defaultScenes = ApplicationLauncher.AppScenes.NEVER,
requiredScenes = ApplicationLauncher.AppScenes.NEVER
Expand Down
8 changes: 4 additions & 4 deletions AdjustableModPanel.version
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
},
"VERSION": {
"MAJOR": 1,
"MINOR": 3,
"MINOR": 4,
"PATCH": 0,
"BUILD": 0
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 3,
"MINOR": 4,
"PATCH": 0
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 3,
"MINOR": 4,
"PATCH": 0
},
"KSP_VERSION_MAX": {
"MAJOR": 1,
"MINOR": 3,
"MINOR": 4,
"PATCH": 99
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]

0 comments on commit 359433a

Please sign in to comment.