2011-11-22 21:28:15 +00:00
/*
===========================================================================
Doom 3 GPL Source Code
2011-12-06 18:20:15 +00:00
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
2011-11-22 21:28:15 +00:00
2011-12-06 16:14:59 +00:00
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
2011-11-22 21:28:15 +00:00
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// -*- mode: objc -*-
#import <AppKit/AppKit.h>
#import <sys/types.h>
#import <sys/param.h>
#import <sys/mount.h>
#import <sys/wait.h>
2011-12-16 22:28:29 +00:00
#import <unistd.h>
#import <dlfcn.h>
#import "sys/platform.h"
#import "sys/osx/macosx_common.h"
#import "sys/osx/macosx_local.h"
#import "sys/osx/macosx_sys.h"
2011-11-22 21:28:15 +00:00
#ifdef OMNI_TIMER
2011-12-16 22:28:29 +00:00
#import "sys/osx/macosx_timers.h"
2011-11-22 21:28:15 +00:00
#endif
void Sys_Init (void);
char *Sys_GetCurrentUser( void );
void Sys_Error( const char *error, ...);
void Sys_Quit (void);
char *Sys_GetClipboardData( void ); // note that this isn't journaled...
void Sys_Print( const char *msg );
//===========================================================================
2011-12-20 15:12:17 +00:00
int main(int argc, char *argv[]) {
return NSApplicationMain(argc, (const char **)argv);
2011-11-22 21:28:15 +00:00
}
//===========================================================================
void EditorPrintConsole( const char *test ) {
}
/*
=================
Sys_UnloadDll
=================
*/
void Sys_UnloadDll( void *dllHandle ) {
}
/*
=================
Sys_LoadDll
Used to load a development dll instead of a virtual machine
=================
*/
extern char *FS_BuildOSPath( const char *base, const char *game, const char *qpath );
void *Sys_LoadDll( const char *name, int (**entryPoint)(int, ...),
2011-12-06 18:20:15 +00:00
int (*systemcalls)(int, ...) )
2011-11-22 21:28:15 +00:00
{
2011-12-06 18:20:15 +00:00
return NULL;
2011-11-22 21:28:15 +00:00
}
//===========================================================================
char *Sys_GetClipboardData(void) // FIXME
{
2011-12-06 18:20:15 +00:00
NSPasteboard *pasteboard;
NSArray *pasteboardTypes;
pasteboard = [NSPasteboard generalPasteboard];
pasteboardTypes = [pasteboard types];
if ([pasteboardTypes containsObject:NSStringPboardType]) {
NSString *clipboardString;
clipboardString = [pasteboard stringForType:NSStringPboardType];
if (clipboardString && [clipboardString length] > 0) {
return strdup([clipboardString cString]);
}
}
return NULL;
2011-11-22 21:28:15 +00:00
}
//===========================================================================
void Sys_BeginProfiling(void)
{
}
void Sys_EndProfiling(void)
{
}
//===========================================================================
/*
================
Sys_Init
The cvar and file system has been setup, so configurations are loaded
================
*/
void Sys_Init(void)
{
// Sys_InitNetwork();
2011-12-06 18:20:15 +00:00
Sys_InitInput();
2011-11-22 21:28:15 +00:00
}
/*
=================
Sys_Shutdown
=================
*/
void Sys_Shutdown(void)
{
2011-12-06 18:20:15 +00:00
common->Printf( "----- Sys_Shutdown -----\n" );
Sys_EndProfiling();
Sys_ShutdownInput();
common->Printf( "------------------------\n" );
2011-11-22 21:28:15 +00:00
}
void Sys_Error(const char *error, ...)
{
2011-12-06 18:20:15 +00:00
va_list argptr;
NSString *formattedString;
2011-11-22 21:28:15 +00:00
2011-12-06 18:20:15 +00:00
Sys_Shutdown();
2011-11-22 21:28:15 +00:00
2011-12-06 18:20:15 +00:00
va_start(argptr,error);
formattedString = [[NSString alloc] initWithFormat:[NSString stringWithCString:error] arguments:argptr];
va_end(argptr);
2011-11-22 21:28:15 +00:00
2011-12-06 18:20:15 +00:00
NSLog(@"Sys_Error: %@", formattedString);
NSRunAlertPanel(@"DOOM Error", formattedString, nil, nil, nil);
2011-11-22 21:28:15 +00:00
2011-12-06 18:20:15 +00:00
Sys_Quit();
2011-11-22 21:28:15 +00:00
}
void Sys_Quit(void)
{
2011-12-06 18:20:15 +00:00
Sys_Shutdown();
[NSApp terminate:nil];
2011-11-22 21:28:15 +00:00
}
/*
================
Sys_Print
This is called for all console output, even if the game is running
full screen and the dedicated console window is hidden.
================
*/
char *ansiColors[8] =
{ "\033[30m" , /* ANSI Black */
"\033[31m" , /* ANSI Red */
"\033[32m" , /* ANSI Green */
"\033[33m" , /* ANSI Yellow */
"\033[34m" , /* ANSI Blue */
"\033[36m" , /* ANSI Cyan */
"\033[35m" , /* ANSI Magenta */
"\033[37m" }; /* ANSI White */
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
void Sys_Print(const char *text)
{
#if 0
/* Okay, this is a stupid hack, but what the hell, I was bored. ;) */
char *scan = text;
char code;
int index;
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
/* Make sure terminal mode is reset at the start of the line... */
fputs("\033[0m", stdout);
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
while(*scan) {
2011-12-06 18:20:15 +00:00
/* See if we have a color control code. If so, snarf the character,
2011-11-22 21:28:15 +00:00
print what we have so far, print the ANSI Terminal color code,
skip over the color control code and continue */
if(Q_IsColorString(scan)) {
index = ColorIndex(scan[1]);
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
/* Flush current message */
if(scan != text) {
fwrite(text, scan - text, 1, stdout);
}
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
/* Write ANSI color code */
fputs(ansiColors[index], stdout);
2011-12-06 18:20:15 +00:00
2011-11-22 21:28:15 +00:00
/* Reset search */
text = scan+2;
scan = text;
2011-12-06 18:20:15 +00:00
continue;
2011-11-22 21:28:15 +00:00
}
scan++;
}
/* Flush whatever's left */
fputs(text, stdout);
/* Make sure terminal mode is reset at the end of the line too... */
fputs("\033[0m", stdout);
#else
2011-12-06 18:20:15 +00:00
fputs(text, stdout);
#endif
2011-11-22 21:28:15 +00:00
}
void OutputDebugString( const char *text ) {
2011-12-06 18:20:15 +00:00
Sys_Print( text );
2011-11-22 21:28:15 +00:00
}
void Sys_OutputDebugString( const char *text ) {
2011-12-06 18:20:15 +00:00
OutputDebugString( text );
2011-11-22 21:28:15 +00:00
}
/*
================
Sys_CheckCD
Return true if the proper CD is in the drive
================
*/
bool Sys_CheckCD( void ) {
2011-12-06 18:20:15 +00:00
return macosx_scanForLibraryDirectory() != NULL;
2011-11-22 21:28:15 +00:00
}