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

Merge pull request #152 from SpoinkyNL/development

1.3.2.0
This commit is contained in:
Robert Beekman 2016-09-01 14:13:05 +02:00 committed by GitHub
commit 62ef77662e
11 changed files with 90 additions and 31 deletions

View File

@ -1,4 +1,5 @@
using Artemis.Models.Interfaces;
using System.ComponentModel;
using Artemis.Models.Interfaces;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.UnrealTournament
@ -25,6 +26,19 @@ namespace Artemis.Modules.Games.UnrealTournament
public PlayerState State { get; set; }
public Inventory Inventory { 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
@ -101,11 +115,11 @@ namespace Artemis.Modules.Games.UnrealTournament
public bool bCasterControl { get; set; }
public bool bForcedBalance { get; set; }
public bool bPlayPlayerIntro { get; set; }
public int TimeLimit { get; set; }
public int SpawnProtectionTime { get; set; }
public int RemainingTime { get; set; }
public int ElapsedTime { get; set; }
public int RespawnWaitTime { get; set; }
public int ForceRespawnTime { get; set; }
public float TimeLimit { get; set; }
public float SpawnProtectionTime { get; set; }
public float RemainingTime { get; set; }
public float ElapsedTime { get; set; }
public float RespawnWaitTime { get; set; }
public float ForceRespawnTime { get; set; }
}
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Timers;
using Artemis.DAL;
using Artemis.Managers;
using Artemis.Models;
@ -10,6 +11,9 @@ namespace Artemis.Modules.Games.UnrealTournament
{
public class UnrealTournamentModel : GameModel
{
private Timer _killTimer;
private int _lastScore;
public UnrealTournamentModel(MainManager mainManager)
: base(mainManager, SettingsProvider.Load<UnrealTournamentSettings>(), new UnrealTournamentDataModel())
{
@ -18,6 +22,9 @@ namespace Artemis.Modules.Games.UnrealTournament
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
_killTimer = new Timer(3500);
_killTimer.Elapsed += KillTimerOnElapsed;
}
public int Scale { get; set; }
@ -25,12 +32,16 @@ namespace Artemis.Modules.Games.UnrealTournament
public override void Dispose()
{
Initialized = false;
_killTimer.Stop();
MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage;
}
public override void Enable()
{
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
_killTimer.Start();
Initialized = true;
}
@ -42,7 +53,7 @@ namespace Artemis.Modules.Games.UnrealTournament
// Parse the JSON
try
{
DataModel = JsonConvert.DeserializeObject<UnrealTournamentDataModel>(message);
JsonConvert.PopulateObject(message, DataModel);
}
catch (Exception)
{
@ -52,6 +63,34 @@ namespace Artemis.Modules.Games.UnrealTournament
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)

View File

@ -13,7 +13,7 @@ namespace Artemis.Profiles.Layers.Animations
public void Update(LayerModel layerModel, bool updateAnimations)
{
// 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;
var progress = layerModel.Properties.AnimationProgress;

View File

@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Generic
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
{
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
SelectedLayerAnimation =

View File

@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Headset
public HeadsetPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
{
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
SelectedLayerAnimation =

View File

@ -15,7 +15,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
public KeyboardPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
{
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
HeightProperties = new LayerDynamicPropertiesViewModel("Height", editorVm);
WidthProperties = new LayerDynamicPropertiesViewModel("Width", editorVm);

View File

@ -12,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Mouse
public MousePropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
{
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.Animations);
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
SelectedLayerAnimation =

View File

@ -52,5 +52,5 @@ using System.Windows;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]

View File

@ -27,13 +27,13 @@ namespace Artemis.ViewModels.Profiles
private ILayerType _selectedLayerType;
public LayerEditorViewModel(LayerModel layer, IDataModel dataModel, IEnumerable<ILayerType> types,
List<ILayerAnimation> animations)
List<ILayerAnimation> layerAnimations)
{
Layer = layer;
ProposedLayer = Clone(layer);
DataModel = DataModel;
Types = new BindableCollection<ILayerType>(types);
Animations = animations;
LayerTypes = new BindableCollection<ILayerType>(types);
LayerAnimations = layerAnimations;
DataModelProps = new BindableCollection<PropertyCollection>(GenerateTypeMap(dataModel));
@ -55,7 +55,7 @@ namespace Artemis.ViewModels.Profiles
[Inject]
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<LayerConditionViewModel> LayerConditionVms { get; set; }
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
{
@ -120,7 +120,7 @@ namespace Artemis.ViewModels.Profiles
public void PreSelect()
{
SelectedLayerType = Types.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
ToggleIsEvent();
}
@ -166,8 +166,8 @@ namespace Artemis.ViewModels.Profiles
LayerPropertiesViewModel?.ApplyProperties();
Layer.Properties.DynamicProperties.Clear();
Layer.Properties.Conditions.Clear();
JsonConvert.PopulateObject(JsonConvert.SerializeObject(ProposedLayer), Layer);
Layer.Properties.Conditions.Clear();
foreach (var conditionViewModel in LayerConditionVms)
Layer.Properties.Conditions.Add(conditionViewModel.LayerConditionModel);

View File

@ -352,16 +352,22 @@ namespace Artemis.ViewModels.Profiles
private List<LayerModel> GetLayers()
{
// 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};
if (SelectedLayer == null)
return new List<LayerModel>();
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