mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Initial server launcher for osx.
This commit is contained in:
parent
8254bf2336
commit
c93dbcaa53
19
default.bam
19
default.bam
|
@ -232,6 +232,7 @@ function build(settings)
|
|||
client_settings.linker.frameworks:add("OpenGL")
|
||||
client_settings.linker.frameworks:add("AGL")
|
||||
client_settings.linker.frameworks:add("Carbon")
|
||||
client_settings.linker.frameworks:add("Cocoa")
|
||||
client_settings.linker.frameworks:add("CoreAudio")
|
||||
client_settings.linker.frameworks:add("AudioToolbox")
|
||||
client_settings.linker.frameworks:add("AudioUnit")
|
||||
|
@ -263,6 +264,10 @@ function build(settings)
|
|||
game_server = Compile(settings, Collect("src/game/server/*.cpp"), serverdata.source, serverdata.cdata)
|
||||
editor = Compile(settings, Collect("src/editor/*.cpp"))
|
||||
|
||||
if platform == "macosx" then
|
||||
osxlaunch = Compile(settings, Collect("src/osxlaunch/*.m"))
|
||||
end
|
||||
|
||||
-- build tools (TODO: fix this so we don't get double _d_d stuff)
|
||||
tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
|
||||
|
||||
|
@ -284,16 +289,28 @@ function build(settings)
|
|||
masterserver_exe = Link(server_settings, "mastersrv", masterserver,
|
||||
engine, zlib)
|
||||
|
||||
if platform == "macosx" then
|
||||
osxlaunch_exe = Link(client_settings, "TeeLaunch", osxlaunch)
|
||||
end
|
||||
|
||||
-- make targets
|
||||
c = PseudoTarget("client".."_"..settings.config_name, client_exe)
|
||||
s = PseudoTarget("server".."_"..settings.config_name, server_exe)
|
||||
m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe)
|
||||
t = PseudoTarget("tools".."_"..settings.config_name, tools)
|
||||
|
||||
if platform == "macosx" then
|
||||
o = PseudoTarget("TeeLaunch".."_"..settings.config_name, osxlaunch_exe)
|
||||
else
|
||||
o = { }
|
||||
end
|
||||
|
||||
Target(c)
|
||||
Target(s)
|
||||
Target(m)
|
||||
Target(t)
|
||||
all = PseudoTarget(settings.config_name, c, s, m, t)
|
||||
Target(o)
|
||||
all = PseudoTarget(settings.config_name, c, s, m, t, o)
|
||||
Target(all)
|
||||
return all
|
||||
end
|
||||
|
|
|
@ -89,6 +89,8 @@ if use_bundle:
|
|||
copydir("data", bundle_resource_dir)
|
||||
shutil.copy("other/icons/Teewars.icns", bundle_resource_dir)
|
||||
shutil.copy("teewars"+exe_ext, bundle_bin_dir)
|
||||
shutil.copy("teewars_srv"+exe_ext, bundle_bin_dir)
|
||||
shutil.copy("TeeLaunch"+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">
|
||||
|
@ -97,7 +99,7 @@ if use_bundle:
|
|||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>teewars</string>
|
||||
<string>TeeLaunch</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Teewars</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
|
|
104
src/osxlaunch/main.m
Normal file
104
src/osxlaunch/main.m
Normal file
|
@ -0,0 +1,104 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
@interface ServerView : NSTextView
|
||||
{
|
||||
NSFileHandle *file;
|
||||
}
|
||||
- (void)listenTo: (NSFileHandle*)f;
|
||||
@end
|
||||
|
||||
@implementation ServerView
|
||||
- (void)listenTo: (NSFileHandle*)f;
|
||||
{
|
||||
file = f;
|
||||
|
||||
[[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
|
||||
{
|
||||
[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]];
|
||||
NSPipe *pipe;
|
||||
NSFileHandle *file;
|
||||
pipe = [NSPipe pipe];
|
||||
[task setStandardOutput: pipe];
|
||||
file = [pipe fileHandleForReading];
|
||||
|
||||
|
||||
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: file];
|
||||
[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars_srv"]];
|
||||
[task launch];
|
||||
[NSApp run];
|
||||
[task terminate];
|
||||
}
|
||||
else
|
||||
{
|
||||
// run client
|
||||
[task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teewars"]];
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
}
|
||||
|
||||
|
||||
|
||||
[NSApp release];
|
||||
[pool release];
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
Loading…
Reference in a new issue