mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-06 16:01:10 +00:00
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.
This commit is contained in:
parent
51a17f280b
commit
5ff1de398e
10 changed files with 785 additions and 73 deletions
29
tools/Forge/Controller.h
Normal file
29
tools/Forge/Controller.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@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
|
167
tools/Forge/Controller.m
Normal file
167
tools/Forge/Controller.m
Normal file
|
@ -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 <AppKit/AppKit.h>
|
||||||
|
#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;
|
||||||
|
{
|
||||||
|
}
|
140
tools/Forge/Forge.classes
Normal file
140
tools/Forge/Forge.classes
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
BIN
tools/Forge/Forge.gorm
Normal file
BIN
tools/Forge/Forge.gorm
Normal file
Binary file not shown.
BIN
tools/Forge/Forge.tiff
Normal file
BIN
tools/Forge/Forge.tiff
Normal file
Binary file not shown.
|
@ -1,12 +1,11 @@
|
||||||
{
|
{
|
||||||
ApplicationDescription = "A map editor for QuakeForge";
|
ApplicationDescription = "A map editor for QuakeForge";
|
||||||
ApplicationIcon = "Images/Forge.tiff";
|
ApplicationIcon = "Forge.tiff";
|
||||||
ApplicationName = Forge;
|
ApplicationName = Forge;
|
||||||
ApplicationRelease = 0.1;
|
ApplicationRelease = "0.1.0 (Development)";
|
||||||
Authors = "Jeff Teunissen and Bill Currie";
|
Authors = ("Jeff Teunissen <deek@quakeforge.net>", "Bill Currie <taniwha@quakeforge.net>");
|
||||||
Copyright = "Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>, Bill Currie <taniwha@quakeforge.net>";
|
Copyright = "Copyright (C) 2002 Dusk To Dawn Computing";
|
||||||
CopyrightDescription = "Released under the GNU General Public License";
|
CopyrightDescription = "This program is released under the GNU General Public License";
|
||||||
FullVersionID = 0.1;
|
FullVersionID = "0.1.0 (Development)";
|
||||||
NOTE = "Automatically generated!";
|
URL = "http://www.quakeforge.net/Forge/";
|
||||||
URL = "";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
#
|
#
|
||||||
# Main application
|
# Main application
|
||||||
#
|
#
|
||||||
|
PACKAGE_NAME= Forge
|
||||||
APP_NAME= Forge
|
APP_NAME= Forge
|
||||||
Forge_PRINCIPAL_CLASS= Forge
|
Forge_PRINCIPAL_CLASS= Forge
|
||||||
Forge_APPLICATION_ICON= Forge.tiff
|
Forge_APPLICATION_ICON= Forge.tiff
|
||||||
|
@ -46,90 +47,34 @@ ADDITIONAL_GUI_LIBS +=
|
||||||
#
|
#
|
||||||
# Resource files
|
# Resource files
|
||||||
#
|
#
|
||||||
|
Forge_RESOURCE_FILES= \
|
||||||
|
ForgeInfo.plist \
|
||||||
|
Forge.tiff
|
||||||
|
# Forge.gorm \
|
||||||
|
|
||||||
# Languages we're localized for
|
# Languages we're localized for
|
||||||
Forge_LANGUAGES= \
|
Forge_LANGUAGES= \
|
||||||
English
|
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
|
# Header files
|
||||||
#
|
#
|
||||||
Forge_HEADERS= \
|
Forge_HEADERS= \
|
||||||
Headers/CameraView.h \
|
Controller.h \
|
||||||
Headers/Clipper.h \
|
Preferences.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
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Class files
|
# Class files
|
||||||
#
|
#
|
||||||
Forge_OBJC_FILES= \
|
Forge_OBJC_FILES= \
|
||||||
Clipper.m \
|
Controller.m \
|
||||||
Forge_main.m \
|
|
||||||
Preferences.m \
|
Preferences.m \
|
||||||
Project.m \
|
main.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 \
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# C files
|
# C files
|
||||||
#
|
#
|
||||||
Forge_C_FILES= \
|
Forge_C_FILES=
|
||||||
cmdlib.c
|
|
||||||
|
|
||||||
-include GNUmakefile.preamble
|
-include GNUmakefile.preamble
|
||||||
-include GNUmakefile.local
|
-include GNUmakefile.local
|
||||||
|
|
92
tools/Forge/Preferences.h
Normal file
92
tools/Forge/Preferences.h
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
Preferences.h
|
||||||
|
|
||||||
|
Preferences class definition for Forge
|
||||||
|
|
||||||
|
Copyright (C) 2001 Jeff Teunissen <deek@d2dc.net>
|
||||||
|
|
||||||
|
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 <Foundation/NSObject.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
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;
|
328
tools/Forge/Preferences.m
Normal file
328
tools/Forge/Preferences.m
Normal file
|
@ -0,0 +1,328 @@
|
||||||
|
/*
|
||||||
|
Preferences.m
|
||||||
|
|
||||||
|
Preferences class for Forge
|
||||||
|
|
||||||
|
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
|
||||||
|
|
||||||
|
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 <Foundation/NSNotification.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSUserDefaults.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
#import <AppKit/NSButton.h>
|
||||||
|
#import <AppKit/NSControl.h>
|
||||||
|
|
||||||
|
#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
|
12
tools/Forge/main.m
Normal file
12
tools/Forge/main.m
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#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);
|
||||||
|
}
|
Loading…
Reference in a new issue