mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 12:31:10 +00:00
Forge updates. Forge now saves, but does not load (heh) projects.
This commit is contained in:
parent
5f54a1931b
commit
caf9d820c1
12 changed files with 90 additions and 70 deletions
Binary file not shown.
|
@ -46,15 +46,12 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode;
|
|||
{
|
||||
IBOutlet BundleController *bundleController;
|
||||
IBOutlet PrefsController *prefsController;
|
||||
IBOutlet id window;
|
||||
IBOutlet CMode fileMode;
|
||||
IBOutlet NSString *fileName;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
@ -66,17 +63,11 @@ typedef enum {CNoMode = 0, COpenMode, CCreateMode} CMode;
|
|||
// Action methods
|
||||
- (IBAction) showPreferencesPanel: (id) sender;
|
||||
|
||||
// Projects
|
||||
// Open/Create Project
|
||||
- (IBAction) newProject: (id) sender;
|
||||
- (IBAction) openProject: (id) sender;
|
||||
- (IBAction) saveProject: (id) sender;
|
||||
- (IBAction) closeProject: (id) sender;
|
||||
|
||||
// Files
|
||||
- (IBAction) addFileToProject: (id) sender;
|
||||
- (IBAction) addNewFileToProject: (id) sender;
|
||||
- (IBAction) open: (id) sender;
|
||||
|
||||
// Private (for Project)
|
||||
- (CMode) fileMode;
|
||||
- (NSString *) fileName;
|
||||
@end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Controller.h
|
||||
Controller.m
|
||||
|
||||
Application controller class
|
||||
|
||||
|
@ -47,22 +47,24 @@ static const char rcsid[] =
|
|||
|
||||
- (BOOL) application: (NSApplication *) app openFile: (NSString *) filename;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (![[filename pathExtension] isEqualToString: @"forge"]) {
|
||||
NSLog (@"File \"%@\" is not a project file!", filename);
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) application: (NSApplication *) app openTempFile: (NSString *) filename;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
fileMode = COpenMode;
|
||||
fileName = filename;
|
||||
|
||||
- (BOOL) applicationOpenUntitledFile: (NSApplication *) app;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (![NSBundle loadNibNamed: @"Project" owner: self]) {
|
||||
NSLog (@"Could not load project manager for file \"%@\"", filename);
|
||||
fileMode = CNoMode;
|
||||
fileName = nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) app;
|
||||
{
|
||||
return NO;
|
||||
fileMode = CNoMode;
|
||||
fileName = nil;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) applicationShouldTerminate: (NSApplication *) app;
|
||||
|
@ -110,34 +112,6 @@ static const char rcsid[] =
|
|||
return;
|
||||
}
|
||||
|
||||
- (void) saveProject: (id) sender;
|
||||
{
|
||||
NSLog (@"This _will_ save the project, but it doesn't yet.");
|
||||
}
|
||||
|
||||
- (void) closeProject: (id) sender;
|
||||
{
|
||||
NSLog (@"This _will_ close the project, but it doesn't yet.");
|
||||
}
|
||||
|
||||
/*
|
||||
File-level stuff.
|
||||
*/
|
||||
- (void) addFileToProject: (id) sender;
|
||||
{
|
||||
NSLog (@"This _will_ copy/move a file into the project, but it doesn't yet.");
|
||||
}
|
||||
|
||||
- (void) addNewFileToProject: (id) sender;
|
||||
{
|
||||
NSLog (@"This _will_ create a new file, but it doesn't yet.");
|
||||
}
|
||||
|
||||
- (void) open: (id) sender;
|
||||
{
|
||||
NSLog (@"This _will_ open a file, but it doesn't yet.");
|
||||
}
|
||||
|
||||
/******
|
||||
Notifications
|
||||
******/
|
||||
|
@ -149,7 +123,6 @@ static const char rcsid[] =
|
|||
*/
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) not;
|
||||
{
|
||||
[bundleController loadBundles];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -172,6 +145,8 @@ static const char rcsid[] =
|
|||
*/
|
||||
NSDebugLog (@"Services");
|
||||
[NSApp setServicesMenu: [[menu itemWithTitle: _(@"Services")] submenu]];
|
||||
|
||||
[bundleController loadBundles];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -189,8 +164,8 @@ static const char rcsid[] =
|
|||
- (void) awakeFromNib
|
||||
{
|
||||
fileMode = CNoMode;
|
||||
[window setFrameAutosaveName: @"Project View"];
|
||||
[window setFrameUsingName: @"Project View"];
|
||||
// [window setFrameAutosaveName: @"Project View"];
|
||||
// [window setFrameUsingName: @"Project View"];
|
||||
}
|
||||
|
||||
/******
|
||||
|
@ -251,4 +226,9 @@ static const char rcsid[] =
|
|||
return fileMode;
|
||||
}
|
||||
|
||||
- (NSString *) fileName
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
);
|
||||
Outlets = (
|
||||
bundleController,
|
||||
prefsController,
|
||||
window
|
||||
prefsController
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -613,7 +613,8 @@
|
|||
closeProject:
|
||||
);
|
||||
Outlets = (
|
||||
owner
|
||||
owner,
|
||||
window
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -45,9 +45,9 @@
|
|||
IBOutlet NSBox *box;
|
||||
IBOutlet NSMatrix *iconList;
|
||||
IBOutlet NSScrollView *scrollView;
|
||||
IBOutlet NSWindow *window;
|
||||
IBOutlet id owner;
|
||||
|
||||
IBOutlet NSWindow *window;
|
||||
}
|
||||
|
||||
+ (PrefsController *) sharedPrefsController;
|
||||
|
|
|
@ -179,7 +179,6 @@ static NSMutableArray *prefsViews = nil;
|
|||
|
||||
if (! [prefsViews containsObject: aController]) {
|
||||
[prefsViews addObject: aController];
|
||||
[aController autorelease];
|
||||
}
|
||||
|
||||
[button setTitle: [aController buttonCaption]];
|
||||
|
@ -191,6 +190,8 @@ static NSMutableArray *prefsViews = nil;
|
|||
|
||||
[iconList addColumnWithCells: [NSArray arrayWithObject: button]];
|
||||
[iconList sizeToCells];
|
||||
|
||||
[aController autorelease];
|
||||
}
|
||||
|
||||
- (NSBox *) prefsViewBox
|
||||
|
|
|
@ -37,7 +37,12 @@
|
|||
|
||||
@interface Project: NSObject
|
||||
{
|
||||
IBOutlet id owner;
|
||||
IBOutlet id owner;
|
||||
IBOutlet NSWindow *window;
|
||||
NSMutableArray *rFiles;
|
||||
NSMutableArray *imgFiles;
|
||||
NSMutableArray *suppFiles;
|
||||
NSMutableArray *otherFiles;
|
||||
}
|
||||
|
||||
- (void) createProjectAtPath: (NSString *) aPath;
|
||||
|
|
|
@ -35,7 +35,10 @@ static const char rcsid[] =
|
|||
|
||||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
|
||||
#import <AppKit/NSBrowser.h>
|
||||
#import <AppKit/NSBrowserCell.h>
|
||||
#import <AppKit/NSOpenPanel.h>
|
||||
#import <AppKit/NSSavePanel.h>
|
||||
|
||||
|
@ -51,13 +54,23 @@ static const char rcsid[] =
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[rFiles release];
|
||||
[imgFiles release];
|
||||
[otherFiles release];
|
||||
[suppFiles release];
|
||||
NSLog (@"Project deallocating");
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
int result;
|
||||
int result;
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
imgFiles = [NSMutableArray new];
|
||||
rFiles = [NSMutableArray new];
|
||||
suppFiles = [NSMutableArray new];
|
||||
otherFiles = [NSMutableArray new];
|
||||
|
||||
if (![owner fileMode]) {
|
||||
NSLog (@"Project -awakeFromNib: Uhh, file mode isn't set. WTF?");
|
||||
|
@ -65,6 +78,11 @@ static const char rcsid[] =
|
|||
return;
|
||||
}
|
||||
|
||||
if ([owner fileName]) {
|
||||
[self openProjectAtPath: [owner fileName]];
|
||||
return;
|
||||
}
|
||||
|
||||
switch ([owner fileMode]) {
|
||||
case COpenMode: { // load project
|
||||
NSArray *fileTypes = [NSArray arrayWithObject: @"forge"];
|
||||
|
@ -74,7 +92,9 @@ static const char rcsid[] =
|
|||
[oPanel setCanChooseFiles: YES];
|
||||
[oPanel setCanChooseDirectories: NO];
|
||||
|
||||
result = [oPanel runModalForTypes: fileTypes];
|
||||
result = [oPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"]
|
||||
file: nil
|
||||
types: fileTypes];
|
||||
|
||||
if (result == NSOKButton) { // got a path
|
||||
NSArray *pathArray = [oPanel filenames];
|
||||
|
@ -93,7 +113,8 @@ static const char rcsid[] =
|
|||
[sPanel setRequiredFileType: @"forge"];
|
||||
[sPanel setTreatsFilePackagesAsDirectories: NO];
|
||||
|
||||
result = [sPanel runModal];
|
||||
result = [sPanel runModalForDirectory: [defaults objectForKey: @"ProjectPath"]
|
||||
file: @"ProjectName.forge"];
|
||||
|
||||
if (result == NSOKButton) { // got a path
|
||||
[self createProjectAtPath: [sPanel filename]];
|
||||
|
@ -110,7 +131,13 @@ static const char rcsid[] =
|
|||
- (void) createProjectAtPath: (NSString *) aPath
|
||||
{
|
||||
NSFileManager *filer = [NSFileManager defaultManager];
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||
// create dictionary with dictionaries in it, each containing nothing
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
imgFiles, @"Image Files",
|
||||
rFiles, @"Ruamoko Source",
|
||||
suppFiles, @"Supporting Files",
|
||||
otherFiles, @"Unmanaged Files",
|
||||
nil];
|
||||
|
||||
if (!aPath) {
|
||||
NSLog (@"No path given!");
|
||||
|
@ -120,14 +147,15 @@ static const char rcsid[] =
|
|||
NSLog (@"Could not create directory %@", aPath);
|
||||
}
|
||||
|
||||
// create dictionary with dictionaries in it, each containing nothing
|
||||
// write the dictionary
|
||||
[dict writeToFile: [aPath stringByAppendingPathComponent: @"Forge.project"]
|
||||
atomically: YES];
|
||||
[window makeKeyAndOrderFront: self];
|
||||
}
|
||||
|
||||
- (void) openProjectAtPath: (NSString *) aPath
|
||||
{
|
||||
NSLog (@"No code to load project %@", aPath);
|
||||
NSLog (@"No code to load project %@.", aPath);
|
||||
[self dealloc];
|
||||
}
|
||||
|
||||
|
@ -135,4 +163,18 @@ static const char rcsid[] =
|
|||
{
|
||||
}
|
||||
|
||||
- (int) browser: (NSBrowser *) sender numberOfRowsInColumn: (int) column
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (void) browser: (NSBrowser *) sender
|
||||
willDisplayCell: (id) cell
|
||||
atRow: (int) row
|
||||
column: (int) column
|
||||
{
|
||||
[cell setStringValue: @"hi"];
|
||||
[cell setLoaded: YES];
|
||||
[cell setLeaf: YES];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#define APP_NAME @"Forge"
|
||||
|
||||
int main(int argc, const char *argv[], const char *env[])
|
||||
int
|
||||
main (int argc, const char *argv[], const char *env[])
|
||||
{
|
||||
return NSApplicationMain (argc, argv);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue