| using Playnite.SDK.Data; |
| using Playnite.SDK.Data; |
| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using System.Collections.ObjectModel; |
| using System.Collections.ObjectModel; |
| using System.ComponentModel; |
| using System.ComponentModel; |
| 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> |
| /// Represents built-in region defition. |
| /// Represents built-in region defition. |
| /// </summary> |
| /// </summary> |
| public class EmulatedRegion : IEquatable<EmulatedRegion> |
| public class EmulatedRegion : IEquatable<EmulatedRegion> |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Gets region id. |
| /// Gets region id. |
| /// </summary> |
| /// </summary> |
| public string Id { get; set; } |
| public string Id { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets region name. |
| /// Gets region name. |
| /// </summary> |
| /// </summary> |
| public string Name { get; set; } |
| public string Name { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets value indicating whether the region should be imported into new libraries. |
| /// Gets value indicating whether the region should be imported into new libraries. |
| /// </summary> |
| /// </summary> |
| public bool DefaultImport { get; set; } |
| public bool DefaultImport { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets ID of the region on IGDB database. |
| /// Gets ID of the region on IGDB database. |
| /// </summary> |
| /// </summary> |
| public ulong IgdbId { get; set; } |
| public ulong IgdbId { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets region codes. |
| /// Gets region codes. |
| /// </summary> |
| /// </summary> |
| public List<string> Codes { get; set; } |
| public List<string> Codes { get; set; } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override int GetHashCode() |
| public override int GetHashCode() |
| { |
| { |
| return Id?.GetHashCode() ?? 0; |
| return Id?.GetHashCode() ?? 0; |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public bool Equals(EmulatedRegion other) |
| public bool Equals(EmulatedRegion other) |
| { |
| { |
| return other.Id == Id; |
| return other.Id == Id; |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override bool Equals(object obj) |
| public override bool Equals(object obj) |
| { |
| { |
| if (obj is EmulatedRegion region) |
| if (obj is EmulatedRegion region) |
| { |
| { |
| return Equals(region); |
| return Equals(region); |
| } |
| } |
| else |
| else |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return Name; |
| return Name; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents built-in platform definition. |
| /// Represents built-in platform definition. |
| /// </summary> |
| /// </summary> |
| public class EmulatedPlatform : IEquatable<EmulatedPlatform> |
| public class EmulatedPlatform : IEquatable<EmulatedPlatform> |
| { |
| { |
| /// <summary> |
| /// <summary> |
| /// Gets ID of the platform on IGDB database. |
| /// Gets ID of the platform on IGDB database. |
| /// </summary> |
| /// </summary> |
| public ulong IgdbId { get; set; } |
| public ulong IgdbId { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets platform name. |
| /// Gets platform name. |
| /// </summary> |
| /// </summary> |
| public string Name { get; set; } |
| public string Name { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets platform id. |
| /// Gets platform id. |
| /// </summary> |
| /// </summary> |
| public string Id { get; set; } |
| public string Id { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets list of platform ROM database ids. |
| /// Gets list of platform ROM database ids. |
| /// </summary> |
| /// </summary> |
| public List<string> Databases { get; set; } |
| public List<string> Databases { get; set; } |
| /// <summary> |
| /// <summary> |
| /// Gets liust of emulator IDs supporting this platform. |
| /// Gets liust of emulator IDs supporting this platform. |
| /// </summary> |
| /// </summary> |
| public List<string> Emulators { get; set; } |
| public List<string> Emulators { get; set; } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override int GetHashCode() |
| public override int GetHashCode() |
| { |
| { |
| return Id?.GetHashCode() ?? 0; |
| return Id?.GetHashCode() ?? 0; |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public bool Equals(EmulatedPlatform other) |
| public bool Equals(EmulatedPlatform other) |
| { |
| { |
| return other.Id == Id; |
| return other.Id == Id; |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override bool Equals(object obj) |
| public override bool Equals(object obj) |
| { |
| { |
| if (obj is EmulatedPlatform platform) |
| if (obj is EmulatedPlatform platform) |
| { |
| { |
| return Equals(platform); |
| return Equals(platform); |
| } |
| } |
| else |
| else |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return Name; |
| return Name; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// |
| /// |
| /// </summary> |
| /// </summary> |
| public abstract class EmulatorProfile : ObservableObject |
| public abstract class EmulatorProfile : ObservableObject |
| { |
| { |
| private string id; |
| private string id; |
| /// <summary> |
| /// <summary> |
| /// Gets emulator profile ID. |
| /// Gets emulator profile ID. |
| /// </summary> |
| /// </summary> |
| public string Id |
| public string Id |
| { |
| { |
| get => id; |
| get => id; |
| set |
| set |
| { |
| { |
| id = value; |
| id = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string name; |
| private string name; |
| /// <summary> |
| /// <summary> |
| /// Gets profile name. |
| /// Gets profile name. |
| /// </summary> |
| /// </summary> |
| public string Name |
| public string Name |
| { |
| { |
| get => name; |
| get => name; |
| set |
| set |
| { |
| { |
| name = value; |
| name = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string preScript; |
| private string preScript; |
| /// <summary> |
| /// <summary> |
| /// Gets pre-execution script. |
| /// Gets pre-execution script. |
| /// </summary> |
| /// </summary> |
| public string PreScript |
| public string PreScript |
| { |
| { |
| get => preScript; |
| get => preScript; |
| set |
| set |
| { |
| { |
| preScript = value; |
| preScript = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string postScript; |
| private string postScript; |
| /// <summary> |
| /// <summary> |
| /// Gets post-execution script. |
| /// Gets post-execution script. |
| /// </summary> |
| /// </summary> |
| public string PostScript |
| public string PostScript |
| { |
| { |
| get => postScript; |
| get => postScript; |
| set |
| set |
| { |
| { |
| postScript = value; |
| postScript = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string exitScript; |
| private string exitScript; |
| /// <summary> |
| /// <summary> |
| /// Gets exit-execution script. |
| /// Gets exit-execution script. |
| /// </summary> |
| /// </summary> |
| public string ExitScript |
| public string ExitScript |
| { |
| { |
| get => exitScript; |
| get => exitScript; |
| set |
| set |
| { |
| { |
| exitScript = value; |
| exitScript = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets emulator profile object type. |
| /// Gets emulator profile object type. |
| /// </summary> |
| /// </summary> |
| [DontSerialize] |
| [DontSerialize] |
| public Type Type => GetType(); |
| public Type Type => GetType(); |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return Name; |
| return Name; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents built-in emulator profile. |
| /// Represents built-in emulator profile. |
| /// </summary> |
| /// </summary> |
| public class BuiltInEmulatorProfile : EmulatorProfile, IEquatable<BuiltInEmulatorProfile> |
| public class BuiltInEmulatorProfile : EmulatorProfile, IEquatable<BuiltInEmulatorProfile> |
| { |
| { |
| internal static readonly string ProfilePrefix = "#builtin_"; |
| internal static readonly string ProfilePrefix = "#builtin_"; |
| |
| |
| private string builtInProfileName; |
| private string builtInProfileName; |
| /// <summary> |
| /// <summary> |
| /// Gets name of built-in profile represented by this definition. |
| /// Gets name of built-in profile represented by this definition. |
| /// </summary> |
| /// </summary> |
| public string BuiltInProfileName |
| public string BuiltInProfileName |
| { |
| { |
| get => builtInProfileName; |
| get => builtInProfileName; |
| set |
| set |
| { |
| { |
| builtInProfileName = value; |
| builtInProfileName = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
. | |
| private bool overrideDefaultArgs; |
| |
| /// <summary> |
| |
| /// Gets or sets value indicating whether built-in arguments should be overriden. |
| |
| /// </summary> |
| |
| public bool OverrideDefaultArgs |
| |
| { |
| |
| get => overrideDefaultArgs; |
| |
| set |
| |
| { |
| |
| overrideDefaultArgs = value; |
| |
| OnPropertyChanged(); |
| |
| } |
| |
| } |
| |
| |
| |
| private string customArguments; |
| |
| /// <summary> |
| |
| /// Gets or set custom emulator arguments. |
| |
| /// </summary> |
| |
| public string CustomArguments |
| |
| { |
| |
| get => customArguments; |
| |
| set |
| |
| { |
| |
| customArguments = value; |
| |
| OnPropertyChanged(); |
| |
| } |
| |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new instance of <see cref="BuiltInEmulatorProfile"/>. |
| /// Creates new instance of <see cref="BuiltInEmulatorProfile"/>. |
| /// </summary> |
| /// </summary> |
| public BuiltInEmulatorProfile() : base() |
| public BuiltInEmulatorProfile() : base() |
| { |
| { |
| Id = ProfilePrefix + Guid.NewGuid(); |
| Id = ProfilePrefix + Guid.NewGuid(); |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public bool Equals(BuiltInEmulatorProfile other) |
| public bool Equals(BuiltInEmulatorProfile other) |
| { |
| { |
| if (other is null) |
| if (other is null) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(BuiltInProfileName, other.BuiltInProfileName, StringComparison.Ordinal)) |
| if (!string.Equals(BuiltInProfileName, other.BuiltInProfileName, 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 (!string.Equals(ExitScript, other.ExitScript, StringComparison.Ordinal)) |
| if (!string.Equals(ExitScript, other.ExitScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(PostScript, other.PostScript, StringComparison.Ordinal)) |
| if (!string.Equals(PostScript, other.PostScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(PreScript, other.PreScript, StringComparison.Ordinal)) |
| if (!string.Equals(PreScript, other.PreScript, StringComparison.Ordinal)) |
. | |
| { |
| |
| return false; |
| |
| } |
| |
| |
| |
| if (!string.Equals(CustomArguments, other.CustomArguments, StringComparison.Ordinal)) |
| |
| { |
| |
| return false; |
| |
| } |
| |
| |
| |
| if (OverrideDefaultArgs != other.OverrideDefaultArgs) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents emulator profile. |
| /// Represents emulator profile. |
| /// </summary> |
| /// </summary> |
| public class CustomEmulatorProfile : EmulatorProfile, IEquatable<CustomEmulatorProfile> |
| public class CustomEmulatorProfile : EmulatorProfile, IEquatable<CustomEmulatorProfile> |
| { |
| { |
| internal static readonly string ProfilePrefix = "#custom_"; |
| internal static readonly string ProfilePrefix = "#custom_"; |
| |
| |
| private string startupScript; |
| private string startupScript; |
| /// <summary> |
| /// <summary> |
| /// Gets startup script. |
| /// Gets startup script. |
| /// </summary> |
| /// </summary> |
| public string StartupScript |
| public string StartupScript |
| { |
| { |
| get => startupScript; |
| get => startupScript; |
| set |
| set |
| { |
| { |
| startupScript = value; |
| startupScript = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private List<Guid> platforms; |
| private List<Guid> platforms; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets platforms supported by profile. |
| /// Gets or sets platforms supported by profile. |
| /// </summary> |
| /// </summary> |
| public List<Guid> Platforms |
| public List<Guid> Platforms |
| { |
| { |
| get => platforms; |
| get => platforms; |
| set |
| set |
| { |
| { |
| platforms = value; |
| platforms = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private List<string> imageExtensions; |
| private List<string> imageExtensions; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets file extension supported by profile. |
| /// Gets or sets file extension supported by profile. |
| /// </summary> |
| /// </summary> |
| public List<string> ImageExtensions |
| public List<string> ImageExtensions |
| { |
| { |
| get => imageExtensions; |
| get => imageExtensions; |
| set |
| set |
| { |
| { |
| imageExtensions = value; |
| imageExtensions = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string executable; |
| private string executable; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets executable path used to launch emulator. |
| /// Gets or sets executable path used to launch emulator. |
| /// </summary> |
| /// </summary> |
| public string Executable |
| public string Executable |
| { |
| { |
| get => executable; |
| get => executable; |
| set |
| set |
| { |
| { |
| executable = value; |
| executable = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string arguments; |
| private string arguments; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets arguments for emulator executable. |
| /// Gets or sets arguments for emulator executable. |
| /// </summary> |
| /// </summary> |
| public string Arguments |
| public string Arguments |
| { |
| { |
| get => arguments; |
| get => arguments; |
| set |
| set |
| { |
| { |
| arguments = value; |
| arguments = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string workingDirectory; |
| private string workingDirectory; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets working directory of emulator process. |
| /// Gets or sets working directory of emulator process. |
| /// </summary> |
| /// </summary> |
| public string WorkingDirectory |
| public string WorkingDirectory |
| { |
| { |
| get => workingDirectory; |
| get => workingDirectory; |
| set |
| set |
| { |
| { |
| workingDirectory = value; |
| workingDirectory = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// |
| /// |
| /// </summary> |
| /// </summary> |
| /// <returns></returns> |
| /// <returns></returns> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return Name; |
| return Name; |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new instance of EmulatorProfile. |
| /// Creates new instance of EmulatorProfile. |
| /// </summary> |
| /// </summary> |
| public CustomEmulatorProfile() : base() |
| public CustomEmulatorProfile() : base() |
| { |
| { |
| Id = ProfilePrefix + Guid.NewGuid(); |
| Id = ProfilePrefix + Guid.NewGuid(); |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public bool Equals(CustomEmulatorProfile other) |
| public bool Equals(CustomEmulatorProfile other) |
| { |
| { |
| if (other is null) |
| if (other is null) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(Id, other.Id, StringComparison.Ordinal)) |
| if (!string.Equals(Id, other.Id, 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 (!Platforms.IsListEqual(other.Platforms)) |
| if (!Platforms.IsListEqual(other.Platforms)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!ImageExtensions.IsListEqual(other.ImageExtensions)) |
| if (!ImageExtensions.IsListEqual(other.ImageExtensions)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(Executable, other.Executable, StringComparison.Ordinal)) |
| if (!string.Equals(Executable, other.Executable, StringComparison.Ordinal)) |
| { |
| { |
| 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(WorkingDirectory, other.WorkingDirectory, StringComparison.Ordinal)) |
| if (!string.Equals(WorkingDirectory, other.WorkingDirectory, 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 (!string.Equals(ExitScript, other.ExitScript, StringComparison.Ordinal)) |
| if (!string.Equals(ExitScript, other.ExitScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(PostScript, other.PostScript, StringComparison.Ordinal)) |
| if (!string.Equals(PostScript, other.PostScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(PreScript, other.PreScript, StringComparison.Ordinal)) |
| if (!string.Equals(PreScript, other.PreScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| if (!string.Equals(StartupScript, other.StartupScript, StringComparison.Ordinal)) |
| if (!string.Equals(StartupScript, other.StartupScript, StringComparison.Ordinal)) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| |
| |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Represents system emulator. |
| /// Represents system emulator. |
| /// </summary> |
| /// </summary> |
| public class Emulator : DatabaseObject |
| public class Emulator : DatabaseObject |
| { |
| { |
| private string builtInConfigId; |
| private string builtInConfigId; |
| /// <summary> |
| /// <summary> |
| /// Gets id of built-in emulator profile. |
| /// Gets id of built-in emulator profile. |
| /// </summary> |
| /// </summary> |
| public string BuiltInConfigId |
| public string BuiltInConfigId |
| { |
| { |
| get => builtInConfigId; |
| get => builtInConfigId; |
| set |
| set |
| { |
| { |
| builtInConfigId = value; |
| builtInConfigId = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private string installDir; |
| private string installDir; |
| /// <summary> |
| /// <summary> |
| /// Gets emulator installation directory. |
| /// Gets emulator installation directory. |
| /// </summary> |
| /// </summary> |
| public string InstallDir |
| public string InstallDir |
| { |
| { |
| get => installDir; |
| get => installDir; |
| set |
| set |
| { |
| { |
| installDir = value; |
| installDir = value; |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| } |
| } |
| } |
| } |
| |
| |
| private ObservableCollection<BuiltInEmulatorProfile> builtinProfiles; |
| private ObservableCollection<BuiltInEmulatorProfile> builtinProfiles; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets list of emulator profiles. |
| /// Gets or sets list of emulator profiles. |
| /// </summary> |
| /// </summary> |
| public ObservableCollection<BuiltInEmulatorProfile> BuiltinProfiles |
| public ObservableCollection<BuiltInEmulatorProfile> BuiltinProfiles |
| { |
| { |
| get => builtinProfiles; |
| get => builtinProfiles; |
| set |
| set |
| { |
| { |
| if (builtinProfiles != null) |
| if (builtinProfiles != null) |
| { |
| { |
| builtinProfiles.CollectionChanged -= Profiles_CollectionChanged; |
| builtinProfiles.CollectionChanged -= Profiles_CollectionChanged; |
| } |
| } |
| |
| |
| builtinProfiles = value; |
| builtinProfiles = value; |
| if (builtinProfiles != null) |
| if (builtinProfiles != null) |
| { |
| { |
| builtinProfiles.CollectionChanged += Profiles_CollectionChanged; |
| builtinProfiles.CollectionChanged += Profiles_CollectionChanged; |
| } |
| } |
| |
| |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| } |
| } |
| } |
| } |
| |
| |
| private ObservableCollection<CustomEmulatorProfile> customProfiles; |
| private ObservableCollection<CustomEmulatorProfile> customProfiles; |
| /// <summary> |
| /// <summary> |
| /// Gets or sets list of emulator profiles. |
| /// Gets or sets list of emulator profiles. |
| /// </summary> |
| /// </summary> |
| public ObservableCollection<CustomEmulatorProfile> CustomProfiles |
| public ObservableCollection<CustomEmulatorProfile> CustomProfiles |
| { |
| { |
| get => customProfiles; |
| get => customProfiles; |
| set |
| set |
| { |
| { |
| if (customProfiles != null) |
| if (customProfiles != null) |
| { |
| { |
| customProfiles.CollectionChanged -= Profiles_CollectionChanged; |
| customProfiles.CollectionChanged -= Profiles_CollectionChanged; |
| } |
| } |
| |
| |
| customProfiles = value; |
| customProfiles = value; |
| if (customProfiles != null) |
| if (customProfiles != null) |
| { |
| { |
| customProfiles.CollectionChanged += Profiles_CollectionChanged; |
| customProfiles.CollectionChanged += Profiles_CollectionChanged; |
| } |
| } |
| |
| |
| OnPropertyChanged(); |
| OnPropertyChanged(); |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| } |
| } |
| } |
| } |
| |
| |
| private void Profiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
| private void Profiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
| { |
| { |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(AllProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| OnPropertyChanged(nameof(SelectableProfiles)); |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets list of all profiles including option for profile auto-select. |
| /// Gets list of all profiles including option for profile auto-select. |
| /// </summary> |
| /// </summary> |
| [DontSerialize] |
| [DontSerialize] |
| public List<EmulatorProfile> SelectableProfiles |
| public List<EmulatorProfile> SelectableProfiles |
| { |
| { |
| get |
| get |
| { |
| { |
| var selProfiles = new List<EmulatorProfile>(); |
| var selProfiles = new List<EmulatorProfile>(); |
| if (BuiltinProfiles.HasItems()) |
| if (BuiltinProfiles.HasItems()) |
| { |
| { |
| selProfiles.AddRange(BuiltinProfiles.OrderBy(a => a.Name)); |
| selProfiles.AddRange(BuiltinProfiles.OrderBy(a => a.Name)); |
| } |
| } |
| |
| |
| if (CustomProfiles.HasItems()) |
| if (CustomProfiles.HasItems()) |
| { |
| { |
| selProfiles.AddRange(CustomProfiles.OrderBy(a => a.Name)); |
| selProfiles.AddRange(CustomProfiles.OrderBy(a => a.Name)); |
| } |
| } |
| |
| |
| selProfiles.Insert(0, new CustomEmulatorProfile { Id = null, Name = ResourceProvider.GetString("LOCGameActionSelectOnStart") }); |
| selProfiles.Insert(0, new CustomEmulatorProfile { Id = null, Name = ResourceProvider.GetString("LOCGameActionSelectOnStart") }); |
| return selProfiles; |
| return selProfiles; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets list of all profiles. |
| /// Gets list of all profiles. |
| /// </summary> |
| /// </summary> |
| [DontSerialize] |
| [DontSerialize] |
| public List<EmulatorProfile> AllProfiles |
| public List<EmulatorProfile> AllProfiles |
| { |
| { |
| get |
| get |
| { |
| { |
| var selProfiles = new List<EmulatorProfile>(); |
| var selProfiles = new List<EmulatorProfile>(); |
| if (BuiltinProfiles.HasItems()) |
| if (BuiltinProfiles.HasItems()) |
| { |
| { |
| selProfiles.AddRange(BuiltinProfiles.OrderBy(a => a.Name)); |
| selProfiles.AddRange(BuiltinProfiles.OrderBy(a => a.Name)); |
| } |
| } |
| |
| |
| if (CustomProfiles.HasItems()) |
| if (CustomProfiles.HasItems()) |
| { |
| { |
| selProfiles.AddRange(CustomProfiles.OrderBy(a => a.Name)); |
| selProfiles.AddRange(CustomProfiles.OrderBy(a => a.Name)); |
| } |
| } |
| |
| |
| return selProfiles; |
| return selProfiles; |
| } |
| } |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new instance of Emulator. |
| /// Creates new instance of Emulator. |
| /// </summary> |
| /// </summary> |
| public Emulator() : base() |
| public Emulator() : base() |
| { |
| { |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Creates new instance of Emulator with specific name. |
| /// Creates new instance of Emulator with specific name. |
| /// </summary> |
| /// </summary> |
| /// <param name="name">Emulator name.</param> |
| /// <param name="name">Emulator name.</param> |
| public Emulator(string name) : this() |
| public Emulator(string name) : this() |
| { |
| { |
| Name = name; |
| Name = name; |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// |
| /// |
| /// </summary> |
| /// </summary> |
| /// <returns></returns> |
| /// <returns></returns> |
| public override string ToString() |
| public override string ToString() |
| { |
| { |
| return Name; |
| return Name; |
| } |
| } |
| |
| |
| /// <summary> |
| /// <summary> |
| /// Gets profile by id. |
| /// Gets profile by id. |
| /// </summary> |
| /// </summary> |
| /// <param name="profileId"></param> |
| /// <param name="profileId"></param> |
| /// <returns></returns> |
| /// <returns></returns> |
| public EmulatorProfile GetProfile(string profileId) |
| public EmulatorProfile GetProfile(string profileId) |
| { |
| { |
| var cus = CustomProfiles?.FirstOrDefault(a => a.Id == profileId); |
| var cus = CustomProfiles?.FirstOrDefault(a => a.Id == profileId); |
| if (cus != null) |
| if (cus != null) |
| { |
| { |
| return cus; |
| return cus; |
| } |
| } |
| |
| |
| return BuiltinProfiles?.FirstOrDefault(a => a.Id == profileId); |
| return BuiltinProfiles?.FirstOrDefault(a => a.Id == profileId); |
| } |
| } |
| |
| |
| /// <inheritdoc/> |
| /// <inheritdoc/> |
| public override void CopyDiffTo(object target) |
| public override void CopyDiffTo(object target) |
| { |
| { |
| base.CopyDiffTo(target); |
| base.CopyDiffTo(target); |
| |
| |
| if (target is Emulator tro) |
| if (target is Emulator tro) |
| { |
| { |
| if (!CustomProfiles.IsListEqualExact(tro.CustomProfiles)) |
| if (!CustomProfiles.IsListEqualExact(tro.CustomProfiles)) |
| { |
| { |
| tro.CustomProfiles = CustomProfiles; |
| tro.CustomProfiles = CustomProfiles; |
| } |
| } |
| |
| |
| if (!BuiltinProfiles.IsListEqualExact(tro.BuiltinProfiles)) |
| if (!BuiltinProfiles.IsListEqualExact(tro.BuiltinProfiles)) |
| { |
| { |
| tro.BuiltinProfiles = BuiltinProfiles; |
| tro.BuiltinProfiles = BuiltinProfiles; |
| } |
| } |
| |
| |
| if (!string.Equals(BuiltInConfigId, tro.BuiltInConfigId, StringComparison.Ordinal)) |
| if (!string.Equals(BuiltInConfigId, tro.BuiltInConfigId, StringComparison.Ordinal)) |
| { |
| { |
| tro.BuiltInConfigId = BuiltInConfigId; |
| tro.BuiltInConfigId = BuiltInConfigId; |
| } |
| } |
| |
| |
| if (!string.Equals(InstallDir, tro.InstallDir, StringComparison.Ordinal)) |
| if (!string.Equals(InstallDir, tro.InstallDir, StringComparison.Ordinal)) |
| { |
| { |
| tro.InstallDir = InstallDir; |
| tro.InstallDir = InstallDir; |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| throw new ArgumentException($"Target object has to be of type {GetType().Name}"); |
| throw new ArgumentException($"Target object has to be of type {GetType().Name}"); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |