Skip to content

Commit

Permalink
Merge branch 'feature-toolbarwrapper' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Majiir committed Sep 2, 2014
2 parents 114d507 + 8a3b19a commit 34d4a8c
Show file tree
Hide file tree
Showing 8 changed files with 910 additions and 142 deletions.
58 changes: 0 additions & 58 deletions KethaneToolbar/KethaneToolbar.csproj

This file was deleted.

36 changes: 0 additions & 36 deletions KethaneToolbar/Properties/AssemblyInfo.cs

This file was deleted.

8 changes: 0 additions & 8 deletions Plugin/IWindowToggle.cs

This file was deleted.

3 changes: 2 additions & 1 deletion Plugin/Kethane.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
<Compile Include="GeodesicGrid\Triangle.cs" />
<Compile Include="GeodesicGrid\TriangleHit.cs" />
<Compile Include="InstallCleanup.cs" />
<Compile Include="IWindowToggle.cs" />
<Compile Include="LegacyResourceGenerator.cs" />
<Compile Include="HeatSinkAnimator.cs" />
<Compile Include="IResourceGenerator.cs" />
Expand Down Expand Up @@ -93,6 +92,8 @@
<Compile Include="SettingsManager.cs" />
<Compile Include="TerrainData.cs" />
<Compile Include="TimedMovingAverage.cs" />
<Compile Include="WindowToggle.cs" />
<Compile Include="Toolbar\ToolbarWrapper.cs" />
<Compile Include="TutorialInstaller.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 4 additions & 8 deletions Plugin/Kethane.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kethane", "Kethane.csproj", "{8D1501AC-6C11-459B-9561-6CC5E3EC15FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KethaneToolbar", "..\KethaneToolbar\KethaneToolbar.csproj", "{0A4BDEC5-89C4-4470-A40E-177D2FEF8300}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,10 +15,6 @@ Global
{8D1501AC-6C11-459B-9561-6CC5E3EC15FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D1501AC-6C11-459B-9561-6CC5E3EC15FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D1501AC-6C11-459B-9561-6CC5E3EC15FE}.Release|Any CPU.Build.0 = Release|Any CPU
{0A4BDEC5-89C4-4470-A40E-177D2FEF8300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A4BDEC5-89C4-4470-A40E-177D2FEF8300}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A4BDEC5-89C4-4470-A40E-177D2FEF8300}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A4BDEC5-89C4-4470-A40E-177D2FEF8300}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
34 changes: 8 additions & 26 deletions Plugin/MapOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Kethane.GeodesicGrid;
using Kethane.Toolbar;
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -33,7 +34,7 @@ public class MapOverlay : MonoBehaviour
private static Rect controlWindowPos = new Rect(0, 0, 160, 0);
private static bool revealAll = false;
private static bool expandWindow = true;
private static IWindowToggle toolbar = findToolbar();
private static WindowToggle toolbar = findToolbar();

private static readonly Color32 colorEmpty = Misc.Parse(SettingsManager.GetValue("ColorEmpty"), new Color32(128, 128, 128, 192));
private static readonly Color32 colorUnknown = Misc.Parse(SettingsManager.GetValue("ColorUnknown"), new Color32(0, 0, 0, 128));
Expand Down Expand Up @@ -272,35 +273,16 @@ private static Color32 getDepositColor(ResourceDefinition definition, IBodyResou
return color;
}

private static IWindowToggle findToolbar()
private static WindowToggle findToolbar()
{
System.Reflection.ConstructorInfo constructor = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
if (ToolbarManager.ToolbarAvailable)
{
try
{
constructor = assembly.GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IWindowToggle)))
.Select(t => t.GetConstructor(System.Type.EmptyTypes))
.FirstOrDefault(c => c != null);

if (constructor != null) { break; }
}
catch (Exception e)
{
Debug.LogWarning("[Kethane] Error inspecting assembly '" + assembly.GetName().Name + "': \n" + e);
}
Debug.Log("[Kethane] Toolbar instance found. Using new interface.");
return new WindowToggle();
}

if (constructor == null) { return null; }

try
{
return (IWindowToggle)constructor.Invoke(new object[0]);
}
catch (Exception e)
else
{
Debug.LogError("[Kethane] Could not instantiate " + constructor.DeclaringType.Name + ":\n" + e);
Debug.LogWarning("[Kethane] Could not find Toolbar instance. Reverting to legacy interface.");
return null;
}
}
Expand Down

0 comments on commit 34d4a8c

Please sign in to comment.