mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
commit
06834d1fb5
5 changed files with 145 additions and 444 deletions
2
Makefile
2
Makefile
|
@ -73,7 +73,7 @@ WITH_SYSTEMDIR:=""
|
|||
# You have to make sure your libs/frameworks supports
|
||||
# these architectures! To build an universal ppc-compatible
|
||||
# one would add -arch ppc for example.
|
||||
OSX_ARCH:=-arch x86_64
|
||||
OSX_ARCH:=-arch $(shell uname -m | sed -e s/i.86/i386/)
|
||||
|
||||
# This will set the build options to create an MacOS .app-bundle.
|
||||
# The app-bundle itself will not be created, but the runtime paths
|
||||
|
|
179
README
179
README
|
@ -11,9 +11,10 @@ II. The main focus is single player, the gameplay and the graphics are
|
|||
unchanged, but many bugs were fixed. Unlike most other Quake II ports Yamagi
|
||||
Quake II is full 64 bit clean so it works perfectly on modern amd64 (x86_64)
|
||||
processors and operating systems. This code should run on Windows XP or later,
|
||||
and on most unix-like operating systems (only FreeBSD, Linux and OpenBSD are
|
||||
officially supported and tested, for other systems you'd at least have to edit
|
||||
the Makefile), just type "make" or "gmake" to compile.
|
||||
Mac OS X 10.6 or higher and on most unix-like operating systems
|
||||
(only FreeBSD, Linux and OpenBSD are officially supported and tested, for other
|
||||
systems you'd at least have to edit the Makefile), just type "make" or "gmake"
|
||||
to compile.
|
||||
|
||||
This code is based upon Icculus Quake II, which itself is built upon id
|
||||
Software's original code drop. Additional code and patches by many contributers
|
||||
|
@ -41,22 +42,31 @@ Content of this file:
|
|||
2.6 Compiling
|
||||
2.7 Default Configuration
|
||||
|
||||
3. OGG/Vorbis playback
|
||||
3.1 Setup for the original soundtrack
|
||||
3.2 Setup for other music and playlists
|
||||
3.3 Manual control
|
||||
3.4 Console variables
|
||||
3. Installation on OS X
|
||||
3.1 Supported Systems
|
||||
3.2 Retail Version
|
||||
3.3 Demo Version
|
||||
3.4 Addons
|
||||
3.5 Binary Installation
|
||||
3.6 Compiling
|
||||
3.7 Default Configuration
|
||||
|
||||
4. Configuration
|
||||
4.1 Video
|
||||
4.2 Input
|
||||
4.3 Sound
|
||||
4.3.1 The classic sound system
|
||||
4.3.2 The OpenAL sound system
|
||||
4. OGG/Vorbis playback
|
||||
4.1 Setup for the original soundtrack
|
||||
4.2 Setup for other music and playlists
|
||||
4.3 Manual control
|
||||
4.4 Console variables
|
||||
|
||||
5. Bugreports
|
||||
5. Configuration
|
||||
5.1 Video
|
||||
5.2 Input
|
||||
5.3 Sound
|
||||
5.3.1 The classic sound system
|
||||
5.3.2 The OpenAL sound system
|
||||
|
||||
6. FAQ
|
||||
6. Bugreports
|
||||
|
||||
7. FAQ
|
||||
|
||||
===============================================================================
|
||||
|
||||
|
@ -266,7 +276,106 @@ Now you are ready to start your brand new Quake II. Have fun.
|
|||
|
||||
===============================================================================
|
||||
|
||||
3. OGG/Vorbis playback
|
||||
3. Installation on OS X
|
||||
=======================
|
||||
Yamagi Quake II has full support for Apple OS X. All features are
|
||||
supported, including the IPv6 network code and the OpenAL sound backend.
|
||||
Installation can be done by using the binary release or by compiling the source.
|
||||
|
||||
3.1 Supported Systems
|
||||
---------------------
|
||||
Yamagi Quake II should run on every Mac with Intel CPU and OS X 10.6
|
||||
or higher.
|
||||
|
||||
3.2 Retail Version
|
||||
------------------
|
||||
If you own Quake II, first get the official point release to Quake II 3.20:
|
||||
ftp://ftp.idsoftware.com/idstuff/quake2/q2-3.20-x86-full-ctf.exe
|
||||
Use this and only this file! Unofficial pointreleases or something like
|
||||
that will not work and may crash your game!
|
||||
|
||||
Extract the file into a new directory (we recommend quake2\) and remove
|
||||
the following files and directories:
|
||||
- 3.20_Changes.txt
|
||||
- quake2.exe
|
||||
- ref_gl.dll
|
||||
- ref_soft.dll
|
||||
- baseq2\gamex86.dll
|
||||
- baseq2\maps.lst
|
||||
- ctf\ctf2.ico
|
||||
- ctf\gamex86.dll
|
||||
- ctf\readme.txt
|
||||
- ctf\server.cfg
|
||||
- xatrix\gamex86.dll
|
||||
- rogue\gamex86.dll
|
||||
|
||||
Now put the Quake II CD-ROM into your cd drive and copy "pak0.pak" and
|
||||
the directory "video\" to the "baseq2\" directory of your installation.
|
||||
|
||||
3.3 Demo Version
|
||||
----------------
|
||||
If you haven't got Quake II, try the demo version. Get it here:
|
||||
ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe
|
||||
|
||||
Extract this file into a new directory and delete everything but
|
||||
"baseq2\pak0.pak" and the "baseq2\players\" directory. No patching
|
||||
is needed for the demo, in fact it would break it.
|
||||
|
||||
3.4 Addons
|
||||
----------
|
||||
Due to license issues - Yamagi Quake II is covered by the GPL and the
|
||||
addons are under the id Software SDK license - the addons are
|
||||
distributed separately. You can get them at http://www.yamagi.org/quake2,
|
||||
both contain installation instructions. But nevertheless you'll need an
|
||||
installation of the full Quake II game with our client for playing them.
|
||||
The same applies to the "ctf" capture the flag addon.
|
||||
|
||||
3.5 Binary Installation
|
||||
-----------------------
|
||||
Extract the zip archive and right click on the app. Select "Show Contents",
|
||||
a new finder window will open. Navigate to Contents/Resources/baseq2 and
|
||||
copy the contents of the baseq2/ folder (created while preparing the game
|
||||
data, see above) into it. Close the finder windows. Yamagi Quake II is
|
||||
now ready.
|
||||
|
||||
3.6 Compiling
|
||||
-------------
|
||||
Compiling Yamagi Quake II from source is unnecessary as long as you will not
|
||||
use the github version or want to develop on OS X. If you really want to
|
||||
compile Yamagi Quake II by yourself follow these steps:
|
||||
|
||||
1. Make sure that you've installed XCode with the "Unix Develoment Tools".
|
||||
Depending on your OS X version the name of these can be different.
|
||||
2. Install dependencies using Homebrew (http://brew.sh). Once you have Homebrew
|
||||
installed, run the following commands from the terminal to install dependencies:
|
||||
brew install sdl2 --universal
|
||||
brew install openal-soft --universal
|
||||
brew install libogg --universal
|
||||
brew install libvorbis --universal
|
||||
brew install libjpeg --universal
|
||||
|
||||
3. Open a terminal and navigate to the Yamagi Quake II source code. Type
|
||||
"make" to compile it. After that the binaries can be found in the release/
|
||||
directory.
|
||||
|
||||
The binaries can be put into an app-bundle (see 3.5 Binary Installation) or
|
||||
used in the classic classic unix way. An empty .App template is included in /stuff/osx.
|
||||
In the latter case the game be started at the command line. Be aware that the app-bundle
|
||||
support has to be deactivated in the Makefile, otherwise the game is unable to find it's
|
||||
libraries!
|
||||
|
||||
3.7 Default Configuration
|
||||
-------------------------
|
||||
Quake II ships with an old and for today standards "insane" default
|
||||
configuration. This is no problem since you can alter everything. To make your
|
||||
life easier Yamagi Quake II contains an updated default configuration.
|
||||
If you want to use it just copy "stuff\yq2.cfg" to your "baseq2\" folder.
|
||||
|
||||
Now you are ready to start your brand new Quake II. Have fun.
|
||||
|
||||
===============================================================================
|
||||
|
||||
4. OGG/Vorbis playback
|
||||
======================
|
||||
Since most modern CD-ROM and DVD drives don't have an analog audio output and
|
||||
most sound codecs don't have the appropriate input header, it's not possible to
|
||||
|
@ -274,7 +383,7 @@ use CD audio as background music on such systems. With SDL 2.0 CD audio is
|
|||
unsupported Therefore OGG/Vorbis music support has been added to Yamagi Quake
|
||||
II.
|
||||
|
||||
3.1 Setup for the original soundtrack:
|
||||
4.1 Setup for the original soundtrack:
|
||||
--------------------------------------
|
||||
Put your Quake II CD-ROM into your drive, start your favorite CD extractor and
|
||||
rip the audiotracks into OGG/Vorbis files. These files must be named after their
|
||||
|
@ -287,7 +396,7 @@ Drop these files in "baseq2/music/", start Quake II, enter the "Options" menu
|
|||
and set "OGG music" to enabled. "CD music" will be automaticly disabled.
|
||||
Quake II will now play the OGG/Vorbis files instead of the Audio-CD.
|
||||
|
||||
3.2 Setup for other music and playlists:
|
||||
4.2 Setup for other music and playlists:
|
||||
----------------------------------------
|
||||
You can put any OGG/Vorbis files into "baseq2/music/" or "your_mod/music/".
|
||||
If shuffle is enabled, Quake II will shuffle through all files, otherwise it
|
||||
|
@ -295,7 +404,7 @@ will loop through the track associated with the map.
|
|||
A playlist is also supported. Just put the filenames into music/playlist
|
||||
(a plain text file) and start the game.
|
||||
|
||||
3.3 Manual control:
|
||||
4.3 Manual control:
|
||||
-------------------
|
||||
For manual control of ogg playback the following console commands are available:
|
||||
|
||||
|
@ -328,7 +437,7 @@ For manual control of ogg playback the following console commands are available:
|
|||
- ogg_status
|
||||
Display status ("playing a file", "paused", "stopped", etc).
|
||||
|
||||
3.4 Console variables:
|
||||
4.4 Console variables:
|
||||
----------------------
|
||||
- ogg_enable {0 | 1}
|
||||
Enables the Ogg Vorbis subsystem if set to "1". Defaults to "0".
|
||||
|
@ -352,13 +461,13 @@ For manual control of ogg playback the following console commands are available:
|
|||
|
||||
===============================================================================
|
||||
|
||||
4. Configuration
|
||||
5. Configuration
|
||||
================
|
||||
While configuring Quake II is straight forward some rough edges can arise.
|
||||
Before reporting bugs or mailing us please read this section all the hints
|
||||
covered in it!
|
||||
|
||||
4.1 Video
|
||||
5.1 Video
|
||||
---------
|
||||
For most people the options in the "Video" menu are sufficent. But there
|
||||
are some things that can and in some cases must be tuned via cvars. Here
|
||||
|
@ -442,7 +551,7 @@ the most common questions are answered.
|
|||
calculates a more or less optimal scaling factor, matching the artwork size
|
||||
at a resolution of 640x480.
|
||||
|
||||
4.2 Input
|
||||
5.2 Input
|
||||
---------
|
||||
Quake II had a rather simple input system, even back in 1997. It just mapped
|
||||
Windows 95 mouse directly on movements. That was a very acurate way to do it,
|
||||
|
@ -472,7 +581,7 @@ There are some cvar to adjust:
|
|||
impossible to add modern acceleration to Quake II since most of the needed data
|
||||
isn't available to the input backend.
|
||||
|
||||
4.3 Sound
|
||||
5.3 Sound
|
||||
---------
|
||||
Quake II featured one of the best sound systems of it's time (for example it had
|
||||
support for realtime calculated stereo effects) but sadly it was totaly broken.
|
||||
|
@ -485,7 +594,7 @@ scratch. This should solve most if not all problems. Yamagi Quake II 4.20
|
|||
featured an optional OpenAL sound system, enabling better stereo calculations
|
||||
and even surround support.
|
||||
|
||||
4.3.1 The classic sound system
|
||||
5.3.1 The classic sound system
|
||||
------------------------------
|
||||
This is the original sound implementation, as used in the first release of Quake
|
||||
II in 1997. It featured stereo calculations for most samples. It's disabled by
|
||||
|
@ -515,13 +624,13 @@ default and can be reenabled by setting "s_openal" to "0", followed by
|
|||
card 0
|
||||
}
|
||||
|
||||
4.3.2 The OpenAL sound system
|
||||
5.3.2 The OpenAL sound system
|
||||
-----------------------------
|
||||
This is a sound system based upon the popular OpenAL audio library. It features
|
||||
sand urround playback which gives a huge improvement in sound quality and
|
||||
gameplay experience. It's enabled by default, but can be disabled by setting
|
||||
"s_openal" to "0", followed by a "snd_restart". To work correctly it's in the
|
||||
need of a correctly configured OpenAL implementation! On Windows the default
|
||||
surround playback which gives a huge improvement in sound quality and gameplay
|
||||
experience. It's enabled by default, but can be disabled by setting "s_openal"
|
||||
to "0", followed by a "snd_restart". To work correctly it's in the need of a
|
||||
correctly configured OpenAL implementation! On OS X and Windows the default
|
||||
configuration is okay. On FreeBSD, Linux and OpenBSD OpenAL is configured in the
|
||||
file ~/.alsoftrc (for the openal-soft implementation, other implementations may
|
||||
vary). The most important options (tested with OpenAL Soft 1.14) are:
|
||||
|
@ -550,7 +659,7 @@ is a limited dynamic range!
|
|||
|
||||
===============================================================================
|
||||
|
||||
5. Bugreports
|
||||
6. Bugreports
|
||||
=============
|
||||
Something is not working as expected? An elevator is broken? An enemy doesn't
|
||||
move? Or the whole game is just crashing? Just open a new github issue at
|
||||
|
@ -589,7 +698,7 @@ Valgrind reports many, many memory leaks!
|
|||
|
||||
===============================================================================
|
||||
|
||||
6. FAQ
|
||||
7. FAQ
|
||||
======
|
||||
|
||||
How do I open the console?
|
||||
|
@ -669,14 +778,14 @@ Can I connect to an IPv6 server?
|
|||
./q2ded +set ip "[2001:db8::1]"
|
||||
|
||||
Where can I find the configuartion file?
|
||||
- It's located at ~/.yq2/game/config.cfg (FreeBSD, Linux and OpenBSD) or
|
||||
- It's located at ~/.yq2/game/config.cfg (FreeBSD, Linux, OpenBSD and OS X) or
|
||||
...\Documents\YamagiQ2\game\config.cfg (Windows). Replace "game" by the mod
|
||||
name, e.g. "baseq2/" for the main game.
|
||||
|
||||
My mod crashes at startup.
|
||||
- This is known problem of some mods. A workaround is to create the working
|
||||
directory by hand:
|
||||
mkdir -p ~/.yq2/$moddir (FreeBSD, Linux, OpenBSD)
|
||||
mkdir -p ~/.yq2/$moddir (FreeBSD, Linux, OpenBSD and OS X)
|
||||
...\Documents\YamagiQ2\$moddir (Windows)
|
||||
|
||||
Only parts of the maps are rendered!
|
||||
|
|
|
@ -1,11 +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
|
||||
@end
|
|
@ -1,397 +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 <SDL/SDL.h>
|
||||
#import "SDLMain.h"
|
||||
#import <sys/param.h> /* for MAXPATHLEN */
|
||||
#import <unistd.h>
|
||||
//#import <iostream>
|
||||
|
||||
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||
but the method still is there and works. To avoid warnings, we declare
|
||||
it ourselves here. */
|
||||
@interface NSApplication(SDL_Missing_Methods)
|
||||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||
#define SDL_USE_NIB_FILE 0
|
||||
|
||||
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||
#define SDL_USE_CPS 1
|
||||
#ifdef SDL_USE_CPS
|
||||
/* Portions of CPS.h */
|
||||
typedef struct CPSProcessSerNum
|
||||
{
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
} CPSProcessSerNum;
|
||||
|
||||
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static BOOL gFinderLaunch;
|
||||
static BOOL gCalledAppMainline = FALSE;
|
||||
|
||||
static NSString *getApplicationName(void)
|
||||
{
|
||||
NSDictionary *dict;
|
||||
NSString *appName = 0;
|
||||
|
||||
/* Determine the application name */
|
||||
dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||
if (dict)
|
||||
appName = [dict objectForKey: @"CFBundleName"];
|
||||
|
||||
if (![appName length])
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
return appName;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* A helper category for NSString */
|
||||
@interface NSString (ReplaceSubString)
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@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
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
printf("setting up working dir\n");
|
||||
if (shouldChdir)
|
||||
{
|
||||
printf("chdir...\n");
|
||||
#if defined(USE_APP_RESOURCES)
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
|
||||
char path[MAXPATHLEN];
|
||||
if (CFURLGetFileSystemRepresentation(resourcesURL, true, (UInt8 *)path, MAXPATHLEN)) {
|
||||
assert ( chdir (path) == 0 ); /* chdir to the Resources directory of app */
|
||||
}
|
||||
printf("Path: %s\n", path);
|
||||
CFRelease(resourcesURL);
|
||||
#else
|
||||
char parentdir[MAXPATHLEN];
|
||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||
if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
|
||||
}
|
||||
CFRelease(url);
|
||||
CFRelease(url2);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
static void setApplicationMenu(void)
|
||||
{
|
||||
/* warning: this code is very odd */
|
||||
NSMenu *appleMenu;
|
||||
NSMenuItem *menuItem;
|
||||
NSString *title;
|
||||
NSString *appName;
|
||||
|
||||
appName = getApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
/* Add menu items */
|
||||
title = [@"About " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Hide " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||
|
||||
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||
|
||||
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Quit " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[appleMenu release];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
/* Create a window menu */
|
||||
static void setupWindowMenu(void)
|
||||
{
|
||||
NSMenu *windowMenu;
|
||||
NSMenuItem *windowMenuItem;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
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 */
|
||||
static void CustomApplicationMain (int argc, char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDLMain *sdlMain;
|
||||
|
||||
/* Ensure the application object is initialised */
|
||||
[SDLApplication sharedApplication];
|
||||
|
||||
#ifdef SDL_USE_CPS
|
||||
{
|
||||
CPSProcessSerNum PSN;
|
||||
/* Tell the dock about us */
|
||||
if (!CPSGetCurrentProcess(&PSN))
|
||||
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||
if (!CPSSetFrontProcess(&PSN))
|
||||
[SDLApplication sharedApplication];
|
||||
}
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
/* Set up the menubar */
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
setApplicationMenu();
|
||||
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
|
||||
|
||||
|
||||
/*
|
||||
* Catch document open requests...this lets us notice files when the app
|
||||
* was launched by double-clicking a document, or when a document was
|
||||
* dragged/dropped on the app's icon. You need to have a
|
||||
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||
* apparently.
|
||||
*
|
||||
* Files are added to gArgv, so to the app, they'll look like command line
|
||||
* arguments. Previously, apps launched from the finder had nothing but
|
||||
* an argv[0].
|
||||
*
|
||||
* This message may be received multiple times to open several docs on launch.
|
||||
*
|
||||
* This message is ignored once the app's mainline has been called.
|
||||
*/
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
const char *temparg;
|
||||
size_t arglen;
|
||||
char *arg;
|
||||
char **newargv;
|
||||
|
||||
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||
return FALSE;
|
||||
|
||||
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||
return FALSE;
|
||||
|
||||
temparg = [filename UTF8String];
|
||||
arglen = SDL_strlen(temparg) + 1;
|
||||
arg = (char *) SDL_malloc(arglen);
|
||||
if (arg == NULL)
|
||||
return FALSE;
|
||||
|
||||
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||
if (newargv == NULL)
|
||||
{
|
||||
SDL_free(arg);
|
||||
return FALSE;
|
||||
}
|
||||
gArgv = newargv;
|
||||
|
||||
SDL_strlcpy(arg, temparg, arglen);
|
||||
gArgv[gArgc++] = arg;
|
||||
gArgv[gArgc] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the internal event loop has just started running */
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||
#endif
|
||||
|
||||
/* Hand off to main application code */
|
||||
gCalledAppMainline = TRUE;
|
||||
status = SDL_main (gArgc, gArgv);
|
||||
|
||||
/* 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 */
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||
gArgv[0] = argv[0];
|
||||
gArgv[1] = NULL;
|
||||
gArgc = 1;
|
||||
gFinderLaunch = YES;
|
||||
} else {
|
||||
int i;
|
||||
gArgc = argc;
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||
for (i = 0; i <= argc; i++)
|
||||
gArgv[i] = argv[i];
|
||||
gFinderLaunch = NO;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
[SDLApplication poseAsClass:[NSApplication class]];
|
||||
NSApplicationMain (argc, argv);
|
||||
#else
|
||||
CustomApplicationMain (argc, argv);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
BIN
stuff/osx/quake2-appbundle.zip
Executable file → Normal file
BIN
stuff/osx/quake2-appbundle.zip
Executable file → Normal file
Binary file not shown.
Loading…
Reference in a new issue