removing the completely depricated folder that was meant for supporting XCode

since the files were not updated for a very long time, the project
files are completely outdated in the current form
This commit is contained in:
Nils Kneuper 2006-02-16 16:18:03 +00:00
parent 2877b0f41a
commit d0fdd46b7e
295 changed files with 0 additions and 65717 deletions

View file

@ -1,6 +0,0 @@
/* Localized versions of Info.plist keys */
CFBundleName = "Battle For Wesnoth";
CFBundleShortVersionString = "Battle For Wesnoth";
CFBundleGetInfoString = "Battle";
NSHumanReadableCopyright = "Copyright 2004 __MyCompanyName__.";

View file

@ -1,4 +0,0 @@
{
IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; });
IBVersion = 1;
}

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBFramework Version</key>
<string>291.0</string>
<key>IBSystem Version</key>
<string>6R73</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,37 +0,0 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
#import <Cocoa/Cocoa.h>
@interface SDLMain : NSObject
- (IBAction)prefs: (id)sender;
- (void)findWindows;
- (IBAction)installUserCampaigns: (id)sender;
- (IBAction)installUserCampaignsSkip: (id)sender;
- (IBAction)installUserOverwrite: (id)sender;
- (void)installEachDirFrom: (NSString *)FromDir to:(NSString *)ToDir overwrite:(BOOL)ow;
- (void)ProcessMyOpenFile: (NSString *)FileToProcess mode:(int)mode overwrite:(BOOL)owMode;
- (IBAction)revealMapsFolder: (id)sender;
- (IBAction)revealDataFolder: (id)sender;
- (IBAction)revealImagesFolder: (id)sender;
- (IBAction)revealFontsFolder: (id)sender;
- (IBAction)revealSoundsFolder: (id)sender;
- (IBAction)revealMusicFolder: (id)sender;
- (IBAction)revealPrefsFolder: (id)sender;
- (IBAction)revealCampaignsFolder: (id)sender;
- (IBAction)revealSaveFolder: (id)sender;
- (IBAction)launchConsole: (id)sender;
- (IBAction)launchEditor: (id)sender;
- (IBAction)webForum: (id)sender;
- (IBAction)webDownloads: (id)sender;
- (IBAction)webMainSite: (id)sender;
@end
@interface InstallingDataWindow : NSWindowController
{
}
@end

View file

@ -1,820 +0,0 @@
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
Feel free to customize this file to suit your needs
*/
//#include <sys/types.h>
//#include <dirent.h>
//#include <sys/stat.h>
// MJP
#include <carbon/carbon.h>
#include "WNCampaign.h";
//
#import "SDL.h"
#import "SDLMacOSXMain.h"
#import <sys/param.h> /* for MAXPATHLEN */
#import <unistd.h>
//#include "display.hpp"
//#include <fstream>
//#include <iostream>
/* Use this flag to determine whether we use SDLMain.nib or not */
#define SDL_USE_NIB_FILE 1 //Changed from 0 MJP
int EarlierThan10_3=0;
static int gArgc;
static char **gArgv;
static BOOL gFinderLaunch;
char mactextdomain[1024]; // MJP for gettext
NSMutableArray *EditorList=0; // Campaign Array
#if SDL_USE_NIB_FILE
/* A helper category for NSString */
@interface NSString (ReplaceSubString)
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
@end
#else
/* An internal Apple class used to setup Apple menus */
@interface NSAppleMenuController:NSObject {}
- (void)controlMenu:(NSMenu *)aMenu;
@end
#endif
@implementation InstallingDataWindow
@end
@interface SDLApplication : NSApplication
@end
@implementation SDLApplication
/* Invoked from the Quit menu item */
- (void)terminate:(id)sender
{
/* Post a SDL_QUIT event */
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
@end
/* The main class of the application, the application's delegate */
@implementation SDLMain
NSWindow *UserWindow=nil, *BackUpWindow=nil, *InstallWindow=nil, *DebugWindow=nil;
NSString *ScenariosFolder=nil, *UserInstallCheck=nil, *userPath=nil, *MyOpenFile=nil;
NSFileManager *manager = nil;
int WindowsInstalled = nil;
BOOL OverwriteBackup = NO, OverwriteUser = NO;
// MJP Added Classes
-(void)findWindows
{
// Find the windows
NSArray *WindowList = [NSApp windows];
int WindowCount = [WindowList count];
int WindowLoop, WindowID=-1;
for (WindowLoop = 0; WindowLoop < WindowCount ;WindowLoop++)
{ // Locate our info window
if ([[[WindowList objectAtIndex:WindowLoop] title] isEqualToString: @"Installing Data"])
{
WindowID = WindowLoop;
InstallWindow = [WindowList objectAtIndex:WindowLoop];
}
if ([[[WindowList objectAtIndex:WindowLoop] title] isEqualToString: @"Install Backup User Campaigns"]) {BackUpWindow = [WindowList objectAtIndex:WindowLoop];}
if ([[[WindowList objectAtIndex:WindowLoop] title] isEqualToString: @"Install User Campaigns"]) {UserWindow = [WindowList objectAtIndex:WindowLoop];}
if ([[[WindowList objectAtIndex:WindowLoop] title] isEqualToString: @"Debug Mode"]) {DebugWindow = [WindowList objectAtIndex:WindowLoop];}
}
// end find windows
WindowsInstalled = 1;
}
-(BOOL)application:(NSApplication *)openApp openFile:(NSString *)fileToOpen
{
MyOpenFile = [NSString stringWithString: fileToOpen];
if (WindowsInstalled == nil) {[self findWindows];};
fprintf(stderr, "drag'n'dropped:%s, MyOpenFile:%s\n\n",[fileToOpen cString],[MyOpenFile cString]);
[UserWindow center];
NSModalSession session = [NSApp beginModalSessionForWindow:UserWindow];
while([NSApp runModalSession:session] == NSRunContinuesResponse) {}
[NSApp endModalSession:session];
return true;
}
-(IBAction)installUserCampaigns: (id)sender
{
[NSApp stopModal];
[UserWindow orderOut:nil];
[self ProcessMyOpenFile: MyOpenFile mode:1 overwrite:OverwriteUser];
}
-(IBAction)installUserCampaignsSkip: (id)sender
{
[NSApp stopModal];
[UserWindow orderOut:nil];
}
-(IBAction)installUserOverwrite: (id)sender
{
OverwriteUser = !OverwriteUser;
}
-(void)installEachDirFrom:(NSString *)FromDir to:(NSString *)ToDir overwrite:(BOOL)ow
{
BOOL isDir;
fprintf(stderr, "Copying %s to %s\n",[FromDir cString], [ToDir cString]);
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] enumeratorAtPath:FromDir];
NSString *pname;
while (pname = [direnum nextObject])
{
if (([[pname pathExtension] isEqualToString:@"rtfd"])||([[pname uppercaseString] isEqualToString:@"MAKEFILE"])||([[pname uppercaseString] isEqualToString:@"README"]))
{
[direnum skipDescendents]; /* donÕt enumerate this directory */
}else {
NSString *myFile = [FromDir stringByAppendingPathComponent: pname];
NSString *toCopyTo = [ToDir stringByAppendingPathComponent:/*[*/pname /*lastPathComponent]*/];
fprintf(stderr, "\nTrying to copy %s to %s...", [pname cString], [toCopyTo cString]);
if ([manager fileExistsAtPath:toCopyTo] && ow)
{
if ([manager fileExistsAtPath:myFile isDirectory:&isDir] && isDir)
{
fprintf(stderr, "Directory already exists and we don't delete those :D\n");
}else{
fprintf(stderr, "file exists and overwrite is enabled, deleting...");
if ([manager removeFileAtPath:toCopyTo handler:nil])
{
fprintf(stderr, "deleted...");
}else{
fprintf(stderr, "delete failed...");
}
}
}
if ([manager copyPath:myFile toPath:toCopyTo handler:nil])
{
fprintf(stderr, "copy succeeded\n");
}else{
fprintf(stderr, "copy failed\n");
}
}
}
}
-(void)ProcessMyOpenFile: (NSString *)FileToProcess mode:(int)InstallMode overwrite: (BOOL)owMode
{
// OK, is there a file manager?
if (manager == nil) {manager = [NSFileManager defaultManager];}
// Now we split the components of the file to get the filename
NSArray *DroppedParts = [FileToProcess pathComponents];
int ArraySize = [DroppedParts count];
ArraySize--; // Decrease size
//NSString *CopyToPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"data/scenarios"];
NSArray *libPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *MapsPath = [[[[[libPaths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"] stringByAppendingPathComponent:@"wesnoth"] stringByAppendingPathComponent:@"editor"] stringByAppendingPathComponent:@"maps"];
NSString *CopyToFile = [MapsPath stringByAppendingPathComponent:[DroppedParts objectAtIndex:ArraySize]];
fprintf(stderr, "Copying %s to %s\n", [FileToProcess cString], [CopyToFile cString]);
// OK, Are we looking at a file or directory?
BOOL isDir;
if ([manager fileExistsAtPath:FileToProcess isDirectory:&isDir] && isDir)
{ // This is a directory
NSString *ResourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *CampaignTo = [[ResourcesPath stringByAppendingPathComponent:@"data"] stringByAppendingPathComponent:@"campaigns"];
fprintf(stderr,"Installing a campaign directory suite %s to %s\n", [FileToProcess cString], [CampaignTo cString]);
[self installEachDirFrom: FileToProcess to: CampaignTo overwrite:owMode];
/* [self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"images"] to: [ResourcesPath stringByAppendingPathComponent:@"images"] overwrite:owMode];
[self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"misc"] to: [ResourcesPath stringByAppendingPathComponent:@"images/misc"] overwrite:owMode];
[self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"data"] to: [ResourcesPath stringByAppendingPathComponent:@"data"] overwrite:owMode];
[self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"scenarios"] to: [ResourcesPath stringByAppendingPathComponent:@"data/scenarios"] overwrite:owMode];
[self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"maps"] to: [ResourcesPath stringByAppendingPathComponent:@"data/maps"] overwrite:owMode];
[self installEachDirFrom:[FileToProcess stringByAppendingPathComponent:@"units"] to: [ResourcesPath stringByAppendingPathComponent:@"data/units"] overwrite:owMode];*/
}else{ // Not a directory, so let us just copy :D
[manager copyPath:FileToProcess toPath:CopyToFile handler:nil];
}
// Delete cache directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
[manager removeFileAtPath:[[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth/cache"] handler:nil];
// Now sort out the backup
if (InstallMode == 1) // Do we actually want to make a backup?
{
if ([paths count] > 0)
{
NSString *BackUpPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth/user-scenario-backup"];
if (!([manager fileExistsAtPath:BackUpPath]))
{
// OK no backup dir, so make one then set the flag that it is created
[manager createDirectoryAtPath:BackUpPath attributes:nil];
NSString *FlagPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"user-scenarios-installed"];
[manager createFileAtPath: FlagPath contents:nil attributes:nil];
}
// Now copy the file to the backup dir
NSString *BackUpFile = [BackUpPath stringByAppendingPathComponent:[DroppedParts objectAtIndex:ArraySize]];
if ([manager fileExistsAtPath: BackUpFile] && OverwriteUser)
{
fprintf(stderr, "Backup already exists, overwrite enabled so deleting...");
[manager removeFileAtPath: BackUpFile handler:nil];
}
fprintf(stderr, "Copying to Backup Directory");
[manager copyPath:FileToProcess toPath:BackUpFile handler:nil];
}
}
}
// MJP Folder Menu Resposes start
-(IBAction)prefs: (id)sender
{
//display *myPrefsDisp;
SDL_Event event;
event.type=SDL_KEYDOWN;
event.key.type=SDL_KEYDOWN;
event.key.state=SDL_PRESSED;
event.key.keysym.mod = KMOD_CTRL;
event.key.keysym.sym =SDLK_p;
if (SDL_PushEvent(&event)==-1)
{
fprintf(stderr,"Cannot send keypress");
}else{
fprintf(stderr,"Keypress sent");
}
}
- (IBAction)revealMapsFolder: (id)sender
{
NSArray *paths;
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
// only copying one file
NSString *destPath = [[[[[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"] stringByAppendingPathComponent:@"wesnoth"] stringByAppendingPathComponent:@"editor"] stringByAppendingPathComponent:@"maps"];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:destPath];
}
}
- (IBAction)revealDataFolder: (id)sender
{
NSString *DataFolderPath = [[[NSBundle mainBundle]pathForResource:@"data" ofType:@""]stringByAppendingPathComponent:@""];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:DataFolderPath];
}
- (IBAction)revealImagesFolder: (id)sender
{
NSString *DataFolderPath = [[[NSBundle mainBundle]pathForResource:@"images" ofType:@""]stringByAppendingPathComponent:@""];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:DataFolderPath];
}
- (IBAction)revealFontsFolder: (id)sender
{
NSString *DataFolderPath = [[[NSBundle mainBundle]pathForResource:@"fonts" ofType:@""]stringByAppendingPathComponent:@""];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:DataFolderPath];
}
- (IBAction)revealSoundsFolder: (id)sender
{
NSString *DataFolderPath = [[[NSBundle mainBundle]pathForResource:@"sounds" ofType:@""]stringByAppendingPathComponent:@""];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:DataFolderPath];
}
- (IBAction)revealMusicFolder: (id)sender
{
NSString *DataFolderPath = [[[NSBundle mainBundle]pathForResource:@"music" ofType:@""]stringByAppendingPathComponent:@""];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:DataFolderPath];
}
- (IBAction)revealPrefsFolder: (id)sender
{
NSArray *paths;
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
// only copying one file
NSString *destPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth"];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:destPath];
}
}
- (IBAction)revealCampaignsFolder: (id)sender
{
NSArray *paths;
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
// only copying one file
NSString *destPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth/data/campaigns"];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:destPath];
}
}
- (IBAction)revealSaveFolder: (id)sender
{
NSArray *paths;
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
// only copying one file
NSString *destPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth/saves"];
[[NSWorkspace sharedWorkspace] selectFile:nil inFileViewerRootedAtPath:destPath];
}
}
// MJP Folder Menu Responses End
- (IBAction)launchConsole: (id)sender
{
fprintf(stderr, "Launching Console...\n");
[[NSWorkspace sharedWorkspace] launchApplication:@"Console.app"];
}
- (IBAction)launchEditor: (id)sender
{
fprintf(stderr, "Launching Editor...\n");
if (EditorList == 0) EditorList = [[NSMutableArray alloc] init];
WNCampaign *newEditor = [[WNCampaign alloc] init];
[EditorList addObject:newEditor];
[WNCampaign setMainMenu:[[NSApplication sharedApplication] mainMenu]];
if ([NSBundle loadNibNamed:@"MainMenu" owner:newEditor])
{
NSLog(@"Editor NIB loaded");
}else{
NSLog(@"Error loading NIB");
}
[WNCampaign setEditorMenu:[[NSApplication sharedApplication] mainMenu]];
NSLog(@"About to change focus");
[[newEditor getEditorWindow] makeKeyAndOrderFront:nil];
//[newEditor showEditorWindow];
}
// MJP Scenario Responses
-(IBAction)installCampaignsOverwrite: (id)sender
{
OverwriteBackup = !OverwriteBackup;
}
-(IBAction)installCampaignsNow: (id)sender
{
[NSApp stopModal];
[BackUpWindow orderOut:nil];
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager] enumeratorAtPath:userPath];
NSString *backupName;
while (backupName = [direnum nextObject])
{
if ([[backupName pathExtension] isEqualToString:@"rtfd"])
{
[direnum skipDescendents]; /* donÕt enumerate this directory */
}else {
[direnum skipDescendents]; // In fact, we don't want to pursue *any* subdirs
NSString *myBackupFile = [userPath stringByAppendingPathComponent: backupName];
fprintf(stderr, "\nTrying to restore %s\n", [backupName cString]);
[self ProcessMyOpenFile:myBackupFile mode:0 overwrite:OverwriteBackup];
}
}
[manager createFileAtPath: UserInstallCheck contents:nil attributes:nil];
}
-(IBAction)installCampaignsNever: (id)sender
{
[NSApp stopModal];
[BackUpWindow orderOut:nil];
[manager createFileAtPath: UserInstallCheck contents:nil attributes:nil];
}
-(IBAction)installCampaignsAskAgain: (id)sender
{
[NSApp stopModal];
[BackUpWindow orderOut:nil];
}
/* MJP Web links */
- (IBAction)webForum: (id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.wesnoth.org/forum"]];
}
- (IBAction)webDownloads: (id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.wesnoth.org/downloads.htm"]];
}
- (IBAction)webMainSite: (id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.wesnoth.org"]];
}
/* Set the working directory to the .app's parent directory */
- (void) setupWorkingDirectory:(BOOL)shouldChdir
{
char parentdir[MAXPATHLEN];
char *c;
strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
c = (char*) parentdir;
while (*c != '\0') /* go to end */
c++;
while (*c != '/') /* back up to parent */
c--;
*c++ = '\0'; /* cut off last part (binary name) */
#ifndef Mac_Editor
if (shouldChdir)
{
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
assert ( chdir ("../Resources/") == 0 ); /* chdir to the .app's parent */ // MJP removed ../../
}
#endif
// MJP Check for prefs dir and if it doesn't exist make it
/* DIR* MyDir = opendir("/Library/Preferences/Wesnoth");
if (MyDir == NULL)
{
mkdir("/Library/Preferences/Wesnoth", 00770);
std::ofstream fOut("/Library/Preferences/Wesnoth/preferences");
fOut<<"fullscreen=false\nturbo=true\n";
fOut.close();
}
*/
}
#if SDL_USE_NIB_FILE
/* Fix menu to contain the real app name instead of "SDL App" */
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
{
NSRange aRange;
NSEnumerator *enumerator;
NSMenuItem *menuItem;
aRange = [[aMenu title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
enumerator = [[aMenu itemArray] objectEnumerator];
while ((menuItem = [enumerator nextObject]))
{
aRange = [[menuItem title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
if ([menuItem hasSubmenu])
[self fixMenu:[menuItem submenu] withAppName:appName];
}
[ aMenu sizeToFit ];
}
#else
void setupAppleMenu(void)
{
/* warning: this code is very odd */
NSAppleMenuController *appleMenuController;
NSMenu *appleMenu;
NSMenuItem *appleMenuItem;
appleMenuController = [[NSAppleMenuController alloc] init];
appleMenu = [[NSMenu alloc] initWithTitle:@""];
appleMenuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[appleMenuItem setSubmenu:appleMenu];
/* yes, we do need to add it and then remove it --
if you don't add it, it doesn't get displayed
if you don't remove it, you have an extra, titleless item in the menubar
when you remove it, it appears to stick around
very, very odd */
[[NSApp mainMenu] addItem:appleMenuItem];
[appleMenuController controlMenu:appleMenu];
[[NSApp mainMenu] removeItem:appleMenuItem];
[appleMenu release];
[appleMenuItem release];
}
/* Create a window menu */
void setupWindowMenu(void)
{
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
// MJP Add show folders menus
NSMenu *folderMenu;
NSMenuItem *DataFolder, *ImagesFolder, *SoundsFolder, *MusicFolder, *PrefsFolder, *SaveFolder, *folderMenuItemTop;
folderMenu = [[NSMenu alloc] initWithTitle:@"Folders"];
DataFolder = [[NSMenuItem alloc] initWithTitle:@"Open Data Folder in Finder" action:@selector(revealDataFolder:) keyEquivalent:@""];
ImagesFolder = [[NSMenuItem alloc] initWithTitle:@"Open Images Folder in Finder" action:@selector(revealImagesFolder:) keyEquivalent:@""];
SoundsFolder = [[NSMenuItem alloc] initWithTitle:@"Open Sounds Folder in Finder" action:@selector(revealSoundsFolder:) keyEquivalent:@""];
MusicFolder = [[NSMenuItem alloc] initWithTitle:@"Open Music Folder in Finder" action:@selector(revealMusicFolder:) keyEquivalent:@""];
PrefsFolder = [[NSMenuItem alloc] initWithTitle:@"Open Preferences Folder in Finder" action:@selector(revealPrefsFolder:) keyEquivalent:@""];
SaveFolder = [[NSMenuItem alloc] initWithTitle:@"Open Saved Games Folder in Finder" action:@selector(revealSaveFolder:) keyEquivalent:@""];
[folderMenu addItem:DataFolder];
[folderMenu addItem:ImagesFolder];
[folderMenu addItem:SoundsFolder];
[folderMenu addItem:MusicFolder];
[folderMenu addItem:PrefsFolder];
[folderMenu addItem:SaveFolder];
folderMenuItemTop = [[NSMenuItem alloc] initWithTitle:@"Folder" action:nil keyEquivalent:@""];
[folderMenuItemTop setSubmenu:folderMenu];
[[NSApp mainMenu] addItem:folderMenuItemTop];
// MJP End
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
[windowMenu addItem:menuItem];
[menuItem release];
/* Put menu into the menubar */
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[windowMenuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:windowMenuItem];
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
/* Finally give up our references to the objects */
[windowMenu release];
[windowMenuItem release];
}
/* Replacement for NSApplicationMain */
void CustomApplicationMain (argc, argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDLMain *sdlMain;
/* Ensure the application object is initialised */
[SDLApplication sharedApplication];
/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
setupAppleMenu();
setupWindowMenu();
/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
/* Start the main event loop */
[NSApp run];
[sdlMain release];
[pool release];
}
#endif
/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
int status;
int myArgc = 0;
char *myArgv[32];
// Screen Depth
NSScreen *myScreen = [NSScreen mainScreen];
NSRect resolution = [myScreen frame];
fprintf(stderr, "Resolution: %g,%g,%g,%g\n", resolution.origin.x, resolution.origin.y,resolution.size.width, resolution.size.height);
resolution = [myScreen visibleFrame];
fprintf(stderr, "Resolution: %g,%g,%g,%g\n", resolution.origin.x, resolution.origin.y,resolution.size.width, resolution.size.height);
// Copy args
int tmp;
for (tmp = 0; tmp<gArgc ;tmp++) myArgv[tmp] = gArgv[tmp];
myArgc = gArgc;
if (WindowsInstalled == nil) {[self findWindows];}
// MJP Not happy as this red's carbon, but still...
UInt32 KeyMode;
KeyMode = GetCurrentEventKeyModifiers();
if (KeyMode == 2048)
{
myArgv[myArgc] = "--debug\0";
myArgc++;
[DebugWindow center];
[DebugWindow makeKeyAndOrderFront:nil];
}
/* KeyMap theKeys;
::GetKeys(theKeys);
const bool optionDown = theKeys[1] & kOptionKey;*/
/* Set the working directory to the .app's parent directory */
[self setupWorkingDirectory:gFinderLaunch];
// MJP Check for Data Dir, etc and copy if red'd
if (manager == nil) {manager = [NSFileManager defaultManager];}
#ifdef Mac_Editor
assert ( chdir ([[[[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Battle For Wesnoth.app"] stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent:@"Resources"] cString]) ==0);
#endif
#ifndef Mac_Editor
NSString *ApplicationPath = [[[NSBundle mainBundle]bundlePath]stringByDeletingLastPathComponent];
NSArray *PathArray = [ApplicationPath pathComponents]; // Get all the path components
NSString *ResourcePath = [[NSBundle mainBundle] resourcePath];
NSMutableString *UseFolderPath = [NSMutableString string];
// MJP Set Text Domain Variable
NSString *messagesPath = [ResourcePath stringByAppendingPathComponent:@"messages"];
strcpy(mactextdomain, [messagesPath cString]);
int PathSize = [PathArray count];
if ([[PathArray objectAtIndex:(PathSize-1)] isEqualToString:@"build"]) // Are we in the build directory
{ // If we are, move up a level
[UseFolderPath setString:[ApplicationPath stringByDeletingLastPathComponent]];
}else{ // If not, stay where we are
[UseFolderPath setString:ApplicationPath];
}
if (!([manager fileExistsAtPath:[ResourcePath stringByAppendingPathComponent:@"data"]]))
{
// OK the data files don't exist... so let us install
if ([manager fileExistsAtPath:[UseFolderPath stringByAppendingPathComponent:@"data"]])
{
if (InstallWindow != nil)
{
[InstallWindow center];
[InstallWindow makeKeyAndOrderFront:nil];
}
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"data"] toPath:[ResourcePath stringByAppendingPathComponent:@"data"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"images"] toPath:[ResourcePath stringByAppendingPathComponent:@"images"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"sounds"] toPath:[ResourcePath stringByAppendingPathComponent:@"sounds"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"music"] toPath:[ResourcePath stringByAppendingPathComponent:@"music"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"icons"] toPath:[ResourcePath stringByAppendingPathComponent:@"icons"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"fonts"] toPath:[ResourcePath stringByAppendingPathComponent:@"fonts"] handler:nil];
[manager copyPath:[UseFolderPath stringByAppendingPathComponent:@"messages"] toPath:[ResourcePath stringByAppendingPathComponent:@"messages"] handler:nil];
if (InstallWindow != nil) [InstallWindow orderOut: nil];
}
}
// MJP Copy Stuff Ends... So all the data files have been created
fprintf(stderr, "\nChecking for user scenarios\n");
ScenariosFolder = [ResourcePath stringByAppendingPathComponent: @"data/scenarios"];
UserInstallCheck = [ResourcePath stringByAppendingPathComponent:@"user-scenarios-installed"];
if (![manager fileExistsAtPath:UserInstallCheck])
{ // ok, there is no prior install
fprintf(stderr, "\nNo installation performed yet\n");
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([paths count] > 0)
{
userPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Preferences/Wesnoth/user-scenario-backup"];
fprintf(stderr,"\nChecking existance of %s\n", [userPath cString]);
if ([manager fileExistsAtPath:userPath])
{
fprintf(stderr, "\nUser scenario dir exists\n");
// Show dialog
[BackUpWindow center];
NSModalSession session = [NSApp beginModalSessionForWindow:BackUpWindow];
while([NSApp runModalSession:session] == NSRunContinuesResponse) {}
[NSApp endModalSession:session];
// end dialog
}
}
}
#endif
// MJP Now we need to check if the symlink exists within data -> user-campaings
#if SDL_USE_NIB_FILE
/* Set the main menu to contain the real app name instead of "SDL App" */
// MJP Commented out next
// [self fixMenu:[NSApp mainMenu] withAppName:[[NSProcessInfo processInfo] processName]];
#endif
/* Hand off to main application code */
status = SDL_main (myArgc, myArgv);
/* We're done, thank you for playing */
exit(status);
}
@end
@implementation NSString (ReplaceSubString)
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
{
unsigned int bufferSize;
unsigned int selfLen = [self length];
unsigned int aStringLen = [aString length];
unichar *buffer;
NSRange localRange;
NSString *result;
bufferSize = selfLen + aStringLen - aRange.length;
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
/* Get first part into buffer */
localRange.location = 0;
localRange.length = aRange.location;
[self getCharacters:buffer range:localRange];
/* Get middle part into buffer */
localRange.location = 0;
localRange.length = aStringLen;
[aString getCharacters:(buffer+aRange.location) range:localRange];
/* Get last part into buffer */
localRange.location = aRange.location + aRange.length;
localRange.length = selfLen - localRange.location;
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
/* Build output string */
result = [NSString stringWithCharacters:buffer length:bufferSize];
NSDeallocateMemoryPages(buffer, bufferSize);
return result;
}
@end
#ifdef main
# undef main
#endif
/* Main entry point to executable - should *not* be SDL_main! */
int main (int argc, char **argv)
{
/* Copy the arguments into a global variable */
int i;
/* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
#ifdef Mac_Editor_OLD
char MyFileString[256];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
int result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil];
if (result == NSOKButton) {
NSArray *filesToOpen = [oPanel filenames];
int count = [filesToOpen count];
NSString *aFile = [filesToOpen objectAtIndex:0];
[aFile getCString:MyFileString];
argv[1] = MyFileString;
}
gArgc = 2;
#else
gArgc = 1; // Was 1 MJP
//argv[1]="--windowed"; // MJP
#endif
gFinderLaunch = YES;
} else {
gArgc = argc;
gFinderLaunch = NO;
}
gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
assert (gArgv != NULL);
for (i = 0; i < gArgc; i++)
gArgv[i] = argv[i];
gArgv[i] = NULL;
// MJP Set Version Flag
// APPKIT_EXTERN double NSAppKitVersionNumber;
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_2)
{
EarlierThan10_3 = 1;
}else{
EarlierThan10_3 = 2;
}
fprintf(stderr, "EarlierThan10_3 set to:%d\n", EarlierThan10_3);
#if SDL_USE_NIB_FILE
[SDLApplication poseAsClass:[NSApplication class]];
NSApplicationMain (argc, argv);
#else
CustomApplicationMain (argc, argv);
#endif
return 0;
}

View file

@ -1,35 +0,0 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {
installCampaignsAskAgain = id;
installCampaignsNever = id;
installCampaignsNow = id;
installCampaignsOverwrite = id;
installUserCampaigns = id;
installUserCampaignsSkip = id;
installUserOverwrite = id;
launchConsole = id;
launchEditor = id;
prefs = id;
revealCampaignsFolder = id;
revealDataFolder = id;
revealFontsFolder = id;
revealImagesFolder = id;
revealMapsFolder = id;
revealMusicFolder = id;
revealPrefsFolder = id;
revealSaveFolder = id;
revealSoundsFolder = id;
webDownloads = id;
webForum = id;
webMainSite = id;
};
CLASS = SDLMain;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>131 600 356 240 0 0 1280 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>56 956 373 44 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>364.0</string>
<key>IBOpenObjects</key>
<array>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>7U16</string>
</dict>
</plist>

Binary file not shown.

View file

@ -1,212 +0,0 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {myAction = id; };
CLASS = NSWindow;
LANGUAGE = ObjC;
SUPERCLASS = NSResponder;
},
{
ACTIONS = {
aggressionSelect = id;
campaignNameSet = id;
campaignPrefixSet = id;
canRecruit = id;
defeatAdd = id;
defeatRemove = id;
defeatSelect = id;
difficultyDescChange = id;
difficultyEasyCheck = id;
difficultyHardCheck = id;
difficultyMediumCheck = id;
doNothing = id;
goldSet = id;
keepCancel = id;
keepChoose = id;
leaderSelect = id;
mapCharacterSelect = id;
mapExport = id;
mapHeightSet = id;
mapImport = id;
mapUnitSide = id;
mapViewSliderSet = id;
mapWidthSet = id;
mapZoomSet = id;
nextScenarioContinueSelect = id;
nextScenarioVictorySelect = id;
noTurnsSet = id;
recruitSelect = id;
scenarioDelete = id;
scenarioNew = id;
scenarioSelect = id;
showConditionsForDifficulty = id;
sidesAdd = id;
sidesAdvancedInfoSet = id;
sidesRemove = id;
sidesSelect = id;
sidesShowDetailFor = id;
teamAdd = id;
teamRemove = id;
teamSelect = id;
terrainSelect = id;
typeAI = id;
typeHuman = id;
unitPlacementSetEasy = id;
unitPlacementSetHard = id;
unitPlacementSetNormal = id;
unitSelect = id;
victoryAdd = id;
victoryRemove = id;
victorySelect = id;
};
CLASS = WNCampaign;
LANGUAGE = ObjC;
OUTLETS = {
UnitPlacementHard = id;
agressionLevel = NSSlider;
campaignIcon = id;
campaignName = id;
campaignPrefix = id;
canRecruit = id;
defeatList = id;
difficultyDescEasy = NSTextField;
difficultyDescHard = NSTextField;
difficultyDescNormal = NSTextField;
difficultyEasy = id;
difficultyHard = id;
difficultyIconEasy = id;
difficultyIconHard = id;
difficultyIconNormal = id;
difficultyMedium = id;
goldAmount = id;
keepSide = id;
keepX = id;
keepY = id;
leaderList = id;
loadSave = WNLoadSave;
mainTabView = id;
mapHeight = id;
mapInfoCharacterList = NSTextView;
mapInfoTerrain = NSTextField;
mapInfoUnitList = NSTextView;
mapUnitSideMenu = id;
mapWidth = id;
mapZoom = id;
nextScenarioContinue = id;
nextScenarioVictory = id;
noTurns = id;
recruitList = id;
scenarioAdvancedInfo = NSTextView;
scenarioList = id;
showConditionsForDifficulty = id;
sidesAdvancedInfo = NSTextView;
sidesList = id;
sidesShowDetailForDifficulty = id;
teamList = id;
terrainList = id;
typeAI = id;
typeHuman = id;
unitList = id;
unitPlacementEasy = id;
unitPlacementNormal = id;
victoryList = id;
};
SUPERCLASS = NSObject;
},
{CLASS = WNCampaignIconView; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
{
ACTIONS = {
CharacterAISelect = id;
CharacterDeathActionSelect = id;
CharacterDeathMessageUpdate = id;
CharacterDialogImageSelect = id;
CharacterHitpointsSelect = id;
CharacterNew = id;
CharacterRemove = id;
CharacterSelect = id;
CharacterTrait1Select = id;
CharacterTrait2Select = id;
CharacterUnitSelect = id;
CharacterUseDialogImageSelect = id;
};
CLASS = WNCharacterEditor;
LANGUAGE = ObjC;
OUTLETS = {
CharacterAI = NSPopUpButton;
CharacterDeathAction = NSPopUpButton;
CharacterDeathMessage = NSTextField;
CharacterDialogImage = NSImageView;
CharacterDialogImageSwitch = NSButton;
CharacterHP = NSSlider;
CharacterList = NSTableView;
CharacterTrait1 = NSPopUpButton;
CharacterTrait2 = NSPopUpButton;
CharacterUnitList = NSTableView;
};
SUPERCLASS = NSObject;
},
{CLASS = WNCharacterList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNCharacterListView; LANGUAGE = ObjC; SUPERCLASS = WNIconListView; },
{CLASS = WNCustomDialogView; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
{CLASS = WNDefeatList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNEventDataSource; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {
actionAdd = id;
actionTypeSelect = id;
eventAdd = id;
eventCharacterSelect = id;
eventRemove = id;
eventSelect = id;
eventSideSelect = id;
eventTriggerSelect = id;
eventUnitSelect = id;
filterAdd = id;
turnNoSet = id;
};
CLASS = WNEventEditor;
LANGUAGE = ObjC;
OUTLETS = {
actionType = NSPopUpButton;
eventCharacterList = WNCharacterListView;
eventInfoTabs = NSTabView;
eventList = NSOutlineView;
eventSideList = NSTableView;
eventTrigger = NSPopUpButton;
eventUnitList = WNIconListView;
turnNo = NSTextField;
};
SUPERCLASS = NSObject;
},
{CLASS = WNEventMapView; LANGUAGE = ObjC; SUPERCLASS = WNMapView; },
{CLASS = WNIconListView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; },
{CLASS = WNLeaderListView; LANGUAGE = ObjC; SUPERCLASS = WNIconListView; },
{
ACTIONS = {export = id; load = id; revert = id; save = id; saveAs = id; };
CLASS = WNLoadSave;
LANGUAGE = ObjC;
OUTLETS = {loadProgress = NSProgressIndicator; saveProgress = NSProgressIndicator; };
SUPERCLASS = NSObject;
},
{CLASS = WNMainTabViewDelegate; LANGUAGE = ObjC; SUPERCLASS = NSTabView; },
{CLASS = WNMapTabViewDelegate; LANGUAGE = ObjC; SUPERCLASS = NSTabView; },
{CLASS = WNMapView; LANGUAGE = ObjC; SUPERCLASS = NSView; },
{CLASS = WNRecruitListView; LANGUAGE = ObjC; SUPERCLASS = WNIconListView; },
{
ACTIONS = {windowDidBecomeKey = id; windowDidResignKey = id; };
CLASS = WNScenarioDesignDelegate;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{CLASS = WNScenarioList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNSideList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNTeamList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNTerrainList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNTerrainMapView; LANGUAGE = ObjC; SUPERCLASS = WNIconListView; },
{CLASS = WNUnitList; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = WNUnitMapView; LANGUAGE = ObjC; SUPERCLASS = WNIconListView; },
{CLASS = WNVictoryList; LANGUAGE = ObjC; SUPERCLASS = NSObject; }
);
IBVersion = 1;
}

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>126 -1 601 697 0 0 1280 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>38 553 392 44 0 0 1024 746 </string>
</dict>
<key>IBFramework Version</key>
<string>364.0</string>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>7U16</string>
</dict>
</plist>

View file

@ -1,21 +0,0 @@
//
// HexUtils.h
// Wesnoth Scenario Editor
//
// Created by Marcus on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface HexUtils : NSObject {
}
+(void)initWithWidth: (int)width;
+(NSPoint)hexFromX:(int)PixelX y:(int)PixelY;
+(NSPoint)pixelFromHexX:(int)ArrayX y:(int)ArrayY;
+(NSPoint)flatHexFromX:(int)PixelX y:(int)PixelY;
+(NSPoint)pixelFromFlatHexX:(int)ArrayX y:(int)ArrayY;
@end

View file

@ -1,158 +0,0 @@
//
// HexUtils.m
// Wesnoth Scenario Editor
//
// Created by Marcus on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "HexUtils.h"
@implementation HexUtils
int HexagonH=0;
int HexagonS=0;
int TileR=0;
float m;
+(void)initWithWidth: (int)width
{
TileR = width/2;
HexagonH = TileR*(0.5773502691896257);// Tan 30 :D
HexagonS = width - (HexagonH*2);
m = HexagonH / TileR;
}
+(NSPoint)hexFromX:(int)PixelX y:(int)PixelY
{
int SectX=0, SectY=0, SectPxlX=0, SectPxlY=0, ArrayX=0,ArrayY=0;
NSPoint myPoint;
SectX = PixelX / (2 * TileR);
SectY = PixelY / (HexagonH + HexagonS);
SectPxlX = PixelX % (2 * TileR);
SectPxlY = PixelY % (HexagonH + HexagonS);
if ((SectY & 1)==0)
{ // Type A
ArrayY = SectY;
ArrayX = SectX;
// Left edge
if (SectPxlY < (HexagonH - SectPxlX*m))
{
ArrayY = SectY - 1;
ArrayX = SectX - 1;
}
// Right edge
if (SectPxlY<(SectPxlX*m-HexagonH))
{
ArrayY = SectY - 1;
ArrayX = SectX;
}
}else{ // Type B
//right side
if (SectPxlX >= TileR)
{
if (SectPxlY < ((2 * HexagonH) - (SectPxlX * m)))
{
ArrayY = SectY - 1;
ArrayX = SectX;
}else{
ArrayY = SectY;
ArrayX = SectX;
}
}else{
// left side
if (SectPxlY < (SectPxlX * m))
{
ArrayY = SectY -1;
ArrayX = SectX;
}else{
ArrayY = SectY;
ArrayX = SectX-1;
}
}
}
myPoint.x = ArrayX;
myPoint.y = ArrayY;
return myPoint;
}
+(NSPoint)flatHexFromX:(int)PixelY y:(int)PixelX
{
int SectX=0, SectY=0, SectPxlX=0, SectPxlY=0, ArrayX=0,ArrayY=0;
NSPoint myPoint;
SectX = PixelX / (2 * TileR);
SectY = PixelY / (HexagonH + HexagonS);
SectPxlX = PixelX % (2 * TileR);
SectPxlY = PixelY % (HexagonH + HexagonS);
if ((SectY & 1)==0)
{ // Type A
ArrayY = SectY;
ArrayX = SectX;
// Left edge
if (SectPxlY < (HexagonH - SectPxlX*m))
{
ArrayY = SectY - 1;
ArrayX = SectX - 1;
}
// Right edge
if (SectPxlY<(SectPxlX*m-HexagonH))
{
ArrayY = SectY - 1;
ArrayX = SectX;
}
}else{ // Type B
//right side
if (SectPxlX >= TileR)
{
if (SectPxlY < ((2 * HexagonH) - (SectPxlX * m)))
{
ArrayY = SectY - 1;
ArrayX = SectX;
}else{
ArrayY = SectY;
ArrayX = SectX;
}
}else{
// left side
if (SectPxlY < (SectPxlX * m))
{
ArrayY = SectY -1;
ArrayX = SectX;
}else{
ArrayY = SectY;
ArrayX = SectX-1;
}
}
}
myPoint.x = ArrayY;
myPoint.y = ArrayX;
return myPoint;
}
+(NSPoint)pixelFromHexX:(int)ArrayX y:(int)ArrayY
{
NSPoint Pixel;
Pixel.x = ArrayX * 2 * TileR + (ArrayY & 1) * TileR;
Pixel.y = ArrayY * (HexagonH + HexagonS);
return Pixel;
}
+(NSPoint)pixelFromFlatHexX:(int)ArrayY y:(int)ArrayX
{
NSPoint Pixel;
Pixel.y = ArrayX * 2 * TileR + (ArrayY & 1) * TileR;
Pixel.x = ArrayY * (HexagonH + HexagonS);
return Pixel;
}
@end

View file

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Wesnoth Scenario Editor</string>
<key>CFBundleIconFile</key>
<string>MacIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>uk.co.fairydreams.wesnotheditor</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>é∂ít</string>
<key>CFBundleVersion</key>
<string>0.13</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View file

@ -1,18 +0,0 @@
//
// SelectionUtils.h
// Wesnoth Scenario Editor
// This is a collection of utilities to make handling list selections more transparent from 10.2 to 10.3+
// At a later date the code is easily replacable to ensure compatability
//
// Created by Marcus on Sat Apr 03 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SelectionUtils : NSObject {
}
+(NSArray *)selectionsFromView:(NSTableView *)myView;
+(void)selectionsToView:(NSTableView *)myView indexArray:(NSArray *)newSelections;
@end

View file

@ -1,37 +0,0 @@
//
// SelectionUtils.m
// Wesnoth Scenario Editor
// This is a collection of utilities to make handling list selections more transparent from 10.2 to 10.3+
// At a later date the code is easily replacable to ensure compatability
//
// Created by Marcus on Sat Apr 03 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "SelectionUtils.h"
@implementation SelectionUtils
+(NSArray *)selectionsFromView:(NSTableView *)myView
{
fprintf(stderr, "selectionsFromView\n");
return [[myView selectedRowEnumerator] allObjects];
}
+(void)selectionsToView:(NSTableView *)myView indexArray:(NSArray *)newSelections
{
int count = [newSelections count];
int rowSelected;
int loop;
[myView deselectAll: self];
fprintf(stderr, "selectionsToView\n");
for (loop=0; loop<count ;loop++)
{
rowSelected = [[newSelections objectAtIndex:loop] intValue];
[myView selectRow:rowSelected byExtendingSelection:YES];
}
}
@end

View file

@ -1,52 +0,0 @@
//
// WMLCampaign.h
// Wesnoth Scenario Editor
//
// Created by Marcus on Sat Mar 27 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WNCharacters.h"
#import "WMLSide.h"
#import "WMLMap.h"
#import "WMLScenario.h"
@interface WMLCampaign : NSObject {
NSMutableString *name; // name of campaign
NSMutableString *prefix; // prefix code
NSMutableArray *scenarios; // scenario list
WNCharacters *characters; // Characters
int activeScenarioIndex;
WMLScenario *activeScenario;
WMLMap *activeMap;
NSImage *campaignIcon;
NSMutableDictionary *difficultyIcons;
NSMutableDictionary *difficultyDescriptions;
}
-(WMLCampaign *)init;
-(void)dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
-(int)count;
-(WMLScenario *)getScenarioAtIndex: (int)index;
-(int) addScenario;
-(void)deleteScenario:(int)index;
-(WMLMap *)getActiveMap;
-(void)setActiveScenario:(int)scenarioIndex;
-(WMLScenario *)getActiveScenario;
-(WMLSide *)getActiveSide;
-(WNCharacters *)getCharacters;
-(void)setPrefix:(NSString *)newPrefix;
-(NSMutableString *)getPrefix;
-(void)setName:(NSString *)newName;
-(NSMutableString *)getName;
-(void)setIcon: (NSImage *)newIcon;
-(NSImage *)getIcon;
-(void)setDifficultyIcon: (NSImage *)newIcon forDifficulty:(NSString *)newDiff;
-(NSImage *)getDifficultyIconForDifficulty:(NSString *)newDiff;
-(void)setDifficultyDescription: (NSString *)newText forDifficulty:(NSString *)newDiff;
-(NSString *)getDifficultyDescriptionForDifficulty:(NSString *)newDiff;
-(void)exportToFolder:(NSString *)folder withDialog:(NSWindow *)saveDialog andIndicator:(NSProgressIndicator *)saveProgress;
@end

View file

@ -1,332 +0,0 @@
//
// WMLCampaign.m
// Wesnoth Scenario Editor
//
// Created by Marcus on Sat Mar 27 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLScenario.h"
#import "WNUnits.h"
#import "WNFileLocations.h"
#include "WNUtils.h"
#import "WMLCampaign.h"
@implementation WMLCampaign
-(WMLCampaign *)init
{
//[HexUtils initWithWidth:70];
fprintf(stderr, "WMLCampaign initialising\n");
[super init];
name = [[NSMutableString alloc] initWithString:@"untitled"];
[name retain];
prefix = [[NSMutableString alloc] initWithString:@"Replace Me"];
[prefix retain];
scenarios = [[NSMutableArray alloc] init];
[scenarios retain];
activeScenario = [[WMLScenario alloc] init];
[activeScenario retain];
activeScenarioIndex = 0;
activeMap = [activeScenario getMap];
[scenarios addObject:activeScenario];
characters = [[WNCharacters alloc] init];
fprintf(stderr, "WMLCampaign initialised\n");
NSSize tmpSize;
tmpSize.width = 16;
tmpSize.height = 16;
campaignIcon = [[NSImage alloc] initWithSize:tmpSize];
difficultyIcons = [[NSMutableDictionary alloc] init];
[difficultyIcons retain];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Easy"];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Normal"];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Hard"];
difficultyDescriptions = [[NSMutableDictionary alloc] init];
[difficultyDescriptions retain];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Easy"] forKey:@"Easy"];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Normal"] forKey:@"Normal"];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Hard"] forKey:@"Hard"];
return self;
}
-(void)dealloc
{
[name autorelease];
[prefix autorelease];
[scenarios autorelease];
[activeScenario autorelease];
[campaignIcon autorelease];
[difficultyIcons autorelease];
[difficultyDescriptions autorelease];
[super dealloc];
}
-(void)encodeWithCoder: (NSCoder *)coder
{
fprintf(stderr, "Enconding WMLCampaign\n");
[coder encodeObject: name forKey:@"name"];
[coder encodeObject: prefix forKey:@"prefix"];
[coder encodeObject: scenarios forKey:@"scenarios"];
[coder encodeObject: characters forKey:@"characters"];
[coder encodeInt: activeScenarioIndex forKey:@"activeScenarioIndex"];
[coder encodeObject: activeMap forKey:@"activeMap"];
[coder encodeObject: [WNUnits getUnitNames] forKey:@"unitLookup"];
[coder encodeObject: campaignIcon forKey:@"campaignIcon"];
[coder encodeObject: difficultyIcons forKey:@"difficultyIcons"];
[coder encodeObject: difficultyDescriptions forKey:@"difficultyDescriptions"];
fprintf(stderr, "WMLCampaign encoded\n");
}
- (id)initWithCoder:(NSCoder *)coder
{
fprintf(stderr, "WMLCampaign loading...");
[super init];
name = [[coder decodeObjectForKey:@"name"] retain];
prefix = [[coder decodeObjectForKey:@"prefix"] retain];
if (prefix == nil) prefix = [[[NSMutableString alloc] initWithString:@"Unknown Campaign"] retain];
scenarios = [[coder decodeObjectForKey:@"scenarios"] retain];
characters = [[coder decodeObjectForKey:@"characters"] retain];
activeScenarioIndex = [coder decodeIntForKey:@"activeScenarioIndex"];
activeMap = [[coder decodeObjectForKey:@"activeMap"] retain];
// OK, now we need to re-instate the map units
NSMutableArray *unitLookup = [[coder decodeObjectForKey:@"unitLookup"] retain];
NSMutableArray *unitConvert = [[[NSMutableArray alloc] init] retain];
int looper;
for (looper=0; looper<[unitLookup count]; looper++)
[unitConvert addObject:
[[NSNumber alloc] initWithInt:[WNUnits unitIndexForName:[unitLookup objectAtIndex:looper]]]];
for (looper=0; looper<[scenarios count] ;looper++)
[[[scenarios objectAtIndex:looper] getMap] updateUnitsWithLookup: unitConvert];
// OK, now the icons... new, so check for non-valid
NSSize tmpSize;
tmpSize.width = 16;
tmpSize.height = 16;
if ((campaignIcon = [[coder decodeObjectForKey:@"campaignIcon"] retain])==nil)
{
fprintf(stderr, "campaignIcon = nil...");
campaignIcon = [[[NSImage alloc] initWithSize:tmpSize] retain];
}
if ((difficultyIcons = [[coder decodeObjectForKey:@"difficultyIcons"] retain])==nil)
{
fprintf(stderr, "difficultyIcons = nil...");
difficultyIcons = [[NSMutableDictionary alloc] init];
[difficultyIcons retain];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Easy"];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Normal"];
[difficultyIcons setObject:[[NSImage alloc] initWithSize:tmpSize] forKey:@"Hard"];
}
if ((difficultyDescriptions = [[coder decodeObjectForKey:@"difficultyDescriptions"] retain])==nil)
{
fprintf(stderr, "difficultyDescriptions = nil...");
[difficultyDescriptions retain];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Easy"] forKey:@"Easy"];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Normal"] forKey:@"Normal"];
[difficultyDescriptions setObject:[[NSString alloc] initWithString:@"Hard"] forKey:@"Hard"];
}
fprintf(stderr, "WMLCampaign loaded\n");
return self;
}
-(int)count
{
return [scenarios count];
}
-(WMLScenario *)getScenarioAtIndex: (int)index
{
return [scenarios objectAtIndex: index];
}
-(int) addScenario
{ // Adds a scenario and returns the index
[scenarios addObject:[[WMLScenario alloc] init]];
return ([scenarios count]-1);
}
-(void)deleteScenario:(int)index
{
[scenarios removeObjectAtIndex: index];
NSNumber *num = [[NSNumber alloc] initWithInt:index];
[scenarios makeObjectsPerformSelector:@selector(checkDeletedScenario:) withObject:num];
}
-(WMLMap *)getActiveMap
{
return activeMap;
}
-(void)setActiveScenario:(int)scenarioIndex
{
fprintf(stderr, "Setting active scenario to: %d\n", scenarioIndex);
activeScenarioIndex = scenarioIndex;
activeScenario = [scenarios objectAtIndex: scenarioIndex];
activeMap = [activeScenario getMap];
}
-(WMLScenario *)getActiveScenario
{
return activeScenario;
}
-(WMLSide *)getActiveSide
{
return [activeScenario getActiveSide];
}
-(WNCharacters *)getCharacters
{
return characters;
}
-(void)setPrefix:(NSString *)newPrefix
{
[prefix setString:newPrefix];
}
-(NSMutableString *)getPrefix
{
return prefix;
}
-(void)setName:(NSString *)newName
{
[name setString: newName];
}
-(NSMutableString *)getName
{
return name;
}
-(void)setIcon: (NSImage *)newIcon
{
campaignIcon = newIcon;
[campaignIcon retain];
}
-(NSImage *)getIcon
{
return campaignIcon;
}
-(void)setDifficultyIcon: (NSImage *)newIcon forDifficulty:(NSString *)newDiff
{
[difficultyIcons setObject:newIcon forKey:newDiff];
}
-(NSImage *)getDifficultyIconForDifficulty:(NSString *)newDiff
{
return [difficultyIcons objectForKey:newDiff];
}
-(void)setDifficultyDescription: (NSString *)newText forDifficulty:(NSString *)newDiff
{
[difficultyDescriptions setObject: newText forKey:newDiff];
}
-(NSString *)getDifficultyDescriptionForDifficulty:(NSString *)newDiff
{
return [difficultyDescriptions objectForKey:newDiff];
}
-(void)exportToFolder:(NSString *)folder withDialog:(NSWindow *)saveDialog andIndicator:(NSProgressIndicator *)saveProgress
// This is the whole reason d'etre of the editor :D
{
FILE *fp;
int scenarioCount = [scenarios count];
NSMutableString *tmpString = [[NSMutableString alloc] init];
NSMutableString *iconString = [[NSMutableString alloc] initWithString:[prefix stringByAppendingString:@"CampaignIcon.png"]];
NSFileManager *fileManager = [NSFileManager defaultManager];
WMLScenario *tmpScenario;
if ([fileManager createDirectoryAtPath: folder attributes:nil])
{
// First we want to have an actual progress indicator, advancing with each scenario
[saveProgress setMinValue: 0.0];
[saveProgress setMaxValue: scenarioCount-1];
[saveProgress setDoubleValue: 0.0];
[saveProgress setIndeterminate: false];
// Create packaging sub-folder
NSString *tmpName = [WNUtils replaceSpaces:[prefix stringByAppendingString:name]];
[tmpString setString:[folder stringByAppendingPathComponent:tmpName]];
[fileManager createDirectoryAtPath: tmpString attributes:nil];
// Now create sub-folders
[WNFileLocations setExportDataLocation: [tmpString stringByAppendingPathComponent:@"data"]];
[WNFileLocations setExportUnitsLocation:[tmpString stringByAppendingPathComponent:@"units"]];
[WNFileLocations setExportScenariosLocation: [tmpString stringByAppendingPathComponent:@"scenarios"]];
[WNFileLocations setExportImagesLocation: [folder stringByAppendingPathComponent:@"images"]];
[fileManager createDirectoryAtPath: [WNFileLocations getExportDataLocation] attributes:nil];
[fileManager createDirectoryAtPath: [WNFileLocations getExportUnitsLocation] attributes:nil];
[fileManager createDirectoryAtPath: [WNFileLocations getExportScenariosLocation] attributes:nil];
[fileManager createDirectoryAtPath: [WNFileLocations getExportImagesLocation] attributes:nil];
// Now we export the campaign.cfg
fp = fopen([[[[WNFileLocations getExportScenariosLocation]
stringByAppendingPathComponent:tmpName]
stringByAppendingPathExtension:@"cfg"] UTF8String], "w\0");
fprintf(fp, "[campaign]\n");
fprintf(fp, "id=%s\n", [tmpName UTF8String]);
fprintf(fp, "name=%s\n", [name UTF8String]);
tmpScenario = [scenarios objectAtIndex:0];
fprintf(fp, "icon=%s\n", [iconString UTF8String]);
fprintf(fp, "define=%s\n", [[tmpName uppercaseString] UTF8String]);
fprintf(fp, "first_scenario=%s\n", [[WNUtils replaceSpaces: [prefix stringByAppendingString:[tmpScenario getName]]] UTF8String]);
fprintf(fp, "difficulties=EASY,NORMAL,HARD\n");
fprintf(fp, "difficulty_descriptions=&%s,%s,(easiest);*&%s,%s;&%s,%s,(hardest)\n",
[[prefix stringByAppendingString:@"difficultyIcon1.png"] UTF8String],
[[difficultyDescriptions objectForKey:@"Easy"] UTF8String],
[[prefix stringByAppendingString:@"difficultyIcon2.png"] UTF8String],
[[difficultyDescriptions objectForKey:@"Normal"] UTF8String],
[[prefix stringByAppendingString:@"difficultyIcon3.png"] UTF8String],
[[difficultyDescriptions objectForKey:@"Hard"] UTF8String]);
fprintf(fp, "[/campaign]\n");
// Now add extra packaging info
char *tmpUTF8;
tmpUTF8 = (char *)[tmpName UTF8String];
fprintf (fp,"{campaigns/%s/units}\n{~campaigns/%s/units}\n", tmpUTF8, tmpUTF8);
fprintf (fp,"#ifdef %s\n", [[tmpName uppercaseString] UTF8String]);
fprintf (fp, "{campaigns/%s/}\n{~campaigns/%s/}\n", tmpUTF8, tmpUTF8);
fprintf (fp, "{campaigns/%s/scenarios}\n{~campaigns/%s/scenarios}\n", tmpUTF8, tmpUTF8);
fprintf (fp, "[binary_path]\npath=data/campaigns/%s/\n[/binary_path]\n#endif\n", tmpUTF8);
fclose(fp);
// Now output the pngs
[WNUtils writeImage:campaignIcon
toPNGFile:[[WNFileLocations getExportImagesLocation]
stringByAppendingPathComponent:iconString]];
fprintf(stderr, "About to export difficulty PNGs\n");
[WNUtils writeImage:[difficultyIcons objectForKey:@"Easy"]
toPNGFile:[[[WNFileLocations getExportImagesLocation]
stringByAppendingPathComponent:prefix]
stringByAppendingString:@"difficultyIcon1.png"]];
[WNUtils writeImage:[difficultyIcons objectForKey:@"Normal"]
toPNGFile:[[[WNFileLocations getExportImagesLocation]
stringByAppendingPathComponent:prefix]
stringByAppendingString:@"difficultyIcon2.png"]];
[WNUtils writeImage:[difficultyIcons objectForKey:@"Hard"]
toPNGFile:[[[WNFileLocations getExportImagesLocation]
stringByAppendingPathComponent:prefix]
stringByAppendingString:@"difficultyIcon3.png"]];
// Now go through and export each scenario
int looper;
for (looper = 0; looper<scenarioCount ;looper++)
{
fprintf(stderr, "Exporting scenario:%d\n", looper);
[saveProgress setDoubleValue: looper];
[[scenarios objectAtIndex:looper] exportToFolderWithPrefix:prefix scenarios:scenarios];
}
}else{
fprintf(stderr, "Folder creation failed\n");
}
}
@end

View file

@ -1,46 +0,0 @@
//
// WMLEvent.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon May 24 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WMLEvent : NSObject {
NSMutableString *name;
NSMutableString *tag;
NSMutableString *stringValue;
int intValue;
NSPoint mapLoc;
BOOL isTag; // Set to yes if this is a tag, no if this is description-value pair
int type; // 0=none, 1=character, 2=unit, 3=side, 4=maploc, 5=info, 6=text
NSMutableArray *children;
WMLEvent *parent;
}
-(WMLEvent *)initAsTag:(BOOL)setTag withName:(NSString *)newName withStringValue:(NSString *)newValue withIntValue:(int)newInt withType:(int)newType withParent:(WMLEvent *)newParent;
-(WMLEvent *)initAsTag:(BOOL)newTag withType:(int)newType withParent:(WMLEvent *)newParent;
-(WMLEvent *)initWithWMLTag:(WMLTag *)tag withParent:(WMLEvent *)newParent;
- (void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(void)dealloc;
-(void)setEventName:(NSString *)newName;
-(NSString *)getEventName;
-(void)setEventValue:(int)newValue string:(NSString *)newString;
-(NSString *)getEventStringValue;
-(void)setEventIntValue:(int)newVal;
-(int)getEventIntValue;
-(int)noEventChildren;
-(void)addEventChild:(WMLEvent *)newEventChild;
-(void)removeEventChild:(WMLEvent *)eventChild;
-(WMLEvent *)getEventChildAtIndex:(int)index;
-(BOOL)isEventATag;
-(int)getEventType;
-(WMLEvent *)getEventParent;
-(void)setEventMapLoc:(NSPoint)mapPos;
-(NSPoint)getEventMapLoc;
-(NSMutableString *)getEventTag;
-(void)exportEventToString:(NSMutableString *)outputString;
@end

View file

@ -1,280 +0,0 @@
//
// WMLEvent.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon May 24 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLEvent.h"
#import "WNUnits.h"
#import "WNEventLookup.h"
@implementation WMLEvent
-(WMLEvent *)initAsTag:(BOOL)setTag withName:(NSString *)newName withStringValue:(NSString *)newValue withIntValue:(int)newInt withType:(int)newType withParent:(WMLEvent *)newParent
{
name = [[[NSMutableString alloc] initWithString:newName] retain];
tag = [[[NSMutableString alloc] initWithString:newName] retain];
stringValue = [[[NSMutableString alloc] initWithString:newValue] retain];
intValue = 0;
mapLoc.x = 0;
mapLoc.y = 0;
isTag = setTag;
type = newType;
parent = newParent;
children = [[[NSMutableArray alloc] init] retain];
return self;
}
-(WMLEvent *)initAsTag:(BOOL)newTag withType:(int)newType withParent:(id)newParent
{
return [self initAsTag:newTag withName:@"" withStringValue:@"" withIntValue:0 withType:newType withParent:newParent];
}
-(WMLEvent *)initWithWMLTag:(WMLTag *)wmlTag withParent:(WMLEvent *)newParent
{ // Takes a WMLTag heirarchy and creates an event heirarchy to match
// First create parent
WMLEvent *child;
NSString *value, *setting, *strSetting;
fprintf(stderr, "initWithWMLTag...%s\n", [[wmlTag getTag] cString]);
/* WMLEvent *thisEvent = [[[WMLEvent alloc] initAsTag:YES withName:[tag getTag] withStringValue:@"" withIntValue:0 withType:0 withParent:newParent] retain];*/
[self initAsTag:YES withName:[wmlTag getTag] withStringValue:@"" withIntValue:0 withType:0 withParent:newParent];
NSArray *settings = [wmlTag getTagSettingKeys];
int i, thisType, intSetting;
fprintf(stderr,"initWithWMLTag found %d settings...\n", [settings count]);
for (i=0; i<[settings count] ; i++)
{
setting = [settings objectAtIndex:i];
value = [wmlTag getSettingFor:setting];
thisType = [WNEventLookup typeForSetting:value];
fprintf(stderr, "Type:%d... for *%s*", thisType, [value cString]);
switch(thisType)
{
case 0: // No Value
intSetting = 0;
strSetting =@"";
break;
case 1: // Character
intSetting = 0;
strSetting = [[[WNCampaign getMainCampaign] getCharacters] getNameAtIndex:0];
break;
case 2: // Unit
intSetting = 0;
strSetting = [WNUnits unitNameAtIndex:0];
break;
case 3: // Side;
intSetting = 0;
strSetting = [[[WNCampaign getActiveScenario] getSideAtIndex:0] getName];
break;
case 4: // maploc
intSetting = 0;
strSetting = @"x=0, y=0";
break;
case 5: // text
intSetting = 0;
strSetting = @"Set me!";
break;
default:
intSetting = 0;
strSetting = @"unknown";
break;
}
fprintf(stderr, "Setting:%d str:%s\n", i, [strSetting cString]);
child = [[WMLEvent alloc] initAsTag:NO withName:setting withStringValue:strSetting withIntValue:intSetting withType:thisType withParent:self];
[children addObject: child];
}
return self;
}
- (void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeObject:name forKey:@"name"];
[coder encodeObject:tag forKey:@"tag"];
[coder encodeObject:stringValue forKey:@"stringValue"];
[coder encodeInt:intValue forKey:@"intValue"];
[coder encodePoint:mapLoc forKey:@"mapLoc"];
[coder encodeInt:isTag forKey:@"isTag"];
[coder encodeInt:type forKey:@"type"];
[coder encodeObject:children forKey:@"children"];
[coder encodeObject:parent forKey:@"parent"];
}
- (id)initWithCoder:(NSCoder *)coder
{
fprintf(stderr, "[WMLEvent] initWithCoder\n");
[super init];
name = [coder decodeObjectForKey:@"name"];
[name retain];
tag = [coder decodeObjectForKey:@"tag"];
[tag retain];
stringValue = [coder decodeObjectForKey:@"stringValue"];
[stringValue retain];
intValue = [coder decodeIntForKey:@"intValue"];
mapLoc = [coder decodePointForKey:@"mapLoc"];
isTag = [coder decodeIntForKey:@"isTag"];
type = [coder decodeIntForKey:@"type"];
children = [coder decodeObjectForKey:@"children"];
[children retain];
parent = [coder decodeObjectForKey:@"parent"];
return self;
}
-(void)dealloc
{
[name autorelease];
[tag autorelease];
[stringValue autorelease];
[children autorelease];
}
-(void)setEventName:(NSString *)newName
{
[name setString:newName];
}
-(NSString *)getEventName
{
return name;
}
-(void)setEventValue:(int)newValue string:(NSString *)newString
{
[stringValue setString:newString];
intValue = newValue;
}
-(NSString *)getEventStringValue
{
char tmpBuf[20];
switch(type)
{
case 1: // Character
[stringValue setString: [[[WNCampaign getMainCampaign] getCharacters] getNameAtIndex:intValue]];
break;
case 2: // Unit
[stringValue setString: [WNUnits unitNameAtIndex: intValue]];
break;
case 3: // Side
[stringValue setString: [[[WNCampaign getActiveScenario] getSideAtIndex:intValue] getName]];
break;
case 4: // Maploc
sprintf(tmpBuf,"x=%g, y=%g", mapLoc.x, mapLoc.y);
[stringValue setString:[NSString stringWithCString: tmpBuf]];
break;
}
return stringValue;
}
-(void)setEventIntValue:(int)newVal
{
intValue = newVal;
}
-(int)getEventIntValue
{
return intValue;
}
-(int)noEventChildren
{
return [children count];
}
-(void)addEventChild:(WMLEvent *)newEventChild
{
if (newEventChild == nil) fprintf(stderr, "ERROR - Added nil child\n");
[children addObject:newEventChild];
}
-(void)removeEventChild:(WMLEvent *)eventChild
{
[children removeObjectIdenticalTo:eventChild];
}
-(WMLEvent *)getEventChildAtIndex:(int)index
{
return [children objectAtIndex:index];
}
-(BOOL)isEventATag
{
return isTag;
}
-(int)getEventType
{
return type;
}
-(WMLEvent *)getEventParent
{
return parent;
}
-(void)setEventMapLoc:(NSPoint)mapPos
{
mapLoc = mapPos;
}
-(NSPoint)getEventMapLoc
{
return mapLoc;
}
-(NSMutableString *)getEventTag
{
return tag;
}
-(void)exportEventToString:(NSMutableString *)outputString
{ // parses the event as text and appends to the outputstring. Recurses through children
[outputString appendString:@"\n"];
int childLoop;
int childCount;
NSMutableString *closeTag = [[NSMutableString alloc] init];
char buf[64];
if ([self isEventATag])
{
[outputString appendString:tag];
childCount = [children count];
for (childLoop = 0; childLoop<childCount ;childLoop++) [[children objectAtIndex:childLoop] exportEventToString:outputString];
[outputString appendString:@"\n"];
[closeTag setString:tag];
[closeTag insertString:@"/" atIndex:1];
[outputString appendString:closeTag];
}else{
[outputString appendString:tag];
[outputString appendString:@"="];
switch(type)
{
case 1: // Character
[outputString appendString: [[[WNCampaign getMainCampaign] getCharacters] getNameAtIndex:intValue]];
break;
case 2: // Unit
[outputString appendString: [WNUnits unitNameAtIndex: intValue]];
break;
case 3: // Side
sprintf(buf,"%d",intValue);
[outputString appendString:[NSString stringWithCString:buf]];
break;
case 4: // Maploc
sprintf(buf,"x=%g,y=%g",mapLoc.x,mapLoc.y);
[outputString appendString: [NSString stringWithCString:buf]];
break;
case 5: // Info
break;
case 6: // Text
[outputString appendString:stringValue];
break;
}
[outputString appendString:@"\n"];
}
}
@end

View file

@ -1,16 +0,0 @@
[scenario]
[time_area]
help=Specifies a separate day / night schedule for given area
x = MapXRange|Location of area
y = MapYRange|Location of area
{dayschedules}
[/time_area]
[/scenario]
[terrain]
help=Specifies individual terrain tile
gives_income=BOOL|Flag specifying whether this tile generates income
heals=BOOL|Flag specifying whether this tile heals units or not
recruit_from=BOOL|Specifies whether a leader can recruit when standing on this tile
recruit_onto=BOOL|Specifies whether units can be recruited onto this tile
[/terrain]

View file

@ -1,39 +0,0 @@
//
// WNMap.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WMLMapPoint.h"
#import "WMLTerrain.h"
@interface WMLMap : NSObject {
int width;
int height;
NSMutableArray *mapData; // mapdata holds rows each row is an array
}
-(WMLMap *)initWithSize: (int)xsize by: (int)ysize;
-(void)dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(void)setWidth: (int)newWidth;
-(void)setHeight: (int)newHeight;
-(void)resizeTo: (int)xSize by: (int)ySize;
-(NSMutableArray *)getRow: (int)index;
-(int)getWidth;
-(int)getHeight;
-(void)setPointToTerrain:(int)idNo x:(int)x y:(int)y;
-(void)setPointToUnit:(int)idNo type:(int)newType side:(int)newSide x:(int)x y:(int)y;
-(void)clearUnitAtPointX:(int) xPos y:(int)yPos;
-(void)exportToFile: (NSString *)saveFile;
-(NSPoint)importFromFile: (NSString *)importFile;
-(void)updateUnitsWithLookup:(NSMutableArray *)unitConvert;
-(NSMutableString *)exportToString;
-(NSMutableString *)getUnitListForDifficulty:(NSString *)diff forSide:(int)side;
-(WMLMapPoint *)getMapPointAtX:(int)x Y:(int)y;
-(void)iterateSelector:(SEL)mySelector withObject:(id)myObject;
@end

View file

@ -1,388 +0,0 @@
//
// WNMap.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLMap.h"
#import "WMLMapPoint.h"
#import "WNTerrains.h"
#import "WNUnits.h"
@implementation WMLMap
-(WMLMap *)initWithSize: (int)xsize by: (int)ysize
{
int loopx=0, loopy=0, grassIndex=0;
NSMutableArray *row=nil;
WMLMapPoint *point=nil;
[super init];
fprintf(stderr, "WMLMap initWithSize\n");
grassIndex = [WNTerrains terrainForCode:@"g"];
mapData = [[NSMutableArray alloc]init];
[mapData retain];
width = xsize;
height = ysize;
for (loopy=0 ;loopy<height ;loopy++)
{
row = [[NSMutableArray alloc] init];
for (loopx=0; loopx<width ;loopx++)
{
point = [[WMLMapPoint alloc] initWithCode: 'g' index:grassIndex];
[row addObject: point];
}
[mapData addObject: row];
}
fprintf(stderr, "WMLMap initialised\n");
return self;
}
-(void)dealloc
{
[mapData autorelease];
[super dealloc];
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeInt: width forKey:@"width"];
[coder encodeInt: height forKey:@"height"];
[coder encodeObject: mapData forKey:@"mapData"];
}
- (id)initWithCoder:(NSCoder *)coder
{
fprintf(stderr, "[WMLMap initWithCoder]\n");
[super init];
width = [coder decodeIntForKey:@"width"];
height = [coder decodeIntForKey:@"height"];
mapData = [[coder decodeObjectForKey:@"mapData"] retain];
return self;
}
-(void)setWidth: (int)newWidth
{
[self resizeTo: newWidth by: height];
}
-(void)setHeight: (int)newHeight
{
// fprintf(stderr, "Setting map height to %d\n", newHeight);
[self resizeTo: width by: newHeight];
}
-(void)resizeTo: (int)xSize by: (int)ySize
{
int loopX=0, loopY=0, grassIndex=0;
NSMutableArray *row;
NSRange rangeToRemove;
grassIndex = [WNTerrains terrainForCode:@"g"];
fprintf(stderr, "Resizing map to %d by %d\n", xSize, ySize);
// first remove any extra rows
if (ySize<height)
{
rangeToRemove.location = ySize;
rangeToRemove.length = (height - ySize);
[mapData removeObjectsInRange: rangeToRemove];
height = ySize;
}
// Now let us go through each row
for (loopY=0; loopY<height ;loopY++)
{
row = [mapData objectAtIndex:loopY];
if (xSize<width)
{
rangeToRemove.location = xSize;
rangeToRemove.length = (width - xSize);
[row removeObjectsInRange: rangeToRemove];
}
if (xSize>width)
for (loopX=width; loopX<xSize ;loopX++) [row addObject:[[WMLMapPoint alloc] initWithCode: 'g' index:grassIndex]];
}
// Now add new rows if needed
if (ySize>height)
for (loopY = height; loopY<ySize ;loopY++)
{
row = [[NSMutableArray alloc] init];
for (loopX=0; loopX<xSize ;loopX++) [row addObject:[[WMLMapPoint alloc] initWithCode: 'g' index:grassIndex]];
[mapData addObject: row];
}
height = ySize;
width = xSize;
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
}
-(NSMutableArray *)getRow: (int)index
{
if (index < [mapData count])
{
return [mapData objectAtIndex: index];
}
return nil;
}
-(int)getWidth
{
return width;
}
-(int)getHeight
{
return height;
}
-(void)setPointToTerrain:(int)idNo x:(int)x y:(int)y
{
WMLTerrain *tmpTerrain = [WNTerrains terrainAtIndex:idNo];
NSMutableArray *row = [mapData objectAtIndex:y];
WMLMapPoint *mapItem = [row objectAtIndex: x];
[mapItem setTerrainID: idNo];
[mapItem setCodeWithString: [tmpTerrain terrainCode]];
}
-(void)setPointToUnit:(int)idNo type:(int)newType side:(int)newSide x:(int)x y:(int)y
{
NSMutableArray *row = [mapData objectAtIndex:y];
WMLMapPoint *mapItem = [row objectAtIndex: x];
if ([WNPreferences getPlaceEasy] == YES)
[mapItem setUnitID: idNo type:newType side:newSide forDifficulty:@"Easy"];
if ([WNPreferences getPlaceNormal] == YES)
[mapItem setUnitID: idNo type:newType side:newSide forDifficulty:@"Normal"];
if ([WNPreferences getPlaceHard] == YES)
[mapItem setUnitID: idNo type:newType side:newSide forDifficulty:@"Hard"];
fprintf(stderr, "Placed unit at %d x %d\n", x, y);
}
-(void)clearUnitAtPointX:(int) x y:(int)y
{
NSMutableArray *row = [mapData objectAtIndex:y];
WMLMapPoint *mapItem = [row objectAtIndex: x];
if ([WNPreferences getPlaceEasy] == YES)
[mapItem clearUnitForDifficulty:@"Easy"];
if ([WNPreferences getPlaceNormal] == YES)
[mapItem clearUnitForDifficulty:@"Normal"];
if ([WNPreferences getPlaceHard] == YES)
[mapItem clearUnitForDifficulty:@"Hard"];
fprintf(stderr, "Clearing units from x:%d, y:%d\n", x, y);
}
-(void)updateMapPointUnitsWith:(NSArray *)lookup
{
int y,x;
NSMutableArray *row;
WMLMapPoint *mapItem;
for (y=0; y<height ;y++)
{
row = [mapData objectAtIndex:y];
for (x=0; x<width ; x++)
{
mapItem = [row objectAtIndex:x];
}
}
}
-(void)exportToFile: (NSString *)saveFile
{
int loopX=0,loopY=0;
NSMutableArray *row;
WMLMapPoint *tmpPoint;
fprintf(stderr, "about to export map to:%s\n", [saveFile UTF8String]);
FILE *efp = fopen([saveFile fileSystemRepresentation], "w");
for (loopY=0; loopY<height ;loopY++)
{
row = [mapData objectAtIndex: loopY];
for (loopX=0; loopX<width ;loopX++)
{
tmpPoint = [row objectAtIndex: loopX];
fputc([tmpPoint getCode], efp);
}
fputc('\n', efp);
}
fclose(efp);
}
-(NSMutableString *)exportToString
{
int loopX=0,loopY=0;
NSMutableArray *row;
WMLMapPoint *tmpPoint;
char buffer[20000];
int curLoc = 0;
fprintf(stderr, "about to export map to string\n");
for (loopY=0; loopY<height ;loopY++)
{
row = [mapData objectAtIndex: loopY];
for (loopX=0; loopX<width ;loopX++)
{
tmpPoint = [row objectAtIndex: loopX];
buffer[curLoc++] = [tmpPoint getCode];
}
buffer[curLoc++] = '\n';
}
curLoc = curLoc - 1;
buffer[curLoc] = 0;
NSMutableString *tmpMap = [[NSMutableString alloc] initWithUTF8String:buffer];
[tmpMap retain];
return tmpMap;
}
-(NSPoint)importFromFile: (NSString *)importFile
{
int xs=0, ys=0, tmpLen=0, xpos=0,ypos=0;
char tmpStr[1024];
NSMutableArray *row;
FILE *fp = fopen([importFile fileSystemRepresentation], "r");
fprintf(stderr, "Examining file: %s for import\n", [importFile UTF8String]);
while(fscanf(fp,"%s",tmpStr)!=EOF)
{
tmpLen = strlen(tmpStr);
if ((tmpLen>xs)&&(tmpLen>5)&&(xs==0)) xs = tmpLen;
if (tmpLen == xs) ys++;
}
fclose(fp);
fprintf(stderr,"Calculated size: %d by %d\n", xs, ys);
[self resizeTo: xs by: ys];
// second pass parsing :D
fp = fopen([importFile fileSystemRepresentation], "r");
fprintf(stderr, "Parsing file: %s for import\n", [importFile UTF8String]);
while((fscanf(fp,"%s",tmpStr)!=EOF)&&(ypos<ys))
{
row = [mapData objectAtIndex: ypos];
tmpLen = strlen(tmpStr);
fprintf(stderr, "Parsing: %s\n", tmpStr);
if (tmpLen == xs)
{
fprintf(stderr,"Assigning\n");
for (xpos=0; xpos<xs ;xpos++)
{
[row replaceObjectAtIndex: xpos withObject:[[WMLMapPoint alloc] initFromCode:tmpStr[xpos]]];
}
}
ypos++;
}
fclose(fp);
fprintf(stderr, "Parsing complete\n");
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
NSPoint returnPoint;
returnPoint.x = xs;
returnPoint.y = ys;
return returnPoint;
}
-(void)updateUnitsWithLookup:(NSMutableArray *)unitConvert
{
int x,y;
WMLMapPoint *tmpPoint;
NSMutableArray *row;
for (y=0; y<height ;y++)
{
row = [mapData objectAtIndex:y];
for (x=0; x<width ;x++)
{
tmpPoint = [row objectAtIndex:x];
[tmpPoint updateMapPointUnits: unitConvert forDifficulty:@"Easy"];
[tmpPoint updateMapPointUnits: unitConvert forDifficulty:@"Normal"];
[tmpPoint updateMapPointUnits: unitConvert forDifficulty:@"Hard"];
}
}
}
-(NSMutableString *)getUnitListForDifficulty:(NSString *)diff forSide:(int)side
{
int loopX=0,loopY=0, tmpUnit, tmpType, tmpSide;
NSMutableArray *row;
NSMutableString *data = [[[NSMutableString alloc] init] retain];
NSMutableString *t1 = [[NSMutableString alloc] init];
NSMutableString *t2 = [[NSMutableString alloc] init];
NSMutableString *t3 = [[NSMutableString alloc] init];
WMLMapPoint *tmpPoint;
WNCharacters *chars = [[WNCampaign getMainCampaign] getCharacters];
char buffer[20000];
fprintf(stderr, "about to compile unit info to string\n");
for (loopY=0; loopY<height ;loopY++)
{
row = [mapData objectAtIndex: loopY];
for (loopX=0; loopX<width ;loopX++)
{
tmpPoint = [row objectAtIndex: loopX];
tmpUnit = [[tmpPoint getUnitIDForDifficulty:diff] intValue];
tmpType = [[tmpPoint getUnitTypeForDifficulty:diff] intValue];
tmpSide = [[tmpPoint getUnitSideForDifficulty:diff] intValue];
if (tmpSide == side)
{
switch(tmpType)
{
case 1: // This is a unit
sprintf(buffer, "[unit]\ntype=%s\nx=%d\ny=%d\nside=%d\n[/unit]\n\n",
[[WNUnits unitNameAtIndex:tmpUnit] UTF8String], (loopX+1), (loopY+1), (tmpSide+1));
[data appendString:[NSString stringWithUTF8String: buffer]];
break;
case 2: // This is a character
if ([[chars getAIAtIndex:tmpUnit] isEqualTo:@"default"])
{
[t3 setString:@""];
}else{
[t3 setString:@"ai_special=\""];
[t3 appendString:[chars getAIAtIndex:tmpUnit]];
[t3 appendString:@"\"\n"];
}
[WNPreferences fillWithTraitTags: t1 forTrait:[chars getTrait:1 atIndex:tmpUnit]];
[WNPreferences fillWithTraitTags: t2 forTrait:[chars getTrait:2 atIndex:tmpUnit]];
sprintf(buffer, "[unit]\ndescription=%s\ntype=%s\nx=%d\ny=%d\nside=%d\ntraits_description=\"%s,%s\"\n[modifications]\n%s%s[/modifications]\n%s[/unit]\n\n",
[[chars getNameAtIndex:tmpUnit] UTF8String],
[[WNUnits unitNameAtIndex:[chars getUnitTypeAtIndex:tmpUnit]] UTF8String],
(loopX+1), (loopY+1), (tmpSide+1),
[[chars getTrait:1 atIndex:tmpUnit] UTF8String],
[[chars getTrait:2 atIndex:tmpUnit] UTF8String],
[t1 UTF8String],[t2 UTF8String],[t3 UTF8String]);
[data appendString:[NSString stringWithUTF8String: buffer]];
[chars setInPlay:tmpUnit];
break;
}
}
}
}
return data;
}
-(WMLMapPoint *)getMapPointAtX:(int)x Y:(int)y
{
return [[mapData objectAtIndex: y] objectAtIndex:x];
}
-(void)iterateSelector:(SEL)mySelector withObject:(id)myObject
{
int x,y;
NSMutableArray *row;
for(y=0; y<height ;y++)
{
row = [mapData objectAtIndex:y];
for (x=0; x<width ;x++) [[row objectAtIndex:x] performSelector:mySelector withObject:myObject];
}
}
@end

View file

@ -1,38 +0,0 @@
//
// WNMapPoint.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WNCharacters.h"
@interface WMLMapPoint : NSObject {
int terrainID; // terrain ID
char code; // Ascii Code
NSMutableDictionary *unitID; // Unit IDs for any unit
NSMutableDictionary *unitType; // Unit type, 1 = standard, 2 = character
NSMutableDictionary *unitSide; // Side for the unit
}
-(WMLMapPoint *)init;
-(WMLMapPoint *)initWithCode: (char)terrainCode index:(int)terrainIndex;
-(WMLMapPoint *)initFromCode: (char)terrainCode;
-(void)dealloc;
-(int)terrainID;
-(void)setTerrainID:(int)newID;
-(void)setCode:(char)newCode;
-(char)getCode;
-(void)setCodeWithString:(NSString *)newCode;
-(void)setUnitID: (int)myID type:(int)myType side:(int)mySide forDifficulty:(NSString *)myDiff;
-(void)clearUnitForDifficulty:(NSString *)myDiff;
-(NSNumber *)getUnitIDForDifficulty:(NSString *)myDiff;
-(NSNumber *)getUnitTypeForDifficulty:(NSString *)myDiff;
-(NSNumber *)getUnitSideForDifficulty:(NSString *)myDiff;
-(void)updateMapPointUnits:(NSMutableArray *)unitConvert forDifficulty:(NSString *)myDiff;
-(void)mapPointUnitInfoToString:(NSMutableString *)desc characterTo:(NSMutableString *)cDesc characters:(WNCharacters *)chars;
-(void)mapPointCharacterInfoForDifficulty:(NSString *)diff toString:(NSMutableString *)desc characterTo:(NSMutableString *)cDesc characters:(WNCharacters *)chars;
-(void)deleteSideWithDict:(NSMutableDictionary *)myDict;
@end

View file

@ -1,220 +0,0 @@
//
// WNMapPoint.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLMapPoint.h"
#import "WNTerrains.h"
#import "WNUnits.h"
#import "WNCharacters.h"
@implementation WMLMapPoint
-(WMLMapPoint *)init
{
[self initWithCode: 0 index: 0];
return self;
}
-(WMLMapPoint *)initWithCode: (char)terrainCode index:(int)terrainIndex
{
[super init];
terrainID = terrainIndex;
code = terrainCode;
unitID = [[NSMutableDictionary alloc] init];
unitType = [[NSMutableDictionary alloc] init];
unitSide = [[NSMutableDictionary alloc] init];
[unitID retain];
[unitType retain];
[unitSide retain];
return self;
}
-(WMLMapPoint *)initFromCode: (char)terrainCode
{
char tmpBuf[2];
int terrainNo;
tmpBuf[0] = terrainCode;
tmpBuf[1] = 0;
NSString *tmpString = [NSString stringWithUTF8String: tmpBuf];
terrainNo = [WNTerrains terrainForCode: tmpString];
if (terrainNo == -1) terrainNo = [WNTerrains terrainForCode:@"g"];
return [self initWithCode: terrainCode index: terrainNo];
}
-(void)dealloc
{
[unitID autorelease];
[unitType autorelease];
[unitSide autorelease];
[super dealloc];
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeInt: code forKey:@"code"];
[coder encodeObject: unitID forKey:@"unitID"];
[coder encodeObject: unitType forKey:@"unitType"];
[coder encodeObject: unitSide forKey:@"unitSide"];
}
- (id)initWithCoder:(NSCoder *)coder
{
[super init];
code = [coder decodeIntForKey:@"code"];
terrainID = [WNTerrains terrainForChar:code];
unitID = [[coder decodeObjectForKey:@"unitID"] retain];
unitType = [[coder decodeObjectForKey:@"unitType"] retain];
unitSide = [[coder decodeObjectForKey:@"unitSide"] retain];
return self;
}
-(int)terrainID
{
return terrainID;
}
-(void)setTerrainID:(int)newID
{
terrainID = newID;
}
-(void)setCode:(char)newCode
{
code = newCode;
}
-(char)getCode
{
return code;
}
-(void)setCodeWithString:(NSString *)newCode
{
if ([newCode characterAtIndex:0]=='"')
{
}else{
code = [newCode characterAtIndex:0];
}
}
-(void)setUnitID: (int)myID type:(int)myType side:(int)mySide forDifficulty:(NSString *)myDiff
{
[unitID setObject:[[NSNumber alloc] initWithInt:myID] forKey:myDiff];
[unitType setObject:[[NSNumber alloc] initWithInt:myType] forKey:myDiff];
[unitSide setObject:[[NSNumber alloc] initWithInt:mySide] forKey:myDiff];
fprintf(stderr, "MapPoint updated for unit:%d and difficulty: %s\n", myID, [myDiff UTF8String]);
}
-(void)clearUnitForDifficulty:(NSString *)myDiff
{
[unitID removeObjectForKey:myDiff];
[unitType removeObjectForKey:myDiff];
[unitSide removeObjectForKey:myDiff];
fprintf(stderr, "MapPoint updated, unit removed\n");
}
-(NSNumber *)getUnitIDForDifficulty:(NSString *)myDiff
{
return [unitID objectForKey:myDiff];
}
-(NSNumber *)getUnitTypeForDifficulty:(NSString *)myDiff
{
return [unitType objectForKey:myDiff];
}
-(NSNumber *)getUnitSideForDifficulty:(NSString *)myDiff
{
return [unitSide objectForKey:myDiff];
}
-(void)updateMapPointUnits:(NSMutableArray *)unitConvert forDifficulty:(NSString *)myDiff
{
NSNumber *tmpNum;
tmpNum = [unitType objectForKey: myDiff];
if (tmpNum !=nil)
if ([tmpNum intValue]==1)
[unitID setObject:[unitConvert objectAtIndex:
[[unitID objectForKey:myDiff] intValue]] forKey:myDiff];
}
-(void)mapPointUnitInfoToString:(NSMutableString *)desc characterTo:(NSMutableString *)cDesc characters:(WNCharacters *)chars
{
[desc setString:@""];
[cDesc setString:@""];
[self mapPointCharacterInfoForDifficulty:@"Easy" toString:desc characterTo: cDesc characters:chars];
[self mapPointCharacterInfoForDifficulty:@"Normal" toString:desc characterTo: cDesc characters:chars];
[self mapPointCharacterInfoForDifficulty:@"Hard" toString:desc characterTo: cDesc characters:chars];
}
-(void)mapPointCharacterInfoForDifficulty:(NSString *)diff toString:(NSMutableString *)desc characterTo:(NSMutableString *)cDesc characters:(WNCharacters *)chars
{
int tmpType, tmpID, tmpSide;
NSNumber *tmpTypeNum = [self getUnitTypeForDifficulty:diff];
if (tmpTypeNum == nil) return;
tmpType = [tmpTypeNum intValue];
tmpID = [[self getUnitIDForDifficulty:diff] intValue];
tmpSide = [[self getUnitSideForDifficulty:diff] intValue];
fprintf(stderr, "Map Info: type=%d, ID=%d, Side=%d\n", tmpType, tmpID, tmpSide);
switch(tmpType)
{
case 1: // Unit
[desc appendString:diff];
[desc appendString:@": "];
[desc appendString:[WNUnits unitNameAtIndex: tmpID]];
[desc appendString:@" side: "];
[desc appendString:[[[WNCampaign getActiveScenario] getSideAtIndex: tmpSide] getName]];
[desc appendString:@"\n"];
break;
case 2: // Character
[cDesc appendString:diff];
[cDesc appendString:@": "];
[cDesc appendString:[chars getNameAtIndex: tmpID]];
[cDesc appendString:@" side: "];
[cDesc appendString:[[[WNCampaign getActiveScenario] getSideAtIndex: tmpSide] getName]];
[cDesc appendString:@"\n"];
break;
}
}
-(void)deleteSideWithDict:(NSMutableDictionary *)myDict
{
int myMode = [[myDict objectForKey:@"mode"] intValue]; // 1= look, 2 = delete
int side = [[myDict objectForKey:@"side"] intValue];
int count = [[myDict objectForKey:@"count"] intValue];
NSNumber *myNum;
NSArray *diffs = [[NSArray alloc] initWithObjects:@"Easy",@"Normal",@"Hard",nil];
int loop, thisSide;
for (loop=0; loop<[diffs count]; loop++)
{
myNum = [unitSide objectForKey:[diffs objectAtIndex:loop]];
if (myNum != nil)
{
thisSide = [myNum intValue];
if (thisSide == side)
{
[myDict setObject:[[NSNumber alloc] initWithInt:(count+1)] forKey:@"count"];
if (myMode==2) [self clearUnitForDifficulty: [diffs objectAtIndex:loop]];
}else if (thisSide> side){
[unitSide setObject:[[NSNumber alloc] initWithInt:(thisSide-1)] forKey:[diffs objectAtIndex:loop]];
}
}
}
}
@end

View file

@ -1,59 +0,0 @@
//
// WMLScenario.h
// Wesnoth Scenario Editor
//
// Created by Marcus on Sat Mar 27 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLScenarioDetails.h"
@interface WMLScenario : NSObject {
NSMutableString *name;
int winID;
int loseID;
int continueID;
int activeSideIndex;
WMLSide *activeSide;
NSMutableArray *sides;
NSMutableArray *teams;
NSMutableDictionary *victoryConditions;
NSMutableDictionary *defeatConditions;
NSMutableDictionary *details;
WMLMap *map;
NSMutableArray *events;
NSMutableString *advancedInfo;
}
-(WMLScenario *)init;
-(void)dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(NSString *)getName;
-(void)setName:(NSString *)newName;
-(WMLMap *)getMap;
-(int)getSidesCount;
-(WMLSide *)getSideAtIndex:(int)index;
-(int)addSide;
-(WMLSide *)getActiveSide;
-(void)setActiveSide:(int)sideNo;
-(void)deleteSide:(int)sideToDie;
-(NSMutableArray *)getDefeatConditionsFor:(NSString *)diffLevel;
-(NSMutableArray *)getVictoryConditionsFor:(NSString *)diffLevel;
-(WMLScenarioDetails *)getDetailsFor:(NSString *)diffLevel;
-(NSMutableArray *)getTeams;
-(void)setScenarioAdvancedInfo: (NSString *)newInfo;
-(NSString *)getScenarioAdvancedInfo;
-(void)exportToFolderWithPrefix:(NSString *)prefix scenarios:(NSMutableArray *)scenarios;
-(void)exportObjectivesForDifficulty:(NSString *)diff forDesc:(NSString *)diffDesc toFile:(FILE *)fp prefix:(NSString *)prefix;
-(NSMutableDictionary *)getNextScenarioText;
-(void)addNextScenarioInfoForDifficulty:(NSString *)diff toVictoryString:(NSMutableString *)vInfo toContinueString:(NSMutableString *)cInfo withPrefix:(NSString *)prefix;
-(void)checkDeletedScenario:(id)index;
-(NSMutableArray *)getEvents;
-(WMLEvent *)getEventAtIndex:(int)index;
-(int)noEvents;
-(void)addNewEvent;
@end

View file

@ -1,361 +0,0 @@
//
// WMLScenario.m
// Wesnoth Scenario Editor
//
// Created by Marcus on Sat Mar 27 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLScenario.h"
#import "WMLMap.h"
#import "WMLSide.h"
#import "WNFileLocations.h"
#import "WNUtils.h"
@implementation WMLScenario
-(WMLScenario *)init
{
[super init]; // init parent first
fprintf(stderr, "WMLScenario initialising\n");
name = [[NSMutableString alloc] initWithString:@"untitled scenario"];
[name retain];
winID=0;
loseID = 0;
continueID=0;
activeSide = 0;
map = [[WMLMap alloc] initWithSize: 50 by:50];
[map retain];
sides = [[NSMutableArray alloc] init];
[sides retain];
activeSide = [[WMLSide alloc] init];
[sides addObject: activeSide]; // add a blank side
fprintf(stderr, "WMLScenario - initialising conditions\n");
victoryConditions = [[NSMutableDictionary alloc] init];
[victoryConditions retain];
defeatConditions = [[NSMutableDictionary alloc] init];
[defeatConditions retain];
[defeatConditions setObject: [[NSMutableArray alloc] init] forKey:@"Easy"];
[defeatConditions setObject: [[NSMutableArray alloc] init] forKey:@"Normal"];
[defeatConditions setObject: [[NSMutableArray alloc] init] forKey:@"Hard"];
[victoryConditions setObject: [[NSMutableArray alloc] init] forKey:@"Easy"];
[victoryConditions setObject: [[NSMutableArray alloc] init] forKey:@"Normal"];
[victoryConditions setObject: [[NSMutableArray alloc] init] forKey:@"Hard"];
fprintf(stderr, "WMLScenario - initialising conditions\n");
details = [[NSMutableDictionary alloc] init];
[details retain];
[details setObject: [[WMLScenarioDetails alloc] init] forKey:@"Easy"];
[details setObject: [[WMLScenarioDetails alloc] init] forKey:@"Normal"];
[details setObject: [[WMLScenarioDetails alloc] init] forKey:@"Hard"];
teams = [[NSMutableArray alloc] init];
[teams retain];
[teams addObject:@"Wesnoth Team"];
advancedInfo = [[[NSMutableString alloc] init] retain];
events = [[[NSMutableArray alloc] init] retain];
return self;
}
-(void)dealloc
{
[name autorelease];
[map autorelease];
[sides autorelease];
[defeatConditions autorelease];
[victoryConditions autorelease];
[details autorelease];
[events autorelease];
[super dealloc]; // dealloc parent first
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeObject: name forKey:@"name"];
[coder encodeInt: winID forKey:@"winID"];
[coder encodeInt: loseID forKey:@"loseID"];
[coder encodeInt: continueID forKey:@"continueID"];
[coder encodeInt: activeSideIndex forKey:@"activeSideIndex"];
[coder encodeObject: activeSide forKey:@"activeSide"];
[coder encodeObject: sides forKey:@"sides"];
[coder encodeObject: teams forKey:@"teams"];
[coder encodeObject: victoryConditions forKey:@"victoryConditions"];
[coder encodeObject: defeatConditions forKey:@"defeatConditions"];
[coder encodeObject: details forKey:@"details"];
[coder encodeObject: map forKey:@"map"];
[coder encodeObject: advancedInfo forKey:@"advancedInfo"];
[coder encodeObject: events forKey:@"events"];
}
- (id)initWithCoder:(NSCoder *)coder
{
fprintf(stderr, "[WMLScenario] initWithCoder\n");
[super init];
name = [[coder decodeObjectForKey:@"name"] retain];
winID = [coder decodeIntForKey:@"winID"];
loseID = [coder decodeIntForKey:@"loseID"];
continueID = [coder decodeIntForKey:@"continueID"];
activeSideIndex = [coder decodeIntForKey:@"activeSideIndex"];
activeSide = [[coder decodeObjectForKey:@"activeSide"] retain];
sides = [[coder decodeObjectForKey:@"sides"] retain];
teams = [[coder decodeObjectForKey:@"teams"] retain];
victoryConditions = [[coder decodeObjectForKey:@"victoryConditions"] retain];
defeatConditions = [[coder decodeObjectForKey:@"defeatConditions"] retain];
details = [[coder decodeObjectForKey:@"details"] retain];
map = [[coder decodeObjectForKey:@"map"] retain];
advancedInfo = [coder decodeObjectForKey:@"advancedInfo"];
if (advancedInfo == nil) advancedInfo = [[NSMutableString alloc] init];
[advancedInfo retain];
events = [coder decodeObjectForKey:@"events"];
if (events == nil) events = [[[NSMutableArray alloc] init] retain];
[events retain];
return self;
}
-(NSString *)getName
{
return name;
}
-(void)setName:(NSString *)newName
{
[name autorelease];
name = [newName copy];
[name retain];
}
-(WMLMap *)getMap
{
return map;
}
-(int)getSidesCount
{
return [sides count];
}
-(WMLSide *)getSideAtIndex:(int)index
{
return [sides objectAtIndex:index];
}
-(int)addSide
{
[sides addObject: [[WMLSide alloc] init]]; // add a blank side
return ([sides count]-1);
}
-(WMLSide *)getActiveSide
{
return activeSide;
}
-(void)setActiveSide:(int)sideNo
{
activeSideIndex = sideNo;
activeSide = [sides objectAtIndex: activeSideIndex];
}
-(NSMutableArray *)getDefeatConditionsFor:(NSString *)diffLevel
{
return [defeatConditions objectForKey: diffLevel];
}
-(void)deleteSide:(int)sideToDie
{
[sides removeObjectAtIndex:sideToDie];
}
-(NSMutableArray *)getVictoryConditionsFor:(NSString *)diffLevel
{
return [victoryConditions objectForKey: diffLevel];
}
-(WMLScenarioDetails *)getDetailsFor:(NSString *)diffLevel
{
return [details objectForKey: diffLevel];
}
-(NSMutableArray *)getTeams
{
return teams;
}
-(void)setScenarioAdvancedInfo: (NSString *)newInfo
{
[advancedInfo setString:newInfo];
}
-(NSString *)getScenarioAdvancedInfo
{
return advancedInfo;
}
-(void)exportToFolderWithPrefix:(NSString *)prefix scenarios:(NSMutableArray *)scenarios
{
[[[WNCampaign getMainCampaign] getCharacters] initInPlay];
NSString *scenarioId = [WNUtils replaceSpaces: [prefix stringByAppendingString:name]];
NSString *fileName = [[[WNFileLocations getExportScenariosLocation]
stringByAppendingPathComponent: scenarioId]
stringByAppendingPathExtension:@"cfg"];
fprintf(stderr, "About to export scenario to:%s\n", [fileName UTF8String]);
FILE *sfp = fopen([fileName fileSystemRepresentation], "w\0");
if (sfp == nil) fprintf(stderr, "ERROR - Failed to open for save\n");
fprintf(sfp, "[scenario]\n");
fprintf(stderr, "Setting id to %s\n", [scenarioId UTF8String]);
fprintf(sfp, "id=%s\n", [scenarioId UTF8String]);
fprintf(sfp, "{DAWN}\n{MORNING}\n{AFTERNOON}\n{DUSK}\n{FIRST_WATCH}\n{SECOND_WATCH}\n\n");
// Next scenario on success
fprintf(stderr, "... about to export progressions\n");
WMLScenario *tmpScen = [scenarios objectAtIndex:winID];
NSString *nextScen = [WNUtils replaceSpaces:[prefix stringByAppendingString:[tmpScen getName]]];
fprintf(sfp, "next_scenario=%s\n", [nextScen UTF8String]);
fprintf(stderr, "...about to export map\n");
NSString *myMap = [map exportToString];
fprintf(sfp, "map_data=\"%s\"\n", [myMap UTF8String]);
[myMap autorelease];
// Now do each side
int sideLoop;
for (sideLoop = 0; sideLoop<[sides count] ; sideLoop++)
{
fprintf(stderr, "About to export side:%d\n", sideLoop);
[[sides objectAtIndex:sideLoop] exportSideToFile:sfp withTeams:teams withIndex:(sideLoop+1) withMap:map withSide:sideLoop];
}
// Now the victory conditions to display
[self exportObjectivesForDifficulty:@"Easy" forDesc:@"EASY" toFile:sfp prefix:prefix];
[self exportObjectivesForDifficulty:@"Normal" forDesc:@"NORMAL" toFile: sfp prefix:prefix];
[self exportObjectivesForDifficulty:@"Hard" forDesc:@"HARD" toFile: sfp prefix:prefix];
// Now export character-specific events
fprintf(stderr, "Processing character events\n");
NSString *charEvents = [[[WNCampaign getMainCampaign] getCharacters] exportCharacterEventsFromScenario:self];
fprintf(sfp, "%s\n", [charEvents UTF8String]);
fprintf(stderr, "Character events processed\n");
// Now we just dump the advanced info
fprintf(sfp, "%s\n", [advancedInfo UTF8String]);
// Now we export the specific events
fprintf(stderr, "Processing scenario events\n");
NSMutableString *scenEvents = [[NSMutableString alloc] init];
int eventLoop;
for (eventLoop = 0; eventLoop<[events count] ;eventLoop++) [[events objectAtIndex:eventLoop] exportEventToString:scenEvents];
fprintf(sfp, [scenEvents UTF8String]);
fprintf(sfp, "\n");
// Done so close and return
fprintf(sfp, "[/scenario]\n");
fclose(sfp);
[[[WNCampaign getMainCampaign] getCharacters] clearInPlay];
}
-(void)exportObjectivesForDifficulty:(NSString *)diff forDesc:(NSString *)diffDesc toFile:(FILE *)fp prefix:(NSString *)prefix
{
NSMutableArray *myVictory = [victoryConditions objectForKey:diff];
NSMutableArray *myDefeat = [defeatConditions objectForKey:diff];
WMLScenarioDetails *myDetail = [details objectForKey:diff];
WMLScenario *nextScen;
fprintf(fp, "#ifdef %s\n", [diffDesc UTF8String]);
fprintf(fp, "turns=%d\n", [myDetail getNoTurns]);
fprintf(fp, "objectives=\"\n");
int vtmp;
fprintf(fp, "Victory:\n");
for (vtmp=0; vtmp<[myVictory count] ;vtmp++)
fprintf(fp, "@%s\n", [[myVictory objectAtIndex:vtmp] UTF8String]);
fprintf(fp, "Defeat:\n");
for (vtmp=0; vtmp<[myDefeat count] ;vtmp++)
fprintf(fp, "#%s\n", [[myDefeat objectAtIndex:vtmp] UTF8String]);
fprintf(fp, "\"\n");
if ([myDetail getVictoryScenarioIndex]!=-1)
{
nextScen = [[WNCampaign getMainCampaign] getScenarioAtIndex: [myDetail getVictoryScenarioIndex]];
fprintf(fp, "next_scenario=%s\n",[[WNUtils replaceSpaces:[prefix stringByAppendingString:[nextScen getName]]] UTF8String]);
}
fprintf(fp, "#endif\n\n");
}
-(NSMutableDictionary *)getNextScenarioText
{
fprintf(stderr, "Setting next scenario text\n");
NSMutableString *vText = [[[NSMutableString alloc] init] retain];
NSMutableString *cText = [[[NSMutableString alloc] init] retain];
NSMutableString *prefix = [[WNCampaign getMainCampaign] getPrefix];
[self addNextScenarioInfoForDifficulty:@"Easy" toVictoryString:vText toContinueString:cText withPrefix:prefix];
[self addNextScenarioInfoForDifficulty:@"Normal" toVictoryString:vText toContinueString:cText withPrefix:prefix];
[self addNextScenarioInfoForDifficulty:@"Hard" toVictoryString:vText toContinueString:cText withPrefix:prefix];
NSMutableDictionary *nextDict = [[NSMutableDictionary alloc] init];
[nextDict setObject:vText forKey:@"Victory"];
[nextDict setObject:cText forKey:@"Continue"];
fprintf(stderr, "Next scenario text set:\n%s\n\n%s\n\n", [vText cString], [cText cString]);
return nextDict;
}
-(void)addNextScenarioInfoForDifficulty:(NSString *)diff toVictoryString:(NSMutableString *)vInfo toContinueString:(NSMutableString *)cInfo withPrefix:(NSString *)prefix
{
WMLScenarioDetails *myDetail = [details objectForKey:diff];
WMLScenario *nextScen;
if ([myDetail getVictoryScenarioIndex]!=-1)
{
[vInfo appendString:@"#ifdef "];
[vInfo appendString:[diff uppercaseString]];
[vInfo appendString:@"\nnext_scenario="];
nextScen = [[WNCampaign getMainCampaign] getScenarioAtIndex: [myDetail getVictoryScenarioIndex]];
[vInfo appendString:[WNUtils replaceSpaces:[prefix stringByAppendingString:[nextScen getName]]]];
[vInfo appendString:@"\n#endif\n\n"];
}
if ([myDetail getContinueScenarioIndex]!=-1)
{
[cInfo appendString:@"#ifdef "];
[cInfo appendString:[diff uppercaseString]];
[cInfo appendString:@"\nnext_scenario="];
nextScen = [[WNCampaign getMainCampaign] getScenarioAtIndex: [myDetail getVictoryScenarioIndex]];
[cInfo appendString:[WNUtils replaceSpaces:[prefix stringByAppendingString:[nextScen getName]]]];
[cInfo appendString:@"\n#endif\n\n"];
}
}
-(void)checkDeletedScenario:(id)index
{
int deadScenario = [index intValue];
if (winID==deadScenario) winID = -1;
if (winID>deadScenario) winID--;
if (loseID==deadScenario) loseID = -1;
if (loseID>deadScenario) loseID--;
if (continueID==deadScenario) continueID=-1;
if (continueID>deadScenario) continueID--;
}
-(NSMutableArray *)getEvents
{
return events;
}
-(WMLEvent *)getEventAtIndex:(int)index
{
return [events objectAtIndex:index];
}
-(int)noEvents
{
return [events count];
}
-(void)addNewEvent
{
fprintf(stderr, "Adding event...\n");
[events addObject:[[[WMLEvent alloc] initAsTag:YES withName:@"[Event]" withStringValue:@"" withIntValue:0 withType:0 withParent:nil] retain]];
fprintf(stderr, "Event Count:%d\n", [events count]);
}
@end

View file

@ -1,28 +0,0 @@
//
// WMLScenarioDetails.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon Apr 05 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WMLScenarioDetails : NSObject {
int noTurns;
int victoryScenarioIndex;
int continueScenarioIndex;
}
- (WMLScenarioDetails *)init;
- (void)dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
- (void)setNoTurns: (int)newTurns;
- (int)getNoTurns;
- (void)setVictoryScenarioIndex: (int)newIndex;
- (int)getVictoryScenarioIndex;
- (void)setContinueScenarioIndex: (int)newIndex;
- (int)getContinueScenarioIndex;
@end

View file

@ -1,75 +0,0 @@
//
// WMLScenarioDetails.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon Apr 05 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLScenarioDetails.h"
@implementation WMLScenarioDetails
- (WMLScenarioDetails *)init
{
noTurns = 10;
victoryScenarioIndex = -1;
continueScenarioIndex = -1;
return self;
}
- (void)dealloc
{
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeInt: noTurns forKey:@"noTurns"];
[coder encodeInt: victoryScenarioIndex forKey:@"victoryScenarioIndex"];
[coder encodeInt: continueScenarioIndex forKey:@"continueScenarioIndex"];
}
- (id)initWithCoder:(NSCoder *)coder
{
[super init];
noTurns = [coder decodeIntForKey:@"noTurns"];
victoryScenarioIndex = [coder decodeIntForKey:@"victoryScenarioIndex"];
continueScenarioIndex = [coder decodeIntForKey:@"continueScenarioIndex"];
return self;
}
- (void)setNoTurns: (int)newTurns
{
noTurns = newTurns;
}
- (int)getNoTurns
{
return noTurns;
}
- (void)setVictoryScenarioIndex: (int)newIndex
{
victoryScenarioIndex = newIndex;
}
- (int)getVictoryScenarioIndex
{
return victoryScenarioIndex;
}
- (void)setContinueScenarioIndex: (int)newIndex
{
continueScenarioIndex = newIndex;
}
- (int)getContinueScenarioIndex
{
return continueScenarioIndex;
}
@end

View file

@ -1,27 +0,0 @@
//
// WMLSide.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed Mar 31 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WMLSideDetail.h";
@interface WMLSide : NSObject {
NSString *name;
NSMutableString *advancedInfo;
NSMutableDictionary *SideLevels;
}
-(WMLSide *)init;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(NSString *)getName;
-(void)setName:(NSString *)newName;
-(WMLSideDetail *)detailForKey:(NSString *)key;
-(void)exportSideToFile:(FILE *)file withTeams:teams withIndex:(int)index withMap:(WMLMap *)map withSide:(int)side;
-(void)setSideAdvancedInfo:(NSString *)newInfo;
-(NSMutableString *)getSideAdvancedInfo;
@end

View file

@ -1,98 +0,0 @@
//
// WMLSide.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed Mar 31 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLSide.h"
@implementation WMLSide
-(WMLSide *)init
{
[super init];
fprintf(stderr, "WMLSide initialising\n");
SideLevels = [[NSMutableDictionary alloc] init];
[SideLevels retain];
[SideLevels setObject:[[WMLSideDetail alloc] init] forKey:@"Easy"];
[SideLevels setObject:[[WMLSideDetail alloc] init] forKey:@"Normal"];
[SideLevels setObject:[[WMLSideDetail alloc] init] forKey:@"Hard"];
name = [[NSString alloc] initWithString:@"Unknown side"];
[name retain];
advancedInfo = [[[NSMutableString alloc] init] retain];
fprintf(stderr, "WMLSide initialised\n");
return self;
}
-(void)dealloc
{
[name autorelease];
[SideLevels autorelease];
[super dealloc];
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeObject: name forKey:@"name"];
[coder encodeObject: advancedInfo forKey:@"advancedInfo"];
[coder encodeObject: SideLevels forKey:@"SideLevels"];
}
- (id)initWithCoder:(NSCoder *)coder
{
[super init];
name = [[coder decodeObjectForKey:@"name"] retain];
SideLevels = [[coder decodeObjectForKey:@"SideLevels"] retain];
advancedInfo = [coder decodeObjectForKey:@"advancedInfo"];
if (advancedInfo == nil) advancedInfo = [[NSMutableString alloc] init];
[advancedInfo retain];
return self;
}
-(NSString *)getName
{
return name;
}
-(void)setName:(NSString *)newName
{
[name autorelease];
name = [NSString stringWithString: newName];
[name retain];
}
-(WMLSideDetail *)detailForKey:(NSString *)key
{
return [SideLevels objectForKey: key];
}
-(void)exportSideToFile:(FILE *)file withTeams:teams withIndex:(int)index withMap:(WMLMap *)map withSide:(int)side
{
fprintf(file,"#ifdef EASY\n");
[[SideLevels objectForKey:@"Easy"] exportSideDetailToFile:file withTeams:teams withIndex:index withMap:(WMLMap *)map withDifficulty:@"Easy" withSide:side withInfo:advancedInfo];
fprintf(file,"#endif\n\n");
fprintf(file,"#ifdef NORMAL\n");
[[SideLevels objectForKey:@"Normal"] exportSideDetailToFile:file withTeams:teams withIndex:index withMap:(WMLMap *)map withDifficulty:@"Normal" withSide:side withInfo:advancedInfo];
fprintf(file,"#endif\n\n");
fprintf(file,"#ifdef HARD\n");
[[SideLevels objectForKey:@"Hard"] exportSideDetailToFile:file withTeams:teams withIndex:index withMap:(WMLMap *)map withDifficulty:@"Hard" withSide:side withInfo:advancedInfo];
fprintf(file,"#endif\n\n");
}
-(void)setSideAdvancedInfo:(NSString *)newInfo
{
[advancedInfo setString: newInfo];
}
-(NSMutableString *)getSideAdvancedInfo
{
return advancedInfo;
}
@end

View file

@ -1,45 +0,0 @@
//
// WMLSideList.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed Mar 31 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WMLMap.h"
@interface WMLSideDetail : NSObject {
int gold; // Amount of gold the side starts with
NSString *leaderName; // The name of the leader
NSString *leaderType; // Unit name of the leader
int leaderID; // Unit ID of the leader
NSMutableArray *recruitTypes; // Index of type of unit that can be recruited;
float agression; // Level of agression for AI units
NSString *type; // Whether AI or not
int team; // The team this side belongs to
BOOL canRecruit; // Whether or not this side can recruit
}
-(WMLSideDetail *)init;
-(void)dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(NSString *)getLeaderName;
-(void)setLeaderName:(NSString *)newName;
-(int)getLeaderID;
-(void)setLeaderTypeByID:(int)newID;
-(int)getGold;
-(void)setGold:(int)newGold;
-(NSString *)getType;
-(void)setType:(NSString *)newType;
-(float)getAgression;
-(void)setAgression:(float)newAgression;
-(BOOL)getCanRecruit;
-(void)setCanRecruit:(BOOL)newCanRecruit;
-(NSArray *)getRecruitTypes;
-(void)setSideDetailTeam:(int)newTeam;
-(int)getSideDetailTeam;
-(void)setRecruitTypes:(NSArray *)newSet;
-(void)exportSideDetailToFile:(FILE *)file withTeams:(NSMutableArray *)teams withIndex:(int)index withMap:(WMLMap *)map withDifficulty:(NSString *)diff withSide:(int)mySide withInfo:(NSMutableString *)advancedInfo;
@end

View file

@ -1,192 +0,0 @@
//
// WMLSideList.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed Mar 31 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLSideDetail.h"
#import "WNUnits.h"
@implementation WMLSideDetail
-(WMLSideDetail *)init
{
[super init]; // Init parent first
leaderName = [[NSString alloc] initWithString:@"Oh Great One"];
leaderType = [[NSString alloc] initWithString:[[WNUnits unitAtIndex:0] getSettingFor:@"name"]];
leaderID = 0;
[leaderName retain];
[leaderType retain];
type = @"Human";
[type retain];
canRecruit = YES;
recruitTypes = [[NSMutableArray alloc] init];
[recruitTypes retain];
return self;
}
-(void)dealloc
{
[leaderName autorelease];
[leaderType autorelease];
[super dealloc]; // Dealloc parent last
}
-(void)encodeWithCoder: (NSCoder *)coder
{
[coder encodeInt: gold forKey:@"gold"];
[coder encodeObject: leaderName forKey:@"leaderName"];
[coder encodeObject: leaderType forKey:@"leaderType"];
[coder encodeObject: [WNUnits convertIndexArray:recruitTypes] forKey:@"recruitTypes"];
[coder encodeFloat: agression forKey:@"agression"];
[coder encodeObject: type forKey:@"type"];
[coder encodeInt: team forKey:@"team"];
[coder encodeInt: canRecruit forKey:@"canRecruit"];
}
- (id)initWithCoder:(NSCoder *)coder
{
fprintf(stderr, "[WMLSideDetail initWithCoder]\n");
[super init];
gold = [coder decodeIntForKey:@"gold"];
leaderName = [[coder decodeObjectForKey:@"leaderName"] retain];
leaderType = [[coder decodeObjectForKey:@"leaderType"] retain];
leaderID = [WNUnits unitIndexForName:leaderType];
recruitTypes = [WNUnits convertNameArray:[coder decodeObjectForKey:@"recruitTypes"]];
agression = [coder decodeFloatForKey:@"agression"];
type = [[coder decodeObjectForKey:@"type"] retain];
team = [coder decodeIntForKey:@"team"];
canRecruit = [coder decodeIntForKey:@"canRecruit"];
return self;
}
-(NSString *)getLeaderName
{
return leaderName;
}
-(void)setLeaderName:(NSString *)newName
{
[leaderName autorelease];
leaderName = [NSString stringWithString: newName];
[leaderName retain];
}
-(int)getLeaderID
{
return leaderID;
}
-(void)setLeaderTypeByID:(int)newID
{
WMLTag *leaderTag;
leaderID = newID;
[leaderType release];
leaderTag = [WNUnits unitAtIndex:newID];
leaderType = [NSString stringWithString:[leaderTag getSettingFor:@"name"]];
[leaderType retain];
}
-(int)getGold
{
return gold;
}
-(void)setGold:(int)newGold
{
gold = newGold;
}
-(NSString *)getType
{
return type;
}
-(void)setType:(NSString *)newType
{
[type release];
type = [NSString stringWithString:newType];
[type retain];
}
-(float)getAgression
{
return agression;
}
-(void)setAgression:(float)newAgression
{
agression = newAgression;
}
-(BOOL)getCanRecruit
{
return canRecruit;
}
-(void)setCanRecruit:(BOOL)newCanRecruit
{
canRecruit = newCanRecruit;
}
-(NSArray *)getRecruitTypes
{
return [NSArray arrayWithArray: recruitTypes];
}
-(void)setRecruitTypes:(NSArray *)newSet
{
[recruitTypes setArray:newSet];
}
-(void)setSideDetailTeam:(int)newTeam
{
team = newTeam;
}
-(int)getSideDetailTeam
{
return team;
}
-(void)exportSideDetailToFile:(FILE *)file withTeams:(NSMutableArray *)teams withIndex:(int)index withMap:(WMLMap *)map withDifficulty:(NSString *)diff withSide:(int)mySide withInfo:(NSMutableString *)advancedInfo
{
int tmploop;
WNCharacters *characters = [[WNCampaign getMainCampaign] getCharacters];
fprintf(stderr, "... exporting side detail");
fprintf(file, "[side]\n");
fprintf(file, "side=%d\n", index);
fprintf(file, "type=%s\n", [[WNUnits unitNameAtIndex: [characters getUnitTypeAtIndex:leaderID]] UTF8String]);
[characters setInPlay:leaderID];
fprintf(file, "description=%s\n",[leaderName UTF8String]);
fprintf(file, "team_name=%s\n", [[teams objectAtIndex:team] UTF8String]);
fprintf(file, "gold=%d\n", gold);
fprintf(file, "controller=%s\n", [[type lowercaseString] UTF8String]);
if ([type isEqualTo:@"AI"]) fprintf(file, "agression=%g\n", agression);
if (canRecruit==YES)
{
fprintf(file, "canrecruit=1\n");
fprintf(file, "recruit=");
for (tmploop=0; tmploop<[recruitTypes count] ;tmploop++)
{
if (tmploop!=0) fprintf(file, ",");
fprintf(file, [[WNUnits unitNameAtIndex:[[recruitTypes objectAtIndex:tmploop] intValue]] UTF8String]);
}
fprintf(file, "\n");
}else{
fprintf(file, "canrecruit=0\n");
}
fprintf(file, [[map getUnitListForDifficulty:diff forSide:mySide] UTF8String]);
fprintf(file, [advancedInfo UTF8String]);
fprintf(file, "\n[/side]\n");
fprintf(stderr, "...exported\n");
}
@end

View file

@ -1,31 +0,0 @@
//
// WNWMLReader.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed Mar 24 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WMLTag : NSObject {
NSMutableArray *Children;
NSMutableDictionary *Settings;
NSString *wmlText;
NSString *Tag;
int Curpos;
int Maxpos;
int Lastpos;
}
-(BOOL)initWithFile: (NSString *)wmlFile setTag: (NSString *)thisTag;
-(BOOL)initWithString: (NSString *)wmlString setTag: (NSString *)thisTag;
-(NSString *)getLine;
-(int) childrenCount;
-(WMLTag *) getChildAtIndex:(int)cIndex;
-(int) settingsCount;
-(NSString *)getSettingFor:(NSString *)sKey;
-(NSString *)getTag;
-(NSArray *)getTagSettingKeys;
@end

View file

@ -1,159 +0,0 @@
//
// WNWMLReader.m
// Wesnoth Scenario Editor
// Class to read a textfile and return Wesnoth code tags
//
// Created by Marcus Phillips on Wed Mar 24 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLTag.h"
@implementation WMLTag
- (BOOL)initWithFile: (NSString *)wmlFile setTag:(NSString *)thisTag
// Just load a file into a string 1st
{
fprintf(stderr, "initialising WMLTag with file:%s\n", [wmlFile UTF8String]);
return [self initWithString: [NSString stringWithContentsOfFile: wmlFile] setTag:thisTag];
}
-(BOOL)initWithString: (NSString *)wmlString setTag:(NSString *)thisTag
// Main init method;
{
NSString *tmpLine=nil;
NSString *closeTag=nil;
NSString *Token, *Value;
NSRange foundPos, searchRange, equalPos, subRange;
WMLTag *child;
// First Allocate data structures
wmlText = [NSString stringWithString:wmlString]; // Make our copy;
Children = [[NSMutableArray alloc] init];
Settings = [[NSMutableDictionary alloc] init];
Tag = [NSString stringWithString:thisTag];
// Ensure we don't lose these objects
[wmlText retain];
[Children retain];
[Settings retain];
[Tag retain];
// Set position markers, just to be sure
Maxpos = [wmlText length];
Lastpos = 0;
Curpos = 0;
fprintf(stderr, "Initialising new WMLTag:%s\n", [thisTag UTF8String]);
do{
tmpLine = [self getLine];
if ((tmpLine == nil) || ([tmpLine length]==0))
{
//fprintf(stderr,"tmpLine is empty\n");
}else{
//fprintf(stderr, "Loaded line:%s\n", [tmpLine UTF8String]);
switch([tmpLine characterAtIndex:0]) // What is the first char
{
case '[': // Open Tag
if ([tmpLine characterAtIndex:1]=='/')
{
fprintf(stderr,"ERROR in wmlTag init... unpaired closetag found\n");
}else{
closeTag = [@"[/" stringByAppendingString: [tmpLine substringFromIndex:1]];
//fprintf(stderr,"Searching for %s\n", [closeTag UTF8String]);
searchRange.location = Curpos;
searchRange.length = [wmlText length]-Curpos;
foundPos = [wmlText rangeOfString:closeTag options:NSCaseInsensitiveSearch range:searchRange];
if (foundPos.length>0)
{
searchRange.location = Curpos;
searchRange.length = (foundPos.location - Curpos);
//fprintf(stderr, "Tag is:***%s***\n", [[wmlText substringWithRange: searchRange] UTF8String]);
Curpos = foundPos.location+foundPos.length;
child = [WMLTag alloc];
[child initWithString:[wmlText substringWithRange: searchRange] setTag: tmpLine];
[Children addObject:child];
}else{
fprintf(stderr,"failed to find tag\n");
}
}
break;
case '#': // Comment, do nothing
fprintf(stderr, "Comment Line... skipping\n");
break;
default: // ok, check for an assignment now
equalPos = [tmpLine rangeOfString:@"="];
if (equalPos.length == 0) // Not found
{
fprintf(stderr,"Unknown syntax, skipping\n");
}else{
subRange.location = 0;
subRange.length = equalPos.location;
Token = [tmpLine substringWithRange: subRange];
subRange.location = equalPos.location+1;
subRange.length = ([tmpLine length] - equalPos.location)-1;
Value = [tmpLine substringWithRange: subRange];
[Settings setObject: Value forKey: Token];
}
break;
}
}
}while(tmpLine != nil);
// OK, basic structures there, now we need to start looking
[super init];
return YES;
}
-(NSString *)getLine
{
int glDone=0;
char ThisChar;
if (Curpos == Maxpos) return nil;
Lastpos = Curpos;
while ((Curpos < Maxpos)&&(glDone == 0))
{
ThisChar = [wmlText characterAtIndex:Curpos];
if (ThisChar == '\n') glDone = 1;
Curpos++;
}
NSRange glRange;
glRange.location = Lastpos;
glRange.length = Curpos-Lastpos;
return [[wmlText substringWithRange:glRange] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
-(int) childrenCount // Returns the number of children
{
return [Children count];
}
-(WMLTag *) getChildAtIndex:(int)cIndex
{
return [Children objectAtIndex:cIndex];
}
-(int) settingsCount // Returns the number of settings
{
return [Settings count];
}
-(NSString *)getSettingFor:(NSString *)sKey
{
return [Settings objectForKey:sKey];
}
-(NSString *)getTag
{
return Tag;
}
-(NSArray *)getTagSettingKeys
{
return [Settings allKeys];
}
@end

View file

@ -1,29 +0,0 @@
//
// WMLTerrain.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Thu Mar 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WMLTerrain : NSObject {
NSString *name;
NSString *imageName;
NSImage *image;
NSImage *scaledImage;
NSString *code;
BOOL userDefined;
}
-(WMLTerrain *) init:(NSString *)inName image:(NSString *)inImage code:(NSString *)inCode userDefined: (BOOL)inUser;
-(void) dealloc;
-(NSString *)name;
-(NSImage *)image;
-(NSImage *)scaledImage;
-(void)resizeTo:(NSSize)newSize;
-(void)resizeToID:(id)newID;
-(NSString *)terrainCode;
@end

View file

@ -1,77 +0,0 @@
//
// WMLTerrain.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Thu Mar 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WMLTerrain.h"
@implementation WMLTerrain
-(WMLTerrain *) init:(NSString *)inName image:(NSString *)inImage code:(NSString *)inCode userDefined: (BOOL)inUser
{
[super init];
name = [NSString stringWithString: inName];
image = [[NSImage alloc] initWithContentsOfFile: inImage];
scaledImage = [image copy];
if (image == nil) fprintf(stderr,"Error - File invalid for image\n");
code = [NSString stringWithString: inCode];
userDefined = inUser;
[image retain];
[scaledImage retain];
[name retain];
[imageName retain];
[code retain];
return self;
}
-(void)dealloc
{
[name autorelease];
[imageName autorelease];
[code autorelease];
[super dealloc];
}
-(NSString *)name
{
return name;
}
-(NSImage *)image
{
return image;
}
-(NSImage *)scaledImage
{
return scaledImage;
}
-(void)resizeTo:(NSSize)newSize
{
[scaledImage autorelease];
scaledImage = [image copy];
[scaledImage setScalesWhenResized:YES];
[scaledImage setSize: newSize];
[scaledImage retain];
}
-(void)resizeToID:(id)newID
{
NSSize mySize = *((NSSize *)newID);
[self resizeTo: mySize];
}
-(NSString *)terrainCode
{
return code;
}
@end

View file

@ -1,141 +0,0 @@
/* WNCampaign */
#import <Cocoa/Cocoa.h>
#import "WMLCampaign.h"
#import "WMLMap.h"
#import "WNCampaignIconView.h"
#import "WNLoadSave.h"
@interface WNCampaign : NSObject
{
IBOutlet id agressionLevel;
IBOutlet id campaignID;
IBOutlet NSTextField *campaignName;
IBOutlet NSTextField *campaignPrefix;
IBOutlet NSButton *canRecruit;
IBOutlet WNCampaignIconView *campaignIcon;
IBOutlet id defeatList;
IBOutlet NSTextField *difficultyDescEasy;
IBOutlet NSTextField *difficultyDescNormal;
IBOutlet NSTextField *difficultyDescHard;
IBOutlet id difficultyEasy;
IBOutlet WNCampaignIconView *difficultyIconEasy;
IBOutlet id difficultyHard;
IBOutlet WNCampaignIconView *difficultyIconHard;
IBOutlet id difficultyMedium;
IBOutlet WNCampaignIconView *difficultyIconNormal;
IBOutlet NSTextField *goldAmount;
IBOutlet NSTableView *keepSide;
IBOutlet NSTextField *keepX;
IBOutlet WNLoadSave *loadSave;
IBOutlet NSTextField *keepY;
IBOutlet id leaderList;
IBOutlet id recruitList;
IBOutlet NSTabView *mainTabView;
IBOutlet id mapHeight;
IBOutlet id mapWidth;
IBOutlet NSTextField *mapInfoTerrain;
IBOutlet NSTextView *mapInfoCharacterList;
IBOutlet NSTextView *mapInfoUnitList;
IBOutlet NSPopUpButton *mapUnitSideMenu;
IBOutlet NSSlider *mapZoom;
IBOutlet NSTableView *nextScenarioVictory;
IBOutlet NSTableView *nextScenarioContinue;
IBOutlet NSTableView *nextScenarioDefeat;
IBOutlet NSTextField *noTurns;
IBOutlet NSTextView *scenarioAdvancedInfo;
IBOutlet id scenarioList;
IBOutlet NSPopUpButton *showConditionsForDifficulty;
IBOutlet NSTextView *sidesAdvancedInfo;
IBOutlet NSPopUpButton *sidesShowDetailForDifficulty;
IBOutlet id sidesList;
IBOutlet NSTableView *teamList;
IBOutlet id terrainList;
IBOutlet id typeAI;
IBOutlet id typeHuman;
IBOutlet id unitList;
IBOutlet NSButton *unitPlacementEasy;
IBOutlet NSButton *unitPlacementHard;
IBOutlet NSButton *unitPlacementNormal;
IBOutlet id victoryList;
}
- (IBAction)aggressionSelect:(id)sender;
- (IBAction)campaignIDSet:(id)sender;
- (IBAction)campaignNameSet:(id)sender;
- (IBAction)campaignPrefixSet:(id)sender;
- (IBAction)canRecruit:(id)sender;
- (IBAction)defeatAdd:(id)sender;
- (IBAction)defeatRemove:(id)sender;
- (IBAction)defeatSelect:(id)sender;
- (IBAction)difficultyDescChange:(id)sender;
- (IBAction)difficultyEasyCheck:(id)sender;
- (IBAction)difficultyHardCheck:(id)sender;
- (IBAction)difficultyMediumCheck:(id)sender;
- (IBAction)doNothing:(id)sender;
- (IBAction)goldSet:(id)sender;
- (IBAction)keepCancel:(id)sender;
- (IBAction)keepChoose:(id)sender;
- (IBAction)leaderSelect:(id)sender;
- (IBAction)mapCharacterSelect:(id)sender;
- (IBAction)mapExport:(id)sender;
- (IBAction)mapHeightSet:(id)sender;
- (IBAction)mapImport:(id)sender;
- (IBAction)mapUnitSide:(id)sender;
- (IBAction)mapViewSliderSet:(id)sender;
- (IBAction)mapWidthSet:(id)sender;
- (IBAction)mapZoomSet:(id)sender;
- (IBAction)nextScenarioVictorySelect:(id)sender;
- (IBAction)nextScenarioContinueSelect:(id)sender;
- (IBAction)noTurnsSet:(id)sender;
- (IBAction)recruitSelect:(id)sender;
- (IBAction)scenarioDelete:(id)sender;
- (IBAction)scenarioNew:(id)sender;
- (IBAction)scenarioSelect:(id)sender;
- (IBAction)showConditionsForDifficulty:(id)sender;
- (IBAction)sidesAdd:(id)sender;
- (void)sidesChanged:(NSNotification *)notification;
- (IBAction)sidesRemove:(id)sender;
- (IBAction)sidesShowDetailFor:(id)sender;
- (void)selectSide: (int)index;
- (IBAction)sidesSelect:(id)sender;
- (void)populateScenarioInfo;
- (void)populateSidesData;
- (IBAction)teamAdd:(id)sender;
- (IBAction)teamRemove:(id)sender;
- (IBAction)teamSelect:(id)sender;
- (IBAction)terrainSelect:(id)sender;
- (IBAction)typeAI:(id)sender;
- (IBAction)typeHuman:(id)sender;
- (IBAction)unitPlacementSetEasy:(id)sender;
- (IBAction)unitPlacementSetHard:(id)sender;
- (IBAction)unitPlacementSetNormal:(id)sender;
- (IBAction)unitSelect:(id)sender;
- (IBAction)victoryAdd:(id)sender;
- (IBAction)victoryRemove:(id)sender;
- (IBAction)victorySelect:(id)sender;
-(void)campaignReset:(NSNotification *)notification;
-(void)awakeFromNib;
-(void)doInit;
+(WMLCampaign *)getMainCampaign;
+(void)setMainCampaign:(WMLCampaign *)newCampaign;
-(void)selectScenario: (int) scenarioIndex;
+(WMLScenario *)getActiveScenario;
+(WMLMap *)getActiveMap;
-(WMLSideDetail *)getActiveSideDetail;
+(float)getMapZoom;
+(NSString *)getDifficulty;
+(WMLScenarioDetails *)getActiveScenarioDetail;
+(NSWindow *)windowForTitle:(NSString *)titleToFind;
-(void)newCampaignIcon:(NSNotification *)notification;
-(void)textDidChange:(NSNotification *)notification;
+(WMLTag *)getEventTags;
+(WMLTag *)getEventTagForTag:(NSString *)tag;
+(void)setMainMenu:(NSMenu *)newMainMenu;
+(NSMenu *)getMainMenu;
+(void)setEditorMenu:(NSMenu *)newEditorMenu;
+(NSMenu *)getEditorMenu;
+(void)switchToMainMenu;
+(void)switchToEditorMenu;
-(void)showEditorWindow;
-(NSWindow *)getEditorWindow;
@end

View file

@ -1,754 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCampaign.h"
#import "WMLCampaign.h"
#import "WNPreferences.h"
#import "WNTerrains.h"
#import "WNUnits.h"
#import "SelectionUtils.h"
@implementation WNCampaign
WMLCampaign *MainCampaign;
BOOL mainCampaignInitialised;
int selectedScenario;
float mapZoomLevel=1.0;
NSMutableString *difficulty;
NSMutableDictionary *windowDict;
WMLTag *eventTags;
NSMutableDictionary *eventTagsDict;
NSMenu *mainMenu=nil;
NSMenu *editorMenu=nil;
int initStatus=0;
NSWindow *editorWindow;
- (IBAction)aggressionSelect:(id)sender
{
[[self getActiveSideDetail] setAgression:[sender floatValue]];
}
- (IBAction)campaignIDSet:(id)sender
{
}
- (IBAction)campaignNameSet:(id)sender
{
[MainCampaign setName: [sender stringValue]];
}
- (IBAction)campaignPrefixSet:(id)sender
{
[MainCampaign setPrefix: [sender stringValue]];
}
- (IBAction)canRecruit:(id)sender
{
int state = [sender state];
WMLSideDetail *myDetail;
myDetail = [self getActiveSideDetail];
if (state == NSOnState)
{
[myDetail setCanRecruit:YES];
}else{
[myDetail setCanRecruit:NO];
}
}
- (IBAction)defeatAdd:(id)sender
{
[[[MainCampaign getActiveScenario] getDefeatConditionsFor: [WNCampaign getDifficulty]] addObject: [[NSMutableString alloc] initWithString:@"Another Defeat Condition"]];
[defeatList reloadData];
}
- (IBAction)defeatRemove:(id)sender
{
int itemToDelete = [defeatList selectedRow];
if (itemToDelete != -1)
[[[MainCampaign getActiveScenario] getDefeatConditionsFor: [WNCampaign getDifficulty]] removeObjectAtIndex: itemToDelete];
[defeatList reloadData];
}
- (IBAction)defeatSelect:(id)sender
{
}
- (IBAction)difficultyDescChange:(id)sender
{
int tag = [sender tag]; // Use to ID which textfield sent the request
switch(tag)
{
case 1:
[MainCampaign setDifficultyDescription:[difficultyDescEasy stringValue] forDifficulty:@"Easy"];
break;
case 2:
[MainCampaign setDifficultyDescription:[difficultyDescNormal stringValue] forDifficulty:@"Normal"];
break;
case 3:
[MainCampaign setDifficultyDescription:[difficultyDescHard stringValue] forDifficulty:@"Hard"];
break;
}
}
- (IBAction)difficultyEasyCheck:(id)sender
{
}
- (IBAction)difficultyHardCheck:(id)sender
{
}
- (IBAction)difficultyMediumCheck:(id)sender
{
}
- (IBAction)doNothing:(id)sender // Does nothing, just for connections :D
{
}
- (IBAction)goldSet:(id)sender
{
[[self getActiveSideDetail] setGold:[sender intValue]];
}
- (IBAction)keepCancel:(id)sender
{
}
- (IBAction)keepChoose:(id)sender
{
}
- (IBAction)leaderSelect:(id)sender
{
fprintf(stderr, "At leader select\n");
int leaderID = [sender selectedRow];
fprintf(stderr, "Setting leader type to: %d\n", leaderID);
[[[MainCampaign getActiveSide] detailForKey: [sidesShowDetailForDifficulty titleOfSelectedItem]] setLeaderTypeByID: leaderID];
[self populateSidesData];
}
- (IBAction)mapCharacterSelect:(id)sender
{
[WNPreferences setCharacterID: [sender selectedRow]];
}
- (IBAction)mapExport:(id)sender
{
NSSavePanel *saveDialog = [NSSavePanel savePanel];
int saveResult = [saveDialog runModalForDirectory:NSHomeDirectory() file:@""];
if (saveResult == NSOKButton) [[MainCampaign getActiveMap] exportToFile: [saveDialog filename]];
}
- (IBAction)mapHeightSet:(id)sender
{
fprintf(stderr, "Changing map height\n");
[[MainCampaign getActiveMap] setHeight:[sender intValue]];
}
- (IBAction)mapImport:(id)sender
{
NSPoint tmpPoint;
int x,y;
NSSavePanel *openDialog = [NSOpenPanel openPanel];
int openResult = [openDialog runModalForDirectory:NSHomeDirectory() file:@""];
if (openResult == NSOKButton) tmpPoint = [[MainCampaign getActiveMap] importFromFile: [openDialog filename]];
x = tmpPoint.x;
y = tmpPoint.y;
[mapWidth setIntValue:x];
[mapHeight setIntValue:y];
}
- (IBAction)mapUnitSide:(id)sender
{
[WNPreferences setUnitSide:[mapUnitSideMenu indexOfSelectedItem]];
}
- (IBAction)mapViewSliderSet:(id)sender
{
[WNPreferences setUnitOpacity:[sender floatValue]];
}
- (IBAction)mapWidthSet:(id)sender
{
[[MainCampaign getActiveMap] setWidth:[sender intValue]];
}
- (IBAction)mapZoomSet:(id)sender
{
mapZoomLevel = [sender floatValue];
[HexUtils initWithWidth:(70*mapZoomLevel)];
NSSize nzSize;
nzSize.width = (70*mapZoomLevel);
nzSize.height = (70*mapZoomLevel);
[WNTerrains resizeTo:nzSize];
[WNUnits resizeTo:nzSize];
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
}
- (IBAction)nextScenarioVictorySelect:(id)sender
{
[[WNCampaign getActiveScenarioDetail] setVictoryScenarioIndex:[nextScenarioVictory selectedRow]];
}
- (IBAction)nextScenarioContinueSelect:(id)sender
{
[[WNCampaign getActiveScenarioDetail] setContinueScenarioIndex:[nextScenarioContinue selectedRow]];
}
- (IBAction)noTurnsSet:(id)sender;
{
[[WNCampaign getActiveScenarioDetail] setNoTurns:[sender intValue]];
}
- (IBAction)recruitSelect:(id)sender
{
WMLSideDetail *myDetail = [self getActiveSideDetail];
[myDetail setRecruitTypes: [SelectionUtils selectionsFromView:sender]];
}
- (IBAction)scenarioDelete:(id)sender
{
if ([MainCampaign count]>1)
{
[MainCampaign deleteScenario: [scenarioList selectedRow]];
[self scenarioSelect:0];
[scenarioList reloadData];
}
}
- (IBAction)scenarioNew:(id)sender
{
int scenIndex = [MainCampaign addScenario];
[scenarioList reloadData];
[self selectScenario: scenIndex];
}
- (IBAction)scenarioSelect:(id)sender
{
[self selectScenario: [sender selectedRow]];
}
- (IBAction)showConditionsForDifficulty:(id)sender
{
[difficulty setString: [showConditionsForDifficulty titleOfSelectedItem]];
[self populateSidesData];
[self populateScenarioInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:@"scenarioInfoRefresh" object:self];
}
- (IBAction)sidesAdd:(id)sender
{
WMLScenario *myScenario = [MainCampaign getActiveScenario];
int sideIndex = [myScenario addSide];
[sidesList reloadData];
[self selectSide: sideIndex];
}
-(void)sidesRefresh
{
int tmpIndex = [mapUnitSideMenu indexOfSelectedItem];
WMLScenario *myScenario = [MainCampaign getActiveScenario];
[mapUnitSideMenu removeAllItems];
int i;
for (i=0; i<[myScenario getSidesCount] ;i++)
[mapUnitSideMenu addItemWithTitle:[[myScenario getSideAtIndex:i] getName]];
[mapUnitSideMenu selectItemAtIndex:tmpIndex];
}
- (IBAction)sidesRemove:(id)sender
{
WMLScenario *myScenario = [MainCampaign getActiveScenario];
WMLMap *myMap = [myScenario getMap];
int curSide = [sidesList selectedRow];
fprintf(stderr, "Removing side:%d\n", curSide);
NSMutableDictionary *delDict = [[NSMutableDictionary alloc] init];
[delDict setObject:[[NSNumber alloc] initWithInt:1] forKey:@"mode"];
[delDict setObject:[[NSNumber alloc] initWithInt:curSide] forKey:@"side"];
[delDict setObject:[[NSNumber alloc] initWithInt:0] forKey:@"count"];
fprintf(stderr, "First iteration, to check\n");
[myMap iterateSelector:@selector(deleteSideWithDict:) withObject:delDict];
NSNumber *count = [delDict objectForKey:@"count"];
fprintf(stderr, "First iteration complete, occurrances found:%d\n", [count intValue]);
if ([count intValue]>0)
{
int choice = NSRunAlertPanel(@"Warning", @"Found %i units on maps", @"cancel", @"delete anyway", nil, [count intValue]);
fprintf(stderr, "Response to delete:%d\n", choice);
if (choice == NSAlertDefaultReturn) return;
}
[delDict setObject:[[NSNumber alloc] initWithInt:2] forKey:@"mode"];
[myMap iterateSelector:@selector(deleteSideWithDict:) withObject:delDict];
[myScenario deleteSide:curSide];
[self selectSide:0];
[sidesList reloadData];
}
- (IBAction)sidesShowDetailFor:(id)sender
{
[difficulty setString: [sidesShowDetailForDifficulty titleOfSelectedItem]];
[showConditionsForDifficulty selectItemWithTitle: difficulty];
[self populateSidesData];
[self populateScenarioInfo];
}
- (void)selectSide: (int)index
{
WMLScenario *myScenario = [MainCampaign getActiveScenario];
fprintf(stderr, "Changing selected side to no:%d\n", index);
[sidesList selectRow: index byExtendingSelection:NO];
[myScenario setActiveSide: index];
[self populateSidesData];
}
-(void)sidesChanged:(NSNotification *)notification
{
[self sidesRefresh];
}
- (IBAction)sidesSelect:(id)sender
{
int newSide = [sidesList selectedRow];
fprintf(stderr, "Side %d selected\n", newSide);
[[MainCampaign getActiveScenario] setActiveSide:newSide];
[self populateSidesData];
}
- (IBAction)teamAdd:(id)sender
{
[[[WNCampaign getActiveScenario] getTeams] addObject:@"New Team"];
[teamList reloadData];
}
- (IBAction)teamRemove:(id)sender
{
}
- (IBAction)teamSelect:(id)sender
{
[[self getActiveSideDetail] setSideDetailTeam: [sender selectedRow]];
}
- (void)populateScenarioInfo
{
[showConditionsForDifficulty selectItemWithTitle: difficulty];
[victoryList reloadData];
[defeatList reloadData];
WMLScenarioDetails *myDetails = [WNCampaign getActiveScenarioDetail];
[noTurns setIntValue: [myDetails getNoTurns]];
[nextScenarioVictory deselectAll: self];
[nextScenarioContinue deselectAll: self];
[nextScenarioDefeat deselectAll: self];
[nextScenarioVictory selectRow: [myDetails getVictoryScenarioIndex] byExtendingSelection:NO];
[nextScenarioContinue selectRow: [myDetails getContinueScenarioIndex] byExtendingSelection:NO];
}
- (void)populateSidesData
{
WMLScenario *myScenario = [MainCampaign getActiveScenario];
WMLSide *mySide = [myScenario getActiveSide];
fprintf(stderr,"Populating side data for difficulty: %s\n", [difficulty UTF8String]);
[sidesShowDetailForDifficulty selectItemWithTitle: difficulty];
WMLSideDetail *myDetail = [mySide detailForKey: difficulty];
[leaderList selectRow: [myDetail getLeaderID] byExtendingSelection:NO];
[goldAmount setIntValue: [[self getActiveSideDetail] getGold]];
NSString *type = [myDetail getType];
if ([type isEqualTo:@"AI"])
{
[typeAI setState:NSOnState];
[typeHuman setState:NSOffState];
}else if ([type isEqualTo:@"Human"]){
[typeAI setState:NSOffState];
[typeHuman setState:NSOnState];
}
[agressionLevel setFloatValue:[myDetail getAgression]];
if ([myDetail getCanRecruit] == YES)
{
[canRecruit setState:NSOnState];
}else{
[canRecruit setState:NSOffState];
}
[SelectionUtils selectionsToView:recruitList indexArray:[myDetail getRecruitTypes]];
[teamList selectRow:[myDetail getSideDetailTeam] byExtendingSelection:NO];
[sidesAdvancedInfo setString:[mySide getSideAdvancedInfo]];
[self sidesRefresh];
}
- (IBAction)terrainSelect:(id)sender
{
[WNPreferences setTerrainID: [sender selectedRow]];
[WNPreferences setTerrain: [WNTerrains terrainAtIndex:[sender selectedRow]]];
}
- (IBAction)typeAI:(id)sender
{
[[self getActiveSideDetail] setType:@"AI"];
}
- (IBAction)typeHuman:(id)sender
{
[[self getActiveSideDetail] setType:@"Human"];
}
- (IBAction)unitPlacementSetEasy:(id)sender
{
[WNPreferences setPlaceEasy:([sender state]==NSOnState)];
}
- (IBAction)unitPlacementSetNormal:(id)sender
{
[WNPreferences setPlaceNormal:([sender state]==NSOnState)];
}
- (IBAction)unitPlacementSetHard:(id)sender
{
[WNPreferences setPlaceHard:([sender state]==NSOnState)];
}
- (IBAction)unitSelect:(id)sender
{
[WNPreferences setUnitID:[sender selectedRow]];
}
- (IBAction)victoryAdd:(id)sender
{
[[[MainCampaign getActiveScenario] getVictoryConditionsFor: [WNCampaign getDifficulty]] addObject: [[NSMutableString alloc] initWithString:@"Another Victory Condition"]];
[victoryList reloadData];
}
- (IBAction)victoryRemove:(id)sender
{
int itemToDelete = [victoryList selectedRow];
if (itemToDelete != -1)
[[[MainCampaign getActiveScenario] getVictoryConditionsFor: [WNCampaign getDifficulty]] removeObjectAtIndex: itemToDelete];
[victoryList reloadData];
}
- (IBAction)victorySelect:(id)sender
{
}
-(void)campaignReset:(NSNotification *)notification
{
fprintf(stderr, "Campaign refresh...");
[scenarioList reloadData];
[self selectScenario:0];
[[MainCampaign getActiveScenario] setActiveSide:0];
[self populateSidesData];
[self populateScenarioInfo];
[mainTabView selectFirstTabViewItem: self];
[self sidesRefresh];
[campaignName setStringValue: [MainCampaign getName]];
[campaignPrefix setStringValue: [MainCampaign getPrefix]];
[campaignIcon setImage: [MainCampaign getIcon]];
[difficultyIconEasy setImage: [MainCampaign getDifficultyIconForDifficulty:@"Easy"]];
[difficultyIconNormal setImage: [MainCampaign getDifficultyIconForDifficulty:@"Normal"]];
[difficultyIconHard setImage: [MainCampaign getDifficultyIconForDifficulty:@"Hard"]];
[difficultyDescEasy setStringValue:[MainCampaign getDifficultyDescriptionForDifficulty:@"Easy"]];
[difficultyDescNormal setStringValue:[MainCampaign getDifficultyDescriptionForDifficulty:@"Normal"]];
[difficultyDescHard setStringValue:[MainCampaign getDifficultyDescriptionForDifficulty:@"Hard"]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"characterListsReset" object:self];
}
-(void)awakeFromNib
{ // OK, time to set up some basic info
#ifdef embeddedEditor
if (initStatus==0)
{
NSLog(@"Launching doInit from awakeFromNib");
[self doInit];
}
#endif
}
-(void)applicationWillFinishLaunching: (NSNotification *)notification
{
#ifndef embeddedEditor
if (initStatus==0)
{
NSLog(@"Launching doInit from applicationWillFinishLaunching");
[self doInit];
}
#endif
}
-(void)doInit
{ // Moved from awakeFromNib
NSLog (@"At doInit *****************");
fprintf(stderr, "WNCampaign - Creating windowDict\n");
windowDict = [[NSMutableDictionary alloc] init];
[windowDict retain];
NSArray *windowList = [NSApp windows];
int i;
for (i=0; i< [windowList count] ;i++) [windowDict setObject:[windowList objectAtIndex: i] forKey:[[windowList objectAtIndex:i] title]];
NSWindow *loadWin = [WNCampaign windowForTitle:@"Initialising Reference Data"];
[loadWin center];
[loadWin makeKeyAndOrderFront: self];
[WNTerrains init];
[WNUnits init];
fprintf(stderr, "Initialising Campaign class\n");
if ([WNTerrains initialised] == NO) [WNTerrains init];
MainCampaign = [[WMLCampaign alloc] init];
[MainCampaign retain];
fprintf(stderr, "MainCampaign created\n");
selectedScenario = 0;
mainCampaignInitialised = YES;
difficulty = [[NSMutableString alloc] initWithString:@"Easy"];
[difficulty retain];
NSLog(@"Initialiasing lists");
[scenarioList reloadData];
[scenarioList selectRow: 0 byExtendingSelection:NO];
[self selectScenario:0];
[sidesList reloadData];
[sidesList selectRow: 0 byExtendingSelection:NO];
[self selectSide:0];
fprintf(stderr, "WN Campaign - Notifications\n");
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sidesChanged:)
name:@"sidesChanged" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(campaignReset:)
name:@"campaignReset" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(newCampaignIcon:)
name:@"newCampaignIcon" object:nil];
NSLog(@"Campaign class initialised\n");
NSLog(@"Setting Prefs");
[WNPreferences setPlaceEasy:YES];
[WNPreferences setPlaceNormal:YES];
[WNPreferences setPlaceHard:YES];
[WNPreferences setDocControl:[[NSDocumentController sharedDocumentController] retain]];
NSLog(@"Prefs Set");
NSLog(@"Resetting Lists");
// Now reset all lists
[leaderList reloadData];
[recruitList reloadData];
[unitList reloadData];
[terrainList reloadData];
NSLog(@"Lists Reset");
// Now send the mapView its info
NSLog(@"Setting and Sending mapView Info");
NSMutableDictionary *mapDict = [[[NSMutableDictionary alloc] init] retain];
[mapDict setObject:mapInfoTerrain forKey:@"Terrain"];
[mapDict setObject:mapInfoUnitList forKey:@"Unit"];
[mapDict setObject:mapInfoCharacterList forKey:@"Character"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapInfo" object:self userInfo:mapDict];
NSLog(@"mapView Info Sent");
[[NSNotificationCenter defaultCenter] postNotificationName:@"campaignReset" object:self];
NSString *eventConfigFile = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"eventConfig.info"];
NSLog(@"Setting Event Tags");
eventTags = [WMLTag alloc];
[eventTags initWithFile:eventConfigFile setTag:@"[EventActions]"];
[eventTags retain];
eventTagsDict = [[[NSMutableDictionary alloc] init] retain];
int tagLoop;
WMLTag *tmpTag;
for (tagLoop = 0; tagLoop<[eventTags childrenCount] ;tagLoop++)
{
tmpTag = [eventTags getChildAtIndex:tagLoop];
[eventTagsDict setObject:tmpTag forKey:[tmpTag getTag]];
}
NSLog(@"Posting finishedLaunching notification");
[[NSNotificationCenter defaultCenter] postNotificationName:@"finishedLaunching" object:self];
[loadWin orderOut: self];
initStatus=1;
editorWindow = [WNCampaign windowForTitle:@"Scenario Designer"];
NSLog(@"doInit completed");
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
fprintf(stderr, "Opening file...");
[loadSave doLoadFile:filename];
return YES;
}
+(WMLCampaign *)getMainCampaign
{
if (mainCampaignInitialised==YES)
{
return MainCampaign;
}
return nil;
}
+(void)setMainCampaign:(WMLCampaign *)newCampaign
{
[MainCampaign autorelease];
MainCampaign = newCampaign;
[MainCampaign retain];
fprintf(stderr, "MainCampaign set\n");
}
-(void)selectScenario: (int) scenarioIndex
{
WMLScenario *tmpScenario=nil;
WMLMap *tmpMap;
fprintf(stderr, "Activating Scenario:%d\n", scenarioIndex);
[scenarioList selectRow: scenarioIndex byExtendingSelection:NO];
selectedScenario = scenarioIndex;
[MainCampaign setActiveScenario: scenarioIndex];
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
tmpScenario = [MainCampaign getScenarioAtIndex: scenarioIndex];
tmpMap = [tmpScenario getMap];
[mapWidth setIntValue:[tmpMap getWidth]];
[mapHeight setIntValue:[tmpMap getHeight]];
[self populateSidesData];
[self populateScenarioInfo];
[scenarioAdvancedInfo setString: [tmpScenario getScenarioAdvancedInfo]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"eventListReset" object:self];
}
+(WMLScenario *)getActiveScenario
{
return [MainCampaign getActiveScenario];
}
+(WMLMap *)getActiveMap
{
return [MainCampaign getActiveMap];
}
-(WMLSideDetail *)getActiveSideDetail
{
return [[MainCampaign getActiveSide] detailForKey:[sidesShowDetailForDifficulty titleOfSelectedItem]];
}
+(float)getMapZoom
{
return mapZoomLevel;
}
+(NSString *)getDifficulty
{
return difficulty;
}
+(WMLScenarioDetails *)getActiveScenarioDetail
{
return [[MainCampaign getActiveScenario] getDetailsFor:difficulty];
}
+(NSWindow *)windowForTitle:(NSString *)titleToFind
{
return [windowDict objectForKey:titleToFind];
}
-(void)newCampaignIcon:(NSNotification *)notification
{
fprintf(stderr,"At newCampaignIcon\n");
int tag = [[notification object] tag];
NSDictionary *tmpDict = [notification userInfo];
NSImage *newImage = [tmpDict objectForKey:@"image"];
// Process
switch(tag)
{
case 0: // Main Campaign Icon
[MainCampaign setIcon: newImage];
break;
case 1: // Easy Icon
[MainCampaign setDifficultyIcon: newImage forDifficulty:@"Easy"];
break;
case 2: // Normal Icon
[MainCampaign setDifficultyIcon: newImage forDifficulty:@"Normal"];
break;
case 3: // Hard Icon
[MainCampaign setDifficultyIcon: newImage forDifficulty:@"Hard"];
break;
}
[tmpDict autorelease];
NSNotification *fred = [[NSNotification alloc] init];
[self campaignReset: fred];
}
-(void)textDidChange:(NSNotification *)notification
{
//fprintf(stderr,"At textDidChange\n");
NSTextView *fromObj = [notification object];
if (fromObj == scenarioAdvancedInfo)
[[MainCampaign getActiveScenario] setScenarioAdvancedInfo:[scenarioAdvancedInfo string]];
if (fromObj == sidesAdvancedInfo)
[[[MainCampaign getActiveScenario] getActiveSide] setSideAdvancedInfo:[sidesAdvancedInfo string]];
}
+(WMLTag *)getEventTags
{
return eventTags;
}
+(WMLTag *)getEventTagForTag:(NSString *)tag
{
return [eventTagsDict objectForKey:tag];
}
+(void)setMainMenu:(NSMenu *)newMainMenu
{
mainMenu = newMainMenu;
[mainMenu retain];
}
+(NSMenu *)getMainMenu
{
return mainMenu;
}
+(void)setEditorMenu:(NSMenu *)newEditorMenu
{
editorMenu = newEditorMenu;
[editorMenu retain];
}
+(NSMenu *)getEditorMenu
{
return editorMenu;
}
+(void)switchToMainMenu
{
if (editorMenu != nil)
{
[[NSApplication sharedApplication] setMainMenu:mainMenu];
}
}
+(void)switchToEditorMenu;
{
if (mainMenu != nil)
{
[[NSApplication sharedApplication] setMainMenu:editorMenu];
}
}
-(void)showEditorWindow
{
NSLog(@"Making Editor window key");
fprintf(stderr, "Editor window:%d\n", editorWindow);
[editorWindow makeKeyAndOrderFront:self];
[editorWindow makeKeyWindow];
[editorWindow makeMainWindow];
}
-(NSWindow *)getEditorWindow
{
return editorWindow;
}
@end

View file

@ -1,11 +0,0 @@
/* WNCampaignIconView */
#import <Cocoa/Cocoa.h>
@interface WNCampaignIconView : NSImageView
{
}
-(void)awakeFromNib;
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
@end

View file

@ -1,57 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCampaignIconView.h"
@implementation WNCampaignIconView
-(void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:
NSTIFFPboardType, NSPICTPboardType, NSFilenamesPboardType, nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSColorPboardType] )
if (sourceDragMask & NSDragOperationGeneric)
return NSDragOperationGeneric;
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
if (sourceDragMask & NSDragOperationCopy)
return NSDragOperationCopy;
return NSDragOperationNone;
}
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
NSImage *draggedImage = [NSImage alloc];
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSTIFFPboardType] )
{
[draggedImage initWithPasteboard:pboard];
} else if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
[draggedImage initWithContentsOfFile:[files objectAtIndex:0]];
}
if (draggedImage != nil)
{
[draggedImage retain];
[self setImage:draggedImage];
NSDictionary *tmpDict = [NSDictionary dictionaryWithObject:draggedImage forKey:@"image"];
[tmpDict retain];
[[NSNotificationCenter defaultCenter]
postNotificationName:@"newCampaignIcon" object:self userInfo:tmpDict];
}
return YES;
}
@end

View file

@ -1,36 +0,0 @@
/* WNCharacterEditor */
#import <Cocoa/Cocoa.h>
#import "WNCharacters.h"
@interface WNCharacterEditor : NSObject
{
IBOutlet NSPopUpButton *CharacterAI;
IBOutlet NSPopUpButton *CharacterDeathAction;
IBOutlet NSTextField *CharacterDeathMessage;
IBOutlet NSImageView *CharacterDialogImage;
IBOutlet NSButton *CharacterDialogImageSwitch;
IBOutlet NSSlider *CharacterHP;
IBOutlet NSTableView *CharacterList;
IBOutlet NSPopUpButton *CharacterTrait1;
IBOutlet NSPopUpButton *CharacterTrait2;
IBOutlet NSTableView *CharacterUnitList;
}
- (void)awakeFromNib;
- (IBAction)CharacterAISelect:(id)sender;
- (IBAction)CharacterDeathActionSelect:(id)sender;
- (IBAction)CharacterDeathMessageUpdate:(id)sender;
- (IBAction)CharacterDialogImageSelect:(id)sender;
- (IBAction)CharacterHitpointsSelect:(id)sender;
- (IBAction)CharacterNew:(id)sender;
- (IBAction)CharacterRemove:(id)sender;
- (IBAction)CharacterSelect:(id)sender;
- (IBAction)CharacterTrait1Select:(id)sender;
- (IBAction)CharacterTrait2Select:(id)sender;
- (IBAction)CharacterUnitSelect:(id)sender;
- (IBAction)CharacterUseDialogImageSelect:(id)sender;
-(WNCharacters *)characters;
-(void)refreshCharacterInfo;
-(void)newCharacterCustomDialogImage:(NSNotification *)notification;
-(void)characterListReload:(NSNotification *)notification;
@end

View file

@ -1,133 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCharacterEditor.h"
@implementation WNCharacterEditor
-(void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(newCharacterCustomDialogImage:)
name:@"newCharacterCustomDialogImage" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(characterListsReset:)
name:@"characterListsReset" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(characterListReload:)
name:@"campaignReset" object:nil];
}
- (IBAction)CharacterAISelect:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
[tmpChar setAIAtIndex:curChar to:[CharacterAI titleOfSelectedItem]];
}
- (IBAction)CharacterDeathActionSelect:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
[tmpChar setDeathActionAtIndex:curChar to:[sender titleOfSelectedItem]];
}
- (IBAction)CharacterDeathMessageUpdate:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
NSString *DeathMessage = [CharacterDeathMessage stringValue];
[tmpChar setDeathMessageAtIndex: curChar to:DeathMessage];
}
- (IBAction)CharacterDialogImageSelect:(id)sender
{
}
- (IBAction)CharacterHitpointsSelect:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
[tmpChar setHPAtIndex: curChar to: [CharacterHP floatValue]];
}
- (IBAction)CharacterNew:(id)sender
{
[[self characters] newCharacter];
[CharacterList reloadData];
}
- (IBAction)CharacterRemove:(id)sender
{
}
- (IBAction)CharacterSelect:(id)sender
{
[self refreshCharacterInfo];
}
- (IBAction)CharacterTrait1Select:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
[tmpChar setTrait:1 atIndex:curChar to:[CharacterTrait1 titleOfSelectedItem]];
}
- (IBAction)CharacterTrait2Select:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
[tmpChar setTrait:2 atIndex:curChar to:[CharacterTrait2 titleOfSelectedItem]];
}
- (IBAction)CharacterUnitSelect:(id)sender
{
WNCharacters *tmpChar = [self characters];
int curChar = [CharacterList selectedRow];
int newUnitType = [sender selectedRow];
[tmpChar setUnitTypeAtIndex: curChar to:newUnitType];
[CharacterList reloadData];
}
- (IBAction)CharacterUseDialogImageSelect:(id)sender
{
}
-(WNCharacters *)characters
{
return [[WNCampaign getMainCampaign] getCharacters];
}
-(void)refreshCharacterInfo
{
int selectedChar = [CharacterList selectedRow];
WNCharacters *myChar = [self characters];
[CharacterAI selectItemWithTitle: [myChar getAIAtIndex: selectedChar]];
[CharacterUnitList selectRow:[myChar getUnitTypeAtIndex: selectedChar] byExtendingSelection:NO];
[CharacterDialogImage setImage:[myChar getDialogImageAtIndex: selectedChar]];
[CharacterHP setFloatValue:[myChar getHPAtIndex: selectedChar]];
[CharacterDeathMessage setStringValue:[myChar getDeathMessageAtIndex: selectedChar]];
[CharacterDeathAction selectItemWithTitle: [myChar getDeathActionAtIndex: selectedChar]];
[CharacterTrait1 selectItemWithTitle: [myChar getTrait:1 atIndex: selectedChar]];
[CharacterTrait2 selectItemWithTitle: [myChar getTrait:2 atIndex: selectedChar]];
}
-(void)characterListsReset:(NSNotification *)notification
{
[CharacterList selectRow:0 byExtendingSelection:NO];
[self refreshCharacterInfo];
}
-(void)newCharacterCustomDialogImage:(NSNotification *)notification
{
WNCharacters *myChar = [self characters];
int selectedChar = [CharacterList selectedRow];
[myChar setDialogImageAtIndex: selectedChar to:[notification object]];
}
-(void)characterListReload:(NSNotification *)notification
{
[CharacterList reloadData];
[CharacterUnitList reloadData];
}
@end

View file

@ -1,13 +0,0 @@
/* WNCharacterList */
#import <Cocoa/Cocoa.h>
@interface WNCharacterList : NSObject
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex;
@end

View file

@ -1,32 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCharacterList.h"
#import "WNUnits.h"
@implementation WNCharacterList
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return [[[WNCampaign getMainCampaign] getCharacters] count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
NSString *identifier = [tableColumn identifier];
WNCharacters *tmpChars = [[WNCampaign getMainCampaign] getCharacters];
if ([identifier isEqualTo:@"image"])
{
return [WNUnits imageAtIndex:[tmpChars getUnitTypeAtIndex:row]];
}else if ([identifier isEqualTo:@"name"]){
return [tmpChars getNameAtIndex:row];
}
return @"";
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
WNCharacters *tmpChar = [[WNCampaign getMainCampaign] getCharacters];
[tmpChar setNameAtIndex: rowIndex to: anObject];
}
@end

View file

@ -1,9 +0,0 @@
/* WNCharacterListView */
#import <Cocoa/Cocoa.h>
#import "WNIconListView.h"
@interface WNCharacterListView : WNIconListView
{
}
@end

View file

@ -1,6 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCharacterListView.h"
@implementation WNCharacterListView
@end

View file

@ -1,50 +0,0 @@
//
// WNCharacters.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon Apr 19 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WNCharacters : NSObject {
NSMutableArray *names; // Names of character
NSMutableArray *unitType; // Parent unit type of characters
NSMutableArray *hitPercentage; // Percentage of parent HP
NSMutableArray *useCustomDialog; // Dictates whether to use a custom icon
NSMutableArray *dialogImage; // This is the custom image to use for dialogs
NSMutableArray *trait1; // This is the first of the custom traits
NSMutableArray *trait2; // This is the second of the custom traits
NSMutableArray *onDeathAction; // This is the custom action on death
NSMutableArray *onDeathMessage; // This is what the character will say on death
NSMutableArray *ai; // This is the AI type
NSMutableDictionary *inPlay; // This provides a means of noting which characters are in play
}
-(WNCharacters *)init;
-(void) dealloc;
-(void)encodeWithCoder: (NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
-(int) count;
-(int) newCharacter; // Adds a new blank character and then returns its index number
-(void)setNameAtIndex:(int)index to:(NSString *)newName;
-(NSString *)getNameAtIndex: (int)index;
-(int)getUnitTypeAtIndex: (int)index;
-(void)setUnitTypeAtIndex: (int)index to:(int)newType;
-(void)setDialogImageAtIndex:(int)index to:(NSImage *)newImage;
-(NSImage *)getDialogImageAtIndex:(int)index;
-(void)setHPAtIndex:(int)index to:(float)newVal;
-(float)getHPAtIndex:(int)index;
-(void)setDeathMessageAtIndex:(int)index to:(NSString *)newMessage;
-(NSString *)getDeathMessageAtIndex:(int)index;
-(void)setTrait:(int)traitNo atIndex:(int)index to:(NSString *)newTrait;
-(NSString *)getTrait:(int)trainNo atIndex:(int)index;
-(void)setAIAtIndex:(int)index to:(NSString *)newAI;
-(NSString *)getAIAtIndex:(int)index;
-(void)setDeathActionAtIndex:(int)index to:(NSString *)newAction;
-(NSString *)getDeathActionAtIndex:(int)index;
-(void)initInPlay;
-(void)clearInPlay;
-(void)setInPlay:(int)index;
-(NSMutableString *)exportCharacterEventsFromScenario: (id)sender;
@end

View file

@ -1,281 +0,0 @@
//
// WNCharacters.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Mon Apr 19 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCharacters.h"
#import "WNUnits.h"
@implementation WNCharacters
-(WNCharacters *)init
{
[super init];
names = [[NSMutableArray alloc] init];
unitType = [[NSMutableArray alloc] init];
hitPercentage = [[NSMutableArray alloc] init];
useCustomDialog = [[NSMutableArray alloc] init];
dialogImage = [[NSMutableArray alloc] init];
trait1 = [[NSMutableArray alloc] init];
trait2 = [[NSMutableArray alloc] init];
onDeathAction = [[NSMutableArray alloc] init];
onDeathMessage = [[NSMutableArray alloc] init];
ai = [[[NSMutableArray alloc] init] retain];
[names retain];
[unitType retain];
[hitPercentage retain];
[useCustomDialog retain];
[dialogImage retain];
[trait1 retain];
[trait2 retain];
[onDeathAction retain];
[onDeathMessage retain];
[self newCharacter];
return self;
}
-(void) dealloc
{
[names autorelease];
[unitType autorelease];
[hitPercentage autorelease];
[useCustomDialog autorelease];
[dialogImage autorelease];
[trait1 autorelease];
[trait2 autorelease];
[onDeathAction autorelease];
[onDeathMessage autorelease];
[ai autorelease];
[super dealloc];
}
-(void)encodeWithCoder: (NSCoder *)coder
{
NSMutableArray *tmpUnitArray = [WNUnits convertIndexArray: unitType];
[coder encodeObject: names forKey:@"names"];
[coder encodeObject: tmpUnitArray forKey:@"unitType"];
[coder encodeObject: hitPercentage forKey:@"hitPercentage"];
[coder encodeObject: useCustomDialog forKey:@"useCustomDialog"];
[coder encodeObject: dialogImage forKey:@"dialogImage"];
[coder encodeObject: trait1 forKey:@"trait1"];
[coder encodeObject: trait2 forKey:@"trait2"];
[coder encodeObject: onDeathAction forKey:@"onDeathAction"];
[coder encodeObject: onDeathMessage forKey:@"onDeathMessage"];
[coder encodeObject: ai forKey:@"ai"];
[tmpUnitArray autorelease];
}
- (id)initWithCoder:(NSCoder *)coder
{
[super init];
names = [[coder decodeObjectForKey:@"names"] retain];
unitType = [WNUnits convertNameArray:[coder decodeObjectForKey:@"unitType"]];
hitPercentage = [[coder decodeObjectForKey:@"hitPercentage"] retain];
useCustomDialog = [[coder decodeObjectForKey:@"useCustomDialog"] retain];
dialogImage = [[coder decodeObjectForKey:@"dialogImage"] retain];
trait1 = [[coder decodeObjectForKey:@"trait1"] retain];
trait2 = [[coder decodeObjectForKey:@"trait2"] retain];
onDeathAction = [[coder decodeObjectForKey:@"onDeathAction"] retain];
onDeathMessage = [[coder decodeObjectForKey:@"onDeathMessage"] retain];
ai = [coder decodeObjectForKey:@"ai"];
if (ai==nil)
{
ai = [[[NSMutableArray alloc] init] retain];
int loop;
for (loop=0; loop<[names count] ;loop++) [ai addObject:@"default"];
}
[ai retain];
return self;
}
-(int) count
{
return [names count];
}
-(int) newCharacter
{
[names addObject:@"Unknown Warrior"];
[unitType addObject:[[NSNumber alloc] initWithInt:0]];
[hitPercentage addObject:[[NSNumber alloc] initWithFloat:100.0]];
[useCustomDialog addObject:@"No"];
[dialogImage addObject:[[NSImage alloc] init]];
[trait1 addObject:@"[None Specified]"];
[trait2 addObject:@"[None Specified]"];
[onDeathAction addObject:@"Nothing"];
[onDeathMessage addObject:@"I am defeated... aaaaarrrrfgggghhh"];
[ai addObject:@"default"];
return ([names count]-1);
}
-(void)setNameAtIndex:(int)index to:(NSString *)newName
{
[names replaceObjectAtIndex:index withObject: newName];
}
-(NSString *)getNameAtIndex: (int)index
{
return [names objectAtIndex: index];
}
-(int)getUnitTypeAtIndex: (int)index
{
return [[unitType objectAtIndex:index] intValue];
}
-(void)setUnitTypeAtIndex: (int)index to:(int)newType
{
[unitType replaceObjectAtIndex:index withObject: [[NSNumber alloc] initWithInt:newType]];
}
-(void)setDialogImageAtIndex:(int)index to:(NSImage *)newImage
{
[dialogImage replaceObjectAtIndex: index withObject: newImage];
}
-(NSImage *)getDialogImageAtIndex:(int)index
{
return [dialogImage objectAtIndex:index];
}
-(void)setHPAtIndex:(int)index to:(float)newVal
{
[hitPercentage replaceObjectAtIndex:index withObject:[[NSNumber alloc] initWithFloat:newVal]];
}
-(float)getHPAtIndex:(int)index
{
return [[hitPercentage objectAtIndex:index] floatValue];
}
-(void)setDeathMessageAtIndex:(int)index to:(NSString *)newMessage
{
[onDeathMessage replaceObjectAtIndex:index withObject:newMessage];
}
-(NSString *)getDeathMessageAtIndex:(int)index
{
return [onDeathMessage objectAtIndex:index];
}
-(void)setTrait:(int)traitNo atIndex:(int)index to:(NSString *)newTrait
{
switch(traitNo)
{
case 1:
[trait1 replaceObjectAtIndex:index withObject:newTrait];
break;
case 2:
[trait2 replaceObjectAtIndex:index withObject:newTrait];
break;
}
}
-(NSString *)getTrait:(int)trainNo atIndex:(int)index
{
switch(trainNo)
{
case 1:
return [trait1 objectAtIndex:index];
break;
case 2:
return [trait2 objectAtIndex:index];
break;
}
return nil;
}
-(void)setAIAtIndex:(int)index to:(NSString *)newAI
{
[ai replaceObjectAtIndex:index withObject:newAI];
}
-(NSString *)getAIAtIndex:(int)index
{
return [ai objectAtIndex:index];
}
-(void)setDeathActionAtIndex:(int)index to:(NSString *)newAction
{
[onDeathAction replaceObjectAtIndex:index withObject:newAction];
}
-(NSString *)getDeathActionAtIndex:(int)index
{
return [onDeathAction objectAtIndex:index];
}
-(void)initInPlay
{
inPlay = [[[NSMutableDictionary alloc] init] retain];
}
-(void)clearInPlay
{
[inPlay autorelease];
}
-(void)setInPlay:(int)index
{
fprintf(stderr, "Marking unit %d in play\n", index);
if (inPlay == nil) [self initInPlay];
[inPlay setObject:@"Found" forKey:[NSNumber numberWithInt: index]];
}
-(NSMutableString *)exportCharacterEventsFromScenario: (WMLScenario *)sender
{ // Export events for those characters marked as in play
NSArray *keys = [inPlay allKeys];
NSMutableString *text = [[[NSMutableString alloc] init] retain];
fprintf(stderr, "Getting next scenario info for Character events...");
NSMutableDictionary *nextScenarioText = [sender getNextScenarioText];
[nextScenarioText retain];
fprintf(stderr, "Done\n");
int noInPlay = [keys count];
int i, index;
NSString *doOnDeath;
for (i=0; i<noInPlay ;i++)
{
index = [[keys objectAtIndex:i] intValue];
// first death message
[text appendString:@"[event]\nname=die\n[filter]\ndescription="];
[text appendString:[names objectAtIndex:index]];
[text appendString:@"\n[/filter]\n[message]\nspeaker=unit\nmessage=\""];
[text appendString:[onDeathMessage objectAtIndex:index]];
// Need to add custom icon stuff
[text appendString:@"\"\n[/message]\n"];
doOnDeath = [onDeathAction objectAtIndex:index];
if ([doOnDeath isEqualTo:@"Victory"])
{
[text appendString:@"[endlevel]\nresult=victory\n"];
[text appendString:[nextScenarioText objectForKey:@"Victory"]];
[text appendString:@"[/endlevel]\n"];
}
if ([doOnDeath isEqualTo:@"Continue"])
{
[text appendString:@"[endlevel]\nresult=continue\n"];
[text appendString:[nextScenarioText objectForKey:@"Continue"]];
[text appendString:@"[/endlevel]\n"];
}
[text appendString:@"[/event]\n\n"];
}
[nextScenarioText autorelease];
fprintf(stderr, "Character events export prepared\n");
return text;
}
@end

View file

@ -1,11 +0,0 @@
/* WNCustomDialogView */
#import <Cocoa/Cocoa.h>
@interface WNCustomDialogView : NSImageView
{
}
-(void)awakeFromNib;
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
@end

View file

@ -1,55 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCustomDialogView.h"
@implementation WNCustomDialogView
-(void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:
NSTIFFPboardType, NSPICTPboardType, NSFilenamesPboardType, nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSColorPboardType] )
if (sourceDragMask & NSDragOperationGeneric)
return NSDragOperationGeneric;
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
if (sourceDragMask & NSDragOperationCopy)
return NSDragOperationCopy;
return NSDragOperationNone;
}
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
NSImage *draggedImage = [NSImage alloc];
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSTIFFPboardType] )
{
[draggedImage initWithPasteboard:pboard];
} else if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
[draggedImage initWithContentsOfFile:[files objectAtIndex:0]];
}
if (draggedImage != nil)
{
[draggedImage retain];
[self setImage:draggedImage];
[[NSNotificationCenter defaultCenter]
postNotificationName:@"newCharacterCustomDialogImage" object:draggedImage];
}
return YES;
}
@end

View file

@ -1,12 +0,0 @@
/* WNDefeatList */
#import <Cocoa/Cocoa.h>
@interface WNDefeatList : NSObject
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex;
@end

View file

@ -1,22 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNDefeatList.h"
@implementation WNDefeatList
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return [[[WNCampaign getActiveScenario] getDefeatConditionsFor: [WNCampaign getDifficulty]] count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
return [[[WNCampaign getActiveScenario] getDefeatConditionsFor: [WNCampaign getDifficulty]] objectAtIndex: row];
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
[[[[WNCampaign getActiveScenario] getDefeatConditionsFor: [WNCampaign getDifficulty]] objectAtIndex: rowIndex] setString: anObject];
}
@end

View file

@ -1,20 +0,0 @@
//
// WNEventDataSource.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Tue May 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WNEventDataSource : NSObject {
}
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(WMLEvent *)item;
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(WMLEvent *)item;
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(WMLEvent *)item;
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(WMLEvent *)item;
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
@end

View file

@ -1,67 +0,0 @@
//
// WNEventDataSource.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Tue May 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNEventDataSource.h"
@implementation WNEventDataSource
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(WMLEvent *)item
{
if (item == nil)
{
fprintf(stderr, "Checking no events in scenario for outline view:%d\n", [[WNCampaign getActiveScenario] noEvents]);
return [[WNCampaign getActiveScenario] noEvents];
}
fprintf(stderr, "Checking no event children: %d\n", [item noEventChildren]);
return [item noEventChildren];
}
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(WMLEvent *)item
{
if (item == nil)
{
// fprintf(stderr, "Getting child %d of main list = %d\n", index, [[WNCampaign getActiveScenario] getEventAtIndex:index]);
return [[WNCampaign getActiveScenario] getEventAtIndex:index];
}
// fprintf(stderr, "Getting child %d of object %d = \n", index, item,[item getEventChildAtIndex:index] );
return [item getEventChildAtIndex:index];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(WMLEvent *)item
{
return [item isEventATag];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(WMLEvent *)item
{
NSString *identifier = [tableColumn identifier];
//return @"TEST";
if ([identifier isEqualTo:@"Name"])
{
return [item getEventName];
}
if ([identifier isEqualTo:@"Value"])
{
return [item getEventStringValue];
}
return @"Error Unknown identifier";
}
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString *identifier = [tableColumn identifier];
if ([identifier isEqualTo:@"Name"])
{
[item setEventName:object];
}else{
fprintf(stderr, "Error - trying to set outlineview item illegally\n");
}
}
@end

View file

@ -1,33 +0,0 @@
/* WNEventEditor */
#import <Cocoa/Cocoa.h>
#import "WNCharacterListView.h"
#import "WNIconListView.h"
@interface WNEventEditor : NSObject
{
IBOutlet NSPopUpButton *actionType;
IBOutlet WNCharacterListView *eventCharacterList;
IBOutlet NSTabView *eventInfoTabs;
IBOutlet NSOutlineView *eventList;
IBOutlet NSTableView *eventSideList;
IBOutlet NSPopUpButton *eventTrigger;
IBOutlet WNIconListView *eventUnitList;
IBOutlet NSTextField *turnNo;
}
- (void)awakeFromNib;
- (IBAction)actionAdd:(id)sender;
- (IBAction)actionTypeSelect:(id)sender;
- (IBAction)eventAdd:(id)sender;
- (IBAction)eventCharacterSelect:(id)sender;
- (IBAction)eventRemove:(id)sender;
- (IBAction)eventSelect:(id)sender;
- (IBAction)eventSideSelect:(id)sender;
- (IBAction)eventTriggerSelect:(id)sender;
- (IBAction)eventUnitSelect:(id)sender;
- (IBAction)filterAdd:(id)sender;
- (WMLEvent *)findSelectedEvent;
- (IBAction)turnNoSet:(id)sender;
- (void)finishedLaunching:(NSNotification *)notification;
-(void)eventListReset:(NSNotification *)notification;
@end

View file

@ -1,151 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNEventEditor.h"
#import "WNEventLookup.h"
@implementation WNEventEditor
-(void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(finishedLaunching:)
name:@"finishedLaunching" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(eventListReset:)
name:@"campaignReset" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(eventListReset:)
name:@"eventListReset" object:nil];
}
- (IBAction)actionAdd:(id)sender
{
int row = [eventList selectedRow];
WMLEvent *event, *newChild;
if (row != -1)
{
fprintf(stderr, "Adding action...\n");
event = [eventList itemAtRow: row];
newChild = [[WMLEvent alloc] initWithWMLTag:[WNCampaign getEventTagForTag:[actionType titleOfSelectedItem]] withParent:event];
fprintf(stderr, "Action prepared...\n");
[event addEventChild:newChild];
fprintf(stderr, "Action added\n");
}
[eventList reloadData];
}
- (IBAction)actionTypeSelect:(id)sender
{
}
- (IBAction)eventAdd:(id)sender
{
[[WNCampaign getActiveScenario] addNewEvent];
[eventList reloadData];
}
- (IBAction)eventCharacterSelect:(id)sender
{
int thisChar = [sender selectedRow];
WNCharacters *characters = [[WNCampaign getMainCampaign] getCharacters];
[[self findSelectedEvent] setEventValue:thisChar string:[characters getNameAtIndex: thisChar]];
[eventList reloadData];
}
- (IBAction)eventRemove:(id)sender
{
WMLEvent *thisEvent = [self findSelectedEvent];
WMLEvent *parentEvent = [thisEvent getEventParent];
NSString *tag = [parentEvent getEventTag];
if (([tag hasPrefix:@"[filter"])||([thisEvent isEventATag]))
{
fprintf(stderr, "Attempting to delete event\n");
[parentEvent removeEventChild: thisEvent];
[eventList reloadData];
}else{
fprintf(stderr, "Can't delete, not part of a filter nor is a main tag\n");
}
}
- (IBAction)eventSideSelect:(id)sender
{
[[self findSelectedEvent] setEventIntValue:[sender selectedRow]];
[eventList reloadData];
}
- (IBAction)eventTriggerSelect:(id)sender
{
}
- (IBAction)eventUnitSelect:(id)sender
{
[[self findSelectedEvent] setEventIntValue:[sender selectedRow]];
[eventList reloadData];
}
- (IBAction)filterAdd:(id)sender
{
}
- (WMLEvent *)findSelectedEvent
{
int row = [eventList selectedRow];
if (row != 1) return [eventList itemAtRow: row];
return nil;
}
- (IBAction)turnNoSet:(id)sender
{
}
- (void)finishedLaunching:(NSNotification *)notification
{
// Setup action menu
[WNEventLookup init];
[actionType removeAllItems];
WMLTag *tagList = [WNCampaign getEventTags];
int noTags = [tagList childrenCount];
fprintf(stderr, "Initialising action menu... found %d actions \n", noTags);
int i;
for (i=0; i< noTags ;i++)
{
[actionType addItemWithTitle:[[tagList getChildAtIndex:i] getTag]];
}
}
- (IBAction)eventSelect:(id)sender
{ // An event has been selected :)
int row = [sender selectedRow];
int eventType;
if (row != -1)
{
WMLEvent *event = [sender itemAtRow: row];
[WNEventLookup setCurrentEvent:event];
eventType = [event getEventType];
switch(eventType)
{
case 1: // Character
[eventCharacterList selectRow:[event getEventIntValue] byExtendingSelection:NO];
break;
case 2: // Unit
[eventUnitList selectRow:[event getEventIntValue] byExtendingSelection:NO];
break;
case 3: // Side
[eventSideList selectRow:[event getEventIntValue] byExtendingSelection:NO];
break;
case 4:// MapLoc
[WNEventLookup setMapLoc:[event getEventMapLoc]];
break;
}
[eventInfoTabs selectTabViewItemWithIdentifier: [WNEventLookup settingForType:eventType]];
fprintf(stderr, "Setting tab to :%s\n", [[WNEventLookup settingForType:eventType] cString]);
[[NSNotificationCenter defaultCenter] postNotificationName:@"eventSelected" object:self];
}
}
-(void)eventListReset:(NSNotification *)notification
{
[eventList reloadData];
}
@end

View file

@ -1,21 +0,0 @@
//
// WNEventLookup.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed May 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WNEventLookup : NSObject {
}
+(void)init;
+(int)typeForSetting:(NSString *)setting;
+(NSString *)settingForType:(int)type;
+(void)setMapLoc:(NSPoint)mapPos;
+(NSPoint)getMapLoc;
+(void)setCurrentEvent:(WMLEvent *)thisEvent;
+(WMLEvent *)getCurrentEvent;
@end

View file

@ -1,71 +0,0 @@
//
// WNEventLookup.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Wed May 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNEventLookup.h"
#import "WMLEvent.h"
@implementation WNEventLookup
WMLEvent *currentEvent;
NSMutableDictionary *dict;
NSMutableArray *types;
int WNEinitialised;
NSPoint mapLoc;
+(void)init
{
dict = [[[NSMutableDictionary alloc] init] retain];
[dict setObject:[[NSNumber alloc] initWithInt:0] forKey:@"None"];
[dict setObject:[[NSNumber alloc] initWithInt:1] forKey:@"character"];
[dict setObject:[[NSNumber alloc] initWithInt:2] forKey:@"unit"];
[dict setObject:[[NSNumber alloc] initWithInt:3] forKey:@"side"];
[dict setObject:[[NSNumber alloc] initWithInt:4] forKey:@"maploc"];
[dict setObject:[[NSNumber alloc] initWithInt:5] forKey:@"info"];
[dict setObject:[[NSNumber alloc] initWithInt:6] forKey:@"text"];
types = [[[NSMutableArray alloc] init] retain];
[types addObject:@"none"];
[types addObject:@"character"];
[types addObject:@"unit"];
[types addObject:@"side"];
[types addObject:@"maploc"];
[types addObject:@"info"];
[types addObject:@"text"];
}
+(int)typeForSetting:(NSString *)setting
{
return [[dict objectForKey:setting] intValue];
}
+(NSString *)settingForType:(int)type
{
return [types objectAtIndex:type];
}
+(void)setMapLoc:(NSPoint)mapPos
{
mapLoc = mapPos;
}
+(NSPoint)getMapLoc
{
return mapLoc;
}
+(void)setCurrentEvent:(WMLEvent *)thisEvent
{
currentEvent = thisEvent;
}
+(WMLEvent *)getCurrentEvent
{
return currentEvent;
}
@end

View file

@ -1,15 +0,0 @@
/* WNEventMapView */
#import <Cocoa/Cocoa.h>
#import "WNMapView.h"
@interface WNEventMapView : WNMapView
{
NSImage *eventImage;
NSImage *scaledEventImage;
}
-(void)awakeFromNib;
-(void)drawRect:(NSRect)rect;
-(void)mouseDown:(NSEvent *)event;
-(void)eventSelected:(NSNotification *)notification;
@end

View file

@ -1,87 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNEventMapView.h"
#import "WNEventLookup.h"
@implementation WNEventMapView
-(void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(eventSelected:)
name:@"eventSelected" object:nil];
eventImage = [[NSImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"eventmarker.png"]];
scaledEventImage = [eventImage copy];
[super awakeFromNib];
}
- (void)drawRect:(NSRect)rect
{
int scaledX=70, scaledY=70;
NSSize scaledSize = {70,70};
float zoomLevel = [WNCampaign getMapZoom];
if (zoomLevel !=1.0)
{
scaledX = 70*zoomLevel;
scaledY = 70*zoomLevel;
scaledSize.width = scaledX;
scaledSize.height = scaledY;
}
if (zoomLevel != lastZoomLevel)
{
[scaledEventImage autorelease];
scaledCursor = [eventImage copy];
[scaledEventImage setScalesWhenResized:YES];
[scaledEventImage setSize:scaledSize];
[scaledEventImage retain];
}
[super drawRect:rect];
}
-(void)drawAt:(NSPoint)myPoint mapPoint:(WMLMapPoint *)myMapPoint zoomed:(BOOL)zoomed
{
[super drawAt:myPoint mapPoint:myMapPoint zoomed:zoomed]; // draw normally
NSPoint eventPoint = [WNEventLookup getMapLoc]; // find out the event position
NSPoint hexPoint = [HexUtils pixelFromFlatHexX: eventPoint.x y:eventPoint.y];
//fprintf(stderr, "x1:%g, x2:%g, y1:%g, y2:%g\n", myPoint.x, hexPoint.x, myPoint.y, hexPoint.y);
if ((hexPoint.x == myPoint.x)&&(hexPoint.y == myPoint.y))
{
fprintf(stderr, "Drawing event icon\n");
[scaledEventImage compositeToPoint: myPoint operation:NSCompositeSourceOver];
}
}
-(void)mouseDown:(NSEvent *)event
{
NSPoint eventLocation = [event locationInWindow];
NSPoint localPos = [self convertPoint:eventLocation fromView:nil];
fprintf(stderr,"*** Click in event map: %f,%f\n",localPos.x,localPos.y);
NSPoint hexPos = [HexUtils flatHexFromX: localPos.x y: localPos.y];
hexPos.y += 1;
hexPos.x += 1;
// int x = hexPos.x;
// int y = hexPos.y;
NSEventType type = [event type];
int modifiers = [event modifierFlags];
if ((modifiers & NSControlKeyMask)==NSControlKeyMask) type = NSRightMouseDown;
switch(type)
{
case NSLeftMouseDown:
// fprintf(stderr, "Placing event at x:%d, y:%d, hexX:%g, hexY:%g\n", x,y,hexPos.x, hexPos.y);
[WNEventLookup setMapLoc:hexPos];
[[WNEventLookup getCurrentEvent] setEventMapLoc:hexPos];
break;
case NSRightMouseDown:
break;
default:
break;
}
[self display];
}
-(void)eventSelected:(NSNotification *)notification
{
fprintf(stderr, "New event selected so redraw\n");
[self display];
}
@end

View file

@ -1,30 +0,0 @@
//
// WNFileLocations.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Thu Mar 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WNFileLocations : NSObject {
}
+(BOOL)init;
+(NSString *)dataLoc;
+(NSString *)unitDataLoc;
+(NSString *)imageLoc;
+(NSString *)terrainImageLoc;
+(void)setSaveLocation:(NSString *)saveLoc;
+(NSString *)getSaveLocation;
+(void)setExportDataLocation:(NSString *)newLoc;
+(NSMutableString *)getExportDataLocation;
+(void)setExportUnitsLocation:(NSString *)newLoc;
+(NSMutableString *)getExportUnitsLocation;
+(void)setExportScenariosLocation:(NSString *)newLoc;
+(NSMutableString *)getExportScenariosLocation;
+(void)setExportImagesLocation:(NSString *)newLoc;
+(NSMutableString *)getExportImagesLocation;
@end

View file

@ -1,147 +0,0 @@
//
// WNFileLocations.m
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Thu Mar 25 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNFileLocations.h"
@implementation WNFileLocations
BOOL initialised=NO;
NSString *imageLoc;
NSString *dataLoc;
NSString *unitDataLoc;
NSString *scenarioLoc;
NSString *terrainImageLoc;
NSMutableString *saveLocation;
NSMutableString *exportData;
NSMutableString *exportUnits;
NSMutableString *exportScenarios;
NSMutableString *exportImages;
+(BOOL)init
{
NSString *MyLoc;
NSString *BFWLoc;
NSString *ContentsLoc;
NSString *ResourcesLoc;
if (initialised == NO) // OK, we haven't been set up yet
{
fprintf(stderr, "Initialising LOCATION Info\n");
MyLoc = [[NSBundle mainBundle] bundlePath];
fprintf(stderr, "Bundle loc: %s\n", [MyLoc fileSystemRepresentation]);
#ifdef embeddedEditor
ResourcesLoc = [[NSBundle mainBundle] resourcePath];
#else
BFWLoc = [[MyLoc stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Battle For Wesnoth.app"];
ContentsLoc = [BFWLoc stringByAppendingPathComponent:@"Contents"];
ResourcesLoc = [ContentsLoc stringByAppendingPathComponent:@"Resources"];
#endif
dataLoc = [ResourcesLoc stringByAppendingPathComponent:@"data"];
[dataLoc retain];
unitDataLoc = [dataLoc stringByAppendingPathComponent:@"units"];
[unitDataLoc retain];
fprintf(stderr, "dataLoc:%s\n", [dataLoc fileSystemRepresentation]);
imageLoc = [ResourcesLoc stringByAppendingPathComponent:@"images"];
[imageLoc retain];
terrainImageLoc = [imageLoc stringByAppendingPathComponent:@"terrain"];
[terrainImageLoc retain];
scenarioLoc = [dataLoc stringByAppendingPathComponent:@"scenarios"];
[scenarioLoc retain];
saveLocation = [[NSMutableString alloc] initWithString:@""];
[saveLocation retain];
exportData = [[NSMutableString alloc] init];
[exportData retain];
exportUnits = [[NSMutableString alloc] init];
[exportUnits retain];
exportScenarios = [[NSMutableString alloc] init];
[exportScenarios retain];
exportImages = [[NSMutableString alloc] init];
[exportImages retain];
initialised = YES;
[super init];
}
return YES;
}
+(NSString *)dataLoc
{
if (initialised == NO) [self init];
return dataLoc;
}
+(NSString *)unitDataLoc
{
if (initialised == NO) [self init];
return unitDataLoc;
}
+(NSString *)imageLoc
{
if (initialised == NO) [self init];
return imageLoc;
}
+(NSString *)terrainImageLoc
{
if (initialised == NO) [self init];
return terrainImageLoc;
}
+(void)setSaveLocation:(NSString *)saveLoc
{
[saveLocation setString:saveLoc];
}
+(NSString *)getSaveLocation
{
return saveLocation;
}
+(void)setExportDataLocation:(NSString *)newLoc
{
[exportData setString:newLoc];
}
+(NSMutableString *)getExportDataLocation
{
return exportData;
}
+(void)setExportUnitsLocation:(NSString *)newLoc
{
[exportUnits setString:newLoc];
}
+(NSMutableString *)getExportUnitsLocation
{
return exportUnits;
}
+(void)setExportScenariosLocation:(NSString *)newLoc
{
[exportScenarios setString:newLoc];
}
+(NSMutableString *)getExportScenariosLocation
{
return exportScenarios;
}
+(void)setExportImagesLocation:(NSString *)newLoc
{
[exportImages setString:newLoc];
}
+(NSMutableString *)getExportImagesLocation
{
return exportImages;
}
@end

View file

@ -1,9 +0,0 @@
/* WNTerrainView */
#import <Cocoa/Cocoa.h>
@interface WNIconListView : NSTableView
{
}
-(void)awakeFromNib;
@end

View file

@ -1,17 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNIconListView.h"
#import "WNTerrains.h"
#import "WNUnits.h"
#import "HexUtils.h";
@implementation WNIconListView
-(void)awakeFromNib
{
// [WNTerrains init];
// [WNUnits init];
[HexUtils initWithWidth: 70];
NSTableColumn* theColumn = [self tableColumnWithIdentifier:@"image"];
[theColumn setDataCell:[[NSImageCell alloc] initImageCell:nil]];
[self reloadData];
}
@end

View file

@ -1,9 +0,0 @@
/* WNLeaderListView */
#import <Cocoa/Cocoa.h>
#include "WNIconListView.h"
@interface WNLeaderListView : WNIconListView
{
}
@end

View file

@ -1,5 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNLeaderListView.h"
@implementation WNLeaderListView
@end

View file

@ -1,18 +0,0 @@
/* WNLoadSave */
#import <Cocoa/Cocoa.h>
@interface WNLoadSave : NSObject
{
IBOutlet NSProgressIndicator *loadProgress;
IBOutlet NSProgressIndicator *saveProgress;
}
- (IBAction)export:(id)sender;
- (IBAction)load:(id)sender;
- (void)doLoadFile:(NSString *)fileToLoad;
- (IBAction)revert:(id)sender;
- (IBAction)save:(id)sender;
- (IBAction)saveAs:(id)sender;
- (NSWindow *)startSaveWindow;
- (void)stopSaveWindow;
@end

View file

@ -1,109 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNLoadSave.h"
#import "WNCampaign.h"
#import "WNFileLocations.h"
@implementation WNLoadSave
- (IBAction)export:(id)sender
{
NSSavePanel *saveDialog = [NSSavePanel savePanel];
int saveResult = [saveDialog runModalForDirectory:NSHomeDirectory() file:@""];
if (saveResult == NSOKButton)
{
NSWindow *tmpSaveWin = [self startSaveWindow];
[[WNCampaign getMainCampaign] exportToFolder:[saveDialog filename] withDialog:tmpSaveWin andIndicator: saveProgress];
[self stopSaveWindow];
}
}
- (IBAction)load:(id)sender
{
NSSavePanel *openDialog = [NSOpenPanel openPanel];
int openResult = [openDialog runModalForDirectory:NSHomeDirectory() file:@""];
if (openResult == NSOKButton) [self doLoadFile:[openDialog filename]];
}
- (void)doLoadFile:(NSString *)fileToLoad
{
NSWindow *loadWin = [WNCampaign windowForTitle:@"Loading Data"];
[loadWin center];
[loadWin makeKeyAndOrderFront: self];
[loadProgress setUsesThreadedAnimation:YES];
[loadProgress startAnimation: self];
//[NSApp runModalForWindow: loadWin];
[WNCampaign setMainCampaign: [NSKeyedUnarchiver unarchiveObjectWithFile:fileToLoad]];
fprintf(stderr, "Unarchive compelte\n");
//[NSApp stopModal];
[loadWin orderOut: self];
[loadProgress stopAnimation: self];
[WNFileLocations setSaveLocation: fileToLoad];
[[NSNotificationCenter defaultCenter] postNotificationName:@"campaignReset" object:self];
[[WNPreferences getDocControl] noteNewRecentDocumentURL:[[NSURL alloc] initFileURLWithPath:fileToLoad]];
fprintf(stderr, "FileLoad complete\n");
}
- (IBAction)revert:(id)sender
{
NSString *lastFile = [WNFileLocations getSaveLocation];
if (lastFile != nil)
{
[self doLoadFile: lastFile];
}
}
- (IBAction)save:(id)sender
{
if ([[WNFileLocations getSaveLocation] isEqualTo:@""])
{
[self saveAs: self];
}else{
NSWindow *saveWin = [WNCampaign windowForTitle:@"Saving Data"];
[saveWin center];
[saveWin makeKeyAndOrderFront: self];
[saveProgress setUsesThreadedAnimation:YES];
[saveProgress startAnimation: self];
[NSKeyedArchiver archiveRootObject:[WNCampaign getMainCampaign] toFile:[WNFileLocations getSaveLocation]];
[saveWin orderOut: self];
[saveProgress stopAnimation: self];
}
}
- (IBAction)saveAs:(id)sender
{
NSSavePanel *saveDialog = [NSSavePanel savePanel];
int saveResult = [saveDialog runModalForDirectory:NSHomeDirectory() file:@""];
if (saveResult == NSOKButton)
{
NSWindow *saveWin = [WNCampaign windowForTitle:@"Saving Data"];
[saveWin center];
[saveWin makeKeyAndOrderFront: self];
[saveProgress setUsesThreadedAnimation:YES];
[saveProgress startAnimation: self];
[NSKeyedArchiver archiveRootObject:[WNCampaign getMainCampaign] toFile:[saveDialog filename]];
[WNFileLocations setSaveLocation: [saveDialog filename]];
[saveWin orderOut: self];
[saveProgress stopAnimation: self];
[[WNPreferences getDocControl] noteNewRecentDocumentURL:[[NSURL alloc] initFileURLWithPath:[saveDialog filename]]];
}
}
-(NSWindow *)startSaveWindow
{
NSWindow *saveWin = [WNCampaign windowForTitle:@"Saving Data"];
[saveProgress setIndeterminate: YES];
[saveWin center];
[saveWin makeKeyAndOrderFront: self];
[saveProgress setUsesThreadedAnimation:YES];
[saveProgress startAnimation: self];
return saveWin;
}
-(void)stopSaveWindow
{
[[WNCampaign windowForTitle:@"Saving Data"] orderOut: self];
[saveProgress stopAnimation: self];
}
@end

View file

@ -1,9 +0,0 @@
/* WNMainTabViewDelegate */
#import <Cocoa/Cocoa.h>
@interface WNMainTabViewDelegate : NSTabView
{
}
- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
@end

View file

@ -1,13 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNMainTabViewDelegate.h"
@implementation WNMainTabViewDelegate
-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
fprintf(stderr, "didSelectTabViewItem called\n");
NSString *thisTab = [tabViewItem identifier];
if ([thisTab isEqualTo:@"mapTab"])
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapTabSelected" object:self];
fprintf(stderr, "Now viewing tab %s\n", [thisTab UTF8String]);
}
@end

View file

@ -1,11 +0,0 @@
/* WNMapTabViewDelegate */
#import <Cocoa/Cocoa.h>
@interface WNMapTabViewDelegate : NSTabView
{
}
- (void)awakeFromNib;
-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
+(NSMutableString *)getTab;
@end

View file

@ -1,23 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNMapTabViewDelegate.h"
@implementation WNMapTabViewDelegate
NSMutableString *myTab;
- (void)awakeFromNib
{
myTab = [[NSMutableString alloc] initWithString:@"Terrain"];
[myTab retain];
}
-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
fprintf(stderr, "didSelectTabViewItem called\n");
[myTab setString:[tabViewItem identifier]];
}
+(NSMutableString *)getTab
{
return myTab;
}
@end

View file

@ -1,36 +0,0 @@
/* WNMapView */
#import <Cocoa/Cocoa.h>
@interface WNMapView : NSView
{
NSTextField *mapInfoTerrain;
NSTextView *mapInfoCharacterList;
NSTextView *mapInfoUnitList;
int lastHexX;
int lastHexY;
NSImage *cursor;
NSImage *scaledCursor;
NSMutableString *infoUnits, *infoCharacters;
NSTrackingRectTag mapRectTag;
BOOL mousePressed;
float lastZoomLevel;
}
- (BOOL)acceptsFirstResponder;
- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;
- (void)awakeFromNib;
- (void)drawAt:(NSPoint)myPoint mapPoint:(WMLMapPoint *)myPoint zoomed:(BOOL)zoomed;
- (void)displayUnitsAtPoint:(NSPoint)point mapPoint:(WMLMapPoint *)mapPoint forDifficulty:(NSString *)diff;
- (BOOL)isFlipped;
- (void)mapTabSelected:(NSNotification *)notification;
- (void)mapRestoreTracking:(NSNotification *)notification;
- (void)mapChanged:(NSNotification *)notification;
- (void)mouseDown:(NSEvent *)event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseMoved: (NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)mouseEntered: (NSEvent *)theEvent;
-(void)mapInfo:(NSNotification *)notification;
@end

View file

@ -1,314 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNCampaign.h"
#import "WNMapView.h"
#import "WNUnits.h"
#import "WNTerrains.h"
#import "WMLMap.h"
#import "WMLMapPoint.h"
#import "HexUtils.h"
#import "WNPreferences.h"
#import "WNMapTabViewDelegate.h"
@implementation WNMapView
float unitOpacity;
- (BOOL) acceptsFirstResponder
{
// We want this view to be able to receive key events.
return YES;
}
- (BOOL)becomeFirstResponder
{
[[self window] setAcceptsMouseMovedEvents: YES];
return YES;
}
- (BOOL)resignFirstResponder
{
[[self window] setAcceptsMouseMovedEvents: NO];
return YES;
}
-(void)awakeFromNib
{ // Add notification for Map Changes
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mapChanged:)
name:@"mapChanged" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mapRestoreTracking:)
name:@"mapRestoreTracking" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mapTabSelected:)
name:@"mapTabSelected" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mapInfo:)
name:@"mapInfo" object:nil];
[[self window] setAcceptsMouseMovedEvents: YES];
if ([[self window] acceptsMouseMovedEvents]) {fprintf(stderr,"window now acceptsMouseMovedEvents\n");}
cursor = [[NSImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: @"mapcursor.png"]];
scaledCursor = [cursor copy];
[cursor retain];
[scaledCursor retain];
mapRectTag = [self addTrackingRect: [self bounds] owner:self userData:nil assumeInside:NO];
// NSWindow * window = [self window];
// [window setAcceptsMouseMovedEvents: YES];
// [window acceptsFirstResponder: YES];
// [window makeFirstResponder: self];
infoUnits = [[[NSMutableString alloc] init] retain];
infoCharacters = [[[NSMutableString alloc] init] retain];
mousePressed = 0;
}
- (id)initWithFrame:(NSRect)frameRect
{
[super initWithFrame:frameRect];
return self;
}
- (void)drawRect:(NSRect)rect
{
WMLMapPoint *tmpPoint = nil;
WMLMap *tmpMap = nil;
NSMutableArray *tmpRow = nil;
NSPoint myPoint;
int scaledX=70, scaledY=70;
NSSize scaledSize = {70,70};
unitOpacity = [WNPreferences getUnitOpacity];
NSRect mapBounds = [self bounds];
float zoomLevel = [WNCampaign getMapZoom];
if (zoomLevel !=1.0)
{
scaledX = 70*zoomLevel;
scaledY = 70*zoomLevel;
scaledSize.width = scaledX;
scaledSize.height = scaledY;
}
if (zoomLevel != lastZoomLevel)
{
[scaledCursor autorelease];
scaledCursor = [cursor copy];
[scaledCursor setScalesWhenResized:YES];
[scaledCursor setSize:scaledSize];
[scaledCursor retain];
lastZoomLevel = zoomLevel;
}
// BG = Black
[[NSColor blackColor] set];
[NSBezierPath fillRect:mapBounds];
NSPoint hexStart = [HexUtils flatHexFromX:rect.origin.x y:rect.origin.y];
NSPoint hexEnd = [HexUtils flatHexFromX:(rect.origin.x+rect.size.width) y:(rect.origin.y+rect.size.height)];
int hexStartX = hexStart.x - 1;
int hexStartY = hexStart.y - 1;
int hexEndX = hexEnd.x + 1;
int hexEndY = hexEnd.y + 1;
if (hexStartX < 0) hexStartX = 0;
if (hexStartY < 0) hexStartY = 0;
int loopX=0, loopY=0, maxTile;
tmpMap = [WNCampaign getActiveMap];
for (loopY = hexStartY ;loopY<=hexEndY; loopY++)
{
tmpRow = [tmpMap getRow:loopY];
if (tmpRow != nil)
{
maxTile = [tmpRow count];
for (loopX = hexStartX ;((loopX<=hexEndX)&&(loopX<maxTile)); loopX++)
{
tmpPoint = [tmpRow objectAtIndex:loopX];
myPoint = [HexUtils pixelFromFlatHexX:loopX y:loopY];
myPoint.y+=scaledY;
if (zoomLevel == 1.0)
[self drawAt: myPoint mapPoint:tmpPoint zoomed:NO];
else
[self drawAt: myPoint mapPoint:tmpPoint zoomed:YES];
}
}
}
myPoint = [HexUtils pixelFromFlatHexX: lastHexX y:lastHexY];
myPoint.y+=scaledY;
if (zoomLevel == 1.0)
[cursor compositeToPoint: myPoint operation:NSCompositeSourceOver];
else
[scaledCursor compositeToPoint: myPoint operation:NSCompositeSourceOver];
}
-(void)drawAt:(NSPoint)myPoint mapPoint:(WMLMapPoint *)myMapPoint zoomed:(BOOL)zoomed
{
if (zoomed == NO)
{
[[[WNTerrains terrainAtIndex:[myMapPoint terrainID]] image]
compositeToPoint: myPoint operation:NSCompositeSourceOver];
}else{
[[[WNTerrains terrainAtIndex:[myMapPoint terrainID]] scaledImage]
compositeToPoint: myPoint operation:NSCompositeSourceOver];
}
if ([WNPreferences getPlaceEasy]==YES) [self displayUnitsAtPoint:myPoint mapPoint:myMapPoint forDifficulty:@"Easy"];
if ([WNPreferences getPlaceNormal]==YES) [self displayUnitsAtPoint:myPoint mapPoint:myMapPoint forDifficulty:@"Normal"];
if ([WNPreferences getPlaceHard]==YES) [self displayUnitsAtPoint:myPoint mapPoint:myMapPoint forDifficulty:@"Hard"];
}
- (void)displayUnitsAtPoint:(NSPoint)point mapPoint:(WMLMapPoint *)mapPoint forDifficulty:(NSString *)diff
{
NSNumber *tmpNum = [mapPoint getUnitIDForDifficulty:diff];
NSNumber *tmpType = [mapPoint getUnitTypeForDifficulty:diff];
if (tmpNum != nil)
{
switch([tmpType intValue])
{
case 1:
[[WNUnits scaledImageAtIndex:[tmpNum intValue]]
compositeToPoint: point operation:NSCompositeSourceOver fraction:unitOpacity];
break;
case 2:
[[WNUnits scaledImageAtIndex:
[[[WNCampaign getMainCampaign] getCharacters] getUnitTypeAtIndex:[tmpNum intValue]]]
compositeToPoint: point operation:NSCompositeSourceOver fraction:unitOpacity];
break;
default:
fprintf(stderr, "ERROR - Reached Default in displayUnitsAtPoint\n");
break;
}
}
}
- (BOOL)isFlipped
{
return YES;
}
-(void)mapTabSelected:(NSNotification *)notification
{
[self removeTrackingRect: mapRectTag];
mapRectTag = [self addTrackingRect: [self bounds] owner:self userData:nil assumeInside:NO];
[[self window] makeFirstResponder: self];
[[self window] setAcceptsMouseMovedEvents: NO];
[[self window] setAcceptsMouseMovedEvents: YES];
}
-(void)mapRestoreTracking:(NSNotification *)notification
{
[[self window] makeFirstResponder: self];
[[self window] setAcceptsMouseMovedEvents: NO];
[[self window] setAcceptsMouseMovedEvents: YES];
}
-(void)mapChanged:(NSNotification *)notification
{
WMLMap *tmpMap = [WNCampaign getActiveMap];
NSSize newSize;
NSPoint tmpPoint = [HexUtils pixelFromFlatHexX: ([tmpMap getWidth] + 1) y:([tmpMap getHeight] + 1)];
newSize.width = tmpPoint.x;
newSize.height = tmpPoint.y;
fprintf(stderr, "Setting Map Size To :%f,%f\n", newSize.width, newSize.height);
[self setFrameSize: newSize];
[self display];
[[self superview] display];
}
-(void)mouseDown:(NSEvent *)event
{
NSPoint eventLocation = [event locationInWindow];
NSPoint localPos = [self convertPoint:eventLocation fromView:nil];
fprintf(stderr,"*** Click PointFrame: %f,%f\n",localPos.x,localPos.y);
NSPoint hexPos = [HexUtils flatHexFromX: localPos.x y: localPos.y];
WMLMap *tmpMap = [WNCampaign getActiveMap];
int xPos = hexPos.x;
int yPos = hexPos.y;
NSMutableString *clickType = [WNMapTabViewDelegate getTab];
NSEventType type = [event type];
int modifiers = [event modifierFlags];
if ((modifiers & NSControlKeyMask)==NSControlKeyMask) type = NSRightMouseDown;
switch(type)
{
case NSLeftMouseDown:
mousePressed = YES;
if ([clickType isEqualTo:@"Terrain"])
[tmpMap setPointToTerrain:[WNPreferences getTerrainID] x:xPos y:yPos];
if ([clickType isEqualTo:@"Units"])
[tmpMap setPointToUnit:[WNPreferences getUnitID]
type:1 side:[WNPreferences getUnitSide] x:xPos y:yPos];
if ([clickType isEqualTo:@"Characters"])
[tmpMap setPointToUnit:[WNPreferences getCharacterID]
type:2 side:[WNPreferences getUnitSide] x:xPos y:yPos];
break;
case NSRightMouseDown:
[tmpMap clearUnitAtPointX: xPos y:yPos];
break;
default:
break;
}
[self display];
}
-(void)rightMouseDown:(NSEvent *)event
{
[self mouseDown: event];
}
-(void)rightMouseUp:(NSEvent *)event
{
}
-(void)mouseUp:(NSEvent *)event
{
mousePressed = NO;
}
- (void)mouseMoved: (NSEvent *)theEvent
{
// fprintf(stderr, "tracking mouse\n");
NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
NSPoint hexLoc = [HexUtils flatHexFromX: location.x y: location.y];
int tmpX = hexLoc.x;
int tmpY = hexLoc.y;
if ((tmpX != lastHexX)||(tmpY != lastHexY))
{
lastHexX = tmpX;
lastHexY = tmpY;
//[self display];
if (mousePressed) [[WNCampaign getActiveMap] setPointToTerrain: [WNPreferences getTerrainID] x:tmpX y:tmpY];
[[NSNotificationCenter defaultCenter] postNotificationName:@"mapChanged" object:self];
NSMutableString *clickType = [WNMapTabViewDelegate getTab];
if ([clickType isEqualTo:@"Info"])
{
WMLMapPoint *tmpPoint = [[WNCampaign getActiveMap] getMapPointAtX: tmpX Y:tmpY];
[mapInfoTerrain setStringValue:[[WNTerrains terrainAtIndex:[tmpPoint terrainID]] name]];
[tmpPoint mapPointUnitInfoToString:infoUnits characterTo:infoCharacters characters:[[WNCampaign getMainCampaign]getCharacters]];
[mapInfoUnitList setString:infoUnits];
[mapInfoCharacterList setString:infoCharacters];
}
}
}
- (void)mouseDragged:(NSEvent *)theEvent
{
[self mouseMoved: theEvent];
}
-(void)mouseEntered: (NSEvent *)theEvent
{
fprintf(stderr, "Mouse entered\n");
[[self window] makeFirstResponder: self];
[[self window] setAcceptsMouseMovedEvents: NO];
[[self window] setAcceptsMouseMovedEvents: YES];
}
-(void)mapInfo:(NSNotification *)notification
{
NSDictionary *tmpDict = [notification userInfo];
mapInfoTerrain = [tmpDict objectForKey:@"Terrain"];
mapInfoUnitList = [tmpDict objectForKey:@"Unit"];
mapInfoCharacterList = [tmpDict objectForKey:@"Character"];
}
@end

View file

@ -1,39 +0,0 @@
//
// WNPreferences.h
// Wesnoth Scenario Editor
//
// Created by Marcus on Sun Mar 28 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WMLTerrain.h"
@interface WNPreferences : NSObject {
}
+(void)setTerrain:(WMLTerrain *)setTerrain;
+(void)setTerrainID:(int)setTerrainID;
+(WMLTerrain *)getTerrain;
+(int)getTerrainID;
+(void)setUnitID:(int)setUnitID;
+(int)getUnitID;
+(void)setCharacterID:(int)setCharacterID;
+(int)getCharacterID;
+(void)setPlaceEasy:(BOOL)newVal;
+(BOOL)getPlaceEasy;
+(void)setPlaceNormal:(BOOL)newVal;
+(BOOL)getPlaceNormal;
+(void)setPlaceHard:(BOOL)newVal;
+(BOOL)getPlaceHard;
+(void)setUnitSide:(int)newVal;
+(int)getUnitSide;
+(void)setLoadIndicator:(NSProgressIndicator *)newIndicator;
+(NSProgressIndicator *)getLoadIndicator;
+(void)fillWithTraitTags:(NSMutableString *)dest forTrait:(NSString *)trait;
+(void)setDocControl:(NSDocumentController *)newDoc;
+(NSDocumentController *)getDocControl;
+(void)setUnitOpacity:(float)newOp;
+(float)getUnitOpacity;
@end

View file

@ -1,154 +0,0 @@
//
// WNPreferences.m
// Wesnoth Scenario Editor
//
// Created by Marcus on Sun Mar 28 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNPreferences.h"
#import "WMLTerrain.h"
@implementation WNPreferences
WMLTerrain *selectedTerrain;
int selectedTerrainID;
int selectedUnitID;
int selectedUnitSide;
int selectedCharacterID;
BOOL placeEasy;
BOOL placeNormal;
BOOL placeHard;
NSProgressIndicator *loadIndicator;
NSDocumentController *docControl;
float unitOpacityLevel;
+(void)setTerrain:(WMLTerrain *)setTerrain
{
selectedTerrain = setTerrain;
}
+(void)setTerrainID:(int)setTerrainID
{
selectedTerrainID = setTerrainID;
}
+(WMLTerrain *)getTerrain
{
return selectedTerrain;
}
+(int)getTerrainID
{
return selectedTerrainID;
}
+(void)setUnitID:(int)setUnitID
{
selectedUnitID = setUnitID;
}
+(int)getUnitID
{
return selectedUnitID;
}
+(void)setCharacterID:(int)setCharacterID
{
selectedCharacterID = setCharacterID;
}
+(int)getCharacterID
{
return selectedCharacterID;
}
+(void)setPlaceEasy:(BOOL)newVal
{
placeEasy = newVal;
}
+(BOOL)getPlaceEasy
{
return placeEasy;
}
+(void)setPlaceNormal:(BOOL)newVal
{
placeNormal = newVal;
}
+(BOOL)getPlaceNormal
{
return placeNormal;
}
+(void)setPlaceHard:(BOOL)newVal
{
placeHard = newVal;
}
+(BOOL)getPlaceHard
{
return placeHard;
}
+(void)setUnitSide:(int)newVal
{
selectedUnitSide = newVal;
}
+(int)getUnitSide
{
return selectedUnitSide;
}
+(void)setLoadIndicator:(NSProgressIndicator *)newIndicator
{
loadIndicator = newIndicator;
fprintf(stderr, "Load indicator set\n");
}
+(NSProgressIndicator *)getLoadIndicator
{
return loadIndicator;
}
+(void)fillWithTraitTags:(NSMutableString *)dest forTrait:(NSString *)trait
{
// currently long winded, should really automate
if ([trait isEqualTo:@"loyal"])
[dest setString:@"[trait]\nid=\"loyal\"\nname=\"loyal\"\n[effect]\napply_to=\"loyal\"\n[/effect]\n[/trait]\n"];
if ([trait isEqualTo:@"intelligent"])
[dest setString:@"[trait]\nid=\"intelligent\"\nname=\"intelligent\"\n[effect]\napply_to=\"max_experience\"\nincrease=\"-20%\"\n[/effect]\n[/trait]\n"];
if ([trait isEqualTo:@"strong"])
[dest setString:@"[trait]\nid=\"strong\"\nname=\"strong\"\n[effect]\napply_to=\"attack\"\nincrease_damage=\"1\"\nrange=\"short\"\n[/effect]\n[effect]\napply_to=\"hitpoints\"\nheal_full=\"yes\"\nincrease_total=\"2\"\n[/effect]\n[/trait]\n"];
if ([trait isEqualTo:@"quick"])
[dest setString:@"[trait]\nid=\"quick\"\nname=\"quick\"\n[effect]\napply_to=\"movement\"\nincrease=\"1\"\n[/effect]\n[effect]\napply_to=\"hitpoints\"\nheal_full=\"yes\"\nincrease_total=\"-10%\"\n[/effect]\n[/trait]\n"];
if ([trait isEqualTo:@"resilient"])
[dest setString:@"[trait]\nid=\"resilient\"\nname=\"resilient\"\n[effect]\napply_to=\"hitpoints\"\nheal_full=\"yes\"\nincrease_total=\"7\"\n[/effect]\n[/trait]\n"];
}
+(void)setDocControl:(NSDocumentController *)newDoc
{
[docControl autorelease];
docControl = newDoc;
}
+(NSDocumentController *)getDocControl
{
return docControl;
}
+(void)setUnitOpacity:(float)newOp
{
unitOpacityLevel = newOp;
}
+(float)getUnitOpacity
{
return unitOpacityLevel;
}
@end

View file

@ -1,9 +0,0 @@
/* WNRecruitListView */
#import <Cocoa/Cocoa.h>
#include "WNIconListView.h"
@interface WNRecruitListView : WNIconListView
{
}
@end

View file

@ -1,6 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNRecruitListView.h"
@implementation WNRecruitListView
@end

View file

@ -1,23 +0,0 @@
//
// WNScenario.h
// Wesnoth Scenario Editor
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WMLMap.h"
@interface WNScenario : NSObject {
NSString *name;
WMLMap *map;
WNScenario *winScenario;
WNScenario *loseScenario;
WNScenario *continueScenario;
}
-(void)init;
@end

View file

@ -1,28 +0,0 @@
//
// WNScenario.m
// Wesnoth Scenario Editor
//
// This class represents a single scenario
//
// Created by Marcus Phillips on Fri Mar 26 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNScenario.h"
@implementation WNScenario
-(void)init // Initialises a scenario
{
name = [[NSString alloc] initWithString:@"untitled"];
[name retain];
map = [WMLMap alloc];
[map initWithSize: 50 by:50];
[map retain];
winScenario = nil;
continueScenario = nil;
loseScenario = nil;
}
@end

View file

@ -1,10 +0,0 @@
/* WNScenarioDesignDelegate */
#import <Cocoa/Cocoa.h>
@interface WNScenarioDesignDelegate : NSObject
{
}
- (IBAction)windowDidBecomeKey:(id)sender;
- (IBAction)windowDidResignKey:(id)sender;
@end

View file

@ -1,18 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNScenarioDesignDelegate.h"
@implementation WNScenarioDesignDelegate
- (IBAction)windowDidBecomeKey:(id)sender
{
NSLog(@"Editor now key");
[WNCampaign switchToEditorMenu];
}
- (IBAction)windowDidResignKey:(id)sender
{
NSLog(@"Editor lost key");
[WNCampaign switchToMainMenu];
}
@end

View file

@ -1,13 +0,0 @@
/* WNScenarioList */
#import <Cocoa/Cocoa.h>
#import "WNCampaign.h"
#import "WMLCampaign.h"
@interface WNScenarioList : NSObject
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
@end

View file

@ -1,70 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNScenarioList.h"
@implementation WNScenarioList
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
WMLCampaign *myCamp;
myCamp = [WNCampaign getMainCampaign];
if (myCamp != nil)
{
return [myCamp count];
}
fprintf(stderr,"*** Value of nil returned for myCamp\n");
return 0;
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
WMLCampaign *myCamp;
WMLScenario *myScen, *nextScen;
int nextIndex;
NSString *identifier = [tableColumn identifier];
myCamp = [WNCampaign getMainCampaign];
if (myCamp != nil)
{
myScen = [myCamp getScenarioAtIndex: row];
if ([identifier isEqualTo:@"name"])
{
return [myScen getName];
}
if ([identifier isEqualTo:@"On Win"])
{
nextIndex = [[myScen getDetailsFor:@"Easy"] getVictoryScenarioIndex];
if (nextIndex == -1) return @"None";
nextScen = [myCamp getScenarioAtIndex: nextIndex];
return [nextScen getName];
}
if ([identifier isEqualTo:@"On Continue"])
{
nextIndex = [[myScen getDetailsFor:@"Easy"] getContinueScenarioIndex];
if (nextIndex == -1) return @"None";
nextScen = [myCamp getScenarioAtIndex: nextIndex];
return [nextScen getName];
}
return @"unknown identifier";
}
fprintf (stderr,"Value of mainCampaign returned as nil\n");
return @"ERROR - Value Not Assigned";
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
WMLCampaign *myCamp;
WMLScenario *myScen;
NSString *identifier = [tableColumn identifier];
if ([identifier isEqualTo:@"name"])
{
myCamp = [WNCampaign getMainCampaign];
myScen = [myCamp getScenarioAtIndex: rowIndex];
[myScen setName:anObject];
}
}
@end

View file

@ -1,14 +0,0 @@
/* WNSideList */
#import <Cocoa/Cocoa.h>
@interface WNSideList : NSObject
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex;
@end

View file

@ -1,73 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNSideList.h"
#import "WMLSide.h"
#import "WMLCampaign.h"
@implementation WNSideList
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
WMLCampaign *myCamp;
WMLScenario *myScenario;
myCamp = [WNCampaign getMainCampaign];
myScenario = [myCamp getActiveScenario];
if (myCamp != nil)
{
return [myScenario getSidesCount];
}
fprintf(stderr,"*** Value of nil returned for myScenario\n");
return 0;
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
WMLCampaign *myCamp;
WMLScenario *myScen;
WMLSide *mySide;
NSString *identifier = [tableColumn identifier];
myCamp = [WNCampaign getMainCampaign];
if (myCamp !=nil)
{
myScen = [myCamp getActiveScenario];
if (myScen != nil)
{
mySide = [myScen getSideAtIndex: row];
if ([identifier isEqualTo:@"name"])
{
return [mySide getName];
}
if ([identifier isEqualTo:@"number"])
{
NSNumber *tmpNum = [[NSNumber alloc] initWithInt:(row+1)];
return tmpNum;
}
return @"unknown identifier";
}
fprintf (stderr,"Value of activeScenario returned as nil\n");
}
return @"ERROR - Value Not Assigned";
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
WMLCampaign *myCamp;
WMLScenario *myScen;
WMLSide *mySide;
NSString *identifier = [tableColumn identifier];
if ([identifier isEqualTo:@"name"])
{
myCamp = [WNCampaign getMainCampaign];
myScen = [myCamp getActiveScenario];
mySide = [myScen getActiveSide];
[mySide setName:anObject];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"sidesChanged" object:self];
}
@end

View file

@ -1,11 +0,0 @@
/* WNTeamList */
#import <Cocoa/Cocoa.h>
@interface WNTeamList : NSObject
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
@end

View file

@ -1,47 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNTeamList.h"
@implementation WNTeamList
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
NSMutableArray *myTeams;
myTeams = [[[WNCampaign getMainCampaign] getActiveScenario] getTeams];
if (myTeams != nil)
{
return [myTeams count];
}
fprintf(stderr,"*** Value of nil returned for myTeams\n");
return 0;
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
NSMutableArray *myTeams;
myTeams = [[[WNCampaign getMainCampaign] getActiveScenario] getTeams];
if (myTeams !=nil)
{
return [myTeams objectAtIndex: row];
}
return @"ERROR - Value Not Assigned";
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(int)rowIndex
{
NSMutableArray *myTeams;
myTeams = [[[WNCampaign getMainCampaign] getActiveScenario] getTeams];
if (myTeams !=nil)
{
[myTeams replaceObjectAtIndex: rowIndex withObject: anObject];
}
}
@end

View file

@ -1,11 +0,0 @@
/* WNTerrainList */
#import <Cocoa/Cocoa.h>
@interface WNTerrainList : NSObject
{
}
- (void)awakeFromNib;
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row;
@end

View file

@ -1,39 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNTerrainList.h"
#import "WMLTag.h";
#import "WNFileLocations.h";
#import "WMLTerrain.h";
#import "WNTerrains.h";
@implementation WNTerrainList
-(void)awakeFromNib // When we start we need to load the terrain info
{
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
if ([WNTerrains initialised] != YES)
{
fprintf(stderr,"Terrains not initialised initialising\n");
[WNTerrains init];
}
return [WNTerrains count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
NSString *identifier = [tableColumn identifier];
WMLTerrain *ThisTerrain =[WNTerrains terrainAtIndex:row];
if ([identifier isEqualTo:@"name"])
{
return [ThisTerrain name];
}
if ([identifier isEqualTo:@"image"])
{
return [ThisTerrain image];
}
return [ThisTerrain name];
}
@end

View file

@ -1,9 +0,0 @@
/* WNTerrainMapView */
#import <Cocoa/Cocoa.h>
#include "WNIconListView.h"
@interface WNTerrainMapView : WNIconListView
{
}
@end

View file

@ -1,6 +0,0 @@
#import "Wesnoth_Scenario_Editor_Prefix.h"
#import "WNTerrainMapView.h"
@implementation WNTerrainMapView
@end

View file

@ -1,9 +0,0 @@
/* WNTerrainView */
#import <Cocoa/Cocoa.h>
@interface WNTerrainView : NSTableView
{
}
-(void)awakeFromNib;
@end

Some files were not shown because too many files have changed in this diff Show more