| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using System.ComponentModel; |
| using System.ComponentModel; |
| using System.Diagnostics; |
| using System.Diagnostics; |
| using System.IO; |
| using System.IO; |
| using System.Linq; |
| using System.Linq; |
| using System.Text; |
| using System.Text; |
| using System.Threading.Tasks; |
| using System.Threading.Tasks; |
| |
| |
| namespace Playnite.SDK.Models |
| namespace Playnite.SDK.Models |
| { |
| { |
| /// <summary> |
| /// <summary> |
. | |
| /// |
| |
| /// </summary> |
| |
| public enum TrackingMode |
| |
| { |
| |
| /// <summary> |
| |
| /// |
| |
| /// </summary> |
| |
| [Description("LOCActionTrackingModeDefault")] |
| |
| Default, |
| |
| /// <summary> |
| |
| /// |
| |
| /// </summary> |
| |
| [Description("LOCActionTrackingModeProcess")] |
| |
| Process, |
| |
| /// <summary> |
| |
| /// |
| |
| /// </summary> |
| |
| [Description("LOCActionTrackingModeDirectory")] |
| |
| Directory |
| |
| } |
| |
| |
| |
| /// <summary> |
| /// Represents game action type. |
| /// Represents game action type. |
| /// </summary> |
| /// </summary> |
| public enum GameActionType : int |
| public enum GameActionType : int |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Game action executes a file. |
| /// Game action executes a file. |
| /// </summary> |
| /// </summary> |
. | |
| [Description("LOCGameActionTypeFile")] |
| File = 0, |
| File = 0, |
| /// <summary> |
| /// <summary> |
| /// Game action navigates to a web based URL. |
| /// Game action navigates to a web based URL. |
| /// </summary> |
| /// </summary> |
. | |
| [Description("LOCGameActionTypeLink")] |
| URL = 1, |
| URL = 1, |
| /// <summary> |
| /// <summary> |
| /// Game action starts an emulator. |
| /// Game action starts an emulator. |
| /// </summary> |
| /// </summary> |
. | Emulator = 2 |
| [Description("LOCGameActionTypeEmulator")] |
| |
| Emulator = 2, |
| |
| /// <summary> |
| |
| /// Game action startup is handled by a script. |
| |
| /// </summary> |
| |
| [Description("LOCGameActionTypeScript")] |
| |
| Script = 3 |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents executable game action. |
| /// Represents executable game action. |
| /// </summary> |
| /// </summary> |
| public class GameAction : ObservableObject, IEquatable<GameAction> |
| public class GameAction : ObservableObject, IEquatable<GameAction> |
| { |
| { |
. | private readonly Guid id = Guid.NewGuid(); |
| |
| |
| |
| private GameActionType type; |
| private GameActionType type; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets task type. |
| /// Gets or sets task type. |
| /// </summary> |
| /// </summary> |
| public GameActionType Type |
| public GameActionType Type |
| { |
| { |
| get => type; |
| get => type; |
| set |
| set |
| { |
| { |
| type = value; |
| type = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string arguments; |
| private string arguments; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets executable arguments for File type tasks. |
| /// Gets or sets executable arguments for File type tasks. |
| /// </summary> |
| /// </summary> |
| public string Arguments |
| public string Arguments |
| { |
| { |
| get => arguments; |
| get => arguments; |
| set |
| set |
| { |
| { |
| arguments = value; |
| arguments = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string additionalArguments; |
| private string additionalArguments; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets additional executable arguments used for Emulator action type. |
| /// Gets or sets additional executable arguments used for Emulator action type. |
| /// </summary> |
| /// </summary> |
| public string AdditionalArguments |
| public string AdditionalArguments |
| { |
| { |
| get => additionalArguments; |
| get => additionalArguments; |
| set |
| set |
| { |
| { |
| additionalArguments = value; |
| additionalArguments = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private bool overrideDefaultArgs; |
| private bool overrideDefaultArgs; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets value indicating wheter emulator arguments should be completely overwritten with action arguments. |
| /// Gets or sets value indicating wheter emulator arguments should be completely overwritten with action arguments. |
| /// Applies only to Emulator action type. |
| /// Applies only to Emulator action type. |
| /// </summary> |
| /// </summary> |
| public bool OverrideDefaultArgs |
| public bool OverrideDefaultArgs |
| { |
| { |
| get => overrideDefaultArgs; |
| get => overrideDefaultArgs; |
| set |
| set |
| { |
| { |
| overrideDefaultArgs = value; |
| overrideDefaultArgs = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string path; |
| private string path; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets executable path for File action type or URL for URL action type. |
| /// Gets or sets executable path for File action type or URL for URL action type. |
| /// </summary> |
| /// </summary> |
| public string Path |
| public string Path |
| { |
| { |
| get => path; |
| get => path; |
| set |
| set |
| { |
| { |
| path = value; |
| path = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string workingDir; |
| private string workingDir; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets working directory for File action type executable. |
| /// Gets or sets working directory for File action type executable. |
| /// </summary> |
| /// </summary> |
| public string WorkingDir |
| public string WorkingDir |
| { |
| { |
| get => workingDir; |
| get => workingDir; |
| set |
| set |
| { |
| { |
| workingDir = value; |
| workingDir = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string name; |
| private string name; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets action name. |
| /// Gets or sets action name. |
| /// </summary> |
| /// </summary> |
| public string Name |
| public string Name |
| { |
| { |
| get => name; |
| get => name; |
| set |
| set |
| { |
| { |
| name = value; |
| name = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
. | private bool isHandledByPlugin; |
| private bool isPlayAction; |
| /// <summary> |
| /// <summary> |
. | /// Gets or sets value indicating wheter a action's execution should be handled by a plugin. |
| /// Gets or sets value indicating wheter an action is play action. |
| /// </summary> |
| /// </summary> |
. | public bool IsHandledByPlugin |
| public bool IsPlayAction |
| { |
| { |
. | get => isHandledByPlugin; |
| get => isPlayAction; |
| set |
| set |
| { |
| { |
. | isHandledByPlugin = value; |
| isPlayAction = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private Guid emulatorId; |
| private Guid emulatorId; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets emulator id for Emulator action type execution. |
| /// Gets or sets emulator id for Emulator action type execution. |
| /// </summary> |
| /// </summary> |
| public Guid EmulatorId |
| public Guid EmulatorId |
| { |
| { |
| get => emulatorId; |
| get => emulatorId; |
| set |
| set |
| { |
| { |
| emulatorId = value; |
| emulatorId = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
. | private Guid emulatorProfileId; |
| private string emulatorProfileId; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets emulator profile id for Emulator action type execution. |
| /// Gets or sets emulator profile id for Emulator action type execution. |
| /// </summary> |
| /// </summary> |
. | public Guid EmulatorProfileId |
| public string EmulatorProfileId |
| { |
| { |
| get => emulatorProfileId; |
| get => emulatorProfileId; |
| set |
| set |
| { |
| { |
| emulatorProfileId = value; |
| emulatorProfileId = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
. | |
| private TrackingMode trackingMode = TrackingMode.Default; |
| |
| /// <summary> |
| |
| /// Gets or sets executable arguments for File type tasks. |
| |
| /// </summary> |
| |
| public TrackingMode TrackingMode |
| |
| { |
| |
| get => trackingMode; |
| |
| set |
| |
| { |
| |
| trackingMode = value; |
| |
| OnPropertyChanged(); |
| |
| } |
| |
| } |
| |
| |
| |
| private string trackingPath; |
| |
| /// <summary> |
| |
| /// Gets or sets executable arguments for File type tasks. |
| |
| /// </summary> |
| |
| public string TrackingPath |
| |
| { |
| |
| get => trackingPath; |
| |
| set |
| |
| { |
| |
| trackingPath = value; |
| |
| OnPropertyChanged(); |
| |
| } |
| |
| } |
| |
| |
| |
| private string script; |
| |
| /// <summary> |
| |
| /// Gets or sets startup script. |
| |
| /// </summary> |
| |
| public string Script |
| |
| { |
| |
| get => script; |
| |
| set |
| |
| { |
| |
| script = value; |
| |
| OnPropertyChanged(); |
| |
| } |
| |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| switch (Type) |
| switch (Type) |
| { |
| { |
| case GameActionType.File: |
| case GameActionType.File: |
| return $"File: {Path}, {Arguments}, {WorkingDir}"; |
| return $"File: {Path}, {Arguments}, {WorkingDir}"; |
| case GameActionType.URL: |
| case GameActionType.URL: |
| return $"Url: {Path}"; |
| return $"Url: {Path}"; |
| case GameActionType.Emulator: |
| case GameActionType.Emulator: |
| return $"Emulator: {EmulatorId}, {EmulatorProfileId}, {OverrideDefaultArgs}, {AdditionalArguments}"; |
| return $"Emulator: {EmulatorId}, {EmulatorProfileId}, {OverrideDefaultArgs}, {AdditionalArguments}"; |
| default: |
| default: |
| return Path; |
| return Path; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Compares two <see cref="GameAction"/> objects for equality. |
| /// Compares two <see cref="GameAction"/> objects for equality. |
| /// </summary> |
| /// </summary> |
| /// <param name="obj1"></param> |
| /// <param name="obj1"></param> |
| /// <param name="obj2"></param> |
| /// <param name="obj2"></param> |
| /// <returns></returns> |
| /// <returns></returns> |
| public static bool Equals(GameAction obj1, GameAction obj2) |
| public static bool Equals(GameAction obj1, GameAction obj2) |
| { |
| { |
| if (obj1 == null && obj2 == null) |
| if (obj1 == null && obj2 == null) |
| { |
| { |
| return true; |
| return true; |
| } |
| } |
| else |
| else |
| { |
| { |
| return obj1?.Equals(obj2) == true; |
| return obj1?.Equals(obj2) == true; |
| } |
| } |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public bool Equals(GameAction other) |
| public bool Equals(GameAction other) |
| { |
| { |
| if (other is null) |
| if (other is null) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (Type != other.Type) |
| if (Type != other.Type) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(Arguments, other.Arguments, StringComparison.Ordinal)) |
| if (!string.Equals(Arguments, other.Arguments, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(AdditionalArguments, other.AdditionalArguments, StringComparison.Ordinal)) |
| if (!string.Equals(AdditionalArguments, other.AdditionalArguments, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(Path, other.Path, StringComparison.Ordinal)) |
| if (!string.Equals(Path, other.Path, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(WorkingDir, other.WorkingDir, StringComparison.Ordinal)) |
| if (!string.Equals(WorkingDir, other.WorkingDir, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(Name, other.Name, StringComparison.Ordinal)) |
| if (!string.Equals(Name, other.Name, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
. | if (IsHandledByPlugin != other.IsHandledByPlugin) |
| if (IsPlayAction != other.IsPlayAction) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (EmulatorId != other.EmulatorId) |
| if (EmulatorId != other.EmulatorId) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
. | if (EmulatorProfileId != other.EmulatorProfileId) |
| if (!string.Equals(EmulatorProfileId, other.EmulatorProfileId, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (OverrideDefaultArgs != other.OverrideDefaultArgs) |
| if (OverrideDefaultArgs != other.OverrideDefaultArgs) |
. | |
| { |
| |
| return false; |
| |
| } |
| |
| |
| |
| if (!string.Equals(TrackingPath, other.TrackingPath, StringComparison.Ordinal)) |
| |
| { |
| |
| return false; |
| |
| } |
| |
| |
| |
| if (TrackingMode != other.TrackingMode) |
| |
| { |
| |
| return false; |
| |
| } |
| |
| |
| |
| if (!string.Equals(Script, other.Script, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |