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 --- macosx/plugins/DFNet/English.lproj/DFNet.xib | 220 +++++++++++++++------ macosx/plugins/DFNet/English.lproj/SockDialog.xib | 25 ++- .../plugins/DFNet/macsrc/PluginConfigController.m | 44 +++-- 3 files changed, 202 insertions(+), 87 deletions(-) (limited to 'macosx/plugins/DFNet') 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]); -- cgit v1.2.3