mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
UI: Cheats - Prevent re-importing existing cheats when importing from cheat DB
This commit is contained in:
parent
f9b5897dbc
commit
f45aaa39f3
1 changed files with 11 additions and 1 deletions
|
@ -98,13 +98,23 @@ namespace Mesen.ViewModels
|
|||
CheatDbGameEntry? dbEntry = await CheatDatabaseWindow.Show(consoleType, parent);
|
||||
if(dbEntry != null && consoleType == MainWindowViewModel.Instance.RomInfo.ConsoleType) {
|
||||
List<CheatCode> newCheats = new();
|
||||
HashSet<string> existingCheats = new();
|
||||
foreach(CheatCode cheatCode in Cheats) {
|
||||
string key = cheatCode.Description + cheatCode.Codes + cheatCode.Type.ToString();
|
||||
existingCheats.Add(key);
|
||||
}
|
||||
|
||||
foreach(CheatDbCheatEntry cheatEntry in dbEntry.Cheats) {
|
||||
CheatCode newCheat = new CheatCode();
|
||||
newCheat.Description = cheatEntry.Desc;
|
||||
newCheat.Enabled = false;
|
||||
newCheat.Type = GetCheatType(consoleType, cheatEntry.Code);
|
||||
newCheat.Codes = string.Join(Environment.NewLine, cheatEntry.Code.Split(";", StringSplitOptions.RemoveEmptyEntries));
|
||||
newCheats.Add(newCheat);
|
||||
|
||||
string key = newCheat.Description + newCheat.Codes + newCheat.Type.ToString();
|
||||
if(!existingCheats.Contains(key)) {
|
||||
newCheats.Add(newCheat);
|
||||
}
|
||||
}
|
||||
Cheats.AddRange(newCheats);
|
||||
Sort();
|
||||
|
|
Loading…
Add table
Reference in a new issue