mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Using my repo as if it's dropbox heh
This commit is contained in:
parent
f1714c1262
commit
2106b44f85
@ -508,19 +508,18 @@
|
||||
<Compile Include="Profiles\Lua\Brushes\LuaColor.cs" />
|
||||
<Compile Include="Profiles\Lua\Brushes\LuaLinearGradientBrush.cs" />
|
||||
<Compile Include="Profiles\Lua\Brushes\LuaRadialGradientBrush.cs" />
|
||||
<Compile Include="Profiles\Lua\Events\LuaKeyPressEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Events\LuaDeviceDrawingEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Events\LuaDeviceUpdatingEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\Events\LuaKeyPressEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceDrawingEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceUpdatingEventArgs.cs" />
|
||||
<Compile Include="Profiles\Lua\Brushes\LuaBrushWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\ILuaModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Events\LuaEventsWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\LuaKeyboardWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\LuaLayerWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\LuaProfileWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\Events\LuaEventsModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\LuaModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Brushes\LuaSolidColorBrush.cs" />
|
||||
<Compile Include="Profiles\Lua\LuaWrapper.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\LuaDrawModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\LuaKeyboardModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\LuaLayerModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Modules\LuaProfileModule.cs" />
|
||||
<Compile Include="Profiles\Lua\Wrappers\LuaDrawWrapper.cs" />
|
||||
<Compile Include="Profiles\ProfileModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Models\SimplePropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesModel.cs" />
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using MoonSharp.Interpreter;
|
||||
using MoonSharp.Interpreter.Interop;
|
||||
|
||||
namespace Artemis.Profiles.Lua
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class LuaKeyboardWrapper : IDisposable
|
||||
{
|
||||
private readonly KeyboardProvider _keyboardProvider;
|
||||
|
||||
public LuaKeyboardWrapper(KeyboardProvider keyboardProvider)
|
||||
{
|
||||
_keyboardProvider = keyboardProvider;
|
||||
|
||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
public string Name => _keyboardProvider.Name;
|
||||
public string Slug => _keyboardProvider.Slug;
|
||||
public int Width => _keyboardProvider.Width;
|
||||
public int Height => _keyboardProvider.Height;
|
||||
|
||||
[MoonSharpVisible(false)]
|
||||
public void Dispose()
|
||||
{
|
||||
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||
{
|
||||
var keyMatch = _keyboardProvider.GetKeyPosition(e.KeyCode);
|
||||
if (keyMatch != null)
|
||||
LuaWrapper.LuaEventsWrapper.InvokeKeyPressed(LuaWrapper.ProfileModel, this, keyMatch.Value.KeyCode,
|
||||
keyMatch.Value.X, keyMatch.Value.Y);
|
||||
}
|
||||
|
||||
public void PressKeys(string keys)
|
||||
{
|
||||
SendKeys.SendWait(keys);
|
||||
}
|
||||
|
||||
public void GetKeyPosition(Keys key)
|
||||
{
|
||||
_keyboardProvider.GetKeyPosition(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,28 +3,36 @@ using System.IO;
|
||||
using System.Text;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Lua.Brushes;
|
||||
using Artemis.Profiles.Lua.Events;
|
||||
using Artemis.Profiles.Lua.Modules.Events;
|
||||
using Artemis.Properties;
|
||||
using Castle.Core.Internal;
|
||||
using MoonSharp.Interpreter;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
|
||||
namespace Artemis.Profiles.Lua
|
||||
{
|
||||
public static class LuaWrapper
|
||||
/// <summary>
|
||||
/// This class is a singleton due to the fact that the LuaScript isn't very memory
|
||||
/// friendly when creating new ones over and over.
|
||||
/// </summary>
|
||||
public class LuaWrapper
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly Script LuaScript = new Script(CoreModules.Preset_SoftSandbox);
|
||||
private static FileSystemWatcher _watcher;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly Script _luaScript = new Script(CoreModules.Preset_SoftSandbox);
|
||||
private FileSystemWatcher _watcher;
|
||||
|
||||
public static ProfileModel ProfileModel { get; private set; }
|
||||
public static KeyboardProvider KeyboardProvider { get; private set; }
|
||||
public static LuaProfileWrapper LuaProfileWrapper { get; private set; }
|
||||
public static LuaBrushWrapper LuaBrushWrapper { get; private set; }
|
||||
public static LuaKeyboardWrapper LuaKeyboardWrapper { get; private set; }
|
||||
public static LuaMouseWrapper LuaMouseWrapper { get; set; }
|
||||
public static LuaEventsWrapper LuaEventsWrapper { get; private set; }
|
||||
public ProfileModel ProfileModel { get; private set; }
|
||||
public KeyboardProvider KeyboardProvider { get; private set; }
|
||||
public LayerModel LayerModel { get; set; }
|
||||
|
||||
public LuaWrapper(IKernel kernel)
|
||||
{
|
||||
_kernel = kernel;
|
||||
}
|
||||
|
||||
public static void SetupLua(ProfileModel profileModel, KeyboardProvider keyboardProvider)
|
||||
{
|
||||
@ -42,12 +50,12 @@ namespace Artemis.Profiles.Lua
|
||||
LuaMouseWrapper = new LuaMouseWrapper();
|
||||
LuaEventsWrapper = new LuaEventsWrapper();
|
||||
|
||||
LuaScript.Options.DebugPrint = LuaPrint;
|
||||
LuaScript.Globals["Profile"] = LuaProfileWrapper;
|
||||
LuaScript.Globals["Events"] = LuaEventsWrapper;
|
||||
LuaScript.Globals["Brushes"] = LuaBrushWrapper;
|
||||
LuaScript.Globals["Keyboard"] = LuaKeyboardWrapper;
|
||||
LuaScript.Globals["Mouse"] = LuaMouseWrapper;
|
||||
_luaScript.Options.DebugPrint = LuaPrint;
|
||||
_luaScript.Globals["Profile"] = LuaProfileWrapper;
|
||||
_luaScript.Globals["Events"] = LuaEventsWrapper;
|
||||
_luaScript.Globals["Brushes"] = LuaBrushWrapper;
|
||||
_luaScript.Globals["Keyboard"] = LuaKeyboardWrapper;
|
||||
_luaScript.Globals["Mouse"] = LuaMouseWrapper;
|
||||
|
||||
if (ProfileModel == null)
|
||||
return;
|
||||
@ -58,29 +66,29 @@ namespace Artemis.Profiles.Lua
|
||||
{
|
||||
lock (LuaEventsWrapper.InvokeLock)
|
||||
{
|
||||
lock (LuaScript)
|
||||
lock (_luaScript)
|
||||
{
|
||||
LuaScript.DoString(ProfileModel.LuaScript);
|
||||
_luaScript.DoString(ProfileModel.LuaScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InternalErrorException e)
|
||||
{
|
||||
Logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (SyntaxErrorException e)
|
||||
{
|
||||
Logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
Logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
lock (LuaScript)
|
||||
lock (_luaScript)
|
||||
{
|
||||
// Clear old fields/properties
|
||||
KeyboardProvider = null;
|
||||
@ -93,12 +101,12 @@ namespace Artemis.Profiles.Lua
|
||||
|
||||
try
|
||||
{
|
||||
LuaScript.Globals.Clear();
|
||||
LuaScript.Registry.Clear();
|
||||
LuaScript.Registry.RegisterConstants();
|
||||
LuaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
LuaScript.Globals.RegisterConstants();
|
||||
LuaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
_luaScript.Globals.Clear();
|
||||
_luaScript.Registry.Clear();
|
||||
_luaScript.Registry.RegisterConstants();
|
||||
_luaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
_luaScript.Globals.RegisterConstants();
|
||||
_luaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
@ -109,17 +117,17 @@ namespace Artemis.Profiles.Lua
|
||||
{
|
||||
lock (LuaEventsWrapper.InvokeLock)
|
||||
{
|
||||
lock (LuaScript)
|
||||
lock (_luaScript)
|
||||
{
|
||||
LuaScript.DoString("");
|
||||
_luaScript.DoString("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (LuaScript)
|
||||
lock (_luaScript)
|
||||
{
|
||||
LuaScript.DoString("");
|
||||
_luaScript.DoString("");
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +140,7 @@ namespace Artemis.Profiles.Lua
|
||||
|
||||
private static void LuaPrint(string s)
|
||||
{
|
||||
Logger.Debug("[{0}-LUA]: {1}", ProfileModel?.Name, s);
|
||||
_logger.Debug("[{0}-LUA]: {1}", ProfileModel?.Name, s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Lua.Modules;
|
||||
using Artemis.Profiles.Lua.Wrappers;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Events
|
||||
namespace Artemis.Profiles.Lua.Modules.Events
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class LuaDeviceDrawingEventArgs : EventArgs
|
||||
{
|
||||
public LuaDeviceDrawingEventArgs(string deviceType, IDataModel dataModel, bool preview, LuaDrawModule luaDrawWrapper)
|
||||
public LuaDeviceDrawingEventArgs(string deviceType, IDataModel dataModel, bool preview, LuaDrawWrapper luaDrawWrapper)
|
||||
{
|
||||
DeviceType = deviceType;
|
||||
DataModel = dataModel;
|
||||
@ -19,6 +19,6 @@ namespace Artemis.Profiles.Lua.Events
|
||||
public string DeviceType { get; set; }
|
||||
public IDataModel DataModel { get; }
|
||||
public bool Preview { get; }
|
||||
public LuaDrawModule Drawing { get; set; }
|
||||
public LuaDrawWrapper Drawing { get; set; }
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using Artemis.Models.Interfaces;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Events
|
||||
namespace Artemis.Profiles.Lua.Modules.Events
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class LuaDeviceUpdatingEventArgs : EventArgs
|
||||
@ -2,17 +2,22 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Lua.Modules;
|
||||
using Artemis.Profiles.Lua.Wrappers;
|
||||
using MoonSharp.Interpreter;
|
||||
using NLog;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Events
|
||||
namespace Artemis.Profiles.Lua.Modules.Events
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class LuaEventsWrapper
|
||||
public class LuaEventsModule : LuaModule
|
||||
{
|
||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
public readonly string InvokeLock = string.Empty;
|
||||
|
||||
public LuaEventsModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ModuleName => "Events";
|
||||
public event EventHandler<LuaDeviceUpdatingEventArgs> DeviceUpdating;
|
||||
public event EventHandler<LuaDeviceDrawingEventArgs> DeviceDrawing;
|
||||
public event EventHandler<LuaKeyPressEventArgs> KeyboardKeyPressed;
|
||||
@ -37,7 +42,7 @@ namespace Artemis.Profiles.Lua.Events
|
||||
try
|
||||
{
|
||||
LuaInvoke(profileModel, () => OnDeviceDrawing(new LuaProfileWrapper(profileModel),
|
||||
new LuaDeviceDrawingEventArgs(deviceType, dataModel, preview, new LuaDrawModule(c))));
|
||||
new LuaDeviceDrawingEventArgs(deviceType, dataModel, preview, new LuaDrawWrapper(c))));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -45,7 +50,7 @@ namespace Artemis.Profiles.Lua.Events
|
||||
}
|
||||
}
|
||||
|
||||
internal void InvokeKeyPressed(ProfileModel profileModel, LuaKeyboardWrapper keyboard, Keys key, int x, int y)
|
||||
internal void InvokeKeyPressed(ProfileModel profileModel, LuaKeyboardModule keyboard, Keys key, int x, int y)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -91,10 +96,18 @@ namespace Artemis.Profiles.Lua.Events
|
||||
DeviceDrawing?.Invoke(profileModel, e);
|
||||
}
|
||||
|
||||
protected virtual void OnKeyboardKeyPressed(LuaProfileWrapper profileModel, LuaKeyboardWrapper keyboard,
|
||||
protected virtual void OnKeyboardKeyPressed(LuaProfileWrapper profileModel, LuaKeyboardModule keyboard,
|
||||
LuaKeyPressEventArgs e)
|
||||
{
|
||||
KeyboardKeyPressed?.Invoke(profileModel, e);
|
||||
}
|
||||
|
||||
#region Overriding members
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
using System.Windows.Forms;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Events
|
||||
namespace Artemis.Profiles.Lua.Modules.Events
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class LuaKeyPressEventArgs : EventArgs
|
||||
@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
{
|
||||
public interface ILuaModule : IDisposable
|
||||
{
|
||||
bool AlwaysPresent { get; }
|
||||
string ModuleName { get; }
|
||||
}
|
||||
}
|
||||
@ -1,45 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders;
|
||||
using MoonSharp.Interpreter.Interop;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
{
|
||||
public class LuaKeyboardModule : ILuaModule
|
||||
[MoonSharpUserData]
|
||||
public class LuaKeyboardModule : LuaModule
|
||||
{
|
||||
public bool AlwaysPresent => true;
|
||||
public string ModuleName => "Keyboard";
|
||||
|
||||
private readonly KeyboardProvider _keyboardProvider;
|
||||
|
||||
public LuaKeyboardModule(KeyboardProvider keyboardProvider)
|
||||
public LuaKeyboardModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
||||
{
|
||||
_keyboardProvider = keyboardProvider;
|
||||
|
||||
_keyboardProvider = luaWrapper.KeyboardProvider;
|
||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
// TODO: Visible in LUA? Decladed as invisile in base class
|
||||
public override string ModuleName => "Keyboard";
|
||||
|
||||
public string Name => _keyboardProvider.Name;
|
||||
public string Slug => _keyboardProvider.Slug;
|
||||
public int Width => _keyboardProvider.Width;
|
||||
public int Height => _keyboardProvider.Height;
|
||||
|
||||
[MoonSharpVisible(false)]
|
||||
public void Dispose()
|
||||
#region Overriding members
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||
{
|
||||
var keyMatch = _keyboardProvider.GetKeyPosition(e.KeyCode);
|
||||
if (keyMatch != null)
|
||||
LuaWrapper.LuaEventsWrapper.InvokeKeyPressed(LuaWrapper.ProfileModel, this, keyMatch.Value.KeyCode,
|
||||
keyMatch.Value.X, keyMatch.Value.Y);
|
||||
// TODO
|
||||
//var keyMatch = _keyboardProvider.GetKeyPosition(e.KeyCode);
|
||||
//if (keyMatch != null)
|
||||
// LuaWrapper.LuaEventsWrapper.InvokeKeyPressed(LuaWrapper.ProfileModel, this, keyMatch.Value.KeyCode,
|
||||
// keyMatch.Value.X, keyMatch.Value.Y);
|
||||
}
|
||||
|
||||
public void PressKeys(string keys)
|
||||
@ -52,4 +52,4 @@ namespace Artemis.Profiles.Lua.Modules
|
||||
_keyboardProvider.GetKeyPosition(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,25 +6,32 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Lua.Brushes;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// Serves as a sandboxed wrapper around the LayerModel
|
||||
/// </summary>
|
||||
[MoonSharpUserData]
|
||||
public class LuaLayerWrapper
|
||||
public class LuaLayerModule : LuaModule
|
||||
{
|
||||
private readonly LayerModel _layerModel;
|
||||
|
||||
public LuaLayerWrapper(LayerModel layerModel)
|
||||
public LuaLayerModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
||||
{
|
||||
_layerModel = layerModel;
|
||||
SavedProperties = new LuaLayerProperties(layerModel);
|
||||
_layerModel = luaWrapper.LayerModel;
|
||||
SavedProperties = new Lua.LuaLayerProperties(_layerModel);
|
||||
|
||||
// Triger an update to fill up the Properties
|
||||
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
||||
}
|
||||
|
||||
public override string ModuleName => "Layer";
|
||||
|
||||
#region Overriding members
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Child methods
|
||||
|
||||
public List<LuaLayerWrapper> GetChildren()
|
||||
@ -106,7 +113,7 @@ namespace Artemis.Profiles.Lua
|
||||
|
||||
#region Advanced layer properties
|
||||
|
||||
public LuaLayerProperties SavedProperties { get; set; }
|
||||
public Lua.LuaLayerProperties SavedProperties { get; set; }
|
||||
|
||||
public string BrushType => _layerModel.Properties.Brush?.GetType().Name;
|
||||
|
||||
30
Artemis/Artemis/Profiles/Lua/Modules/LuaModule.cs
Normal file
30
Artemis/Artemis/Profiles/Lua/Modules/LuaModule.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using MoonSharp.Interpreter;
|
||||
using MoonSharp.Interpreter.Interop;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a module which will be accessable in all LUA scripts.
|
||||
/// </summary>
|
||||
[MoonSharpUserData]
|
||||
public abstract class LuaModule : IDisposable
|
||||
{
|
||||
public LuaModule(LuaWrapper luaWrapper)
|
||||
{
|
||||
LuaWrapper = luaWrapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name under which this module will be accessable in LUA
|
||||
/// </summary>
|
||||
[MoonSharpVisible(false)]
|
||||
public abstract string ModuleName { get; }
|
||||
|
||||
[MoonSharpVisible(false)]
|
||||
public LuaWrapper LuaWrapper { get; set; }
|
||||
|
||||
[MoonSharpVisible(false)]
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
@ -1,28 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// Serves as a sandboxed wrapper around the ProfileModel
|
||||
/// </summary>
|
||||
[MoonSharpUserData]
|
||||
public class LuaProfileWrapper
|
||||
public class LuaProfileModule : LuaModule
|
||||
{
|
||||
private readonly ProfileModel _profileModel;
|
||||
|
||||
public LuaProfileWrapper(ProfileModel profileModel)
|
||||
public LuaProfileModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
||||
{
|
||||
_profileModel = profileModel;
|
||||
_profileModel = luaWrapper.ProfileModel;
|
||||
}
|
||||
|
||||
public override string ModuleName => "Profile";
|
||||
|
||||
#region General profile properties
|
||||
|
||||
public string Name => _profileModel.Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overriding members
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Layer methods
|
||||
|
||||
public List<LuaLayerWrapper> GetLayers()
|
||||
@ -5,27 +5,23 @@ using System.Windows.Media;
|
||||
using Artemis.Profiles.Lua.Brushes;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Profiles.Lua.Modules
|
||||
namespace Artemis.Profiles.Lua.Wrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper that is provided to each OnDraw event to allow drawing in LUA
|
||||
/// </summary>
|
||||
[MoonSharpUserData]
|
||||
public class LuaDrawModule : ILuaModule
|
||||
public class LuaDrawWrapper
|
||||
{
|
||||
private readonly DrawingContext _ctx;
|
||||
private readonly FontFamily _font;
|
||||
|
||||
public LuaDrawModule(DrawingContext ctx)
|
||||
public LuaDrawWrapper(DrawingContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_font = new FontFamily(new Uri("pack://application:,,,/"), "./resources/#Silkscreen");
|
||||
}
|
||||
|
||||
public bool AlwaysPresent => false;
|
||||
public string ModuleName => null;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public void DrawEllipse(LuaBrush luaBrush, double x, double y, double height, double width)
|
||||
{
|
||||
x *= 4;
|
||||
@ -33,7 +29,7 @@ namespace Artemis.Profiles.Lua.Modules
|
||||
height *= 4;
|
||||
width *= 4;
|
||||
|
||||
var center = new Point(x + width/2, y + height/2);
|
||||
var center = new Point(x + width / 2, y + height / 2);
|
||||
_ctx.DrawEllipse(luaBrush.Brush, new Pen(), center, width, height);
|
||||
}
|
||||
|
||||
@ -70,7 +66,7 @@ namespace Artemis.Profiles.Lua.Modules
|
||||
fontSize, luaBrush.Brush);
|
||||
|
||||
_ctx.DrawText(formatted, new Point(x, y));
|
||||
return formatted.Width/4;
|
||||
return formatted.Width / 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user