From c912deb4e76adb823b1bb5355b1171eb1241b42b Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Tue, 9 Jul 2013 03:20:01 +0000 Subject: Updating OS X plug-in code. Now the net plug-in will warn you if you have a too large or non-ASCII characters. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85926 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- .../English.lproj/Bladesio1PluginConfig.xib | 3 +- .../Bladesio1/macsrc/PluginConfigController.h | 1 - .../Bladesio1/macsrc/PluginConfigController.m | 21 +- macosx/plugins/Bladesio1/macsrc/cfg.c | 11 -- .../DFCdrom/macsrc/PluginConfigController.m | 11 +- macosx/plugins/DFInput/macsrc/PadController.m | 10 +- macosx/plugins/DFNet/English.lproj/DFNet.xib | 220 +++++++++++++++------ macosx/plugins/DFNet/English.lproj/SockDialog.xib | 25 ++- .../plugins/DFNet/macsrc/PluginConfigController.m | 44 +++-- macosx/plugins/DFSound/macsrc/PluginController.m | 10 +- .../DFXVideo/macsrc/PluginConfigController.m | 11 +- .../NetSfPeopsOpenGLPluginConfigController.m | 10 +- 12 files changed, 222 insertions(+), 155 deletions(-) (limited to 'macosx/plugins') diff --git a/macosx/plugins/Bladesio1/English.lproj/Bladesio1PluginConfig.xib b/macosx/plugins/Bladesio1/English.lproj/Bladesio1PluginConfig.xib index 26b3fd66..91239800 100644 --- a/macosx/plugins/Bladesio1/English.lproj/Bladesio1PluginConfig.xib +++ b/macosx/plugins/Bladesio1/English.lproj/Bladesio1PluginConfig.xib @@ -93,7 +93,6 @@ {{236, 13}, {65, 32}} - YES 67108864 @@ -1536,7 +1535,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h index 595dce02..3adaf29b 100755 --- a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h +++ b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.h @@ -17,7 +17,6 @@ - (IBAction)toggleEnabled:(id)sender; - (IBAction)resetPreferences:(id)sender; - - (void)loadValues; @end diff --git a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m index 609976ef..dbc85174 100755 --- a/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m +++ b/macosx/plugins/Bladesio1/macsrc/PluginConfigController.m @@ -121,14 +121,18 @@ void ReadConfig() NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues]; NSString *theAddress = [ipAddressField stringValue]; - if ([theAddress lengthOfBytesUsingEncoding:NSASCIIStringEncoding] > (sizeof(settings.ip) - 1)) { - NSBeginAlertSheet(@"Address too long", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address is too long. Try to use only the IP address and not a host name."); + NSInteger asciiLen = [theAddress lengthOfBytesUsingEncoding:NSASCIIStringEncoding]; + if (asciiLen > (sizeof(settings.ip) - 1)) { + NSBeginAlertSheet(@"Address too long", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address is too long.\n\nTry to use only the IP address and not a host name."); + return; + } else if (asciiLen == 0) { + NSBeginAlertSheet(@"Blank address", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address specified is either blank, or can't be converted to ASCII.\n\nTry connecting directly using the IP address using latin numerals."); return; } [writeDic setObject:(([enabledButton state] == NSOnState) ? @YES : @NO) forKey:kSioEnabled]; [writeDic setObject:theAddress forKey:kSioIPAddress]; - [writeDic setObject:@((unsigned short)[portField intValue]) forKey:kSioPort]; + [writeDic setObject:@((u16)[portField intValue]) forKey:kSioPort]; { int player; @@ -202,12 +206,5 @@ void ReadConfig() @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} - +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); diff --git a/macosx/plugins/Bladesio1/macsrc/cfg.c b/macosx/plugins/Bladesio1/macsrc/cfg.c index 65fd5111..98531e47 100755 --- a/macosx/plugins/Bladesio1/macsrc/cfg.c +++ b/macosx/plugins/Bladesio1/macsrc/cfg.c @@ -37,14 +37,3 @@ void settingsRead() { ReadConfig(); } - -#if 0 -extern long SIO1configure() { - ConfDlgProc(); - return 0; -} - -extern void SIO1about() { - AboutDlgProc(); -} -#endif diff --git a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m b/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m index 95f57fb5..ed80b490 100755 --- a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m +++ b/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m @@ -165,12 +165,5 @@ void ReadConfig() @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} - +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); diff --git a/macosx/plugins/DFInput/macsrc/PadController.m b/macosx/plugins/DFInput/macsrc/PadController.m index 87e25407..e3942158 100755 --- a/macosx/plugins/DFInput/macsrc/PadController.m +++ b/macosx/plugins/DFInput/macsrc/PadController.m @@ -145,11 +145,5 @@ long DoConfiguration() { @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PadController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} +#import "OSXPlugLocalization.h" +PLUGLOCIMP([padController class]); diff --git a/macosx/plugins/DFNet/English.lproj/DFNet.xib b/macosx/plugins/DFNet/English.lproj/DFNet.xib index 5fddbcca..bb2868f0 100644 --- a/macosx/plugins/DFNet/English.lproj/DFNet.xib +++ b/macosx/plugins/DFNet/English.lproj/DFNet.xib @@ -2,22 +2,23 @@ 1060 - 11C74 - 1938 - 1138.23 - 567.00 + 12E55 + 3084 + 1187.39 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin - 1938 + 3084 + NSButton + NSButtonCell + NSCustomObject + NSNumberFormatter NSTextField + NSTextFieldCell NSView NSWindowTemplate - NSTextFieldCell - NSButtonCell - NSButton - NSCustomObject com.apple.InterfaceBuilder.CocoaPlugin @@ -39,24 +40,26 @@ 15 2 - {{196, 240}, {372, 270}} + {{196, 240}, {340, 151}} 544735232 Settings NSWindow + {340, 151} - + 256 268 - {{262, 12}, {96, 32}} + {{230, 13}, {96, 32}} + YES - 67239424 + 67108864 134217728 Okay @@ -65,22 +68,25 @@ 1044 - -2038284033 + -2038284288 129 200 25 + NO 268 - {{126, 228}, {96, 22}} + {{126, 109}, {194, 22}} + + YES - -1804468671 + -1804599231 272630784 127.0.0.1 @@ -105,52 +111,100 @@ + NO 268 - {{154, 12}, {96, 32}} + {{134, 13}, {96, 32}} + + YES - 67239424 + 67108864 134217728 Cancel - -2038284033 + -2038284288 129 Gw 200 25 + NO 268 - {{126, 198}, {96, 22}} + {{126, 79}, {194, 22}} + + YES - -1804468671 - 272630784 + -1804599231 + -1874852864 33306 + + + + + + + + + + -∞ + + +∞ + + # + # + + + + + + + + NaN + + + + + + 3 + YES + YES + YES + + . + , + NO + NO + YES + YES + NO 268 - {{17, 230}, {75, 17}} + {{17, 111}, {75, 17}} + + YES - 68288064 + 68157504 272630784 IP Address: @@ -171,15 +225,18 @@ + NO 268 - {{17, 200}, {38, 17}} + {{17, 81}, {38, 17}} + + YES - 68288064 + 68157504 272630784 Port: @@ -187,15 +244,18 @@ + NO 268 - {{17, 170}, {101, 17}} + {{17, 51}, {101, 17}} + + YES - 68288064 + 68157504 272630784 Player Number: @@ -203,28 +263,73 @@ + NO 268 - {{126, 168}, {96, 22}} + {{126, 49}, {194, 22}} + + YES - -1804468671 - 272630784 + -1804599231 + -1874852864 1 + + + + + + + + -∞ + + +∞ + + # + # + + + + + + + + NaN + + + + + + 3 + YES + YES + YES + + . + , + NO + NO + YES + YES + NO - {372, 270} + {340, 151} + + + - {{0, 0}, {1680, 1028}} + {{0, 0}, {1920, 1058}} + {340, 173} {10000000000000, 10000000000000} YES @@ -318,7 +423,6 @@ 2 - @@ -326,6 +430,7 @@ + @@ -379,6 +484,9 @@ 18 + + + @@ -431,8 +539,21 @@ 27 + + + + + 29 + + + + + 30 + + + @@ -463,6 +584,12 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -471,32 +598,13 @@ - 28 + 30 DFNetPlayPluginConfigController NSWindowController - - NSTextField - NSTextField - NSTextField - - - - ipAddress - NSTextField - - - playerNum - NSTextField - - - portNum - NSTextField - - IBProjectSource ./Classes/DFNetPlayPluginConfigController.h @@ -510,10 +618,6 @@ com.apple.InterfaceBuilder.CocoaPlugin.macosx - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - YES 3 diff --git a/macosx/plugins/DFNet/English.lproj/SockDialog.xib b/macosx/plugins/DFNet/English.lproj/SockDialog.xib index 04c8cc73..6c2808d2 100644 --- a/macosx/plugins/DFNet/English.lproj/SockDialog.xib +++ b/macosx/plugins/DFNet/English.lproj/SockDialog.xib @@ -40,12 +40,14 @@ 15 2 - {{196, 371}, {382, 139}} + {{196, 371}, {380, 140}} 544735232 Window NSWindow + {380, 140} + {380, 140} 256 @@ -53,9 +55,10 @@ 268 - {{17, 102}, {348, 17}} + {{78, 103}, {225, 17}} + YES 68157504 @@ -90,19 +93,21 @@ - 1292 - {{104, 61}, {174, 20}} + 268 + {{103, 60}, {174, 20}} + 24586 100 268 - {{143, 12}, {96, 32}} + {{142, 13}, {96, 32}} + YES 67108864 @@ -120,12 +125,14 @@ NO - {382, 139} + {380, 140} + - {{0, 0}, {1680, 1028}} - {10000000000000, 10000000000000} + {{0, 0}, {1920, 1058}} + {380, 162} + {380, 162} YES @@ -186,9 +193,9 @@ 2 - + diff --git a/macosx/plugins/DFNet/macsrc/PluginConfigController.m b/macosx/plugins/DFNet/macsrc/PluginConfigController.m index 53f1567a..c25bd8bf 100755 --- a/macosx/plugins/DFNet/macsrc/PluginConfigController.m +++ b/macosx/plugins/DFNet/macsrc/PluginConfigController.m @@ -23,9 +23,9 @@ #include "dfnet.h" #import "ARCBridge.h" -NSString * const kIPADDRKEY = @"IP Address"; -NSString * const kIPPORT = @"IP Port"; -NSString * const kPLAYERNUM = @"Player Number"; +#define kIPADDRKEY @"IP Address" +#define kIPPORT @"IP Port" +#define kPLAYERNUM @"Player Number" #define APP_ID @"net.codeplex.pcsxr.DFNet" #define PrefsKey APP_ID @" Settings" @@ -90,9 +90,9 @@ void ReadConfig() [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys: - @"127.0.0.1",kIPADDRKEY, - [NSNumber numberWithInt:33306], kIPPORT, - [NSNumber numberWithInt:1], kPLAYERNUM, + @"127.0.0.1", kIPADDRKEY, + @((unsigned short)33306), kIPPORT, + @1, kPLAYERNUM, nil], PrefsKey, nil]]; keyValues = [defaults dictionaryForKey:PrefsKey]; @@ -113,10 +113,21 @@ void ReadConfig() { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *theAddress = [ipAddress stringValue]; + NSInteger asciiLen = [theAddress lengthOfBytesUsingEncoding:NSASCIIStringEncoding]; + if (asciiLen > (sizeof(conf.ipAddress) - 1)) { + NSBeginAlertSheet(@"Address too long", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address is too long.\n\nTry to use only the IP address and not a host name."); + return; + } else if (asciiLen == 0) { + NSBeginAlertSheet(@"Blank address", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address specified is either blank, or can't be converted to ASCII.\n\nTry connecting directly using the IP address using latin numerals."); + return; + } + + NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:[defaults dictionaryForKey:PrefsKey]]; - [writeDic setObject:[NSNumber numberWithInt:[portNum intValue]] forKey:kIPPORT]; - [writeDic setObject:[NSNumber numberWithInt:[playerNum intValue]] forKey:kPLAYERNUM]; - [writeDic setObject:[ipAddress stringValue] forKey:kIPADDRKEY]; + [writeDic setObject:@((unsigned short)[portNum intValue]) forKey:kIPPORT]; + [writeDic setObject:@([playerNum intValue]) forKey:kPLAYERNUM]; + [writeDic setObject:theAddress forKey:kIPADDRKEY]; // write to defaults [defaults setObject:writeDic forKey:PrefsKey]; @@ -135,18 +146,11 @@ void ReadConfig() NSDictionary *keyValues = [defaults dictionaryForKey:PrefsKey]; [ipAddress setStringValue:[keyValues objectForKey:kIPADDRKEY]]; - [portNum setStringValue:[[keyValues objectForKey:kIPPORT] stringValue]]; - [playerNum setStringValue:[[keyValues objectForKey:kPLAYERNUM] stringValue]]; + [portNum setIntValue:[[keyValues objectForKey:kIPPORT] unsignedShortValue]]; + [playerNum setIntValue:[[keyValues objectForKey:kPLAYERNUM] intValue]]; } @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} - +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); diff --git a/macosx/plugins/DFSound/macsrc/PluginController.m b/macosx/plugins/DFSound/macsrc/PluginController.m index 49cd371b..fa6fbc97 100755 --- a/macosx/plugins/DFSound/macsrc/PluginController.m +++ b/macosx/plugins/DFSound/macsrc/PluginController.m @@ -216,11 +216,5 @@ void ReadConfig(void) @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:@"" table:nil]; - return (char*)[transString UTF8String]; -} +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginController class]); diff --git a/macosx/plugins/DFXVideo/macsrc/PluginConfigController.m b/macosx/plugins/DFXVideo/macsrc/PluginConfigController.m index 2932d3d7..75b2433f 100755 --- a/macosx/plugins/DFXVideo/macsrc/PluginConfigController.m +++ b/macosx/plugins/DFXVideo/macsrc/PluginConfigController.m @@ -354,12 +354,5 @@ void ReadConfig(void) @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} - +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); diff --git a/macosx/plugins/PeopsXgl/macsrc/NetSfPeopsOpenGLPluginConfigController.m b/macosx/plugins/PeopsXgl/macsrc/NetSfPeopsOpenGLPluginConfigController.m index 37793acc..f5f5e7c3 100755 --- a/macosx/plugins/PeopsXgl/macsrc/NetSfPeopsOpenGLPluginConfigController.m +++ b/macosx/plugins/PeopsXgl/macsrc/NetSfPeopsOpenGLPluginConfigController.m @@ -362,11 +362,5 @@ void ReadConfig(void) @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); -- cgit v1.2.3