Skip to content

Commit a8db504

Browse files
Updated to add large icon to the toolbar.BigTexturePath (new in toolbar 1.7.20)
Added InstallChecker Updated AssemblyVersion.tt Changed the message about: WARNING: RegisterMod to only show when debugmode is true Removed the unBlur mod as a hard dependency. It will use UnBlur if it's there, otherwise will fall back to reading the file Removed dependency check for unBlur
1 parent d4554b8 commit a8db504

File tree

14 files changed

+196
-67
lines changed

14 files changed

+196
-67
lines changed
528 KB
Binary file not shown.
528 KB
Binary file not shown.

ChangeLog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
0.1.8
2+
Updated to add large icon to the toolbar.BigTexturePath (new in toolbar 1.7.20)
3+
Added InstallChecker
4+
Updated AssemblyVersion.tt
5+
Changed the message about: WARNING: RegisterMod to only show when debugmode is true
6+
Removed the unBlur mod as a hard dependency. It will use UnBlur if it's there, otherwise will fall back to reading the file
7+
Removed dependency check for unBlur
8+
19
0.1.7
210
Added dependency unBlur
311
Added dependency checks for unblur, clickthroughblocker

ToolbarControl.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"VERSION": {
1010
"MAJOR": 0,
1111
"MINOR": 1,
12-
"PATCH": 7,
12+
"PATCH": 8,
1313
"BUILD": 0
1414
},
1515
"KSP_VERSION": {

ToolbarControl.version.old

Lines changed: 0 additions & 25 deletions
This file was deleted.

ToolbarControl/AssemblyVersion.tt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727
int i2 = 0;
2828
string s;
2929

30+
// For Visual Studio / MSBuild Build-Time Template Resolution
31+
string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";
32+
3033
//
31-
// Update the following with the complete path to the .version file
34+
// Update the following with the name of the .version file which is in the root directory
3235
//
33-
string versionfile = @"D:\Users\jbb\github\ToolbarControl\ToolbarControl.version";
36+
string versionfile = RootDirectory + "ToolbarControl.version";
3437

3538
if (!File.Exists(versionfile))
3639
{

ToolbarControl/InstallChecker.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Based on the InstallChecker from the Kethane mod for Kerbal Space Program.
3+
* https://github.com/Majiir/Kethane/blob/b93b1171ec42b4be6c44b257ad31c7efd7ea1702/Plugin/InstallChecker.cs
4+
*
5+
* Original is (C) Copyright Majiir.
6+
* CC0 Public Domain (http://creativecommons.org/publicdomain/zero/1.0/)
7+
* http://forum.kerbalspaceprogram.com/threads/65395-CompatibilityChecker-Discussion-Thread?p=899895&viewfull=1#post899895
8+
*
9+
* This file has been modified extensively and is released under the same license.
10+
*/
11+
using System;
12+
using System.IO;
13+
using System.Linq;
14+
using System.Reflection;
15+
using UnityEngine;
16+
17+
namespace ToolbarControl_NS
18+
{
19+
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
20+
internal class InstallChecker : MonoBehaviour
21+
{
22+
private const string MODNAME = "Toolbar Controller";
23+
private const string FOLDERNAME = "001_ToolbarControl";
24+
private const string EXPECTEDPATH = FOLDERNAME + "/Plugins";
25+
26+
protected void Start()
27+
{
28+
// Search for this mod's DLL existing in the wrong location. This will also detect duplicate copies because only one can be in the right place.
29+
var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
30+
if (assemblies.Any())
31+
{
32+
var badPaths = assemblies.Select(a => a.path).Select(p => Uri.UnescapeDataString(new Uri(Path.GetFullPath(KSPUtil.ApplicationRootPath)).MakeRelativeUri(new Uri(p)).ToString().Replace('/', Path.DirectorySeparatorChar)));
33+
PopupDialog.SpawnPopupDialog
34+
(
35+
new Vector2(0.5f, 0.5f),
36+
new Vector2(0.5f, 0.5f),
37+
"test",
38+
"Incorrect " + MODNAME + " Installation",
39+
MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + FOLDERNAME + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray()),
40+
"OK",
41+
false,
42+
HighLogic.UISkin
43+
);
44+
Debug.Log("Incorrect " + MODNAME + " Installation: " + MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + EXPECTEDPATH + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray())
45+
46+
);
47+
48+
}
49+
50+
//// Check for Module Manager
51+
//if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
52+
//{
53+
// PopupDialog.SpawnPopupDialog("Missing Module Manager",
54+
// modName + " requires the Module Manager mod in order to function properly.\n\nPlease download from http://forum.kerbalspaceprogram.com/threads/55219 and copy to the KSP/GameData/ directory.",
55+
// "OK", false, HighLogic.Skin);
56+
//}
57+
58+
CleanupOldVersions();
59+
}
60+
61+
/*
62+
* Tries to fix the install if it was installed over the top of a previous version
63+
*/
64+
void CleanupOldVersions()
65+
{
66+
try
67+
{
68+
}
69+
catch (Exception ex)
70+
{
71+
Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
72+
"Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);
73+
74+
}
75+
}
76+
}
77+
}
78+

ToolbarControl/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
[assembly: KSPAssembly("ToolbarController", 1, 0)]
3939

4040
[assembly: KSPAssemblyDependency("ClickThroughBlocker", 1, 0)]
41-
[assembly: KSPAssemblyDependency("unBlur", 0, 4)]
41+
//[assembly: KSPAssemblyDependency("unBlur", 0, 4)]

ToolbarControl/RegisterToolbar.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ namespace ToolbarControl_NS
99
[KSPAddon(KSPAddon.Startup.Instantly, true)]
1010
public class RegisterToolbarBlizzyOptions : MonoBehaviour
1111
{
12+
public static bool unBlurPresent = false;
1213

1314
void Start()
1415
{
16+
unBlurPresent = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "unBlur");
17+
1518
ToolbarControl.RegisterMod(BlizzyOptions.MODID, BlizzyOptions.MODNAME, false, true, false);
1619
}
1720
}

ToolbarControl/RegisterUsage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ internal static void LoadData()
136136

137137
public static bool RegisterMod(string NameSpace, string DisplayName = "", bool useBlizzy = false, bool useStock = true, bool NoneAllowed = true)
138138
{
139-
if (BlizzyOptions.startupCompleted)
139+
if (BlizzyOptions.startupCompleted && ConfigInfo.debugMode)
140140
{
141141
Log.Error("WARNING: RegisterMod, LoadedScene: " + HighLogic.LoadedScene + ", called too late for: " + NameSpace + ", " + DisplayName + ", button may not be registered properly");
142142
}

0 commit comments

Comments
 (0)