mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 10:13:30 +00:00
MIssing file
LUA refactor LUA is made up out of modules now Added DI to LUA Added GetKeyPosition to keyboard module Cleaned up event arguments (see wiki) Made all internal classes public since Artemis isn't a library anyway Added DI convention based bindings
This commit is contained in:
parent
52d30353de
commit
ef69c39cf5
@ -336,11 +336,9 @@
|
|||||||
<Compile Include="Events\EffectChangedEventArgs.cs" />
|
<Compile Include="Events\EffectChangedEventArgs.cs" />
|
||||||
<Compile Include="Events\EnabledChangedEventArgs.cs" />
|
<Compile Include="Events\EnabledChangedEventArgs.cs" />
|
||||||
<Compile Include="Events\KeyboardChangedEventArgs.cs" />
|
<Compile Include="Events\KeyboardChangedEventArgs.cs" />
|
||||||
|
<Compile Include="Events\ProfileDeviceEventsArg.cs" />
|
||||||
<Compile Include="Events\RazerColorArrayChanged.cs" />
|
<Compile Include="Events\RazerColorArrayChanged.cs" />
|
||||||
<Compile Include="Events\RazerColorsChangedEventArgs.cs" />
|
<Compile Include="Events\RazerColorsChangedEventArgs.cs" />
|
||||||
<Compile Include="InjectionModules\DeviceModules.cs" />
|
|
||||||
<Compile Include="InjectionModules\EffectModules.cs" />
|
|
||||||
<Compile Include="InjectionModules\ProfileModules.cs" />
|
|
||||||
<Compile Include="ItemBehaviours\BindableSelectedItemBehavior.cs" />
|
<Compile Include="ItemBehaviours\BindableSelectedItemBehavior.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairKeyboard.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairKeyboard.cs" />
|
||||||
<Compile Include="DeviceProviders\KeyboardProvider.cs" />
|
<Compile Include="DeviceProviders\KeyboardProvider.cs" />
|
||||||
@ -354,6 +352,7 @@
|
|||||||
<Compile Include="Managers\EffectManager.cs" />
|
<Compile Include="Managers\EffectManager.cs" />
|
||||||
<Compile Include="Managers\DeviceManager.cs" />
|
<Compile Include="Managers\DeviceManager.cs" />
|
||||||
<Compile Include="Managers\LoopManager.cs" />
|
<Compile Include="Managers\LoopManager.cs" />
|
||||||
|
<Compile Include="Managers\LuaManager.cs" />
|
||||||
<Compile Include="Managers\MainManager.cs" />
|
<Compile Include="Managers\MainManager.cs" />
|
||||||
<Compile Include="Managers\ProfileManager.cs" />
|
<Compile Include="Managers\ProfileManager.cs" />
|
||||||
<Compile Include="Models\EffectModel.cs" />
|
<Compile Include="Models\EffectModel.cs" />
|
||||||
@ -504,23 +503,23 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Profiles\Layers\Types\Mousemat\MousematPropertiesViewModel.cs" />
|
<Compile Include="Profiles\Layers\Types\Mousemat\MousematPropertiesViewModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\Mousemat\MousematType.cs" />
|
<Compile Include="Profiles\Layers\Types\Mousemat\MousematType.cs" />
|
||||||
<Compile Include="Profiles\LuaMouseWrapper.cs" />
|
<Compile Include="Profiles\Lua\Modules\Brushes\LuaBrush.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaBrush.cs" />
|
<Compile Include="Profiles\Lua\Modules\Brushes\LuaColor.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaColor.cs" />
|
<Compile Include="Profiles\Lua\Modules\Brushes\LuaLinearGradientBrush.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaLinearGradientBrush.cs" />
|
<Compile Include="Profiles\Lua\Modules\Brushes\LuaRadialGradientBrush.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaRadialGradientBrush.cs" />
|
|
||||||
<Compile Include="Profiles\Lua\Modules\Events\LuaKeyPressEventArgs.cs" />
|
<Compile Include="Profiles\Lua\Modules\Events\LuaKeyPressEventArgs.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceDrawingEventArgs.cs" />
|
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceDrawingEventArgs.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceUpdatingEventArgs.cs" />
|
<Compile Include="Profiles\Lua\Modules\Events\LuaDeviceUpdatingEventArgs.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaBrushWrapper.cs" />
|
<Compile Include="Profiles\Lua\Modules\LuaEventsModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\Events\LuaEventsModule.cs" />
|
<Compile Include="Profiles\Lua\Modules\LuaBrushesModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\LuaModule.cs" />
|
<Compile Include="Profiles\Lua\LuaModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Brushes\LuaSolidColorBrush.cs" />
|
<Compile Include="Profiles\Lua\Modules\Brushes\LuaSolidColorBrush.cs" />
|
||||||
<Compile Include="Profiles\Lua\LuaWrapper.cs" />
|
|
||||||
<Compile Include="Profiles\Lua\Modules\LuaKeyboardModule.cs" />
|
<Compile Include="Profiles\Lua\Modules\LuaKeyboardModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\LuaLayerModule.cs" />
|
<Compile Include="Profiles\Lua\Modules\LuaLayerModule.cs" />
|
||||||
|
<Compile Include="Profiles\Lua\Modules\LuaMouseModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Modules\LuaProfileModule.cs" />
|
<Compile Include="Profiles\Lua\Modules\LuaProfileModule.cs" />
|
||||||
<Compile Include="Profiles\Lua\Wrappers\LuaDrawWrapper.cs" />
|
<Compile Include="Profiles\Lua\Wrappers\LuaDrawWrapper.cs" />
|
||||||
|
<Compile Include="Profiles\Lua\Wrappers\LuaLayerWrapper.cs" />
|
||||||
<Compile Include="Profiles\ProfileModel.cs" />
|
<Compile Include="Profiles\ProfileModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Models\SimplePropertiesModel.cs" />
|
<Compile Include="Profiles\Layers\Models\SimplePropertiesModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesModel.cs" />
|
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesModel.cs" />
|
||||||
|
|||||||
@ -77,8 +77,7 @@ namespace Artemis
|
|||||||
|
|
||||||
protected override void Configure()
|
protected override void Configure()
|
||||||
{
|
{
|
||||||
_kernel = new StandardKernel(new BaseModules(), new ManagerModules(), new DeviceModules(),
|
_kernel = new StandardKernel(new BaseModules(), new ManagerModules());
|
||||||
new EffectModules(), new ProfileModules());
|
|
||||||
|
|
||||||
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
|
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
|
||||||
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Ninject.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairHeadset : DeviceProvider
|
public class CorsairHeadset : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairHeadset(ILogger logger)
|
public CorsairHeadset(ILogger logger)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Ninject.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairMouse : DeviceProvider
|
public class CorsairMouse : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairMouse(ILogger logger)
|
public CorsairMouse(ILogger logger)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Ninject.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairMousemat : DeviceProvider
|
public class CorsairMousemat : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairMousemat(ILogger logger)
|
public CorsairMousemat(ILogger logger)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Artemis.Settings;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Logitech
|
namespace Artemis.DeviceProviders.Logitech
|
||||||
{
|
{
|
||||||
internal class G810 : LogitechKeyboard
|
public class G810 : LogitechKeyboard
|
||||||
{
|
{
|
||||||
private GeneralSettings _generalSettings;
|
private GeneralSettings _generalSettings;
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using Artemis.Settings;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Logitech
|
namespace Artemis.DeviceProviders.Logitech
|
||||||
{
|
{
|
||||||
internal class G910 : LogitechKeyboard
|
public class G910 : LogitechKeyboard
|
||||||
{
|
{
|
||||||
private readonly GeneralSettings _generalSettings;
|
private readonly GeneralSettings _generalSettings;
|
||||||
|
|
||||||
|
|||||||
22
Artemis/Artemis/Events/ProfileDeviceEventsArg.cs
Normal file
22
Artemis/Artemis/Events/ProfileDeviceEventsArg.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Artemis.Models.Interfaces;
|
||||||
|
|
||||||
|
namespace Artemis.Events
|
||||||
|
{
|
||||||
|
public class ProfileDeviceEventsArg : EventArgs
|
||||||
|
{
|
||||||
|
public ProfileDeviceEventsArg(string updateType, IDataModel dataModel, bool preview, DrawingContext drawingContext)
|
||||||
|
{
|
||||||
|
UpdateType = updateType;
|
||||||
|
DataModel = dataModel;
|
||||||
|
Preview = preview;
|
||||||
|
DrawingContext = drawingContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UpdateType { get; }
|
||||||
|
public IDataModel DataModel { get; }
|
||||||
|
public bool Preview { get; }
|
||||||
|
public DrawingContext DrawingContext { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,39 +1,135 @@
|
|||||||
using Artemis.Modules.Effects.ProfilePreview;
|
using Artemis.DeviceProviders;
|
||||||
using Artemis.Services;
|
using Artemis.Models;
|
||||||
using Artemis.Utilities.DataReaders;
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
using Artemis.Utilities.GameState;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.ViewModels;
|
using Artemis.Profiles.Layers.Types.AmbientLight;
|
||||||
using Artemis.ViewModels.Abstract;
|
using Artemis.Profiles.Layers.Types.Audio;
|
||||||
using Artemis.ViewModels.Profiles;
|
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||||
using Ninject.Modules;
|
using Artemis.Profiles.Layers.Types.KeyPress;
|
||||||
|
using Artemis.Profiles.Lua;
|
||||||
namespace Artemis.InjectionModules
|
using Artemis.Services;
|
||||||
{
|
using Artemis.Utilities.DataReaders;
|
||||||
internal class BaseModules : NinjectModule
|
using Artemis.Utilities.GameState;
|
||||||
{
|
using Artemis.ViewModels;
|
||||||
public override void Load()
|
using Artemis.ViewModels.Abstract;
|
||||||
{
|
using Artemis.ViewModels.Profiles;
|
||||||
// ViewModels
|
using Ninject.Extensions.Conventions;
|
||||||
Bind<ShellViewModel>().ToSelf().InSingletonScope();
|
using Ninject.Modules;
|
||||||
Bind<ProfileViewModel>().ToSelf();
|
|
||||||
Bind<ProfileEditorViewModel>().ToSelf();
|
namespace Artemis.InjectionModules
|
||||||
Bind<DebugViewModel>().ToSelf().InSingletonScope();
|
{
|
||||||
|
public class BaseModules : NinjectModule
|
||||||
Bind<BaseViewModel>().To<WelcomeViewModel>();
|
{
|
||||||
Bind<BaseViewModel>().To<EffectsViewModel>();
|
public override void Load()
|
||||||
Bind<BaseViewModel>().To<GamesViewModel>();
|
{
|
||||||
Bind<BaseViewModel>().To<OverlaysViewModel>();
|
#region ViewModels
|
||||||
|
|
||||||
// Models
|
Bind<ShellViewModel>().ToSelf().InSingletonScope();
|
||||||
Bind<ProfilePreviewModel>().ToSelf().InSingletonScope();
|
Bind<ProfileViewModel>().ToSelf();
|
||||||
|
Bind<ProfileEditorViewModel>().ToSelf();
|
||||||
// Services
|
Bind<DebugViewModel>().ToSelf().InSingletonScope();
|
||||||
Bind<MetroDialogService>().ToSelf().InSingletonScope();
|
Kernel.Bind(x =>
|
||||||
Bind<WindowService>().ToSelf().InSingletonScope();
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
// Servers
|
.InheritedFrom<BaseViewModel>()
|
||||||
Bind<GameStateWebServer>().ToSelf().InSingletonScope();
|
.BindAllBaseClasses());
|
||||||
Bind<PipeServer>().ToSelf().InSingletonScope();
|
|
||||||
}
|
#endregion
|
||||||
}
|
|
||||||
|
#region Models
|
||||||
|
|
||||||
|
Bind<ProfilePreviewModel>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Services
|
||||||
|
|
||||||
|
Bind<MetroDialogService>().ToSelf().InSingletonScope();
|
||||||
|
Bind<WindowService>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Servers
|
||||||
|
|
||||||
|
Bind<GameStateWebServer>().ToSelf().InSingletonScope();
|
||||||
|
Bind<PipeServer>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Devices
|
||||||
|
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<DeviceProvider>()
|
||||||
|
.BindAllBaseClasses());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Effects
|
||||||
|
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<EffectModel>()
|
||||||
|
.BindAllBaseClasses()
|
||||||
|
.Configure((b, c) => b.InSingletonScope().Named(c.Name))
|
||||||
|
);
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<EffectViewModel>()
|
||||||
|
.BindBase());
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<GameViewModel>()
|
||||||
|
.BindBase());
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<OverlayViewModel>()
|
||||||
|
.BindBase());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Profiles
|
||||||
|
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<ILayerAnimation>()
|
||||||
|
.BindAllInterfaces());
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<ILayerCondition>()
|
||||||
|
.BindAllInterfaces());
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<ILayerType>()
|
||||||
|
.BindAllInterfaces());
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<ILayerType>()
|
||||||
|
.BindToSelf());
|
||||||
|
|
||||||
|
// Type helpers
|
||||||
|
Bind<AudioCaptureManager>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Lua
|
||||||
|
|
||||||
|
Kernel.Bind(x =>
|
||||||
|
x.FromThisAssembly()
|
||||||
|
.SelectAllClasses()
|
||||||
|
.InheritedFrom<LuaModule>()
|
||||||
|
.BindAllBaseClasses());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,37 +0,0 @@
|
|||||||
using Artemis.DeviceProviders;
|
|
||||||
using Artemis.DeviceProviders.Artemis;
|
|
||||||
using Artemis.DeviceProviders.CoolerMaster;
|
|
||||||
using Artemis.DeviceProviders.Corsair;
|
|
||||||
using Artemis.DeviceProviders.Logitech;
|
|
||||||
using Artemis.DeviceProviders.Razer;
|
|
||||||
using Ninject.Modules;
|
|
||||||
|
|
||||||
namespace Artemis.InjectionModules
|
|
||||||
{
|
|
||||||
public class DeviceModules : NinjectModule
|
|
||||||
{
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
// Keyboards
|
|
||||||
Bind<DeviceProvider>().To<NoneKeyboard>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<CorsairKeyboard>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<G910>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<G810>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<BlackWidow>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<MasterkeysProL>().InSingletonScope();
|
|
||||||
Bind<DeviceProvider>().To<MasterkeysProS>().InSingletonScope();
|
|
||||||
|
|
||||||
// Mice
|
|
||||||
Bind<DeviceProvider>().To<CorsairMouse>().InSingletonScope();
|
|
||||||
|
|
||||||
// Headsets
|
|
||||||
Bind<DeviceProvider>().To<CorsairHeadset>().InSingletonScope();
|
|
||||||
|
|
||||||
// Mousemats
|
|
||||||
Bind<DeviceProvider>().To<CorsairMousemat>().InSingletonScope();
|
|
||||||
|
|
||||||
// Other
|
|
||||||
Bind<DeviceProvider>().To<LogitechGeneric>().InSingletonScope();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
using Artemis.Models;
|
|
||||||
using Artemis.ViewModels.Abstract;
|
|
||||||
using Ninject.Extensions.Conventions;
|
|
||||||
using Ninject.Modules;
|
|
||||||
|
|
||||||
namespace Artemis.InjectionModules
|
|
||||||
{
|
|
||||||
public class EffectModules : NinjectModule
|
|
||||||
{
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
// Effects
|
|
||||||
Kernel.Bind(x =>
|
|
||||||
{
|
|
||||||
x.FromThisAssembly()
|
|
||||||
.SelectAllClasses()
|
|
||||||
.InheritedFrom<EffectModel>()
|
|
||||||
.BindBase()
|
|
||||||
.Configure((b, c) => b.InSingletonScope().Named(c.Name));
|
|
||||||
});
|
|
||||||
|
|
||||||
// View models
|
|
||||||
Kernel.Bind(x =>
|
|
||||||
{
|
|
||||||
x.FromThisAssembly()
|
|
||||||
.SelectAllClasses()
|
|
||||||
.InheritedFrom<EffectViewModel>()
|
|
||||||
.BindBase();
|
|
||||||
});
|
|
||||||
|
|
||||||
Kernel.Bind(x =>
|
|
||||||
{
|
|
||||||
x.FromThisAssembly()
|
|
||||||
.SelectAllClasses()
|
|
||||||
.InheritedFrom<GameViewModel>()
|
|
||||||
.BindBase();
|
|
||||||
});
|
|
||||||
Kernel.Bind(x =>
|
|
||||||
{
|
|
||||||
x.FromThisAssembly()
|
|
||||||
.SelectAllClasses()
|
|
||||||
.InheritedFrom<OverlayViewModel>()
|
|
||||||
.BindBase();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ using Ninject.Modules;
|
|||||||
|
|
||||||
namespace Artemis.InjectionModules
|
namespace Artemis.InjectionModules
|
||||||
{
|
{
|
||||||
internal class ManagerModules : NinjectModule
|
public class ManagerModules : NinjectModule
|
||||||
{
|
{
|
||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
@ -12,6 +12,7 @@ namespace Artemis.InjectionModules
|
|||||||
Bind<DeviceManager>().ToSelf().InSingletonScope();
|
Bind<DeviceManager>().ToSelf().InSingletonScope();
|
||||||
Bind<EffectManager>().ToSelf().InSingletonScope();
|
Bind<EffectManager>().ToSelf().InSingletonScope();
|
||||||
Bind<ProfileManager>().ToSelf().InSingletonScope();
|
Bind<ProfileManager>().ToSelf().InSingletonScope();
|
||||||
|
Bind<LuaManager>().ToSelf().InSingletonScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,57 +0,0 @@
|
|||||||
using Artemis.Profiles.Layers.Animations;
|
|
||||||
using Artemis.Profiles.Layers.Conditions;
|
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
|
||||||
using Artemis.Profiles.Layers.Types.AmbientLight;
|
|
||||||
using Artemis.Profiles.Layers.Types.Audio;
|
|
||||||
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
|
||||||
using Artemis.Profiles.Layers.Types.Folder;
|
|
||||||
using Artemis.Profiles.Layers.Types.Generic;
|
|
||||||
using Artemis.Profiles.Layers.Types.Headset;
|
|
||||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
|
||||||
using Artemis.Profiles.Layers.Types.KeyboardGif;
|
|
||||||
using Artemis.Profiles.Layers.Types.KeyPress;
|
|
||||||
using Artemis.Profiles.Layers.Types.Mouse;
|
|
||||||
using Artemis.Profiles.Layers.Types.Mousemat;
|
|
||||||
using Ninject.Modules;
|
|
||||||
|
|
||||||
namespace Artemis.InjectionModules
|
|
||||||
{
|
|
||||||
public class ProfileModules : NinjectModule
|
|
||||||
{
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
// Animations
|
|
||||||
Bind<ILayerAnimation>().To<NoneAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<GrowAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<PulseAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<SlideDownAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<SlideLeftAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<SlideRightAnimation>();
|
|
||||||
Bind<ILayerAnimation>().To<SlideUpAnimation>();
|
|
||||||
|
|
||||||
// Conditions
|
|
||||||
Bind<ILayerCondition>().To<DataModelCondition>();
|
|
||||||
Bind<ILayerCondition>().To<EventCondition>();
|
|
||||||
|
|
||||||
// Types
|
|
||||||
Bind<ILayerType>().To<FolderType>();
|
|
||||||
Bind<ILayerType>().To<HeadsetType>();
|
|
||||||
Bind<ILayerType>().To<KeyboardType>();
|
|
||||||
Bind<ILayerType>().To<KeyboardGifType>();
|
|
||||||
Bind<ILayerType>().To<MouseType>();
|
|
||||||
Bind<ILayerType>().To<MousematType>();
|
|
||||||
Bind<ILayerType>().To<GenericType>();
|
|
||||||
Bind<ILayerType>().To<KeyPressType>();
|
|
||||||
Bind<ILayerType>().To<AudioType>();
|
|
||||||
Bind<ILayerType>().To<AmbientLightType>();
|
|
||||||
|
|
||||||
// Bind some Layer Types to self as well in order to allow JSON.NET injection
|
|
||||||
Bind<KeyPressType>().ToSelf();
|
|
||||||
Bind<AudioType>().ToSelf();
|
|
||||||
Bind<AmbientLightType>().ToSelf();
|
|
||||||
|
|
||||||
// Type helpers
|
|
||||||
Bind<AudioCaptureManager>().ToSelf().InSingletonScope();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,212 +1,208 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.IO;
|
||||||
using Artemis.DAL;
|
using System.Linq;
|
||||||
using Artemis.DeviceProviders;
|
using System.Text;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.DAL;
|
||||||
using Artemis.Profiles.Lua.Brushes;
|
using Artemis.DeviceProviders;
|
||||||
using Artemis.Profiles.Lua.Modules.Events;
|
using Artemis.Profiles;
|
||||||
using Artemis.Properties;
|
using Artemis.Profiles.Lua;
|
||||||
using Castle.Core.Internal;
|
using Artemis.Profiles.Lua.Modules;
|
||||||
using MoonSharp.Interpreter;
|
using Artemis.Properties;
|
||||||
using Ninject;
|
using Castle.Core.Internal;
|
||||||
using NLog;
|
using MoonSharp.Interpreter;
|
||||||
|
using Ninject;
|
||||||
namespace Artemis.Profiles.Lua
|
using Ninject.Extensions.Logging;
|
||||||
{
|
|
||||||
/// <summary>
|
namespace Artemis.Managers
|
||||||
/// This class is a singleton due to the fact that the LuaScript isn't very memory
|
{
|
||||||
/// friendly when creating new ones over and over.
|
public class LuaManager
|
||||||
/// </summary>
|
{
|
||||||
public class LuaWrapper
|
private readonly DeviceManager _deviceManager;
|
||||||
{
|
private readonly IKernel _kernel;
|
||||||
private readonly IKernel _kernel;
|
private readonly ILogger _logger;
|
||||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private List<LuaModule> _luaModules;
|
||||||
private readonly Script _luaScript = new Script(CoreModules.Preset_SoftSandbox);
|
private readonly Script _luaScript;
|
||||||
private FileSystemWatcher _watcher;
|
private FileSystemWatcher _watcher;
|
||||||
|
|
||||||
public ProfileModel ProfileModel { get; private set; }
|
public LuaManager(IKernel kernel, ILogger logger, DeviceManager deviceManager)
|
||||||
public KeyboardProvider KeyboardProvider { get; private set; }
|
{
|
||||||
public LayerModel LayerModel { get; set; }
|
_kernel = kernel;
|
||||||
|
_logger = logger;
|
||||||
public LuaWrapper(IKernel kernel)
|
_deviceManager = deviceManager;
|
||||||
{
|
_luaScript = new Script(CoreModules.Preset_SoftSandbox);
|
||||||
_kernel = kernel;
|
}
|
||||||
}
|
|
||||||
|
public ProfileModel ProfileModel { get; private set; }
|
||||||
public static void SetupLua(ProfileModel profileModel, KeyboardProvider keyboardProvider)
|
public KeyboardProvider KeyboardProvider { get; private set; }
|
||||||
{
|
public LuaProfileModule ProfileModule { get; private set; }
|
||||||
Clear();
|
public LuaEventsModule EventsModule { get; private set; }
|
||||||
|
|
||||||
if ((profileModel == null) || (keyboardProvider == null))
|
public void SetupLua(ProfileModel profileModel)
|
||||||
return;
|
{
|
||||||
|
// Clear old state
|
||||||
// Setup a new environment
|
ClearLua();
|
||||||
KeyboardProvider = keyboardProvider;
|
|
||||||
ProfileModel = profileModel;
|
// Stop after that if no model provided/there is no keyboard
|
||||||
LuaProfileWrapper = new LuaProfileWrapper(ProfileModel);
|
if (profileModel == null || _deviceManager.ActiveKeyboard == null)
|
||||||
LuaBrushWrapper = new LuaBrushWrapper();
|
return;
|
||||||
LuaKeyboardWrapper = new LuaKeyboardWrapper(keyboardProvider);
|
|
||||||
LuaMouseWrapper = new LuaMouseWrapper();
|
ProfileModel = profileModel;
|
||||||
LuaEventsWrapper = new LuaEventsWrapper();
|
KeyboardProvider = _deviceManager.ActiveKeyboard;
|
||||||
|
|
||||||
_luaScript.Options.DebugPrint = LuaPrint;
|
// Get new instances of all modules
|
||||||
_luaScript.Globals["Profile"] = LuaProfileWrapper;
|
_luaModules = _kernel.Get<List<LuaModule>>();
|
||||||
_luaScript.Globals["Events"] = LuaEventsWrapper;
|
ProfileModule = (LuaProfileModule)_luaModules.First(m => m.ModuleName == "Profile");
|
||||||
_luaScript.Globals["Brushes"] = LuaBrushWrapper;
|
EventsModule = (LuaEventsModule)_luaModules.First(m => m.ModuleName == "Events");
|
||||||
_luaScript.Globals["Keyboard"] = LuaKeyboardWrapper;
|
|
||||||
_luaScript.Globals["Mouse"] = LuaMouseWrapper;
|
// Setup new state
|
||||||
|
_luaScript.Options.DebugPrint = LuaPrint;
|
||||||
if (ProfileModel == null)
|
|
||||||
return;
|
// Insert each module into the script's globals
|
||||||
if (ProfileModel.LuaScript.IsNullOrEmpty())
|
foreach (var luaModule in _luaModules)
|
||||||
return;
|
{
|
||||||
|
_luaScript.Globals[luaModule.ModuleName] = luaModule;
|
||||||
try
|
}
|
||||||
{
|
|
||||||
lock (LuaEventsWrapper.InvokeLock)
|
// If there is no LUA script, don't bother executing the string
|
||||||
{
|
if (ProfileModel.LuaScript.IsNullOrEmpty())
|
||||||
lock (_luaScript)
|
return;
|
||||||
{
|
|
||||||
_luaScript.DoString(ProfileModel.LuaScript);
|
try
|
||||||
}
|
{
|
||||||
}
|
lock (EventsModule.InvokeLock)
|
||||||
}
|
{
|
||||||
catch (InternalErrorException e)
|
lock (_luaScript)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
_luaScript.DoString(ProfileModel.LuaScript);
|
||||||
}
|
}
|
||||||
catch (SyntaxErrorException e)
|
}
|
||||||
{
|
}
|
||||||
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
catch (InternalErrorException e)
|
||||||
}
|
{
|
||||||
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);
|
catch (SyntaxErrorException e)
|
||||||
}
|
{
|
||||||
}
|
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||||
|
}
|
||||||
public static void Clear()
|
catch (ScriptRuntimeException e)
|
||||||
{
|
{
|
||||||
lock (_luaScript)
|
_logger.Error(e, "[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||||
{
|
}
|
||||||
// Clear old fields/properties
|
}
|
||||||
KeyboardProvider = null;
|
|
||||||
ProfileModel = null;
|
public void ClearLua()
|
||||||
LuaProfileWrapper = null;
|
{
|
||||||
LuaBrushWrapper = null;
|
if (_luaModules != null)
|
||||||
LuaKeyboardWrapper?.Dispose();
|
{
|
||||||
LuaKeyboardWrapper = null;
|
foreach (var luaModule in _luaModules)
|
||||||
LuaMouseWrapper = null;
|
luaModule.Dispose();
|
||||||
|
_luaModules.Clear();
|
||||||
try
|
}
|
||||||
{
|
|
||||||
_luaScript.Globals.Clear();
|
try
|
||||||
_luaScript.Registry.Clear();
|
{
|
||||||
_luaScript.Registry.RegisterConstants();
|
_luaScript.Globals.Clear();
|
||||||
_luaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
_luaScript.Registry.Clear();
|
||||||
_luaScript.Globals.RegisterConstants();
|
_luaScript.Registry.RegisterConstants();
|
||||||
_luaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
_luaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||||
}
|
_luaScript.Globals.RegisterConstants();
|
||||||
catch (NullReferenceException)
|
_luaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||||
{
|
}
|
||||||
// TODO: Ask MoonSharp folks why this is happening
|
catch (NullReferenceException)
|
||||||
}
|
{
|
||||||
|
// TODO: Ask MoonSharp folks why this is happening
|
||||||
if (LuaEventsWrapper != null)
|
}
|
||||||
{
|
|
||||||
lock (LuaEventsWrapper.InvokeLock)
|
if (EventsModule != null)
|
||||||
{
|
{
|
||||||
lock (_luaScript)
|
lock (EventsModule.InvokeLock)
|
||||||
{
|
{
|
||||||
_luaScript.DoString("");
|
lock (_luaScript)
|
||||||
}
|
{
|
||||||
}
|
_luaScript.DoString("");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
lock (_luaScript)
|
else
|
||||||
{
|
{
|
||||||
_luaScript.DoString("");
|
lock (_luaScript)
|
||||||
}
|
{
|
||||||
}
|
_luaScript.DoString("");
|
||||||
|
}
|
||||||
|
}
|
||||||
LuaEventsWrapper = null;
|
}
|
||||||
}
|
|
||||||
}
|
#region Private lua functions
|
||||||
|
|
||||||
#region Private lua functions
|
private void LuaPrint(string s)
|
||||||
|
{
|
||||||
private static void LuaPrint(string s)
|
_logger.Info("[{0}-LUA]: {1}", ProfileModel?.Name, s);
|
||||||
{
|
}
|
||||||
_logger.Debug("[{0}-LUA]: {1}", ProfileModel?.Name, s);
|
|
||||||
}
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#region Editor
|
||||||
|
|
||||||
#region Editor
|
public void OpenEditor()
|
||||||
|
{
|
||||||
public static void OpenEditor()
|
if (ProfileModel == null)
|
||||||
{
|
return;
|
||||||
if (ProfileModel == null)
|
|
||||||
return;
|
// Create a temp file
|
||||||
|
var fileName = Guid.NewGuid() + ".lua";
|
||||||
// Create a temp file
|
var file = File.Create(Path.GetTempPath() + fileName);
|
||||||
var fileName = Guid.NewGuid() + ".lua";
|
file.Dispose();
|
||||||
var file = File.Create(Path.GetTempPath() + fileName);
|
|
||||||
file.Dispose();
|
// Add instructions to LUA script if it's a new file
|
||||||
|
if (ProfileModel.LuaScript.IsNullOrEmpty())
|
||||||
// Add instructions to LUA script if it's a new file
|
ProfileModel.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
|
||||||
if (ProfileModel.LuaScript.IsNullOrEmpty())
|
File.WriteAllText(Path.GetTempPath() + fileName, ProfileModel.LuaScript);
|
||||||
ProfileModel.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
|
|
||||||
File.WriteAllText(Path.GetTempPath() + fileName, ProfileModel.LuaScript);
|
// Watch the file for changes
|
||||||
|
SetupWatcher(Path.GetTempPath(), fileName);
|
||||||
// Watch the file for changes
|
|
||||||
SetupWatcher(Path.GetTempPath(), fileName);
|
// Open the temp file with the default editor
|
||||||
|
System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
|
||||||
// Open the temp file with the default editor
|
}
|
||||||
System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
|
|
||||||
}
|
private void SetupWatcher(string path, string fileName)
|
||||||
|
{
|
||||||
private static void SetupWatcher(string path, string fileName)
|
if (_watcher == null)
|
||||||
{
|
{
|
||||||
if (_watcher == null)
|
_watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
|
||||||
{
|
_watcher.Changed += LuaFileChanged;
|
||||||
_watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
|
_watcher.EnableRaisingEvents = true;
|
||||||
_watcher.Changed += LuaFileChanged;
|
}
|
||||||
_watcher.EnableRaisingEvents = true;
|
|
||||||
}
|
_watcher.Path = path;
|
||||||
|
_watcher.Filter = fileName;
|
||||||
_watcher.Path = path;
|
}
|
||||||
_watcher.Filter = fileName;
|
|
||||||
}
|
private void LuaFileChanged(object sender, FileSystemEventArgs args)
|
||||||
|
{
|
||||||
private static void LuaFileChanged(object sender, FileSystemEventArgs args)
|
if (args.ChangeType != WatcherChangeTypes.Changed)
|
||||||
{
|
return;
|
||||||
if (args.ChangeType != WatcherChangeTypes.Changed)
|
|
||||||
return;
|
if (ProfileModel == null)
|
||||||
|
return;
|
||||||
if (ProfileModel == null)
|
|
||||||
return;
|
lock (ProfileModel)
|
||||||
|
{
|
||||||
lock (ProfileModel)
|
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{
|
{
|
||||||
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (var sr = new StreamReader(fs))
|
||||||
{
|
{
|
||||||
using (var sr = new StreamReader(fs))
|
ProfileModel.LuaScript = sr.ReadToEnd();
|
||||||
{
|
}
|
||||||
ProfileModel.LuaScript = sr.ReadToEnd();
|
}
|
||||||
}
|
|
||||||
}
|
ProfileProvider.AddOrUpdate(ProfileModel);
|
||||||
|
SetupLua(ProfileModel);
|
||||||
ProfileProvider.AddOrUpdate(ProfileModel);
|
}
|
||||||
|
}
|
||||||
if (KeyboardProvider != null)
|
|
||||||
SetupLua(ProfileModel, KeyboardProvider);
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -23,9 +23,10 @@ namespace Artemis.Models
|
|||||||
|
|
||||||
protected DateTime LastTrace;
|
protected DateTime LastTrace;
|
||||||
|
|
||||||
protected EffectModel(DeviceManager deviceManager, EffectSettings settings, IDataModel dataModel)
|
protected EffectModel(DeviceManager deviceManager, LuaManager luaManager, EffectSettings settings, IDataModel dataModel)
|
||||||
{
|
{
|
||||||
DeviceManager = deviceManager;
|
DeviceManager = deviceManager;
|
||||||
|
LuaManager = luaManager;
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
DataModel = dataModel;
|
DataModel = dataModel;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ namespace Artemis.Models
|
|||||||
|
|
||||||
public bool Initialized { get; set; }
|
public bool Initialized { get; set; }
|
||||||
public DeviceManager DeviceManager { get; set; }
|
public DeviceManager DeviceManager { get; set; }
|
||||||
|
public LuaManager LuaManager { get; }
|
||||||
public EffectSettings Settings { get; set; }
|
public EffectSettings Settings { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int KeyboardScale { get; set; } = 4;
|
public int KeyboardScale { get; set; } = 4;
|
||||||
@ -50,7 +52,7 @@ namespace Artemis.Models
|
|||||||
|
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
Profile?.Deactivate();
|
Profile?.Deactivate(LuaManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs args)
|
private void DeviceManagerOnOnKeyboardChangedEvent(object sender, KeyboardChangedEventArgs args)
|
||||||
@ -85,7 +87,7 @@ namespace Artemis.Models
|
|||||||
|
|
||||||
// If the profile has no active LUA wrapper, create one
|
// If the profile has no active LUA wrapper, create one
|
||||||
if (!string.IsNullOrEmpty(Profile.LuaScript))
|
if (!string.IsNullOrEmpty(Profile.LuaScript))
|
||||||
Profile.Activate(DeviceManager.ActiveKeyboard);
|
Profile.Activate(LuaManager);
|
||||||
|
|
||||||
// Render the keyboard layer-by-layer
|
// Render the keyboard layer-by-layer
|
||||||
var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||||
|
|||||||
@ -6,7 +6,8 @@ namespace Artemis.Models
|
|||||||
{
|
{
|
||||||
public abstract class GameModel : EffectModel
|
public abstract class GameModel : EffectModel
|
||||||
{
|
{
|
||||||
protected GameModel(DeviceManager deviceManager, GameSettings settings, IDataModel dataModel): base(deviceManager, settings, dataModel)
|
protected GameModel(DeviceManager deviceManager, LuaManager luaManager, GameSettings settings,
|
||||||
|
IDataModel dataModel) : base(deviceManager, luaManager, settings, dataModel)
|
||||||
{
|
{
|
||||||
// Override settings to the GameSettings type
|
// Override settings to the GameSettings type
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
|
|||||||
@ -8,7 +8,8 @@ namespace Artemis.Models
|
|||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
public string ProcessName;
|
public string ProcessName;
|
||||||
|
|
||||||
protected OverlayModel(DeviceManager deviceManager, OverlaySettings settings) : base(deviceManager, settings, null)
|
protected OverlayModel(DeviceManager deviceManager, LuaManager luaManager, OverlaySettings settings)
|
||||||
|
: base(deviceManager, luaManager, settings, null)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Enabled = settings.Enabled;
|
Enabled = settings.Enabled;
|
||||||
|
|||||||
@ -15,7 +15,8 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
{
|
{
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
public BubblesModel(DeviceManager deviceManager) : base(deviceManager, SettingsProvider.Load<BubblesSettings>(), null)
|
public BubblesModel(DeviceManager deviceManager, LuaManager luaManager)
|
||||||
|
: base(deviceManager, luaManager, SettingsProvider.Load<BubblesSettings>(), null)
|
||||||
{
|
{
|
||||||
Name = "Bubbles";
|
Name = "Bubbles";
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
@ -41,7 +42,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
KeyboardScale = Settings.Smoothness;
|
KeyboardScale = Settings.Smoothness;
|
||||||
|
|
||||||
var rect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
var rect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||||
var scaleFactor = Settings.Smoothness/25.0;
|
var scaleFactor = Settings.Smoothness / 25.0;
|
||||||
|
|
||||||
for (var i = 0; i < Settings.BubbleCount; i++)
|
for (var i = 0; i < Settings.BubbleCount; i++)
|
||||||
{
|
{
|
||||||
@ -49,16 +50,18 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
? ColorHelpers.GetRandomRainbowColor()
|
? ColorHelpers.GetRandomRainbowColor()
|
||||||
: ColorHelpers.ToDrawingColor(Settings.BubbleColor);
|
: ColorHelpers.ToDrawingColor(Settings.BubbleColor);
|
||||||
// -Settings.MoveSpeed because we want to spawn at least one move away from borders
|
// -Settings.MoveSpeed because we want to spawn at least one move away from borders
|
||||||
var initialPositionX = (rect.Width - Settings.BubbleSize*scaleFactor*2 - Settings.MoveSpeed*scaleFactor)*
|
var initialPositionX = (rect.Width - Settings.BubbleSize * scaleFactor * 2 -
|
||||||
_random.NextDouble() + Settings.BubbleSize*scaleFactor;
|
Settings.MoveSpeed * scaleFactor) *
|
||||||
var initialPositionY = (rect.Height - Settings.BubbleSize*scaleFactor*2 - Settings.MoveSpeed*scaleFactor)*
|
_random.NextDouble() + Settings.BubbleSize * scaleFactor;
|
||||||
_random.NextDouble() + Settings.BubbleSize*scaleFactor;
|
var initialPositionY = (rect.Height - Settings.BubbleSize * scaleFactor * 2 -
|
||||||
var initialDirectionX = Settings.MoveSpeed*scaleFactor*_random.NextDouble()*
|
Settings.MoveSpeed * scaleFactor) *
|
||||||
|
_random.NextDouble() + Settings.BubbleSize * scaleFactor;
|
||||||
|
var initialDirectionX = Settings.MoveSpeed * scaleFactor * _random.NextDouble() *
|
||||||
(_random.Next(1) == 0 ? -1 : 1);
|
(_random.Next(1) == 0 ? -1 : 1);
|
||||||
var initialDirectionY = (Settings.MoveSpeed*scaleFactor - Math.Abs(initialDirectionX))*
|
var initialDirectionY = (Settings.MoveSpeed * scaleFactor - Math.Abs(initialDirectionX)) *
|
||||||
(_random.Next(1) == 0 ? -1 : 1);
|
(_random.Next(1) == 0 ? -1 : 1);
|
||||||
|
|
||||||
_bubbles.Add(new Bubble(color, (int) Math.Round(Settings.BubbleSize*scaleFactor),
|
_bubbles.Add(new Bubble(color, (int) Math.Round(Settings.BubbleSize * scaleFactor),
|
||||||
new Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
|
new Point(initialPositionX, initialPositionY), new Vector(initialDirectionX, initialDirectionY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
|||||||
if (Settings.IsShiftColors)
|
if (Settings.IsShiftColors)
|
||||||
bubble.Color = ColorHelpers.ShiftColor(bubble.Color,
|
bubble.Color = ColorHelpers.ShiftColor(bubble.Color,
|
||||||
Settings.IsRandomColors
|
Settings.IsRandomColors
|
||||||
? (int) Math.Round(Settings.ShiftColorSpeed*_random.NextDouble())
|
? (int) Math.Round(Settings.ShiftColorSpeed * _random.NextDouble())
|
||||||
: Settings.ShiftColorSpeed);
|
: Settings.ShiftColorSpeed);
|
||||||
|
|
||||||
bubble.CheckCollision(keyboardRectangle);
|
bubble.CheckCollision(keyboardRectangle);
|
||||||
|
|||||||
@ -16,8 +16,7 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
{
|
{
|
||||||
public class ProfilePreviewModel : EffectModel
|
public class ProfilePreviewModel : EffectModel
|
||||||
{
|
{
|
||||||
public ProfilePreviewModel(DeviceManager deviceManager)
|
public ProfilePreviewModel(DeviceManager deviceManager, LuaManager luaManager): base(deviceManager, luaManager, null, new ProfilePreviewDataModel())
|
||||||
: base(deviceManager, null, new ProfilePreviewDataModel())
|
|
||||||
{
|
{
|
||||||
Name = "Profile Preview";
|
Name = "Profile Preview";
|
||||||
}
|
}
|
||||||
@ -55,8 +54,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
|||||||
var renderLayers = GetRenderLayers(keyboardOnly);
|
var renderLayers = GetRenderLayers(keyboardOnly);
|
||||||
|
|
||||||
// If the profile has no active LUA wrapper, create one
|
// If the profile has no active LUA wrapper, create one
|
||||||
if (!Equals(LuaWrapper.ProfileModel, Profile))
|
if (!Equals(LuaManager.ProfileModel, Profile))
|
||||||
Profile.Activate(DeviceManager.ActiveKeyboard);
|
Profile.Activate(LuaManager);
|
||||||
|
|
||||||
// Render the keyboard layer-by-layer
|
// Render the keyboard layer-by-layer
|
||||||
var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
var keyboardRect = DeviceManager.ActiveKeyboard.KeyboardRectangle(KeyboardScale);
|
||||||
|
|||||||
@ -24,8 +24,9 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
private SpotifyLocalAPI _spotify;
|
private SpotifyLocalAPI _spotify;
|
||||||
private bool _spotifySetupBusy;
|
private bool _spotifySetupBusy;
|
||||||
|
|
||||||
public WindowsProfileModel(DeviceManager deviceManager)
|
public WindowsProfileModel(DeviceManager deviceManager, LuaManager luaManager)
|
||||||
: base(deviceManager, SettingsProvider.Load<WindowsProfileSettings>(), new WindowsProfileDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<WindowsProfileSettings>(),
|
||||||
|
new WindowsProfileDataModel())
|
||||||
{
|
{
|
||||||
_lastMusicUpdate = DateTime.Now;
|
_lastMusicUpdate = DateTime.Now;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
|
|
||||||
var phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();
|
var phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB();
|
||||||
var tot = PerformanceInfo.GetTotalMemoryInMiB();
|
var tot = PerformanceInfo.GetTotalMemoryInMiB();
|
||||||
var percentFree = phav/(decimal) tot*100;
|
var percentFree = phav / (decimal) tot * 100;
|
||||||
var percentOccupied = 100 - percentFree;
|
var percentOccupied = 100 - percentFree;
|
||||||
|
|
||||||
dataModel.Performance.RAMUsage = (int) percentOccupied;
|
dataModel.Performance.RAMUsage = (int) percentOccupied;
|
||||||
@ -222,7 +223,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
|
|
||||||
if (dataModel.Spotify.SongLength > 0)
|
if (dataModel.Spotify.SongLength > 0)
|
||||||
dataModel.Spotify.SongPercentCompleted =
|
dataModel.Spotify.SongPercentCompleted =
|
||||||
(int) (status.PlayingPosition/dataModel.Spotify.SongLength*100.0);
|
(int) (status.PlayingPosition / dataModel.Spotify.SongLength * 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateGooglePlayMusic(WindowsProfileDataModel dataModel)
|
private void UpdateGooglePlayMusic(WindowsProfileDataModel dataModel)
|
||||||
@ -241,14 +242,14 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
|||||||
#region System
|
#region System
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true,
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true,
|
||||||
CallingConvention = CallingConvention.Winapi)]
|
CallingConvention = CallingConvention.Winapi)]
|
||||||
public static extern short GetKeyState(int keyCode);
|
public static extern short GetKeyState(int keyCode);
|
||||||
|
|
||||||
private void UpdateKeyStates(WindowsProfileDataModel dataModel)
|
private void UpdateKeyStates(WindowsProfileDataModel dataModel)
|
||||||
{
|
{
|
||||||
dataModel.Keyboard.NumLock = ((ushort)GetKeyState(0x90) & 0xffff) != 0;
|
dataModel.Keyboard.NumLock = ((ushort) GetKeyState(0x90) & 0xffff) != 0;
|
||||||
dataModel.Keyboard.CapsLock = ((ushort)GetKeyState(0x14) & 0xffff) != 0;
|
dataModel.Keyboard.CapsLock = ((ushort) GetKeyState(0x14) & 0xffff) != 0;
|
||||||
dataModel.Keyboard.ScrollLock = ((ushort)GetKeyState(0x91) & 0xffff) != 0;
|
dataModel.Keyboard.ScrollLock = ((ushort) GetKeyState(0x91) & 0xffff) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateActiveWindow(WindowsProfileDataModel dataModel)
|
private void UpdateActiveWindow(WindowsProfileDataModel dataModel)
|
||||||
|
|||||||
@ -22,9 +22,10 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
private DateTime _lastKill;
|
private DateTime _lastKill;
|
||||||
private int _lastKills;
|
private int _lastKills;
|
||||||
|
|
||||||
public CounterStrikeModel(DeviceManager deviceManager, GameStateWebServer gameStateWebServer,
|
public CounterStrikeModel(DeviceManager deviceManager, LuaManager luaManager,
|
||||||
MetroDialogService dialogService)
|
GameStateWebServer gameStateWebServer, MetroDialogService dialogService)
|
||||||
: base(deviceManager, SettingsProvider.Load<CounterStrikeSettings>(), new CounterStrikeDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<CounterStrikeSettings>(),
|
||||||
|
new CounterStrikeDataModel())
|
||||||
{
|
{
|
||||||
_gameStateWebServer = gameStateWebServer;
|
_gameStateWebServer = gameStateWebServer;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
|
|||||||
@ -17,9 +17,9 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
private readonly MetroDialogService _dialogService;
|
private readonly MetroDialogService _dialogService;
|
||||||
private readonly GameStateWebServer _gameStateWebServer;
|
private readonly GameStateWebServer _gameStateWebServer;
|
||||||
|
|
||||||
public Dota2Model(DeviceManager deviceManager, GameStateWebServer gameStateWebServer,
|
public Dota2Model(DeviceManager deviceManager, LuaManager luaManager, GameStateWebServer gameStateWebServer,
|
||||||
MetroDialogService dialogService)
|
MetroDialogService dialogService)
|
||||||
: base(deviceManager, SettingsProvider.Load<Dota2Settings>(), new Dota2DataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<Dota2Settings>(), new Dota2DataModel())
|
||||||
{
|
{
|
||||||
_gameStateWebServer = gameStateWebServer;
|
_gameStateWebServer = gameStateWebServer;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
@ -109,8 +109,8 @@ namespace Artemis.Modules.Games.Dota2
|
|||||||
if (dataModel?.map?.daytime == null)
|
if (dataModel?.map?.daytime == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var timeLeft = 240 - dataModel.map.clock_time%240;
|
var timeLeft = 240 - dataModel.map.clock_time % 240;
|
||||||
dataModel.map.dayCyclePercentage = (int) (100.00/240*timeLeft);
|
dataModel.map.dayCyclePercentage = (int) (100.00 / 240 * timeLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Artemis.Modules.Games.Dota2
|
namespace Artemis.Modules.Games.Dota2
|
||||||
{
|
{
|
||||||
internal class Dota2Settings : GameSettings
|
public class Dota2Settings : GameSettings
|
||||||
{
|
{
|
||||||
public string GameDirectory { get; set; }
|
public string GameDirectory { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using Artemis.Modules.Games.EurotruckSimulator2.Data.Reader;
|
|||||||
|
|
||||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
||||||
{
|
{
|
||||||
internal class Ets2TelemetryData : IEts2TelemetryData
|
public class Ets2TelemetryData : IEts2TelemetryData
|
||||||
{
|
{
|
||||||
private Box<Ets2TelemetryStructure> _rawData;
|
private Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Game : IEts2Game
|
public class Ets2Game : IEts2Game
|
||||||
{
|
{
|
||||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
public string TelemetryPluginVersion => _rawData.Struct.ets2_telemetry_plugin_revision.ToString();
|
public string TelemetryPluginVersion => _rawData.Struct.ets2_telemetry_plugin_revision.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Vector : IEts2Vector
|
public class Ets2Vector : IEts2Vector
|
||||||
{
|
{
|
||||||
public Ets2Vector(float x, float y, float z)
|
public Ets2Vector(float x, float y, float z)
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
public float Z { get; }
|
public float Z { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Placement : IEts2Placement
|
public class Ets2Placement : IEts2Placement
|
||||||
{
|
{
|
||||||
public Ets2Placement(float x, float y, float z,
|
public Ets2Placement(float x, float y, float z,
|
||||||
float heading, float pitch, float roll)
|
float heading, float pitch, float roll)
|
||||||
@ -90,7 +90,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
public float Roll { get; }
|
public float Roll { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Truck : IEts2Truck
|
public class Ets2Truck : IEts2Truck
|
||||||
{
|
{
|
||||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Trailer : IEts2Trailer
|
public class Ets2Trailer : IEts2Trailer
|
||||||
{
|
{
|
||||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
_rawData.Struct.trailerRotationZ);
|
_rawData.Struct.trailerRotationZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Navigation : IEts2Navigation
|
public class Ets2Navigation : IEts2Navigation
|
||||||
{
|
{
|
||||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
_rawData.Struct.navigationSpeedLimit > 0 ? (int) Math.Round(_rawData.Struct.navigationSpeedLimit*3.6f) : 0;
|
_rawData.Struct.navigationSpeedLimit > 0 ? (int) Math.Round(_rawData.Struct.navigationSpeedLimit*3.6f) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Ets2Job : IEts2Job
|
public class Ets2Job : IEts2Job
|
||||||
{
|
{
|
||||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
internal class Box<T> where T : struct
|
public class Box<T> where T : struct
|
||||||
{
|
{
|
||||||
public Box(T @struct)
|
public Box(T @struct)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using System.Runtime.InteropServices;
|
|||||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
internal struct Ets2TelemetryStructure
|
public struct Ets2TelemetryStructure
|
||||||
{
|
{
|
||||||
private const int GeneralStringSize = 64;
|
private const int GeneralStringSize = 64;
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
||||||
{
|
{
|
||||||
internal class SharedProcessMemory<T> : IDisposable
|
public class SharedProcessMemory<T> : IDisposable
|
||||||
{
|
{
|
||||||
private readonly string _mapName;
|
private readonly string _mapName;
|
||||||
private MemoryMappedViewAccessor _memoryMappedAccessor;
|
private MemoryMappedViewAccessor _memoryMappedAccessor;
|
||||||
|
|||||||
@ -18,9 +18,10 @@ namespace Artemis.Modules.Games.EurotruckSimulator2
|
|||||||
{
|
{
|
||||||
private readonly MetroDialogService _dialogService;
|
private readonly MetroDialogService _dialogService;
|
||||||
|
|
||||||
public EurotruckSimulator2Model(DeviceManager deviceManager, MetroDialogService dialogService)
|
public EurotruckSimulator2Model(DeviceManager deviceManager, LuaManager luaManager,
|
||||||
: base(
|
MetroDialogService dialogService)
|
||||||
deviceManager, SettingsProvider.Load<EurotruckSimulator2Settings>(), new EurotruckSimulator2DataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<EurotruckSimulator2Settings>(),
|
||||||
|
new EurotruckSimulator2DataModel())
|
||||||
{
|
{
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
Name = "EurotruckSimulator2";
|
Name = "EurotruckSimulator2";
|
||||||
|
|||||||
@ -15,8 +15,8 @@ namespace Artemis.Modules.Games.GtaV
|
|||||||
{
|
{
|
||||||
private readonly PipeServer _pipeServer;
|
private readonly PipeServer _pipeServer;
|
||||||
|
|
||||||
public GtaVModel(DeviceManager deviceManager, PipeServer pipeServer)
|
public GtaVModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer)
|
||||||
: base(deviceManager, SettingsProvider.Load<GtaVSettings>(), new GtaVDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<GtaVSettings>(), new GtaVDataModel())
|
||||||
{
|
{
|
||||||
_pipeServer = pipeServer;
|
_pipeServer = pipeServer;
|
||||||
Name = "GTAV";
|
Name = "GTAV";
|
||||||
|
|||||||
@ -6,15 +6,14 @@ using Artemis.Managers;
|
|||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Utilities.DataReaders;
|
using Artemis.Utilities.DataReaders;
|
||||||
using Artemis.Utilities.GameState;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.LightFx
|
namespace Artemis.Modules.Games.LightFx
|
||||||
{
|
{
|
||||||
public class LightFxModel : GameModel
|
public class LightFxModel : GameModel
|
||||||
{
|
{
|
||||||
public LightFxModel(DeviceManager deviceManager, PipeServer pipeServer)
|
public LightFxModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer)
|
||||||
: base(deviceManager, SettingsProvider.Load<LightFxSettings>(), new LightFxDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<LightFxSettings>(), new LightFxDataModel())
|
||||||
{
|
{
|
||||||
Name = "LightFX";
|
Name = "LightFX";
|
||||||
ProcessName = "LoL";
|
ProcessName = "LoL";
|
||||||
@ -26,6 +25,8 @@ namespace Artemis.Modules.Games.LightFx
|
|||||||
pipeServer.PipeMessage += PipeServerOnPipeMessage;
|
pipeServer.PipeMessage += PipeServerOnPipeMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Scale { get; set; }
|
||||||
|
|
||||||
private void PipeServerOnPipeMessage(string msg)
|
private void PipeServerOnPipeMessage(string msg)
|
||||||
{
|
{
|
||||||
// Ensure it's Light FX JSON
|
// Ensure it's Light FX JSON
|
||||||
@ -44,11 +45,9 @@ namespace Artemis.Modules.Games.LightFx
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup process name
|
// Setup process name
|
||||||
ProcessName = Path.GetFileNameWithoutExtension(((LightFxDataModel)DataModel).LightFxState.game);
|
ProcessName = Path.GetFileNameWithoutExtension(((LightFxDataModel) DataModel).LightFxState.game);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|||||||
@ -29,9 +29,9 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
private DateTime _ultimateReady;
|
private DateTime _ultimateReady;
|
||||||
private DateTime _ultimateUsed;
|
private DateTime _ultimateUsed;
|
||||||
|
|
||||||
public OverwatchModel(DeviceManager deviceManager, PipeServer pipeServer, MetroDialogService dialogService,
|
public OverwatchModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer,
|
||||||
DebugViewModel debugViewModel)
|
MetroDialogService dialogService, DebugViewModel debugViewModel)
|
||||||
: base(deviceManager, SettingsProvider.Load<OverwatchSettings>(), new OverwatchDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<OverwatchSettings>(), new OverwatchDataModel())
|
||||||
{
|
{
|
||||||
_pipeServer = pipeServer;
|
_pipeServer = pipeServer;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
@ -240,7 +240,8 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
|
|
||||||
// Ultimate is ready when Q is blinking
|
// Ultimate is ready when Q is blinking
|
||||||
var charCol = characterMatch.Value.Color;
|
var charCol = characterMatch.Value.Color;
|
||||||
var backlidColor = Color.FromRgb((byte) (charCol.R*0.25), (byte) (charCol.G*0.25), (byte) (charCol.B*0.25));
|
var backlidColor = Color.FromRgb((byte) (charCol.R * 0.25), (byte) (charCol.G * 0.25),
|
||||||
|
(byte) (charCol.B * 0.25));
|
||||||
var ultReady = !backlidColor.Equals(colors[2, 2]);
|
var ultReady = !backlidColor.Equals(colors[2, 2]);
|
||||||
|
|
||||||
if (_ultimateUsed.AddSeconds(15) <= DateTime.Now)
|
if (_ultimateUsed.AddSeconds(15) <= DateTime.Now)
|
||||||
@ -291,7 +292,7 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var key = Registry.LocalMachine.OpenSubKey(
|
var key = Registry.LocalMachine.OpenSubKey(
|
||||||
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
||||||
var path = key?.GetValue("DisplayIcon")?.ToString();
|
var path = key?.GetValue("DisplayIcon")?.ToString();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using Artemis.DAL;
|
using Artemis.DAL;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
using Artemis.Modules.Games.ProjectCars.Data;
|
using Artemis.Modules.Games.ProjectCars.Data;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Properties;
|
|
||||||
using Artemis.Services;
|
using Artemis.Services;
|
||||||
using Artemis.Settings;
|
|
||||||
using Artemis.Utilities;
|
|
||||||
using Ninject.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.ProjectCars
|
namespace Artemis.Modules.Games.ProjectCars
|
||||||
{
|
{
|
||||||
@ -18,8 +12,8 @@ namespace Artemis.Modules.Games.ProjectCars
|
|||||||
{
|
{
|
||||||
private readonly MetroDialogService _dialogService;
|
private readonly MetroDialogService _dialogService;
|
||||||
|
|
||||||
public ProjectCarsModel(DeviceManager deviceManager, MetroDialogService dialogService)
|
public ProjectCarsModel(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService)
|
||||||
: base(deviceManager, SettingsProvider.Load<ProjectCarsSettings>(), new ProjectCarsDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<ProjectCarsSettings>(), new ProjectCarsDataModel())
|
||||||
{
|
{
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
Name = "ProjectCars";
|
Name = "ProjectCars";
|
||||||
@ -49,10 +43,7 @@ namespace Artemis.Modules.Games.ProjectCars
|
|||||||
|
|
||||||
// item1 is the true/false indicating a good read or not
|
// item1 is the true/false indicating a good read or not
|
||||||
if (returnTuple.Item1)
|
if (returnTuple.Item1)
|
||||||
{
|
|
||||||
// map the data that's read from the struct and map it to the class
|
|
||||||
dataModel.GameData = dataModel.GameData.MapStructToClass(returnTuple.Item2, dataModel.GameData);
|
dataModel.GameData = dataModel.GameData.MapStructToClass(returnTuple.Item2, dataModel.GameData);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
||||||
|
|||||||
@ -17,8 +17,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
private Memory _memory;
|
private Memory _memory;
|
||||||
private GamePointersCollection _pointer;
|
private GamePointersCollection _pointer;
|
||||||
|
|
||||||
public RocketLeagueModel(DeviceManager deviceManager)
|
public RocketLeagueModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager, SettingsProvider.Load<RocketLeagueSettings>(), new RocketLeagueDataModel())
|
||||||
: base(deviceManager, SettingsProvider.Load<RocketLeagueSettings>(), new RocketLeagueDataModel())
|
|
||||||
{
|
{
|
||||||
Name = "RocketLeague";
|
Name = "RocketLeague";
|
||||||
ProcessName = "RocketLeague";
|
ProcessName = "RocketLeague";
|
||||||
|
|||||||
@ -16,8 +16,8 @@ namespace Artemis.Modules.Games.TheDivision
|
|||||||
private StickyValue<bool> _stickyAmmo;
|
private StickyValue<bool> _stickyAmmo;
|
||||||
private StickyValue<bool> _stickyHp;
|
private StickyValue<bool> _stickyHp;
|
||||||
|
|
||||||
public TheDivisionModel(DeviceManager deviceManager, PipeServer pipeServer)
|
public TheDivisionModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer)
|
||||||
: base(deviceManager, SettingsProvider.Load<TheDivisionSettings>(), new TheDivisionDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<TheDivisionSettings>(), new TheDivisionDataModel())
|
||||||
{
|
{
|
||||||
_pipeServer = pipeServer;
|
_pipeServer = pipeServer;
|
||||||
Name = "TheDivision";
|
Name = "TheDivision";
|
||||||
|
|||||||
@ -25,8 +25,10 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
private Timer _killTimer;
|
private Timer _killTimer;
|
||||||
private int _lastScore;
|
private int _lastScore;
|
||||||
|
|
||||||
public UnrealTournamentModel(DeviceManager deviceManager, PipeServer pipeServer, MetroDialogService dialogService)
|
public UnrealTournamentModel(DeviceManager deviceManager, LuaManager luaManager, PipeServer pipeServer,
|
||||||
: base(deviceManager, SettingsProvider.Load<UnrealTournamentSettings>(), new UnrealTournamentDataModel())
|
MetroDialogService dialogService)
|
||||||
|
: base(deviceManager, luaManager, SettingsProvider.Load<UnrealTournamentSettings>(),
|
||||||
|
new UnrealTournamentDataModel())
|
||||||
{
|
{
|
||||||
_pipeServer = pipeServer;
|
_pipeServer = pipeServer;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
@ -44,7 +46,7 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
|
|
||||||
public void FindGame()
|
public void FindGame()
|
||||||
{
|
{
|
||||||
var gameSettings = (UnrealTournamentSettings)Settings;
|
var gameSettings = (UnrealTournamentSettings) Settings;
|
||||||
// If already propertly set up, don't do anything
|
// If already propertly set up, don't do anything
|
||||||
if ((gameSettings.GameDirectory != null) &&
|
if ((gameSettings.GameDirectory != null) &&
|
||||||
File.Exists(gameSettings.GameDirectory + "UE4-Win64-Shipping.exe"))
|
File.Exists(gameSettings.GameDirectory + "UE4-Win64-Shipping.exe"))
|
||||||
@ -77,13 +79,13 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
|
|
||||||
public void PlaceFiles()
|
public void PlaceFiles()
|
||||||
{
|
{
|
||||||
var gameSettings = (UnrealTournamentSettings)Settings;
|
var gameSettings = (UnrealTournamentSettings) Settings;
|
||||||
var path = gameSettings.GameDirectory;
|
var path = gameSettings.GameDirectory;
|
||||||
|
|
||||||
if (!File.Exists(path + @"\UE4-Win64-Shipping.exe"))
|
if (!File.Exists(path + @"\UE4-Win64-Shipping.exe"))
|
||||||
{
|
{
|
||||||
_dialogService.ShowErrorMessageBox("Please select a valid Unreal Tournament directory\n\n" +
|
_dialogService.ShowErrorMessageBox("Please select a valid Unreal Tournament directory\n\n" +
|
||||||
@"By default Unreal Tournament is in C:\Program Files\Epic Games\UnrealTournament");
|
@"By default Unreal Tournament is in C:\Program Files\Epic Games\UnrealTournament");
|
||||||
|
|
||||||
gameSettings.GameDirectory = string.Empty;
|
gameSettings.GameDirectory = string.Empty;
|
||||||
gameSettings.Save();
|
gameSettings.Save();
|
||||||
|
|||||||
@ -17,8 +17,8 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
private readonly Stopwatch _updateSw;
|
private readonly Stopwatch _updateSw;
|
||||||
private string _witcherSettings;
|
private string _witcherSettings;
|
||||||
|
|
||||||
public Witcher3Model(DeviceManager deviceManager)
|
public Witcher3Model(DeviceManager deviceManager, LuaManager luaManager)
|
||||||
: base(deviceManager, SettingsProvider.Load<Witcher3Settings>(), new Witcher3DataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<Witcher3Settings>(), new Witcher3DataModel())
|
||||||
{
|
{
|
||||||
Name = "Witcher3";
|
Name = "Witcher3";
|
||||||
ProcessName = "witcher3";
|
ProcessName = "witcher3";
|
||||||
|
|||||||
@ -18,8 +18,8 @@ namespace Artemis.Modules.Games.WoW
|
|||||||
private readonly GamePointersCollection _pointer;
|
private readonly GamePointersCollection _pointer;
|
||||||
private ProcessSharp _process;
|
private ProcessSharp _process;
|
||||||
|
|
||||||
public WoWModel(DeviceManager deviceManager)
|
public WoWModel(DeviceManager deviceManager, LuaManager luaManager)
|
||||||
: base(deviceManager, SettingsProvider.Load<WoWSettings>(), new WoWDataModel())
|
: base(deviceManager, luaManager, SettingsProvider.Load<WoWSettings>(), new WoWDataModel())
|
||||||
{
|
{
|
||||||
Name = "WoW";
|
Name = "WoW";
|
||||||
ProcessName = "Wow-64";
|
ProcessName = "Wow-64";
|
||||||
|
|||||||
@ -13,7 +13,8 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
{
|
{
|
||||||
public class VolumeDisplayModel : OverlayModel
|
public class VolumeDisplayModel : OverlayModel
|
||||||
{
|
{
|
||||||
public VolumeDisplayModel(DeviceManager deviceManager): base(deviceManager, SettingsProvider.Load<VolumeDisplaySettings>())
|
public VolumeDisplayModel(DeviceManager deviceManager, LuaManager luaManager)
|
||||||
|
: base(deviceManager, luaManager, SettingsProvider.Load<VolumeDisplaySettings>())
|
||||||
{
|
{
|
||||||
Name = "VolumeDisplay";
|
Name = "VolumeDisplay";
|
||||||
Settings = (VolumeDisplaySettings) base.Settings;
|
Settings = (VolumeDisplaySettings) base.Settings;
|
||||||
@ -44,7 +45,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
if (VolumeDisplay.Ttl < 1)
|
if (VolumeDisplay.Ttl < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var decreaseAmount = 500/fps;
|
var decreaseAmount = 500 / fps;
|
||||||
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
|
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
|
||||||
if (VolumeDisplay.Ttl < 128)
|
if (VolumeDisplay.Ttl < 128)
|
||||||
VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
|
VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
|
||||||
@ -55,7 +56,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
var volumeFloat =
|
var volumeFloat =
|
||||||
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
|
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
|
||||||
.AudioEndpointVolume.MasterVolumeLevelScalar;
|
.AudioEndpointVolume.MasterVolumeLevelScalar;
|
||||||
VolumeDisplay.Volume = (int) (volumeFloat*100);
|
VolumeDisplay.Volume = (int) (volumeFloat * 100);
|
||||||
}
|
}
|
||||||
catch (COMException)
|
catch (COMException)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -52,6 +52,9 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
/// <param name="updateAnimations"></param>
|
/// <param name="updateAnimations"></param>
|
||||||
public void Update(IDataModel dataModel, bool preview, bool updateAnimations)
|
public void Update(IDataModel dataModel, bool preview, bool updateAnimations)
|
||||||
{
|
{
|
||||||
|
if (LayerType == null)
|
||||||
|
return;
|
||||||
|
|
||||||
LayerType.Update(this, dataModel, preview);
|
LayerType.Update(this, dataModel, preview);
|
||||||
LayerAnimation?.Update(this, updateAnimations);
|
LayerAnimation?.Update(this, updateAnimations);
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ using Ninject;
|
|||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.Audio
|
namespace Artemis.Profiles.Layers.Types.Audio
|
||||||
{
|
{
|
||||||
internal class AudioType : ILayerType
|
public class AudioType : ILayerType
|
||||||
{
|
{
|
||||||
private readonly List<LayerModel> _audioLayers = new List<LayerModel>();
|
private readonly List<LayerModel> _audioLayers = new List<LayerModel>();
|
||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ using Artemis.ViewModels.Profiles;
|
|||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.KeyPress
|
namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||||
{
|
{
|
||||||
internal class KeyPressType : ILayerType
|
public class KeyPressType : ILayerType
|
||||||
{
|
{
|
||||||
private readonly DeviceManager _deviceManager;
|
private readonly DeviceManager _deviceManager;
|
||||||
private List<LayerModel> _keyPressLayers;
|
private List<LayerModel> _keyPressLayers;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ using Artemis.ViewModels.Profiles;
|
|||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
||||||
{
|
{
|
||||||
internal class KeyboardGifType : ILayerType
|
public class KeyboardGifType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name => "Keyboard - GIF";
|
public string Name => "Keyboard - GIF";
|
||||||
public bool ShowInEdtor => true;
|
public bool ShowInEdtor => true;
|
||||||
|
|||||||
@ -1,30 +1,36 @@
|
|||||||
using System;
|
using System;
|
||||||
using MoonSharp.Interpreter;
|
using Artemis.Managers;
|
||||||
using MoonSharp.Interpreter.Interop;
|
using MoonSharp.Interpreter.Interop;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Modules
|
namespace Artemis.Profiles.Lua
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines a module which will be accessable in all LUA scripts.
|
/// Defines a module which will be accessable in all LUA scripts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MoonSharpUserData]
|
|
||||||
public abstract class LuaModule : IDisposable
|
public abstract class LuaModule : IDisposable
|
||||||
{
|
{
|
||||||
public LuaModule(LuaWrapper luaWrapper)
|
public LuaModule(LuaManager luaManager)
|
||||||
{
|
{
|
||||||
LuaWrapper = luaWrapper;
|
LuaManager = luaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name under which this module will be accessable in LUA
|
/// The name under which this module will be accessable in LUA
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MoonSharpVisible(false)]
|
|
||||||
public abstract string ModuleName { get; }
|
public abstract string ModuleName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The LUA manager containing this module
|
||||||
|
/// </summary>
|
||||||
[MoonSharpVisible(false)]
|
[MoonSharpVisible(false)]
|
||||||
public LuaWrapper LuaWrapper { get; set; }
|
public LuaManager LuaManager { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the LUA script is restarted
|
||||||
|
/// </summary>
|
||||||
[MoonSharpVisible(false)]
|
[MoonSharpVisible(false)]
|
||||||
public abstract void Dispose();
|
public virtual void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
using MoonSharp.Interpreter.Interop;
|
using MoonSharp.Interpreter.Interop;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
namespace Artemis.Profiles.Lua.Modules.Brushes
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public abstract class LuaBrush
|
public abstract class LuaBrush
|
||||||
@ -3,7 +3,7 @@ using Artemis.Utilities;
|
|||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
using MoonSharp.Interpreter.Interop;
|
using MoonSharp.Interpreter.Interop;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
namespace Artemis.Profiles.Lua.Modules.Brushes
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaColor
|
public class LuaColor
|
||||||
@ -5,7 +5,7 @@ using System.Windows;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
namespace Artemis.Profiles.Lua.Modules.Brushes
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaLinearGradientBrush : LuaBrush
|
public class LuaLinearGradientBrush : LuaBrush
|
||||||
@ -5,7 +5,7 @@ using System.Windows;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
namespace Artemis.Profiles.Lua.Modules.Brushes
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaRadialGradientBrush : LuaBrush
|
public class LuaRadialGradientBrush : LuaBrush
|
||||||
@ -2,7 +2,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
namespace Artemis.Profiles.Lua.Modules.Brushes
|
||||||
{
|
{
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaSolidColorBrush : LuaBrush
|
public class LuaSolidColorBrush : LuaBrush
|
||||||
@ -8,7 +8,8 @@ namespace Artemis.Profiles.Lua.Modules.Events
|
|||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaDeviceDrawingEventArgs : EventArgs
|
public class LuaDeviceDrawingEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public LuaDeviceDrawingEventArgs(string deviceType, IDataModel dataModel, bool preview, LuaDrawWrapper luaDrawWrapper)
|
public LuaDeviceDrawingEventArgs(string deviceType, IDataModel dataModel, bool preview,
|
||||||
|
LuaDrawWrapper luaDrawWrapper)
|
||||||
{
|
{
|
||||||
DeviceType = deviceType;
|
DeviceType = deviceType;
|
||||||
DataModel = dataModel;
|
DataModel = dataModel;
|
||||||
|
|||||||
@ -1,43 +1,51 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Artemis.Utilities;
|
using Artemis.Managers;
|
||||||
using MoonSharp.Interpreter;
|
using Artemis.Profiles.Lua.Modules.Brushes;
|
||||||
|
using Artemis.Utilities;
|
||||||
namespace Artemis.Profiles.Lua.Brushes
|
using MoonSharp.Interpreter;
|
||||||
{
|
|
||||||
[MoonSharpUserData]
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
public class LuaBrushWrapper
|
{
|
||||||
{
|
[MoonSharpUserData]
|
||||||
public LuaColor GetColor(string hexCode)
|
public class LuaBrushesModule : LuaModule
|
||||||
{
|
{
|
||||||
return new LuaColor(hexCode);
|
public LuaBrushesModule(LuaManager luaManager) : base(luaManager)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
public LuaColor GetColor(byte a, byte r, byte g, byte b)
|
|
||||||
{
|
public override string ModuleName => "Brushes";
|
||||||
return new LuaColor(a, r, g, b);
|
|
||||||
}
|
public LuaColor GetColor(string hexCode)
|
||||||
|
{
|
||||||
public LuaColor GetRandomColor()
|
return new LuaColor(hexCode);
|
||||||
{
|
}
|
||||||
return new LuaColor(ColorHelpers.GetRandomRainbowMediaColor());
|
|
||||||
}
|
public LuaColor GetColor(byte a, byte r, byte g, byte b)
|
||||||
|
{
|
||||||
public LuaSolidColorBrush GetSolidColorBrush(LuaColor color)
|
return new LuaColor(a, r, g, b);
|
||||||
{
|
}
|
||||||
return new LuaSolidColorBrush(color);
|
|
||||||
}
|
public LuaColor GetRandomColor()
|
||||||
|
{
|
||||||
public LuaLinearGradientBrush GetLinearGradientBrush(Dictionary<LuaColor, double> gradientColors,
|
return new LuaColor(ColorHelpers.GetRandomRainbowMediaColor());
|
||||||
double startX = 0.5, double startY = 0.0, double endX = 0.5, double endY = 1.0)
|
}
|
||||||
{
|
|
||||||
return new LuaLinearGradientBrush(gradientColors, startX, startY, endX, endY);
|
public LuaSolidColorBrush GetSolidColorBrush(LuaColor color)
|
||||||
}
|
{
|
||||||
|
return new LuaSolidColorBrush(color);
|
||||||
// TODO: Check default values
|
}
|
||||||
public LuaRadialGradientBrush GetRadialGradientBrush(Dictionary<LuaColor, double> gradientColors,
|
|
||||||
double centerX = 0.5, double centerY = 0.5, double originX = 0.5, double originY = 0.5)
|
public LuaLinearGradientBrush GetLinearGradientBrush(Dictionary<LuaColor, double> gradientColors,
|
||||||
{
|
double startX = 0.5, double startY = 0.0, double endX = 0.5, double endY = 1.0)
|
||||||
return new LuaRadialGradientBrush(gradientColors, centerX, centerY, originX, originY);
|
{
|
||||||
}
|
return new LuaLinearGradientBrush(gradientColors, startX, startY, endX, endY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Check default values
|
||||||
|
public LuaRadialGradientBrush GetRadialGradientBrush(Dictionary<LuaColor, double> gradientColors,
|
||||||
|
double centerX = 0.5, double centerY = 0.5, double originX = 0.5, double originY = 0.5)
|
||||||
|
{
|
||||||
|
return new LuaRadialGradientBrush(gradientColors, centerX, centerY, originX, originY);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,34 +1,44 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using Artemis.DeviceProviders;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Events;
|
||||||
|
using Artemis.Managers;
|
||||||
|
using Artemis.Profiles.Lua.Modules.Events;
|
||||||
using Artemis.Profiles.Lua.Wrappers;
|
using Artemis.Profiles.Lua.Wrappers;
|
||||||
|
using Artemis.Utilities.Keyboard;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Modules.Events
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
{
|
{
|
||||||
|
[MoonSharpUserData]
|
||||||
public class LuaEventsModule : LuaModule
|
public class LuaEventsModule : LuaModule
|
||||||
{
|
{
|
||||||
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
private readonly ProfileModel _profileModel;
|
||||||
public readonly string InvokeLock = string.Empty;
|
public readonly string InvokeLock = string.Empty;
|
||||||
|
|
||||||
public LuaEventsModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
public LuaEventsModule(LuaManager luaManager) : base(luaManager)
|
||||||
{
|
{
|
||||||
|
_profileModel = luaManager.ProfileModel;
|
||||||
|
_profileModel.OnDeviceUpdatedEvent += OnDeviceUpdatedEvent;
|
||||||
|
_profileModel.OnDeviceDrawnEvent += OnDeviceDrawnEvent;
|
||||||
|
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ModuleName => "Events";
|
public override string ModuleName => "Events";
|
||||||
|
|
||||||
public event EventHandler<LuaDeviceUpdatingEventArgs> DeviceUpdating;
|
public event EventHandler<LuaDeviceUpdatingEventArgs> DeviceUpdating;
|
||||||
public event EventHandler<LuaDeviceDrawingEventArgs> DeviceDrawing;
|
public event EventHandler<LuaDeviceDrawingEventArgs> DeviceDrawing;
|
||||||
public event EventHandler<LuaKeyPressEventArgs> KeyboardKeyPressed;
|
public event EventHandler<LuaKeyPressEventArgs> KeyboardKeyPressed;
|
||||||
|
|
||||||
internal void InvokeDeviceUpdate(ProfileModel profileModel, string deviceType, IDataModel dataModel,
|
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||||
bool preview)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LuaInvoke(profileModel, () => OnDeviceUpdating(new LuaProfileWrapper(profileModel),
|
var keyMatch = LuaManager.KeyboardProvider.GetKeyPosition(e.KeyCode) ?? new KeyMatch(e.KeyCode, 0, 0);
|
||||||
new LuaDeviceUpdatingEventArgs(deviceType, dataModel, preview)));
|
var args = new LuaKeyPressEventArgs(e.KeyCode, keyMatch.X, keyMatch.Y);
|
||||||
|
LuaInvoke(_profileModel, () => OnKeyboardKeyPressed(LuaManager.ProfileModule, args));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -36,13 +46,12 @@ namespace Artemis.Profiles.Lua.Modules.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void InvokeDeviceDraw(ProfileModel profileModel, string deviceType, IDataModel dataModel, bool preview,
|
private void OnDeviceUpdatedEvent(object sender, ProfileDeviceEventsArg e)
|
||||||
DrawingContext c)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LuaInvoke(profileModel, () => OnDeviceDrawing(new LuaProfileWrapper(profileModel),
|
var args = new LuaDeviceUpdatingEventArgs(e.UpdateType, e.DataModel, e.Preview);
|
||||||
new LuaDeviceDrawingEventArgs(deviceType, dataModel, preview, new LuaDrawWrapper(c))));
|
LuaInvoke(_profileModel, () => OnDeviceUpdating(LuaManager.ProfileModule, args));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -50,12 +59,13 @@ namespace Artemis.Profiles.Lua.Modules.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void InvokeKeyPressed(ProfileModel profileModel, LuaKeyboardModule keyboard, Keys key, int x, int y)
|
private void OnDeviceDrawnEvent(object sender, ProfileDeviceEventsArg e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LuaInvoke(profileModel, () => OnKeyboardKeyPressed(new LuaProfileWrapper(profileModel),
|
var wrapper = new LuaDrawWrapper(e.DrawingContext);
|
||||||
keyboard, new LuaKeyPressEventArgs(key, x, y)));
|
var args = new LuaDeviceDrawingEventArgs(e.UpdateType, e.DataModel, e.Preview, wrapper);
|
||||||
|
LuaInvoke(_profileModel, () => OnDeviceDrawing(LuaManager.ProfileModule, args));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -86,26 +96,29 @@ namespace Artemis.Profiles.Lua.Modules.Events
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDeviceUpdating(LuaProfileWrapper profileModel, LuaDeviceUpdatingEventArgs e)
|
protected virtual void OnDeviceUpdating(LuaProfileModule profileModel, LuaDeviceUpdatingEventArgs e)
|
||||||
{
|
{
|
||||||
DeviceUpdating?.Invoke(profileModel, e);
|
DeviceUpdating?.Invoke(profileModel, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnDeviceDrawing(LuaProfileWrapper profileModel, LuaDeviceDrawingEventArgs e)
|
protected virtual void OnDeviceDrawing(LuaProfileModule profileModel, LuaDeviceDrawingEventArgs e)
|
||||||
{
|
{
|
||||||
DeviceDrawing?.Invoke(profileModel, e);
|
DeviceDrawing?.Invoke(profileModel, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnKeyboardKeyPressed(LuaProfileWrapper profileModel, LuaKeyboardModule keyboard,
|
protected virtual void OnKeyboardKeyPressed(LuaProfileModule profileModel, LuaKeyPressEventArgs e)
|
||||||
LuaKeyPressEventArgs e)
|
|
||||||
{
|
{
|
||||||
KeyboardKeyPressed?.Invoke(profileModel, e);
|
KeyboardKeyPressed?.Invoke(profileModel, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overriding members
|
#region Overriding members
|
||||||
|
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
_profileModel.OnDeviceUpdatedEvent -= OnDeviceUpdatedEvent;
|
||||||
|
_profileModel.OnDeviceDrawnEvent -= OnDeviceDrawnEvent;
|
||||||
|
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -1,6 +1,8 @@
|
|||||||
using System.Windows.Forms;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Windows.Forms;
|
||||||
using Artemis.DeviceProviders;
|
using Artemis.DeviceProviders;
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Managers;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Modules
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
@ -10,13 +12,14 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
{
|
{
|
||||||
private readonly KeyboardProvider _keyboardProvider;
|
private readonly KeyboardProvider _keyboardProvider;
|
||||||
|
|
||||||
public LuaKeyboardModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
public LuaKeyboardModule(LuaManager luaManager) : base(luaManager)
|
||||||
{
|
{
|
||||||
_keyboardProvider = luaWrapper.KeyboardProvider;
|
_keyboardProvider = luaManager.KeyboardProvider;
|
||||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
|
||||||
|
// Register the KeyMatch type for usage in GetKeyPosition
|
||||||
|
UserData.RegisterType(typeof(KeyMatch));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Visible in LUA? Decladed as invisile in base class
|
|
||||||
public override string ModuleName => "Keyboard";
|
public override string ModuleName => "Keyboard";
|
||||||
|
|
||||||
public string Name => _keyboardProvider.Name;
|
public string Name => _keyboardProvider.Name;
|
||||||
@ -24,32 +27,23 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
public int Width => _keyboardProvider.Width;
|
public int Width => _keyboardProvider.Width;
|
||||||
public int Height => _keyboardProvider.Height;
|
public int Height => _keyboardProvider.Height;
|
||||||
|
|
||||||
#region Overriding members
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
|
||||||
{
|
|
||||||
// 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)
|
public void PressKeys(string keys)
|
||||||
{
|
{
|
||||||
SendKeys.SendWait(keys);
|
SendKeys.SendWait(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetKeyPosition(Keys key)
|
public KeyMatch? GetKeyPosition(string key)
|
||||||
{
|
{
|
||||||
_keyboardProvider.GetKeyPosition(key);
|
// Convert string to Keys enum, I'm not sure if built-in enums can be converted automatically
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var keyEnum = (Keys)Enum.Parse(typeof(Keys), key);
|
||||||
|
return _keyboardProvider.GetKeyPosition(keyEnum);
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
throw new ScriptRuntimeException($"Key '{key}' not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using Artemis.Managers;
|
||||||
using Artemis.Modules.Effects.ProfilePreview;
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Profiles.Lua.Brushes;
|
using Artemis.Profiles.Lua.Modules.Brushes;
|
||||||
|
using Artemis.Profiles.Lua.Wrappers;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Modules
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
@ -13,10 +15,10 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
{
|
{
|
||||||
private readonly LayerModel _layerModel;
|
private readonly LayerModel _layerModel;
|
||||||
|
|
||||||
public LuaLayerModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
public LuaLayerModule(LuaManager luaManager, LayerModel layerModel) : base(luaManager)
|
||||||
{
|
{
|
||||||
_layerModel = luaWrapper.LayerModel;
|
_layerModel = layerModel;
|
||||||
SavedProperties = new Lua.LuaLayerProperties(_layerModel);
|
SavedProperties = new Wrappers.LuaLayerProperties(_layerModel);
|
||||||
|
|
||||||
// Triger an update to fill up the Properties
|
// Triger an update to fill up the Properties
|
||||||
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
||||||
@ -24,14 +26,6 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
|
|
||||||
public override string ModuleName => "Layer";
|
public override string ModuleName => "Layer";
|
||||||
|
|
||||||
#region Overriding members
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Child methods
|
#region Child methods
|
||||||
|
|
||||||
public List<LuaLayerWrapper> GetChildren()
|
public List<LuaLayerWrapper> GetChildren()
|
||||||
@ -113,7 +107,7 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
|
|
||||||
#region Advanced layer properties
|
#region Advanced layer properties
|
||||||
|
|
||||||
public Lua.LuaLayerProperties SavedProperties { get; set; }
|
public Wrappers.LuaLayerProperties SavedProperties { get; set; }
|
||||||
|
|
||||||
public string BrushType => _layerModel.Properties.Brush?.GetType().Name;
|
public string BrushType => _layerModel.Properties.Brush?.GetType().Name;
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +1,39 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using MoonSharp.Interpreter;
|
using Artemis.Managers;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
namespace Artemis.Profiles
|
|
||||||
{
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
[MoonSharpUserData]
|
{
|
||||||
public class LuaMouseWrapper
|
[MoonSharpUserData]
|
||||||
{
|
public class LuaMouseModule : LuaModule
|
||||||
public int Y => (int) GetMousePosition().Y;
|
{
|
||||||
|
public LuaMouseModule(LuaManager luaManager) : base(luaManager)
|
||||||
public int X => (int) GetMousePosition().X;
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
public override string ModuleName => "Mouse";
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
internal static extern bool GetCursorPos(ref Win32Point pt);
|
public int Y => (int) GetMousePosition().Y;
|
||||||
|
|
||||||
public static Point GetMousePosition()
|
public int X => (int) GetMousePosition().X;
|
||||||
{
|
|
||||||
var w32Mouse = new Win32Point();
|
[DllImport("user32.dll")]
|
||||||
GetCursorPos(ref w32Mouse);
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
return new Point(w32Mouse.X, w32Mouse.Y);
|
internal static extern bool GetCursorPos(ref Win32Point pt);
|
||||||
}
|
|
||||||
|
public static Point GetMousePosition()
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
{
|
||||||
internal struct Win32Point
|
var w32Mouse = new Win32Point();
|
||||||
{
|
GetCursorPos(ref w32Mouse);
|
||||||
public int X;
|
return new Point(w32Mouse.X, w32Mouse.Y);
|
||||||
public int Y;
|
}
|
||||||
}
|
|
||||||
}
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct Win32Point
|
||||||
|
{
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,15 +1,19 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Artemis.Managers;
|
||||||
|
using Artemis.Profiles.Lua.Wrappers;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Modules
|
namespace Artemis.Profiles.Lua.Modules
|
||||||
{
|
{
|
||||||
|
[MoonSharpUserData]
|
||||||
public class LuaProfileModule : LuaModule
|
public class LuaProfileModule : LuaModule
|
||||||
{
|
{
|
||||||
private readonly ProfileModel _profileModel;
|
private readonly ProfileModel _profileModel;
|
||||||
|
|
||||||
public LuaProfileModule(LuaWrapper luaWrapper) : base(luaWrapper)
|
public LuaProfileModule(LuaManager luaManager) : base(luaManager)
|
||||||
{
|
{
|
||||||
_profileModel = luaWrapper.ProfileModel;
|
_profileModel = luaManager.ProfileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ModuleName => "Profile";
|
public override string ModuleName => "Profile";
|
||||||
@ -20,14 +24,6 @@ namespace Artemis.Profiles.Lua.Modules
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Overriding members
|
|
||||||
|
|
||||||
public override void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Layer methods
|
#region Layer methods
|
||||||
|
|
||||||
public List<LuaLayerWrapper> GetLayers()
|
public List<LuaLayerWrapper> GetLayers()
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Profiles.Lua.Brushes;
|
using Artemis.Profiles.Lua.Modules.Brushes;
|
||||||
using MoonSharp.Interpreter;
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Lua.Wrappers
|
namespace Artemis.Profiles.Lua.Wrappers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A wrapper that is provided to each OnDraw event to allow drawing in LUA
|
/// A wrapper that is provided to each OnDraw event to allow drawing in LUA
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MoonSharpUserData]
|
[MoonSharpUserData]
|
||||||
public class LuaDrawWrapper
|
public class LuaDrawWrapper
|
||||||
|
|||||||
183
Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs
Normal file
183
Artemis/Artemis/Profiles/Lua/Wrappers/LuaLayerWrapper.cs
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Artemis.Modules.Effects.ProfilePreview;
|
||||||
|
using Artemis.Profiles.Layers.Models;
|
||||||
|
using Artemis.Profiles.Lua.Modules.Brushes;
|
||||||
|
using MoonSharp.Interpreter;
|
||||||
|
|
||||||
|
namespace Artemis.Profiles.Lua.Wrappers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Serves as a sandboxed wrapper around the LayerModel
|
||||||
|
/// </summary>
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class LuaLayerWrapper
|
||||||
|
{
|
||||||
|
private readonly LayerModel _layerModel;
|
||||||
|
|
||||||
|
public LuaLayerWrapper(LayerModel layerModel)
|
||||||
|
{
|
||||||
|
_layerModel = layerModel;
|
||||||
|
SavedProperties = new LuaLayerProperties(layerModel);
|
||||||
|
|
||||||
|
// Triger an update to fill up the Properties
|
||||||
|
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Child methods
|
||||||
|
|
||||||
|
public List<LuaLayerWrapper> GetChildren()
|
||||||
|
{
|
||||||
|
return _layerModel.Children.Select(l => new LuaLayerWrapper(l)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuaLayerWrapper GetChildByName(string name)
|
||||||
|
{
|
||||||
|
var layer = _layerModel.Children.FirstOrDefault(l => l.Name == name);
|
||||||
|
return layer == null ? null : new LuaLayerWrapper(layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region General layer properties
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _layerModel.Name; }
|
||||||
|
set { _layerModel.Name = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Enabled
|
||||||
|
{
|
||||||
|
get { return _layerModel.Enabled; }
|
||||||
|
set { _layerModel.Enabled = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEvent
|
||||||
|
{
|
||||||
|
get { return _layerModel.IsEvent; }
|
||||||
|
set { _layerModel.IsEvent = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuaLayerWrapper Parent => new LuaLayerWrapper(_layerModel.Parent);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Render layer properties
|
||||||
|
|
||||||
|
public double X
|
||||||
|
{
|
||||||
|
get { return _layerModel.X; }
|
||||||
|
set { _layerModel.X = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Y
|
||||||
|
{
|
||||||
|
get { return _layerModel.Y; }
|
||||||
|
set { _layerModel.Y = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Width
|
||||||
|
{
|
||||||
|
get { return _layerModel.Width; }
|
||||||
|
set { _layerModel.Width = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Height
|
||||||
|
{
|
||||||
|
get { return _layerModel.Height; }
|
||||||
|
set { _layerModel.Height = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Opacity
|
||||||
|
{
|
||||||
|
get { return _layerModel.Opacity; }
|
||||||
|
set { _layerModel.Opacity = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double AnimationProgress
|
||||||
|
{
|
||||||
|
get { return _layerModel.AnimationProgress; }
|
||||||
|
set { _layerModel.AnimationProgress = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Advanced layer properties
|
||||||
|
|
||||||
|
public LuaLayerProperties SavedProperties { get; set; }
|
||||||
|
|
||||||
|
public string BrushType => _layerModel.Properties.Brush?.GetType().Name;
|
||||||
|
|
||||||
|
public LuaBrush Brush
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_layerModel.Properties.Brush is SolidColorBrush)
|
||||||
|
return new LuaSolidColorBrush(_layerModel.Properties.Brush);
|
||||||
|
if (_layerModel.Properties.Brush is LinearGradientBrush)
|
||||||
|
return new LuaLinearGradientBrush(_layerModel.Properties.Brush);
|
||||||
|
if (_layerModel.Properties.Brush is RadialGradientBrush)
|
||||||
|
return new LuaRadialGradientBrush(_layerModel.Properties.Brush);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set { _layerModel.Properties.Brush = value?.Brush; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class LuaLayerProperties
|
||||||
|
{
|
||||||
|
private readonly LayerModel _layerModel;
|
||||||
|
|
||||||
|
public LuaLayerProperties(LayerModel layerModel)
|
||||||
|
{
|
||||||
|
_layerModel = layerModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double X
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.X; }
|
||||||
|
set { _layerModel.Properties.X = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Y
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Y; }
|
||||||
|
set { _layerModel.Properties.Y = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Width
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Width; }
|
||||||
|
set { _layerModel.Properties.Width = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Height
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Height; }
|
||||||
|
set { _layerModel.Properties.Height = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contain
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Contain; }
|
||||||
|
set { _layerModel.Properties.Contain = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Opacity
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Opacity; }
|
||||||
|
set { _layerModel.Properties.Opacity = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double AnimationSpeed
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.AnimationSpeed; }
|
||||||
|
set { _layerModel.Properties.AnimationSpeed = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,10 +6,11 @@ using System.Linq;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.DeviceProviders;
|
using Artemis.DeviceProviders;
|
||||||
|
using Artemis.Events;
|
||||||
|
using Artemis.Managers;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Profiles.Lua;
|
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.ParentChild;
|
using Artemis.Utilities.ParentChild;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -41,6 +42,9 @@ namespace Artemis.Profiles
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string Slug => new string(Name.Where(ch => !_invalidFileNameChars.Contains(ch)).ToArray());
|
public string Slug => new string(Name.Where(ch => !_invalidFileNameChars.Contains(ch)).ToArray());
|
||||||
|
|
||||||
|
public event EventHandler<ProfileDeviceEventsArg> OnDeviceUpdatedEvent;
|
||||||
|
public event EventHandler<ProfileDeviceEventsArg> OnDeviceDrawnEvent;
|
||||||
|
|
||||||
public void FixOrder()
|
public void FixOrder()
|
||||||
{
|
{
|
||||||
Layers.Sort(l => l.Order);
|
Layers.Sort(l => l.Order);
|
||||||
@ -77,12 +81,14 @@ namespace Artemis.Profiles
|
|||||||
var layers = new List<LayerModel>();
|
var layers = new List<LayerModel>();
|
||||||
foreach (var layerModel in Layers.OrderByDescending(l => l.Order))
|
foreach (var layerModel in Layers.OrderByDescending(l => l.Order))
|
||||||
{
|
{
|
||||||
if (!layerModel.Enabled || (keyboardOnly && (layerModel.LayerType.DrawType != DrawType.Keyboard)))
|
if (!layerModel.Enabled || keyboardOnly && layerModel.LayerType.DrawType != DrawType.Keyboard)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!ignoreConditions)
|
if (!ignoreConditions)
|
||||||
|
{
|
||||||
if (!layerModel.ConditionsMet(dataModel))
|
if (!layerModel.ConditionsMet(dataModel))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
layers.Add(layerModel);
|
layers.Add(layerModel);
|
||||||
layers.AddRange(layerModel.GetRenderLayers(dataModel, keyboardOnly, ignoreConditions));
|
layers.AddRange(layerModel.GetRenderLayers(dataModel, keyboardOnly, ignoreConditions));
|
||||||
@ -115,12 +121,12 @@ namespace Artemis.Profiles
|
|||||||
// Update the layers
|
// Update the layers
|
||||||
foreach (var layerModel in layerModels)
|
foreach (var layerModel in layerModels)
|
||||||
layerModel.Update(dataModel, preview, updateAnimations);
|
layerModel.Update(dataModel, preview, updateAnimations);
|
||||||
LuaWrapper.LuaEventsWrapper?.InvokeDeviceUpdate(this, updateType, dataModel, preview);
|
RaiseDeviceUpdatedEvent(new ProfileDeviceEventsArg(updateType, dataModel, preview, null));
|
||||||
|
|
||||||
// Draw the layers
|
// Draw the layers
|
||||||
foreach (var layerModel in layerModels)
|
foreach (var layerModel in layerModels)
|
||||||
layerModel.Draw(dataModel, c, preview, updateAnimations);
|
layerModel.Draw(dataModel, c, preview, updateAnimations);
|
||||||
LuaWrapper.LuaEventsWrapper?.InvokeDeviceDraw(this, updateType, dataModel, preview, c);
|
RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg(updateType, dataModel, preview, c));
|
||||||
|
|
||||||
// Remove the clip
|
// Remove the clip
|
||||||
c.Pop();
|
c.Pop();
|
||||||
@ -132,6 +138,18 @@ namespace Artemis.Profiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RaiseDeviceUpdatedEvent(ProfileDeviceEventsArg e)
|
||||||
|
{
|
||||||
|
var handler = OnDeviceUpdatedEvent;
|
||||||
|
handler?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RaiseDeviceDrawnEvent(ProfileDeviceEventsArg e)
|
||||||
|
{
|
||||||
|
var handler = OnDeviceDrawnEvent;
|
||||||
|
handler?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks at all the layers wthin the profile and makes sure they are within boundaries of the given rectangle
|
/// Looks at all the layers wthin the profile and makes sure they are within boundaries of the given rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -172,15 +190,15 @@ namespace Artemis.Profiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(KeyboardProvider keyboard)
|
public void Activate(LuaManager luaManager)
|
||||||
{
|
{
|
||||||
if (!Equals(LuaWrapper.ProfileModel, this))
|
if (!Equals(luaManager.ProfileModel, this))
|
||||||
LuaWrapper.SetupLua(this, keyboard);
|
luaManager.SetupLua(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public void Deactivate(LuaManager luaManager)
|
||||||
{
|
{
|
||||||
LuaWrapper.Clear();
|
luaManager.ClearLua();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayerModel AddLayer(LayerModel afterLayer)
|
public LayerModel AddLayer(LayerModel afterLayer)
|
||||||
@ -189,7 +207,9 @@ namespace Artemis.Profiles
|
|||||||
var layer = LayerModel.CreateLayer();
|
var layer = LayerModel.CreateLayer();
|
||||||
|
|
||||||
if (afterLayer != null)
|
if (afterLayer != null)
|
||||||
|
{
|
||||||
afterLayer.InsertAfter(layer);
|
afterLayer.InsertAfter(layer);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Layers.Add(layer);
|
Layers.Add(layer);
|
||||||
@ -221,8 +241,8 @@ namespace Artemis.Profiles
|
|||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
var hashCode = Slug?.GetHashCode() ?? 0;
|
var hashCode = Slug?.GetHashCode() ?? 0;
|
||||||
hashCode = (hashCode*397) ^ (KeyboardSlug?.GetHashCode() ?? 0);
|
hashCode = (hashCode * 397) ^ (KeyboardSlug?.GetHashCode() ?? 0);
|
||||||
hashCode = (hashCode*397) ^ (GameName?.GetHashCode() ?? 0);
|
hashCode = (hashCode * 397) ^ (GameName?.GetHashCode() ?? 0);
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
Artemis/Artemis/Properties/Resources.Designer.cs
generated
2
Artemis/Artemis/Properties/Resources.Designer.cs
generated
@ -22,7 +22,7 @@ namespace Artemis.Properties {
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources {
|
public class Resources {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using System.Windows.Media.Imaging;
|
|||||||
|
|
||||||
namespace Artemis.Utilities
|
namespace Artemis.Utilities
|
||||||
{
|
{
|
||||||
internal class ImageUtilities
|
public class ImageUtilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resize the image to the specified width and height.
|
/// Resize the image to the specified width and height.
|
||||||
|
|||||||
@ -7,7 +7,7 @@ namespace Artemis.Utilities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A value that only changes it's not changed again within a set time
|
/// A value that only changes it's not changed again within a set time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class StickyValue<T> : IDisposable
|
public class StickyValue<T> : IDisposable
|
||||||
{
|
{
|
||||||
private readonly int _stickyTime;
|
private readonly int _stickyTime;
|
||||||
private readonly BackgroundWorker _updateWorker;
|
private readonly BackgroundWorker _updateWorker;
|
||||||
|
|||||||
@ -27,14 +27,14 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
private ILayerType _selectedLayerType;
|
private ILayerType _selectedLayerType;
|
||||||
|
|
||||||
public LayerEditorViewModel(LayerModel layer, IDataModel dataModel, IEnumerable<ILayerType> types,
|
public LayerEditorViewModel(LayerModel layer, IDataModel dataModel, IEnumerable<ILayerType> types,
|
||||||
List<ILayerAnimation> layerAnimations)
|
IEnumerable<ILayerAnimation> layerAnimations)
|
||||||
{
|
{
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
ProposedLayer = Clone(layer);
|
ProposedLayer = Clone(layer);
|
||||||
ProposedLayer.Children.Clear();
|
ProposedLayer.Children.Clear();
|
||||||
DataModel = DataModel;
|
DataModel = DataModel;
|
||||||
LayerTypes = new BindableCollection<ILayerType>(types);
|
LayerTypes = new BindableCollection<ILayerType>(types.OrderBy(t => t.Name));
|
||||||
LayerAnimations = layerAnimations;
|
LayerAnimations = layerAnimations.OrderBy(l => l.Name).ToList();
|
||||||
|
|
||||||
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
|
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
NotifyOfPropertyChange(() => SelectedLayerType);
|
NotifyOfPropertyChange(() => SelectedLayerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreSelect()
|
public void PreSelect()
|
||||||
{
|
{
|
||||||
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
||||||
|
|||||||
@ -16,11 +16,9 @@ using Artemis.Models;
|
|||||||
using Artemis.Profiles;
|
using Artemis.Profiles;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Profiles.Layers.Types.Folder;
|
using Artemis.Profiles.Layers.Types.Folder;
|
||||||
using Artemis.Profiles.Lua;
|
|
||||||
using Artemis.Services;
|
using Artemis.Services;
|
||||||
using Artemis.Styles.DropTargetAdorners;
|
using Artemis.Styles.DropTargetAdorners;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Caliburn.Micro;
|
|
||||||
using GongSolutions.Wpf.DragDrop;
|
using GongSolutions.Wpf.DragDrop;
|
||||||
using MahApps.Metro.Controls.Dialogs;
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
@ -38,6 +36,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
{
|
{
|
||||||
private readonly DeviceManager _deviceManager;
|
private readonly DeviceManager _deviceManager;
|
||||||
private readonly EffectModel _gameModel;
|
private readonly EffectModel _gameModel;
|
||||||
|
private readonly LuaManager _luaManager;
|
||||||
private readonly Timer _saveTimer;
|
private readonly Timer _saveTimer;
|
||||||
private ImageSource _keyboardPreview;
|
private ImageSource _keyboardPreview;
|
||||||
private ObservableCollection<LayerModel> _layers;
|
private ObservableCollection<LayerModel> _layers;
|
||||||
@ -45,11 +44,12 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
private bool _saving;
|
private bool _saving;
|
||||||
private ProfileModel _selectedProfile;
|
private ProfileModel _selectedProfile;
|
||||||
|
|
||||||
public ProfileEditorViewModel(DeviceManager deviceManager, EffectModel gameModel,
|
public ProfileEditorViewModel(DeviceManager deviceManager, LuaManager luaManager, EffectModel gameModel,
|
||||||
ProfileViewModel profileViewModel, MetroDialogService dialogService, WindowService windowService,
|
ProfileViewModel profileViewModel, MetroDialogService dialogService, WindowService windowService,
|
||||||
string lastProfile)
|
string lastProfile)
|
||||||
{
|
{
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
|
_luaManager = luaManager;
|
||||||
_gameModel = gameModel;
|
_gameModel = gameModel;
|
||||||
|
|
||||||
ProfileNames = new ObservableCollection<string>();
|
ProfileNames = new ObservableCollection<string>();
|
||||||
@ -79,7 +79,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public ProfileViewModel ProfileViewModel { get; set; }
|
public ProfileViewModel ProfileViewModel { get; set; }
|
||||||
|
|
||||||
public bool EditorEnabled
|
public bool EditorEnabled
|
||||||
=> (SelectedProfile != null) && !SelectedProfile.IsDefault && (_deviceManager.ActiveKeyboard != null);
|
=> SelectedProfile != null && !SelectedProfile.IsDefault && _deviceManager.ActiveKeyboard != null;
|
||||||
|
|
||||||
public ObservableCollection<string> ProfileNames
|
public ObservableCollection<string> ProfileNames
|
||||||
{
|
{
|
||||||
@ -125,11 +125,11 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Deactivate old profile
|
// Deactivate old profile
|
||||||
_selectedProfile?.Deactivate();
|
_selectedProfile?.Deactivate(_luaManager);
|
||||||
// Update the value
|
// Update the value
|
||||||
_selectedProfile = value;
|
_selectedProfile = value;
|
||||||
// Activate new profile
|
// Activate new profile
|
||||||
_selectedProfile?.Activate(_deviceManager.ActiveKeyboard);
|
_selectedProfile?.Activate(_luaManager);
|
||||||
NotifyOfPropertyChange(() => SelectedProfile);
|
NotifyOfPropertyChange(() => SelectedProfile);
|
||||||
NotifyOfPropertyChange(() => SelectedProfileName);
|
NotifyOfPropertyChange(() => SelectedProfileName);
|
||||||
}
|
}
|
||||||
@ -149,16 +149,16 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public PreviewSettings? PreviewSettings => _deviceManager.ActiveKeyboard?.PreviewSettings;
|
public PreviewSettings? PreviewSettings => _deviceManager.ActiveKeyboard?.PreviewSettings;
|
||||||
|
|
||||||
public bool ProfileSelected => SelectedProfile != null;
|
public bool ProfileSelected => SelectedProfile != null;
|
||||||
public bool LayerSelected => (SelectedProfile != null) && (ProfileViewModel.SelectedLayer != null);
|
public bool LayerSelected => SelectedProfile != null && ProfileViewModel.SelectedLayer != null;
|
||||||
|
|
||||||
public void DragOver(IDropInfo dropInfo)
|
public void DragOver(IDropInfo dropInfo)
|
||||||
{
|
{
|
||||||
var source = dropInfo.Data as LayerModel;
|
var source = dropInfo.Data as LayerModel;
|
||||||
var target = dropInfo.TargetItem as LayerModel;
|
var target = dropInfo.TargetItem as LayerModel;
|
||||||
if ((source == null) || (target == null) || (source == target))
|
if (source == null || target == null || source == target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter) &&
|
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
||||||
target.LayerType is FolderType)
|
target.LayerType is FolderType)
|
||||||
{
|
{
|
||||||
dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
|
dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
|
||||||
@ -175,7 +175,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
{
|
{
|
||||||
var source = dropInfo.Data as LayerModel;
|
var source = dropInfo.Data as LayerModel;
|
||||||
var target = dropInfo.TargetItem as LayerModel;
|
var target = dropInfo.TargetItem as LayerModel;
|
||||||
if ((source == null) || (target == null) || (source == target))
|
if (source == null || target == null || source == target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't allow a folder to become it's own child, that's just weird
|
// Don't allow a folder to become it's own child, that's just weird
|
||||||
@ -196,7 +196,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
parent.FixOrder();
|
parent.FixOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter) &&
|
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
||||||
target.LayerType is FolderType)
|
target.LayerType is FolderType)
|
||||||
{
|
{
|
||||||
// Insert into folder
|
// Insert into folder
|
||||||
@ -208,9 +208,9 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Insert the source into it's new profile/parent and update the order
|
// Insert the source into it's new profile/parent and update the order
|
||||||
if ((dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
|
if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem ||
|
||||||
(dropInfo.InsertPosition ==
|
dropInfo.InsertPosition ==
|
||||||
(RelativeInsertPosition.TargetItemCenter | RelativeInsertPosition.AfterTargetItem)))
|
(RelativeInsertPosition.TargetItemCenter | RelativeInsertPosition.AfterTargetItem))
|
||||||
target.InsertAfter(source);
|
target.InsertAfter(source);
|
||||||
else
|
else
|
||||||
target.InsertBefore(source);
|
target.InsertBefore(source);
|
||||||
@ -237,7 +237,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
public void Deactivate()
|
public void Deactivate()
|
||||||
{
|
{
|
||||||
ProfileViewModel.Deactivate();
|
ProfileViewModel.Deactivate();
|
||||||
SelectedProfile?.Deactivate();
|
SelectedProfile?.Deactivate(_luaManager);
|
||||||
_saveTimer.Stop();
|
_saveTimer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
private void LoadProfiles()
|
private void LoadProfiles()
|
||||||
{
|
{
|
||||||
ProfileNames.Clear();
|
ProfileNames.Clear();
|
||||||
if ((_gameModel == null) || (_deviceManager.ActiveKeyboard == null))
|
if (_gameModel == null || _deviceManager.ActiveKeyboard == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ProfileNames.AddRange(ProfileProvider.GetProfileNames(_deviceManager.ActiveKeyboard, _gameModel));
|
ProfileNames.AddRange(ProfileProvider.GetProfileNames(_deviceManager.ActiveKeyboard, _gameModel));
|
||||||
@ -255,17 +255,13 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// If a profile name was provided, try to load it
|
// If a profile name was provided, try to load it
|
||||||
ProfileModel lastProfileModel = null;
|
ProfileModel lastProfileModel = null;
|
||||||
if (!string.IsNullOrEmpty(LastProfile))
|
if (!string.IsNullOrEmpty(LastProfile))
|
||||||
{
|
|
||||||
lastProfileModel = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _gameModel, LastProfile);
|
lastProfileModel = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _gameModel, LastProfile);
|
||||||
}
|
|
||||||
|
|
||||||
if (lastProfileModel != null)
|
if (lastProfileModel != null)
|
||||||
SelectedProfile = lastProfileModel;
|
SelectedProfile = lastProfileModel;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
SelectedProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _gameModel,
|
SelectedProfile = ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, _gameModel,
|
||||||
ProfileNames.FirstOrDefault());
|
ProfileNames.FirstOrDefault());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -532,7 +528,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
var name = await DialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
|
var name = await DialogService.ShowInputDialog("Rename profile", "Please enter a unique new profile name");
|
||||||
|
|
||||||
// Null when the user cancelled
|
// Null when the user cancelled
|
||||||
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
if (string.IsNullOrEmpty(name) || name.Length < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SelectedProfile.Name = name;
|
SelectedProfile.Name = name;
|
||||||
@ -544,7 +540,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
.ShowInputDialog("Name already in use", "Please enter a unique new profile name");
|
.ShowInputDialog("Name already in use", "Please enter a unique new profile name");
|
||||||
|
|
||||||
// Null when the user cancelled
|
// Null when the user cancelled
|
||||||
if (string.IsNullOrEmpty(name) || (name.Length < 2))
|
if (string.IsNullOrEmpty(name) || name.Length < 2)
|
||||||
{
|
{
|
||||||
SelectedProfile.Name = oldName;
|
SelectedProfile.Name = oldName;
|
||||||
return;
|
return;
|
||||||
@ -694,8 +690,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SelectedProfile?.Activate(_deviceManager.ActiveKeyboard);
|
SelectedProfile?.Activate(_luaManager);
|
||||||
LuaWrapper.OpenEditor();
|
_luaManager.OpenEditor();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -738,7 +734,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
public void SaveSelectedProfile()
|
public void SaveSelectedProfile()
|
||||||
{
|
{
|
||||||
if (_saving || (SelectedProfile == null) || _deviceManager.ChangingKeyboard)
|
if (_saving || SelectedProfile == null || _deviceManager.ChangingKeyboard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_saving = true;
|
_saving = true;
|
||||||
|
|||||||
@ -11,7 +11,6 @@ using Artemis.Modules.Effects.ProfilePreview;
|
|||||||
using Artemis.Profiles;
|
using Artemis.Profiles;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
using Artemis.Profiles.Layers.Types.Folder;
|
using Artemis.Profiles.Layers.Types.Folder;
|
||||||
using Artemis.Profiles.Lua;
|
|
||||||
using Artemis.Properties;
|
using Artemis.Properties;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
@ -103,10 +102,11 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
if (_blurProgress > 2)
|
if (_blurProgress > 2)
|
||||||
_blurProgress = 0;
|
_blurProgress = 0;
|
||||||
_blurProgress = _blurProgress + 0.025;
|
_blurProgress = _blurProgress + 0.025;
|
||||||
BlurRadius = (Math.Sin(_blurProgress*Math.PI) + 1)*10 + 10;
|
BlurRadius = (Math.Sin(_blurProgress * Math.PI) + 1) * 10 + 10;
|
||||||
|
|
||||||
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
|
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
|
||||||
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null || _deviceManager.ActiveKeyboard.Slug == "none")
|
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null ||
|
||||||
|
_deviceManager.ActiveKeyboard.Slug == "none")
|
||||||
{
|
{
|
||||||
var preview = new DrawingImage();
|
var preview = new DrawingImage();
|
||||||
preview.Freeze();
|
preview.Freeze();
|
||||||
@ -166,8 +166,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
|
new Point(layerRect.BottomRight.X - 0.7, layerRect.BottomRight.Y - 0.7));
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaWrapper.LuaEventsWrapper?.InvokeDeviceDraw(SelectedProfile, "preview", new ProfilePreviewDataModel(),
|
SelectedProfile.RaiseDeviceDrawnEvent(new ProfileDeviceEventsArg("preview",
|
||||||
true, drawingContext);
|
new ProfilePreviewDataModel(), true, drawingContext));
|
||||||
|
|
||||||
// Remove the clip
|
// Remove the clip
|
||||||
drawingContext.Pop();
|
drawingContext.Pop();
|
||||||
@ -223,8 +223,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
var keyboard = _deviceManager.ActiveKeyboard;
|
var keyboard = _deviceManager.ActiveKeyboard;
|
||||||
var pos = e.GetPosition((Image) e.OriginalSource);
|
var pos = e.GetPosition((Image) e.OriginalSource);
|
||||||
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
var x = pos.X / ((double) keyboard.PreviewSettings.Width / keyboard.Width);
|
||||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
var y = pos.Y / ((double) keyboard.PreviewSettings.Height / keyboard.Height);
|
||||||
|
|
||||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||||
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||||
@ -244,8 +244,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
var pos = e.GetPosition((Image) e.OriginalSource);
|
var pos = e.GetPosition((Image) e.OriginalSource);
|
||||||
var keyboard = _deviceManager.ActiveKeyboard;
|
var keyboard = _deviceManager.ActiveKeyboard;
|
||||||
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
var x = pos.X / ((double) keyboard.PreviewSettings.Width / keyboard.Width);
|
||||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
var y = pos.Y / ((double) keyboard.PreviewSettings.Height / keyboard.Height);
|
||||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||||
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||||
|
|
||||||
@ -267,7 +267,9 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
: Cursors.SizeAll;
|
: Cursors.SizeAll;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
KeyboardPreviewCursor = Cursors.Hand;
|
KeyboardPreviewCursor = Cursors.Hand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cursor KeyboardPreviewCursor
|
public Cursor KeyboardPreviewCursor
|
||||||
@ -292,14 +294,14 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
{
|
{
|
||||||
// Reset the dragging state on mouse release
|
// Reset the dragging state on mouse release
|
||||||
if (e.LeftButton == MouseButtonState.Released ||
|
if (e.LeftButton == MouseButtonState.Released ||
|
||||||
(_draggingLayer != null && SelectedLayer != _draggingLayer))
|
_draggingLayer != null && SelectedLayer != _draggingLayer)
|
||||||
{
|
{
|
||||||
_draggingLayerOffset = null;
|
_draggingLayerOffset = null;
|
||||||
_draggingLayer = null;
|
_draggingLayer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedLayer == null || (SelectedLayer.LayerType != null && !SelectedLayer.LayerType.ShowInEdtor))
|
if (SelectedLayer == null || SelectedLayer.LayerType != null && !SelectedLayer.LayerType.ShowInEdtor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Setup the dragging state on mouse press
|
// Setup the dragging state on mouse press
|
||||||
@ -314,7 +316,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6;
|
Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_draggingLayerOffset == null || _draggingLayer == null || (_draggingLayer != SelectedLayer))
|
if (_draggingLayerOffset == null || _draggingLayer == null || _draggingLayer != SelectedLayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var draggingProps = _draggingLayer.Properties;
|
var draggingProps = _draggingLayer.Properties;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ using Artemis86Wrapper.Intergrations.Skype;
|
|||||||
|
|
||||||
namespace Artemis86Wrapper
|
namespace Artemis86Wrapper
|
||||||
{
|
{
|
||||||
internal class Program
|
public class Program
|
||||||
{
|
{
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user