From 41e3401765468965e52ffedd84462d585395a488 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 2 Aug 2023 13:23:18 -0700 Subject: [PATCH] Cocoa Port: In the Cheat Database Viewer, add the option to ignore any game compatibility checks when adding new cheats. - At their own risk, this option allows the user to add any cheat from the database to any game that they want, regardless of any potential dangers that may arise from doing so. Use this option responsibly. --- .../English.lproj/CheatDatabaseViewer.xib | 580 ++++++++++-------- .../CheatDatabaseWindowController.h | 4 + .../CheatDatabaseWindowController.mm | 39 +- .../userinterface/EmuControllerDelegate.mm | 8 + 4 files changed, 383 insertions(+), 248 deletions(-) diff --git a/desmume/src/frontend/cocoa/translations/English.lproj/CheatDatabaseViewer.xib b/desmume/src/frontend/cocoa/translations/English.lproj/CheatDatabaseViewer.xib index bca64a637..f18057cd5 100644 --- a/desmume/src/frontend/cocoa/translations/English.lproj/CheatDatabaseViewer.xib +++ b/desmume/src/frontend/cocoa/translations/English.lproj/CheatDatabaseViewer.xib @@ -95,7 +95,7 @@ 292 - {{43, 3}, {114, 32}} + {{44, 3}, {110, 32}} YES @@ -121,7 +121,7 @@ 292 - {{157, 3}, {114, 32}} + {{149, 3}, {110, 32}} YES @@ -351,101 +351,101 @@ NO 1 - + 268 {{17, 414}, {90, 14}} YES - + 68157504 4326400 Game Search: - + NO 1 - + 265 {{303, 412}, {36, 14}} YES - + 68157504 71435264 CRC: - + LucidaGrande-Bold 11 16 - + NO 1 - + 265 {{294, 430}, {45, 14}} YES - + 68157504 71435264 Serial: - - + + NO 1 - + 265 {{340, 412}, {83, 14}} YES - + 70254657 4330496 CRC - + NO 1 - + 265 {{340, 430}, {83, 14}} YES - + 70254657 4330496 gameCode - + @@ -499,7 +499,7 @@ 292 - {{11, 7}, {27, 27}} + {{12, 7}, {27, 27}} YES @@ -511,7 +511,7 @@ -2033434624 160 - + NSImage NSActionTemplate @@ -1211,7 +1211,7 @@ NO 1 - + 265 {{289, 385}, {136, 28}} @@ -1219,13 +1219,13 @@ _NS:610 YES - + 67108864 134348800 Select Current Game _NS:610 - + -2038284288 129 @@ -1235,6 +1235,71 @@ NO + + + 289 + {{424.9296875, 7}, {106, 26}} + + + YES + + -2076180416 + 2048 + + + 109199360 + 129 + + + 400 + 75 + + + YES + Options + + 1048576 + 2147483647 + + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + + Ignore Compatibility Check + + 2147483647 + + + _popUpItemAction: + + + + + + 1 + YES + 1 + YES + YES + 2 + + NO + {640, 480} @@ -1412,7 +1477,7 @@ 69206017 272633856 - + LucidaGrande-Bold 13 16 @@ -1479,7 +1544,7 @@ NO - + 268 {{17, 148}, {446, 17}} @@ -1487,21 +1552,21 @@ _NS:4068 YES - + 70254657 272634880 - + Major String _NS:4068 - + NO 1 - + 268 {{17, 44}, {446, 96}} @@ -1509,14 +1574,14 @@ _NS:4068 YES - + 69206017 272764928 Minor String _NS:4068 - + @@ -2046,17 +2111,17 @@ selectCurrentGame: - + 196 enabled: isCurrentGameFound - + - + enabled: isCurrentGameFound enabled @@ -2066,156 +2131,6 @@ 197 - - - enabled: isCurrentGameFound - - - - - - enabled: isCurrentGameFound - enabled - isCurrentGameFound - 2 - - - 198 - - - - enabled: isCurrentGameFound - - - - - - enabled: isCurrentGameFound - enabled - isCurrentGameFound - 2 - - - 199 - - - - enabled: isCurrentGameFound - - - - - - enabled: isCurrentGameFound - enabled - isCurrentGameFound - 2 - - - 200 - - - - enabled2: isSelectedGameTheCurrentGame - - - - - - enabled2: isSelectedGameTheCurrentGame - enabled2 - isSelectedGameTheCurrentGame - - YES - - YES - NSMultipleValuesPlaceholder - NSNoSelectionPlaceholder - NSNotApplicablePlaceholder - NSNullPlaceholder - - - YES - - - - - - - - 2 - - - 201 - - - - enabled2: isSelectedGameTheCurrentGame - - - - - - enabled2: isSelectedGameTheCurrentGame - enabled2 - isSelectedGameTheCurrentGame - - YES - - YES - NSMultipleValuesPlaceholder - NSNoSelectionPlaceholder - NSNotApplicablePlaceholder - NSNullPlaceholder - - - YES - - - - - - - - 2 - - - 202 - - - - enabled2: isSelectedGameTheCurrentGame - - - - - - enabled2: isSelectedGameTheCurrentGame - enabled2 - isSelectedGameTheCurrentGame - - YES - - YES - NSMultipleValuesPlaceholder - NSNoSelectionPlaceholder - NSNotApplicablePlaceholder - NSNullPlaceholder - - - YES - - - - - - - - 2 - - - 203 - errorSheet @@ -2235,10 +2150,10 @@ value: errorMajorString - + - + value: errorMajorString value @@ -2251,10 +2166,10 @@ value: errorMajorString - + - + value: errorMajorString value @@ -2267,10 +2182,10 @@ value: errorMinorString - + - + value: errorMinorString value @@ -2285,7 +2200,7 @@ predicate: filterPredicate - + predicate: filterPredicate @@ -2314,7 +2229,7 @@ predicate2: filterPredicate - + predicate2: filterPredicate @@ -2333,7 +2248,7 @@ serial CONTAINS[cd] $value - + 2 @@ -2363,7 +2278,7 @@ crcString CONTAINS[cd] $value - + 2 @@ -2373,17 +2288,17 @@ selectCurrentGameButton - + 229 value: currentGameSerial - + - + value: currentGameSerial value @@ -2396,10 +2311,10 @@ value: currentGameCRCString - + - + value: currentGameCRCString value @@ -2409,6 +2324,121 @@ 241 + + + value: isCompatibilityCheckIgnored + + + + + + value: isCompatibilityCheckIgnored + value + isCompatibilityCheckIgnored + 2 + + + 278 + + + + enabled: isSelectedGameTheCurrentGame + + + + + + enabled: isSelectedGameTheCurrentGame + enabled + isSelectedGameTheCurrentGame + + YES + + YES + NSMultipleValuesPlaceholder + NSNoSelectionPlaceholder + NSNotApplicablePlaceholder + NSNullPlaceholder + + + YES + + + + + + + 2 + + + 279 + + + + enabled: isSelectedGameTheCurrentGame + + + + + + enabled: isSelectedGameTheCurrentGame + enabled + isSelectedGameTheCurrentGame + + YES + + YES + NSMultipleValuesPlaceholder + NSNoSelectionPlaceholder + NSNotApplicablePlaceholder + NSNullPlaceholder + + + YES + + + + + + + 2 + + + 280 + + + + enabled: isSelectedGameTheCurrentGame + + + + + + enabled: isSelectedGameTheCurrentGame + enabled + isSelectedGameTheCurrentGame + + YES + + YES + NSMultipleValuesPlaceholder + NSNoSelectionPlaceholder + NSNotApplicablePlaceholder + NSNullPlaceholder + + + YES + + + + + + + 2 + + + 281 + @@ -2466,12 +2496,13 @@ - - - - - - + + + + + + + @@ -2674,9 +2705,9 @@ YES - + - + @@ -3033,115 +3064,153 @@ 187 - + YES - + 188 - - + + 190 - + YES - + 191 - - + + 210 - + YES - + 211 - - + + 213 - + YES - + 214 - - + + 230 - + YES - + 231 - - + + 232 - + YES - + 233 - - + + 234 - + YES - + 235 - + YES - + 236 - - + + 237 - - + + + + + 270 + + + YES + + + + + + 271 + + + YES + + + + + + 272 + + + YES + + + + + + + 275 + + + + + 277 + + @@ -3212,6 +3281,14 @@ 25.IBPluginDependency 26.IBPluginDependency 27.IBPluginDependency + 270.IBPluginDependency + 270.IBViewBoundsToFrameTransform + 271.IBPluginDependency + 272.IBEditorWindowLastContentRect + 272.IBPluginDependency + 275.IBAttributePlaceholdersKey + 275.IBPluginDependency + 277.IBPluginDependency 28.IBPluginDependency 3.IBEditorWindowLastContentRect 3.IBPluginDependency @@ -3377,6 +3454,23 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABD0YAAwcgAAA + + com.apple.InterfaceBuilder.CocoaPlugin + {{916, 204}, {251, 43}} + com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Renders NDS shadow polygons. Disabling this option may cause some shadows to disappear. Low performance impact. + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{502, 214}, {640, 480}} com.apple.InterfaceBuilder.CocoaPlugin {{502, 214}, {640, 480}} @@ -3499,7 +3593,7 @@ - 241 + 281 @@ -3659,11 +3753,15 @@ YES NSActionTemplate + NSMenuCheckmark + NSMenuMixedState NSSwitch YES {14, 14} + {11, 11} + {10, 3} {15, 15} diff --git a/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.h b/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.h index e8f1622a4..80e0c6156 100644 --- a/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.h +++ b/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.h @@ -48,6 +48,8 @@ NSString *currentGameIndexString; NSString *currentGameSerial; NSUInteger currentGameCRC; + BOOL isCompatibilityCheckIgnored; + BOOL isOptionWarningSilenced; NSString *errorMajorString; NSString *errorMinorString; @@ -76,6 +78,8 @@ @property (retain, nonatomic) NSString *currentGameSerial; @property (assign, nonatomic) NSUInteger currentGameCRC; @property (readonly, nonatomic) NSString *currentGameCRCString; +@property (assign, nonatomic) BOOL isCompatibilityCheckIgnored; +@property (assign) BOOL isOptionWarningSilenced; @property (assign) NSString *errorMajorString; @property (assign) NSString *errorMinorString; diff --git a/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.mm b/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.mm index 2ec9cb352..c71e759b0 100644 --- a/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.mm +++ b/desmume/src/frontend/cocoa/userinterface/CheatDatabaseWindowController.mm @@ -46,6 +46,8 @@ NSMutableArray *cheatDatabaseWindowList = nil; @dynamic currentGameSerial; @synthesize currentGameCRC; @dynamic currentGameCRCString; +@dynamic isCompatibilityCheckIgnored; +@synthesize isOptionWarningSilenced; @synthesize errorMajorString; @synthesize errorMinorString; @@ -71,6 +73,8 @@ NSMutableArray *cheatDatabaseWindowList = nil; currentGameTableRowIndex = NSNotFound; currentGameSerial = nil; currentGameCRC = 0; + isCompatibilityCheckIgnored = NO; + isOptionWarningSilenced = NO; errorMajorString = @"No error has occurred!"; errorMinorString = @"This is just a placeholder message for initialization purposes."; @@ -237,6 +241,7 @@ NSMutableArray *cheatDatabaseWindowList = nil; [NSDate date], @"AddedDate", [[self window] stringWithSavedFrame], @"WindowFrame", [NSNumber numberWithFloat:[[[splitView subviews] objectAtIndex:0] frame].size.height], @"WindowSplitViewDividerPosition", + [NSNumber numberWithBool:[self isCompatibilityCheckIgnored]], @"OptionIgnoreCompatibilityCheck", nil]; // ...and then add the newest recent item, ensuring that it is always last in the list. @@ -337,7 +342,7 @@ NSMutableArray *cheatDatabaseWindowList = nil; if ( (delegate != nil) && (cheatManager != nil) && ([selectedGame serial] != nil) ) { - showWillAddColumn = ([[selectedGame serial] isEqualToString:currentGameSerial]) && ([selectedGame crc] == currentGameCRC); + showWillAddColumn = ( [self isCompatibilityCheckIgnored] || (([[selectedGame serial] isEqualToString:currentGameSerial]) && ([selectedGame crc] == currentGameCRC)) ); } NSTableColumn *willAddColumn = [entryOutline tableColumnWithIdentifier:@"willAdd"]; @@ -524,6 +529,30 @@ NSMutableArray *cheatDatabaseWindowList = nil; return @"---"; } +- (BOOL) isCompatibilityCheckIgnored +{ + return isCompatibilityCheckIgnored; +} + +- (void) setIsCompatibilityCheckIgnored:(BOOL)theState +{ + isCompatibilityCheckIgnored = theState; + + if (![self isOptionWarningSilenced] && theState) + { + NSAlert *criticalErrorAlert = [[[NSAlert alloc] init] autorelease]; + [criticalErrorAlert setAlertStyle:ALERTSTYLE_CRITICAL]; + [criticalErrorAlert setMessageText:@"Using an incompatible cheat may ruin your game."]; + [criticalErrorAlert setInformativeText:@"Cheats are normally restricted to the current game \ +for compatibility reasons. By choosing to ignore the compatibility check, you can add any cheat to \ +any game that you want, but you must also assume the risk of an incompatible cheat ruining your game \ +session or corrupting your game's save data."]; + [criticalErrorAlert runModal]; + } + + [self validateWillAddColumn]; +} + #pragma mark - #pragma mark IBActions @@ -620,11 +649,6 @@ NSMutableArray *cheatDatabaseWindowList = nil; return; } - if ( ([self currentGameSerial] == nil) || ([self currentGameCRC] == 0) ) - { - return; - } - NSMutableArray *entryTree = [entryListController content]; if (entryTree == nil) { @@ -634,7 +658,7 @@ NSMutableArray *cheatDatabaseWindowList = nil; NSInteger selectedIndex = [gameTable selectedRow]; CocoaDSCheatDBGame *selectedGame = (CocoaDSCheatDBGame *)[[gameListController arrangedObjects] objectAtIndex:selectedIndex]; - if ( (![[selectedGame serial] isEqualToString:[self currentGameSerial]]) || ([selectedGame crc] != [self currentGameCRC]) ) + if ( ![self isCompatibilityCheckIgnored] && ((![[selectedGame serial] isEqualToString:[self currentGameSerial]]) || ([selectedGame crc] != [self currentGameCRC])) ) { return; } @@ -725,6 +749,7 @@ NSMutableArray *cheatDatabaseWindowList = nil; NSMutableDictionary *newRecentItem = [NSMutableDictionary dictionaryWithDictionary:recentItem]; [newRecentItem setObject:[[self window] stringWithSavedFrame] forKey:@"WindowFrame"]; [newRecentItem setObject:[NSNumber numberWithFloat:[[[splitView subviews] objectAtIndex:0] frame].size.height] forKey:@"WindowSplitViewDividerPosition"]; + [newRecentItem setObject:[NSNumber numberWithBool:[self isCompatibilityCheckIgnored]] forKey:@"OptionIgnoreCompatibilityCheck"]; [dbRecentsList addObject:newRecentItem]; } diff --git a/desmume/src/frontend/cocoa/userinterface/EmuControllerDelegate.mm b/desmume/src/frontend/cocoa/userinterface/EmuControllerDelegate.mm index 9a0b82b18..2fe9e93c5 100644 --- a/desmume/src/frontend/cocoa/userinterface/EmuControllerDelegate.mm +++ b/desmume/src/frontend/cocoa/userinterface/EmuControllerDelegate.mm @@ -854,6 +854,14 @@ if (recentItem != nil) { + NSNumber *compatibilityCheckNumber = (NSNumber *)[recentItem objectForKey:@"OptionIgnoreCompatibilityCheck"]; + if (compatibilityCheckNumber != nil) + { + [newWindowController setIsOptionWarningSilenced:YES]; + [newWindowController setIsCompatibilityCheckIgnored:[compatibilityCheckNumber boolValue]]; + [newWindowController setIsOptionWarningSilenced:NO]; + } + // Set up the window properties. NSString *windowFrameString = (NSString *)[recentItem objectForKey:@"WindowFrame"]; if (windowFrameString != nil)