Forge updates. The app controller now has methods for bundles to call,

to register functionality with the app.
This commit is contained in:
Jeff Teunissen 2001-11-28 23:46:37 +00:00
parent 74e2f63188
commit a7dfe849fd
9 changed files with 48 additions and 22 deletions

View file

@ -62,6 +62,15 @@
@end
/*
Forge bundles need an owner to send their messages to
*/
@protocol ForgeBundle <NSObject>
- (id) initWithOwner: (id <BundleDelegate>) anOwner;
@end
@interface BundleController: NSObject
{
id delegate;

View file

@ -129,6 +129,7 @@ static const char rcsid[] =
*/
- (void) applicationWillFinishLaunching: (NSNotification *) not;
{
#if 0
NSMenu *menu = [[[NSMenu alloc] init] autorelease];
NSMenu *info;
NSMenu *project;
@ -260,6 +261,7 @@ static const char rcsid[] =
[menu setSubmenu: services forItem: [menu itemWithTitle: _(@"Services")]];
[NSApp setMainMenu: menu];
#endif
{ // yeah, yeah, shaddap
id controller = [[BundleController alloc] init];
@ -284,23 +286,29 @@ static const char rcsid[] =
- (void) bundleController: (BundleController *) aController didLoadBundle: (NSBundle *) aBundle
{
NSDictionary *info = nil;
if (!aBundle) {
NSLog (@"Controller -bundleController: sent nil bundle");
return;
}
info = [aBundle infoDictionary];
if (![aBundle principalClass]) {
NSDictionary *info = [aBundle infoDictionary];
if (!(info || [info objectForKey: @"NSExecutable"])) {
NSLog (@"%@ has no principal class and no info dictionary", aBundle);
return;
}
NSLog (@"Bundle `%@' has no principal class!", [info objectForKey: @"NSExecutable"]);
NSLog (@"Bundle `%@' has no principal class!", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return;
}
[[[aBundle principalClass] alloc] init];
if (![[aBundle principalClass] conformsToProtocol: @protocol(ForgeBundle)]) {
NSLog (@"Bundle %@'s principal class does not conform to the ForgeBundle protocol.", [[info objectForKey: @"NSExecutable"] lastPathComponent]);
return;
}
[[(id <ForgeBundle>) [aBundle principalClass] alloc] initWithOwner: self];
}
- (BOOL) registerPrefsController: (id <PrefsViewController>) aPrefsController

View file

@ -12,9 +12,11 @@
Actions = (
createNew:,
createNewProject:,
infoPanel:,
open:,
openProject:,
saveAll:
saveAll:,
showPreferencesPanel:
);
Outlets = (
);

Binary file not shown.

View file

@ -1,5 +1,5 @@
{
ApplicationDescription = "A map editor for QuakeForge";
ApplicationDescription = "A game editor for QuakeForge";
ApplicationIcon = "Forge.tiff";
ApplicationName = Forge;
ApplicationRelease = "0.1.0 (Development)";
@ -7,7 +7,7 @@
Authors = (
"Jeff Teunissen <deek@d2dc.net>",
);
Copyright = "Copyright (C) 2001 Dusk To Dawn Computing";
CopyrightDescription = "This program is released under the GNU General Public License";
Copyright = "Copyright (C) 2001 Dusk To Dawn Computing, Inc.";
CopyrightDescription = "Released under the GNU GPL. See COPYING for details.";
FullVersionID = "0.1.0 (Development)";
}

View file

@ -153,8 +153,7 @@ static NSMutableArray *prefsViews = nil;
[controller autorelease];
}
[[prefsPanel prefsViewBox] setContentView: [controller view]];
[[prefsPanel prefsViewBox] setNeedsDisplay: YES];
[prefsPanel addPrefsViewButton: controller];
}
@end

View file

@ -1,7 +1,7 @@
/*
PrefsWindow.h
PrefsPanel.h
Preferences window class
Preferences panel class
Copyright (C) 2001 Dusk to Dawn Computing, Inc.
@ -47,7 +47,11 @@
- (void) initUI;
- (void) dealloc;
- (void) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img;
#if 0
- (NSButtonCell *) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img;
#else
- (void) addPrefsViewButton: (NSButtonCell *) aButton;
#endif
- (NSBox *) prefsViewBox;
- (NSMatrix *) prefsViewList;

View file

@ -1,7 +1,7 @@
/*
PrefsWindow.m
PrefsPanel.m
Preferences window class
Preferences panel class
Copyright (C) 2001 Dusk to Dawn Computing, Inc.
@ -41,6 +41,7 @@ static const char rcsid[] =
#import <AppKit/NSMatrix.h>
#import <AppKit/NSScrollView.h>
#import "BundleController.h"
#import "PrefsPanel.h"
@implementation PrefsPanel
@ -81,7 +82,6 @@ static const char rcsid[] =
[prefsViewList setPrototype: prototype];
[prefsViewList setTarget: [self windowController]];
[prefsViewList setAction: @selector(cellWasClicked:)];
[prefsViewList addRow]; // No columns yet, they'll get added as views do
iconScrollView = [[NSScrollView alloc] initWithFrame: NSMakeRect (8, 290, 500, 86)];
[iconScrollView autorelease];
@ -136,15 +136,17 @@ static const char rcsid[] =
[super dealloc];
}
- (void) addPrefsViewButtonWithTitle: (NSString *) desc andImage: (NSImage *) img
- (void) addPrefsViewButton: (id <PrefsViewController>) aController
{
NSButtonCell *button = [[NSButtonCell alloc] init];
[button setTag: _topTag++];
[button setTitle: desc];
[button setFont: [NSFont systemFontOfSize: 8]];
[button setImage: img];
[button setTitle: [aController buttonCaption]];
[button setFont: [NSFont systemFontOfSize: 9]];
[button setImage: [aController buttonImage]];
[button setImagePosition: NSImageAbove];
[button setTarget: aController];
[button setAction: [aController buttonSelector]];
[prefsViewList addColumnWithCells: [NSArray arrayWithObject: button]];
[prefsViewList sizeToCells];
[prefsViewList setNeedsDisplay: YES];

View file

@ -31,7 +31,9 @@
# include "Config.h"
#endif
#import <Foundation/NSObject.h>
#import <AppKit/NSView.h>
#import <AppKit/NSButtonCell.h>
// size of a PrefsView
#define PrefsRect NSMakeRect (0, 0, 486, 228)
@ -42,9 +44,9 @@
- (void) loadPrefs: (id) sender;
- (void) resetPrefsToDefault: (id) sender;
- (NSString *) buttonCaption;
- (NSImage *) buttonImage;
- (SEL) buttonSelector;
- (NSView *) view;
@end
@interface PrefsViewController <PrefsViewController>
@end