diff options
Diffstat (limited to 'Ryujinx.Ava/Ui/Models')
-rw-r--r-- | Ryujinx.Ava/Ui/Models/Amiibo.cs | 72 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/CheatModel.cs | 37 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/CheatsList.cs | 51 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/DlcModel.cs | 18 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/ProfileImageModel.cs | 2 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/TitleUpdateModel.cs | 7 | ||||
-rw-r--r-- | Ryujinx.Ava/Ui/Models/UserProfile.cs | 61 |
7 files changed, 245 insertions, 3 deletions
diff --git a/Ryujinx.Ava/Ui/Models/Amiibo.cs b/Ryujinx.Ava/Ui/Models/Amiibo.cs new file mode 100644 index 00000000..8644ab52 --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/Amiibo.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Ryujinx.Ava.Ui.Models +{ + public class Amiibo + { + public struct AmiiboJson + { + [JsonPropertyName("amiibo")] public List<AmiiboApi> Amiibo { get; set; } + [JsonPropertyName("lastUpdated")] public DateTime LastUpdated { get; set; } + } + + public struct AmiiboApi + { + [JsonPropertyName("name")] public string Name { get; set; } + [JsonPropertyName("head")] public string Head { get; set; } + [JsonPropertyName("tail")] public string Tail { get; set; } + [JsonPropertyName("image")] public string Image { get; set; } + [JsonPropertyName("amiiboSeries")] public string AmiiboSeries { get; set; } + [JsonPropertyName("character")] public string Character { get; set; } + [JsonPropertyName("gameSeries")] public string GameSeries { get; set; } + [JsonPropertyName("type")] public string Type { get; set; } + + [JsonPropertyName("release")] public Dictionary<string, string> Release { get; set; } + + [JsonPropertyName("gamesSwitch")] public List<AmiiboApiGamesSwitch> GamesSwitch { get; set; } + + public override string ToString() + { + return Name; + } + + public string GetId() + { + return Head + Tail; + } + + public override bool Equals(object obj) + { + if (obj is AmiiboApi amiibo) + { + return amiibo.Head + amiibo.Tail == Head + Tail; + } + + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class AmiiboApiGamesSwitch + { + [JsonPropertyName("amiiboUsage")] public List<AmiiboApiUsage> AmiiboUsage { get; set; } + + [JsonPropertyName("gameID")] public List<string> GameId { get; set; } + + [JsonPropertyName("gameName")] public string GameName { get; set; } + } + + public class AmiiboApiUsage + { + [JsonPropertyName("Usage")] public string Usage { get; set; } + + [JsonPropertyName("write")] public bool Write { get; set; } + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/CheatModel.cs b/Ryujinx.Ava/Ui/Models/CheatModel.cs new file mode 100644 index 00000000..cdab27cd --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/CheatModel.cs @@ -0,0 +1,37 @@ +using Ryujinx.Ava.Ui.ViewModels; +using System; + +namespace Ryujinx.Ava.Ui.Models +{ + public class CheatModel : BaseModel + { + private bool _isEnabled; + + public event EventHandler<bool> EnableToggled; + + public CheatModel(string name, string buildId, bool isEnabled) + { + Name = name; + BuildId = buildId; + IsEnabled = isEnabled; + } + + public bool IsEnabled + { + get => _isEnabled; + set + { + _isEnabled = value; + EnableToggled?.Invoke(this, _isEnabled); + OnPropertyChanged(); + } + } + + public string BuildId { get; } + + public string BuildIdKey => $"{BuildId}-{Name}"; + public string Name { get; } + + public string CleanName => Name.Substring(1, Name.Length - 8); + } +}
\ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/CheatsList.cs b/Ryujinx.Ava/Ui/Models/CheatsList.cs new file mode 100644 index 00000000..f2b0592e --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/CheatsList.cs @@ -0,0 +1,51 @@ +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; + +namespace Ryujinx.Ava.Ui.Models +{ + public class CheatsList : ObservableCollection<CheatModel> + { + public CheatsList(string buildId, string path) + { + BuildId = buildId; + Path = path; + CollectionChanged += CheatsList_CollectionChanged; + } + + private void CheatsList_CollectionChanged(object sender, + NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + (e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled; + } + } + + private void Item_EnableToggled(object sender, bool e) + { + OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); + } + + public string BuildId { get; } + public string Path { get; } + + public bool IsEnabled + { + get + { + return this.ToList().TrueForAll(x => x.IsEnabled); + } + set + { + foreach (var cheat in this) + { + cheat.IsEnabled = value; + } + + OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); + } + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/DlcModel.cs b/Ryujinx.Ava/Ui/Models/DlcModel.cs new file mode 100644 index 00000000..7e5f4a62 --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/DlcModel.cs @@ -0,0 +1,18 @@ +namespace Ryujinx.Ava.Ui.Models +{ + public class DlcModel + { + public bool IsEnabled { get; set; } + public string TitleId { get; } + public string ContainerPath { get; } + public string FullPath { get; } + + public DlcModel(string titleId, string containerPath, string fullPath, bool isEnabled) + { + TitleId = titleId; + ContainerPath = containerPath; + FullPath = fullPath; + IsEnabled = isEnabled; + } + } +}
\ No newline at end of file diff --git a/Ryujinx.Ava/Ui/Models/ProfileImageModel.cs b/Ryujinx.Ava/Ui/Models/ProfileImageModel.cs index a23b55cc..1c9f3b05 100644 --- a/Ryujinx.Ava/Ui/Models/ProfileImageModel.cs +++ b/Ryujinx.Ava/Ui/Models/ProfileImageModel.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Ava.Ui.Models { - internal class ProfileImageModel + public class ProfileImageModel { public ProfileImageModel(string name, byte[] data) { diff --git a/Ryujinx.Ava/Ui/Models/TitleUpdateModel.cs b/Ryujinx.Ava/Ui/Models/TitleUpdateModel.cs index f864e70a..2bf6dbfa 100644 --- a/Ryujinx.Ava/Ui/Models/TitleUpdateModel.cs +++ b/Ryujinx.Ava/Ui/Models/TitleUpdateModel.cs @@ -9,8 +9,11 @@ namespace Ryujinx.Ava.Ui.Models public bool IsNoUpdate { get; } public ApplicationControlProperty Control { get; } public string Path { get; } - public string Label => IsNoUpdate ? LocaleManager.Instance["NoUpdate"] : - string.Format(LocaleManager.Instance["TitleUpdateVersionLabel"], Control.DisplayVersionString.ToString(), Path); + + public string Label => IsNoUpdate + ? LocaleManager.Instance["NoUpdate"] + : string.Format(LocaleManager.Instance["TitleUpdateVersionLabel"], Control.DisplayVersionString.ToString(), + Path); public TitleUpdateModel(ApplicationControlProperty control, string path, bool isNoUpdate = false) { diff --git a/Ryujinx.Ava/Ui/Models/UserProfile.cs b/Ryujinx.Ava/Ui/Models/UserProfile.cs new file mode 100644 index 00000000..351ada76 --- /dev/null +++ b/Ryujinx.Ava/Ui/Models/UserProfile.cs @@ -0,0 +1,61 @@ +using Ryujinx.Ava.Ui.ViewModels; +using Ryujinx.HLE.HOS.Services.Account.Acc; +using Profile = Ryujinx.HLE.HOS.Services.Account.Acc.UserProfile; + +namespace Ryujinx.Ava.Ui.Models +{ + public class UserProfile : BaseModel + { + private readonly Profile _profile; + private byte[] _image; + private string _name; + private UserId _userId; + + public byte[] Image + { + get => _image; + set + { + _image = value; + OnPropertyChanged(); + } + } + + public UserId UserId + { + get => _userId; + set + { + _userId = value; + OnPropertyChanged(); + } + } + + public string Name + { + get => _name; + set + { + _name = value; + OnPropertyChanged(); + } + } + + public UserProfile(Profile profile) + { + _profile = profile; + + Image = profile.Image; + Name = profile.Name; + UserId = profile.UserId; + } + + public bool IsOpened => _profile.AccountState == AccountState.Open; + + public void UpdateState() + { + OnPropertyChanged(nameof(IsOpened)); + OnPropertyChanged(nameof(Name)); + } + } +}
\ No newline at end of file |