diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 5f0aea86c..1f6bdac10 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -573,6 +573,7 @@ + LuaWindowView.xaml diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs index 3454a954b..4a216cd99 100644 --- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs +++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs @@ -77,8 +77,8 @@ namespace Artemis.Modules.Games.Overwatch new CharacterColor {Character = OverwatchCharacter.Zenyatta, Color = Color.FromRgb(248, 218, 26)}, new CharacterColor {Character = OverwatchCharacter.Ana, Color = Color.FromRgb(16, 36, 87)}, new CharacterColor {Character = OverwatchCharacter.Sombra, Color = Color.FromRgb(20, 5, 101)}, - new CharacterColor {Character = OverwatchCharacter.Orisa, Color = Color.FromRgb(194,233,78)}, - new CharacterColor {Character = OverwatchCharacter.Doomfist, Color = Color.FromRgb(207, 137, 77)} + new CharacterColor {Character = OverwatchCharacter.Orisa, Color = Color.FromRgb(1,40,0)}, + new CharacterColor {Character = OverwatchCharacter.Doomfist, Color = Color.FromRgb(33, 3, 1)} }; } diff --git a/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs index 0dcb8b958..0a14af4f8 100644 --- a/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs +++ b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs @@ -1,6 +1,7 @@ using System; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using Artemis.Managers; using MoonSharp.Interpreter; using MoonSharp.Interpreter.Interop; @@ -8,20 +9,22 @@ using MoonSharp.Interpreter.Interop; namespace Artemis.Profiles.Lua.Modules.Gui { [MoonSharpUserData] - class LuaSlider + public class LuaSlider { private readonly LuaManager _luaManager; - public LuaSlider(LuaManager luaManager, int interval, double intialValue, double x, double y, double? width, double? height) + public LuaSlider(LuaManager luaManager, int interval, double intialValue, double minimum, double maximum, double x, double y, double? width, double? height) { _luaManager = luaManager; - Slider = new Slider { Value = intialValue, Interval = interval }; + Slider = new Slider { Value = intialValue, TickFrequency = interval, Minimum = minimum, Maximum = maximum, TickPlacement = TickPlacement.BottomRight, IsSnapToTickEnabled = true}; if (width != null) Slider.Width = width.Value; if (height != null) Slider.Height = height.Value; + + Slider.ValueChanged += SliderOnValueChanged; } [MoonSharpVisible(false)] @@ -38,5 +41,17 @@ namespace Artemis.Profiles.Lua.Modules.Gui get => Slider.Dispatcher.Invoke(() => (int) Slider.Interval); set => Slider.Dispatcher.Invoke(() => Slider.Interval = value); } + + private void SliderOnValueChanged(object sender, RoutedPropertyChangedEventArgs routedPropertyChangedEventArgs) + { + _luaManager.EventsModule.LuaInvoke(_luaManager.ProfileModel, () => OnValueChanged(this)); + } + + public event EventHandler ValueChanged; + + protected virtual void OnValueChanged(LuaSlider slider) + { + ValueChanged?.Invoke(slider, null); + } } } \ No newline at end of file diff --git a/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaWindowViewModel.cs b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaWindowViewModel.cs index 5c927cdb1..f7201069e 100644 --- a/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaWindowViewModel.cs +++ b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaWindowViewModel.cs @@ -83,6 +83,18 @@ namespace Artemis.Profiles.Lua.Modules.Gui return element; } + public LuaSlider CreateSlider(int interval, double initialValue, double minimum, double maximum, double x, double y, double? width = 200.0, double? height = 20.0) + { + LuaSlider element = null; + Execute.OnUIThread(() => + { + element = new LuaSlider(_luaManager, interval, initialValue, minimum, maximum, x, y, width, height); + AddControl(element.Slider, x, y); + }); + + return element; + } + private void AddControl(UIElement uiElement, double x, double y) { Canvas.Children.Add(uiElement);