about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2008-10-08 16:33:08 +0000
committerJoel de Vahl <joel@stalverk80.se>2008-10-08 16:33:08 +0000
commitb74c2b79318779e69da88e7639b322b9a54d862c (patch)
treea1d763e09fa56ea836270db67361a65af58867f0
parent2b6f991010875e31184ddbc6c0917d13c02c7cbe (diff)
downloadzcatch-b74c2b79318779e69da88e7639b322b9a54d862c.tar.gz
zcatch-b74c2b79318779e69da88e7639b322b9a54d862c.zip
Initial launcher (again)
-rw-r--r--default.bam10
-rw-r--r--scripts/make_release.py6
-rw-r--r--src/engine/external/glfw/lib/macosx/macosx_init.c3
-rw-r--r--src/osxlaunch/main.m101
4 files changed, 112 insertions, 8 deletions
diff --git a/default.bam b/default.bam
index cbe63fed..7f39ed73 100644
--- a/default.bam
+++ b/default.bam
@@ -315,6 +315,8 @@ function build(settings)
 
 	-- build tools (TODO: fix this so we don't get double _d_d stuff)
 	tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
+
+	osxlaunch_src = Collect("src/osxlaunch/*.m")
 	
 	objs = Compile(settings, tools_src)
 	tools = {}
@@ -337,9 +339,9 @@ function build(settings)
 	masterserver_exe = Link(server_settings, "mastersrv", masterserver,
 		engine, zlib)
 
-	--if platform == "macosx" then
-	--	osxlaunch_exe = Link(client_settings, "TeeLaunch", osxlaunch)
-	--end
+	if platform == "macosx" then
+		osxlaunch_exe = Link(client_settings, "osxlaunch", osxlaunch_src)
+	end
 
 	-- make targets
 	c = PseudoTarget("client".."_"..settings.config_name, client_exe)
@@ -355,7 +357,7 @@ function build(settings)
 	Target(t)
 	
 	if platform == "macosx" then
-		o = PseudoTarget("TeeLaunch".."_"..settings.config_name, osxlaunch_exe)
+		o = PseudoTarget("osxlaunch".."_"..settings.config_name, osxlaunch_exe)
 		all = PseudoTarget(settings.config_name, c, s, v, m, t, o)
 	else
 		all = PseudoTarget(settings.config_name, c, s, v, m, t)
diff --git a/scripts/make_release.py b/scripts/make_release.py
index 4bcff6cb..e2314884 100644
--- a/scripts/make_release.py
+++ b/scripts/make_release.py
@@ -37,7 +37,7 @@ if platform == 'win32':
 if 'osx_' in platform:
 	use_zip = 1
 	use_gz = 0
-	use_bundle = 0
+	use_bundle = 1
 
 def copydir(src, dst, excl=[]):
 	for root, dirs, files in os.walk(src, topdown=True):
@@ -90,7 +90,7 @@ if use_bundle:
 	shutil.copy("other/icons/Teeworlds.icns", bundle_resource_dir)
 	shutil.copy(name+exe_ext, bundle_bin_dir)
 	shutil.copy(name+"_srv"+exe_ext, bundle_bin_dir)
-	shutil.copy("TeeLaunch"+exe_ext, bundle_bin_dir)
+	shutil.copy("osxlaunch"+exe_ext, bundle_bin_dir)
 	file(os.path.join(bundle_content_dir, "Info.plist"), "w").write("""
 <?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">
@@ -99,7 +99,7 @@ if use_bundle:
         <key>CFBundleDevelopmentRegion</key>
         <string>English</string>
         <key>CFBundleExecutable</key>
-        <string>teeworlds</string>
+        <string>osxlaunch</string>
         <key>CFBundleIconFile</key>
         <string>Teeworlds</string>
         <key>CFBundleInfoDictionaryVersion</key>
diff --git a/src/engine/external/glfw/lib/macosx/macosx_init.c b/src/engine/external/glfw/lib/macosx/macosx_init.c
index c123daf0..3ee6dc43 100644
--- a/src/engine/external/glfw/lib/macosx/macosx_init.c
+++ b/src/engine/external/glfw/lib/macosx/macosx_init.c
@@ -96,11 +96,12 @@ void _glfwChangeToResourcesDirectory( void )
     }

 

     CFRelease( resourcesURL );

-

+/*

     if( chdir( resourcesPath ) != 0 )

     {

         UNBUNDLED;

     }

+	*/

 }

 

 int _glfwPlatformInit( void )

diff --git a/src/osxlaunch/main.m b/src/osxlaunch/main.m
new file mode 100644
index 00000000..a2c5dba5
--- /dev/null
+++ b/src/osxlaunch/main.m
@@ -0,0 +1,101 @@
+#import <Cocoa/Cocoa.h>
+#include <Carbon/Carbon.h>
+
+@interface ServerView : NSTextView
+{
+	NSTask *task;
+	NSFileHandle *file;
+}
+- (void)listenTo: (NSTask*)t;
+@end
+
+@implementation ServerView
+- (void)listenTo: (NSTask*)t;
+{
+	NSPipe *pipe;
+	task = t;
+    pipe = [NSPipe pipe];
+    [task setStandardOutput: pipe];
+    file = [pipe fileHandleForReading];
+
+	[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(outputNotification:) name: NSFileHandleReadCompletionNotification object: file];
+
+	[file readInBackgroundAndNotify];
+}
+
+- (void) outputNotification: (NSNotification *) notification
+{
+	NSData *data = [[[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] retain];
+	NSString *string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding];
+
+	NSRange end = NSMakeRange([[self string] length], 0);
+
+	[self replaceCharactersInRange: end withString: string];
+	end.location += [string length];
+	[self scrollRangeToVisible: end];
+
+	[string release];
+	[file readInBackgroundAndNotify];
+}
+
+-(void)windowWillClose:(NSNotification *)notification
+{
+	[task terminate];
+    [NSApp terminate:self];
+}
+@end
+
+int main(int argc, char **argv)
+{
+	UInt32 mod = GetCurrentKeyModifiers();
+
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    NSApp = [NSApplication sharedApplication];
+	NSBundle* mainBundle = [NSBundle mainBundle];
+	NSTask *task;
+    task = [[NSTask alloc] init];
+	[task setCurrentDirectoryPath: [mainBundle resourcePath]]; 
+
+	if(mod & optionKey)
+	{
+		// run server
+		NSWindow *window;
+		ServerView *view;
+		NSRect graphicsRect;
+
+		graphicsRect = NSMakeRect(100.0, 1000.0, 600.0, 400.0);
+
+		window = [[NSWindow alloc]
+			initWithContentRect: graphicsRect
+			styleMask: NSTitledWindowMask 
+			 | NSClosableWindowMask 
+			 | NSMiniaturizableWindowMask
+			backing: NSBackingStoreBuffered
+			defer: NO];
+
+		[window setTitle: @"Teewars Server"];
+
+		view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease];
+		[view setEditable: NO];
+
+		[window setContentView: view];
+		[window setDelegate: view];
+		[window makeKeyAndOrderFront: nil];
+
+		[view listenTo: task];
+		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teeworlds_srv"]];
+		[task launch];
+		[NSApp run];
+		[task terminate];
+	}
+	else
+	{
+		// run client
+		[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teeworlds"]];
+		[task launch];
+	}
+
+    [NSApp release];
+    [pool release];
+    return(EXIT_SUCCESS);
+}