diff --git a/GNUmakefile b/GNUmakefile index 9e69818..c274325 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -28,7 +28,8 @@ Resources/MainMenu-OSX.gsmarkup # chocolate-launcher_HEADER_FILES = \ AppController.h \ -IWADList.h \ +IWADController.h \ +IWADLocation.h \ LauncherManager.h # @@ -36,7 +37,8 @@ LauncherManager.h # chocolate-launcher_OBJC_FILES = \ AppController.m \ -IWADList.m \ +IWADController.m \ +IWADLocation.m \ LauncherManager.m # diff --git a/IWADController.h b/IWADController.h new file mode 100644 index 0000000..bd8938c --- /dev/null +++ b/IWADController.h @@ -0,0 +1,17 @@ +/* All Rights reserved */ + +#include + +@interface IWADController : NSObject +{ + id chex; + id doom1; + id doom2; + id iwadSelector; + id configWindow; + id plutonia; + id tnt; +} +- (void) closeConfigWindow: (id)sender; +- (void) openConfigWindow: (id)sender; +@end diff --git a/IWADController.m b/IWADController.m new file mode 100644 index 0000000..03e2928 --- /dev/null +++ b/IWADController.m @@ -0,0 +1,23 @@ +/* All Rights reserved */ + +#include +#include "IWADController.h" + +@implementation IWADController + + +- (void) closeConfigWindow: (id)sender +{ + [self->configWindow orderOut: sender]; +} + + +- (void) openConfigWindow: (id)sender +{ + if (![self->configWindow isVisible]) + { + [self->configWindow makeKeyAndOrderFront: sender]; + } +} + +@end diff --git a/IWADList.h b/IWADList.h deleted file mode 100644 index 62a77f5..0000000 --- a/IWADList.h +++ /dev/null @@ -1,40 +0,0 @@ -/* ... */ -//----------------------------------------------------------------------------- -// -// Copyright(C) 2009 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -//----------------------------------------------------------------------------- -// -// Controller for managing the list of IWAD files. -// -//----------------------------------------------------------------------------- - -#include - -@interface IWADList : NSObject -{ - id iwadListTable; - NSMutableArray *iwads; -} - -- (void) addIwad: (id)sender; -- (void) deleteIwad: (id)sender; -- (NSString *) getSelectedIwad; - -@end - diff --git a/IWADList.m b/IWADList.m deleted file mode 100644 index fb5a0d2..0000000 --- a/IWADList.m +++ /dev/null @@ -1,139 +0,0 @@ -/* ... */ -//----------------------------------------------------------------------------- -// -// Copyright(C) 2009 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -//----------------------------------------------------------------------------- -// -// Controller for managing the list of IWAD files. -// -//----------------------------------------------------------------------------- - -#include -#include "IWADList.h" - -static id WAD_TYPES[] = { - @"wad", @"WAD" -}; - -@implementation IWADList - -// Constructor. - -- init -{ - self = [super init]; - - iwads = [NSMutableArray array]; - [iwads retain]; - - return self; -} - -// Callback invoked when the add IWAD button is clicked. - -- (void) addIwad: (id)sender -{ - NSArray *wadTypes = [NSArray arrayWithObjects: WAD_TYPES count: 2]; - NSArray *filenames; - id filename; - NSOpenPanel *openPanel; - int result; - - [wadTypes retain]; - - // Open a file selector for the new file. - - openPanel = [NSOpenPanel openPanel]; - [openPanel setTitle: @"Add IWAD file"]; - [openPanel setCanChooseFiles: YES]; - [openPanel setCanChooseDirectories: NO]; - - result = [openPanel runModalForTypes: wadTypes]; - - // If the "OK" button was clicked, add the new IWAD file to the list. - - if (result == NSOKButton) - { - filenames = [openPanel filenames]; - filename = [filenames lastObject]; - [filename retain]; - [iwads addObject: filename]; - [iwadListTable reloadData]; - } -} - -// Callback invoked when the delete IWAD button is clicked. - -- (void) deleteIwad: (id)sender -{ - int row; - id str; - - [iwadListTable setHeaderView: nil]; - - // Check that a valid IWAD is selected. - - row = [iwadListTable selectedRow]; - - if (row >= 0 && row < [iwads count]) - { - str = [iwads objectAtIndex:row]; - - // Remove from the list. - - [iwads removeObjectAtIndex: row]; - [str release]; - [iwadListTable reloadData]; - } -} - -// Used by the table controller - returns number of rows for the table. - -- (int) numberOfRowsInTableView:(NSTableView *)aTableView -{ -printf("numberOfRowsInTableView\n"); - return [iwads count]; -} - -// Used by the table controller to get the contents for a cell. - -- (id) tableView:(NSTableView *) aTableView - objectValueForTableColumn: (NSTableColumn *) aTableColumn - row: (int) rowIndex -{ -printf("tableView\n"); - return [iwads objectAtIndex:rowIndex]; -} - -// Public interface to get the selected IWAD. - -- (NSString *) getSelectedIwad -{ - if ([iwads count] <= 0) - { - return nil; - } - else - { - return [iwads objectAtIndex:[iwadListTable selectedRow]]; - } -} - -@end - diff --git a/IWADLocation.h b/IWADLocation.h new file mode 100644 index 0000000..b3ab173 --- /dev/null +++ b/IWADLocation.h @@ -0,0 +1,14 @@ +/* All Rights reserved */ + +#include + +@interface IWADLocation : NSObject +{ + id locationConfigBox; +} + +- (void) setLocation: (id)sender; +- (NSString *) getLocation; + +@end + diff --git a/IWADLocation.m b/IWADLocation.m new file mode 100644 index 0000000..792dc8c --- /dev/null +++ b/IWADLocation.m @@ -0,0 +1,45 @@ +/* All Rights reserved */ + +#include +#include "IWADLocation.h" + +static id WAD_TYPES[] = { + @"wad", @"WAD" +}; + +@implementation IWADLocation + +- (void) setLocation: (id)sender +{ + NSArray *wadTypes = [NSArray arrayWithObjects: WAD_TYPES count: 2]; + NSOpenPanel *openPanel; + NSArray *filenames; + int result; + + [wadTypes retain]; + + // Open a file selector for the new file. + + openPanel = [NSOpenPanel openPanel]; + [openPanel setTitle: @"Add IWAD file"]; + [openPanel setCanChooseFiles: YES]; + [openPanel setCanChooseDirectories: NO]; + + result = [openPanel runModalForTypes: wadTypes]; + + // If the "OK" button was clicked, add the new IWAD file to the list. + + if (result == NSOKButton) + { + filenames = [openPanel filenames]; + [self->locationConfigBox setStringValue: [filenames lastObject]]; + } +} + +- (NSString *) getLocation +{ + return [self->locationConfigBox stringValue]; +} + +@end + diff --git a/LauncherManager.h b/LauncherManager.h index a45f931..4f51f4f 100644 --- a/LauncherManager.h +++ b/LauncherManager.h @@ -1,39 +1,12 @@ -/* ... */ -//----------------------------------------------------------------------------- -// -// Copyright(C) 2009 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -//----------------------------------------------------------------------------- -// -// Controller for the launcher program. -// -//----------------------------------------------------------------------------- +/* All Rights reserved */ #include @interface LauncherManager : NSObject { - id commandLineArguments; - id iwadList; + id commandLineArguments; + id iwadController; } - - (void) launch: (id)sender; - (void) runSetup: (id)sender; - @end - diff --git a/LauncherManager.m b/LauncherManager.m index c2a1bd6..7ba1ecc 100644 --- a/LauncherManager.m +++ b/LauncherManager.m @@ -1,51 +1,20 @@ -/* ... */ -//----------------------------------------------------------------------------- -// -// Copyright(C) 2009 Simon Howard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. -// -//----------------------------------------------------------------------------- -// -// Controller for the launcher program. -// -//----------------------------------------------------------------------------- +/* All Rights reserved */ #include #include "LauncherManager.h" -#include "IWADList.h" @implementation LauncherManager -// Callback invoked when the launch button is clicked. - (void) launch: (id)sender { - printf("launch the game\n"); - printf("arguments: -iwad %s %s\n", - [[iwadList getSelectedIwad] UTF8String], - [[commandLineArguments stringValue] UTF8String]); + /* insert your code here */ } -// Callback invoked when the setup tool button is clicked. - (void) runSetup: (id)sender { - printf("run setup tool\n"); + /* insert your code here */ } @end - diff --git a/PC.project b/PC.project index b30849d..f8ee230 100644 --- a/PC.project +++ b/PC.project @@ -6,7 +6,8 @@ ); CLASS_FILES = ( AppController.m, - IWADList.m, + IWADController.m, + IWADLocation.m, LauncherManager.m ); COMPILEROPTIONS = ""; @@ -18,7 +19,8 @@ ); HEADER_FILES = ( AppController.h, - IWADList.h, + IWADController.h, + IWADLocation.h, LauncherManager.h ); IMAGES = ( @@ -55,7 +57,7 @@ PRINCIPAL_CLASS = NSApplication; PROJECT_AUTHORS = ( ); - PROJECT_COPYRIGHT = "Copyright (C) 200x"; + PROJECT_COPYRIGHT = "Copyright (C) 2009"; PROJECT_COPYRIGHT_DESC = "Released under ..."; PROJECT_CREATOR = "Simon Howard,,,"; PROJECT_DESCRIPTION = "No description avaliable!"; @@ -84,4 +86,4 @@ BritainEnglish, English ); -} \ No newline at end of file +} diff --git a/Resources/launcher.gorm/data.classes b/Resources/launcher.gorm/data.classes index fece661..ad45da1 100644 --- a/Resources/launcher.gorm/data.classes +++ b/Resources/launcher.gorm/data.classes @@ -13,19 +13,37 @@ "addIwad:", "deleteIwad:", "launch:", + "closeConfigWindow:", + "openConfigWindow:", "orderFrontFontPanel:", "runSetup:", + "setLocation:", "showPrefPanel:" ); Super = NSObject; }; - IWADList = { + IWADController = { Actions = ( - "addIwad:", - "deleteIwad:" + "closeConfigWindow:", + "openConfigWindow:" ); Outlets = ( - iwadListTable + chex, + doom1, + doom2, + iwadSelector, + configWindow, + plutonia, + tnt + ); + Super = NSObject; + }; + IWADLocation = { + Actions = ( + "setLocation:" + ); + Outlets = ( + locationConfigBox ); Super = NSObject; }; @@ -36,7 +54,7 @@ ); Outlets = ( commandLineArguments, - iwadList + iwadController ); Super = NSObject; }; diff --git a/Resources/launcher.gorm/objects.gorm b/Resources/launcher.gorm/objects.gorm index b39a0d0..f068e1d 100644 Binary files a/Resources/launcher.gorm/objects.gorm and b/Resources/launcher.gorm/objects.gorm differ