-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmulatorProfile.cs
More file actions
107 lines (92 loc) · 3.46 KB
/
Copy pathEmulatorProfile.cs
File metadata and controls
107 lines (92 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace GameSnapPlugin
{
public class EmulatorProfile : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged;
private void Notify([CallerMemberName] string? name = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
public static readonly string[] BuiltInNames =
{
"RetroArch", "PCSX2", "Dolphin", "RPCS3",
"Cemu", "PPSSPP", "mGBA", "DuckStation"
};
public static List<EmulatorProfile> CreateDefaults()
{
var list = new List<EmulatorProfile>();
foreach (var name in BuiltInNames)
list.Add(new EmulatorProfile { Name = name, Enabled = false });
return list;
}
// ── Propriedades persistidas no JSON ─────────────────────────────────────
private string _name = "";
public string Name
{
get => _name;
set { _name = value; Notify(); NotifyComputed(); }
}
private bool _enabled;
public bool Enabled
{
get => _enabled;
set { _enabled = value; Notify(); }
}
private string _customPath = "";
public string CustomPath
{
get => _customPath;
set { _customPath = value; Notify(); NotifyComputed(); }
}
public bool IsUserAdded { get; set; } = false;
// ── Propriedades computed — NÃO persistidas no JSON ──────────────────────
[IgnoreDataMember]
public bool IsCustom => !string.IsNullOrEmpty(CustomPath);
[IgnoreDataMember]
public string DisplayPath
{
get
{
if (!string.IsNullOrEmpty(CustomPath)) return CustomPath;
var auto = EmulatorService.GetDefaultFolder(Name);
return auto ?? "(auto)";
}
}
[IgnoreDataMember]
public string StatusText
{
get
{
if (!string.IsNullOrEmpty(CustomPath))
return System.IO.Directory.Exists(CustomPath) ? "OK Custom" : "X Not found";
var auto = EmulatorService.GetDefaultFolder(Name);
if (auto == null) return "X Not found";
return System.IO.Directory.Exists(auto) ? "OK Detected" : "X Not found";
}
}
[IgnoreDataMember]
public string StatusColor => StatusText.StartsWith("OK") ? "#4caf50" : "#f44336";
[IgnoreDataMember]
public string? ResolvedPath
{
get
{
if (!string.IsNullOrEmpty(CustomPath))
return System.IO.Directory.Exists(CustomPath) ? CustomPath : null;
var auto = EmulatorService.GetDefaultFolder(Name);
return auto != null && System.IO.Directory.Exists(auto) ? auto : null;
}
}
private void NotifyComputed()
{
Notify(nameof(IsCustom));
Notify(nameof(DisplayPath));
Notify(nameof(StatusText));
Notify(nameof(StatusColor));
Notify(nameof(ResolvedPath));
}
}
}