From 1d47a9f77d6a2b983d4b77ae37655b2eeab8e473 Mon Sep 17 00:00:00 2001 From: Tyler Jaacks Date: Wed, 26 Jul 2017 13:58:11 -0500 Subject: [PATCH 1/3] Added Orisa and Doomfist to the OverwatchCharacter, and added Orisa and Doomfist to CharacterColor in OverwatchModel. --- Artemis/Artemis/Modules/Games/Overwatch/OverwatchDataModel.cs | 4 +++- Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchDataModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchDataModel.cs index d88a3a28e..72895b27d 100644 --- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchDataModel.cs +++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchDataModel.cs @@ -48,6 +48,8 @@ namespace Artemis.Modules.Games.Overwatch Symmetra, Zenyatta, Ana, - Sombra + Sombra, + Orisa, + Doomfist } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs index 819611cb0..3454a954b 100644 --- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs +++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs @@ -76,7 +76,9 @@ namespace Artemis.Modules.Games.Overwatch new CharacterColor {Character = OverwatchCharacter.Symmetra, Color = Color.FromRgb(46, 116, 148)}, 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.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)} }; } From a09649e9d08f4002284ddc032f4413b2f20f61b6 Mon Sep 17 00:00:00 2001 From: Tyler Jaacks Date: Wed, 26 Jul 2017 14:59:24 -0500 Subject: [PATCH 2/3] Added initial imlementation of LuaSlider, still needs event system. --- .../Profiles/Lua/Modules/Gui/LuaSlider.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs diff --git a/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs new file mode 100644 index 000000000..0dcb8b958 --- /dev/null +++ b/Artemis/Artemis/Profiles/Lua/Modules/Gui/LuaSlider.cs @@ -0,0 +1,42 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using Artemis.Managers; +using MoonSharp.Interpreter; +using MoonSharp.Interpreter.Interop; + +namespace Artemis.Profiles.Lua.Modules.Gui +{ + [MoonSharpUserData] + class LuaSlider + { + private readonly LuaManager _luaManager; + + public LuaSlider(LuaManager luaManager, int interval, double intialValue, double x, double y, double? width, double? height) + { + _luaManager = luaManager; + + Slider = new Slider { Value = intialValue, Interval = interval }; + + if (width != null) + Slider.Width = width.Value; + if (height != null) + Slider.Height = height.Value; + } + + [MoonSharpVisible(false)] + public Slider Slider { get; } + + public double Value + { + get => Slider.Dispatcher.Invoke(() => (double) Slider.Value); + set => Slider.Dispatcher.Invoke(() => Slider.Value = value); + } + + public int Interval + { + get => Slider.Dispatcher.Invoke(() => (int) Slider.Interval); + set => Slider.Dispatcher.Invoke(() => Slider.Interval = value); + } + } +} \ No newline at end of file From 75a556f07d9828e423f4e779fee3cf63324901c6 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Fri, 28 Jul 2017 19:33:02 +0200 Subject: [PATCH 3/3] Adjust Overwatch colors Add slider creation method Add slider changed event Add minimum and maximum to slider Show slider ticks Snap to slider ticks --- Artemis/Artemis/Artemis.csproj | 1 + .../Modules/Games/Overwatch/OverwatchModel.cs | 4 ++-- .../Profiles/Lua/Modules/Gui/LuaSlider.cs | 21 ++++++++++++++++--- .../Lua/Modules/Gui/LuaWindowViewModel.cs | 12 +++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) 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);