mirror of
https://github.com/chocolate-doom/launcher.git
synced 2024-11-22 04:31:02 +00:00
Populate drop-down IWAD selector based on which IWADs have been
configured, and add initial code to build command line. Subversion-branch: /launcher Subversion-revision: 1754
This commit is contained in:
parent
24b7ebbc9d
commit
59587038c7
5 changed files with 117 additions and 11 deletions
|
@ -12,6 +12,10 @@
|
|||
id plutonia;
|
||||
id tnt;
|
||||
}
|
||||
|
||||
- (void) closeConfigWindow: (id)sender;
|
||||
- (void) openConfigWindow: (id)sender;
|
||||
- (NSString *) getIWADLocation;
|
||||
|
||||
@end
|
||||
|
||||
|
|
101
IWADController.m
101
IWADController.m
|
@ -2,22 +2,115 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "IWADController.h"
|
||||
#include "IWADLocation.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IWAD_DOOM1,
|
||||
IWAD_DOOM2,
|
||||
IWAD_TNT,
|
||||
IWAD_PLUTONIA,
|
||||
IWAD_CHEX,
|
||||
NUM_IWAD_TYPES
|
||||
} IWAD;
|
||||
|
||||
static NSString *IWADLabels[NUM_IWAD_TYPES] =
|
||||
{
|
||||
@"Doom",
|
||||
@"Doom II: Hell on Earth",
|
||||
@"Final Doom: TNT: Evilution",
|
||||
@"Final Doom: Plutonia Experiment",
|
||||
@"Chex Quest"
|
||||
};
|
||||
|
||||
@implementation IWADController
|
||||
|
||||
|
||||
- (void) closeConfigWindow: (id)sender
|
||||
- (void) getIWADList: (IWADLocation **) iwadList
|
||||
{
|
||||
[self->configWindow orderOut: sender];
|
||||
iwadList[IWAD_DOOM1] = self->doom1;
|
||||
iwadList[IWAD_DOOM2] = self->doom2;
|
||||
iwadList[IWAD_TNT] = self->tnt;
|
||||
iwadList[IWAD_PLUTONIA] = self->plutonia;
|
||||
iwadList[IWAD_CHEX] = self->chex;
|
||||
}
|
||||
|
||||
// Set the dropdown list to include an entry for each IWAD that has
|
||||
// been configured.
|
||||
|
||||
- (void) setDropdownList
|
||||
{
|
||||
IWADLocation *iwadList[NUM_IWAD_TYPES];
|
||||
id location;
|
||||
unsigned int i;
|
||||
|
||||
[self getIWADList: iwadList];
|
||||
[self->iwadSelector removeAllItems];
|
||||
|
||||
for (i=0; i<NUM_IWAD_TYPES; ++i)
|
||||
{
|
||||
location = [iwadList[i] getLocation];
|
||||
|
||||
if (location != nil && [location length] > 0)
|
||||
{
|
||||
[self->iwadSelector addItemWithTitle: IWADLabels[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IWAD) getSelectedIWAD
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<NUM_IWAD_TYPES; ++i)
|
||||
{
|
||||
if ([self->iwadSelector titleOfSelectedItem] == IWADLabels[i])
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return NUM_IWAD_TYPES;
|
||||
}
|
||||
|
||||
// Get the location of the selected IWAD.
|
||||
|
||||
- (NSString *) getIWADLocation
|
||||
{
|
||||
IWAD selectedIWAD;
|
||||
IWADLocation *iwadList[NUM_IWAD_TYPES];
|
||||
|
||||
selectedIWAD = [self getSelectedIWAD];
|
||||
|
||||
if (selectedIWAD == NUM_IWAD_TYPES)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self getIWADList: iwadList];
|
||||
|
||||
return [iwadList[selectedIWAD] getLocation];
|
||||
}
|
||||
}
|
||||
|
||||
// Callback method invoked when the configuration button in the main
|
||||
// window is clicked.
|
||||
|
||||
- (void) openConfigWindow: (id)sender
|
||||
{
|
||||
if (![self->configWindow isVisible])
|
||||
{
|
||||
[self->configWindow makeKeyAndOrderFront: sender];
|
||||
[self->configWindow makeKeyAndOrderFront: sender];
|
||||
}
|
||||
}
|
||||
|
||||
// Callback method invoked when the close button is clicked.
|
||||
|
||||
- (void) closeConfigWindow: (id)sender
|
||||
{
|
||||
[self->configWindow orderOut: sender];
|
||||
[self setDropdownList];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ static id WAD_TYPES[] = {
|
|||
{
|
||||
NSArray *wadTypes = [NSArray arrayWithObjects: WAD_TYPES count: 2];
|
||||
NSOpenPanel *openPanel;
|
||||
NSString *filename;
|
||||
NSArray *filenames;
|
||||
int result;
|
||||
|
||||
|
@ -32,7 +33,8 @@ static id WAD_TYPES[] = {
|
|||
if (result == NSOKButton)
|
||||
{
|
||||
filenames = [openPanel filenames];
|
||||
[self->locationConfigBox setStringValue: [filenames lastObject]];
|
||||
filename = [filenames lastObject];
|
||||
[self->locationConfigBox setStringValue: filename];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
/* All Rights reserved */
|
||||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "IWADController.h"
|
||||
|
||||
@interface LauncherManager : NSObject
|
||||
{
|
||||
id commandLineArguments;
|
||||
id iwadController;
|
||||
id commandLineArguments;
|
||||
IWADController *iwadController;
|
||||
}
|
||||
|
||||
- (void) launch: (id)sender;
|
||||
- (void) runSetup: (id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -5,16 +5,19 @@
|
|||
|
||||
@implementation LauncherManager
|
||||
|
||||
|
||||
- (void) launch: (id)sender
|
||||
{
|
||||
/* insert your code here */
|
||||
}
|
||||
NSString *iwad;
|
||||
NSString *args;
|
||||
|
||||
iwad = [self->iwadController getIWADLocation];
|
||||
args = [self->commandLineArguments stringValue];
|
||||
|
||||
printf("Command line: %s %s\n", [iwad UTF8String], [args UTF8String]);
|
||||
}
|
||||
|
||||
- (void) runSetup: (id)sender
|
||||
{
|
||||
/* insert your code here */
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue