1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge pull request #383 from TylerJaacks/master

Added the new Overwatch Characters and added initial implementation of LuaSlider.
This commit is contained in:
Robert Beekman 2017-08-01 22:25:42 +02:00 committed by GitHub
commit f05cf0b6d9
5 changed files with 76 additions and 2 deletions

View File

@ -574,6 +574,7 @@
<Compile Include="Profiles\Lua\Modules\Gui\LuaCheckBox.cs" />
<Compile Include="Profiles\Lua\Modules\Gui\LuaComboBox.cs" />
<Compile Include="Profiles\Lua\Modules\Gui\LuaLabel.cs" />
<Compile Include="Profiles\Lua\Modules\Gui\LuaSlider.cs" />
<Compile Include="Profiles\Lua\Modules\Gui\LuaTextBox.cs" />
<Compile Include="Profiles\Lua\Modules\Gui\LuaWindowView.xaml.cs">
<DependentUpon>LuaWindowView.xaml</DependentUpon>

View File

@ -48,6 +48,8 @@ namespace Artemis.Modules.Games.Overwatch
Symmetra,
Zenyatta,
Ana,
Sombra
Sombra,
Orisa,
Doomfist
}
}

View File

@ -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(1,40,0)},
new CharacterColor {Character = OverwatchCharacter.Doomfist, Color = Color.FromRgb(33, 3, 1)}
};
}

View File

@ -0,0 +1,57 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Artemis.Managers;
using MoonSharp.Interpreter;
using MoonSharp.Interpreter.Interop;
namespace Artemis.Profiles.Lua.Modules.Gui
{
[MoonSharpUserData]
public class LuaSlider
{
private readonly LuaManager _luaManager;
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, 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)]
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);
}
private void SliderOnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> routedPropertyChangedEventArgs)
{
_luaManager.EventsModule.LuaInvoke(_luaManager.ProfileModel, () => OnValueChanged(this));
}
public event EventHandler<EventArgs> ValueChanged;
protected virtual void OnValueChanged(LuaSlider slider)
{
ValueChanged?.Invoke(slider, null);
}
}
}

View File

@ -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);