From 5ff1de398ee6f2095daea0dc7de87c27e39f83e2 Mon Sep 17 00:00:00 2001 From: Jeff Teunissen Date: Mon, 5 Nov 2001 19:58:25 +0000 Subject: [PATCH] Okay, tiny skeleton for Forge. It will be cleaner and probably faster to treat Forge like an entirely new program, and not as a port. I'll still be using many of the ideas from QuakeEd (and from my old Forge work), but there's no promise that it'll be a duplicate, or even similar. --- tools/Forge/Controller.h | 29 ++++ tools/Forge/Controller.m | 167 ++++++++++++++++++ tools/Forge/Forge.classes | 140 +++++++++++++++ tools/Forge/Forge.gorm | Bin 0 -> 10868 bytes tools/Forge/Forge.tiff | Bin 0 -> 2436 bytes tools/Forge/ForgeInfo.plist | 15 +- tools/Forge/GNUmakefile | 75 ++------- tools/Forge/Preferences.h | 92 ++++++++++ tools/Forge/Preferences.m | 328 ++++++++++++++++++++++++++++++++++++ tools/Forge/main.m | 12 ++ 10 files changed, 785 insertions(+), 73 deletions(-) create mode 100644 tools/Forge/Controller.h create mode 100644 tools/Forge/Controller.m create mode 100644 tools/Forge/Forge.classes create mode 100644 tools/Forge/Forge.gorm create mode 100644 tools/Forge/Forge.tiff create mode 100644 tools/Forge/Preferences.h create mode 100644 tools/Forge/Preferences.m create mode 100644 tools/Forge/main.m 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 0000000000000000000000000000000000000000..6583ecc198ec901b9815fa4fd83516cfda53b016 GIT binary patch literal 10868 zcmcgy3w&Eu89(y>d$cHPn{J~@yRZxx%41o2*M_A@NYZv7 zLIni{99absM0trI4?O`zQIMf1h=LOY5d{Z|@_vo?Ykuc^xwj{|O`8ET{q635&-u>x zedm9^@0{=6WJS+WskE8!hLYj_$dC#6@hvudtpWfTAp%B|X|*)9f@Wx}c15r!vd$lm zr9+XJnPm7ebXL_9T)FNfGn^Lp40NN6P45YI52i!wqGo3#oQ}j}q2wu|({QmVJ;D4o zwjXvhLzz)7GzHViNURTAG}&IcFT(Pfc&XIU%rII7SGHUXsj<6iu&X_hh(^L8VGGJh zpxPFw)`ic>cr=Q`D~t-}mJ{hpn**qbF<#!#;1NJx6bO}0RoyuEV-GXm7c#J8myeHTZ-&~(ppl=V5(8WruGC^n;X;1BWASMZ$_iSkWnk5u3ZMA-8NM)Y~3-aqlK;z4#{|{ z(EXtSGa1UjG^0+)F2@kUPK@w+k}bDo%k}nTBor01s_?Y82_gEZIAf7f?0>m;BJNn-0)Dw({Z*#snuKCd*Vi1I;nQ}-!Zq;eu*c32d!?A;6?w$YQHhl~=@rD<$(K*8-E4)Q2r`kA zpUNY4PnFnhVm0xy^Ev6Yh}{c`-TVJY>>MO^pPeBVIV~i1u1c(o*m^-Mg{EU)vYQKu z-8YZe{l+J@<3_aa-0bY;!ie49BK80z_CO-G%8uA7eOW9WNk`1oE{fZ^Nbf-(liqm_ zdMiH)y$9#fd&nn4?|h5i1xPOty=o28ksM6*?=p7hA-l%MWY?#%D|ZFSuK$ve@wQvL zxiEN}^4M)2pI!f`Q0mxj?dHPZU1+hp2-#gs?5Zd3Dzgvkw_OyvJ|uU^$0WDKs22sE zU18uBsu|OnTO7c$z!VK*6`wrr{5#|ZdcVl?M-eLJCGM+Mvr1JX?#it>szhotI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forge/Forge.tiff b/tools/Forge/Forge.tiff new file mode 100644 index 0000000000000000000000000000000000000000..f7b1c4e84241290c988c2f1488738b54f00c10da GIT binary patch literal 2436 zcmYk;c{H0@9|!O!L?Q&CMW`jjQmUlUjJ*k}w$?UPquNR+VyP${)nz1-+PaA?v>3H? zTC~MG+74QYpuE~nY3EEWZIjr_jA|^^CnocFGw<=ooO|xMpL@^u-rqU*ub;oaEx=U; z02lyQGqRw!iOsz7)YL5Pl#8|H%SDStjJ?d1*bQZqe9w6hrDGLPZIOs6u)z-be+u?; zWy*;geY^qFTZ_vjv%@vk4B>W+fvU}7@Wpn&&=B4*4dWGIW z->TN#@lDdP$PhYFK%v-S(dr^<7Ka`}yoyXy(Dno%5$A)=2#u(><04?B?9$ zqoPl(4*RNbnqjp+SU3x&+jdsJZk@Tu?9-RG@E4?wzQPi}HrIV+D-e-8Lpc{qdOxG##D^eKvmCcN# zPMdaIl5w2dRq@}vcD&f}t^SJ{8OP36cgmqOQuk%{`!l?CL`~p4X3Jxig{XyT0o|DDvykg5^H_r$uiVbpnyxoWXgnRi@7K4ltDsJ<$M{RGBjiQ z=K~qC!40av6HcY%j;K4M+5MOK=TA>-y@6!UHSU=hz4b{8sWT}lU*pa*So>t03l@;T zfMlBkTz_OQ4z*5phnlJg{albyx|s<`j!`j|O8Q?GWRH|HAWU^R8JQzi{OLfE$x6C- zw#gN0i|h!$LnQcnlr@~vqaC$vxR(?LRuwW=L47Q~6L-8Ksde?Pwz2_ zghnQL-R4^H9G$OrI2~q>;qG^ zkIY~G{9V>m@Ik47ze+7+#!ZQyg5Rq{1OuXq&3@mWFCMYD>x`yeO+HL3jgrFftrg%Z zV}zzg!YkxTA6yDSXj+E1JwqEdu+=WCRPW6tKb5??2A(Aem-BzSJ1x@nn>rv~{G4i` zdiAE47aCG#7qB{ieYsupX6&*9`mQ9}2Gbjjb*~rQ+GV^1a)K^Okw1dTC$4C-B0)SI zPU{mkFCJ`@Pz}v8+XoRKCo@cneA$@nT^R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)}19e0=>hx7G66axGY D;?zER literal 0 HcmV?d00001 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); +}