osx: Tweak launcher interface.

Change preferences window to use standard NSPathControl controls for
selecting IWAD file paths. Make the command line arguments text box
multiline to better support long command lines.
This commit is contained in:
Simon Howard 2016-06-04 19:29:09 -04:00
parent 46b0556624
commit d8cfdba5bf
6 changed files with 528 additions and 3708 deletions

View file

@ -129,7 +129,6 @@ LAUNCHER_OBJS= \
AppController.o \
Execute.o \
IWADController.o \
IWADLocation.o \
LauncherManager.o \
main.o

View file

@ -16,7 +16,6 @@
#include <string.h>
#include <AppKit/AppKit.h>
#include "IWADController.h"
#include "IWADLocation.h"
typedef enum
{
@ -58,7 +57,7 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
@implementation IWADController
- (void) getIWADList: (IWADLocation **) iwadList
- (void) getIWADList: (NSPathControl **) iwadList
{
iwadList[IWAD_DOOM1] = self->doom1;
iwadList[IWAD_DOOM2] = self->doom2;
@ -90,7 +89,7 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
- (NSString *) getIWADLocation
{
IWAD selectedIWAD;
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
selectedIWAD = [self getSelectedIWAD];
@ -102,7 +101,7 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
{
[self getIWADList: iwadList];
return [iwadList[selectedIWAD] getLocation];
return [[iwadList[selectedIWAD] URL] path];
}
}
@ -133,7 +132,7 @@ static const char *NameForIWAD(IWAD iwad)
- (void) setIWADConfig
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
NSUserDefaults *defaults;
NSString *key;
NSString *value;
@ -152,7 +151,7 @@ static const char *NameForIWAD(IWAD iwad)
if (value != nil)
{
[iwadList[i] setLocation:value];
[iwadList[i] setURL: [NSURL fileURLWithPath: value]];
}
}
}
@ -190,7 +189,7 @@ static const char *NameForIWAD(IWAD iwad)
- (BOOL) setDropdownList
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
BOOL have_wads;
id location;
unsigned int i;
@ -205,7 +204,7 @@ static const char *NameForIWAD(IWAD iwad)
for (i=0; i<NUM_IWAD_TYPES; ++i)
{
location = [iwadList[i] getLocation];
location = [[iwadList[i] URL] path];
if (location != nil && [location length] > 0)
{
@ -229,7 +228,7 @@ static const char *NameForIWAD(IWAD iwad)
- (void) saveConfig
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
IWAD selectedIWAD;
NSUserDefaults *defaults;
NSString *key;
@ -245,7 +244,7 @@ static const char *NameForIWAD(IWAD iwad)
for (i=0; i<NUM_IWAD_TYPES; ++i)
{
key = IWADFilenames[i];
value = [iwadList[i] getLocation];
value = [[iwadList[i] URL] path];
[defaults setObject:value forKey:key];
}
@ -298,7 +297,7 @@ static const char *NameForIWAD(IWAD iwad)
- (char *) doomWadPath
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
NSString *location;
unsigned int i;
BOOL first;
@ -313,7 +312,7 @@ static const char *NameForIWAD(IWAD iwad)
for (i=0; i<NUM_IWAD_TYPES; ++i)
{
location = [iwadList[i] getLocation];
location = [[iwadList[i] URL] path];
if (location != nil && [location length] > 0)
{
@ -330,7 +329,7 @@ static const char *NameForIWAD(IWAD iwad)
for (i=0; i<NUM_IWAD_TYPES; ++i)
{
location = [iwadList[i] getLocation];
location = [[iwadList[i] URL] path];
if (location != nil && [location length] > 0)
{
@ -375,7 +374,7 @@ static const char *NameForIWAD(IWAD iwad)
- (BOOL) addIWADPath: (NSString *) path
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
NSArray *pathComponents;
NSString *filename;
unsigned int i;
@ -394,7 +393,7 @@ static const char *NameForIWAD(IWAD iwad)
{
// Configure this IWAD.
[iwadList[i] setLocation: path];
[iwadList[i] setURL: [NSURL fileURLWithPath: path]];
// Rebuild dropdown list and select the new IWAD.
@ -411,7 +410,7 @@ static const char *NameForIWAD(IWAD iwad)
- (BOOL) selectGameByName: (const char *) name
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSPathControl *iwadList[NUM_IWAD_TYPES];
NSString *location;
const char *name2;
int i;
@ -429,7 +428,7 @@ static const char *NameForIWAD(IWAD iwad)
for (i = 0; i < NUM_IWAD_TYPES; ++i)
{
location = [iwadList[i] getLocation];
location = [[iwadList[i] URL] path];
name2 = NameForIWAD(i);
if (!strcmp(name, name2)

View file

@ -1,36 +0,0 @@
//
// Copyright(C) 2005-2014 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.
//
#ifndef LAUNCHER_IWADLOCATION_H
#define LAUNCHER_IWADLOCATION_H
#include <AppKit/AppKit.h>
#include "IWADController.h"
@interface IWADLocation : NSObject
{
IWADController *iwadController;
id locationConfigBox;
}
- (void) setButtonClicked: (id)sender;
- (NSString *) getLocation;
- (void) setLocation: (NSString *) value;
@end
#endif /* #ifndef LAUNCHER_IWADLOCATION_H */

View file

@ -1,66 +0,0 @@
//
// Copyright(C) 2005-2014 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.
//
#include <AppKit/AppKit.h>
#include "IWADLocation.h"
static id WAD_TYPES[] =
{
@"wad", @"WAD"
};
@implementation IWADLocation
- (void) setButtonClicked: (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 setLocation: [filenames lastObject]];
[self->iwadController saveConfig];
[self->iwadController setDropdownList];
}
}
- (NSString *) getLocation
{
return [self->locationConfigBox stringValue];
}
- (void) setLocation: (NSString *) filename
{
[self->locationConfigBox setStringValue: filename];
}
@end

File diff suppressed because it is too large Load diff

Binary file not shown.