openmohaa/code/mohui/ui_main.cpp
2016-03-27 11:49:47 +02:00

144 lines
3 KiB
C++

/*
===========================================================================
Copyright (C) 2010-2011 Michael Rieder
This file is part of OpenMohaa source code.
OpenMohaa 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 2 of the License,
or (at your option) any later version.
OpenMohaa 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 OpenMohaa source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
/*
=======================================================================
USER INTERFACE MAIN
=======================================================================
*/
#include "ui_local.h"
// Memory allocation code from Q3 ui_shared.c
// ****
// allocates 16-byte blocks out of a pool of MEM_POOL_SIZE=1MB
#define MEM_POOL_SIZE 1024 * 1024
static char memoryPool[MEM_POOL_SIZE];
static int allocPoint;
qboolean outOfMemory;
/*
===============
UI_Alloc
===============
*/
void *UI_Alloc( int size ) {
char *p;
if ( allocPoint + size > MEM_POOL_SIZE ) {
outOfMemory = qtrue;
Com_Printf("UI_Alloc: Failure. Out of memory!\n");
return NULL;
}
p = &memoryPool[allocPoint];
allocPoint += ( size + 15 ) & ~15;
return p;
}
/*
===============
UI_Free
===============
*/
void UI_Free( void *p ) {
}
/*
===============
UI_InitMemory
===============
*/
void UI_InitMemory( void ) {
allocPoint = 0;
outOfMemory = qfalse;
}
qboolean UI_OutOfMemory( void ) {
return outOfMemory;
}
/*
================
vmMain
This is the only way control passes into the module.
This must be the very first function compiled into the .qvm file
================
*/
#if 0
intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
switch ( command ) {
case UI_GETAPIVERSION:
return UI_API_VERSION;
case UI_INIT:
UI_Init();
return 0;
case UI_SHUTDOWN:
UI_Shutdown();
return 0;
case UI_KEY_EVENT:
UI_KeyEvent( arg0, arg1 );
return 0;
case UI_MOUSE_EVENT:
UI_MouseEvent( arg0, arg1 );
return 0;
case UI_REFRESH:
UI_Refresh( arg0 );
return 0;
case UI_HUD:
UI_DrawHUD( (playerState_t*)arg0 );
return 0;
case UI_IS_FULLSCREEN:
return UI_IsFullscreen();
case UI_SET_ACTIVE_MENU:
UI_SetActiveMenu( (uiMenuCommand_t)arg0 );
return 0;
case UI_CONSOLE_COMMAND:
return UI_ConsoleCommand(arg0);
case UI_DRAW_CONNECT_SCREEN:
UI_DrawConnectScreen( (qboolean)arg0 );
return 0;
case UI_HASUNIQUECDKEY: // mod authors need to observe this
return qtrue; // change this to qfalse for mods!
}
return -1;
}
#endif