diff --git a/tools/Forge/Controller.h b/tools/Forge/Controller.h new file mode 100644 index 000000000..04537d8fb --- /dev/null +++ b/tools/Forge/Controller.h @@ -0,0 +1,29 @@ +#import + +@interface Controller: NSObject +{ +@public +} + +// App delegate methods +- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename; +- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename; +- (BOOL) applicationOpenUntitledFile: (NSApplication *) app; +- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app; +- (BOOL) applicationShouldTerminate: (NSApplication *) app; +- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app; + +// Notifications +- (void) applicationDidFinishLaunching: (NSNotification *) not; +- (void) applicationWillFinishLaunching: (NSNotification *) not; +- (void) applicationWillTerminate: (NSNotification *) not; + +// Action methods +- (void) createNew: (id) sender; +- (void) createNewProject: (id) sender; +- (void) infoPanel: (id) sender; +- (void) open: (id) sender; +- (void) openProject: (id) sender; +- (void) saveAll: (id) sender; + +@end diff --git a/tools/Forge/Controller.m b/tools/Forge/Controller.m new file mode 100644 index 000000000..18e2eb5ea --- /dev/null +++ b/tools/Forge/Controller.m @@ -0,0 +1,167 @@ +/* + Controller.m + + Central controller object for Edit... + + Copyright (c) 1995-1996, NeXT Software, Inc. + All rights reserved. + Author: Ali Ozer + + 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. +*/ + +#import +#import "Controller.h" +#import "Preferences.h" + +@implementation Controller + +- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename; +{ + return NO; +} + +- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename; +{ + return NO; +} + +- (BOOL) applicationOpenUntitledFile: (NSApplication *) app; +{ + return NO; +} + +- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app; +{ + return NO; +} + +- (BOOL) applicationShouldTerminate: (NSApplication *) app; +{ + return YES; +} + +- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *) app; +{ + return YES; +} + +/* + Action methods +*/ +- (void) createNew: (id) sender; +{ + NSLog (@"This _would_ create a new file, but it doesn't."); +} + +- (void) createNewProject: (id) sender; +{ + NSLog (@"This _would_ create a new project, but it doesn't."); +} + +- (void) infoPanel: (id) sender; +{ + [NSApp orderFrontStandardAboutPanel: self]; +} + +- (void) open: (id) sender; +{ + NSLog (@"This _would_ open a file, but it doesn't."); +} + +- (void) openProject: (id) sender; +{ + NSLog (@"This _would_ open a project, but it doesn't."); +} + +- (void) saveAll: (id) sender; +{ + NSLog (@"This _would_ save, but it doesn't."); +} + + +/* + Notifications +*/ + +- (void) applicationDidFinishLaunching: (NSNotification *) not; +{ +} + +- (void) applicationWillFinishLaunching: (NSNotification *) not; +{ + NSMenu *menu = [[[NSMenu alloc] init] autorelease]; + NSMenu *info; + NSMenu *project; + NSMenu *edit; + NSMenu *bsp; + NSMenu *brush; + NSMenu *windows; + NSMenu *services; + + [menu addItemWithTitle: @"Info" action: NULL keyEquivalent: @""]; + [menu addItemWithTitle: @"Project" 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"]; + + /* + Info + */ + info = [[[NSMenu alloc] init] autorelease]; + [menu setSubmenu: info forItem: [menu itemWithTitle: @"Info"]]; + + [info addItemWithTitle: @"Info Panel..." + action: @selector (orderFrontStandardAboutPanel:) + keyEquivalent: @""]; + [info addItemWithTitle: @"Preferences..." + action: @selector (orderFrontPreferencesPanel:) + keyEquivalent: @""]; + [info addItemWithTitle: @"Help" + action: @selector (openFrontHelpPanel:) + keyEquivalent: @"?"]; + + /* + Project + */ + project = [[[NSMenu alloc] init] autorelease]; + [menu setSubmenu: project forItem: [menu itemWithTitle: @"Project"]]; + + [project addItemWithTitle: @"Open" + action: @selector (open:) + keyEquivalent: @"o"]; + [project addItemWithTitle: @"Close" + action: @selector (closeProject:) + keyEquivalent: @""]; + + /* + Windows + */ + windows = [[[NSMenu alloc] init] autorelease]; + + [menu setSubmenu: windows forItem: [menu itemWithTitle: @"Windows"]]; + + [NSApp setWindowsMenu: windows]; + + /* + Services + */ + services = [[[NSMenu alloc] init] autorelease]; + + [menu setSubmenu: services forItem: [menu itemWithTitle: @"Services"]]; + + [NSApp setServicesMenu: services]; + + [NSApp setMainMenu: menu]; +} + +- (void) applicationWillTerminate: (NSNotification *) not; +{ +} diff --git a/tools/Forge/Forge.classes b/tools/Forge/Forge.classes new file mode 100644 index 000000000..c27961eed --- /dev/null +++ b/tools/Forge/Forge.classes @@ -0,0 +1,140 @@ +{ + CameraView = { + Actions = ( + ); + Outlets = ( + ); + Super = NSView; + }; + Controller = { + Actions = ( + createNew:, + createNewProject:, + open:, + openProject:, + saveAll: + ); + Outlets = ( + ); + Super = NSObject; + }; + Forge = { + Actions = ( + ); + Outlets = ( + brushCount, + cmdInput, + cmdOutput, + entityCount, + filterClip, + filterEntities, + filterLights, + filterPaths, + filterWater, + filterWorld, + showCoords, + showNames, + xyDrawMode + ); + Super = NSWindow; + }; + NSApplication = { + Outlets = ( + delegate + ); + Super = NSResponder; + }; + NSButton = { + Super = NSControl; + }; + NSControl = { + Actions = ( + takeDoubleValueFrom:, + takeFloatValueFrom:, + takeIntValueFrom:, + takeObjectValueFrom:, + takeStringValueFrom: + ); + Outlets = ( + target + ); + Super = NSView; + }; + NSMenu = { + Super = NSObject; + }; + NSMenuItem = { + Outlets = ( + target + ); + Super = NSObject; + }; + NSPanel = { + Super = NSWindow; + }; + NSResponder = { + Super = NSObject; + }; + NSSlider = { + Super = NSControl; + }; + NSTextField = { + Outlets = ( + delegate + ); + Super = NSControl; + }; + NSView = { + Super = NSResponder; + }; + NSWindow = { + Outlets = ( + delegate + ); + Super = NSResponder; + }; + Preferences = { + Actions = ( + commitDisplayedValues:, + discardDisplayedValues:, + loadDefaults:, + objectForKey:key:, + ok:sender:, + preferences:, + prefsChanged:sender:, + revert:sender:, + revertToDefault:sender:, + saveDefaults:, + sharedInstance:, + updateUI: + ); + Outlets = ( + bspSoundPathField, + offsetBrushCopyButton, + projectPathField, + showBSPOutputButton, + startWadField, + xLightField, + yLightField, + zLightField + ); + Super = NSObject; + }; + XYView = { + Actions = ( + autoresizingMask, + setAutoresizingMask: + ); + Outlets = ( + target + ); + Super = NSView; + }; + ZView = { + Actions = ( + ); + Outlets = ( + ); + Super = NSView; + }; +} \ No newline at end of file diff --git a/tools/Forge/Forge.gorm b/tools/Forge/Forge.gorm new file mode 100644 index 000000000..6583ecc19 Binary files /dev/null and b/tools/Forge/Forge.gorm differ diff --git a/tools/Forge/Forge.tiff b/tools/Forge/Forge.tiff new file mode 100644 index 000000000..f7b1c4e84 Binary files /dev/null and b/tools/Forge/Forge.tiff differ diff --git a/tools/Forge/ForgeInfo.plist b/tools/Forge/ForgeInfo.plist index 97ef3bf40..9b3456f60 100644 --- a/tools/Forge/ForgeInfo.plist +++ b/tools/Forge/ForgeInfo.plist @@ -1,12 +1,11 @@ { ApplicationDescription = "A map editor for QuakeForge"; - ApplicationIcon = "Images/Forge.tiff"; + ApplicationIcon = "Forge.tiff"; ApplicationName = Forge; - ApplicationRelease = 0.1; - Authors = "Jeff Teunissen and Bill Currie"; - Copyright = "Copyright (C) 2001 Jeff Teunissen , Bill Currie "; - CopyrightDescription = "Released under the GNU General Public License"; - FullVersionID = 0.1; - NOTE = "Automatically generated!"; - URL = ""; + ApplicationRelease = "0.1.0 (Development)"; + Authors = ("Jeff Teunissen ", "Bill Currie "); + Copyright = "Copyright (C) 2002 Dusk To Dawn Computing"; + CopyrightDescription = "This program is released under the GNU General Public License"; + FullVersionID = "0.1.0 (Development)"; + URL = "http://www.quakeforge.net/Forge/"; } diff --git a/tools/Forge/GNUmakefile b/tools/Forge/GNUmakefile index 608d7ce4c..3666e4746 100644 --- a/tools/Forge/GNUmakefile +++ b/tools/Forge/GNUmakefile @@ -34,6 +34,7 @@ include $(GNUSTEP_MAKEFILES)/common.make # # Main application # +PACKAGE_NAME= Forge APP_NAME= Forge Forge_PRINCIPAL_CLASS= Forge Forge_APPLICATION_ICON= Forge.tiff @@ -46,90 +47,34 @@ ADDITIONAL_GUI_LIBS += # # Resource files # +Forge_RESOURCE_FILES= \ + ForgeInfo.plist \ + Forge.tiff +# Forge.gorm \ # Languages we're localized for Forge_LANGUAGES= \ English -# We don't have a proper .gorm file yet, but we will -Forge_LOCALIZED_RESOURCE_FILES= \ - Forge.gorm - -Forge_RESOURCE_FILES= \ - ForgeInfo.plist \ - Images/DownArrow.tiff \ - Images/i_90d.tiff \ - Images/i_add.tiff \ - Images/i_brushes.tiff \ - Images/i_fliph.tiff \ - Images/i_flipv.tiff \ - Images/i_sub.tiff \ - Images/short.tiff \ - Images/tall.tiff \ - Images/UpArrow.tiff - # # Header files # Forge_HEADERS= \ - Headers/CameraView.h \ - Headers/Clipper.h \ - Headers/Entity.h \ - Headers/EntityArray.h \ - Headers/EntityClass.h \ - Headers/Forge.h \ - Headers/InspectorControl.h \ - Headers/KeypairView.h \ - Headers/Map.h \ - Headers/PopScrollView.h \ - Headers/Preferences.h \ - Headers/Project.h \ - Headers/SetBrush.h \ - Headers/TexturePalette.h \ - Headers/TextureView.h \ - Headers/Things.h \ - Headers/UserPath.h \ - Headers/XYView.h \ - Headers/ZScrollView.h \ - Headers/ZView.h \ - Headers/cmdlib.h \ - Headers/mathlib.h \ - Headers/qedefs.h \ - Headers/render.h + Controller.h \ + Preferences.h # # Class files # Forge_OBJC_FILES= \ - Clipper.m \ - Forge_main.m \ + Controller.m \ Preferences.m \ - Project.m \ - Forge.m \ - Map.m \ - Things.m \ - misc.m \ - Entity.m \ - EntityArray.m \ - EntityClass.m \ - CameraView.m \ - XYView.m \ - KeypairView.m \ - InspectorControl.m \ - PopScrollView.m \ - TexturePalette.m \ - TextureView.m \ - ZScrollView.m \ - ZView.m \ - render.m -# SetBrush.m \ -# UserPath.m \ + main.m # # C files # -Forge_C_FILES= \ - cmdlib.c +Forge_C_FILES= -include GNUmakefile.preamble -include GNUmakefile.local diff --git a/tools/Forge/Preferences.h b/tools/Forge/Preferences.h new file mode 100644 index 000000000..afccb9a1c --- /dev/null +++ b/tools/Forge/Preferences.h @@ -0,0 +1,92 @@ +/* + Preferences.h + + Preferences class definition for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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$ +*/ +#ifdef HAVE_CONFIG_H +# include "Config.h" +#endif + +#import +#import + +/* + Keys in the dictionary +*/ +#define ProjectPath @"projectPath" +#define BspSoundPath @"bspSoundPath" +#define ShowBSPOutput @"showBSPOutput" +#define OffsetBrushCopy @"offsetBrushCopy" +#define StartWad @"startWad" +#define XLight @"xLight" +#define YLight @"yLight" +#define ZLight @"zLight" + +@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; +} + ++ (void) saveDefaults; +- (void) loadDefaults; + ++ (Preferences *) sharedInstance; // Return the shared instance + +- (NSDictionary *) preferences; // current prefs + +- (void) updateUI; // Update the displayed values in the UI +- (void) commitDisplayedValues; // Make displayed settings current +- (void) discardDisplayedValues; // Replace displayed settings with current + +// UI notifications +- (void) ok: (id) sender; // commit displayed values +- (void) revert: (id) sender; // revert to current values +- (void) revertToDefault: (id) sender; // revert current values to defaults and + // discard displayed values + +- (void) prefsChanged: (id) sender; // Notify the object to update the UI + + +- (id) objectForKey: (id) key; +//+ (void) setObject: (id) obj forKey: (id) key; + + ++ (NSDictionary *) preferencesFromDefaults; ++ (void) savePreferencesToDefaults: (NSDictionary *) dict; + +@end + +extern Preferences *prefs; diff --git a/tools/Forge/Preferences.m b/tools/Forge/Preferences.m new file mode 100644 index 000000000..eb958503f --- /dev/null +++ b/tools/Forge/Preferences.m @@ -0,0 +1,328 @@ +/* + Preferences.m + + Preferences class for Forge + + Copyright (C) 2001 Jeff Teunissen + + 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 +#import +#import +#import + +#import +#import + +#import "Preferences.h" + +id prefs; + +static NSDictionary *defaultValues (void) { + static NSDictionary *dict = nil; + if (!dict) { + dict = [[NSDictionary alloc] initWithObjectsAndKeys: + @"/Local/Forge/Projects", ProjectPath, + @"/Local/Forge/Sounds", BspSoundPath, + [NSNumber numberWithInt: 0], StartWad, + [NSNumber numberWithFloat: 1.0], XLight, + [NSNumber numberWithFloat: 0.6], YLight, + [NSNumber numberWithFloat: 0.75], ZLight, + [NSNumber numberWithBool: NO], ShowBSPOutput, + [NSNumber numberWithBool: NO], OffsetBrushCopy, + nil]; + } + return dict; +} + +@implementation Preferences + +static Preferences *sharedInstance = nil; + +- (id) objectForKey: (id) key +{ + return [[[[self class] sharedInstance] preferences] objectForKey: key]; +} + ++ (void) saveDefaults +{ + if (sharedInstance) { + [self savePreferencesToDefaults: [sharedInstance preferences]]; + } +} + +- (void) saveDefaults: (id) sender +{ + [[self class] saveDefaults]; +} + +- (void) loadDefaults +{ + if (currentValues) + [currentValues release]; + + currentValues = [[[self class] preferencesFromDefaults] copyWithZone: [self zone]]; + [self discardDisplayedValues]; +} + ++ (Preferences *) sharedInstance +{ + return (sharedInstance ? sharedInstance : [[self alloc] init]); +} + +- (id) init +{ + if (sharedInstance) { + [self dealloc]; + } else { + [super init]; + currentValues = [[[self class] preferencesFromDefaults] copyWithZone:[self zone]]; + [self discardDisplayedValues]; + sharedInstance = self; + prefs = sharedInstance; + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(saveDefaults:) + name: @"NSApplicationWillTerminateNotification" + object: nil]; + } + return sharedInstance; +} + +- (NSDictionary *) preferences +{ + return currentValues; +} + +- (void) dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver: self]; + [currentValues release]; + [displayedValues release]; + currentValues = displayedValues = nil; + [super dealloc]; +} + +/* + updateUI + + Update the user interface with new preferences +*/ +- (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; + float aFloat; + + if (!yes) { + yes = [[NSNumber alloc] initWithBool: YES]; + no = [[NSNumber alloc] initWithBool: NO]; + } + + [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 = [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 = [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]; + + [self commitDisplayedValues]; +} + +- (void) commitDisplayedValues +{ + if (currentValues != displayedValues) { + [currentValues release]; + currentValues = [displayedValues copyWithZone: [self zone]]; + } +} + +- (void) discardDisplayedValues +{ + if (currentValues != displayedValues) { + [displayedValues release]; + displayedValues = [currentValues mutableCopyWithZone: [self zone]]; + [self updateUI]; + } +} + +- (void) ok: (id) sender +{ + [self commitDisplayedValues]; +} + +- (void) revert: (id) sender +{ + [self discardDisplayedValues]; +} + +- (void) revertToDefault: (id) sender +{ + if (currentValues) + [currentValues release]; + + currentValues = [defaultValues () copyWithZone: [self zone]]; + [currentValues retain]; + + [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 +{ + 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); + + 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]; \ +} + +#define setFloatDefault(name) \ +{ \ + if ([[defaultValues() objectForKey: name] isEqual: [dict objectForKey: name]]) \ + [defaults removeObjectForKey: name]; \ + else \ + [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]; \ +} + +#define setStringDefault(name) \ +{ \ + if ([[defaultValues() objectForKey:name] isEqual: [dict objectForKey: name]]) \ + [defaults removeObjectForKey: name]; \ + else \ + [defaults setObject: [[dict objectForKey: name] stringValue] forKey: name]; \ +} + ++ (void) savePreferencesToDefaults: (NSDictionary *) dict +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + setStringDefault(ProjectPath); + setStringDefault(BspSoundPath); + setIntDefault(StartWad); + setFloatDefault(XLight); + setFloatDefault(YLight); + setFloatDefault(ZLight); + setBoolDefault(ShowBSPOutput); + setBoolDefault(OffsetBrushCopy); +} + +@end diff --git a/tools/Forge/main.m b/tools/Forge/main.m new file mode 100644 index 000000000..650259ece --- /dev/null +++ b/tools/Forge/main.m @@ -0,0 +1,12 @@ +#import +#import "Controller.h" + +#define APP_NAME @"GNUstep" + +int main(int argc, const char *argv[], const char *env[]) +{ + [NSApplication sharedApplication]; + [NSApp setDelegate: [[Controller alloc] init]]; + + return NSApplicationMain (argc, argv); +}