mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed profile saving, expanded Overwatch data model
This commit is contained in:
parent
0b889c3b0c
commit
b01f9485ae
@ -5,13 +5,42 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
public class OverwatchDataModel : IGameDataModel
|
public class OverwatchDataModel : IGameDataModel
|
||||||
{
|
{
|
||||||
public OverwatchStatus Status { get; set; }
|
public OverwatchStatus Status { get; set; }
|
||||||
|
public OverwatchCharacter Character { get; set; }
|
||||||
|
public bool UltimateReady { get; set; }
|
||||||
|
public bool Ability1Ready { get; set; }
|
||||||
|
public bool Ability2Ready { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OverwatchStatus
|
public enum OverwatchStatus
|
||||||
{
|
{
|
||||||
Unkown,
|
Unkown,
|
||||||
InMainMenu,
|
InMainMenu,
|
||||||
InCharacterSelection,
|
|
||||||
InGame
|
InGame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum OverwatchCharacter
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Genji,
|
||||||
|
Mccree,
|
||||||
|
Pharah,
|
||||||
|
Reaper,
|
||||||
|
Soldier76,
|
||||||
|
Tracer,
|
||||||
|
Bastion,
|
||||||
|
Hanzo,
|
||||||
|
Junkrat,
|
||||||
|
Mei,
|
||||||
|
Torbjörn,
|
||||||
|
Widowmaker,
|
||||||
|
Dva,
|
||||||
|
Reinhardt,
|
||||||
|
Roadhog,
|
||||||
|
Winston,
|
||||||
|
Zarya,
|
||||||
|
Lúcio,
|
||||||
|
Mercy,
|
||||||
|
Symmetra,
|
||||||
|
Zenyatta
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq.Dynamic;
|
using System.Linq;
|
||||||
using Artemis.Events;
|
using Artemis.Events;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
@ -28,12 +28,51 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
MmfReader = new MmfReader("overwatchMmf");
|
MmfReader = new MmfReader("overwatchMmf");
|
||||||
|
LoadOverwatchCharacters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CharacterColor> OverwatchCharacters { get; set; }
|
||||||
|
|
||||||
public MmfReader MmfReader { get; set; }
|
public MmfReader MmfReader { get; set; }
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
|
|
||||||
|
private void LoadOverwatchCharacters()
|
||||||
|
{
|
||||||
|
OverwatchCharacters = new List<CharacterColor>
|
||||||
|
{
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Genji, Color = Color.FromRgb(13, 61, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Mccree, Color = Color.FromRgb(24, 1, 1)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Pharah, Color = Color.FromRgb(0, 6, 32)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Reaper, Color = Color.FromRgb(7, 0, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Soldier76, Color = Color.FromRgb(3, 5, 11)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Tracer, Color = Color.FromRgb(46, 12, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Bastion, Color = Color.FromRgb(6, 10, 5)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Hanzo, Color = Color.FromRgb(28, 24, 8)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Junkrat, Color = Color.FromRgb(59, 28, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Mei, Color = Color.FromRgb(3, 20, 55)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Torbjörn, Color = Color.FromRgb(31, 4, 3)},
|
||||||
|
new CharacterColor
|
||||||
|
{
|
||||||
|
OverwatchCharacter = OverwatchCharacter.Widowmaker,
|
||||||
|
Color = Color.FromRgb(16, 3, 17)
|
||||||
|
},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Dva, Color = Color.FromRgb(62, 12, 32)},
|
||||||
|
new CharacterColor
|
||||||
|
{
|
||||||
|
OverwatchCharacter = OverwatchCharacter.Reinhardt,
|
||||||
|
Color = Color.FromRgb(12, 16, 16)
|
||||||
|
},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Roadhog, Color = Color.FromRgb(26, 10, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Winston, Color = Color.FromRgb(17, 18, 26)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Zarya, Color = Color.FromRgb(58, 7, 24)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Lúcio, Color = Color.FromRgb(8, 35, 0)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Mercy, Color = Color.FromRgb(60, 56, 26)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Symmetra, Color = Color.FromRgb(11, 29, 37)},
|
||||||
|
new CharacterColor {OverwatchCharacter = OverwatchCharacter.Zenyatta, Color = Color.FromRgb(62, 54, 6)}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
@ -59,15 +98,34 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
{
|
{
|
||||||
for (var x = 0; x < 22; x++)
|
for (var x = 0; x < 22; x++)
|
||||||
{
|
{
|
||||||
g.DrawRectangle(new Pen(ColorHelpers.ToDrawingColor(colors[y, x])), y, x, 1, 1 );
|
g.DrawRectangle(new Pen(ColorHelpers.ToDrawingColor(colors[y, x])), y, x, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
_events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
||||||
if (colors[0, 0].Equals(Color.FromRgb(55, 30, 0)))
|
|
||||||
gameDataModel.Status = OverwatchStatus.InMainMenu;
|
// Determine general game state
|
||||||
else if (colors[0, 0].Equals(Color.FromRgb(3, 5, 11)))
|
gameDataModel.Status = colors[0, 0].Equals(Color.FromRgb(55, 30, 0))
|
||||||
gameDataModel.Status = OverwatchStatus.InGame;
|
? OverwatchStatus.InMainMenu
|
||||||
|
: OverwatchStatus.Unkown;
|
||||||
|
|
||||||
|
if (gameDataModel.Status == OverwatchStatus.InMainMenu)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If ingame, look for a character
|
||||||
|
var characterMatch = OverwatchCharacters.FirstOrDefault(c => c.Color == colors[0, 0]);
|
||||||
|
if (characterMatch.OverwatchCharacter == OverwatchCharacter.None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gameDataModel.Status = OverwatchStatus.InGame;
|
||||||
|
gameDataModel.Character = characterMatch.OverwatchCharacter;
|
||||||
|
|
||||||
|
// Ability1 is ready when LShift is lid
|
||||||
|
gameDataModel.Ability1Ready = colors[4, 1].Equals(Color.FromRgb(4, 141, 144));
|
||||||
|
// Ability2 is ready when E is lid
|
||||||
|
gameDataModel.Ability2Ready = colors[2, 4].Equals(Color.FromRgb(4, 141, 144));
|
||||||
|
// Ultimate is ready when Q is blinking
|
||||||
|
gameDataModel.UltimateReady = !characterMatch.Color.Equals(colors[2, 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
@ -89,4 +147,10 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
return Profile?.GenerateBrush<OverwatchDataModel>(GameDataModel, LayerType.Headset, false, true);
|
return Profile?.GenerateBrush<OverwatchDataModel>(GameDataModel, LayerType.Headset, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct CharacterColor
|
||||||
|
{
|
||||||
|
public OverwatchCharacter OverwatchCharacter { get; set; }
|
||||||
|
public Color Color { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -83,6 +83,8 @@ namespace Artemis.Utilities
|
|||||||
friendlyName = "(Number)";
|
friendlyName = "(Number)";
|
||||||
else if (propertyInfo.PropertyType.Name == "String")
|
else if (propertyInfo.PropertyType.Name == "String")
|
||||||
friendlyName = "(Text)";
|
friendlyName = "(Text)";
|
||||||
|
else if (propertyInfo.PropertyType.Name == "Boolean")
|
||||||
|
friendlyName = "(Yes/no)";
|
||||||
if (propertyInfo.PropertyType.BaseType?.Name == "Enum")
|
if (propertyInfo.PropertyType.BaseType?.Name == "Enum")
|
||||||
friendlyName = "(Choice)";
|
friendlyName = "(Choice)";
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
{
|
{
|
||||||
private readonly NamedOperator[] _boolOperators =
|
private readonly NamedOperator[] _boolOperators =
|
||||||
{
|
{
|
||||||
new NamedOperator("True", "== True"),
|
new NamedOperator("Equal to", "==")
|
||||||
new NamedOperator("False", "== False")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly LayerEditorViewModel _conditionModel;
|
private readonly LayerEditorViewModel _conditionModel;
|
||||||
@ -114,7 +113,6 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
get { return _selectedOperator; }
|
get { return _selectedOperator; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value.Equals(_selectedOperator)) return;
|
|
||||||
_selectedOperator = value;
|
_selectedOperator = value;
|
||||||
NotifyOfPropertyChange(() => SelectedOperator);
|
NotifyOfPropertyChange(() => SelectedOperator);
|
||||||
}
|
}
|
||||||
@ -142,6 +140,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Operators.Clear();
|
Operators.Clear();
|
||||||
|
Enums.Clear();
|
||||||
UserValueIsVisible = false;
|
UserValueIsVisible = false;
|
||||||
EnumValueIsVisible = false;
|
EnumValueIsVisible = false;
|
||||||
|
|
||||||
@ -153,6 +152,9 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
break;
|
break;
|
||||||
case "Boolean":
|
case "Boolean":
|
||||||
Operators.AddRange(_boolOperators);
|
Operators.AddRange(_boolOperators);
|
||||||
|
Enums.Add("True");
|
||||||
|
Enums.Add("False");
|
||||||
|
EnumValueIsVisible = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Operators.AddRange(_operators);
|
Operators.AddRange(_operators);
|
||||||
@ -193,7 +195,13 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
LayerConditionModel.Field = SelectedDataModelProp.Path;
|
LayerConditionModel.Field = SelectedDataModelProp.Path;
|
||||||
LayerConditionModel.Operator = SelectedOperator.Value;
|
LayerConditionModel.Operator = SelectedOperator.Value;
|
||||||
LayerConditionModel.Type = SelectedDataModelProp.Type;
|
LayerConditionModel.Type = SelectedDataModelProp.Type;
|
||||||
LayerConditionModel.Value = SelectedDataModelProp.Type == "Enum" ? SelectedEnum : UserValue;
|
|
||||||
|
if (SelectedDataModelProp.Type == "Enum" || SelectedDataModelProp.Type == "Boolean")
|
||||||
|
LayerConditionModel.Value = SelectedEnum;
|
||||||
|
else
|
||||||
|
LayerConditionModel.Value = UserValue;
|
||||||
|
|
||||||
|
UpdateForm(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -48,6 +48,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
|
|
||||||
|
ProfileViewModel.PropertyChanged += PropertyChangeHandler;
|
||||||
PropertyChanged += PropertyChangeHandler;
|
PropertyChanged += PropertyChangeHandler;
|
||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user