diff --git a/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml b/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml
index 7a260238d..eda51857f 100644
--- a/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml
+++ b/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml
@@ -12,7 +12,7 @@
-
+
@@ -36,8 +36,8 @@
-
-
+
+
diff --git a/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml.cs b/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml.cs
index e0e6e1da3..374e16f26 100644
--- a/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Controls/GameStateParameterPicker.xaml.cs
@@ -21,52 +21,28 @@ public partial class GameStateParameterPicker : UserControl, INotifyPropertyChan
public event EventHandler SelectedPathChanged;
public event PropertyChangedEventHandler PropertyChanged;
- private List parameterList;
-
public GameStateParameterPicker() {
InitializeComponent();
}
#region UI Properties
- ///
- /// The current parts that make up the path. E.G. "LocalPCInfo/RAM" -> "LocalPCInfo", "RAM"
- ///
- private Stack WorkingPath { get; set; } = new Stack();
-
- ///
- /// Lazy-evaluated list of parameters for this application and property type.
- ///
- public List ParameterList => parameterList ?? (parameterList = Application?.ParameterLookup?.GetParameters(PropertyType).ToList());
+ public string WorkingPath { get; set; } = "";
///
/// Gets a list of items that should be displayed in the parameter list (based on the current "parent" variable).
///
- public IEnumerable CurrentParameterListItems {
+ public IEnumerable CurrentParameterListItems {
get {
// If the application or param lookup is null, we don't know the parameters so do nothing
if (Application?.ParameterLookup == null) return null;
// If the given working path is a path to a variable (which it shouldn't be), pop the last item (the variable name) from the path to give just the "directory"
- if (Application.ParameterLookup.IsValidParameter(WorkingPathStr))
- WorkingPath.Pop();
-
- // Generate the string version of this working path (and cache it)
- var _workingPath = WorkingPathStr;
- if (_workingPath != "") _workingPath += "/"; // If not at the root directory, add / to the end of the test path. This means it doesn't get confused with things such as `CPU` and `CPUUsage`.
- return from path in ParameterList // With all properties in the current param lookup that are of a valid type (e.g. numbers)
- where path.StartsWith(_workingPath) // Pick only the ones that start with the same working path
- let pathSplit = path.Substring(_workingPath.Length).Split('/') // Get a list of all remaining parts of the path (e.g. if this was A/B/C and current path was A, pathSplit would be 'B', 'C')
- let isFolder = pathSplit.Length > 1 // If there is more than one part of the path remaining, this must be a directory
- group isFolder by pathSplit[0] into g // Group by the path name so duplicates are removed
- orderby !g.First(), g.Key // Order the remaining (distinct) items by folders first, then order by their name
- select new PathOption(g.Key, g.First()); // Finally, put them in a POCO so we can bind the UI to these properties.
+ if (Application.ParameterLookup.IsValidParameter(WorkingPath))
+ GoUp();
+
+ return Application.ParameterLookup.Children(WorkingPath, PropertyType).OrderBy(p => !p.IsFolder).ThenBy(p => p.DisplayName);
}
}
-
- ///
- /// Returns the string representation of the current working path.
- ///
- public string WorkingPathStr => string.Join("/", WorkingPath.Reverse());
#endregion
#region IsOpen Dependency Property
@@ -113,9 +89,9 @@ private static void SelectedPathDPChanged(DependencyObject sender, DependencyPro
} else {
// Else if an actual path has been given, split it up into it's ""directories""
// For the path to be valid (and to be passed as a param to this method) it will be a path to a variable, not a "directory". We use this assumption.
- picker.WorkingPath = new Stack(e.NewValue.ToString().Split('/'));
- picker.WorkingPath.Pop(); // Remove the last one, since the working path should not include the actual var name
- picker.NotifyChanged(nameof(WorkingPath), nameof(WorkingPathStr), nameof(ParameterList), nameof(CurrentParameterListItems)); // All these things will be different now, so trigger an update of anything requiring them
+ picker.WorkingPath = (string)e.NewValue;
+ picker.GoUp(); // Remove the last one, since the working path should not include the actual var name
+ picker.NotifyChanged(nameof(WorkingPath), nameof(CurrentParameterListItems)); // All these things will be different now, so trigger an update of anything requiring them
picker.mainListBox.SelectedValue = e.NewValue.ToString().Split('/').Last(); // The selected item in the list will be the last part of the path
}
@@ -141,18 +117,17 @@ public Application Application {
///
/// The types of properties that will be shown to the user.
///
- public PropertyType PropertyType {
- get => (PropertyType)GetValue(PropertyTypeProperty);
+ public GSIPropertyType PropertyType {
+ get => (GSIPropertyType)GetValue(PropertyTypeProperty);
set => SetValue(PropertyTypeProperty, value);
}
public static readonly DependencyProperty PropertyTypeProperty =
- DependencyProperty.Register(nameof(PropertyType), typeof(PropertyType), typeof(GameStateParameterPicker), new PropertyMetadata(PropertyType.None, ApplicationOrPropertyTypeChange));
+ DependencyProperty.Register(nameof(PropertyType), typeof(GSIPropertyType), typeof(GameStateParameterPicker), new PropertyMetadata(GSIPropertyType.None, ApplicationOrPropertyTypeChange));
public static void ApplicationOrPropertyTypeChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) {
var picker = (GameStateParameterPicker)sender;
- picker.parameterList = null;
- picker.NotifyChanged(nameof(ParameterList), nameof(CurrentParameterListItems));
+ picker.NotifyChanged(nameof(CurrentParameterListItems));
if (!picker.ValidatePath(picker.SelectedPath))
picker.SelectedPath = "";
@@ -165,11 +140,11 @@ public static void ApplicationOrPropertyTypeChange(DependencyObject sender, Depe
///
private bool ValidatePath(string path) =>
// If application parameter context doesn't exist or there is no set type, assume non loaded and allow the path
- Application?.ParameterLookup == null || PropertyType == PropertyType.None
+ Application?.ParameterLookup == null || PropertyType == GSIPropertyType.None
// An empty path is fine
|| string.IsNullOrEmpty(path)
// If we're in number mode, allow the selected path to be a double
- || (PropertyType == PropertyType.Number && double.TryParse(path, out var _))
+ || (PropertyType == GSIPropertyType.Number && double.TryParse(path, out var _))
// If not in number mode, must be a valid path and have the same type as the expected property type
|| Application.ParameterLookup.IsValidParameter(path, PropertyType);
@@ -215,13 +190,13 @@ private Storyboard CreateStoryboard(int from, int to, UIElement target) {
#region Event Handlers
private void BackBtn_Click(object sender, RoutedEventArgs e) {
- if (WorkingPath.Count > 0) {
+ if (!string.IsNullOrEmpty(WorkingPath)) {
// Make the aux list box take on the same items as the current one so that when animated (since the aux is moved to the middle first) it looks natural
auxillaryListbox.ItemsSource = CurrentParameterListItems;
Animate(-1);
- WorkingPath.Pop(); // Remove the last "directory" off the working path
- NotifyChanged(nameof(CurrentParameterListItems), nameof(WorkingPathStr)); // These properties will have changed so any UI stuff that relies on it should update
+ GoUp(); // Remove the last "directory" off the working path
+ NotifyChanged(nameof(CurrentParameterListItems), nameof(WorkingPath)); // These properties will have changed so any UI stuff that relies on it should update
}
}
@@ -237,29 +212,24 @@ private void MainListBox_PreviewMouseLeftButtonDown(object sender, System.Window
// Element selection code is adapted from http://kevin-berridge.blogspot.com/2008/06/wpf-listboxitem-double-click.html
var el = (UIElement)mainListBox.InputHitTest(e.GetPosition(mainListBox));
while (el != null && el != mainListBox) {
- if (el is ListBoxItem item) {
+ if (el is ListBoxItem item && item.DataContext is GameStateParameterLookupEntry itemContext) {
// Since the user has picked an item on the list, we want to clear the numeric box so it is obvious to the user that the number is having no effect.
numericEntry.Value = null;
- // Copy the current list items to the aux list box incase the list box is animated later. This must be done BEFORE the workingpath.push call.
+ // Copy the current list items to the aux list box incase the list box is animated later. This must be done BEFORE changing workingpath
auxillaryListbox.ItemsSource = CurrentParameterListItems;
- // Add the clicked item to the working path (even if it is an end variable, not a "directory")
- WorkingPath.Push(((PathOption)item.DataContext).Path);
+ if (itemContext.IsFolder) {
+ // If the user selected a directory, animate the box.
+ WorkingPath = itemContext.Path;
+ Animate(1);
+ NotifyChanged(nameof(CurrentParameterListItems), nameof(WorkingPath));
- var path = string.Join("/", WorkingPath.Reverse());
- if (Application?.ParameterLookup?.IsValidParameter(path) ?? false) {
- // If it turns out the user has selected an end variable, we want to update the DependencyObject for the selected path
- SelectedPath = path;
- NotifyChanged(nameof(SelectedPath));
} else {
- // If the user has selected a directory instead (i.e. isn't not a valid parameter) then perform the animation since there will now be new properties to choose from
- Animate(1);
+ // Otherwise if the user selected a parameter, update the SelectedPath Dependency Property (which will fire a change event).
+ SelectedPath = itemContext.Path;
}
-
- // Regardless of whether it was a variable or a directory, the list and path will have changed
- NotifyChanged(nameof(CurrentParameterListItems), nameof(WorkingPathStr));
}
el = (UIElement)VisualTreeHelper.GetParent(el);
}
@@ -277,24 +247,15 @@ private void NumericEntry_ValueChanged(object sender, RoutedPropertyChangedEvent
}
#endregion
- private void NotifyChanged(params string[] propNames) {
- foreach (var prop in propNames)
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
- }
-
-
///
- /// Basic POCO for holding a bit of metadata about a path option.
+ /// Removes the last parameter or folder from the working path.
///
- public class PathOption {
- public PathOption(string path, bool isFolder) {
- Path = path;
- IsFolder = isFolder;
- }
+ private void GoUp() =>
+ WorkingPath = WorkingPath.Contains("/") ? WorkingPath.Substring(0, WorkingPath.LastIndexOf("/")) : "";
- public string DisplayPath => Path.CamelCaseToSpaceCase();
- public string Path { get; }
- public bool IsFolder { get; }
+ private void NotifyChanged(params string[] propNames) {
+ foreach (var prop in propNames)
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
}
}
@@ -325,10 +286,10 @@ public class IsStringNotNullOrWhitespaceConverter : IValueConverter {
///
/// Converter that converts a PropertyType enum value to a GridLength. Used for binding onto one of the row definition properties to hide a row when
- /// the property type is anything other than .
+ /// the property type is anything other than .
///
public class PropertyTypeToGridLengthConverter : IValueConverter {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => new GridLength(0, (PropertyType)value == PropertyType.Number ? GridUnitType.Auto : GridUnitType.Pixel);
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => new GridLength(0, (GSIPropertyType)value == GSIPropertyType.Number ? GridUnitType.Auto : GridUnitType.Pixel);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => new NotImplementedException();
}
diff --git a/Project-Aurora/Project-Aurora/NetworkListener.cs b/Project-Aurora/Project-Aurora/NetworkListener.cs
index ccd69d4e2..c80ca6a90 100644
--- a/Project-Aurora/Project-Aurora/NetworkListener.cs
+++ b/Project-Aurora/Project-Aurora/NetworkListener.cs
@@ -228,7 +228,7 @@ private void ReceiveGameState(IAsyncResult result)
response.ContentLength64 = 0;
response.Close();
}
- CurrentGameState = new GameState(JSON);
+ CurrentGameState = new EmptyGameState(JSON);
}
private void HandleNewIPCGameState(string gs_data)
diff --git a/Project-Aurora/Project-Aurora/Profiles/Application.cs b/Project-Aurora/Project-Aurora/Profiles/Application.cs
index 811ed8c75..bd92adbfc 100755
--- a/Project-Aurora/Project-Aurora/Profiles/Application.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Application.cs
@@ -68,7 +68,7 @@ public class Application : ObjectSettings, IInit, ILightEve
public bool Disposed { get; protected set; } = false;
public ApplicationProfile Profile { get; set; }
public ObservableCollection Profiles { get; set; }
- public Dictionary> ParameterLookup { get; set; } //Key = variable path, Value = {Return type, Parameter type}
+ public GameStateParameterLookup ParameterLookup { get; set; }
public bool HasLayers { get; set; }
public event EventHandler ProfileChanged;
public bool ScriptsLoaded { get; protected set; }
@@ -108,7 +108,7 @@ public Application(LightEventConfig config)
};
EffectScripts = new Dictionary();
if (config.GameStateType != null)
- ParameterLookup = Utils.GameStateUtils.ReflectGameStateParameters(config.GameStateType);
+ ParameterLookup = new GameStateParameterLookup(config.GameStateType);
}
public virtual bool Initialize()
@@ -307,14 +307,14 @@ void InitialiseLayerCollection(ObservableCollection collection) {
continue;
}
- lyr.AnythingChanged += SaveProfilesEvent;
+ lyr.PropertyChanged += SaveProfilesEvent;
}
collection.CollectionChanged += (_, e) => {
if (e.NewItems != null)
foreach (Layer lyr in e.NewItems)
if (lyr != null)
- lyr.AnythingChanged += SaveProfilesEvent;
+ lyr.PropertyChanged += SaveProfilesEvent;
SaveProfiles();
};
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/AutoJsonNode.cs b/Project-Aurora/Project-Aurora/Profiles/AutoJsonNode.cs
index 1caebdca5..4f230f249 100644
--- a/Project-Aurora/Project-Aurora/Profiles/AutoJsonNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/AutoJsonNode.cs
@@ -8,9 +8,9 @@
namespace Aurora.Profiles {
///
- /// A version of which automatically populates the fields defined on it from the parsed JSON data.
+ /// A version of which automatically populates the fields defined on it from the parsed JSON data.
///
- public class AutoJsonNode : Node where TSelf : AutoJsonNode {
+ public class AutoJsonNode : Node where TSelf : AutoJsonNode {
// Did consider implementing this auto feature as a Fody weaver however, should profiles become plugin-based, each plugin would need to use Fody if they
// wished to have the automatic capability. Doing it as a class that can be extended means that no additional setup is required for plugin authors.
diff --git a/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/GameState_Borderlands2.cs b/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/GameState_Borderlands2.cs
index 6a742c84d..4c70ecd56 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/GameState_Borderlands2.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/GameState_Borderlands2.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.Borderlands2.GSI
///
/// A class representing various information relating to Borderlands 2
///
- public class GameState_Borderlands2 : GameState
+ public class GameState_Borderlands2 : GameState
{
private Player_Borderlands2 player;
@@ -38,13 +38,5 @@ public GameState_Borderlands2() : base()
public GameState_Borderlands2(string json_data) : base(json_data)
{
}
-
- ///
- /// A copy constructor, creates a GameState_Borderlands2 instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_Borderlands2(IGameState other_state) : base(other_state)
- {
- }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/Nodes/Player.cs
index 2285e86bd..05c742a3e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Borderlands 2/GSI/Nodes/Player.cs
@@ -3,7 +3,7 @@
///
/// Class representing player information
///
- public class Player_Borderlands2 : Node
+ public class Player_Borderlands2 : Node
{
///
/// Player's boost amount [0.0f, 1.0f]
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/GameState_CSGO.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/GameState_CSGO.cs
index 74a5e6b1b..88f2d0b92 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/GameState_CSGO.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/GameState_CSGO.cs
@@ -13,7 +13,7 @@ namespace Aurora.Profiles.CSGO.GSI
///
/// A class representing various information retaining to Game State Integration of Counter-Strike: Global Offensive
///
- public class GameState_CSGO : GameState
+ public class GameState_CSGO : GameState
{
private ProviderNode _Provider;
private MapNode _Map;
@@ -151,34 +151,8 @@ public AuthNode Auth
}
}
- ///
- /// Creates a default GameState_CSGO instance.
- ///
- public GameState_CSGO()
- {
- json = "{}";
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json);
- }
-
- ///
- /// Creates a GameState_CSGO instance based on the passed json data.
- ///
- /// The passed json data
- public GameState_CSGO(string JSONstring)
- {
- if (String.IsNullOrWhiteSpace(JSONstring))
- JSONstring = "{}";
-
- json = JSONstring;
- _ParsedData = JObject.Parse(JSONstring);
- }
- ///
- /// A copy constructor, creates a GameState_CSGO instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_CSGO(IGameState other_state) : base(other_state)
- {
- }
+ public GameState_CSGO() : base() { }
+ public GameState_CSGO(string json_data) : base(json_data) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AllPlayersNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AllPlayersNode.cs
index 035d0e2b4..6b69bb1f9 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AllPlayersNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AllPlayersNode.cs
@@ -7,7 +7,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// A class representing player information for all players
///
- public class AllPlayersNode : Node
+ public class AllPlayersNode : Node
{
private readonly List _Players = new List();
@@ -77,7 +77,6 @@ public PlayerNode this[int index]
/// Retrieves the enumerator for all players list
///
/// The enumerator
- [GameStateIgnoreAttribute]
public IEnumerator GetEnumerator()
{
return _Players.GetEnumerator();
@@ -89,7 +88,6 @@ public IEnumerator GetEnumerator()
/// The team to lookup
/// A list of players
//[Range(0, 16)]
- [GameStateIgnoreAttribute]
public List GetTeam(PlayerTeam Team)
{
return _Players.FindAll(x => x.Team == Team);
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AuthNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AuthNode.cs
index f55f55613..8d278a31d 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AuthNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/AuthNode.cs
@@ -9,7 +9,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// A class representing the authentication information for GSI
///
- public class AuthNode : Node
+ public class AuthNode : Node
{
///
/// The auth token sent by GSI
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapNode.cs
index a9e4fd0e6..627e8d5ee 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapNode.cs
@@ -5,7 +5,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing information about the map
///
- public class MapNode : Node
+ public class MapNode : Node
{
///
/// Current gamemode
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapTeamNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapTeamNode.cs
index e481d67ac..b4a26c378 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapTeamNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MapTeamNode.cs
@@ -9,7 +9,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing team information
///
- public class MapTeamNode : Node
+ public class MapTeamNode : Node
{
///
/// Team score
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MatchStatsNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MatchStatsNode.cs
index 0470f25f7..cd30f9314 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MatchStatsNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/MatchStatsNode.cs
@@ -5,7 +5,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing various player statistics
///
- public class MatchStatsNode : Node
+ public class MatchStatsNode : Node
{
///
/// Amount of kills
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerNode.cs
index e96414c15..f369d5c4a 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerNode.cs
@@ -9,7 +9,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing player information
///
- public class PlayerNode : Node
+ public class PlayerNode : Node
{
internal string _SteamID;
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerStateNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerStateNode.cs
index b58a2a520..2ddfafd34 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerStateNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/PlayerStateNode.cs
@@ -5,7 +5,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing various player states
///
- public class PlayerStateNode : Node
+ public class PlayerStateNode : Node
{
///
/// Player's health
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/ProviderNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/ProviderNode.cs
index c9db6e3d9..b79df5b23 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/ProviderNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/ProviderNode.cs
@@ -3,7 +3,7 @@
///
/// Information about the provider of this GameState
///
- public class ProviderNode : Node
+ public class ProviderNode : Node
{
///
/// Game name
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/RoundNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/RoundNode.cs
index d389a097a..f2a4f9e40 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/RoundNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/RoundNode.cs
@@ -5,7 +5,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing information about the round
///
- public class RoundNode : Node
+ public class RoundNode : Node
{
///
/// Current round phase
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponNode.cs
index 8eb6b8127..431c164a0 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponNode.cs
@@ -12,7 +12,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// A class representing weapon information
///
- public class WeaponNode : Node
+ public class WeaponNode : Node
{
///
/// Weapon's name
diff --git a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponsNode.cs b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponsNode.cs
index ec830c6ed..28213f286 100755
--- a/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponsNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CSGO/GSI/Nodes/WeaponsNode.cs
@@ -9,7 +9,7 @@ namespace Aurora.Profiles.CSGO.GSI.Nodes
///
/// Class representing information about player's weapons
///
- public class WeaponsNode : Node
+ public class WeaponsNode : Node
{
private List _Weapons = new List();
diff --git a/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/GameState_CloneHero.cs b/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/GameState_CloneHero.cs
index 568f7264a..d77015ada 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/GameState_CloneHero.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/GameState_CloneHero.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.CloneHero.GSI
///
/// A class representing various information relating to CloneHero
///
- public class GameState_CloneHero : GameState
+ public class GameState_CloneHero : GameState
{
private Player_CloneHero player;
@@ -38,13 +38,5 @@ public GameState_CloneHero() : base()
public GameState_CloneHero(string json_data) : base(json_data)
{
}
-
- ///
- /// A copy constructor, creates a GameState_CloneHero instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_CloneHero(IGameState other_state) : base(other_state)
- {
- }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/Nodes/Player.cs
index 87c7944dc..a1cbfa2a9 100644
--- a/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/CloneHero/GSI/Nodes/Player.cs
@@ -3,7 +3,7 @@
///
/// Class representing player information
///
- public class Player_CloneHero : Node
+ public class Player_CloneHero : Node
{
///
/// Player's boost amount [0.0f, 1.0f]
diff --git a/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopApplication.cs b/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopApplication.cs
index be1628d47..078c99310 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopApplication.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Desktop/DesktopApplication.cs
@@ -1,19 +1,13 @@
-using Aurora.Settings;
-using Newtonsoft.Json;
-using System;
-using System.IO;
-using System.Text;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-
-namespace Aurora.Profiles.Desktop
-{
- public class Desktop : Application
- {
- public Desktop()
- : base(new LightEventConfig { Name = "Desktop", ID = "desktop", ProfileType = typeof(DesktopProfile), OverviewControlType = typeof(Control_Desktop), GameStateType = typeof(GameState), Event = new Event_Desktop(), IconURI= "Resources/desktop_icon.png" })
- {
- }
+namespace Aurora.Profiles.Desktop {
+ public class Desktop : Application {
+ public Desktop() : base(new LightEventConfig {
+ Name = "Desktop",
+ ID = "desktop",
+ ProfileType = typeof(DesktopProfile),
+ OverviewControlType = typeof(Control_Desktop),
+ GameStateType = typeof(EmptyGameState),
+ Event = new Event_Desktop(),
+ IconURI = "Resources/desktop_icon.png"
+ }) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs
index 5fab27c80..8c247bacf 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Discord/GSI/GameState_Discord.cs
@@ -1,15 +1,9 @@
using Aurora.Profiles.Discord.GSI.Nodes;
using Aurora.Profiles.Generic.GSI.Nodes;
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Aurora.Profiles.Discord.GSI
{
- public class GameState_Discord : GameState
+ public class GameState_Discord : GameState
{
public ProviderNode Provider => NodeFor("provider");
@@ -21,21 +15,8 @@ public class GameState_Discord : GameState
public VoiceNode Voice => NodeFor("voice");
- ///
- /// Creates a default GameState_Discord instance.
- ///
- public GameState_Discord() : base() { }
- ///
- /// Creates a GameState_Discord instance based on the passed JSON data.
- ///
- ///
+ public GameState_Discord() : base() { }
public GameState_Discord(string JSONstring) : base(JSONstring) { }
-
- ///
- /// Creates a GameState_Discord instance based on the data from the passed GameState instance.
- ///
- public GameState_Discord(IGameState other) : base(other) { }
-
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/GameState_Dishonored.cs b/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/GameState_Dishonored.cs
index ec267b79b..b63a31dac 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/GameState_Dishonored.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/GameState_Dishonored.cs
@@ -1,12 +1,11 @@
using Aurora.Profiles.Dishonored.GSI.Nodes;
-using System;
namespace Aurora.Profiles.Dishonored.GSI
{
///
/// A class representing various information relating to Dishonored
///
- public class GameState_Dishonored : GameState
+ public class GameState_Dishonored : GameState
{
private Player_Dishonored player;
@@ -24,27 +23,8 @@ public Player_Dishonored Player
}
}
- ///
- /// Creates a default GameState_Dishonored instance.
- ///
- public GameState_Dishonored() : base()
- {
- }
- ///
- /// Creates a GameState instance based on the passed json data.
- ///
- /// The passed json data
- public GameState_Dishonored(string json_data) : base(json_data)
- {
- }
-
- ///
- /// A copy constructor, creates a GameState_Dishonored instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_Dishonored(IGameState other_state) : base(other_state)
- {
- }
+ public GameState_Dishonored() : base() { }
+ public GameState_Dishonored(string json_data) : base(json_data) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/Nodes/Player.cs
index a8f4a18f5..d229edb86 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dishonored/GSI/Nodes/Player.cs
@@ -3,7 +3,7 @@
///
/// Class representing player information
///
- public class Player_Dishonored : Node
+ public class Player_Dishonored : Node
{
///
/// Player's boost amount [0.0f, 1.0f]
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/GameState_Dota2.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/GameState_Dota2.cs
index afd43159c..b9d8d8cdf 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/GameState_Dota2.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/GameState_Dota2.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.Dota_2.GSI
///
/// A class representing various information retaining to Game State Integration of Dota 2
///
- public class GameState_Dota2 : GameState
+ public class GameState_Dota2 : GameState
{
private Auth_Dota2 auth;
private Provider_Dota2 provider;
@@ -18,28 +18,8 @@ public class GameState_Dota2 : GameState
private GameState_Dota2 previously;
private GameState_Dota2 added;
- ///
- /// Creates a default GameState_Dota2 instance.
- ///
- public GameState_Dota2() : base()
- {
- }
-
- ///
- /// Creates a GameState instance based on the passed json data.
- ///
- /// The passed json data
- public GameState_Dota2(string json_data) : base(json_data)
- {
- }
-
- ///
- /// A copy constructor, creates a GameState_Dota2 instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_Dota2(IGameState other_state) : base(other_state)
- {
- }
+ public GameState_Dota2() : base() { }
+ public GameState_Dota2(string json_data) : base(json_data) { }
///
/// Information about GSI authentication
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Abilities.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Abilities.cs
index db2fec10c..542f5ee1e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Abilities.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Abilities.cs
@@ -8,7 +8,7 @@ namespace Aurora.Profiles.Dota_2.GSI.Nodes
///
/// Class representing hero abilities
///
- public class Abilities_Dota2 : Node, IEnumerable
+ public class Abilities_Dota2 : Node, IEnumerable
{
private List abilities = new List();
@@ -54,11 +54,6 @@ public Ability this[int index]
}
}
- public override string ToString()
- {
- return json;
- }
-
public IEnumerator GetEnumerator()
{
return abilities.GetEnumerator();
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Ability.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Ability.cs
index 1efca11da..7a917a614 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Ability.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Ability.cs
@@ -3,7 +3,7 @@
///
/// Class representing ability information
///
- public class Ability : Node
+ public class Ability : Node
{
///
/// Ability name
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Attributes.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Attributes.cs
index 82a564e2b..f24c43d67 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Attributes.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Attributes.cs
@@ -3,7 +3,7 @@
///
/// Class representing ability attributes
///
- public class Attributes : Node
+ public class Attributes : Node
{
///
/// Amount of levels to spend
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Auth.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Auth.cs
index 30c42ec00..92578f896 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Auth.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Auth.cs
@@ -3,7 +3,7 @@
///
/// A class representing the authentication information for GSI
///
- public class Auth_Dota2 : Node
+ public class Auth_Dota2 : Node
{
///
/// The auth token sent by this GSI
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Hero.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Hero.cs
index 450d13890..464fa7eab 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Hero.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Hero.cs
@@ -3,7 +3,7 @@
///
/// Class representing hero information
///
- public class Hero_Dota2 : Node
+ public class Hero_Dota2 : Node
{
///
/// Hero ID
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Item.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Item.cs
index e8cb0c949..c0620f4a4 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Item.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Item.cs
@@ -3,7 +3,7 @@
///
/// Class representing item information
///
- public class Item : Node
+ public class Item : Node
{
///
/// Item name
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Items.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Items.cs
index 6f585b59b..28cb4786f 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Items.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Items.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.Dota_2.GSI.Nodes
///
/// Class representing item information
///
- public class Items_Dota2 : Node
+ public class Items_Dota2 : Node
{
private List inventory = new List();
private List stash = new List();
@@ -56,7 +56,6 @@ internal Items_Dota2(string json_data) : base(json_data)
///
/// The index
///
- [GameStateIgnore]
public Item GetInventoryAt(int index)
{
if (index > inventory.Count - 1)
@@ -70,7 +69,6 @@ public Item GetInventoryAt(int index)
///
/// The index
///
- [GameStateIgnore]
public Item GetStashAt(int index)
{
if (index > stash.Count - 1)
@@ -116,7 +114,6 @@ public bool StashContains(string itemname)
///
/// The item name
/// The first index at which item is found, -1 if not found.
- [GameStateIgnore]
public int InventoryIndexOf(string itemname)
{
for (int x = 0; x < this.inventory.Count; x++)
@@ -133,7 +130,6 @@ public int InventoryIndexOf(string itemname)
///
/// The item name
/// The first index at which item is found, -1 if not found.
- [GameStateIgnore]
public int StashIndexOf(string itemname)
{
for (int x = 0; x < this.stash.Count; x++)
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Map.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Map.cs
index f94cf6e18..c61d6def5 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Map.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Map.cs
@@ -90,7 +90,7 @@ public enum PlayerTeam
///
/// Class representing information about the map
///
- public class Map_Dota2 : Node
+ public class Map_Dota2 : Node
{
///
/// Name of the current map
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Player.cs
index 9bc9cc3df..35da8f931 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Player.cs
@@ -24,7 +24,7 @@ public enum PlayerActivity
///
/// Class representing player information
///
- public class Player_Dota2 : Node
+ public class Player_Dota2 : Node
{
///
/// Player's steam ID
diff --git a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Provider.cs b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Provider.cs
index d82cec3b3..36e2c0979 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Provider.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Dota 2/GSI/Nodes/Provider.cs
@@ -3,7 +3,7 @@
///
/// Information about the provider of this GameState
///
- public class Provider_Dota2 : Node
+ public class Provider_Dota2 : Node
{
///
/// Game name
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/GameState_ETS2.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/GameState_ETS2.cs
index 2c5968894..387ff81fc 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/GameState_ETS2.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/GameState_ETS2.cs
@@ -7,7 +7,7 @@
namespace Aurora.Profiles.ETS2.GSI {
- public class GameState_ETS2 : GameState {
+ public class GameState_ETS2 : GameState {
internal Box _memdat;
private GameNode _Game;
@@ -82,12 +82,6 @@ public GameState_ETS2() : base() { }
/// The JSON data to parse.
public GameState_ETS2(string json_data) : base(json_data) { }
- ///
- /// Creates a GameState_ETS2 instance based on data from another GateState instance.
- ///
- /// The GameState to copy.
- public GameState_ETS2(IGameState other) : base(other) { }
-
///
/// Creates a GameState_ETS2 instance based on data that has been read from the MemoryMappedFile
/// into a ETS2MemoryStruct.
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/GameNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/GameNode.cs
index 73ec7b2cc..d536fae05 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/GameNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/GameNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class GameNode : Node {
+ public class GameNode : Node {
private Box _memdat;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/JobNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/JobNode.cs
index df7bac11d..398171989 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/JobNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/JobNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class JobNode : Node {
+ public class JobNode : Node {
private Box _memdat;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/NavigationNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/NavigationNode.cs
index db2d68df4..45fa48b50 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/NavigationNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/NavigationNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class NavigationNode : Node {
+ public class NavigationNode : Node {
private Box _memdat;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/PlacementNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/PlacementNode.cs
index b4005e5d5..1a3c3f8e1 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/PlacementNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/PlacementNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class PlacementNode : Node {
+ public class PlacementNode : Node {
/// X coordinate of the object.
public float x;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TrailerNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TrailerNode.cs
index 7b15682d3..1a2d557a8 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TrailerNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TrailerNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class TrailerNode : Node {
+ public class TrailerNode : Node {
private Box _memdat;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TruckNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TruckNode.cs
index 90e856d4f..7f7942872 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TruckNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/TruckNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class TruckNode : Node {
+ public class TruckNode : Node {
internal Box _memdat;
diff --git a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/VectorNode.cs b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/VectorNode.cs
index b10f25bed..11bf7283e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/VectorNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/ETS2/GSI/Nodes/VectorNode.cs
@@ -1,5 +1,5 @@
namespace Aurora.Profiles.ETS2.GSI.Nodes {
- public class VectorNode : Node {
+ public class VectorNode : Node {
public float x;
public float y;
diff --git a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/GameState_EliteDangerous.cs b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/GameState_EliteDangerous.cs
index 8c301d9fd..cda1af270 100644
--- a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/GameState_EliteDangerous.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/GameState_EliteDangerous.cs
@@ -76,7 +76,7 @@ public bool IsSatisfied(GameState_EliteDangerous gameState)
}
}
- public class GameState_EliteDangerous : GameState
+ public class GameState_EliteDangerous : GameState
{
private Status status;
private Nodes.Journal journal;
diff --git a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Controls.cs b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Controls.cs
index 09be21cb2..97cc93039 100644
--- a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Controls.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Controls.cs
@@ -536,7 +536,7 @@ public ControlGroup(string colorGroupName, string[] commands,
///
/// Class representing current controls configuration
///
- public class Controls : Node
+ public class Controls : Node
{
public HashSet modifierKeys = new HashSet();
public Dictionary commandToBind = new Dictionary();
diff --git a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Journal.cs b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Journal.cs
index 6e98c6cb9..af4d4e19e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Journal.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Journal.cs
@@ -43,7 +43,7 @@ public class SimpleShipLoadout
public bool hasShieldCellBank;
}
- public class Journal : Node
+ public class Journal : Node
{
public FighterStatus fighterStatus = FighterStatus.None;
diff --git a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Status.cs b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Status.cs
index f7063ef5c..f448e056a 100644
--- a/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Status.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/EliteDangerous/GSI/Nodes/Status.cs
@@ -73,7 +73,7 @@ public class Fuel
///
/// Class representing player status
///
- public class Status : Node
+ public class Status : Node
{
public DateTime timestamp;
public string @event;
diff --git a/Project-Aurora/Project-Aurora/Profiles/GTA5/GSI/GameState_GTA5.cs b/Project-Aurora/Project-Aurora/Profiles/GTA5/GSI/GameState_GTA5.cs
index f3a2384f3..cae955cd9 100644
--- a/Project-Aurora/Project-Aurora/Profiles/GTA5/GSI/GameState_GTA5.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/GTA5/GSI/GameState_GTA5.cs
@@ -130,11 +130,7 @@ public class GameState_GTA5 : GameState_Wrapper
///
/// Creates a default GameState_GTA5 instance.
///
- public GameState_GTA5()
- {
- json = "{}";
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json);
- }
+ public GameState_GTA5() { }
private byte RoundTo5(byte no)
{
@@ -173,23 +169,6 @@ public GameState_GTA5(string json_data) : base(json_data)
HasCops = LeftSirenColor != RightSirenColor;
}
- ///
- /// A copy constructor, creates a GameState_GTA5 instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_GTA5(GameState other_state) : base(other_state)
- {
- GameState_GTA5 gta = other_state as GameState_GTA5;
- if (gta != null)
- {
- this.HasCops = gta.HasCops;
- this.LeftSirenColor = gta.LeftSirenColor;
- this.RightSirenColor = gta.RightSirenColor;
- this.CurrentState = gta.CurrentState;
- this.StateColor = gta.StateColor;
- }
- }
-
private Color JSonToColor(byte a, byte r, byte g, byte b)
{
return Color.FromArgb(a, r, g, b);
diff --git a/Project-Aurora/Project-Aurora/Profiles/GameState.cs b/Project-Aurora/Project-Aurora/Profiles/GameState.cs
index b520aa1bc..eec198a43 100644
--- a/Project-Aurora/Project-Aurora/Profiles/GameState.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/GameState.cs
@@ -1,351 +1,176 @@
-using Aurora.Profiles;
-using Microsoft.VisualBasic.Devices;
+using Aurora.Utils;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-using NAudio.CoreAudioApi;
-using Aurora.Utils;
namespace Aurora.Profiles
{
- public class GameStateIgnoreAttribute : Attribute
- { }
-
- public class RangeAttribute : Attribute
- {
- public int Start { get; set; }
-
- public int End { get; set; }
-
- public RangeAttribute(int start, int end)
- {
- Start = start;
- End = end;
- }
- }
///
/// A class representing various information retaining to the game.
///
- public interface IGameState
- {
- ///
- /// Information about the local system
- ///
- //LocalPCInformation LocalPCInfo { get; }
-
- JObject _ParsedData { get; set; }
- string json { get; set; }
-
+ public interface IGameState {
+ JObject _ParsedData { get; }
+ string Json { get; }
string GetNode(string name);
+
+ /// Attempts to resolve the given path into a numeric value. Returns 0 on failure.
+ double GetNumber(string path);
+
+ /// Attempts to resolve the given path into a boolean value. Returns false on failure.
+ bool GetBool(string path);
+
+ /// Attempts to resolve the given path into a string value. Returns an empty string on failure.
+ string GetString(string path);
+
+ /// Attempts to resolve the given path into a enum value. Returns null on failure.
+ Enum GetEnum(string path);
+
+ /// Attempts to resolve the given path into a numeric value. Returns default on failure.
+ TEnum GetEnum(string path) where TEnum : Enum;
}
- public class GameState : StringProperty, IGameState where TSelf : GameState
+ public class GameState : IGameState
{
private static LocalPCInformation _localpcinfo;
// Holds a cache of the child nodes on this gamestate
private readonly Dictionary childNodes = new Dictionary(StringComparer.OrdinalIgnoreCase);
- ///
- /// Information about the local system
- ///
- public LocalPCInformation LocalPCInfo => _localpcinfo ?? (_localpcinfo = new LocalPCInformation());
+ [GameStateIgnore] public JObject _ParsedData { get; }
+ [GameStateIgnore] public string Json { get; }
- [GameStateIgnore] public JObject _ParsedData { get; set; }
- [GameStateIgnore] public string json { get; set; }
+ public LocalPCInformation LocalPCInfo => _localpcinfo ?? (_localpcinfo = new LocalPCInformation());
///
/// Creates a default GameState instance.
///
- public GameState() : base()
- {
- json = "{}";
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json);
+ public GameState() : base() {
+ Json = "{}";
+ _ParsedData = new JObject();
}
///
/// Creates a GameState instance based on the passed json data.
///
/// The passed json data
- public GameState(string json_data) : base()
- {
- if (String.IsNullOrWhiteSpace(json_data))
+ public GameState(string json_data) : base() {
+ if (string.IsNullOrWhiteSpace(json_data))
json_data = "{}";
- json = json_data;
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json_data);
+ Json = json_data;
+ _ParsedData = JObject.Parse(json_data);
}
///
- /// A copy constructor, creates a GameState instance based on the data from the passed GameState instance.
+ /// Gets the JSON for a child node in this GameState.
///
- /// The passed GameState
- public GameState(IGameState other_state) : base()
- {
- _ParsedData = other_state._ParsedData;
- json = other_state.json;
- }
-
- [GameStateIgnore] public string GetNode(string name)
- {
- Newtonsoft.Json.Linq.JToken value;
-
- if (_ParsedData.TryGetValue(name, StringComparison.OrdinalIgnoreCase, out value))
- return value.ToString();
- else
- return "";
- }
+ public string GetNode(string name) =>
+ _ParsedData.TryGetValue(name, StringComparison.OrdinalIgnoreCase, out var value) ? value.ToString() : "";
///
/// Use this method to more-easily lazily return the child node of the given name that exists on this AutoNode.
///
- [GameStateIgnore] protected TNode NodeFor(string name) where TNode : Node
+ protected TNode NodeFor(string name) where TNode : Node
=> (TNode)(childNodes.TryGetValue(name, out var n) ? n : (childNodes[name] = Instantiator.Create(_ParsedData[name]?.ToString() ?? "")));
+ #region GameState path resolution
///
- /// Displays the JSON, representative of the GameState data
+ /// Attempts to resolve the given GameState path into a value.
+ /// Returns whether or not the path resulted in a field or property (true) or was invalid (false).
///
- /// JSON String
- [GameStateIgnore] public override string ToString()
- {
- return json;
- }
- }
-
- public class GameState : GameState
- {
- public GameState() : base() { }
- public GameState(IGameState gs) : base(gs) { }
- public GameState(string json) : base(json) { }
- }
-
- ///
- /// Class representing local computer information
- ///
- public class LocalPCInformation : Node {
- #region Time Properties
- ///
- /// The current hour
- ///
- public int CurrentHour => Utils.Time.GetHours();
-
- ///
- /// The current minute
- ///
- public int CurrentMinute => Utils.Time.GetMinutes();
-
- ///
- /// The current second
- ///
- public int CurrentSecond => Utils.Time.GetSeconds();
-
- ///
- /// The current millisecond
- ///
- public int CurrentMillisecond => Utils.Time.GetMilliSeconds();
-
- ///
- /// The total number of milliseconds since the epoch
- ///
- public long MillisecondsSinceEpoch => Utils.Time.GetMillisecondsSinceEpoch();
- #endregion
-
- #region Audio Properties
- private static readonly MMDeviceEnumerator mmDeviceEnumerator = new MMDeviceEnumerator();
- private static readonly NAudio.Wave.WaveInEvent waveInEvent = new NAudio.Wave.WaveInEvent();
-
- ///
- /// Gets the default endpoint for output (playback) devices e.g. speakers, headphones, etc.
- /// This will return null if there are no playback devices available.
- ///
- private MMDevice DefaultAudioOutDevice {
- get {
- try { return mmDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console); }
- catch { return null; }
- }
+ /// The that the property must match for this to be valid.
+ /// The current value of the resulting property or field on this instance.
+ private bool TryResolveGSPath(string path, GSIPropertyType type, out object value) {
+ value = null;
+ return !string.IsNullOrEmpty(path)
+ && (value = this.ResolvePropertyPath(path)) != null
+ && GSIPropertyTypeConverter.IsTypePropertyType(value?.GetType(), type);
}
- ///
- /// Gets the default endpoint for input (recording) devices e.g. microphones.
- /// This will return null if there are no recording devices available.
- ///
- private MMDevice DefaultAudioInDevice {
- get {
- try { return mmDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console); }
- catch { return null; }
- }
+ public double GetNumber(string path) {
+ if (double.TryParse(path, out var val)) // If the path is a raw number, return that
+ return val;
+ if (TryResolveGSPath(path, GSIPropertyType.Number, out var pVal)) // Next, try resolve the path as we would other types
+ return Convert.ToDouble(pVal);
+ return 0;
}
- ///
- /// Current system volume (as set from the speaker icon)
- ///
- // Note: Manually checks if muted to return 0 since this is not taken into account with the MasterVolumeLevelScalar.
- public float SystemVolume => SystemVolumeIsMuted ? 0 : DefaultAudioOutDevice?.AudioEndpointVolume.MasterVolumeLevelScalar * 100 ?? 0;
-
- ///
- /// Gets whether the system volume is muted.
- ///
- public bool SystemVolumeIsMuted => DefaultAudioOutDevice?.AudioEndpointVolume.Mute ?? true;
-
- ///
- /// The volume level that is being recorded by the default microphone even when muted.
- ///
- public float MicrophoneLevel => DefaultAudioInDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
-
- ///
- /// The volume level that is being emitted by the default speaker even when muted.
- ///
- public float SpeakerLevel => DefaultAudioOutDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
-
- ///
- /// The volume level that is being recorded by the default microphone if not muted.
- ///
- public float MicLevelIfNotMuted => MicrophoneIsMuted ? 0 : DefaultAudioInDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
-
- ///
- /// Gets whether the default microphone is muted.
- ///
- public bool MicrophoneIsMuted => DefaultAudioInDevice?.AudioEndpointVolume.Mute ?? true;
+ public bool GetBool(string path) => TryResolveGSPath(path, GSIPropertyType.Boolean, out var @bool) ? Convert.ToBoolean(@bool) : false;
+ public string GetString(string path) => TryResolveGSPath(path, GSIPropertyType.String, out var str) ? str.ToString() : "";
+ public Enum GetEnum(string path) => TryResolveGSPath(path, GSIPropertyType.Enum, out var @enum) && @enum is Enum e ? e : null;
+ public TEnum GetEnum(string path) where TEnum : Enum => TryResolveGSPath(path, GSIPropertyType.Enum, out var @enum) && @enum is TEnum e ? e : default;
#endregion
- #region Device Properties
- ///
- /// Battery level of a dualshock controller
- ///
- public int DS4Battery => Global.dev_manager.GetInitializedDevices().OfType().FirstOrDefault()?.Battery ?? 0;
///
- /// Whether or not thr dualshock controller is charging
- ///
- public bool DS4Charging => Global.dev_manager.GetInitializedDevices().OfType().FirstOrDefault()?.Charging ?? false;
- #endregion
-
- #region CPU Properties
- ///
- /// Legacy cpu usage prop, DEPRECATED
+ /// Displays the JSON, representative of the GameState data
///
- public float CPUUsage => CPU.Usage;
+ /// JSON String
+ public override string ToString() => Json;
+ }
- private static CPUInfo _cpuInfo;
- public CPUInfo CPU => _cpuInfo ?? (_cpuInfo = new CPUInfo());
- #endregion
- #region RAM Properties
- ///
- /// Used RAM, DEPRECATED
- ///
- public long MemoryUsed => RAM.Used;
+ /// The valid types of GSI property.
+ public enum GSIPropertyType { None, Number, Boolean, String, Enum }
+ internal static class GSIPropertyTypeConverter {
///
- /// Available RAM, DEPRECATED
+ /// A set of predicates that determine if the given is of the given
///
- public long MemoryFree => RAM.Free;
+ private static Dictionary> predicates = new Dictionary> {
+ [GSIPropertyType.None] = _ => false,
+ [GSIPropertyType.Enum] = type => type.IsEnum, // Needs to take priority over number, since enums are stored as numbers as so IsNumericType would be true
+ [GSIPropertyType.Number] = type => TypeUtils.IsNumericType(type),
+ [GSIPropertyType.Boolean] = type => Type.GetTypeCode(type) == TypeCode.Boolean,
+ [GSIPropertyType.String] = type => Type.GetTypeCode(type) == TypeCode.String
+ };
///
- /// Total RAM, DEPRECATED
+ /// Gets the for the given .
///
- public long MemoryTotal => MemoryFree + MemoryUsed;
-
- private static RAMInfo _ramInfo;
- public RAMInfo RAM => _ramInfo ?? (_ramInfo = new RAMInfo());
- #endregion
-
- #region GPU Properties
- private static GPUInfo _gpuInfo;
- public GPUInfo GPU => _gpuInfo ?? (_gpuInfo = new GPUInfo());
- #endregion
-
- #region NET Properties
- private static NETInfo _netInfo;
- public NETInfo NET => _netInfo ?? (_netInfo = new NETInfo());
- #endregion
-
- ///
- /// Returns whether or not the device dession is in a locked state.
- ///
- public bool IsDesktopLocked => Utils.DesktopUtils.IsDesktopLocked;
-
- static LocalPCInformation() {
- void StartStopRecording() {
- // We must start recording to be able to capture audio in, but only do this if the user has the option set. Allowing them
- // to turn it off will give them piece of mind we're not spying on them and will stop the Windows 10 mic icon appearing.
- try {
- if (Global.Configuration.EnableAudioCapture)
- waveInEvent.StartRecording();
- else
- waveInEvent.StopRecording();
- } catch { }
- }
-
- StartStopRecording();
- Global.Configuration.PropertyChanged += (sender, e) => {
- if (e.PropertyName == "EnableAudioCapture")
- StartStopRecording();
- };
+ public static GSIPropertyType TypeToPropertyType(Type type) {
+ if (type == null) return GSIPropertyType.None;
+ foreach (var (propertyType, predicate) in predicates)
+ if (predicate(type))
+ return propertyType;
+ return GSIPropertyType.None;
}
- }
- public class CPUInfo : Node
- {
///
- /// Represents the CPU usage from 0 to 100
+ /// Determines if the given is valid for the given .
///
- public float Usage => Utils.HardwareMonitor.CPU.CPUTotalLoad;
+ public static bool IsTypePropertyType(Type type, GSIPropertyType propertyType) => type == null ? false : predicates[propertyType](type);
+ }
- ///
- /// Represents the temperature of the cpu die in celsius
- ///
- public float Temperature => Utils.HardwareMonitor.CPU.CPUDieTemp;
- ///
- /// Represents the CPU power draw in watts
- ///
- public float PowerUsage => Utils.HardwareMonitor.CPU.CPUPower;
+ ///
+ /// An empty gamestate with no child nodes.
+ ///
+ public class EmptyGameState : GameState
+ {
+ public EmptyGameState() : base() { }
+ public EmptyGameState(string json) : base(json) { }
}
- public class RAMInfo : Node
- {
- ///
- /// Used system memory in megabytes
- ///
- public long Used => (long)(Utils.HardwareMonitor.RAM.RAMUsed * 1024f);
- ///
- /// Free system memory in megabytes
- ///
- public long Free => (long)(Utils.HardwareMonitor.RAM.RAMFree * 1024f);
+ ///
+ /// Attribute that can be applied to properties to indicate they should be excluded from the game state.
+ ///
+ [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
+ public class GameStateIgnoreAttribute : Attribute { }
- ///
- /// Total system memory in megabytes
- ///
- public long Total => Free + Used;
- }
+ ///
+ /// Attribute that indicates the range of indicies that are valid for an enumerable game state property.
+ ///
+ [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
+ public class RangeAttribute : Attribute {
- public class GPUInfo : Node
- {
- public float Usage => Utils.HardwareMonitor.GPU.GPUCoreLoad;
- public float Temperature => Utils.HardwareMonitor.GPU.GPUCoreTemp;
- public float PowerUsage => Utils.HardwareMonitor.GPU.GPUPower;
- public float FanRPM => Utils.HardwareMonitor.GPU.GPUFan;
- public float CoreClock => Utils.HardwareMonitor.GPU.GPUCoreClock;
- public float MemoryClock => Utils.HardwareMonitor.GPU.GPUMemoryClock;
- public float ShaderClock => Utils.HardwareMonitor.GPU.GPUShaderClock;
- public float MemoryControllerUsage => Utils.HardwareMonitor.GPU.GPUMemoryCLoad;
- public float VideoEngineUsage => Utils.HardwareMonitor.GPU.GPUVideoEngineLoad;
- public float MemoryUsed => Utils.HardwareMonitor.GPU.GPUMemoryUsed;
- public float MemoryFree => MemoryTotal - MemoryUsed;
- public float MemoryTotal => Utils.HardwareMonitor.GPU.GPUMemoryTotal;
- }
+ public RangeAttribute(int start, int end) {
+ Start = start;
+ End = end;
+ }
- public class NETInfo : Node
- {
- public float Usage => Utils.HardwareMonitor.NET.BandwidthUsed;
- public float UploadSpeed => Utils.HardwareMonitor.NET.UploadSpeedBytes;
- public float DownloadSpeed => Utils.HardwareMonitor.NET.DownloadSpeedBytes;
+ public int Start { get; set; }
+ public int End { get; set; }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/GameStateParameterLookup.cs b/Project-Aurora/Project-Aurora/Profiles/GameStateParameterLookup.cs
new file mode 100644
index 000000000..796dc909e
--- /dev/null
+++ b/Project-Aurora/Project-Aurora/Profiles/GameStateParameterLookup.cs
@@ -0,0 +1,131 @@
+using Aurora.Utils;
+using FastMember;
+using Mono.CSharp;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Aurora.Profiles {
+
+ ///
+ /// Data structure that holds a record of all game state parameters for a particular type of GameState.
+ ///
+ public sealed class GameStateParameterLookup {
+
+ // List of types that are permitted to be recursively searched
+ private static readonly Type[] recursiveWhiteList = new[] { typeof(Node), typeof(GameState), typeof(IEnumerable) };
+
+ // Internal parameter store. Key = full path, Value = meta
+ private readonly Dictionary lookup = new Dictionary();
+
+ ///
+ /// Creates a new by inspecting all properties on the given type.
+ ///
+ public GameStateParameterLookup(Type type) {
+ // Recursive function for visiting all types on the given type
+ // Will add relevant entries to lookup
+ void Visit(string path, string name, Type type) {
+ // If this is a variable that can be handled (such as a number or bool), add it to the lookup
+ if (GSIPropertyTypeConverter.TypeToPropertyType(type) != GSIPropertyType.None)
+ lookup.Add(path, GameStateParameterLookupEntry.Property(name, path, type));
+
+ else if (recursiveWhiteList.Any(t => t.IsAssignableFrom(type))) {
+ // Else if this not a handlable property, check if it's a node or list of nodes and if so make a folder and visit it's children
+ if (path != "") // If it's the root folder, don't add it
+ lookup.Add(path, GameStateParameterLookupEntry.Folder(name, path));
+
+ var accessor = TypeAccessor.Create(type);
+ if (!accessor.GetMembersSupported) return;
+ foreach (var member in accessor.GetMembers()) {
+ if (member.Type == type) continue; // Ignore recursive types
+ if (member.GetAttribute(typeof(GameStateIgnoreAttribute), true) != null) continue; // Ignore properties with [GameStateIgnore]
+
+ var nextPath = (path + "/" + member.Name).TrimStart('/');
+
+ // If the type is an Enumerable with a range attribute, visit for each item in that range
+ if (member.Type.GetGenericInterfaceTypes(typeof(IEnumerable<>)) is { } ienumTypes && typeof(Node).IsAssignableFrom(ienumTypes[0]) && member.GetAttribute(typeof(RangeAttribute), true) is RangeAttribute range)
+ for (var i = range.Start; i <= range.End; i++)
+ Visit(nextPath + "/" + i, i.ToString(), ienumTypes[0]);
+
+ // Recursively visit the next type (do this even if it is IEnumerable, as it might be a custom class that implements IEnumerable with extra properties)
+ Visit(nextPath, member.Name, member.Type);
+ }
+ }
+ }
+
+ // Start the recursive function at the root.
+ Visit("", "", type);
+ }
+
+ ///
+ /// Attempts to get the definition for the folder or property at the given path.
+ ///
+ public GameStateParameterLookupEntry this[string path] =>
+ lookup.TryGetValue(path, out var entry) ? entry : null;
+
+ ///
+ /// Gets all the direct/first-level children of the folder at the given path.
+ /// Optionally, only children ones that either are of the given type (in the case of properties) or that contain atleast one property of the given type (in the case of folders).
+ ///
+ /// Only children that are within the folder at the given path will be returned.
+ /// If not , only children of this type and only folders that contain atleast one property of this type will be returned.
+ public IEnumerable Children(string path = "", GSIPropertyType type = GSIPropertyType.None) =>
+ from kvp in lookup
+ where GetFolderOf(kvp.Key) == path // only include anything in this folder
+ where type == GSIPropertyType.None // if type is none, don't worry about type filtering
+ || (kvp.Value.IsFolder && AllChildren(kvp.Key).Any(c => c.Type == type)) // return a folder if it contains atleast one child of type
+ || (!kvp.Value.IsFolder && kvp.Value.Type == type) // return a property if it is of type
+ select kvp.Value;
+
+ /// Returns a list of all children of the given path, REGARDLESS of depth.
+ private IEnumerable AllChildren(string path) {
+ if (!path.EndsWith("/")) path += '/';
+ return from kvp in lookup where kvp.Key.StartsWith(path) select kvp.Value;
+ }
+
+ ///
+ /// Determines if the given path results in a property of the given type.
+ ///
+ /// The result will only be true if the parameter type is of this type. If None is passed, any parameter type is allowed.
+ public bool IsValidParameter(string path, GSIPropertyType type = GSIPropertyType.None) =>
+ lookup.TryGetValue(path, out var entry) && !entry.IsFolder && (type == GSIPropertyType.None || entry.Type == type);
+
+ ///
+ /// Returns the folder that the given path is in.
+ ///
+ private string GetFolderOf(string path) => path.Contains('/') ? path.Substring(0, path.LastIndexOf('/')) : "";
+ }
+
+
+ ///
+ /// Plain object that holds metadata about a single parameter or folder in the collection.
+ ///
+ public sealed class GameStateParameterLookupEntry {
+ public string Name { get; private set; }
+ public string Path { get; private set; }
+ public bool IsFolder { get; private set; }
+ public Type ClrType { get; private set; }
+ public GSIPropertyType Type { get; private set; }
+
+ public string DisplayName => Name.CamelCaseToSpaceCase();
+
+ private GameStateParameterLookupEntry() { }
+
+ internal static GameStateParameterLookupEntry Folder(string name, string path) => new GameStateParameterLookupEntry {
+ Name = name,
+ Path = path,
+ IsFolder = true,
+ ClrType = null,
+ Type = GSIPropertyType.None
+ };
+
+ internal static GameStateParameterLookupEntry Property(string name, string path, Type type) => new GameStateParameterLookupEntry {
+ Name = name,
+ Path = path,
+ IsFolder = false,
+ ClrType = type,
+ Type = GSIPropertyTypeConverter.TypeToPropertyType(type)
+ };
+ }
+}
diff --git a/Project-Aurora/Project-Aurora/Profiles/GameState_Wrapper.cs b/Project-Aurora/Project-Aurora/Profiles/GameState_Wrapper.cs
index 53b099543..a20f128fd 100644
--- a/Project-Aurora/Project-Aurora/Profiles/GameState_Wrapper.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/GameState_Wrapper.cs
@@ -113,38 +113,19 @@ public Extra_Keys_Wrapper Extra_Keys
///
/// Creates a default GameState_Wrapper instance.
///
- public GameState_Wrapper()
- {
- json = "{}";
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json);
- }
+ public GameState_Wrapper() { }
///
/// Creates a GameState_Wrapper instance based on the passed json data.
///
/// The passed json data
- public GameState_Wrapper(string json_data) : base(json_data)
- {
- if (String.IsNullOrWhiteSpace(json_data))
- json_data = "{}";
-
- json = json_data;
- _ParsedData = JObject.Parse(json_data);
- }
-
- ///
- /// A copy constructor, creates a GameState_Wrapper instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_Wrapper(GameState other_state) : base(other_state)
- {
- }
+ public GameState_Wrapper(string json_data) : base(json_data) { }
}
///
/// Class representing provider information for the wrapper
///
- public class Provider_Wrapper : Node
+ public class Provider_Wrapper : Node
{
///
/// Name of the program
@@ -167,7 +148,7 @@ internal Provider_Wrapper(string JSON)
///
/// Class for additional wrapper command data such as effects and colors
///
- public class Command_Wrapper : Node
+ public class Command_Wrapper : Node
{
public int red_start;
public int green_start;
@@ -203,7 +184,7 @@ internal Command_Wrapper(string JSON)
///
/// Class for additional wrapper keys
///
- public class Extra_Keys_Wrapper : Node
+ public class Extra_Keys_Wrapper : Node
{
public Color peripheral;
public Color logo;
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/GameState_LoL.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/GameState_LoL.cs
index cd59bad0b..2eb948eb1 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/GameState_LoL.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/GameState_LoL.cs
@@ -7,7 +7,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI
{
- public class GameState_LoL : GameState
+ public class GameState_LoL : GameState
{
private PlayerNode player;
public PlayerNode Player => player ?? (player = new PlayerNode());
@@ -24,10 +24,5 @@ public GameState_LoL(string json_data) : base(json_data)
{
}
-
- public GameState_LoL(IGameState other_state) : base(other_state)
- {
-
- }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilitiesNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilitiesNode.cs
index b5a2713d3..5667da960 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilitiesNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilitiesNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI.Nodes
{
- public class AbilitiesNode : Node
+ public class AbilitiesNode : Node
{
public AbilityNode Q = new AbilityNode();
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilityNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilityNode.cs
index ab8742005..14c4c5edb 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilityNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/AbilityNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI.Nodes
{
- public class AbilityNode : Node
+ public class AbilityNode : Node
{
public bool Learned => Level != 0;
public int Level;
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/InventoryNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/InventoryNode.cs
index 7f9904c63..81c76890b 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/InventoryNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/InventoryNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI.Nodes
{
- public class InventoryNode : Node
+ public class InventoryNode : Node
{
public SlotNode Slot1 = new SlotNode();
public SlotNode Slot2 = new SlotNode();
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/ItemNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/ItemNode.cs
index f00572f5e..4960dfd1b 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/ItemNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/ItemNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI.Nodes
{
- public class SlotNode : Node
+ public class SlotNode : Node
{
public bool HasItem => Item != ItemID.None;
public bool CanUse;
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/MatchNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/MatchNode.cs
index b6252420f..665f400cf 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/MatchNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/MatchNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.LeagueOfLegends.GSI.Nodes
{
- public class MatchNode : Node
+ public class MatchNode : Node
{
public MapTerrain MapTerrain;
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/PlayerNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/PlayerNode.cs
index 914655487..c82a2ef9c 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/PlayerNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/PlayerNode.cs
@@ -200,7 +200,7 @@ public enum Position
Support
}
- public class PlayerNode : Node
+ public class PlayerNode : Node
{
public StatsNode ChampionStats = new StatsNode();
public AbilitiesNode Abilities = new AbilitiesNode();
diff --git a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/StatsNode.cs b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/StatsNode.cs
index ff3ae5212..fe90304f7 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/StatsNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LeagueOfLegends/GSI/Nodes/StatsNode.cs
@@ -26,7 +26,7 @@ public enum ResourceType
Max
}
- public class StatsNode : Node
+ public class StatsNode : Node
{
public float AbilityPower;
public float Armor;
diff --git a/Project-Aurora/Project-Aurora/Profiles/LightEvent.cs b/Project-Aurora/Project-Aurora/Profiles/LightEvent.cs
index 55c3ef33c..cf65f0d7c 100644
--- a/Project-Aurora/Project-Aurora/Profiles/LightEvent.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LightEvent.cs
@@ -108,7 +108,7 @@ public virtual bool IsEnabled
public virtual void ResetGameState()
{
- _game_state = new GameState();
+ _game_state = new EmptyGameState();
}
public virtual void OnStart()
diff --git a/Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs b/Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs
index 9e1f8efbe..ccc6c47df 100755
--- a/Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/LightingStateManager.cs
@@ -576,7 +576,7 @@ public void GameStateUpdate(IGameState gs)
{
IGameState gameState = gs;
if (profile.Config.GameStateType != null)
- gameState = (IGameState)Activator.CreateInstance(profile.Config.GameStateType, gs.json);
+ gameState = (IGameState)Activator.CreateInstance(profile.Config.GameStateType, gs.Json);
profile.SetGameState(gameState);
}
else if (gs is GameState_Wrapper && Global.Configuration.allow_all_logitech_bitmaps)
diff --git a/Project-Aurora/Project-Aurora/Profiles/LocalPCInformation.cs b/Project-Aurora/Project-Aurora/Profiles/LocalPCInformation.cs
new file mode 100644
index 000000000..156f4c8dd
--- /dev/null
+++ b/Project-Aurora/Project-Aurora/Profiles/LocalPCInformation.cs
@@ -0,0 +1,229 @@
+using Aurora.Utils;
+using NAudio.CoreAudioApi;
+using System.Linq;
+
+namespace Aurora.Profiles {
+ ///
+ /// Class representing local computer information
+ ///
+ public class LocalPCInformation : Node {
+ #region Time Properties
+ ///
+ /// The current hour
+ ///
+ public int CurrentHour => Time.GetHours();
+
+ ///
+ /// The current minute
+ ///
+ public int CurrentMinute => Time.GetMinutes();
+
+ ///
+ /// The current second
+ ///
+ public int CurrentSecond => Time.GetSeconds();
+
+ ///
+ /// The current millisecond
+ ///
+ public int CurrentMillisecond => Time.GetMilliSeconds();
+
+ ///
+ /// The total number of milliseconds since the epoch
+ ///
+ public long MillisecondsSinceEpoch => Time.GetMillisecondsSinceEpoch();
+ #endregion
+
+ #region Audio Properties
+ private static readonly MMDeviceEnumerator mmDeviceEnumerator = new MMDeviceEnumerator();
+ private static readonly NAudio.Wave.WaveInEvent waveInEvent = new NAudio.Wave.WaveInEvent();
+
+ ///
+ /// Gets the default endpoint for output (playback) devices e.g. speakers, headphones, etc.
+ /// This will return null if there are no playback devices available.
+ ///
+ private MMDevice DefaultAudioOutDevice {
+ get {
+ try { return mmDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console); }
+ catch { return null; }
+ }
+ }
+
+ ///
+ /// Gets the default endpoint for input (recording) devices e.g. microphones.
+ /// This will return null if there are no recording devices available.
+ ///
+ private MMDevice DefaultAudioInDevice {
+ get {
+ try { return mmDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console); }
+ catch { return null; }
+ }
+ }
+
+ ///
+ /// Current system volume (as set from the speaker icon)
+ ///
+ // Note: Manually checks if muted to return 0 since this is not taken into account with the MasterVolumeLevelScalar.
+ public float SystemVolume => SystemVolumeIsMuted ? 0 : DefaultAudioOutDevice?.AudioEndpointVolume.MasterVolumeLevelScalar * 100 ?? 0;
+
+ ///
+ /// Gets whether the system volume is muted.
+ ///
+ public bool SystemVolumeIsMuted => DefaultAudioOutDevice?.AudioEndpointVolume.Mute ?? true;
+
+ ///
+ /// The volume level that is being recorded by the default microphone even when muted.
+ ///
+ public float MicrophoneLevel => DefaultAudioInDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
+
+ ///
+ /// The volume level that is being emitted by the default speaker even when muted.
+ ///
+ public float SpeakerLevel => DefaultAudioOutDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
+
+ ///
+ /// The volume level that is being recorded by the default microphone if not muted.
+ ///
+ public float MicLevelIfNotMuted => MicrophoneIsMuted ? 0 : DefaultAudioInDevice?.AudioMeterInformation.MasterPeakValue * 100 ?? 0;
+
+ ///
+ /// Gets whether the default microphone is muted.
+ ///
+ public bool MicrophoneIsMuted => DefaultAudioInDevice?.AudioEndpointVolume.Mute ?? true;
+ #endregion
+
+ #region Device Properties
+ ///
+ /// Battery level of a dualshock controller
+ ///
+ public int DS4Battery => Global.dev_manager.GetInitializedDevices().OfType().FirstOrDefault()?.Battery ?? 0;
+ ///
+ /// Whether or not thr dualshock controller is charging
+ ///
+ public bool DS4Charging => Global.dev_manager.GetInitializedDevices().OfType().FirstOrDefault()?.Charging ?? false;
+ #endregion
+
+ #region CPU Properties
+ ///
+ /// Legacy cpu usage prop, DEPRECATED
+ ///
+ public float CPUUsage => CPU.Usage;
+
+ private static CPUInfo _cpuInfo;
+ public CPUInfo CPU => _cpuInfo ?? (_cpuInfo = new CPUInfo());
+ #endregion
+
+ #region RAM Properties
+ ///
+ /// Used RAM, DEPRECATED
+ ///
+ public long MemoryUsed => RAM.Used;
+
+ ///
+ /// Available RAM, DEPRECATED
+ ///
+ public long MemoryFree => RAM.Free;
+
+ ///
+ /// Total RAM, DEPRECATED
+ ///
+ public long MemoryTotal => MemoryFree + MemoryUsed;
+
+ private static RAMInfo _ramInfo;
+ public RAMInfo RAM => _ramInfo ?? (_ramInfo = new RAMInfo());
+ #endregion
+
+ #region GPU Properties
+ private static GPUInfo _gpuInfo;
+ public GPUInfo GPU => _gpuInfo ?? (_gpuInfo = new GPUInfo());
+ #endregion
+
+ #region NET Properties
+ private static NETInfo _netInfo;
+ public NETInfo NET => _netInfo ?? (_netInfo = new NETInfo());
+ #endregion
+
+ ///
+ /// Returns whether or not the device dession is in a locked state.
+ ///
+ public bool IsDesktopLocked => DesktopUtils.IsDesktopLocked;
+
+ static LocalPCInformation() {
+ void StartStopRecording() {
+ // We must start recording to be able to capture audio in, but only do this if the user has the option set. Allowing them
+ // to turn it off will give them piece of mind we're not spying on them and will stop the Windows 10 mic icon appearing.
+ try {
+ if (Global.Configuration.EnableAudioCapture)
+ waveInEvent.StartRecording();
+ else
+ waveInEvent.StopRecording();
+ } catch { }
+ }
+
+ StartStopRecording();
+ Global.Configuration.PropertyChanged += (sender, e) => {
+ if (e.PropertyName == "EnableAudioCapture")
+ StartStopRecording();
+ };
+ }
+ }
+
+ public class CPUInfo : Node
+ {
+ ///
+ /// Represents the CPU usage from 0 to 100
+ ///
+ public float Usage => HardwareMonitor.CPU.CPUTotalLoad;
+
+ ///
+ /// Represents the temperature of the cpu die in celsius
+ ///
+ public float Temperature => HardwareMonitor.CPU.CPUDieTemp;
+
+ ///
+ /// Represents the CPU power draw in watts
+ ///
+ public float PowerUsage => HardwareMonitor.CPU.CPUPower;
+ }
+
+ public class RAMInfo : Node
+ {
+ ///
+ /// Used system memory in megabytes
+ ///
+ public long Used => (long)(HardwareMonitor.RAM.RAMUsed * 1024f);
+
+ ///
+ /// Free system memory in megabytes
+ ///
+ public long Free => (long)(HardwareMonitor.RAM.RAMFree * 1024f);
+
+ ///
+ /// Total system memory in megabytes
+ ///
+ public long Total => Free + Used;
+ }
+
+ public class GPUInfo : Node
+ {
+ public float Usage => HardwareMonitor.GPU.GPUCoreLoad;
+ public float Temperature => HardwareMonitor.GPU.GPUCoreTemp;
+ public float PowerUsage => HardwareMonitor.GPU.GPUPower;
+ public float FanRPM => HardwareMonitor.GPU.GPUFan;
+ public float CoreClock => HardwareMonitor.GPU.GPUCoreClock;
+ public float MemoryClock => HardwareMonitor.GPU.GPUMemoryClock;
+ public float ShaderClock => HardwareMonitor.GPU.GPUShaderClock;
+ public float MemoryControllerUsage => HardwareMonitor.GPU.GPUMemoryCLoad;
+ public float VideoEngineUsage => HardwareMonitor.GPU.GPUVideoEngineLoad;
+ public float MemoryUsed => HardwareMonitor.GPU.GPUMemoryUsed;
+ public float MemoryFree => MemoryTotal - MemoryUsed;
+ public float MemoryTotal => HardwareMonitor.GPU.GPUMemoryTotal;
+ }
+
+ public class NETInfo : Node
+ {
+ public float Usage => HardwareMonitor.NET.BandwidthUsed;
+ public float UploadSpeed => HardwareMonitor.NET.UploadSpeedBytes;
+ public float DownloadSpeed => HardwareMonitor.NET.DownloadSpeedBytes;
+ }
+}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Minecraft/GSI/GameState_Minecraft.cs b/Project-Aurora/Project-Aurora/Profiles/Minecraft/GSI/GameState_Minecraft.cs
index abc1be1c3..79ced88b6 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Minecraft/GSI/GameState_Minecraft.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Minecraft/GSI/GameState_Minecraft.cs
@@ -9,7 +9,7 @@
namespace Aurora.Profiles.Minecraft.GSI {
- public class GameState_Minecraft : GameState {
+ public class GameState_Minecraft : GameState {
///
/// Provider node provides information about the data source so that Aurora can update the correct gamestate.
@@ -41,11 +41,6 @@ public GameState_Minecraft() : base() { }
///
///
public GameState_Minecraft(string JSONstring) : base(JSONstring) { }
-
- ///
- /// Creates a GameState_Minecraft instance based on the data from the passed GameState instance.
- ///
- public GameState_Minecraft(IGameState other) : base(other) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Node.cs b/Project-Aurora/Project-Aurora/Profiles/Node.cs
index 97d1698e6..59d51aa2f 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Node.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Node.cs
@@ -1,87 +1,49 @@
using Aurora.Utils;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq.Expressions;
-using System.Reflection;
namespace Aurora.Profiles
{
- public class Node : StringProperty where TClass : Node
+ public class Node
{
- protected Newtonsoft.Json.Linq.JObject _ParsedData;
+ protected JObject _ParsedData;
// Holds a cache of the child nodes on this node
private readonly Dictionary childNodes = new Dictionary(StringComparer.OrdinalIgnoreCase);
- public Node() : base()
- {
- _ParsedData = new Newtonsoft.Json.Linq.JObject();
+ public Node() {
+ _ParsedData = new JObject();
}
- public Node(string json_data) : this()
- {
- if (String.IsNullOrWhiteSpace(json_data))
+ public Node(string json_data) {
+ if (string.IsNullOrWhiteSpace(json_data))
json_data = "{}";
- try
- {
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json_data);
- }
- catch(Exception exc)
- {
+ try {
+ _ParsedData = JObject.Parse(json_data);
+ } catch (Exception exc) {
Global.logger.Error($"Exception during Node parsing. Exception: {exc}");
-
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse("{}");
+ _ParsedData = JObject.Parse("{}");
}
}
- public string GetString(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
-
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value))
- return value.ToString();
- else
- return "";
- }
-
- public int GetInt(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
+ public string GetString(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) ? value.ToString() : "";
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value))
- return Convert.ToInt32(value.ToString());
- else
- return -1;
- }
+ public int GetInt(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) ? Convert.ToInt32(value.ToString()) : -1;
- public float GetFloat(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
+ public float GetFloat(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) ? Convert.ToSingle(value.ToString()) : -1.0f;
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value))
- return Convert.ToSingle(value.ToString());
- else
- return -1.0f;
- }
-
- public long GetLong(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
-
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value))
- return Convert.ToInt64(value.ToString());
- else
- return -1;
- }
+ public long GetLong(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) ? Convert.ToInt64(value.ToString()) : -1l;
public T GetEnum(string Name) where T : struct
{
- Newtonsoft.Json.Linq.JToken value;
-
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value) && !String.IsNullOrWhiteSpace(value.ToString()))
- {
+ if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) && !string.IsNullOrWhiteSpace(value.ToString())) {
var type = typeof(T);
if (!type.IsEnum) throw new InvalidOperationException();
@@ -93,39 +55,27 @@ public T GetEnum(string Name) where T : struct
foreach (var field in type.GetFields())
if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute
&& attribute.Description.ToLowerInvariant().Equals(value.ToString().ToLowerInvariant()))
- return (T)field.GetValue(null);
+ return (T)field.GetValue(null);
}
// If there is an "undefined" enum value, return that else just do the default(T).
return Enum.TryParse("Undefined", true, out var u) ? u : default(T);
}
- public bool GetBool(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
+ public bool GetBool(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) && value.ToObject()
+ ? value.ToObject()
+ : false;
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value) && value.ToObject())
- return value.ToObject();
- else
- return false;
- }
-
- public T[] GetArray(string Name)
- {
- Newtonsoft.Json.Linq.JToken value;
-
- if (_ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out value))
- return value.ToObject();
- else
- return new T[] { };
- }
+ public T[] GetArray(string Name) =>
+ _ParsedData.TryGetValue(Name, StringComparison.OrdinalIgnoreCase, out var value) ? value.ToObject() : (new T[] { });
///
/// Method for accessing and caching a child node.
///
/// The type of node that will be returned by this method.
/// The JSON path of the child node.
- public TNode NodeFor(string name) where TNode : Node
+ public TNode NodeFor(string name) where TNode : Node
=> (TNode)(childNodes.TryGetValue(name, out var n) ? n : (childNodes[name] = Instantiator.Create( _ParsedData[name]?.ToString() ?? "")));
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Osu/GSI/GameState_Osu.cs b/Project-Aurora/Project-Aurora/Profiles/Osu/GSI/GameState_Osu.cs
index e83755d09..5d3c8d88c 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Osu/GSI/GameState_Osu.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Osu/GSI/GameState_Osu.cs
@@ -2,7 +2,7 @@
namespace Aurora.Profiles.Osu.GSI {
- public class GameState_Osu : GameState {
+ public class GameState_Osu : GameState {
public ProviderNode Provider => NodeFor("Provider");
@@ -10,7 +10,6 @@ public class GameState_Osu : GameState {
public GameState_Osu() : base() { }
public GameState_Osu(string JSONstring) : base(JSONstring) { }
- public GameState_Osu(IGameState other) : base(other) { }
}
public class GameNode : AutoJsonNode {
diff --git a/Project-Aurora/Project-Aurora/Profiles/Overlays/SkypeOverlay/State_SkypeOverlay.cs b/Project-Aurora/Project-Aurora/Profiles/Overlays/SkypeOverlay/State_SkypeOverlay.cs
index 525ce37cd..74ecbaafe 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Overlays/SkypeOverlay/State_SkypeOverlay.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Overlays/SkypeOverlay/State_SkypeOverlay.cs
@@ -45,7 +45,7 @@ public State_SkypeOverlay(IGameState other_state) : base(other_state)
}
}
- public class Skype_Integration : Node
+ public class Skype_Integration : Node
{
public int MissedMessagesCount;
public bool IsCalled;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/GameState_PD2.cs b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/GameState_PD2.cs
index ff65dc147..c60527287 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/GameState_PD2.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/GameState_PD2.cs
@@ -8,7 +8,7 @@ namespace Aurora.Profiles.Payday_2.GSI
///
/// A class representing various information retaining to Payday 2
///
- public class GameState_PD2 : GameState
+ public class GameState_PD2 : GameState
{
private ProviderNode _Provider;
private LobbyNode _Lobby;
@@ -118,34 +118,9 @@ public GameState_PD2 Previously
}
}
- ///
- /// Creates a default GameState_PD2 instance.
- ///
- public GameState_PD2()
- {
- json = "{}";
- _ParsedData = Newtonsoft.Json.Linq.JObject.Parse(json);
- }
- ///
- /// Creates a GameState_PD2 instance based on the passed json data.
- ///
- /// The passed json data
- public GameState_PD2(string JSONstring)
- {
- if (String.IsNullOrWhiteSpace(JSONstring))
- JSONstring = "{}";
- json = JSONstring;
- _ParsedData = JObject.Parse(JSONstring);
- }
-
- ///
- /// A copy constructor, creates a GameState_CSGO instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_PD2(IGameState other_state) : base(other_state)
- {
- }
+ public GameState_PD2() { }
+ public GameState_PD2(string json) : base(json) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/ItemsNode.cs b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/ItemsNode.cs
index a1e52394c..14e72640f 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/ItemsNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/ItemsNode.cs
@@ -4,7 +4,7 @@
namespace Aurora.Profiles.Payday_2.GSI.Nodes
{
- public class ItemsNode : Node
+ public class ItemsNode : Node
{
private List _Items = new List();
diff --git a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/PlayersNode.cs b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/PlayersNode.cs
index b6774e669..95f973ceb 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/PlayersNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/PlayersNode.cs
@@ -8,7 +8,7 @@ namespace Aurora.Profiles.Payday_2.GSI.Nodes
///
/// Information about players in the lobby
///
- public class PlayersNode : Node, IEnumerable
+ public class PlayersNode : Node, IEnumerable
{
private List _Players = new List();
private PlayerNode _LocalPlayer = new PlayerNode("");
diff --git a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/WeaponsNode.cs b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/WeaponsNode.cs
index c72b1fa2c..bb6387502 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/WeaponsNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Payday 2/GSI/Nodes/WeaponsNode.cs
@@ -3,7 +3,7 @@
namespace Aurora.Profiles.Payday_2.GSI.Nodes
{
- public class WeaponsNode : Node
+ public class WeaponsNode : Node
{
private List _Weapons = new List();
private WeaponNode _ActiveWeapon = new WeaponNode("");
diff --git a/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/GameState_ResidentEvil2.cs b/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/GameState_ResidentEvil2.cs
index 5e86d0033..488117b13 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/GameState_ResidentEvil2.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/GameState_ResidentEvil2.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.ResidentEvil2.GSI
///
/// A class representing various information relating to Resident Evil 2
///
- public class GameState_ResidentEvil2 : GameState
+ public class GameState_ResidentEvil2 : GameState
{
private Player_ResidentEvil2 player;
@@ -38,13 +38,5 @@ public GameState_ResidentEvil2() : base()
public GameState_ResidentEvil2(string json_data) : base(json_data)
{
}
-
- ///
- /// A copy constructor, creates a GameState_ResidentEvil2 instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_ResidentEvil2(IGameState other_state) : base(other_state)
- {
- }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/Nodes/Player.cs
index 49a61de69..017352eb3 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Resident Evil 2/GSI/Nodes/Player.cs
@@ -3,7 +3,7 @@
///
/// Class representing player information
///
- public class Player_ResidentEvil2 : Node
+ public class Player_ResidentEvil2 : Node
{
public enum PlayerStatus
{
diff --git a/Project-Aurora/Project-Aurora/Profiles/RocketLeague/GSI/GameState_RocketLeague.cs b/Project-Aurora/Project-Aurora/Profiles/RocketLeague/GSI/GameState_RocketLeague.cs
index 5cf51e160..a0c79320b 100644
--- a/Project-Aurora/Project-Aurora/Profiles/RocketLeague/GSI/GameState_RocketLeague.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/RocketLeague/GSI/GameState_RocketLeague.cs
@@ -32,7 +32,7 @@ internal Game_RocketLeague(string json_data) : base(json_data) { }
///
/// A class representing various information relating to Rocket League
///
- public class GameState_RocketLeague : GameState
+ public class GameState_RocketLeague : GameState
{
public Match_RocketLeague Match => NodeFor("match");
public Player_RocketLeague Player => NodeFor("player");
@@ -49,12 +49,6 @@ public GameState_RocketLeague() : base() { }
/// The passed json data
public GameState_RocketLeague(string json_data) : base(json_data) { }
- ///
- /// A copy constructor, creates a GameState_RocketLeague instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_RocketLeague(IGameState other_state) : base(other_state) { }
-
///
/// Returns true if all the color values for both teams are between zero and one.
///
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/GameState_Slime_Rancher.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/GameState_Slime_Rancher.cs
index 1a080a824..2c3f108b7 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/GameState_Slime_Rancher.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/GameState_Slime_Rancher.cs
@@ -8,7 +8,7 @@
namespace Aurora.Profiles.Slime_Rancher.GSI {
- public class GameState_Slime_Rancher : GameState {
+ public class GameState_Slime_Rancher : GameState {
private ProviderNode _Provider;
private GameStateNode _GameState;
@@ -112,11 +112,5 @@ public GameState_Slime_Rancher() : base() { }
///
///
public GameState_Slime_Rancher(string JSONstring) : base(JSONstring) { }
-
- ///
- /// Creates a GameState_Slime_Rancher instance based on the data from the passed GameState instance.
- ///
- public GameState_Slime_Rancher(IGameState other) : base(other) { }
-
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/GameStateNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/GameStateNode.cs
index f006d5d3f..aed4a570c 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/GameStateNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/GameStateNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes {
- public class GameStateNode : Node {
+ public class GameStateNode : Node {
public bool InMenu;
public bool loading;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/LocationNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/LocationNode.cs
index 0bd5f8382..a7b08dc04 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/LocationNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/LocationNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes
{
- public class LocationNode : Node
+ public class LocationNode : Node
{
public BiomeNode In;
@@ -17,7 +17,7 @@ internal LocationNode(string json) : base(json)
}
- public class BiomeNode : Node
+ public class BiomeNode : Node
{
public bool None;
public bool TheRanch;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/MailNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/MailNode.cs
index 1bcbca2a0..76d6af38b 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/MailNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/MailNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes {
- public class MailNode : Node {
+ public class MailNode : Node {
public bool NewMail;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/PlayerNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/PlayerNode.cs
index 281f7bd91..2a4111ab9 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/PlayerNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/PlayerNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes {
- public class PlayerNode : Node {
+ public class PlayerNode : Node {
public HealthNode Health;
public EnergyNode Energy;
@@ -20,7 +20,7 @@ internal PlayerNode(string json) : base(json) {
}
- public class HealthNode : Node
+ public class HealthNode : Node
{
public int Current;
public int Max;
@@ -32,7 +32,7 @@ internal HealthNode(string json) : base(json)
}
}
- public class EnergyNode : Node
+ public class EnergyNode : Node
{
public int Current;
public int Max;
@@ -44,7 +44,7 @@ internal EnergyNode(string json) : base(json)
}
}
- public class RadNode : Node
+ public class RadNode : Node
{
public int Current;
public int Max;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/ProviderNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/ProviderNode.cs
index 6522918d5..67940da1b 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/ProviderNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/ProviderNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes
{
- public class ProviderNode : Node
+ public class ProviderNode : Node
{
public string Name;
public int AppID;
@@ -19,7 +19,7 @@ internal ProviderNode(string json) : base(json)
//ModVer = new ModVerNode(_ParsedData["modver"]?.ToString() ?? "");
}
- public class ModVerNode : Node
+ public class ModVerNode : Node
{
public int Major;
public int Minor;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/VacPackNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/VacPackNode.cs
index fd5da5786..56d946875 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/VacPackNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/VacPackNode.cs
@@ -6,7 +6,7 @@
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes
{
- public class VacPackNode : Node
+ public class VacPackNode : Node
{
public AmountNode Amount;
public MaxNode Max;
@@ -31,7 +31,7 @@ internal VacPackNode(string json) : base(json)
InNimbleValleyMode = GetBool("in_nimble_valley_mode");
}
- public class AmountNode : Node
+ public class AmountNode : Node
{
public int SellectedSlot;
public int Slot1;
@@ -51,7 +51,7 @@ internal AmountNode(string json) : base(json)
}
}
- public class MaxNode : Node
+ public class MaxNode : Node
{
public int SellectedSlot;
public int Slot1;
@@ -71,7 +71,7 @@ internal MaxNode(string json) : base(json)
}
}
- public class ColorNode : Node
+ public class ColorNode : Node
{
public SellectedSlotNode SellectedSlot;
public ColorSlot1Node Slot1;
@@ -91,7 +91,7 @@ internal ColorNode(string json) : base(json)
}
}
#region ColorSlotNodes
- public class SellectedSlotNode : Node
+ public class SellectedSlotNode : Node
{
public float Red;
public float Green;
@@ -107,7 +107,7 @@ internal SellectedSlotNode(string json) : base(json)
}
}
- public class ColorSlot1Node : Node
+ public class ColorSlot1Node : Node
{
public float Red;
public float Green;
@@ -123,7 +123,7 @@ internal ColorSlot1Node(string json) : base(json)
}
}
- public class ColorSlot2Node : Node
+ public class ColorSlot2Node : Node
{
public float Red;
public float Green;
@@ -139,7 +139,7 @@ internal ColorSlot2Node(string json) : base(json)
}
}
- public class ColorSlot3Node : Node
+ public class ColorSlot3Node : Node
{
public float Red;
public float Green;
@@ -155,7 +155,7 @@ internal ColorSlot3Node(string json) : base(json)
}
}
- public class ColorSlot4Node : Node
+ public class ColorSlot4Node : Node
{
public float Red;
public float Green;
@@ -171,7 +171,7 @@ internal ColorSlot4Node(string json) : base(json)
}
}
- public class ColorSlot5Node : Node
+ public class ColorSlot5Node : Node
{
public float Red;
public float Green;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/WorldNode.cs b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/WorldNode.cs
index 8634b9462..563975d84 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/WorldNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Slime Rancher/GSI/Nodes/WorldNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Slime_Rancher.GSI.Nodes {
- public class WorldNode : Node {
+ public class WorldNode : Node {
public TimeNode Time;
public bool Paused;
@@ -16,7 +16,7 @@ internal WorldNode(string json) : base(json) {
}
}
- public class TimeNode : Node
+ public class TimeNode : Node
{
public int Hour;
public int Min;
diff --git a/Project-Aurora/Project-Aurora/Profiles/StringProperty.cs b/Project-Aurora/Project-Aurora/Profiles/StringProperty.cs
deleted file mode 100644
index 767c4af17..000000000
--- a/Project-Aurora/Project-Aurora/Profiles/StringProperty.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Aurora.Profiles
-{
- public interface IStringProperty
- {
- object GetValueFromString(string name, object input = null);
- void SetValueFromString(string name, object value);
- IStringProperty Clone();
- }
-
- public class StringProperty : IStringProperty
- {
- public static Dictionary, Action, Type>> PropertyLookup { get; set; } = null;
- public static object DictLock = new object();
-
- public StringProperty()
- {
- lock (DictLock)
- {
- if (PropertyLookup != null)
- return;
-
- PropertyLookup = new Dictionary, Action, Type>>();
-
- Type typ = typeof(T);
- foreach (MemberInfo prop in typ.GetMembers())
- {
- ParameterExpression paramExpression = Expression.Parameter(typ);
- Func getp;
- switch (prop.MemberType)
- {
- case MemberTypes.Property:
- case MemberTypes.Field:
- Type t = Expression.GetFuncType(typ, typeof(object));
-
- LambdaExpression exp = Expression.Lambda(
- t,
- Expression.Convert(
- Expression.PropertyOrField(paramExpression, prop.Name),
- typeof(object)
- ),
- paramExpression
- );
-
- getp = (Func)exp.Compile();
- break;
- /*case MemberTypes.Property:
- getp = (Func)Delegate.CreateDelegate(
- typeof(Func),
- ((PropertyInfo)prop).GetMethod
- );
-
- break;*/
- default:
- continue;
- }
-
-
-
- Action setp = null;
- if (!(prop.MemberType == MemberTypes.Property && ((PropertyInfo)prop).SetMethod == null))
- {
- ParameterExpression paramExpression2 = Expression.Parameter(typeof(object));
- MemberExpression propertyGetterExpression = Expression.PropertyOrField(paramExpression, prop.Name);
-
- Type var_type;
- if (prop is PropertyInfo)
- var_type = ((PropertyInfo)prop).PropertyType;
- else
- var_type = ((FieldInfo)prop).FieldType;
-
- setp = Expression.Lambda>
- (
- Expression.Assign(propertyGetterExpression, Expression.ConvertChecked(paramExpression2, var_type)), paramExpression, paramExpression2
- ).Compile();
- }
- if (!PropertyLookup.ContainsKey(prop.Name))
- {
- PropertyLookup.Add(prop.Name, new Tuple, Action, Type>(getp, setp, typ));
- }
-
- }
- }
- }
-
- public object GetValueFromString(string name, object input = null)
- {
- if (PropertyLookup.ContainsKey(name))
- {
- return PropertyLookup[name].Item1((T)(object)this);
- }
-
- /*Type t = obj.GetType();
- MemberInfo member;
- if ((member = input == null ? t.GetMember(name).FirstOrDefault() : t.GetMethod(name, new[] { input.GetType() })) != null)
- {
- if (member is FieldInfo)
- return ((FieldInfo)member).GetValue(obj);
- else if (member is PropertyInfo)
- return ((PropertyInfo)member).GetValue(obj);
- else if (member is MethodInfo)
- return ((MethodInfo)member).Invoke(obj, new[] { input });
- }*/
-
- return null;
- }
-
- public void SetValueFromString(string name, object value)
- {
- if (PropertyLookup.ContainsKey(name))
- {
- PropertyLookup[name]?.Item2((T)(object)this, value);
- }
- }
-
- public IStringProperty Clone()
- {
- return (IStringProperty)this.MemberwiseClone();
- }
- }
-}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/GameState_Subnautica.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/GameState_Subnautica.cs
index ca40f2b0e..972a4d12e 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/GameState_Subnautica.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/GameState_Subnautica.cs
@@ -9,7 +9,7 @@
namespace Aurora.Profiles.Subnautica.GSI {
- public class GameState_Subnautica : GameState {
+ public class GameState_Subnautica : GameState {
private ProviderNode _Provider;
private GameStateNode _GameState;
@@ -84,11 +84,6 @@ public GameState_Subnautica() : base() { }
///
///
public GameState_Subnautica(string JSONstring) : base(JSONstring) { }
-
- ///
- /// Creates a GameState_Subnautica instance based on the data from the passed GameState instance.
- ///
- public GameState_Subnautica(IGameState other) : base(other) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/GameStateNode.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/GameStateNode.cs
index 0cf2eab17..244693935 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/GameStateNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/GameStateNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Subnautica.GSI.Nodes {
- public class GameStateNode : Node {
+ public class GameStateNode : Node {
public int GameState;
/*
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/NotificationNode.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/NotificationNode.cs
index 8cadc5160..25dd171fd 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/NotificationNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/NotificationNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Subnautica.GSI.Nodes {
- public class NotificationNode : Node {
+ public class NotificationNode : Node {
public int UndefinedNotificationCount;
public int InventoryNotificationCount;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/PlayerNode.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/PlayerNode.cs
index 9fdb69a2a..1d9560161 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/PlayerNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/PlayerNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Subnautica.GSI.Nodes {
- public class PlayerNode : Node {
+ public class PlayerNode : Node {
public string Biom;
public bool InLifePod;
diff --git a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/WorldNode.cs b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/WorldNode.cs
index c4362dec2..ca2456983 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/WorldNode.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Subnautica/GSI/Nodes/WorldNode.cs
@@ -5,7 +5,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.Subnautica.GSI.Nodes {
- public class WorldNode : Node {
+ public class WorldNode : Node {
public float DayScalar;
//public bool IsDay;
diff --git a/Project-Aurora/Project-Aurora/Profiles/TModLoader/GSI/GameState_TModLoader.cs b/Project-Aurora/Project-Aurora/Profiles/TModLoader/GSI/GameState_TModLoader.cs
index d37c95e20..d80b76e34 100644
--- a/Project-Aurora/Project-Aurora/Profiles/TModLoader/GSI/GameState_TModLoader.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/TModLoader/GSI/GameState_TModLoader.cs
@@ -8,7 +8,7 @@
using System.Threading.Tasks;
namespace Aurora.Profiles.TModLoader.GSI {
- public class GameState_TModLoader : GameState {
+ public class GameState_TModLoader : GameState {
public ProviderNode Provider => NodeFor("provider");
public WorldNode World => NodeFor("world");
@@ -22,10 +22,5 @@ public GameState_TModLoader() : base() { }
///
///
public GameState_TModLoader(string JSONstring) : base(JSONstring) { }
-
- ///
- /// Creates a GameState_Terraria instance based on the data from the passed GameState instance.
- ///
- public GameState_TModLoader(IGameState other) : base(other) { }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/GameState_Witcher3.cs b/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/GameState_Witcher3.cs
index 05fa7d34c..312a764d6 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/GameState_Witcher3.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/GameState_Witcher3.cs
@@ -6,7 +6,7 @@ namespace Aurora.Profiles.Witcher3.GSI
///
/// A class representing various information retaining to Game State Integration of Witcher 3
///
- public class GameState_Witcher3 : GameState
+ public class GameState_Witcher3 : GameState
{
private Player_Witcher3 player;
@@ -35,13 +35,5 @@ public GameState_Witcher3() : base()
public GameState_Witcher3(string json_data) : base(json_data)
{
}
-
- ///
- /// A copy constructor, creates a GameState_Witcher3 instance based on the data from the passed GameState instance.
- ///
- /// The passed GameState
- public GameState_Witcher3(IGameState other_state) : base(other_state)
- {
- }
}
}
diff --git a/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/Nodes/Player.cs b/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/Nodes/Player.cs
index 831fe3479..1ca849cb8 100644
--- a/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/Nodes/Player.cs
+++ b/Project-Aurora/Project-Aurora/Profiles/Witcher3/GSI/Nodes/Player.cs
@@ -3,7 +3,7 @@
///
/// Class representing player information
///
- public class Player_Witcher3 : Node
+ public class Player_Witcher3 : Node
{
public int MaximumHealth = 0;
public int CurrentHealth = 0;
diff --git a/Project-Aurora/Project-Aurora/Project-Aurora.csproj b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
index 63ea59675..4d8434f6e 100644
--- a/Project-Aurora/Project-Aurora/Project-Aurora.csproj
+++ b/Project-Aurora/Project-Aurora/Project-Aurora.csproj
@@ -205,6 +205,7 @@
+
@@ -221,6 +222,7 @@
Control_LoLBackgroundLayer.xaml
+
@@ -675,6 +677,7 @@
+
@@ -941,7 +944,6 @@
- Control_WormsWMD.xaml
@@ -1488,7 +1490,6 @@
-
@@ -2603,6 +2604,9 @@
1.13.7
+
+ 1.5.0
+ 6.1.1runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/Project-Aurora/Project-Aurora/Settings/Control_LayerList.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Control_LayerList.xaml.cs
index 4cade1478..f3e323138 100644
--- a/Project-Aurora/Project-Aurora/Settings/Control_LayerList.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Control_LayerList.xaml.cs
@@ -145,7 +145,7 @@ public string ListTitle {
/// Adds a new layer to the currently active collection. Will also setup the event listener to make the profile save and set the layer's application.
///
private void AddLayer(Layer layer) {
- layer.AnythingChanged += FocusedApplication.SaveProfilesEvent;
+ layer.PropertyChanged += FocusedApplication.SaveProfilesEvent;
layer.SetProfile(FocusedApplication);
ActiveLayerCollection.Insert(0, layer);
SelectedLayer = layer;
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/AnimationLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/AnimationLayerHandler.cs
index d6e87301b..b6c883cd7 100755
--- a/Project-Aurora/Project-Aurora/Settings/Layers/AnimationLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/AnimationLayerHandler.cs
@@ -216,7 +216,7 @@ private void CheckTriggers(IGameState gamestate) {
// Evaluate the evaluatable or the game state path and retrieve the double
double resolvedTriggerValue = IsTriggerEvaluatableNumericValueBased(Properties.TriggerMode)
? ((IEvaluatable)Properties.EvaluatableTrigger)?.Evaluate(gamestate) ?? 0 // Evaluatable may be null, so we need to account for that
- : GameStateUtils.TryGetDoubleFromState(gamestate, Properties.TriggerPath);
+ : gamestate.GetNumber(Properties.TriggerPath);
// Check to see if a gamestate value change should trigger the animation
switch (Properties.TriggerMode) {
@@ -243,7 +243,7 @@ private void CheckTriggers(IGameState gamestate) {
// Evaluatable the boolean, either as an evaluatable or a game state variable.
bool resolvedTriggerValue = IsTriggerEvaluatableBooleanValueBased(Properties.TriggerMode)
? ((IEvaluatable)Properties.EvaluatableTrigger)?.Evaluate(gamestate) ?? false // Evaluatable may be null, so we need to account for that
- : GameStateUtils.TryGetBoolFromState(gamestate, Properties.TriggerPath);
+ : gamestate.GetBool(Properties.TriggerPath);
switch (Properties.TriggerMode) {
case AnimationTriggerMode.OnTrue:
@@ -291,7 +291,7 @@ private void CheckTriggers(IGameState gamestate) {
public override void SetApplication(Application profile) {
// Check to ensure the property specified actually exists
- if (profile != null && !string.IsNullOrWhiteSpace(Properties._TriggerPath) && !profile.ParameterLookup.ContainsKey(Properties._TriggerPath))
+ if (profile != null && !string.IsNullOrWhiteSpace(Properties._TriggerPath) && !profile.ParameterLookup.IsValidParameter(Properties._TriggerPath))
Properties._TriggerPath = string.Empty;
// Tell the control to update (will update the combobox with the possible variable paths)
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/BinaryCounterLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/BinaryCounterLayerHandler.cs
index d046afa60..87f5451ed 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/BinaryCounterLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/BinaryCounterLayerHandler.cs
@@ -44,7 +44,7 @@ public override void SetApplication(Application profile) {
public override EffectLayer Render(IGameState gamestate) {
// Get the current game state value
- double value = Properties.Logic._Value ?? Utils.GameStateUtils.TryGetDoubleFromState(gamestate, Properties.VariablePath);
+ double value = Properties.Logic._Value ?? gamestate.GetNumber(Properties.VariablePath);
// Set the active key
var layer = new EffectLayer("BinaryCounterCustomLayer");
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/ComparisonLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/ComparisonLayerHandler.cs
index 37296c7c3..279794b0b 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/ComparisonLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/ComparisonLayerHandler.cs
@@ -45,8 +45,8 @@ protected override UserControl CreateControl() {
public override EffectLayer Render(IGameState gamestate) {
// Parse the operands
- double op1 = Utils.GameStateUtils.TryGetDoubleFromState(gamestate, Properties.Operand1Path);
- double op2 = Utils.GameStateUtils.TryGetDoubleFromState(gamestate, Properties.Operand2Path);
+ double op1 = gamestate.GetNumber(Properties.Operand1Path);
+ double op2 = gamestate.GetNumber(Properties.Operand2Path);
// Evaluate the operands
bool cond = false;
@@ -67,9 +67,9 @@ public override EffectLayer Render(IGameState gamestate) {
public override void SetApplication(Application profile) {
if (profile != null) {
- if (!double.TryParse(Properties._Operand1Path, out double value) && !string.IsNullOrWhiteSpace(Properties._Operand1Path) && !profile.ParameterLookup.ContainsKey(Properties._Operand1Path))
+ if (!double.TryParse(Properties._Operand1Path, out double value) && !string.IsNullOrWhiteSpace(Properties._Operand1Path) && !profile.ParameterLookup.IsValidParameter(Properties._Operand1Path))
Properties._Operand1Path = string.Empty;
- if (!double.TryParse(Properties._Operand2Path, out value) && !string.IsNullOrWhiteSpace(Properties._Operand2Path) && !profile.ParameterLookup.ContainsKey(Properties._Operand2Path))
+ if (!double.TryParse(Properties._Operand2Path, out value) && !string.IsNullOrWhiteSpace(Properties._Operand2Path) && !profile.ParameterLookup.IsValidParameter(Properties._Operand2Path))
Properties._Operand2Path = string.Empty;
}
(Control as Control_ComparisonLayer).SetProfile(profile);
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/ConditionalLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/ConditionalLayerHandler.cs
index d6381ae5e..eba3de449 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/ConditionalLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/ConditionalLayerHandler.cs
@@ -31,12 +31,7 @@ protected override UserControl CreateControl() {
public override EffectLayer Render(IGameState gamestate) {
EffectLayer layer = new EffectLayer("Conditional Layer");
- bool result = false;
- if (Properties.ConditionPath.Length > 0)
- try {
- object tmp = Utils.GameStateUtils.RetrieveGameStateParameter(gamestate, Properties.ConditionPath);
- result = (bool)Utils.GameStateUtils.RetrieveGameStateParameter(gamestate, Properties.ConditionPath);
- } catch { }
+ bool result = gamestate.GetBool(Properties.ConditionPath);
layer.Set(Properties.Sequence, result ? Properties.PrimaryColor : Properties.SecondaryColor);
return layer;
@@ -44,7 +39,7 @@ public override EffectLayer Render(IGameState gamestate) {
public override void SetApplication(Application profile) {
if (profile != null) {
- if (!string.IsNullOrWhiteSpace(Properties._ConditionPath) && !profile.ParameterLookup.ContainsKey(Properties._ConditionPath))
+ if (!string.IsNullOrWhiteSpace(Properties._ConditionPath) && !profile.ParameterLookup.IsValidParameter(Properties._ConditionPath))
Properties._ConditionPath = string.Empty;
}
(Control as Control_ConditionalLayer).SetProfile(profile);
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_AnimationLayer.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Control_AnimationLayer.xaml.cs
index 10c2b50f8..5f1daa7ec 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_AnimationLayer.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_AnimationLayer.xaml.cs
@@ -96,13 +96,13 @@ private void UpdatePathCombobox() {
triggerPathItemsAreBoolean = isTriggerBoolean;
// Get a list of the parameters. If trigger is boolean mode, filters to only boolean values, else does numeric values
- triggerPath.ItemsSource = profile?.ParameterLookup?
+ /*triggerPath.ItemsSource = profile?.ParameterLookup?
.Where(kvp => isTriggerBoolean
? kvp.Value.Item1 == typeof(bool)
: TypeUtils.IsNumericType(kvp.Value.Item1)
)
.Select(kvp => kvp.Key)
- .ToList();
+ .ToList();*/
}
private void btnEditAnimation_Click(object sender, RoutedEventArgs e) {
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml b/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml
index c8ac1de12..c709d9061 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml
@@ -32,7 +32,7 @@
-
+
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml.cs
index ac7beb00e..8b958a28c 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_BinaryCounterLayer.xaml.cs
@@ -13,7 +13,7 @@ public Control_BinaryCounterLayer(BinaryCounterLayerHandler context) {
}
public void SetApplication(Profiles.Application app) {
- valuePath.ItemsSource = app.ParameterLookup?.Where(kvp => Utils.TypeUtils.IsNumericType(kvp.Value.Item1)).Select(kvp => kvp.Key);
+ varPathPicker.Application = app;
}
private void KeySequence_SequenceUpdated(object sender, System.EventArgs e) {
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_ComparisonLayer.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Control_ComparisonLayer.xaml.cs
index ea967e2ac..98d5c75bb 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_ComparisonLayer.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_ComparisonLayer.xaml.cs
@@ -23,7 +23,6 @@ namespace Aurora.Settings.Layers {
public partial class Control_ComparisonLayer : UserControl {
private bool settingsset = false;
- private bool profileset = false;
public Control_ComparisonLayer() {
InitializeComponent();
@@ -55,17 +54,6 @@ public void SetSettings() {
}
internal void SetProfile(Profiles.Application profile) {
- if (profile != null && !profileset) {
- var var_types_numerical = profile.ParameterLookup?.Where(kvp => Utils.TypeUtils.IsNumericType(kvp.Value.Item1));
- operand1Path.Items.Clear();
- operand2Path.Items.Clear();
- foreach (var item in var_types_numerical) {
- operand1Path.Items.Add(item.Key);
- operand2Path.Items.Add(item.Key);
- }
-
- profileset = true;
- }
settingsset = false;
this.SetSettings();
}
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Control_ConditionalLayer.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Control_ConditionalLayer.xaml.cs
index b11dcd83a..27adbcdc8 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Control_ConditionalLayer.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Control_ConditionalLayer.xaml.cs
@@ -21,7 +21,6 @@ namespace Aurora.Settings.Layers {
public partial class Control_ConditionalLayer : UserControl {
private bool settingsset = false;
- private bool profileset = false;
public Control_ConditionalLayer() {
InitializeComponent();
@@ -45,14 +44,6 @@ public void SetSettings() {
}
internal void SetProfile(Profiles.Application profile) {
- if (profile != null && !profileset) {
- var var_types_boolean = profile.ParameterLookup?.Where(kvp => Type.GetTypeCode(kvp.Value.Item1) == TypeCode.Boolean);
- conditionPath.Items.Clear();
- foreach (var item in var_types_boolean)
- conditionPath.Items.Add(item.Key);
-
- profileset = true;
- }
settingsset = false;
this.SetSettings();
}
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/Layer.cs b/Project-Aurora/Project-Aurora/Settings/Layers/Layer.cs
index 59e1c08ae..1e6ff74fd 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/Layer.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/Layer.cs
@@ -3,274 +3,86 @@
using Aurora.Settings.Overrides.Logic;
using Aurora.Settings.Overrides.Logic.Builder;
using Newtonsoft.Json;
+using PropertyChanged;
using System;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Controls;
namespace Aurora.Settings.Layers
{
- ///
- /// All available layer types. Note: There is a large overhead for generap purpose layers, so there is ample room for adding new layers that apply to all profiles.
- /// Each game reserves 50 unique layer types.
- ///
- /*public enum LayerType
- {
- [Description("Default Layer")]
- Default = 0,
-
- [Description("Animation Layer")]
- Animation = 10,
-
- [Description("Solid Color Layer")]
- Solid = 100,
-
- [Description("Solid Fill Color Layer")]
- SolidFilled = 110,
-
- [Description("Gradient Layer")]
- Gradient = 115,
-
- [Description("Gradient Fill Layer")]
- GradientFill = 116,
-
- [Description("Breathing Layer")]
- Breathing = 120,
-
- [Description("Blinking Layer")]
- Blinking = 121,
-
- [Description("Image Layer")]
- Image = 122,
-
- [Description("Script Layer")]
- Script = 123,
-
- [Description("Percent Effect Layer")]
- Percent = 200,
-
- [Description("Percent (Gradient) Effect Layer")]
- PercentGradient = 201,
-
- [Description("Interactive Layer")]
- Interactive = 300,
-
- [Description("Shortcut Assistant Layer")]
- ShortcutAssistant = 400,
-
- [Description("Equalizer Layer")]
- Equalizer = 500,
-
- [Description("Ambilight Layer")]
- Ambilight = 600,
-
- [Description("Lock Color Layer")]
- LockColor = 700,
-
- [Description("Dota 2 Background Layer")]
- Dota2Background = 800,
-
- [Description("Dota 2 Respawn Layer")]
- Dota2Respawn = 801,
-
- [Description("Dota 2 Abilies Layer")]
- Dota2Abilities = 802,
-
- [Description("Dota 2 Items Layer")]
- Dota2Items = 803,
-
- [Description("Dota 2 Hero Abiliy Effects Layer")]
- Dota2HeroAbilityEffects = 804,
-
- [Description("Dota 2 Killstreak Layer")]
- Dota2Killstreak = 805,
-
- [Description("CSGO Background Layer")]
- CSGOBackground = 850,
-
- [Description("CSGO Bomb Layer")]
- CSGOBomb = 851,
-
- [Description("CSGO Kills Indicator Layer")]
- CSGOKillsIndicator = 852,
-
- [Description("CSGO Burning Effect Layer")]
- CSGOBurning = 853,
-
- [Description("CSGO Flashbang Effect Layer")]
- CSGOFlashbang = 854,
-
- [Description("CSGO Typing Layer")]
- CSGOTyping = 855,
-
- [Description("GTA 5 Background Layer")]
- GTA5Background = 900,
-
- [Description("GTA 5 Police Siren Layer")]
- GTA5PoliceSiren = 901,
-
- [Description("Rocket League Background Layer")]
- RocketLeagueBackground = 950,
-
- [Description("Payday 2 Background Layer")]
- PD2Background = 1000,
-
- [Description("Payday 2 Flashbang Layer")]
- PD2Flashbang = 1001,
-
- [Description("Payday 2 States Layer")]
- PD2States = 1002,
-
- }*/
///
/// A class representing a default settings layer
///
- public class Layer : ICloneable, IDisposable
+ public class Layer : INotifyPropertyChanged, ICloneable, IDisposable
{
- private Application _application;
-
- [JsonIgnore]
- public Application AssociatedApplication { get { return _application; } }
+ [DoNotNotify, JsonIgnore]
+ public Application AssociatedApplication { get; private set; }
- public event EventHandler AnythingChanged;
-
- protected string _Name = "New Layer";
-
- public string Name
- {
- get { return _Name; }
- set
- {
- _Name = value;
- AnythingChanged?.Invoke(this, null);
- }
- }
+ public string Name { get; set; } = "New Layer";
- private ILayerHandler _Handler = new DefaultLayerHandler();
-
- public ILayerHandler Handler
- {
- get { return _Handler; }
- set
- {
- _Handler = value;
-
- if(_application != null)
- _Handler.SetApplication(_application);
- }
- }
+ [OnChangedMethod(nameof(OnHandlerChanged))]
+ public ILayerHandler Handler { get; set; } = new DefaultLayerHandler();
[JsonIgnore]
- public UserControl Control
- {
- get
- {
- return _Handler.Control;
- }
- }
-
- protected bool _Enabled = true;
-
- public bool Enabled
- {
- get { return _Enabled; }
- set
- {
- _Enabled = value;
- AnythingChanged?.Invoke(this, null);
- }
- }
+ public UserControl Control => Handler.Control;
- /*protected string _Type;
+ public bool Enabled { get; set; } = true;
- public string Type
- {
- get { return _Type; }
- set
- {
- _Type = value;
- AnythingChanged?.Invoke(this, null);
- }
- }*/
+ public Dictionary OverrideLogic { get; set; }
+ // private void OnOverrideLogicChanged() => // Make the logic collection changed event trigger a property change to ensure it gets saved?
- protected Dictionary _OverrideLogic;
+ #region Constructors
+ public Layer() { }
- public Dictionary OverrideLogic
- {
- get { return _OverrideLogic; }
- set
- {
- _OverrideLogic = value;
- AnythingChanged?.Invoke(this, null);
- //if (value != null)
- // _OverrideLogic.CollectionChanged += (sender, e) => AnythingChanged?.Invoke(this, null);
- }
- }
-
- ///
- ///
- ///
- public Layer()
- {
- }
-
- public Layer(string name, ILayerHandler handler = null) : this()
- {
+ public Layer(string name, ILayerHandler handler = null) : this() {
Name = name;
- if (handler != null)
- _Handler = handler;
+ Handler = handler ?? Handler;
}
public Layer(string name, ILayerHandler handler, Dictionary overrideLogic) : this(name, handler) {
- _OverrideLogic = overrideLogic;
+ OverrideLogic = overrideLogic;
}
public Layer(string name, ILayerHandler handler, OverrideLogicBuilder builder) : this(name, handler, builder.Create()) { }
+ #endregion
+
+ public event PropertyChangedEventHandler PropertyChanged;
- public EffectLayer Render(IGameState gs)
- {
- if (_OverrideLogic != null)
- // For every property which has an override logic assigned
- foreach (var kvp in _OverrideLogic)
+ private void OnHandlerChanged() {
+ if (AssociatedApplication != null)
+ Handler.SetApplication(AssociatedApplication);
+ }
+
+ public EffectLayer Render(IGameState gs) {
+ if (OverrideLogic != null) {
+ // For every property which has an override logic assigned
+ foreach (var kvp in OverrideLogic)
// Set the value of the logic evaluation as the override for this property
- ((IValueOverridable)_Handler.Properties).Overrides.SetValueFromString(kvp.Key, kvp.Value.Evaluate(gs));
+ ((IValueOverridable)Handler.Properties).SetOverride(kvp.Key, kvp.Value.Evaluate(gs));
+ }
- return ((dynamic)_Handler.Properties).Enabled ? _Handler.PostRenderFX(_Handler.Render(gs)) : new EffectLayer();
+ return ((dynamic)Handler.Properties).Enabled ? Handler.PostRenderFX(Handler.Render(gs)) : new EffectLayer();
}
- public void SetProfile(Application profile)
- {
- _application = profile;
-
- _Handler?.SetApplication(_application);
+ public void SetProfile(Application profile) {
+ AssociatedApplication = profile;
+ Handler?.SetApplication(AssociatedApplication);
}
- public object Clone()
- {
+ public object Clone() {
string str = JsonConvert.SerializeObject(this, Formatting.None, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, Binder = Aurora.Utils.JSONUtils.SerializationBinder });
-
return JsonConvert.DeserializeObject(
- str,
- this.GetType(),
- new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace, TypeNameHandling = TypeNameHandling.All, Binder = Aurora.Utils.JSONUtils.SerializationBinder }
- );
- }
-
- public void SetGameState(IGameState new_game_state)
- {
- Handler.SetGameState(new_game_state);
+ str,
+ this.GetType(),
+ new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace, TypeNameHandling = TypeNameHandling.All, Binder = Aurora.Utils.JSONUtils.SerializationBinder }
+ );
}
- public void Dispose()
- {
- this.Handler.Dispose();
- }
+ public void SetGameState(IGameState new_game_state) => Handler.SetGameState(new_game_state);
+ public void Dispose() => Handler.Dispose();
}
///
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/LayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/LayerHandler.cs
index 472c2ad85..36bf63e68 100755
--- a/Project-Aurora/Project-Aurora/Settings/Layers/LayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/LayerHandler.cs
@@ -10,23 +10,16 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
+using FastMember;
namespace Aurora.Settings.Layers
{
- public interface IValueOverridable
+ public abstract class LayerHandlerProperties : IValueOverridable where TProperty : LayerHandlerProperties
{
- IStringProperty Overrides { get; set; }
- }
+ private static readonly Lazy accessor = new Lazy(() => TypeAccessor.Create(typeof(TProperty)));
- public abstract class LayerHandlerProperties : StringProperty, IValueOverridable where TProperty : LayerHandlerProperties
- {
- [GameStateIgnoreAttribute]
- [JsonIgnore]
+ [GameStateIgnore, JsonIgnore]
public TProperty Logic { get; set; }
- IStringProperty IValueOverridable.Overrides {
- get => (IStringProperty)Logic;
- set => Logic = value as TProperty;
- }
[LogicOverridable("Primary Color")]
public virtual Color? _PrimaryColor { get; set; }
@@ -79,6 +72,20 @@ public virtual void Default()
_PrimaryColor = Utils.ColorUtils.GenerateRandomColor();
_Sequence = new KeySequence();
}
+
+ public object GetOverride(string propertyName) {
+ try {
+ return accessor.Value[Logic, propertyName];
+ } catch (ArgumentOutOfRangeException) {
+ return null;
+ }
+ }
+
+ public void SetOverride(string propertyName, object value) {
+ try {
+ accessor.Value[Logic, propertyName] = value;
+ } catch (ArgumentOutOfRangeException) { }
+ }
}
public class LayerHandlerProperties2Color : LayerHandlerProperties where TProperty : LayerHandlerProperties2Color
@@ -108,7 +115,7 @@ public interface ILayerHandler : IDisposable
{
UserControl Control { get; }
- IStringProperty Properties { get; set; }
+ object Properties { get; set; }
bool EnableSmoothing { get; set; }
@@ -143,7 +150,7 @@ public abstract class LayerHandler : ILayerHandler where TProperty :
public TProperty Properties { get; set; } = Activator.CreateInstance();
- IStringProperty ILayerHandler.Properties {
+ object ILayerHandler.Properties {
get => Properties;
set => Properties = value as TProperty;
}
@@ -247,4 +254,17 @@ public class LayerHandler : LayerHandler
{
}
+
+
+ public interface IValueOverridable {
+ ///
+ /// Gets the overriden value of the speicifed property.
+ ///
+ object GetOverride(string propertyName);
+
+ ///
+ /// Sets the overriden value of the speicifed property to the given value.
+ ///
+ void SetOverride(string propertyName, object value);
+ }
}
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/PercentGradientLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/PercentGradientLayerHandler.cs
index 5e54b9901..5b8929a4f 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/PercentGradientLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/PercentGradientLayerHandler.cs
@@ -41,8 +41,8 @@ protected override UserControl CreateControl()
public override EffectLayer Render(IGameState state)
{
- double value = Properties.Logic._Value ?? Utils.GameStateUtils.TryGetDoubleFromState(state, Properties.VariablePath);
- double maxvalue = Properties.Logic._MaxValue ?? Utils.GameStateUtils.TryGetDoubleFromState(state, Properties.MaxVariablePath);
+ double value = Properties.Logic._Value ?? state.GetNumber(Properties.VariablePath);
+ double maxvalue = Properties.Logic._MaxValue ?? state.GetNumber(Properties.MaxVariablePath);
return new EffectLayer().PercentEffect(Properties.Gradient.GetColorSpectrum(), Properties.Sequence, value, maxvalue, Properties.PercentType, Properties.BlinkThreshold, Properties.BlinkDirection);
}
@@ -52,10 +52,10 @@ public override void SetApplication(Application profile)
if (profile != null)
{
double value;
- if (!double.TryParse(Properties._VariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._VariablePath) && !profile.ParameterLookup.ContainsKey(Properties._VariablePath))
+ if (!double.TryParse(Properties._VariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._VariablePath) && !profile.ParameterLookup.IsValidParameter(Properties._VariablePath))
Properties._VariablePath = string.Empty;
- if (!double.TryParse(Properties._MaxVariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._MaxVariablePath) && !profile.ParameterLookup.ContainsKey(Properties._MaxVariablePath))
+ if (!double.TryParse(Properties._MaxVariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._MaxVariablePath) && !profile.ParameterLookup.IsValidParameter(Properties._MaxVariablePath))
Properties._MaxVariablePath = string.Empty;
}
(Control as Control_PercentGradientLayer).SetApplication(profile);
diff --git a/Project-Aurora/Project-Aurora/Settings/Layers/PercentLayerHandler.cs b/Project-Aurora/Project-Aurora/Settings/Layers/PercentLayerHandler.cs
index b09707005..4e38d4976 100644
--- a/Project-Aurora/Project-Aurora/Settings/Layers/PercentLayerHandler.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Layers/PercentLayerHandler.cs
@@ -82,8 +82,8 @@ public class PercentLayerHandler : LayerHandler where TPro
{
public override EffectLayer Render(IGameState state)
{
- double value = Properties.Logic._Value ?? Utils.GameStateUtils.TryGetDoubleFromState(state, Properties.VariablePath);
- double maxvalue = Properties.Logic._MaxValue ?? Utils.GameStateUtils.TryGetDoubleFromState(state, Properties.MaxVariablePath);
+ double value = Properties.Logic._Value ?? state.GetNumber(Properties.VariablePath);
+ double maxvalue = Properties.Logic._MaxValue ?? state.GetNumber(Properties.MaxVariablePath);
return new EffectLayer().PercentEffect(Properties.PrimaryColor, Properties.SecondaryColor, Properties.Sequence, value, maxvalue, Properties.PercentType, Properties.BlinkThreshold, Properties.BlinkDirection, Properties.BlinkBackground);
}
@@ -92,11 +92,10 @@ public override void SetApplication(Application profile)
{
if (profile != null)
{
- double value;
- if (!double.TryParse(Properties._VariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._VariablePath) && !profile.ParameterLookup.ContainsKey(Properties._VariablePath))
+ if (!double.TryParse(Properties._VariablePath, out _) && !string.IsNullOrWhiteSpace(Properties._VariablePath) && !profile.ParameterLookup.IsValidParameter(Properties._VariablePath))
Properties._VariablePath = string.Empty;
- if (!double.TryParse(Properties._MaxVariablePath, out value) && !string.IsNullOrWhiteSpace(Properties._MaxVariablePath) && !profile.ParameterLookup.ContainsKey(Properties._MaxVariablePath))
+ if (!double.TryParse(Properties._MaxVariablePath, out _) && !string.IsNullOrWhiteSpace(Properties._MaxVariablePath) && !profile.ParameterLookup.IsValidParameter(Properties._MaxVariablePath))
Properties._MaxVariablePath = string.Empty;
}
(Control as Control_PercentLayer).SetProfile(profile);
diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Control_OverridesEditor.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Control_OverridesEditor.xaml.cs
index f7e49f558..a0a96f0c0 100644
--- a/Project-Aurora/Project-Aurora/Settings/Overrides/Control_OverridesEditor.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Control_OverridesEditor.xaml.cs
@@ -1,6 +1,7 @@
using Aurora.Settings.Layers;
using Aurora.Settings.Overrides.Logic;
using Aurora.Utils;
+using FastMember;
using PropertyChanged;
using System;
using System.Collections.Generic;
@@ -102,7 +103,8 @@ public Type SelectedLogicType {
if (_selectedProperty != null && SelectedLogic?.GetType() != value) {
if (value == null) { // If the value is null, that means the user selected the "None" option, so remove the override for this property. Also force reset the override to null so that it doesn't persist after removing the logic.
Layer.OverrideLogic.Remove(_selectedProperty.Item1);
- ((IValueOverridable)Layer.Handler.Properties).Overrides.SetValueFromString(_selectedProperty.Item1, null);
+ ((IValueOverridable)Layer.Handler.Properties).SetOverride(_selectedProperty.Item1, null);
+
} else // Else if the user selected a non-"None" option, create a new instance of that OverrideLogic and assign it to this property
Layer.OverrideLogic[_selectedProperty.Item1] = (IOverrideLogic)Activator.CreateInstance(value, _selectedProperty.Item3);
OnPropertyChanged(nameof(SelectedLogic), nameof(SelectedLogicType), nameof(SelectedLogicControl)); // Raise an event to update the control
diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_GameState.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_GameState.cs
index d72e46fe9..b5600645e 100755
--- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_GameState.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Boolean_GameState.cs
@@ -27,15 +27,7 @@ public BooleanGSIBoolean() { }
public Visual GetControl() => control ?? (control = new Control_ConditionGSIBoolean(this));
/// Fetches the given boolean value from the game state and returns it.
- public bool Evaluate(IGameState gameState) {
- bool result = false;
- if (VariablePath.Length > 0)
- try {
- object tmp = Utils.GameStateUtils.RetrieveGameStateParameter(gameState, VariablePath);
- result = (bool)Utils.GameStateUtils.RetrieveGameStateParameter(gameState, VariablePath);
- } catch { }
- return result;
- }
+ public bool Evaluate(IGameState gameState) => gameState.GetBool(VariablePath);
object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);
public IEvaluatable Clone() => new BooleanGSIBoolean { VariablePath = VariablePath };
@@ -74,8 +66,8 @@ public BooleanGSINumeric() { }
/// Parses the numbers, compares the result, and returns the result.
public bool Evaluate(IGameState gameState) {
// Parse the operands (either as numbers or paths)
- double op1 = Utils.GameStateUtils.TryGetDoubleFromState(gameState, Operand1Path);
- double op2 = Utils.GameStateUtils.TryGetDoubleFromState(gameState, Operand2Path);
+ double op1 = gameState.GetNumber(Operand1Path);
+ double op2 = gameState.GetNumber(Operand2Path);
// Evaluate the operands based on the selected operator and return the result.
switch (Operator) {
@@ -121,7 +113,7 @@ public BooleanGSIEnum() { }
/// Parses the numbers, compares the result, and returns the result.
public bool Evaluate(IGameState gameState) {
- var @enum = GameStateUtils.TryGetEnumFromState(gameState, StatePath);
+ var @enum = gameState.GetEnum(StatePath);
return @enum != null && @enum.Equals(EnumValue);
}
object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);
diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs
index be12a1486..3885430b0 100644
--- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Boolean/Control_BooleanGSIEnum.xaml.cs
@@ -21,8 +21,8 @@ private void UpdateEnumDropDown() {
var isValid = ((FrameworkElement)Content).DataContext is BooleanGSIEnum ctx
&& !string.IsNullOrWhiteSpace(ctx.StatePath) // If the path to the enum GSI isn't empty
&& application?.ParameterLookup != null // If the application parameter lookup is ready (and application isn't null)
- && application.ParameterLookup.ContainsKey(ctx.StatePath) // If the param lookup has the specified GSI key
- && (selectedEnumType = application.ParameterLookup[ctx.StatePath].Item1).IsEnum; // And the GSI variable is an enum type
+ && application.ParameterLookup.IsValidParameter(ctx.StatePath) // If the param lookup has the specified GSI key
+ && (selectedEnumType = application.ParameterLookup[ctx.StatePath].ClrType).IsEnum; // And the GSI variable is an enum type
EnumVal.IsEnabled = isValid;
EnumVal.ItemsSource = isValid ? Utils.EnumUtils.GetEnumItemsSource(selectedEnumType) : null;
diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Number/Number_GameState.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Number/Number_GameState.cs
index 5f9783dbc..afd2800e5 100755
--- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Number/Number_GameState.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/Number/Number_GameState.cs
@@ -24,12 +24,12 @@ public NumberGSINumeric() { }
public string VariablePath { get; set; }
// Control assigned to this evaluatable
- public Visual GetControl() => new GameStateParameterPicker { PropertyType = PropertyType.Number }
+ public Visual GetControl() => new GameStateParameterPicker { PropertyType = GSIPropertyType.Number }
.WithBinding(GameStateParameterPicker.ApplicationProperty, new AttachedApplicationBinding())
.WithBinding(GameStateParameterPicker.SelectedPathProperty, new Binding("VariablePath") { Source = this });
/// Parses the numbers, compares the result, and returns the result.
- public double Evaluate(IGameState gameState) => GameStateUtils.TryGetDoubleFromState(gameState, VariablePath);
+ public double Evaluate(IGameState gameState) => gameState.GetNumber(VariablePath);
object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);
public IEvaluatable Clone() => new NumberGSINumeric { VariablePath = VariablePath };
diff --git a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/String/String_GameState.cs b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/String/String_GameState.cs
index 5c4c32578..a41b53188 100755
--- a/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/String/String_GameState.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Overrides/Logic/String/String_GameState.cs
@@ -16,17 +16,12 @@ public class StringGSIString : IEvaluatable {
public string VariablePath { get; set; } = "";
/// Control assigned to this logic node.
- public Visual GetControl() => new GameStateParameterPicker { PropertyType = PropertyType.String }
+ public Visual GetControl() => new GameStateParameterPicker { PropertyType = GSIPropertyType.String }
.WithBinding(GameStateParameterPicker.ApplicationProperty, new AttachedApplicationBinding())
.WithBinding(GameStateParameterPicker.SelectedPathProperty, new Binding("VariablePath") { Source = this });
/// Attempts to return the string at the given state variable.
- public string Evaluate(IGameState gameState) {
- if (VariablePath.Length > 0)
- try { return (string)Utils.GameStateUtils.RetrieveGameStateParameter(gameState, VariablePath); }
- catch { }
- return "";
- }
+ public string Evaluate(IGameState gameState) => gameState.GetString(VariablePath);
object IEvaluatable.Evaluate(IGameState gameState) => Evaluate(gameState);
/// Clones this StringGSIString.
diff --git a/Project-Aurora/Project-Aurora/Settings/Window_GSIHttpDebug.xaml.cs b/Project-Aurora/Project-Aurora/Settings/Window_GSIHttpDebug.xaml.cs
index 3eb632aef..8170bb618 100644
--- a/Project-Aurora/Project-Aurora/Settings/Window_GSIHttpDebug.xaml.cs
+++ b/Project-Aurora/Project-Aurora/Settings/Window_GSIHttpDebug.xaml.cs
@@ -50,7 +50,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) {
// If a gamestate is already stored by the network listener, display it to the user immediately.
if (Global.net_listener.CurrentGameState != null)
- SetJsonText(Global.net_listener.CurrentGameState.json);
+ SetJsonText(Global.net_listener.CurrentGameState.Json);
// Start a timer to update the time displays for the request
timeDisplayTimer = new Timer(_ => Dispatcher.Invoke(() => {
@@ -83,7 +83,7 @@ private void Net_listener_NewGameState(Profiles.IGameState gamestate)
{
// This needs to be invoked due to the UI thread being different from the networking thread.
// Without this, an exception is thrown trying to update the text box.
- Dispatcher.Invoke(() => SetJsonText(gamestate.json));
+ Dispatcher.Invoke(() => SetJsonText(gamestate.Json));
// Also record the time this request came in
lastRequestTime = DateTime.Now;
}
diff --git a/Project-Aurora/Project-Aurora/Utils/CollectionUtils.cs b/Project-Aurora/Project-Aurora/Utils/CollectionUtils.cs
index caaefe759..37cc55e12 100644
--- a/Project-Aurora/Project-Aurora/Utils/CollectionUtils.cs
+++ b/Project-Aurora/Project-Aurora/Utils/CollectionUtils.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
@@ -13,6 +15,28 @@ public static ObservableCollection Clone(this ObservableCollection sour
new ObservableCollection(
source.Select(c => (T)c.Clone())
);
- }
+
+ ///
+ /// Gets the element at the given index in the non-generic .
+ ///
+ ///
+ /// Not called 'ElementAt' as this causes issues with ,
+ /// where this method usually takes priority over the better generic method if the generic type parameter is missing.
+ public static object ElementAtIndex(this IEnumerable source, int index) {
+ var i = 0;
+ foreach (var item in source)
+ if (index == i++)
+ return item;
+ throw new IndexOutOfRangeException();
+ }
+
+ ///
+ /// Deconstructor for a KeyValuePair.
+ ///
+ public static void Deconstruct(this KeyValuePair kvp, out TKey key, out TValue value) {
+ key = kvp.Key;
+ value = kvp.Value;
+ }
+ }
}
diff --git a/Project-Aurora/Project-Aurora/Utils/FastMemberExtensions.cs b/Project-Aurora/Project-Aurora/Utils/FastMemberExtensions.cs
new file mode 100644
index 000000000..1c46cd189
--- /dev/null
+++ b/Project-Aurora/Project-Aurora/Utils/FastMemberExtensions.cs
@@ -0,0 +1,33 @@
+using FastMember;
+using System;
+using System.Collections;
+
+namespace Aurora.Utils {
+
+ public static class FastMemberExtensions {
+
+ ///
+ /// Takes a path to a property (e.g. "Property/NestedProperty") and attempts to resolve it into a value within the context of this object.
+ ///
+ public static object ResolvePropertyPath(this object target, string path) {
+ var pathParts = path.Split('/');
+ var curObj = target;
+ try {
+ foreach (var part in pathParts) {
+ // If this is an enumerable and the part is a valid number, get the nth item of that enumerable
+ if (curObj is IEnumerable e && int.TryParse(part, out var index))
+ curObj = e.ElementAtIndex(index);
+
+ // Otherwise if this is any other object, use FastMember to access the relevant property/field.
+ else
+ curObj = ObjectAccessor.Create(curObj)[part];
+ }
+
+ return curObj; // If we got here, there is a valid object at this path, return it.
+
+ } catch (ArgumentOutOfRangeException) { // Thrown if ObjectAccessor attepts to get a field/property that doesn't exist
+ } catch (IndexOutOfRangeException) { } // Thrown if IEnumerable.ElementAtIndex tries to go out of bounds
+ return null;
+ }
+ }
+}
diff --git a/Project-Aurora/Project-Aurora/Utils/GameStateUtils.cs b/Project-Aurora/Project-Aurora/Utils/GameStateUtils.cs
deleted file mode 100644
index 40eb6688a..000000000
--- a/Project-Aurora/Project-Aurora/Utils/GameStateUtils.cs
+++ /dev/null
@@ -1,253 +0,0 @@
-using Aurora.Profiles;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using GamestateParameterLookup = System.Collections.Generic.Dictionary>;
-
-namespace Aurora.Utils
-{
- public static class GameStateUtils
- {
- static Dictionary AdditionalAllowedTypes = new Dictionary
- {
- { typeof(string), true },
- };
-
- public static GamestateParameterLookup ReflectGameStateParameters(Type typ)
- {
- var parameters = new GamestateParameterLookup();
-
- foreach (MemberInfo prop in typ.GetFields().Cast().Concat(typ.GetProperties().Cast()).Concat(typ.GetMethods().Where(m => !m.IsSpecialName).Cast()))
- {
- if (prop.GetCustomAttribute(typeof(GameStateIgnoreAttribute)) != null)
- continue;
-
- Type prop_type;
- Type prop_param_type = null;
- switch (prop.MemberType)
- {
- case MemberTypes.Field:
- prop_type = ((FieldInfo)prop).FieldType;
- break;
- case MemberTypes.Property:
- prop_type = ((PropertyInfo)prop).PropertyType;
- break;
-
- /* Why is this here? There is no way of passing parameters to methods from the game state UI?? */
- case MemberTypes.Method:
- //if (((MethodInfo)prop).IsSpecialName)
- //continue;
-
- prop_type = ((MethodInfo)prop).ReturnType;
-
- if (prop.Name.Equals("Equals") || prop.Name.Equals("GetType") || prop.Name.Equals("ToString") || prop.Name.Equals("GetHashCode"))
- continue;
-
- if (((MethodInfo)prop).GetParameters().Count() == 0)
- prop_param_type = null;
- else if (((MethodInfo)prop).GetParameters().Count() == 1)
- prop_param_type = ((MethodInfo)prop).GetParameters()[0].ParameterType;
- else
- {
- //Warning: More than 1 parameter!
- Console.WriteLine();
- }
-
- break;
- default:
- continue;
- }
-
- if(prop.Name.Equals("Abilities"))
- Console.WriteLine();
-
- Type temp = null;
-
- if (prop_type.IsPrimitive || prop_type.IsEnum || AdditionalAllowedTypes.ContainsKey(prop_type))
- {
- parameters.Add(prop.Name, new Tuple(prop_type, prop_param_type));
- }
- else if (prop_type.IsArray || prop_type.GetInterfaces().Any(t =>
- {
- return t == typeof(IEnumerable) || t == typeof(IList) || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable<>) && (temp = t.GenericTypeArguments[0]) != null);
- }))
- {
- RangeAttribute attribute;
- if ((attribute = prop.GetCustomAttribute(typeof(RangeAttribute)) as RangeAttribute) != null)
- {
- var sub_params = ReflectGameStateParameters(temp ?? prop_type.GetElementType());
-
- for (int i = attribute.Start; i <= attribute.End; i++)
- {
- foreach (var sub_param in sub_params)
- parameters.Add(prop.Name + "/" + i + "/" + sub_param.Key, sub_param.Value);
- }
- }
- else
- {
- //warning
- Console.WriteLine();
- }
- }
- else if (prop_type.IsClass)
- {
- if (prop.MemberType == MemberTypes.Method)
- {
- parameters.Add(prop.Name, new Tuple(prop_type, prop_param_type));
- }
- else
- {
- GamestateParameterLookup sub_params;
-
- if (prop_type == typ)
- sub_params = new GamestateParameterLookup(parameters);
- else
- sub_params = ReflectGameStateParameters(prop_type);
-
- foreach (var sub_param in sub_params)
- parameters.Add(prop.Name + "/" + sub_param.Key, sub_param.Value);
- }
- }
- }
-
- return parameters;
- }
-
- private static object _RetrieveGameStateParameter(IGameState state, string parameter_path, params object[] input_values)
- {
- string[] parameters = parameter_path.Split('/');
-
- object val = null;
- IStringProperty property_object = state as IStringProperty;
- int index_pos = 0;
-
- for (int x = 0; x < parameters.Count(); x++)
- {
- if (property_object == null)
- return val;
-
- string param = parameters[x];
-
- //Following needs validation
- //If next param is placeholder then take the appropriate input value from the input_values array
- val = property_object.GetValueFromString(param);
-
- if (val == null)
- throw new ArgumentNullException($"Failed to get value {parameter_path}, failed at '{param}'");
-
- Type property_type = property_object.GetType();
- Type temp = null;
- if (x < parameters.Length - 1 && (property_type.IsArray || property_type.GetInterfaces().Any(t =>
- {
- return t == typeof(IEnumerable) || t == typeof(IList) || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable<>) && (temp = t.GenericTypeArguments[0]) != null);
- })) && int.TryParse(parameters[x + 1], out index_pos))
- {
- x++;
- Type child_type = temp ?? property_type.GetElementType();
- IEnumerable