summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorSimon Howard2010-01-23 23:06:45 +0000
committerSimon Howard2010-01-23 23:06:45 +0000
commitbf8974e63b988ae1b5d2fdb0492dfe0bb3613680 (patch)
tree4a1531b099c78c5b3e5553e0099ee294d197c153 /pkg
parent47f828ea9faf6fbb695fe2b901be466195b2a168 (diff)
downloadchocolate-doom-bf8974e63b988ae1b5d2fdb0492dfe0bb3613680.tar.gz
chocolate-doom-bf8974e63b988ae1b5d2fdb0492dfe0bb3613680.tar.bz2
chocolate-doom-bf8974e63b988ae1b5d2fdb0492dfe0bb3613680.zip
Add menu item to launcher to open a terminal window that can be used to
start the game. Add missing 'edit' menu. Set svn:ignore property for osx directory. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1824
Diffstat (limited to 'pkg')
-rw-r--r--pkg/osx/.gitignore2
-rw-r--r--pkg/osx/Execute.h1
-rw-r--r--pkg/osx/Execute.m86
-rw-r--r--pkg/osx/IWADController.h1
-rw-r--r--pkg/osx/IWADController.m31
-rw-r--r--pkg/osx/LauncherManager.h2
-rw-r--r--pkg/osx/LauncherManager.m18
-rw-r--r--pkg/osx/Resources/launcher.nib/classes.nib2
-rw-r--r--pkg/osx/Resources/launcher.nib/info.nib6
-rw-r--r--pkg/osx/Resources/launcher.nib/keyedobjects.nibbin17541 -> 19494 bytes
10 files changed, 139 insertions, 10 deletions
diff --git a/pkg/osx/.gitignore b/pkg/osx/.gitignore
index 5b7a16ef..ca1a7908 100644
--- a/pkg/osx/.gitignore
+++ b/pkg/osx/.gitignore
@@ -1,5 +1,7 @@
Info.plist
+Info-gnustep.plist
launcher
*.o
*.d
+*.dmg
staging
diff --git a/pkg/osx/Execute.h b/pkg/osx/Execute.h
index e92d3a11..2098be8a 100644
--- a/pkg/osx/Execute.h
+++ b/pkg/osx/Execute.h
@@ -25,6 +25,7 @@
void SetProgramLocation(const char *path);
void ExecuteProgram(const char *executable, const char *iwad, const char *args);
+void OpenTerminalWindow(const char *doomwadpath);
#endif /* #ifndef LAUNCHER_EXECUTE_H */
diff --git a/pkg/osx/Execute.m b/pkg/osx/Execute.m
index 1afcab1f..bb4eed45 100644
--- a/pkg/osx/Execute.m
+++ b/pkg/osx/Execute.m
@@ -24,10 +24,16 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <AppKit/AppKit.h>
+
+#include "config.h"
+
#define RESPONSE_FILE "/tmp/launcher.rsp"
+#define TEMP_SCRIPT "/tmp/tempscript.sh"
static char *executable_path;
@@ -109,3 +115,83 @@ void ExecuteProgram(const char *executable, const char *iwad, const char *args)
}
}
+// Write a sequence of commands that will display the specified message
+// via shell commands.
+
+static void WriteMessage(FILE *script, char *msg)
+{
+ char *p;
+
+ fprintf(script, "echo \"");
+
+ for (p=msg; *p != '\0'; ++p)
+ {
+ // Start new line?
+
+ if (*p == '\n')
+ {
+ fprintf(script, "\"\necho \"");
+ continue;
+ }
+
+ // Escaped character?
+
+ if (*p == '\\' || *p == '\"')
+ {
+ fprintf(script, "\\");
+ }
+
+ fprintf(script, "%c", *p);
+ }
+
+ fprintf(script, "\"\n");
+}
+
+// Open a terminal window with the PATH set appropriately, and DOOMWADPATH
+// set to the specified value.
+
+void OpenTerminalWindow(const char *doomwadpath)
+{
+ FILE *stream;
+
+ // Generate a shell script that sets the PATH to include the location
+ // where the Doom binaries are, and DOOMWADPATH to include the
+ // IWAD files that have been configured in the launcher interface.
+ // The script then deletes itself and starts a shell.
+
+ stream = fopen(TEMP_SCRIPT, "w");
+
+ fprintf(stream, "#!/bin/sh\n");
+ //fprintf(stream, "set -x\n");
+ fprintf(stream, "PATH=\"%s:$PATH\"\n", executable_path);
+ fprintf(stream, "DOOMWADPATH=\"%s\"\n", doomwadpath);
+ fprintf(stream, "export DOOMWADPATH\n");
+ fprintf(stream, "rm -f \"%s\"\n", TEMP_SCRIPT);
+
+ // Display a useful message:
+
+ fprintf(stream, "clear\n");
+ WriteMessage(stream,
+ "\n"
+ "This command line has the PATH variable configured so that you may\n"
+ "launch the game with whatever parameters you desire.\n"
+ "\n"
+ "For example:\n"
+ "\n"
+ " " PACKAGE_TARNAME " -iwad doom2.wad -file sid.wad -warp 1\n"
+ "\n"
+ "Type 'exit' to exit.\n");
+
+ fprintf(stream, "exec $SHELL\n");
+ fprintf(stream, "\n");
+
+ fclose(stream);
+
+ chmod(TEMP_SCRIPT, 0755);
+
+ // Tell the terminal to open a window to run the script.
+
+ [[NSWorkspace sharedWorkspace] openFile: @TEMP_SCRIPT
+ withApplication: @"Terminal"];
+}
+
diff --git a/pkg/osx/IWADController.h b/pkg/osx/IWADController.h
index 8bdd0d55..90f44667 100644
--- a/pkg/osx/IWADController.h
+++ b/pkg/osx/IWADController.h
@@ -45,6 +45,7 @@
- (BOOL) setDropdownList;
- (void) setDropdownSelection;
- (void) saveConfig;
+- (char *) doomWadPath;
- (void) setEnvironment;
@end
diff --git a/pkg/osx/IWADController.m b/pkg/osx/IWADController.m
index a7730cc7..3c596850 100644
--- a/pkg/osx/IWADController.m
+++ b/pkg/osx/IWADController.m
@@ -264,10 +264,10 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
}
}
-// Set the DOOMWADPATH environment variable to contain the path to each
-// of the configured IWAD files.
+// Generate a value to set for the DOOMWADPATH environment variable
+// that contains each of the configured IWAD files.
-- (void) setEnvironment
+- (char *) doomWadPath
{
IWADLocation *iwadList[NUM_IWAD_TYPES];
NSString *location;
@@ -280,7 +280,7 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
// Calculate length of environment string.
- len = 30;
+ len = 0;
for (i=0; i<NUM_IWAD_TYPES; ++i)
{
@@ -295,7 +295,7 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
// Build string.
env = malloc(len);
- strcpy(env, "DOOMWADPATH=");
+ strcpy(env, "");
first = YES;
@@ -315,6 +315,27 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] =
}
}
+ return env;
+}
+
+// Set the DOOMWADPATH environment variable to contain the path to each
+// of the configured IWAD files.
+
+- (void) setEnvironment
+{
+ char *doomwadpath;
+ char *env;
+
+ // Get the value for the path.
+
+ doomwadpath = [self doomWadPath];
+
+ env = malloc(strlen(doomwadpath) + 15);
+
+ sprintf(env, "DOOMWADPATH=%s", doomwadpath);
+
+ free(doomwadpath);
+
// Load into environment:
putenv(env);
diff --git a/pkg/osx/LauncherManager.h b/pkg/osx/LauncherManager.h
index eac4cfba..76c74624 100644
--- a/pkg/osx/LauncherManager.h
+++ b/pkg/osx/LauncherManager.h
@@ -43,7 +43,7 @@
- (void) clearCommandLine;
- (void) addFileToCommandLine: (NSString *) fileName
forArgument: (NSString *) args;
-
+- (void) openTerminal: (id) sender;
@end
diff --git a/pkg/osx/LauncherManager.m b/pkg/osx/LauncherManager.m
index 0d0ab4ea..ee7ed3dc 100644
--- a/pkg/osx/LauncherManager.m
+++ b/pkg/osx/LauncherManager.m
@@ -299,6 +299,8 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName)
[NSApp terminate:sender];
}
+// Invoked when the "Setup Tool" button is clicked, to run the setup tool:
+
- (void) runSetup: (id)sender
{
[self saveConfig];
@@ -307,6 +309,22 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName)
ExecuteProgram("chocolate-setup", NULL, NULL);
}
+// Invoked when the "Terminal" option is selected from the menu, to open
+// a terminal window.
+
+- (void) openTerminal: (id) sender
+{
+ char *doomwadpath;
+
+ [self saveConfig];
+
+ doomwadpath = [self->iwadController doomWadPath];
+
+ OpenTerminalWindow(doomwadpath);
+
+ free(doomwadpath);
+}
+
- (void) awakeFromNib
{
[self->packageLabel setStringValue: @PACKAGE_STRING];
diff --git a/pkg/osx/Resources/launcher.nib/classes.nib b/pkg/osx/Resources/launcher.nib/classes.nib
index 3ff47e71..236f6b67 100644
--- a/pkg/osx/Resources/launcher.nib/classes.nib
+++ b/pkg/osx/Resources/launcher.nib/classes.nib
@@ -30,7 +30,7 @@
SUPERCLASS = NSObject;
},
{
- ACTIONS = {launch = id; runSetup = id; };
+ ACTIONS = {launch = id; openTerminal = id; runSetup = id; };
CLASS = LauncherManager;
LANGUAGE = ObjC;
OUTLETS = {
diff --git a/pkg/osx/Resources/launcher.nib/info.nib b/pkg/osx/Resources/launcher.nib/info.nib
index aecf812a..32b331f5 100644
--- a/pkg/osx/Resources/launcher.nib/info.nib
+++ b/pkg/osx/Resources/launcher.nib/info.nib
@@ -3,18 +3,18 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
- <string>170 140 612 260 0 0 1440 878 </string>
+ <string>484 105 612 260 0 0 1440 878 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
- <string>108 337 163 44 0 0 1440 878 </string>
+ <string>221 322 205 44 0 0 1440 878 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
- <integer>21</integer>
<integer>29</integer>
+ <integer>21</integer>
<integer>227</integer>
</array>
<key>IBSystem Version</key>
diff --git a/pkg/osx/Resources/launcher.nib/keyedobjects.nib b/pkg/osx/Resources/launcher.nib/keyedobjects.nib
index 12cf6aa5..4f078d7c 100644
--- a/pkg/osx/Resources/launcher.nib/keyedobjects.nib
+++ b/pkg/osx/Resources/launcher.nib/keyedobjects.nib
Binary files differ