Nothing to see here, move along

This commit is contained in:
Brant Martin
2019-09-07 12:10:08 -04:00
parent ff0d881273
commit aec03840cc
5 changed files with 72 additions and 1 deletions

View File

@@ -34,5 +34,22 @@ namespace Torch.API.Plugins
/// This is called on the game thread after each tick.
/// </summary>
void Update();
/// <summary>
/// Plugin's enabled state. Mainly for UI niceness
/// </summary>
PluginState State { get; }
}
public enum PluginState
{
NotInitialized,
DisabledError,
DisabledUser,
UpdateRequired,
UninstallRequested,
NotInstalled,
MissingDependency,
Enabled
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -51,5 +52,55 @@ namespace Torch.Server.ViewModels
this.Control.Resources.MergedDictionaries.Clear();
this.Control.Resources.MergedDictionaries.Add(dictionary);
}
public Brush Color
{
get {
switch (Plugin.State)
{
case PluginState.NotInitialized:
case PluginState.MissingDependency:
case PluginState.DisabledError:
return Brushes.Red;
case PluginState.UpdateRequired:
return Brushes.DodgerBlue;
case PluginState.UninstallRequested:
return Brushes.Gold;
case PluginState.NotInstalled:
case PluginState.DisabledUser:
return Brushes.Gray;
case PluginState.Enabled:
return Brushes.Transparent;
default:
throw new ArgumentOutOfRangeException();
}
}
}
public string ToolTip
{
get { switch (Plugin.State)
{
case PluginState.NotInitialized:
return "Error during load.";
case PluginState.DisabledError:
return "Disabled due to error on load.";
case PluginState.DisabledUser:
return "Disabled.";
case PluginState.UpdateRequired:
return "Update required.";
case PluginState.UninstallRequested:
return "Marked for uninstall.";
case PluginState.NotInstalled:
return "Not installed. Click 'Enable'";
case PluginState.Enabled:
return string.Empty;
case PluginState.MissingDependency:
return "Dependency missing. Check the log.";
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
}

View File

@@ -22,7 +22,7 @@
<ListView Grid.Row="0" ItemsSource="{Binding Plugins}" SelectedItem="{Binding SelectedPlugin}" Margin="3">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Name}" Background="{Binding Color}" ToolTip="{Binding ToolTip}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using NLog;
namespace Torch.Managers.PatchManager
{
@@ -10,6 +11,7 @@ namespace Torch.Managers.PatchManager
public sealed class PatchContext
{
private readonly Dictionary<MethodBase, MethodRewritePattern> _rewritePatterns = new Dictionary<MethodBase, MethodRewritePattern>();
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
internal PatchContext()
{

View File

@@ -28,6 +28,7 @@ namespace Torch
}
public virtual void Update() { }
public PluginState State { get; }
public virtual void Dispose() { }
}