Forge updates. Preferences seems to be debugged now.

This commit is contained in:
Jeff Teunissen 2001-11-11 20:54:59 +00:00
parent fe50e4b1e5
commit 316004e793
8 changed files with 252 additions and 226 deletions

View file

@ -11,4 +11,7 @@ config.log
config.status
configure
configure-stamp
shared_debug_obj
shared_obj
shared_profile_debug_obj
shared_profile_obj

View file

@ -1,20 +1,35 @@
/*
Controller.m
Central controller object for Edit...
Controller class for Forge
Copyright (c) 1995-1996, NeXT Software, Inc.
All rights reserved.
Author: Ali Ozer
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
You may freely copy, distribute and reuse the code in this example.
NeXT disclaims any warranty of any kind, expressed or implied,
as to its fitness for any particular use.
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:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
$Id$
*/
#import <AppKit/NSApplication.h>
#import <AppKit/NSMenu.h>
#import "Controller.h"
#import "Preferences.h"
@implementation Controller
@ -81,7 +96,6 @@
NSLog (@"This _would_ save, but it doesn't.");
}
/*
Notifications
*/
@ -112,31 +126,31 @@
NSMenu *windows;
NSMenu *services;
[menu addItemWithTitle: @"Info" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Project" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"File" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Edit" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"BSP" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Brush" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Windows" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Services" action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Info") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Project") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"File") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Edit") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"BSP") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Brush") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Windows") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: _(@"Services") action: NULL keyEquivalent: @""];
[menu addItemWithTitle: @"Hide" action: @selector(hide:) keyEquivalent: @"h"];
[menu addItemWithTitle: @"Quit" action: @selector(terminate:) keyEquivalent: @"q"];
[menu addItemWithTitle: _(@"Hide") action: @selector(hide:) keyEquivalent: @"h"];
[menu addItemWithTitle: _(@"Quit") action: @selector(terminate:) keyEquivalent: @"q"];
/*
Info
*/
info = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: info forItem: [menu itemWithTitle: @"Info"]];
[menu setSubmenu: info forItem: [menu itemWithTitle: _(@"Info")]];
[info addItemWithTitle: @"Info Panel..."
[info addItemWithTitle: _(@"Info Panel...")
action: @selector (orderFrontStandardAboutPanel:)
keyEquivalent: @""];
[info addItemWithTitle: @"Preferences..."
[info addItemWithTitle: _(@"Preferences...")
action: @selector (orderFrontPreferencesPanel:)
keyEquivalent: @""];
[info addItemWithTitle: @"Help"
[info addItemWithTitle: _(@"Help")
action: @selector (orderFrontHelpPanel:)
keyEquivalent: @"?"];
@ -144,21 +158,21 @@
Project
*/
project = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: project forItem: [menu itemWithTitle: @"Project"]];
[menu setSubmenu: project forItem: [menu itemWithTitle: _(@"Project")]];
[project addItemWithTitle: @"Open..."
[project addItemWithTitle: _(@"Open...")
action: @selector (openProject:)
keyEquivalent: @"@o"];
[project addItemWithTitle: @"New"
keyEquivalent: @"~o"];
[project addItemWithTitle: _(@"New")
action: @selector (createNewProject:)
keyEquivalent: @"@n"];
[project addItemWithTitle: @"Save..."
keyEquivalent: @"~n"];
[project addItemWithTitle: _(@"Save...")
action: @selector (saveProject:)
keyEquivalent: @"@s"];
[project addItemWithTitle: @"Save As..."
keyEquivalent: @"~s"];
[project addItemWithTitle: _(@"Save As...")
action: @selector (saveProjectAs:)
keyEquivalent: @"@S"];
[project addItemWithTitle: @"Close"
keyEquivalent: @"~S"];
[project addItemWithTitle: _(@"Close")
action: @selector (closeProject:)
keyEquivalent: @""];
@ -166,27 +180,27 @@
File
*/
file = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: file forItem: [menu itemWithTitle: @"File"]];
[menu setSubmenu: file forItem: [menu itemWithTitle: _(@"File")]];
[file addItemWithTitle: @"Open..."
[file addItemWithTitle: _(@"Open...")
action: @selector (open:)
keyEquivalent: @"o"];
[file addItemWithTitle: @"New"
[file addItemWithTitle: _(@"New")
action: @selector (createNew:)
keyEquivalent: @"n"];
[file addItemWithTitle: @"Save..."
[file addItemWithTitle: _(@"Save...")
action: @selector (save:)
keyEquivalent: @"s"];
[file addItemWithTitle: @"Save As..."
[file addItemWithTitle: _(@"Save As...")
action: @selector (saveAs:)
keyEquivalent: @"S"];
[file addItemWithTitle: @"Save All"
[file addItemWithTitle: _(@"Save All")
action: @selector (saveAll:)
keyEquivalent: @""];
[file addItemWithTitle: @"Revert to Saved"
[file addItemWithTitle: _(@"Revert to Saved")
action: @selector (revertToSaved:)
keyEquivalent: @""];
[file addItemWithTitle: @"Close"
[file addItemWithTitle: _(@"Close")
action: @selector (close:)
keyEquivalent: @""];
@ -194,58 +208,61 @@
Edit
*/
edit = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: edit forItem: [menu itemWithTitle: @"Edit"]];
[menu setSubmenu: edit forItem: [menu itemWithTitle: _(@"Edit")]];
[edit addItemWithTitle: @"Undo"
[edit addItemWithTitle: _(@"Undo")
action: @selector (undo:)
keyEquivalent: @"z"];
[edit addItemWithTitle: @"Redo"
[edit addItemWithTitle: _(@"Redo")
action: @selector (redo:)
keyEquivalent: @"Z"];
[edit addItemWithTitle: @"Cut"
[edit addItemWithTitle: _(@"Cut")
action: @selector (cut:)
keyEquivalent: @"x"];
[edit addItemWithTitle: @"Copy"
[edit addItemWithTitle: _(@"Copy")
action: @selector (copy:)
keyEquivalent: @"c"];
[edit addItemWithTitle: @"Paste"
[edit addItemWithTitle: _(@"Paste")
action: @selector (paste:)
keyEquivalent: @"v"];
[edit addItemWithTitle: _(@"Delete")
action: @selector (delete:)
keyEquivalent: @""];
[edit addItemWithTitle: _(@"Select All")
action: @selector (selectAll:)
keyEquivalent: @"a"];
/*
BSP
*/
bsp = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: bsp forItem: [menu itemWithTitle: @"BSP"]];
[menu setSubmenu: bsp forItem: [menu itemWithTitle: _(@"BSP")]];
[bsp addItemWithTitle: @"dunno"
action: @selector (undo:)
keyEquivalent: @"z"];
[bsp addItemWithTitle: _(@"None") action: @selector(nothing:) keyEquivalent: @""];
/*
Brush
*/
brush = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: brush forItem: [menu itemWithTitle: @"Brush"]];
[menu setSubmenu: brush forItem: [menu itemWithTitle: _(@"Brush")]];
[brush addItemWithTitle: @"dunno"
action: @selector (undo:)
keyEquivalent: @"z"];
[brush addItemWithTitle: _(@"none") action: @selector(nothing:) keyEquivalent: @""];
/*
Windows
*/
windows = [[[NSMenu alloc] init] autorelease];
[menu setSubmenu: windows forItem: [menu itemWithTitle: @"Windows"]];
[NSApp setWindowsMenu: windows];
[menu setSubmenu: windows forItem: [menu itemWithTitle: _(@"Windows")]];
/*
Services
*/
services = [[[NSMenu alloc] init] autorelease];
[NSApp setServicesMenu: services];
[menu setSubmenu: services forItem: [menu itemWithTitle: @"Services"]];
[menu setSubmenu: services forItem: [menu itemWithTitle: _(@"Services")]];
[NSApp setMainMenu: menu];
}
@ -253,7 +270,7 @@
/*
applicationWillTerminate:
Sort of like SIGQUIT. App should die now, but has a chance to clean up
Sort of like SIGQUIT. App is about to die, but has a chance to clean up
*/
- (void) applicationWillTerminate: (NSNotification *) not;
{

View file

@ -11,6 +11,17 @@
);
Super = NSObject;
};
IBInspector = {
Actions = (
ok:,
revert:,
touch:
);
Outlets = (
window
);
Super = NSObject;
};
NSApplication = {
Outlets = (
delegate
@ -73,15 +84,15 @@
revert:
);
Outlets = (
bspSoundPathField,
offsetBrushCopyButton,
projectPathField,
showBSPOutputButton,
startWadField,
xLightField,
yLightField,
zLightField
bspSoundPath,
offsetBrushCopy,
projectPath,
showBSPOutput,
startWad,
xLight,
yLight,
zLight
);
Super = NSObject;
};
}
}

Binary file not shown.

View file

@ -53,6 +53,9 @@ Forge_RESOURCE_FILES= \
Forge.tiff \
ForgeInfo.plist
Forge_LOCALIZED_RESOURCE_FILES= \
Localizable.strings
# Languages we're localized for
Forge_LANGUAGES= \
English

View file

@ -47,24 +47,21 @@
@interface Preferences: NSObject
{
// UI targets
id projectPathField; // path to the project to load on startup
id bspSoundPathField; // location of BSP sounds
id startWadField; // which wadfile to load on startup
id xLightField; // Lighting for X side
id yLightField; // Lighting for Y side
id zLightField; // Lighting for Z side
id showBSPOutputButton; // "Show BSP Output" checkbox
id offsetBrushCopyButton; // "Brush offset" checkbox
NSDictionary *currentValues;
NSMutableDictionary *displayedValues;
NSString *projectPath; // path to the project to load on startup
NSString *bspSoundPath; // location of BSP sounds
NSString *startWad; // which wadfile to load on startup
float xLight; // Lighting for X side
float yLight; // Lighting for Y side
float zLight; // Lighting for Z side
BOOL showBSPOutput; // "Show BSP Output" checkbox
BOOL offsetBrushCopy; // "Brush offset" checkbox
}
+ (void) saveDefaults;
- (void) loadDefaults;
+ (Preferences *) sharedInstance; // Return the shared instance
- (void) saveDefaults;
- (void) loadDefaults;
- (NSDictionary *) preferences; // current prefs
- (void) updateUI; // Update the displayed values in the UI
@ -81,12 +78,9 @@
- (id) objectForKey: (id) key;
//+ (void) setObject: (id) obj forKey: (id) key;
- (void) setObject: (id) obj forKey: (id) key;
+ (NSDictionary *) preferencesFromDefaults;
+ (void) savePreferencesToDefaults: (NSDictionary *) dict;
- (NSDictionary *) preferencesFromDefaults;
- (void) savePreferencesToDefaults: (NSDictionary *) dict;
@end
extern Preferences *prefs;

View file

@ -36,15 +36,15 @@
#import "Preferences.h"
id prefs;
NSMutableDictionary *
defaultValues (void) {
static NSMutableDictionary *dict = nil;
static NSDictionary *defaultValues (void) {
static NSDictionary *dict = nil;
if (!dict) {
dict = [[NSDictionary alloc] initWithObjectsAndKeys:
dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"/Local/Forge/Projects", ProjectPath,
@"/Local/Forge/Sounds", BspSoundPath,
[NSNumber numberWithInt: 0], StartWad,
@"/Local/Library/Sounds", BspSoundPath,
@"none", StartWad,
[NSNumber numberWithFloat: 1.0], XLight,
[NSNumber numberWithFloat: 0.6], YLight,
[NSNumber numberWithFloat: 0.75], ZLight,
@ -55,25 +55,95 @@ static NSDictionary *defaultValues (void) {
return dict;
}
/***
Code to deal with defaults
***/
BOOL
getBoolDefault (NSMutableDictionary *dict, NSString *name)
{
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey: name];
NSNumber *num;
if (!str)
str = [[defaultValues() objectForKey: name] stringValue];
num = [NSNumber numberWithBool: [str hasPrefix: @"Y"]];
[dict setObject: num forKey: name];
return [num boolValue];
}
float
getFloatDefault (NSMutableDictionary *dict, NSString *name)
{
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey: name];
NSNumber *num;
if (!str)
str = [[defaultValues() objectForKey: name] stringValue];
num = [NSNumber numberWithFloat: [str floatValue]];
[dict setObject: num forKey: name];
return [num floatValue];
}
int
getIntDefault (NSMutableDictionary *dict, NSString *name)
{
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey: name];
NSNumber *num;
if (!str)
str = [[defaultValues() objectForKey: name] stringValue];
num = [NSNumber numberWithInt: [str intValue]];
[dict setObject: num forKey: name];
return [num intValue];
}
NSString *
getStringDefault (NSMutableDictionary *dict, NSString *name)
{
NSString *str = [[NSUserDefaults standardUserDefaults] stringForKey: name];
if (!str)
str = [defaultValues() objectForKey: name];
[dict setObject: str forKey: name];
return str;
}
@implementation Preferences
static Preferences *sharedInstance = nil;
static Preferences *sharedInstance = nil;
static NSDictionary *currentValues = nil;
static NSMutableDictionary *displayedValues = nil;
- (id) objectForKey: (id) key
{
return [[[[self class] sharedInstance] preferences] objectForKey: key];
id obj = [[NSUserDefaults standardUserDefaults] objectForKey: key];
if (!obj)
return [defaultValues () objectForKey: key];
else
return obj;
}
+ (void) saveDefaults
- (void) setObject: (id) obj forKey: (id) key
{
if (sharedInstance) {
[self savePreferencesToDefaults: [sharedInstance preferences]];
}
if ((!key) || (!obj))
return;
[displayedValues setObject: obj forKey: key];
[self commitDisplayedValues];
}
- (void) saveDefaults: (id) sender
- (void) saveDefaults
{
[[self class] saveDefaults];
[self savePreferencesToDefaults: currentValues];
}
- (void) loadDefaults
@ -81,7 +151,7 @@ static Preferences *sharedInstance = nil;
if (currentValues)
[currentValues release];
currentValues = [[[self class] preferencesFromDefaults] copyWithZone: [self zone]];
currentValues = [[self preferencesFromDefaults] copyWithZone: [self zone]];
[self discardDisplayedValues];
}
@ -96,16 +166,16 @@ static Preferences *sharedInstance = nil;
[self dealloc];
} else {
[super init];
currentValues = [[[self class] preferencesFromDefaults] copyWithZone:[self zone]];
currentValues = [[self preferencesFromDefaults] mutableCopy];
[self discardDisplayedValues];
sharedInstance = self;
prefs = sharedInstance;
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(saveDefaults:)
selector: @selector(saveDefaults)
name: @"NSApplicationWillTerminateNotification"
object: nil];
}
[self prefsChanged: self];
return sharedInstance;
}
@ -130,87 +200,54 @@ static Preferences *sharedInstance = nil;
*/
- (void) updateUI
{
id theCenter = [NSNotificationCenter defaultCenter];
NSLog (@"Defaults updated, UI should update.");
[theCenter postNotificationName: @"ForgeTextureCacheShouldFlush" object: self userInfo: nil];
[theCenter postNotificationName: @"ForgeUIShouldUpdate" object: self userInfo: nil];
return;
}
- (void) prefsChanged: (id) sender {
static NSNumber *yes = nil;
static NSNumber *no = nil;
int anInt;
- (void) prefsChanged: (id) sender
{
float aFloat;
if (!yes) {
yes = [[NSNumber alloc] initWithBool: YES];
no = [[NSNumber alloc] initWithBool: NO];
[displayedValues setObject: projectPath forKey: ProjectPath];
[displayedValues setObject: bspSoundPath forKey: BspSoundPath];
[displayedValues setObject: startWad forKey: StartWad];
if ((aFloat = [[displayedValues objectForKey: XLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: XLight] floatValue];
}
xLight = aFloat;
[displayedValues setObject: [NSNumber numberWithFloat: xLight] forKey: XLight];
[displayedValues setObject: [projectPathField stringValue] forKey: ProjectPath];
[displayedValues setObject: [bspSoundPathField stringValue] forKey: BspSoundPath];
if ((anInt = [startWadField intValue]) < 0 || anInt > 2) {
if ((anInt = [[displayedValues objectForKey: StartWad] intValue]) < 0 || anInt > 2) {
anInt = [[defaultValues () objectForKey: StartWad] intValue];
}
[startWadField setIntValue: anInt];
} else {
[displayedValues setObject: [NSNumber numberWithInt: anInt] forKey: StartWad];
if ((aFloat = [[displayedValues objectForKey: YLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: YLight] floatValue];
}
yLight = aFloat;
[displayedValues setObject: [NSNumber numberWithFloat: yLight] forKey: YLight];
if ((aFloat = [xLightField floatValue]) < 0.0 || aFloat > 1.0) {
if ((aFloat = [[displayedValues objectForKey: XLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: XLight] floatValue];
}
[xLightField setFloatValue: aFloat];
} else {
[displayedValues setObject: [NSNumber numberWithFloat: aFloat] forKey: XLight];
if ((aFloat = [[displayedValues objectForKey: ZLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: ZLight] floatValue];
}
zLight = aFloat;
[displayedValues setObject: [NSNumber numberWithFloat: zLight] forKey: ZLight];
if ((aFloat = [yLightField floatValue]) < 0.0 || aFloat > 1.0) {
if ((aFloat = [[displayedValues objectForKey: YLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: YLight] floatValue];
}
[yLightField setFloatValue: aFloat];
} else {
[displayedValues setObject: [NSNumber numberWithFloat: aFloat] forKey: YLight];
}
if ((aFloat = [zLightField floatValue]) < 0.0 || aFloat > 1.0) {
if ((aFloat = [[displayedValues objectForKey: YLight] floatValue]) < 0.0 || aFloat > 1.0) {
aFloat = [[defaultValues () objectForKey: YLight] floatValue];
}
[zLightField setFloatValue: aFloat];
} else {
[displayedValues setObject: [NSNumber numberWithFloat: aFloat] forKey: ZLight];
}
[displayedValues setObject: ([showBSPOutputButton state] ? yes : no) forKey: ShowBSPOutput];
[displayedValues setObject: ([offsetBrushCopyButton state] ? yes : no) forKey: OffsetBrushCopy];
[displayedValues setObject: [NSNumber numberWithBool: showBSPOutput] forKey: ShowBSPOutput];
[displayedValues setObject: [NSNumber numberWithBool: offsetBrushCopy] forKey: OffsetBrushCopy];
[self commitDisplayedValues];
}
- (void) commitDisplayedValues
{
if (currentValues != displayedValues) {
[currentValues release];
currentValues = [displayedValues copyWithZone: [self zone]];
}
[currentValues release];
currentValues = [[displayedValues copy] retain];
[self saveDefaults];
[self updateUI];
}
- (void) discardDisplayedValues
{
if (currentValues != displayedValues) {
[displayedValues release];
displayedValues = [currentValues mutableCopyWithZone: [self zone]];
[self updateUI];
}
[displayedValues release];
displayedValues = [[currentValues mutableCopy] retain];
[self updateUI];
}
- (void) ok: (id) sender
@ -228,101 +265,61 @@ static Preferences *sharedInstance = nil;
if (currentValues)
[currentValues release];
currentValues = [defaultValues () copyWithZone: [self zone]];
[currentValues retain];
currentValues = defaultValues ();
[self discardDisplayedValues];
}
/***
Code to deal with defaults
***/
#define getBoolDefault(name) \
{ \
NSString *str = [defaults stringForKey: name]; \
[dict setObject: (str ? [NSNumber numberWithBool: [str hasPrefix: @"Y"]] : [defaultValues() objectForKey: name]) forKey: name]; \
}
#define getFloatDefault(name) \
{ \
NSString *str = [defaults stringForKey: name]; \
[dict setObject: (str ? [NSNumber numberWithFloat: [str floatValue]] : [defaultValues() objectForKey: name]) forKey: name]; \
}
#define getIntDefault(name) \
{ \
NSString *str = [defaults stringForKey: name]; \
[dict setObject: (str ? [NSNumber numberWithInt: [str intValue]] : [defaultValues() objectForKey: name]) forKey: name]; \
}
#define getStringDefault(name) \
{ \
NSString *str = [defaults stringForKey: name]; \
[dict setObject: (str ? str : [defaultValues() objectForKey: name]) forKey: name]; \
}
+ (NSDictionary *) preferencesFromDefaults
- (NSDictionary *) preferencesFromDefaults
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity: 10];
getStringDefault(ProjectPath);
getStringDefault(BspSoundPath);
getIntDefault(StartWad);
getFloatDefault(XLight);
getFloatDefault(YLight);
getFloatDefault(ZLight);
getBoolDefault(ShowBSPOutput);
getBoolDefault(OffsetBrushCopy);
projectPath = getStringDefault (dict, ProjectPath);
bspSoundPath = getStringDefault (dict, BspSoundPath);
startWad = getStringDefault (dict, StartWad);
xLight = getFloatDefault (dict, XLight);
yLight = getFloatDefault (dict, YLight);
zLight = getFloatDefault (dict, ZLight);
showBSPOutput = getBoolDefault (dict, ShowBSPOutput);
offsetBrushCopy = getBoolDefault (dict, OffsetBrushCopy);
return dict;
}
#define setBoolDefault(name) \
{ \
if ([[defaultValues() objectForKey: name] isEqual: [dict objectForKey: name]]) \
[defaults removeObjectForKey: name]; \
else \
[defaults setBool:[[dict objectForKey:name] boolValue] forKey: name]; \
[defaults setBool:[[dict objectForKey:name] boolValue] forKey: name]; \
}
#define setFloatDefault(name) \
{ \
if ([[defaultValues() objectForKey: name] isEqual: [dict objectForKey: name]]) \
[defaults removeObjectForKey: name]; \
else \
[defaults setFloat:[[dict objectForKey:name] floatValue] forKey: name]; \
[defaults setFloat:[[dict objectForKey:name] floatValue] forKey: name]; \
}
#define setIntDefault(name) \
{ \
if ([[defaultValues() objectForKey:name] isEqual:[dict objectForKey:name]]) \
[defaults removeObjectForKey:name]; \
else \
[defaults setInteger:[[dict objectForKey:name] intValue] forKey:name]; \
[defaults setInteger:[[dict objectForKey:name] intValue] forKey:name]; \
}
#define setStringDefault(name) \
{ \
if ([[defaultValues() objectForKey:name] isEqual: [dict objectForKey: name]]) \
[defaults removeObjectForKey: name]; \
else \
[defaults setObject: [[dict objectForKey: name] stringValue] forKey: name]; \
[defaults setObject: [dict objectForKey: name] forKey: name]; \
}
+ (void) savePreferencesToDefaults: (NSDictionary *) dict
- (void) savePreferencesToDefaults: (NSDictionary *) dict
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog (@"Updating defaults...");
setStringDefault(ProjectPath);
setStringDefault(BspSoundPath);
setIntDefault(StartWad);
setStringDefault(StartWad);
setFloatDefault(XLight);
setFloatDefault(YLight);
setFloatDefault(ZLight);
setBoolDefault(ShowBSPOutput);
setBoolDefault(OffsetBrushCopy);
[defaults synchronize];
}
@end

View file

@ -1,6 +1,7 @@
#import <AppKit/NSApplication.h>
#import "Controller.h"
#define APP_NAME @"GNUstep"
#define APP_NAME @"Forge"
int main(int argc, const char *argv[], const char *env[])
{