mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
commit
62ef77662e
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
using Artemis.Models.Interfaces;
|
using System.ComponentModel;
|
||||||
|
using Artemis.Models.Interfaces;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.UnrealTournament
|
namespace Artemis.Modules.Games.UnrealTournament
|
||||||
@ -25,6 +26,19 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
public PlayerState State { get; set; }
|
public PlayerState State { get; set; }
|
||||||
public Inventory Inventory { get; set; }
|
public Inventory Inventory { get; set; }
|
||||||
public Weapon Weapon { get; set; }
|
public Weapon Weapon { get; set; }
|
||||||
|
|
||||||
|
[DefaultValue("None")]
|
||||||
|
public KillState KillState { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum KillState
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Kill = 1,
|
||||||
|
DoubleKill = 2,
|
||||||
|
MultiKill = 3,
|
||||||
|
UltraKill = 4,
|
||||||
|
MonsterKill = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerState
|
public class PlayerState
|
||||||
@ -101,11 +115,11 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
public bool bCasterControl { get; set; }
|
public bool bCasterControl { get; set; }
|
||||||
public bool bForcedBalance { get; set; }
|
public bool bForcedBalance { get; set; }
|
||||||
public bool bPlayPlayerIntro { get; set; }
|
public bool bPlayPlayerIntro { get; set; }
|
||||||
public int TimeLimit { get; set; }
|
public float TimeLimit { get; set; }
|
||||||
public int SpawnProtectionTime { get; set; }
|
public float SpawnProtectionTime { get; set; }
|
||||||
public int RemainingTime { get; set; }
|
public float RemainingTime { get; set; }
|
||||||
public int ElapsedTime { get; set; }
|
public float ElapsedTime { get; set; }
|
||||||
public int RespawnWaitTime { get; set; }
|
public float RespawnWaitTime { get; set; }
|
||||||
public int ForceRespawnTime { get; set; }
|
public float ForceRespawnTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Timers;
|
||||||
using Artemis.DAL;
|
using Artemis.DAL;
|
||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models;
|
using Artemis.Models;
|
||||||
@ -10,6 +11,9 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
{
|
{
|
||||||
public class UnrealTournamentModel : GameModel
|
public class UnrealTournamentModel : GameModel
|
||||||
{
|
{
|
||||||
|
private Timer _killTimer;
|
||||||
|
private int _lastScore;
|
||||||
|
|
||||||
public UnrealTournamentModel(MainManager mainManager)
|
public UnrealTournamentModel(MainManager mainManager)
|
||||||
: base(mainManager, SettingsProvider.Load<UnrealTournamentSettings>(), new UnrealTournamentDataModel())
|
: base(mainManager, SettingsProvider.Load<UnrealTournamentSettings>(), new UnrealTournamentDataModel())
|
||||||
{
|
{
|
||||||
@ -18,6 +22,9 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
Scale = 4;
|
Scale = 4;
|
||||||
Enabled = Settings.Enabled;
|
Enabled = Settings.Enabled;
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
|
_killTimer = new Timer(3500);
|
||||||
|
_killTimer.Elapsed += KillTimerOnElapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
@ -25,12 +32,16 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
|
_killTimer.Stop();
|
||||||
MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage;
|
MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
|
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
|
||||||
|
_killTimer.Start();
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +53,7 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
// Parse the JSON
|
// Parse the JSON
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataModel = JsonConvert.DeserializeObject<UnrealTournamentDataModel>(message);
|
JsonConvert.PopulateObject(message, DataModel);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -52,6 +63,34 @@ namespace Artemis.Modules.Games.UnrealTournament
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
var utDataModel = (UnrealTournamentDataModel) DataModel;
|
||||||
|
if (utDataModel.Player?.State?.Score == _lastScore)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Reset the timer
|
||||||
|
_killTimer.Stop();
|
||||||
|
_killTimer.Start();
|
||||||
|
if (utDataModel.Player?.State != null)
|
||||||
|
{
|
||||||
|
// Can't go past MonsterKill in the current version of UT
|
||||||
|
if (utDataModel.Player.KillState != KillState.MonsterKill)
|
||||||
|
{
|
||||||
|
var recentKills = utDataModel.Player.State.Score - _lastScore;
|
||||||
|
utDataModel.Player.KillState = (KillState) ((int) utDataModel.Player.KillState + recentKills);
|
||||||
|
}
|
||||||
|
_lastScore = utDataModel.Player.State.Score;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_lastScore = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void KillTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
|
||||||
|
{
|
||||||
|
var dataModel = (UnrealTournamentDataModel) DataModel;
|
||||||
|
if (dataModel.Player != null)
|
||||||
|
dataModel.Player.KillState = KillState.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
// Reset animation progress if layer wasn't drawn for 100ms
|
// Reset animation progress if layer wasn't drawn for 100ms
|
||||||
if (new TimeSpan(0, 0, 0, 0, 100) > DateTime.Now - layerModel.LastRender)
|
if (new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender)
|
||||||
layerModel.Properties.AnimationProgress = 0;
|
layerModel.Properties.AnimationProgress = 0;
|
||||||
|
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.Properties.AnimationProgress;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Generic
|
|||||||
|
|
||||||
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||||
{
|
{
|
||||||
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
|
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
|
||||||
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
||||||
|
|
||||||
SelectedLayerAnimation =
|
SelectedLayerAnimation =
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Headset
|
|||||||
|
|
||||||
public HeadsetPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
public HeadsetPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||||
{
|
{
|
||||||
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
|
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
|
||||||
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
||||||
|
|
||||||
SelectedLayerAnimation =
|
SelectedLayerAnimation =
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
|
|
||||||
public KeyboardPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
public KeyboardPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||||
{
|
{
|
||||||
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
|
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
|
||||||
|
|
||||||
HeightProperties = new LayerDynamicPropertiesViewModel("Height", editorVm);
|
HeightProperties = new LayerDynamicPropertiesViewModel("Height", editorVm);
|
||||||
WidthProperties = new LayerDynamicPropertiesViewModel("Width", editorVm);
|
WidthProperties = new LayerDynamicPropertiesViewModel("Width", editorVm);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Mouse
|
|||||||
|
|
||||||
public MousePropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
public MousePropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||||
{
|
{
|
||||||
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
|
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
|
||||||
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
||||||
|
|
||||||
SelectedLayerAnimation =
|
SelectedLayerAnimation =
|
||||||
|
|||||||
@ -52,5 +52,5 @@ using System.Windows;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.3.1.0")]
|
[assembly: AssemblyVersion("1.3.2.0")]
|
||||||
[assembly: AssemblyFileVersion("1.3.1.0")]
|
[assembly: AssemblyFileVersion("1.3.2.0")]
|
||||||
@ -27,13 +27,13 @@ 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> animations)
|
List<ILayerAnimation> layerAnimations)
|
||||||
{
|
{
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
ProposedLayer = Clone(layer);
|
ProposedLayer = Clone(layer);
|
||||||
DataModel = DataModel;
|
DataModel = DataModel;
|
||||||
Types = new BindableCollection<ILayerType>(types);
|
LayerTypes = new BindableCollection<ILayerType>(types);
|
||||||
Animations = animations;
|
LayerAnimations = layerAnimations;
|
||||||
|
|
||||||
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
|
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
[Inject]
|
[Inject]
|
||||||
public MetroDialogService DialogService { get; set; }
|
public MetroDialogService DialogService { get; set; }
|
||||||
|
|
||||||
public BindableCollection<ILayerType> Types { get; set; }
|
public BindableCollection<ILayerType> LayerTypes { get; set; }
|
||||||
public BindableCollection<PropertyCollection> DataModelProps { get; set; }
|
public BindableCollection<PropertyCollection> DataModelProps { get; set; }
|
||||||
public BindableCollection<LayerConditionViewModel> LayerConditionVms { get; set; }
|
public BindableCollection<LayerConditionViewModel> LayerConditionVms { get; set; }
|
||||||
public bool KeyboardGridIsVisible => ProposedLayer.LayerType is KeyboardType;
|
public bool KeyboardGridIsVisible => ProposedLayer.LayerType is KeyboardType;
|
||||||
@ -72,7 +72,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ILayerAnimation> Animations { get; set; }
|
public List<ILayerAnimation> LayerAnimations { get; set; }
|
||||||
|
|
||||||
public LayerModel ProposedLayer
|
public LayerModel ProposedLayer
|
||||||
{
|
{
|
||||||
@ -120,7 +120,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
public void PreSelect()
|
public void PreSelect()
|
||||||
{
|
{
|
||||||
SelectedLayerType = Types.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
||||||
ToggleIsEvent();
|
ToggleIsEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +166,8 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
LayerPropertiesViewModel?.ApplyProperties();
|
LayerPropertiesViewModel?.ApplyProperties();
|
||||||
|
|
||||||
Layer.Properties.DynamicProperties.Clear();
|
Layer.Properties.DynamicProperties.Clear();
|
||||||
Layer.Properties.Conditions.Clear();
|
|
||||||
JsonConvert.PopulateObject(JsonConvert.SerializeObject(ProposedLayer), Layer);
|
JsonConvert.PopulateObject(JsonConvert.SerializeObject(ProposedLayer), Layer);
|
||||||
|
Layer.Properties.Conditions.Clear();
|
||||||
foreach (var conditionViewModel in LayerConditionVms)
|
foreach (var conditionViewModel in LayerConditionVms)
|
||||||
Layer.Properties.Conditions.Add(conditionViewModel.LayerConditionModel);
|
Layer.Properties.Conditions.Add(conditionViewModel.LayerConditionModel);
|
||||||
|
|
||||||
|
|||||||
@ -352,16 +352,22 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
|
|
||||||
private List<LayerModel> GetLayers()
|
private List<LayerModel> GetLayers()
|
||||||
{
|
{
|
||||||
// Get the layers that must be drawn
|
if (SelectedLayer == null)
|
||||||
List<LayerModel> drawLayers;
|
return new List<LayerModel>();
|
||||||
if (ShowAll)
|
|
||||||
drawLayers = SelectedProfile.GetLayers();
|
|
||||||
else if (SelectedLayer.LayerType is FolderType)
|
|
||||||
drawLayers = SelectedLayer.GetLayers().ToList();
|
|
||||||
else
|
|
||||||
drawLayers = new List<LayerModel> {SelectedLayer};
|
|
||||||
|
|
||||||
return drawLayers;
|
lock (SelectedLayer)
|
||||||
|
{
|
||||||
|
// Get the layers that must be drawn
|
||||||
|
List<LayerModel> drawLayers;
|
||||||
|
if (ShowAll)
|
||||||
|
drawLayers = SelectedProfile.GetLayers();
|
||||||
|
else if (SelectedLayer.LayerType is FolderType)
|
||||||
|
drawLayers = SelectedLayer.GetLayers().ToList();
|
||||||
|
else
|
||||||
|
drawLayers = new List<LayerModel> {SelectedLayer};
|
||||||
|
|
||||||
|
return drawLayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user