Initial commit.

This commit is contained in:
Jim Gray
2013-04-04 14:32:05 -07:00
parent ba5c81da32
commit d71d53e8ec
2180 changed files with 1393544 additions and 1 deletions

35
code/ui/gameinfo.cpp Normal file
View File

@@ -0,0 +1,35 @@
//
// gameinfo.c
//
// *** This file is used by both the game and the user interface ***
// ... and for that reason is excluded from PCH usage for the moment =Ste.
#include "gameinfo.h"
#include "..\game\weapons.h"
gameinfo_import_t gi;
weaponData_t weaponData[WP_NUM_WEAPONS];
ammoData_t ammoData[AMMO_MAX];
extern void WP_LoadWeaponParms (void);
//
// Initialization - Read in files and parse into infos
//
/*
===============
GI_Init
===============
*/
void GI_Init( gameinfo_import_t *import ) {
gi = *import;
WP_LoadWeaponParms ();
}

24
code/ui/gameinfo.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef __GAMEINFO_H__
#define __GAMEINFO_H__
#include "../game/q_shared.h"
#include <stdio.h>
typedef struct {
int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode );
int (*FS_Read)( void *buffer, int len, fileHandle_t f );
void (*FS_FCloseFile)( fileHandle_t f );
void (*Cvar_Set)( const char *name, const char *value );
void (*Cvar_VariableStringBuffer)( const char *var_name, char *buffer, int bufsize );
void (*Cvar_Create)( const char *var_name, const char *var_value, int flags );
int (*FS_ReadFile)( const char *name, void **buf );
void (*FS_FreeFile)( void *buf );
void (*Printf)( const char *fmt, ... );
} gameinfo_import_t;
void GI_Init( gameinfo_import_t *import );
#endif

143
code/ui/menudef.h Normal file
View File

@@ -0,0 +1,143 @@
#define ITEM_TYPE_TEXT 0 // simple text
#define ITEM_TYPE_BUTTON 1 // button, basically text with a border
#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped
#define ITEM_TYPE_CHECKBOX 3 // check box
#define ITEM_TYPE_EDITFIELD 4 // editable text, associated with a cvar
#define ITEM_TYPE_COMBO 5 // drop down list
#define ITEM_TYPE_LISTBOX 6 // scrollable list
#define ITEM_TYPE_MODEL 7 // model
#define ITEM_TYPE_OWNERDRAW 8 // owner draw, name specs what it is
#define ITEM_TYPE_NUMERICFIELD 9 // editable text, associated with a cvar
#define ITEM_TYPE_SLIDER 10 // mouse speed, volume, etc.
#define ITEM_TYPE_YESNO 11 // yes no cvar setting
#define ITEM_TYPE_MULTI 12 // multiple list setting, enumerated
#define ITEM_TYPE_BIND 13 // multiple list setting, enumerated
#define ITEM_TYPE_TEXTSCROLL 14 // scrolling text
#define ITEM_ALIGN_LEFT 0 // left alignment
#define ITEM_ALIGN_CENTER 1 // center alignment
#define ITEM_ALIGN_RIGHT 2 // right alignment
#define ITEM_TEXTSTYLE_NORMAL 0 // normal text
#define ITEM_TEXTSTYLE_BLINK 1 // fast blinking
#define ITEM_TEXTSTYLE_PULSE 2 // slow pulsing
#define ITEM_TEXTSTYLE_SHADOWED 3 // drop shadow ( need a color for this )
#define ITEM_TEXTSTYLE_OUTLINED 4 // drop shadow ( need a color for this )
#define ITEM_TEXTSTYLE_OUTLINESHADOWED 5 // drop shadow ( need a color for this )
#define ITEM_TEXTSTYLE_SHADOWEDMORE 6 // drop shadow ( need a color for this )
#define WINDOW_BORDER_NONE 0 // no border
#define WINDOW_BORDER_FULL 1 // full border based on border color ( single pixel )
#define WINDOW_BORDER_HORZ 2 // horizontal borders only
#define WINDOW_BORDER_VERT 3 // vertical borders only
#define WINDOW_BORDER_KCGRADIENT 4 // horizontal border using the gradient bars
#define WINDOW_STYLE_EMPTY 0 // no background
#define WINDOW_STYLE_FILLED 1 // filled with background color
#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color
#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color
#define WINDOW_STYLE_TEAMCOLOR 4 // team color
#define WINDOW_STYLE_CINEMATIC 5 // cinematic
#define MENU_TRUE 1 // uh.. true
#define MENU_FALSE 0 // and false
#define HUD_VERTICAL 0x00
#define HUD_HORIZONTAL 0x01
// list box element types
#define LISTBOX_TEXT 0x00
#define LISTBOX_IMAGE 0x01
// list feeders
#define FEEDER_SAVEGAMES 0x00 // save games
#define FEEDER_MAPS 0x01 // text maps based on game type
#define FEEDER_SERVERS 0x02 // servers
#define FEEDER_CLANS 0x03 // clan names
#define FEEDER_ALLMAPS 0x04 // all maps available, in graphic format
#define FEEDER_REDTEAM_LIST 0x05 // red team members
#define FEEDER_BLUETEAM_LIST 0x06 // blue team members
#define FEEDER_PLAYER_LIST 0x07 // players
#define FEEDER_TEAM_LIST 0x08 // team members for team voting
#define FEEDER_MODS 0x09 //
#define FEEDER_DEMOS 0x0a //
#define FEEDER_SCOREBOARD 0x0b //
#define FEEDER_Q3HEADS 0x0c // model heads
#define FEEDER_SERVERSTATUS 0x0d // server status
#define FEEDER_FINDPLAYER 0x0e // find player
#define FEEDER_CINEMATICS 0x0f // cinematics
#define FEEDER_PLAYER_SPECIES 0x10 // models/player/*w
#define FEEDER_PLAYER_SKIN_HEAD 0x11 // head*.skin files in species folder
#define FEEDER_PLAYER_SKIN_TORSO 0x12 // torso*.skin files in species folder
#define FEEDER_PLAYER_SKIN_LEGS 0x13 // lower*.skin files in species folder
#define FEEDER_COLORCHOICES 0x14 // special hack to feed text/actions from playerchoice.txt in species folder
#define FEEDER_MOVES 0x15 // moves for the data pad moves screen
#define FEEDER_MOVES_TITLES 0x16 // move titles for the data pad moves screen
#define FEEDER_LANGUAGES 0x17 // the list of languages
#define FEEDER_PROFILES 0x18 //list of saved profiles
#define FEEDER_LEVELSELECT 0x19 // list of levels for level select cheat screen
#define UI_SOFT_KEYBOARD_ACCEPT 197
#define UI_SOFT_KEYBOARD_DELETE 198
#define UI_SOFT_KEYBOARD 199
#define UI_VERSION 200
#define UI_HANDICAP 200
#define UI_EFFECTS 201
#define UI_PLAYERMODEL 202
#define UI_DATAPAD_MISSION 203
#define UI_DATAPAD_WEAPONS 204
#define UI_DATAPAD_INVENTORY 205
#define UI_DATAPAD_FORCEPOWERS 206
#define UI_SKILL 207
#define UI_BLUETEAMNAME 208
#define UI_REDTEAMNAME 209
#define UI_BLUETEAM1 210
#define UI_BLUETEAM2 211
#define UI_BLUETEAM3 212
#define UI_BLUETEAM4 213
#define UI_BLUETEAM5 214
#define UI_REDTEAM1 215
#define UI_REDTEAM2 216
#define UI_REDTEAM3 217
#define UI_REDTEAM4 218
#define UI_REDTEAM5 219
#define UI_NETSOURCE 220
#define UI_NETMAPPREVIEW 221
#define UI_NETFILTER 222
#define UI_TIER 223
#define UI_OPPONENTMODEL 224
#define UI_TIERMAP1 225
#define UI_TIERMAP2 226
#define UI_TIERMAP3 227
#define UI_PLAYERLOGO 228
#define UI_OPPONENTLOGO 229
#define UI_PLAYERLOGO_METAL 230
#define UI_OPPONENTLOGO_METAL 231
#define UI_PLAYERLOGO_NAME 232
#define UI_OPPONENTLOGO_NAME 233
#define UI_TIER_MAPNAME 234
#define UI_TIER_GAMETYPE 235
#define UI_ALLMAPS_SELECTION 236
#define UI_OPPONENT_NAME 237
#define UI_VOTE_KICK 238
#define UI_BOTNAME 239
#define UI_BOTSKILL 240
#define UI_REDBLUE 241
#define UI_CROSSHAIR 242
#define UI_SELECTEDPLAYER 243
#define UI_MAPCINEMATIC 244
#define UI_NETGAMETYPE 245
#define UI_NETMAPCINEMATIC 246
#define UI_SERVERREFRESHDATE 247
#define UI_SERVERMOTD 248
#define UI_GLINFO 249
#define UI_KEYBINDSTATUS 250
#define UI_CLANCINEMATIC 251
#define UI_MAP_TIMETOBEAT 252
#define UI_JOINGAMETYPE 253
#define UI_PREVIEWCINEMATIC 254
#define UI_STARTMAPCINEMATIC 255
#define UI_MAPS_SELECTION 256

4
code/ui/ui.def Normal file
View File

@@ -0,0 +1,4 @@
EXPORTS
GetUIAPI
vmMain
dllEntry

504
code/ui/ui_atoms.cpp Normal file
View File

@@ -0,0 +1,504 @@
/**********************************************************************
UI_ATOMS.C
User interface building blocks and support functions.
**********************************************************************/
// leave this at the top of all UI_xxxx files for PCH reasons...
//
#include "../server/exe_headers.h"
#include "ui_local.h"
#include "gameinfo.h"
#include "../qcommon/stv_version.h"
uiimport_t ui;
uiStatic_t uis;
//externs
static void UI_LoadMenu_f( void );
static void UI_SaveMenu_f( void );
//locals
/*
=================
UI_ForceMenuOff
=================
*/
void UI_ForceMenuOff (void)
{
ui.Key_SetCatcher( ui.Key_GetCatcher() & ~KEYCATCH_UI );
ui.Key_ClearStates();
ui.Cvar_Set( "cl_paused", "0" );
}
/*
=================
UI_SetActiveMenu -
this should be the ONLY way the menu system is brought up
=================
*/
extern void S_StopAllSoundsExceptMusic( void );
void UI_SetActiveMenu( const char* menuname,const char *menuID )
{
// Sooper-hack. After we play the ja08 cutscene, the game renders for a couple frames.
// So the cinematic code turns off Present(), and we have to turn it back on here:
extern bool connectSwapOverride;
connectSwapOverride = false;
// this should be the ONLY way the menu system is brought up (besides the UI_ConsoleCommand below)
if (cls.state != CA_DISCONNECTED && !ui.SG_GameAllowedToSaveHere(qtrue)) //don't check full sytem, only if incamera
{
return;
}
if ( !menuname ) {
UI_ForceMenuOff();
return;
}
//make sure force-speed and slowmodeath doesn't slow down menus - NOTE: they should reset the timescale when the game un-pauses
Cvar_SetValue( "timescale", 1.0f );
UI_Cursor_Show(qtrue);
// enusure minumum menu data is cached
Menu_Cache();
if ( Q_stricmp (menuname, "mainMenu") == 0 )
{
UI_MainMenu();
return;
}
if ( Q_stricmp (menuname, "ingame") == 0 )
{
ui.Cvar_Set( "cl_paused", "1" );
// S_StopAllSounds();
//NOT USED
//JLF usually called with menuID == NULL but if 'noController' is the menuID
// this forces the pause menu open first and then opens the 'noController' menu
//basically forces the 'ingameMainMenu' open first
// if (menuID)
// UI_InGameMenu(NULL);
//END NOT USED
UI_InGameMenu(menuID);
return;
}
if ( Q_stricmp (menuname, "datapad") == 0 )
{
ui.Cvar_Set( "cl_paused", "1" );
S_StopAllSoundsExceptMusic();
UI_DataPadMenu();
return;
}
if ( Q_stricmp (menuname, "missionfailed_menu") == 0 )
{
Menus_CloseAll();
Menus_ActivateByName("missionfailed_menu");
ui.Key_SetCatcher( KEYCATCH_UI );
return;
}
//allows the 'noController' menu and similar menus to 'popup' over existing menu
if ( Q_stricmp (menuname, "ui_popup") == 0 )
{
Menus_ActivateByName(menuID);
return;
}
//JLF SPLASHMAIN MPSKIPPED
#ifdef _XBOX
{
Menus_CloseAll();
if (Menus_ActivateByName(menuname))
ui.Key_SetCatcher( KEYCATCH_UI );
else
UI_MainMenu();
}
#endif
}
/*
=================
UI_Argv
=================
*/
static char *UI_Argv( int arg )
{
static char buffer[MAX_STRING_CHARS];
ui.Argv( arg, buffer, sizeof( buffer ) );
return buffer;
}
/*
=================
UI_Cvar_VariableString
=================
*/
char *UI_Cvar_VariableString( const char *var_name )
{
static char buffer[MAX_STRING_CHARS];
ui.Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) );
return buffer;
}
/*
=================
UI_Cache
=================
*/
static void UI_Cache_f( void )
{
int index;
Menu_Cache();
extern const char *lukeForceStatusSounds[];
extern const char *kyleForceStatusSounds[];
for (index = 0; index < 5; index++)
{
DC->registerSound(lukeForceStatusSounds[index], qfalse);
DC->registerSound(kyleForceStatusSounds[index], qfalse);
}
for (index = 1; index <= 18; index++)
{
DC->registerSound(va("sound/chars/storyinfo/%d",index), qfalse);
}
trap_S_RegisterSound("sound/chars/kyle/04kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/05kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/07kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/14kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/21kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/24kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/kyle/25kyk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/luke/06luk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/luke/08luk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/luke/22luk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/luke/23luk001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/protocol/12pro001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/protocol/15pro001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/protocol/16pro001.mp3", qfalse);
trap_S_RegisterSound("sound/chars/wedge/13wea001.mp3", qfalse);
Menus_ActivateByName("ingameMissionSelect1");
Menus_ActivateByName("ingameMissionSelect2");
Menus_ActivateByName("ingameMissionSelect3");
}
/*
=================
UI_ConsoleCommand
=================
*/
void UI_Load(void); //in UI_main.cpp
qboolean UI_ConsoleCommand( void )
{
char *cmd;
if (!ui.SG_GameAllowedToSaveHere(qtrue)) //only check if incamera
{
return qfalse;
}
cmd = UI_Argv( 0 );
// ensure minimum menu data is available
Menu_Cache();
if ( Q_stricmp (cmd, "ui_cache") == 0 )
{
UI_Cache_f();
return qtrue;
}
if ( Q_stricmp (cmd, "levelselect") == 0 )
{
UI_LoadMenu_f();
return qtrue;
}
if ( Q_stricmp (cmd, "ui_teamOrders") == 0 )
{
UI_SaveMenu_f();
return qtrue;
}
if ( Q_stricmp (cmd, "ui_report") == 0 )
{
UI_Report();
return qtrue;
}
if ( Q_stricmp (cmd, "ui_load") == 0 )
{
UI_Load();
return qtrue;
}
return qfalse;
}
/*
=================
UI_Init
=================
*/
void UI_Init( int apiVersion, uiimport_t *uiimport, qboolean inGameLoad )
{
ui = *uiimport;
if ( apiVersion != UI_API_VERSION ) {
ui.Error( ERR_FATAL, "Bad UI_API_VERSION: expected %i, got %i\n", UI_API_VERSION, apiVersion );
}
// get static data (glconfig, media)
ui.GetGlconfig( &uis.glconfig );
uis.scaley = uis.glconfig.vidHeight * (1.0/480.0);
uis.scalex = uis.glconfig.vidWidth * (1.0/640.0);
Menu_Cache( );
ui.Cvar_Create( "cg_drawCrosshair", "1", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_marks", "1", CVAR_ARCHIVE );
// ui.Cvar_Create ("s_language", "english", CVAR_ARCHIVE | CVAR_NORESTART);
ui.Cvar_Create( "g_char_model", "jedi_tf", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_skin_head", "head_a1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_skin_torso", "torso_a1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_skin_legs", "lower_a1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_color_red", "255", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_color_green", "255", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_char_color_blue", "255", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_saber_type", "single", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_saber", "single_1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_saber2", "", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_saber_color", "yellow", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "g_saber2_color", "yellow", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART );
ui.Cvar_Create( "ui_forcepower_inc", "0", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
ui.Cvar_Create( "tier_storyinfo", "0", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
ui.Cvar_Create( "tiers_complete", "", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
ui.Cvar_Create( "ui_prisonerobj_currtotal", "0", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
ui.Cvar_Create( "ui_prisonerobj_mintotal", "0", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
ui.Cvar_Create( "g_dismemberment", "3", CVAR_ARCHIVE );//0 = none, 1 = arms and hands, 2 = legs, 3 = waist and head, 4 = mega dismemberment
ui.Cvar_Create( "cg_gunAutoFirst", "1", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_crosshairIdentifyTarget", "1", CVAR_ARCHIVE );
ui.Cvar_Create( "g_subtitles", "0", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_marks", "1", CVAR_ARCHIVE );
ui.Cvar_Create( "d_slowmodeath", "3", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_shadows", "1", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_runpitch", "0.002", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_runroll", "0.005", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_bobup", "0.005", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_bobpitch", "0.002", CVAR_ARCHIVE );
ui.Cvar_Create( "cg_bobroll", "0.002", CVAR_ARCHIVE );
ui.Cvar_Create( "ui_disableWeaponSway", "0", CVAR_ARCHIVE );
_UI_Init(inGameLoad);
}
// these are only here so the functions in q_shared.c can link
#ifndef UI_HARD_LINKED
/*
================
Com_Error
=================
*/
/*
void Com_Error( int level, const char *error, ... )
{
va_list argptr;
char text[1024];
va_start (argptr, error);
vsprintf (text, error, argptr);
va_end (argptr);
ui.Error( level, "%s", text);
}
*/
/*
================
Com_Printf
=================
*/
/*
void Com_Printf( const char *msg, ... )
{
va_list argptr;
char text[1024];
va_start (argptr, msg);
vsprintf (text, msg, argptr);
va_end (argptr);
ui.Printf( "%s", text);
}
*/
#endif
/*
================
UI_DrawNamedPic
=================
*/
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname )
{
qhandle_t hShader;
hShader = ui.R_RegisterShaderNoMip( picname );
ui.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader );
}
/*
================
UI_DrawHandlePic
=================
*/
void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader )
{
float s0;
float s1;
float t0;
float t1;
if( w < 0 ) { // flip about horizontal
w = -w;
s0 = 1;
s1 = 0;
}
else {
s0 = 0;
s1 = 1;
}
if( h < 0 ) { // flip about vertical
h = -h;
t0 = 1;
t1 = 0;
}
else {
t0 = 0;
t1 = 1;
}
ui.R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader );
}
/*
================
UI_FillRect
Coordinates are 640*480 virtual values
=================
*/
void UI_FillRect( float x, float y, float width, float height, const float *color )
{
ui.R_SetColor( color );
ui.R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uis.whiteShader );
ui.R_SetColor( NULL );
}
/*
=================
UI_UpdateScreen
=================
*/
void UI_UpdateScreen( void )
{
ui.UpdateScreen();
}
/*
===============
UI_LoadMenu_f
===============
*/
static void UI_LoadMenu_f( void )
{
trap_Key_SetCatcher( KEYCATCH_UI );
Menus_ActivateByName("ingameloadMenu");
}
/*
===============
UI_SaveMenu_f
===============
*/
static void UI_SaveMenu_f( void )
{
// ui.PrecacheScreenshot();
trap_Key_SetCatcher( KEYCATCH_UI );
Menus_ActivateByName("ingamesaveMenu");
}
//--------------------------------------------
/*
=================
UI_SetColor
=================
*/
void UI_SetColor( const float *rgba )
{
trap_R_SetColor( rgba );
}
/*int registeredFontCount = 0;
#define MAX_FONTS 6
static fontInfo_t registeredFont[MAX_FONTS];
*/
/*
=================
UI_RegisterFont
=================
*/
int UI_RegisterFont(const char *fontName)
{
int iFontIndex = ui.R_RegisterFont(fontName);
if (iFontIndex == 0)
{
iFontIndex = ui.R_RegisterFont("ergoec"); // fall back
}
return iFontIndex;
}

127
code/ui/ui_connect.cpp Normal file
View File

@@ -0,0 +1,127 @@
// leave this at the top of all UI_xxxx files for PCH reasons...
//
#include "../server/exe_headers.h"
#include "ui_local.h"
/*
===============================================================================
CONNECTION SCREEN
===============================================================================
*/
char connectionDialogString[1024];
char connectionMessageString[1024];
/*
========================
UI_DrawConnect
========================
*/
void UI_DrawConnect( const char *servername, const char *updateInfoString )
{
// We need to use this special hack variable, nothing else is set up yet:
const char *s = Cvar_VariableString( "ui_mapname" );
// Special case for first map:
extern SavedGameJustLoaded_e g_eSavedGameJustLoaded;
if ( g_eSavedGameJustLoaded != eFULL && (!strcmp(s,"yavin1") || !strcmp(s,"demo")) )
{
ui.R_SetColor( colorTable[CT_BLACK] );
uis.whiteShader = ui.R_RegisterShaderNoMip( "*white" );
ui.R_DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f, 1.0f, uis.whiteShader );
const char *t = SE_GetString( "SP_INGAME_ALONGTIME" );
int w = ui.R_Font_StrLenPixels( t, uiInfo.uiDC.Assets.qhMediumFont, 1.0f );
ui.R_Font_DrawString( (320)-(w/2), 140, t, colorTable[CT_ICON_BLUE], uiInfo.uiDC.Assets.qhMediumFont, -1, 1.0f );
return;
}
// Grab the loading menu:
extern menuDef_t *Menus_FindByName( const char *p );
menuDef_t *menu = Menus_FindByName( "loadingMenu" );
if( !menu )
return;
// Find the levelshot item, so we can fix up it's shader:
itemDef_t *item = Menu_FindItemByName( menu, "mappic" );
if( !item )
return;
item->window.background = ui.R_RegisterShaderNoMip( va( "levelshots/%s", s ) );
if (!item->window.background) {
item->window.background = ui.R_RegisterShaderNoMip( "menu/art/unknownmap" );
}
// Do the second levelshot as well:
qhandle_t firstShot = item->window.background;
item = Menu_FindItemByName( menu, "mappic2" );
if( !item )
return;
item->window.background = ui.R_RegisterShaderNoMip( va( "levelshots/%s2", s ) );
if (!item->window.background) {
item->window.background = firstShot;
}
const char *b = SE_GetString( "BRIEFINGS", s );
if( b && b[0] )
Cvar_Set( "ui_missionbriefing", va("@BRIEFINGS_%s", s) );
else
Cvar_Set( "ui_missionbriefing", "@BRIEFINGS_NONE" );
// Now, force it to draw:
extern void Menu_Paint( menuDef_t *menu, qboolean forcePaint );
Menu_Paint( menu, qtrue );
}
/*
========================
UI_UpdateConnectionString
========================
*/
void UI_UpdateConnectionString( char *string ) {
Q_strncpyz( connectionDialogString, string, sizeof( connectionDialogString ) );
UI_UpdateScreen();
}
/*
========================
UI_UpdateConnectionMessageString
========================
*/
void UI_UpdateConnectionMessageString( char *string ) {
char *s;
Q_strncpyz( connectionMessageString, string, sizeof( connectionMessageString ) );
// strip \n
s = strstr( connectionMessageString, "\n" );
if ( s ) {
*s = 0;
}
UI_UpdateScreen();
}
/*
===================
UI_KeyConnect
===================
*/
void UI_KeyConnect( int key )
{
if ( key == A_ESCAPE )
{
ui.Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
return;
}
}

747
code/ui/ui_debug.cpp Normal file
View File

@@ -0,0 +1,747 @@
// Filename:- ui_debug.cpp
//
// an entire temp module just for doing some evil menu hackery during development...
//
#include "../server/exe_headers.h"
#if 0 // this entire module was special code to StripEd-ify *menu, it isn't needed now, but I'll keep the source around for a while -ste
#ifdef _DEBUG
#include <set>
#include "../qcommon/sstring.h"
typedef sstring<4096> sstringBIG_t;
typedef set<sstring_t> StringSet_t;
StringSet_t MenusUsed;
typedef map <sstring_t, StringSet_t> ReferencesAndPackages_t;
ReferencesAndPackages_t ReferencesAndPackage;
struct Reference_t
{
sstringBIG_t sString;
sstring_t sReference;
sstring_t sMenu;
Reference_t()
{
sString = "";
sReference = "";
sMenu = "";
}
// sort by menu entry, then by reference within menu...
//
bool operator < (const Reference_t& _X) const
{
int i = stricmp(sMenu.c_str(),_X.sMenu.c_str());
if (i)
return i<0;
return !!(stricmp(sReference.c_str(),_X.sReference.c_str()) < 0);
}
};
#include <list>
typedef list <Reference_t> References_t;
References_t BadReferences;
sstring_t sCurrentMenu;
void UI_Debug_AddMenuFilePath(LPCSTR psMenuFile) // eg "ui/blah.menu"
{
sCurrentMenu = psMenuFile;
OutputDebugString(va("Current menu: \"%s\"\n",psMenuFile));
}
typedef struct
{
// to correct...
//
sstring_t sMenuFile;
sstringBIG_t sTextToFind; // will be either @REFERENCE or "text"
sstringBIG_t sTextToReplaceWith; // will be @NEWREF
//
// to generate new data...
//
sstring_t sStripEdReference; // when NZ, this will create a new StripEd entry...
sstringBIG_t sStripEdText;
sstring_t sStripEdFileRef; // ... in this file reference (eg "SPMENUS%d"), where 0.255 of each all have this in them (for ease of coding)
} CorrectionDataItem_t;
typedef list<CorrectionDataItem_t> CorrectionData_t;
CorrectionData_t CorrectionData;
static LPCSTR CreateUniqueReference(LPCSTR psText)
{
static set <sstringBIG_t> ReferencesSoFar;
static sstringBIG_t NewReference;
LPCSTR psTextScanPos = psText;
while(*psTextScanPos)
{
while (isspace(*psTextScanPos)) psTextScanPos++;
NewReference = psTextScanPos;
// cap off text at an approx length...
//
const int iApproxReferenceLength = 20;
char *p;
if (iApproxReferenceLength<strlen(NewReference.c_str()))
{
p = NewReference.c_str();
p+=iApproxReferenceLength;
while ( *p && !isspace(*p))
p++;
*p = '\0';
}
// now replace everything except digits and letters with underscores...
//
p = NewReference.c_str();
for (int i=0; i<strlen(p); i++)
{
if (!isalpha(p[i]) && !isdigit(p[i]))
{
p[i] = '_';
}
}
strupr(p);
// remove any trailing underscores...
//
while ( strlen(NewReference.c_str()) && NewReference.c_str()[strlen(NewReference.c_str())-1]=='_')
{
NewReference.c_str()[strlen(NewReference.c_str())-1]='\0';
}
// remove any multiple underscores...
//
while ( (p=strstr(NewReference.c_str(),"__")) != NULL)
{
memmove(p,p+1,strlen(p+1)+1);
}
// do we already have this reference?...
//
if (!strlen(NewReference.c_str()))
{
break; // empty, shit.
}
if (ReferencesSoFar.find(NewReference.c_str()) == ReferencesSoFar.end())
{
// no, so add it in then return...
//
ReferencesSoFar.insert(NewReference.c_str());
return NewReference.c_str();
}
// skip past the first word in the reference and try again...
//
while (*psTextScanPos && !isspace(*psTextScanPos)) psTextScanPos++;
}
// if we get here then we're getting desperate, so...
//
// (special case check first)...
//
for (LPCSTR p2 = psText; *p2 && isspace(*p2); p2++){}
if (!*p2)
{
psText = "BLANK";
}
int iReScanDigit = 1;
while (1)
{
NewReference = va("%s_%d",psText,iReScanDigit++);
// now replace everything except digits and letters with underscores...
//
char *p = NewReference.c_str();
for (int i=0; i<strlen(p); i++)
{
if (!isalpha(p[i]) && !isdigit(p[i]))
{
p[i] = '_';
}
}
strupr(p);
// remove any trailing underscores...
//
while ( strlen(NewReference.c_str()) && NewReference.c_str()[strlen(NewReference.c_str())-1]=='_')
{
NewReference.c_str()[strlen(NewReference.c_str())-1]='\0';
}
// remove any multiple underscores...
//
while ( (p=strstr(NewReference.c_str(),"__")) != NULL)
{
memmove(p,p+1,strlen(p+1)+1);
}
if (ReferencesSoFar.find(NewReference.c_str()) == ReferencesSoFar.end())
{
// no, so add it in then return...
//
ReferencesSoFar.insert(NewReference.c_str());
return NewReference.c_str();
}
}
// should never get here...
//
assert(0);
return NULL;
}
static LPCSTR EnterBadRef(LPCSTR ps4LetterType, LPCSTR psBad)
{
Reference_t BadReference;
BadReference.sString = psBad;
BadReference.sMenu = sCurrentMenu;
BadReferences.push_back( BadReference );
LPCSTR p = NULL;
// p = CreateUniqueReference(psBad);
// OutputDebugString(va("NEWREF: \"%s\"\n",p));
return p;
}
static void EnterRef(LPCSTR psReference, LPCSTR psText, LPCSTR psMenuFile)
{
// special hack, StripEd text at this point will have had any "\n" LITERALS replaced by the 0x0D 0x0A pair,
// so we need to put them back to "\n" text ready for saving out into StripEd files again...
//
string strNewText( psText );
//
// not sure whether just 0x0A or 0x0D/0x0A pairs (sigh), so first, eliminate 0x0Ds...
//
int iLoc;
while ( (iLoc = strNewText.find(0x0D,0)) != -1)
{
strNewText.replace(iLoc, 1, "");
}
// now replace any 0x0As with literal "\n" strings...
//
while ( (iLoc = strNewText.find(0x0A,0)) != -1)
{
strNewText.replace(iLoc, 1, "\\n");
}
psText = strNewText.c_str();
// curiousity...
//
static int iLongestText = 0;
if (iLongestText < strlen(psText))
{
iLongestText = strlen(psText);
OutputDebugString(va("Longest StripEd text: %d\n",iLongestText));
}
typedef map <sstringBIG_t, sstring_t> TextConsolidationTable_t; // string and ref
static TextConsolidationTable_t TextConsolidationTable, RefrConsolidationTable;
static int iIndex = 0; // INC'd every time a new StripEd entry is synthesised
TextConsolidationTable_t::iterator it = TextConsolidationTable.find(psText);
if (it == TextConsolidationTable.end())
{
// new entry...
//
LPCSTR psNewReference = CreateUniqueReference( (strlen(psReference) > strlen(psText))?psReference:psText );
CorrectionDataItem_t CorrectionDataItem;
CorrectionDataItem.sMenuFile = psMenuFile;
CorrectionDataItem.sTextToFind = strlen(psReference) ? ( /* !stricmp(psReference,psNewReference) ? "" :*/ va("@%s",psReference) )
: va("\"%s\"",psText);
CorrectionDataItem.sTextToReplaceWith = /* !stricmp(psReference,psNewReference) ? "" : */va("@%s",psNewReference);
//
CorrectionDataItem.sStripEdReference = psNewReference;
CorrectionDataItem.sStripEdText = psText;
// qboolean bIsMulti = !!strstr(psMenuFile,"jk2mp");
// CorrectionDataItem.sStripEdFileRef = va("%sMENUS%d",bIsMulti?"MP":"SP",iIndex/256);
CorrectionDataItem.sStripEdFileRef = va( "MENUS%d",iIndex/256);
iIndex++;
CorrectionData.push_back( CorrectionDataItem );
TextConsolidationTable[ psText ] = psNewReference;
RefrConsolidationTable[ psText ] = CorrectionDataItem.sStripEdFileRef.c_str();
}
else
{
// text already entered, so do a little duplicate-resolving...
//
// need to find the reference for the existing version...
//
LPCSTR psNewReference = (*it).second.c_str();
LPCSTR psPackageRef = (*RefrConsolidationTable.find(psText)).second.c_str(); // yeuch, hack-city
// only enter correction data if references are different...
//
// if (stricmp(psReference,psNewReference))
{
CorrectionDataItem_t CorrectionDataItem;
CorrectionDataItem.sMenuFile = psMenuFile;
CorrectionDataItem.sTextToFind = strlen(psReference) ? va("@%s",psReference) : va("\"%s\"",psText);
CorrectionDataItem.sTextToReplaceWith = va("@%s",psNewReference);
//
CorrectionDataItem.sStripEdReference = "";
CorrectionDataItem.sStripEdText = "";
CorrectionDataItem.sStripEdFileRef = psPackageRef;
CorrectionData.push_back( CorrectionDataItem );
}
}
}
static void EnterGoodRef(LPCSTR ps4LetterType, LPCSTR psReference, LPCSTR psPackageReference, LPCSTR psText)
{
EnterRef(psReference, psText, sCurrentMenu.c_str());
ReferencesAndPackage[psReference].insert(psPackageReference);
MenusUsed.insert(psPackageReference);
}
static bool SendFileToNotepad(LPCSTR psFilename)
{
bool bReturn = false;
char sExecString[MAX_PATH];
sprintf(sExecString,"notepad %s",psFilename);
if (WinExec(sExecString, // LPCSTR lpCmdLine, // address of command line
SW_SHOWNORMAL // UINT uCmdShow // window style for new application
)
>31 // don't ask me, Windoze just uses >31 as OK in this call.
)
{
// ok...
//
bReturn = true;
}
else
{
assert(0);//ErrorBox("Unable to locate/run NOTEPAD on this machine!\n\n(let me know about this -Ste)");
}
return bReturn;
}
// creates as temp file, then spawns notepad with it...
//
static bool SendStringToNotepad(LPCSTR psWhatever, LPCSTR psLocalFileName)
{
bool bReturn = false;
LPCSTR psOutputFileName = va("c:\\%s",psLocalFileName);
FILE *handle = fopen(psOutputFileName,"wt");
if (handle)
{
fprintf(handle,"%s",psWhatever); // NOT fprintf(handle,psWhatever), which will try and process built-in %s stuff
fclose(handle);
bReturn = SendFileToNotepad(psOutputFileName);
}
else
{
assert(0);//ErrorBox(va("Unable to create file \"%s\" for notepad to use!",psOutputFileName));
}
return bReturn;
}
static qboolean DoFileFindReplace( LPCSTR psMenuFile, LPCSTR psFind, LPCSTR psReplace )
{
char *buffer;
OutputDebugString(va("Loading: \"%s\"\n",psMenuFile));
int iLen = FS_ReadFile( psMenuFile,(void **) &buffer);
if (iLen<1)
{
OutputDebugString("Failed!\n");
assert(0);
return qfalse;
}
// find/rep...
//
string str(buffer);
str += "\r\n"; // safety for *(char+1) stuff
FS_FreeFile( buffer ); // let go of the buffer
// originally this kept looping for replacements, but now it only does one (since the find/replace args are repeated
// and this is called again if there are >1 replacements of the same strings to be made...
//
// int iReplacedCount = 0;
char *pFound;
int iSearchPos = 0;
while ( (pFound = strstr(str.c_str()+iSearchPos,psFind)) != NULL)
{
// special check, the next char must be whitespace or carriage return etc, or we're not on a whole-word position...
//
int iFoundLoc = pFound - str.c_str();
char cAfterFind = pFound[strlen(psFind)];
if (cAfterFind > 32)
{
// ... then this string was part of a larger one, so ignore it...
//
iSearchPos = iFoundLoc+1;
continue;
}
str.replace(iFoundLoc, strlen(psFind), psReplace);
// iSearchPos = iFoundLoc+1;
// iReplacedCount++;
break;
}
// assert(iReplacedCount);
// if (iReplacedCount>1)
// {
// int z=1;
// }
FS_WriteFile( psMenuFile, str.c_str(), strlen(str.c_str()));
OutputDebugString("Ok\n");
return qtrue;
}
void UI_Dump_f(void)
{
string sFinalOutput;
vector <string> vStripEdFiles;
#define OUTPUT sFinalOutput+=
#define OUTPUTSTRIP vStripEdFiles[vStripEdFiles.size()-1] +=
OUTPUT("### UI_Dump(): Top\n");
for (ReferencesAndPackages_t::iterator it = ReferencesAndPackage.begin(); it!=ReferencesAndPackage.end(); ++it)
{
if ( (*it).second.size()>1)
{
OUTPUT(va("!!!DUP: Ref \"%s\" exists in:\n",(*it).first.c_str()));
StringSet_t &Set = (*it).second;
for (StringSet_t::iterator itS = Set.begin(); itS!=Set.end(); ++itS)
{
OUTPUT(va("%s\n",(*itS).c_str()));
}
}
}
OUTPUT("\nSP Package Reference list:\n");
for (StringSet_t::iterator itS = MenusUsed.begin(); itS!=MenusUsed.end(); ++itS)
{
OUTPUT(va("%s\n",(*itS).c_str()));
}
OUTPUT("\nBad Text list:\n");
for (References_t::iterator itBad=BadReferences.begin(); itBad!=BadReferences.end();++itBad)
{
Reference_t &BadReference = (*itBad);
OUTPUT(va("File: %30s \"%s\"\n",BadReference.sMenu.c_str(), BadReference.sString.c_str()));
}
OUTPUT("\nAdding bad references to final correction list...\n");
for (itBad=BadReferences.begin(); itBad!=BadReferences.end();++itBad)
{
Reference_t &BadReference = (*itBad);
EnterRef("", BadReference.sString.c_str(), BadReference.sMenu.c_str() );
}
OUTPUT("\nFinal correction list:\n");
// qboolean bIsMulti = !!strstr((*CorrectionData.begin()).sMenuFile.c_str(),"jk2mp");
// actually do the find/replace...
//
for (CorrectionData_t::iterator itCorrectionData = CorrectionData.begin(); itCorrectionData != CorrectionData.end(); ++itCorrectionData)
{
CorrectionDataItem_t &CorrectionDataItem = (*itCorrectionData);
if (CorrectionDataItem.sTextToFind.c_str()[0] && CorrectionDataItem.sTextToReplaceWith.c_str()[0])
{
OUTPUT( va("Load File: \"%s\", find \"%s\", replace with \"%s\"\n",
CorrectionDataItem.sMenuFile.c_str(),
CorrectionDataItem.sTextToFind.c_str(),
CorrectionDataItem.sTextToReplaceWith.c_str()
)
);
// if (strstr(CorrectionDataItem.sTextToReplaceWith.c_str(),"START_A_NEW_GAME"))
// {
// int z=1;
// }
assert( CorrectionDataItem.sTextToReplaceWith.c_str()[0] );
string sReplace( CorrectionDataItem.sTextToReplaceWith.c_str() );
sReplace.insert(1,"_");
sReplace.insert(1,CorrectionDataItem.sStripEdFileRef.c_str());
DoFileFindReplace( CorrectionDataItem.sMenuFile.c_str(),
CorrectionDataItem.sTextToFind.c_str(),
sReplace.c_str()//CorrectionDataItem.sTextToReplaceWith.c_str()
);
}
}
// scan in all SP files into one huge string, so I can pick out any foreign translations to add in when generating
// new StripEd files...
//
char **ppsFiles;
char *buffers[1000]; // max # SP files, well-OTT.
int iNumFiles;
int i;
string sStripFiles;
// scan for shader files
ppsFiles = FS_ListFiles( "strip", ".sp", &iNumFiles );
if ( !ppsFiles || !iNumFiles )
{
assert(0);
}
else
{
// load files...
//
for (i=0; i<iNumFiles; i++)
{
char sFilename[MAX_QPATH];
Com_sprintf( sFilename, sizeof( sFilename ), "strip/%s", ppsFiles[i] );
OutputDebugString( va("...loading '%s'\n", sFilename ) );
int iLen = FS_ReadFile( sFilename, (void **)&buffers[i] );
if ( iLen<1 ) {
assert(0);//Com_Error( ERR_DROP, "Couldn't load %s", filename );
}
}
// free up memory...
//
FS_FreeFileList( ppsFiles );
// build single large buffer and free up buffers as we go...
//
// ( free in reverse order, so the temp files are all dumped )
for ( i=iNumFiles-1; i>=0; i-- )
{
sStripFiles += buffers[i];
sStripFiles += "\r\n";
FS_FreeFile( buffers[i] );
}
}
int iIndex=0;
for (itCorrectionData = CorrectionData.begin(); itCorrectionData != CorrectionData.end(); ++itCorrectionData)
{
CorrectionDataItem_t &CorrectionDataItem = (*itCorrectionData);
if (CorrectionDataItem.sStripEdReference.c_str()[0] // skip over duplicate-resolving entries
// && CorrectionDataItem.sStripEdText.c_str()[0] //
)
{
string strAnyForeignStringsFound; // will be entire line plus CR
string strNotes; // will be just the bit within quotes
LPCSTR psFoundExisting;
int iInitialSearchPos = 0;
while (iInitialSearchPos < sStripFiles.size() &&
(strAnyForeignStringsFound.empty() || strNotes.empty())
)
{
if ( (psFoundExisting = strstr( sStripFiles.c_str()+iInitialSearchPos, va("\"%s\"",CorrectionDataItem.sStripEdText.c_str()))) != NULL )
{
// see if we can find any NOTES entry above this...
//
LPCSTR p;
if (strNotes.empty())
{
p = psFoundExisting;
while (p > sStripFiles.c_str() && *p!='{')
{
if (!strnicmp(p,"NOTES",5) && isspace(p[-1]) && isspace(p[5]))
{
p = strchr(p,'"');
if (!p++)
break;
while (*p != '"')
strNotes += *p++;
break;
}
p--;
}
}
// now search for any foreign versions we already have translated...
//
if (strAnyForeignStringsFound.empty())
{
p = psFoundExisting;
LPCSTR psNextBrace = strchr(p,'}');
assert(psNextBrace);
if (psNextBrace)
{
for (int i=2; i<10; i++)
{
LPCSTR psForeign = strstr(p,va("TEXT_LANGUAGE%d",i));
if (psForeign && psForeign < psNextBrace)
{
strAnyForeignStringsFound += " ";
while (*psForeign != '\n' && *psForeign != '\0')
{
strAnyForeignStringsFound += *psForeign++;
}
strAnyForeignStringsFound += "\n";
}
}
}
}
iInitialSearchPos = psFoundExisting - sStripFiles.c_str();
iInitialSearchPos++; // one past, so we don't re-find ourselves
}
else
{
break;
}
}
if (!strNotes.empty())
{
strNotes = va(" NOTES \"%s\"\n",strNotes.c_str());
}
// now do output...
//
if (!(iIndex%256))
{
string s;
vStripEdFiles.push_back(s);
OUTPUTSTRIP( va( "VERSION 1\n"
"CONFIG W:\\bin\\striped.cfg\n"
"ID %d\n"
"REFERENCE MENUS%d\n"
"DESCRIPTION \"menu text\"\n"
"COUNT 256\n", // count will need correcting for last one
250 + (iIndex/256), // 250 range seems to be unused
iIndex/256
)
);
// OUTPUTSTRIP( va("REFERENCE %s\n", va("%sMENUS%d",bIsMulti?"MP":"SP",iIndex/256)) );
// OUTPUTSTRIP( va("REFERENCE %s\n", va( "MENUS%d",iIndex/256)) );
}
OUTPUTSTRIP( va( "INDEX %d\n"
"{\n"
" REFERENCE %s\n"
"%s"
" TEXT_LANGUAGE1 \"%s\"\n"
"%s"
"}\n",
iIndex%256,
CorrectionDataItem.sStripEdReference.c_str(),
(strNotes.empty()?"":strNotes.c_str()),
CorrectionDataItem.sStripEdText.c_str(),
strAnyForeignStringsFound.c_str()
)
);
iIndex++;
}
}
OUTPUT("### UI_Dump(): Bottom\n");
SendStringToNotepad(sFinalOutput.c_str(), "temp.txt");
// output the SP files...
//
for (i=0; i<vStripEdFiles.size(); i++)
{
// need to make local string, because ingame va() is crippled to 2 depths...
//
char sName[MAX_PATH];
sprintf(sName,"Source\\StarWars\\code\\base\\strip\\MENUS%d.sp",i);
SendStringToNotepad(vStripEdFiles[i].c_str(), sName);
}
}
void UI_Debug_EnterReference(LPCSTR ps4LetterType, LPCSTR psItemString)
{
if ((int)psItemString < 0) //string package ID
{
LPCSTR psPackageName, psPackageReference, psText;
psItemString = SP_GetReferenceText(-(int)psItemString, psPackageName, psPackageReference, psText);
if (psItemString && psItemString[0]) {
// OutputDebugString(va(" TEXT: \"%s\" Package: %s\n",psItemString,psPackageReference));
EnterGoodRef(ps4LetterType,psItemString,psPackageReference,psText);
}
else {
assert(0);
}
}
else
{
if (psItemString && psItemString[0])
{
if ( !stricmp(psItemString,"english") ||
!stricmp(psItemString,"francais") ||
!stricmp(psItemString,"deutsch")
)
{
// then don't localise it!
}
else
{
//OutputDebugString(va("BAD TEXT: \"%s\" REF: \"%s\"\n",psItemString, EnterBadText(psItemString)));
EnterBadRef(ps4LetterType,psItemString);
}
}
else {
assert(0);
}
}
}
#endif
#endif

259
code/ui/ui_local.h Normal file
View File

@@ -0,0 +1,259 @@
#ifndef __UI_LOCAL_H__
#define __UI_LOCAL_H__
#include <string.h>
#include <limits.h>
#include "../game/q_shared.h"
#include "../renderer/tr_types.h"
#include "../qcommon/qcommon.h"
#include "ui_public.h"
#include "ui_shared.h"
#define MAX_PLAYERMODELS 32
#define MAX_DEFERRED_SCRIPT 1024
//
// ui_qmenu.c
//
#define MAX_EDIT_LINE 256
typedef struct {
int cursor;
int scroll;
int widthInChars;
char buffer[MAX_EDIT_LINE];
int maxchars;
int style;
int textEnum; // Label
int textcolor; // Normal color
int textcolor2; // Highlight color
} uifield_t;
extern void Menu_Cache( void );
//
// ui_field.c
//
extern void Field_Clear( uifield_t *edit );
extern void Field_CharEvent( uifield_t *edit, int ch );
extern void Field_Draw( uifield_t *edit, int x, int y, int width, int size,int color,int color2, qboolean showCursor );
//
// ui_menu.c
//
extern void UI_MainMenu(void);
extern void UI_InGameMenu(const char*holoFlag);
extern void AssetCache(void);
extern void UI_DataPadMenu(void);
//
// ui_connect.c
//
extern void UI_DrawConnect( const char *servername, const char * updateInfoString );
extern void UI_UpdateConnectionString( char *string );
extern void UI_UpdateConnectionMessageString( char *string );
//
// ui_atoms.c
//
#define UI_FADEOUT 0
#define UI_FADEIN 1
typedef struct {
int frametime;
int realtime;
int cursorx;
int cursory;
glconfig_t glconfig;
qboolean debugMode;
qhandle_t whiteShader;
qhandle_t menuBackShader;
qhandle_t cursor;
float scalex;
float scaley;
//float bias;
qboolean firstdraw;
} uiStatic_t;
extern void UI_FillRect( float x, float y, float width, float height, const float *color );
extern void UI_DrawString( int x, int y, const char* str, int style, vec4_t color );
extern void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader );
extern void UI_UpdateScreen( void );
extern int UI_RegisterFont(const char *fontName);
extern void UI_SetColor( const float *rgba );
extern char *UI_Cvar_VariableString( const char *var_name );
extern uiStatic_t uis;
extern uiimport_t ui;
#define MAX_MOVIES 256
#define MAX_MODS 64
typedef struct {
const char *modName;
const char *modDescr;
} modInfo_t;
typedef struct {
char Name[64];
int SkinHeadCount;
// qhandle_t SkinHeadIcons[MAX_PLAYERMODELS];
char SkinHeadNames[MAX_PLAYERMODELS][16];
int SkinTorsoCount;
// qhandle_t SkinTorsoIcons[MAX_PLAYERMODELS];
char SkinTorsoNames[MAX_PLAYERMODELS][16];
int SkinLegCount;
// qhandle_t SkinLegIcons[MAX_PLAYERMODELS];
char SkinLegNames[MAX_PLAYERMODELS][16];
char ColorShader[MAX_PLAYERMODELS][64];
int ColorCount;
char ColorActionText[MAX_PLAYERMODELS][128];
} playerSpeciesInfo_t;
typedef struct {
displayContextDef_t uiDC;
int effectsColor;
int currentCrosshair;
modInfo_t modList[MAX_MODS];
int modIndex;
int modCount;
int playerSpeciesCount;
playerSpeciesInfo_t playerSpecies[MAX_PLAYERMODELS];
int playerSpeciesIndex;
char deferredScript [ MAX_DEFERRED_SCRIPT ];
itemDef_t* deferredScriptItem;
itemDef_t* runScriptItem;
qboolean inGameLoad;
// Used by Force Power allocation screen
short forcePowerUpdated; // Enum of which power had the point allocated
// Used by Weapon allocation screen
short selectedWeapon1; // 1st weapon chosen
// char selectedWeapon1ItemName[64]; // Item name of weapon chosen
// int selectedWeapon1AmmoIndex; // Holds index to ammo
short selectedWeapon2; // 2nd weapon chosen
// char selectedWeapon2ItemName[64]; // Item name of weapon chosen
// int selectedWeapon2AmmoIndex; // Holds index to ammo
short selectedThrowWeapon; // throwable weapon chosen
// char selectedThrowWeaponItemName[64]; // Item name of weapon chosen
// int selectedThrowWeaponAmmoIndex; // Holds index to ammo
itemDef_t *weapon1ItemButton;
qhandle_t litWeapon1Icon;
qhandle_t unlitWeapon1Icon;
itemDef_t *weapon2ItemButton;
qhandle_t litWeapon2Icon;
qhandle_t unlitWeapon2Icon;
itemDef_t *weaponThrowButton;
qhandle_t litThrowableIcon;
qhandle_t unlitThrowableIcon;
short movesTitleIndex;
char *movesBaseAnim;
int moveAnimTime;
// int languageCount;
int languageCountIndex;
} uiInfo_t;
extern uiInfo_t uiInfo;
//
// ui_main.c
//
void _UI_Init( qboolean inGameLoad );
void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color );
void _UI_MouseEvent( int dx, int dy );
void _UI_KeyEvent( int key, qboolean down );
void UI_Report(void);
extern char GoToMenu[];
//
// ui_syscalls.c
//
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */);
int trap_CIN_StopCinematic(int handle);
void trap_Cvar_Set( const char *var_name, const char *value );
float trap_Cvar_VariableValue( const char *var_name );
void trap_GetGlconfig( glconfig_t *glconfig );
void trap_Key_ClearStates( void );
int trap_Key_GetCatcher( void );
qboolean trap_Key_GetOverstrikeMode( void );
void trap_Key_SetBinding( int keynum, const char *binding );
void trap_Key_SetCatcher( int catcher );
void trap_Key_SetOverstrikeMode( qboolean state );
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
void trap_R_SetColor( const float *rgba );
void trap_R_ClearScene( void );
void trap_R_AddRefEntityToScene( const refEntity_t *re );
void trap_R_RenderScene( const refdef_t *fd );
void trap_S_StopSounds( void );
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed );
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );
#ifdef _IMMERSION
ffHandle_t trap_FF_Register( const char *name, int channel = FF_CHANNEL_MENU );
void trap_FF_Start( ffHandle_t ff );
#endif // _IMMERSION
#ifndef _XBOX
int PASSFLOAT( float x );
#endif
void _UI_Refresh( int realtime );
//from xboxcommon.h (from MP)
//
// Xbox Error Popup Constants
//
// The error popup system needs a context when it returns a value to know
// what to do. One of these is saved off when we create the popup, and then it's
// queried when we get a response so we know what we're doing.
enum xbErrorPopupType
{
XB_POPUP_NONE,
XB_POPUP_DELETE_CONFIRM,
XB_POPUP_DISKFULL, // Only at startup
XB_POPUP_DISKFULL_DURING_SAVE, // When trying to save a new game
XB_POPUP_SAVE_COMPLETE,
XB_POPUP_OVERWRITE_CONFIRM,
XB_POPUP_LOAD_FAILED,
XB_POPUP_LOAD_CHECKPOINT_FAILED,
XB_POPUP_QUIT_CONFIRM,
XB_POPUP_SAVING,
XB_POPUP_LOAD_CONFIRM,
XB_POPUP_TOO_MANY_SAVES,
XB_POPUP_LOAD_CONFIRM_CHECKPOINT,
XB_POPUP_CONFIRM_INVITE,
XB_POPUP_CORRUPT_SETTINGS,
XB_POPUP_DISKFULL_BOTH,
XB_POPUP_YOU_ARE_DEAD,
XB_POPUP_TESTING_SAVE,
XB_POPUP_CORRUPT_SCREENSHOT,
XB_POPUP_CONFIRM_NEW_1,
XB_POPUP_CONFIRM_NEW_2,
XB_POPUP_CONFIRM_NEW_3,
};
void UI_xboxErrorPopup(xbErrorPopupType popup);
void UI_xboxPopupResponse(void);
void UI_CheckForInvite( void );
#endif

8580
code/ui/ui_main.cpp Normal file

File diff suppressed because it is too large Load Diff

74
code/ui/ui_playerinfo.h Normal file
View File

@@ -0,0 +1,74 @@
#ifndef __UI_PLAYERINFO_H__
#define __UI_PLAYERINFO_H__
#include "../game/bg_public.h"
#include "../game/anims.h"
//FIXME ripped from cg_local.h
typedef struct {
int oldFrame;
int oldFrameTime; // time when ->oldFrame was exactly on
int frame;
int frameTime; // time when ->frame will be exactly on
float backlerp;
float yawAngle;
qboolean yawing;
float pitchAngle;
qboolean pitching;
int animationNumber; //
animation_t *animation;
int animationTime; // time when the first frame of the animation will be exact
} lerpFrame_t;
typedef struct {
// model info
qhandle_t legsModel;
qhandle_t legsSkin;
lerpFrame_t legs;
qhandle_t torsoModel;
qhandle_t torsoSkin;
lerpFrame_t torso;
qhandle_t headModel;
qhandle_t headSkin;
animation_t animations[MAX_ANIMATIONS];
qhandle_t weaponModel;
vec3_t flashDlightColor;
int muzzleFlashTime;
// currently in use drawing parms
vec3_t viewAngles;
vec3_t moveAngles;
weapon_t currentWeapon;
int legsAnim;
int torsoAnim;
// animation vars
weapon_t weapon;
weapon_t lastWeapon;
weapon_t pendingWeapon;
int weaponTimer;
int pendingLegsAnim;
int torsoAnimationTimer;
int pendingTorsoAnim;
int legsAnimationTimer;
qboolean chat;
qboolean looking;
} playerInfo_t;
void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time );
void UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model, const char* headmodel );
void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNum, qboolean chat );
qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName );
#endif //__UI_PLAYERINFO_H__

250
code/ui/ui_public.h Normal file
View File

@@ -0,0 +1,250 @@
#ifndef __UI_PUBLIC_H__
#define __UI_PUBLIC_H__
#include "../client/keycodes.h"
#define UI_API_VERSION 3
typedef struct {
//============== general Quake services ==================
// print message on the local console
void (*Printf)( const char *fmt, ... );
// abort the game
void (*Error)( int level, const char *fmt, ... );
// console variable interaction
void (*Cvar_Set)( const char *name, const char *value );
float (*Cvar_VariableValue)( const char *var_name );
void (*Cvar_VariableStringBuffer)( const char *var_name, char *buffer, int bufsize );
void (*Cvar_SetValue)( const char *var_name, float value );
void (*Cvar_Reset)( const char *name );
void (*Cvar_Create)( const char *var_name, const char *var_value, int flags );
void (*Cvar_InfoStringBuffer)( int bit, char *buffer, int bufsize );
// console command interaction
int (*Argc)( void );
void (*Argv)( int n, char *buffer, int bufferLength );
void (*Cmd_ExecuteText)( int exec_when, const char *text );
void (*Cmd_TokenizeString)( const char *text );
// filesystem access
int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode );
int (*FS_Read)( void *buffer, int len, fileHandle_t f );
int (*FS_Write)( const void *buffer, int len, fileHandle_t f );
void (*FS_FCloseFile)( fileHandle_t f );
int (*FS_GetFileList)( const char *path, const char *extension, char *listbuf, int bufsize );
int (*FS_ReadFile)( const char *name, void **buf );
void (*FS_FreeFile)( void *buf );
// =========== renderer function calls ================
qhandle_t (*R_RegisterModel)( const char *name ); // returns rgb axis if not found
qhandle_t (*R_RegisterSkin)( const char *name ); // returns all white if not found
qhandle_t (*R_RegisterShader)( const char *name ); // returns white if not found
qhandle_t (*R_RegisterShaderNoMip)( const char *name ); // returns white if not found
qhandle_t (*R_RegisterFont)( const char *name ); // returns 0 for bad font
#ifdef _XBOX // No default arguments on function pointers
int R_Font_StrLenPixels(const char *text, const int setIndex, const float scale = 1.0f)
{
return RE_Font_StrLenPixels(text, setIndex, scale);
}
int R_Font_HeightPixels(const int setIndex, const float scale = 1.0f)
{
return RE_Font_HeightPixels(setIndex, scale);
}
void R_Font_DrawString(int ox, int oy, const char *text, const float *rgba, const int setIndex, int iMaxPixelWidth, const float scale = 1.0f)
{
RE_Font_DrawString(ox, oy, text, rgba, setIndex, iMaxPixelWidth, scale);
}
#else
int (*R_Font_StrLenPixels)(const char *text, const int setIndex, const float scale = 1.0f);
int (*R_Font_HeightPixels)(const int setIndex, const float scale = 1.0f);
void (*R_Font_DrawString)(int ox, int oy, const char *text, const float *rgba, const int setIndex, int iMaxPixelWidth, const float scale = 1.0f);
#endif
int (*R_Font_StrLenChars)(const char *text);
qboolean (*Language_IsAsian) (void);
qboolean (*Language_UsesSpaces) (void);
unsigned int (*AnyLanguage_ReadCharFromString)( const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation /* = NULL */);
// a scene is built up by calls to R_ClearScene and the various R_Add functions.
// Nothing is drawn until R_RenderScene is called.
void (*R_ClearScene)( void );
void (*R_AddRefEntityToScene)( const refEntity_t *re );
void (*R_AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts );
void (*R_AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
void (*R_RenderScene)( const refdef_t *fd );
void (*R_ModelBounds)( qhandle_t handle, vec3_t mins, vec3_t maxs );
void (*R_SetColor)( const float *rgba ); // NULL = 1,1,1,1
void (*R_DrawStretchPic) ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white
void (*R_ScissorPic) ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white
// force a screen update, only used during gamestate load
void (*UpdateScreen)( void );
// stuff for savegame screenshots...
#ifdef _XBOX
void (*PrecacheScreenshot)( void );
#endif
//========= model collision ===============
// R_LerpTag is only valid for md3 models
void (*R_LerpTag)( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
float frac, const char *tagName );
// =========== sound function calls ===============
void (*S_StartLocalSound)( sfxHandle_t sfxHandle, int channelNum );
sfxHandle_t (*S_RegisterSound)( const char* name);
void (*S_StartLocalLoopingSound)( sfxHandle_t sfxHandle);
void (*S_StopSounds)( void );
// =========== getting save game picture ===============
void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);
//qboolean(*SG_GetSaveImage)( const char *psPathlessBaseName, void *pvAddress );
int (*SG_GetSaveGameComment)(const char *psPathlessBaseName, char *sComment, char *sMapName);
qboolean (*SG_GameAllowedToSaveHere)(qboolean inCamera);
void (*SG_StoreSaveGameComment)(const char *sComment);
//byte *(*SCR_GetScreenshot)(qboolean *);
// =========== data shared with the client system =============
// keyboard and key binding interaction
void (*Key_KeynumToStringBuf)( int keynum, char *buf, int buflen );
void (*Key_GetBindingBuf)( int keynum, char *buf, int buflen );
void (*Key_SetBinding)( int keynum, const char *binding );
qboolean (*Key_IsDown)( int keynum );
qboolean (*Key_GetOverstrikeMode)( void );
void (*Key_SetOverstrikeMode)( qboolean state );
void (*Key_ClearStates)( void );
int (*Key_GetCatcher)( void );
void (*Key_SetCatcher)( int catcher );
void (*GetClipboardData)( char *buf, int bufsize );
void (*GetGlconfig)( glconfig_t *config );
connstate_t (*GetClientState)( void );
void (*GetConfigString)( int index, char* buff, int buffsize );
int (*Milliseconds)( void );
void (*Draw_DataPad)(int HUDType);
} uiimport_t;
typedef enum {
DP_HUD=0,
DP_OBJECTIVES,
DP_WEAPONS,
DP_INVENTORY,
DP_FORCEPOWERS
}dpTypes_t;
typedef enum {
UI_ERROR,
UI_PRINT,
UI_MILLISECONDS,
UI_CVAR_SET,
UI_CVAR_VARIABLEVALUE,
UI_CVAR_VARIABLESTRINGBUFFER,
UI_CVAR_SETVALUE,
UI_CVAR_RESET,
UI_CVAR_CREATE,
UI_CVAR_INFOSTRINGBUFFER,
UI_ARGC, // 10
UI_ARGV,
UI_CMD_EXECUTETEXT,
UI_FS_FOPENFILE,
UI_FS_READ,
UI_FS_WRITE,
UI_FS_FCLOSEFILE,
UI_FS_GETFILELIST,
UI_R_REGISTERMODEL,
UI_R_REGISTERSKIN,
UI_R_REGISTERSHADERNOMIP, // 20
UI_R_CLEARSCENE,
UI_R_ADDREFENTITYTOSCENE,
UI_R_ADDPOLYTOSCENE,
UI_R_ADDLIGHTTOSCENE,
UI_R_RENDERSCENE,
UI_R_SETCOLOR,
UI_R_DRAWSTRETCHPIC,
UI_UPDATESCREEN,
UI_CM_LERPTAG,
UI_CM_LOADMODEL, // 30
UI_S_REGISTERSOUND,
UI_S_STARTLOCALSOUND,
UI_KEY_KEYNUMTOSTRINGBUF,
UI_KEY_GETBINDINGBUF,
UI_KEY_SETBINDING,
UI_KEY_ISDOWN,
UI_KEY_GETOVERSTRIKEMODE,
UI_KEY_SETOVERSTRIKEMODE,
UI_KEY_CLEARSTATES,
UI_KEY_GETCATCHER, // 40
UI_KEY_SETCATCHER,
UI_GETCLIPBOARDDATA,
UI_GETGLCONFIG,
UI_GETCLIENTSTATE,
UI_GETCONFIGSTRING,
UI_LAN_GETPINGQUEUECOUNT,
UI_LAN_CLEARPING,
UI_LAN_GETPING,
UI_LAN_GETPINGINFO,
UI_CVAR_REGISTER, // 50
UI_CVAR_UPDATE,
UI_MEMORY_REMAINING,
UI_GET_CDKEY,
UI_SET_CDKEY,
UI_R_REGISTERFONT,
UI_R_MODELBOUNDS,
UI_PC_ADD_GLOBAL_DEFINE,
UI_PC_LOAD_SOURCE,
UI_PC_FREE_SOURCE,
UI_PC_READ_TOKEN, // 60
UI_PC_SOURCE_FILE_AND_LINE,
UI_S_STOPBACKGROUNDTRACK,
UI_S_STARTBACKGROUNDTRACK,
UI_REAL_TIME,
UI_LAN_GETSERVERCOUNT,
UI_LAN_GETSERVERADDRESSSTRING,
UI_LAN_GETSERVERINFO,
UI_LAN_MARKSERVERVISIBLE,
UI_LAN_UPDATEVISIBLEPINGS,
UI_LAN_RESETPINGS, // 70
UI_LAN_LOADCACHEDSERVERS,
UI_LAN_SAVECACHEDSERVERS,
UI_LAN_ADDSERVER,
UI_LAN_REMOVESERVER,
UI_CIN_PLAYCINEMATIC,
UI_CIN_STOPCINEMATIC,
UI_CIN_RUNCINEMATIC,
UI_CIN_DRAWCINEMATIC,
UI_CIN_SETEXTENTS,
UI_R_REMAP_SHADER, // 80
UI_VERIFY_CDKEY,
UI_LAN_SERVERSTATUS,
UI_LAN_GETSERVERPING,
UI_LAN_SERVERISVISIBLE,
UI_LAN_COMPARESERVERS,
UI_MEMSET = 100,
UI_MEMCPY,
UI_STRNCPY,
UI_SIN,
UI_COS,
UI_ATAN2,
UI_SQRT,
UI_FLOOR,
UI_CEIL
} uiImport_t;
#endif

866
code/ui/ui_saber.cpp Normal file
View File

@@ -0,0 +1,866 @@
//
/*
=======================================================================
USER INTERFACE SABER LOADING & DISPLAY CODE
=======================================================================
*/
// leave this at the top of all UI_xxxx files for PCH reasons...
//
#include "../server/exe_headers.h"
#include "ui_local.h"
#include "ui_shared.h"
#include "../ghoul2/G2.h"
#define MAX_SABER_DATA_SIZE 0x8000
// On Xbox, static linking lets us steal the buffer from wp_saberLoad
// Just make sure that the saber data size is the same
#ifdef _XBOX
extern char SaberParms[MAX_SABER_DATA_SIZE];
#else
char SaberParms[MAX_SABER_DATA_SIZE];
#endif
qboolean ui_saber_parms_parsed = qfalse;
static qhandle_t redSaberGlowShader;
static qhandle_t redSaberCoreShader;
static qhandle_t orangeSaberGlowShader;
static qhandle_t orangeSaberCoreShader;
static qhandle_t yellowSaberGlowShader;
static qhandle_t yellowSaberCoreShader;
static qhandle_t greenSaberGlowShader;
static qhandle_t greenSaberCoreShader;
static qhandle_t blueSaberGlowShader;
static qhandle_t blueSaberCoreShader;
static qhandle_t purpleSaberGlowShader;
static qhandle_t purpleSaberCoreShader;
void UI_CacheSaberGlowGraphics( void )
{//FIXME: these get fucked by vid_restarts
redSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/red_glow" );
redSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/red_line" );
orangeSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/orange_glow" );
orangeSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/orange_line" );
yellowSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/yellow_glow" );
yellowSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/yellow_line" );
greenSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/green_glow" );
greenSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/green_line" );
blueSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/blue_glow" );
blueSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/blue_line" );
purpleSaberGlowShader = re.RegisterShader( "gfx/effects/sabers/purple_glow" );
purpleSaberCoreShader = re.RegisterShader( "gfx/effects/sabers/purple_line" );
}
qboolean UI_ParseLiteral( const char **data, const char *string )
{
const char *token;
token = COM_ParseExt( data, qtrue );
if ( token[0] == 0 )
{
ui.Printf( "unexpected EOF\n" );
return qtrue;
}
if ( Q_stricmp( token, string ) )
{
ui.Printf( "required string '%s' missing\n", string );
return qtrue;
}
return qfalse;
}
qboolean UI_SaberParseParm( const char *saberName, const char *parmname, char *saberData )
{
const char *token;
const char *value;
const char *p;
if ( !saberName || !saberName[0] )
{
return qfalse;
}
//try to parse it out
p = SaberParms;
COM_BeginParseSession();
// look for the right saber
while ( p )
{
token = COM_ParseExt( &p, qtrue );
if ( token[0] == 0 )
{
return qfalse;
}
if ( !Q_stricmp( token, saberName ) )
{
break;
}
SkipBracedSection( &p );
}
if ( !p )
{
return qfalse;
}
if ( UI_ParseLiteral( &p, "{" ) )
{
return qfalse;
}
// parse the saber info block
while ( 1 )
{
token = COM_ParseExt( &p, qtrue );
if ( !token[0] )
{
ui.Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'\n", saberName );
return qfalse;
}
if ( !Q_stricmp( token, "}" ) )
{
break;
}
if ( !Q_stricmp( token, parmname ) )
{
if ( COM_ParseString( &p, &value ) )
{
continue;
}
strcpy( saberData, value );
return qtrue;
}
SkipRestOfLine( &p );
continue;
}
return qfalse;
}
qboolean UI_SaberProperNameForSaber( const char *saberName, char *saberProperName )
{
return UI_SaberParseParm( saberName, "name", saberProperName );
}
qboolean UI_SaberModelForSaber( const char *saberName, char *saberModel )
{
return UI_SaberParseParm( saberName, "saberModel", saberModel );
}
qboolean UI_SaberSkinForSaber( const char *saberName, char *saberSkin )
{
return UI_SaberParseParm( saberName, "customSkin", saberSkin );
}
qboolean UI_SaberTypeForSaber( const char *saberName, char *saberType )
{
return UI_SaberParseParm( saberName, "saberType", saberType );
}
int UI_SaberNumBladesForSaber( const char *saberName )
{
char numBladesString[8]={0};
UI_SaberParseParm( saberName, "numBlades", numBladesString );
int numBlades = atoi( numBladesString );
if ( numBlades < 1 )
{
numBlades = 1;
}
else if ( numBlades > 8 )
{
numBlades = 8;
}
return numBlades;
}
float UI_SaberBladeLengthForSaber( const char *saberName, int bladeNum )
{
char lengthString[8]={0};
float length = 40.0f;
UI_SaberParseParm( saberName, "saberLength", lengthString );
if ( lengthString[0] )
{
length = atof( lengthString );
if ( length < 0.0f )
{
length = 0.0f;
}
}
UI_SaberParseParm( saberName, va("saberLength%d", bladeNum+1), lengthString );
if ( lengthString[0] )
{
length = atof( lengthString );
if ( length < 0.0f )
{
length = 0.0f;
}
}
return length;
}
float UI_SaberBladeRadiusForSaber( const char *saberName, int bladeNum )
{
char radiusString[8]={0};
float radius = 3.0f;
UI_SaberParseParm( saberName, "saberRadius", radiusString );
if ( radiusString[0] )
{
radius = atof( radiusString );
if ( radius < 0.0f )
{
radius = 0.0f;
}
}
UI_SaberParseParm( saberName, va("saberRadius%d", bladeNum+1), radiusString );
if ( radiusString[0] )
{
radius = atof( radiusString );
if ( radius < 0.0f )
{
radius = 0.0f;
}
}
return radius;
}
void UI_SaberLoadParms( void )
{
int len, totallen, saberExtFNLen, fileCnt, i;
char *buffer, *holdChar, *marker;
char saberExtensionListBuf[2048]; // The list of file names read in
//ui.Printf( "UI Parsing *.sab saber definitions\n" );
ui_saber_parms_parsed = qtrue;
UI_CacheSaberGlowGraphics();
//set where to store the first one
totallen = 0;
marker = SaberParms;
marker[0] = '\0';
//now load in the sabers
fileCnt = ui.FS_GetFileList("ext_data/sabers", ".sab", saberExtensionListBuf, sizeof(saberExtensionListBuf) );
holdChar = saberExtensionListBuf;
for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 )
{
saberExtFNLen = strlen( holdChar );
len = ui.FS_ReadFile( va( "ext_data/sabers/%s", holdChar), (void **) &buffer );
if ( len == -1 )
{
ui.Printf( "UI_SaberLoadParms: error reading %s\n", holdChar );
}
else
{
if ( totallen && *(marker-1) == '}' )
{//don't let it end on a } because that should be a stand-alone token
strcat( marker, " " );
totallen++;
marker++;
}
len = COM_Compress( buffer );
if ( totallen + len >= MAX_SABER_DATA_SIZE ) {
Com_Error( ERR_FATAL, "UI_SaberLoadParms: ran out of space before reading %s\n(you must make the .npc files smaller)", holdChar );
}
strcat( marker, buffer );
ui.FS_FreeFile( buffer );
totallen += len;
marker += len;
}
}
}
void UI_DoSaber( vec3_t origin, vec3_t dir, float length, float lengthMax, float radius, saber_colors_t color )
{
vec3_t mid, rgb={1,1,1};
qhandle_t blade = 0, glow = 0;
refEntity_t saber;
float radiusmult;
if ( length < 0.5f )
{
// if the thing is so short, just forget even adding me.
return;
}
// Find the midpoint of the saber for lighting purposes
VectorMA( origin, length * 0.5f, dir, mid );
switch( color )
{
case SABER_RED:
glow = redSaberGlowShader;
blade = redSaberCoreShader;
VectorSet( rgb, 1.0f, 0.2f, 0.2f );
break;
case SABER_ORANGE:
glow = orangeSaberGlowShader;
blade = orangeSaberCoreShader;
VectorSet( rgb, 1.0f, 0.5f, 0.1f );
break;
case SABER_YELLOW:
glow = yellowSaberGlowShader;
blade = yellowSaberCoreShader;
VectorSet( rgb, 1.0f, 1.0f, 0.2f );
break;
case SABER_GREEN:
glow = greenSaberGlowShader;
blade = greenSaberCoreShader;
VectorSet( rgb, 0.2f, 1.0f, 0.2f );
break;
case SABER_BLUE:
glow = blueSaberGlowShader;
blade = blueSaberCoreShader;
VectorSet( rgb, 0.2f, 0.4f, 1.0f );
break;
case SABER_PURPLE:
glow = purpleSaberGlowShader;
blade = purpleSaberCoreShader;
VectorSet( rgb, 0.9f, 0.2f, 1.0f );
break;
}
// always add a light because sabers cast a nice glow before they slice you in half!! or something...
/*
if ( doLight )
{//FIXME: RGB combine all the colors of the sabers you're using into one averaged color!
cgi_R_AddLightToScene( mid, (length*2.0f) + (random()*8.0f), rgb[0], rgb[1], rgb[2] );
}
*/
memset( &saber, 0, sizeof( refEntity_t ));
// Saber glow is it's own ref type because it uses a ton of sprites, otherwise it would eat up too many
// refEnts to do each glow blob individually
saber.saberLength = length;
// Jeff, I did this because I foolishly wished to have a bright halo as the saber is unleashed.
// It's not quite what I'd hoped tho. If you have any ideas, go for it! --Pat
if (length < lengthMax )
{
radiusmult = 1.0 + (2.0 / length); // Note this creates a curve, and length cannot be < 0.5.
}
else
{
radiusmult = 1.0;
}
float radiusRange = radius * 0.075f;
float radiusStart = radius-radiusRange;
saber.radius = (radiusStart + crandom() * radiusRange)*radiusmult;
//saber.radius = (2.8f + crandom() * 0.2f)*radiusmult;
VectorCopy( origin, saber.origin );
VectorCopy( dir, saber.axis[0] );
saber.reType = RT_SABER_GLOW;
saber.customShader = glow;
saber.shaderRGBA[0] = saber.shaderRGBA[1] = saber.shaderRGBA[2] = saber.shaderRGBA[3] = 0xff;
//saber.renderfx = rfx;
DC->addRefEntityToScene( &saber );
// Do the hot core
VectorMA( origin, length, dir, saber.origin );
VectorMA( origin, -1, dir, saber.oldorigin );
saber.customShader = blade;
saber.reType = RT_LINE;
radiusStart = radius/3.0f;
saber.radius = (radiusStart + crandom() * radiusRange)*radiusmult;
// saber.radius = (1.0 + crandom() * 0.2f)*radiusmult;
DC->addRefEntityToScene( &saber );
}
saber_colors_t TranslateSaberColor( const char *name )
{
if ( !Q_stricmp( name, "red" ) )
{
return SABER_RED;
}
if ( !Q_stricmp( name, "orange" ) )
{
return SABER_ORANGE;
}
if ( !Q_stricmp( name, "yellow" ) )
{
return SABER_YELLOW;
}
if ( !Q_stricmp( name, "green" ) )
{
return SABER_GREEN;
}
if ( !Q_stricmp( name, "blue" ) )
{
return SABER_BLUE;
}
if ( !Q_stricmp( name, "purple" ) )
{
return SABER_PURPLE;
}
if ( !Q_stricmp( name, "random" ) )
{
return ((saber_colors_t)(Q_irand( SABER_ORANGE, SABER_PURPLE )));
}
return SABER_BLUE;
}
saberType_t TranslateSaberType( const char *name )
{
if ( !Q_stricmp( name, "SABER_SINGLE" ) )
{
return SABER_SINGLE;
}
if ( !Q_stricmp( name, "SABER_STAFF" ) )
{
return SABER_STAFF;
}
if ( !Q_stricmp( name, "SABER_BROAD" ) )
{
return SABER_BROAD;
}
if ( !Q_stricmp( name, "SABER_PRONG" ) )
{
return SABER_PRONG;
}
if ( !Q_stricmp( name, "SABER_DAGGER" ) )
{
return SABER_DAGGER;
}
if ( !Q_stricmp( name, "SABER_ARC" ) )
{
return SABER_ARC;
}
if ( !Q_stricmp( name, "SABER_SAI" ) )
{
return SABER_SAI;
}
if ( !Q_stricmp( name, "SABER_CLAW" ) )
{
return SABER_CLAW;
}
if ( !Q_stricmp( name, "SABER_LANCE" ) )
{
return SABER_LANCE;
}
if ( !Q_stricmp( name, "SABER_STAR" ) )
{
return SABER_STAR;
}
if ( !Q_stricmp( name, "SABER_TRIDENT" ) )
{
return SABER_TRIDENT;
}
if ( !Q_stricmp( name, "SABER_SITH_SWORD" ) )
{
return SABER_SITH_SWORD;
}
return SABER_SINGLE;
}
void UI_SaberDrawBlade( itemDef_t *item, char *saberName, int saberModel, saberType_t saberType, vec3_t origin, float curYaw, int bladeNum )
{
char bladeColorString[MAX_QPATH];
vec3_t angles={0};
// if ( item->flags&(ITF_ISANYSABER) && item->flags&(ITF_ISCHARACTER) )
{ //it's bolted to a dude!
angles[YAW] = curYaw;
}
// else
// {
// angles[PITCH] = curYaw;
// angles[ROLL] = 90;
// }
if ( saberModel >= item->ghoul2.size() )
{//uhh... invalid index!
return;
}
if ( (item->flags&ITF_ISSABER) && saberModel < 2 )
{
DC->getCVarString( "ui_saber_color", bladeColorString, sizeof(bladeColorString) );
}
else//if ( item->flags&ITF_ISSABER2 ) - presumed
{
DC->getCVarString( "ui_saber2_color", bladeColorString, sizeof(bladeColorString) );
}
saber_colors_t bladeColor = TranslateSaberColor( bladeColorString );
float bladeLength = UI_SaberBladeLengthForSaber( saberName, bladeNum );
float bladeRadius = UI_SaberBladeRadiusForSaber( saberName, bladeNum );
vec3_t bladeOrigin={0};
vec3_t axis[3]={0};
mdxaBone_t boltMatrix;
qboolean tagHack = qfalse;
char *tagName = va( "*blade%d", bladeNum+1 );
int bolt = DC->g2_AddBolt( &item->ghoul2[saberModel], tagName );
if ( bolt == -1 )
{
tagHack = qtrue;
//hmm, just fall back to the most basic tag (this will also make it work with pre-JKA saber models
bolt = DC->g2_AddBolt( &item->ghoul2[saberModel], "*flash" );
if ( bolt == -1 )
{//no tag_flash either?!!
bolt = 0;
}
}
DC->g2_GetBoltMatrix( item->ghoul2, saberModel, bolt, &boltMatrix, angles, origin, uiInfo.uiDC.realTime, NULL, vec3_origin );//NULL was cgs.model_draw
// work the matrix axis stuff into the original axis and origins used.
DC->g2_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, bladeOrigin);
DC->g2_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, axis[0]);//front (was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin' awful)
DC->g2_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_Y, axis[1]);//right
DC->g2_GiveMeVectorFromMatrix(boltMatrix, POSITIVE_Z, axis[2]);//up
float scale = DC->xscale;
if ( tagHack )
{
switch ( saberType )
{
case SABER_SINGLE:
case SABER_DAGGER:
case SABER_LANCE:
break;
case SABER_STAFF:
if ( bladeNum == 1 )
{
VectorScale( axis[0], -1, axis[0] );
VectorMA( bladeOrigin, 16*scale, axis[0], bladeOrigin );
}
break;
case SABER_BROAD:
if ( bladeNum == 0 )
{
VectorMA( bladeOrigin, -1*scale, axis[1], bladeOrigin );
}
else if ( bladeNum == 1 )
{
VectorMA( bladeOrigin, 1*scale, axis[1], bladeOrigin );
}
break;
case SABER_PRONG:
if ( bladeNum == 0 )
{
VectorMA( bladeOrigin, -3*scale, axis[1], bladeOrigin );
}
else if ( bladeNum == 1 )
{
VectorMA( bladeOrigin, 3*scale, axis[1], bladeOrigin );
}
break;
case SABER_ARC:
VectorSubtract( axis[1], axis[2], axis[1] );
VectorNormalize( axis[1] );
switch ( bladeNum )
{
case 0:
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
VectorScale( axis[0], 0.75f, axis[0] );
VectorScale( axis[1], 0.25f, axis[1] );
VectorAdd( axis[0], axis[1], axis[0] );
break;
case 1:
VectorScale( axis[0], 0.25f, axis[0] );
VectorScale( axis[1], 0.75f, axis[1] );
VectorAdd( axis[0], axis[1], axis[0] );
break;
case 2:
VectorMA( bladeOrigin, -8*scale, axis[0], bladeOrigin );
VectorScale( axis[0], -0.25f, axis[0] );
VectorScale( axis[1], 0.75f, axis[1] );
VectorAdd( axis[0], axis[1], axis[0] );
break;
case 3:
VectorMA( bladeOrigin, -16*scale, axis[0], bladeOrigin );
VectorScale( axis[0], -0.75f, axis[0] );
VectorScale( axis[1], 0.25f, axis[1] );
VectorAdd( axis[0], axis[1], axis[0] );
break;
}
break;
case SABER_SAI:
if ( bladeNum == 1 )
{
VectorMA( bladeOrigin, -3*scale, axis[1], bladeOrigin );
}
else if ( bladeNum == 2 )
{
VectorMA( bladeOrigin, 3*scale, axis[1], bladeOrigin );
}
break;
case SABER_CLAW:
switch ( bladeNum )
{
case 0:
VectorMA( bladeOrigin, 2*scale, axis[0], bladeOrigin );
VectorMA( bladeOrigin, 2*scale, axis[2], bladeOrigin );
break;
case 1:
VectorMA( bladeOrigin, 2*scale, axis[0], bladeOrigin );
VectorMA( bladeOrigin, 2*scale, axis[2], bladeOrigin );
VectorMA( bladeOrigin, 2*scale, axis[1], bladeOrigin );
break;
case 2:
VectorMA( bladeOrigin, 2*scale, axis[0], bladeOrigin );
VectorMA( bladeOrigin, 2*scale, axis[2], bladeOrigin );
VectorMA( bladeOrigin, -2*scale, axis[1], bladeOrigin );
break;
}
break;
case SABER_STAR:
switch ( bladeNum )
{
case 0:
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
case 1:
VectorScale( axis[0], 0.33f, axis[0] );
VectorScale( axis[2], 0.67f, axis[2] );
VectorAdd( axis[0], axis[2], axis[0] );
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
case 2:
VectorScale( axis[0], -0.33f, axis[0] );
VectorScale( axis[2], 0.67f, axis[2] );
VectorAdd( axis[0], axis[2], axis[0] );
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
case 3:
VectorScale( axis[0], -1, axis[0] );
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
case 4:
VectorScale( axis[0], -0.33f, axis[0] );
VectorScale( axis[2], -0.67f, axis[2] );
VectorAdd( axis[0], axis[2], axis[0] );
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
case 5:
VectorScale( axis[0], 0.33f, axis[0] );
VectorScale( axis[2], -0.67f, axis[2] );
VectorAdd( axis[0], axis[2], axis[0] );
VectorMA( bladeOrigin, 8*scale, axis[0], bladeOrigin );
break;
}
break;
case SABER_TRIDENT:
switch ( bladeNum )
{
case 0:
VectorMA( bladeOrigin, 24*scale, axis[0], bladeOrigin );
break;
case 1:
VectorMA( bladeOrigin, -6*scale, axis[1], bladeOrigin );
VectorMA( bladeOrigin, 24*scale, axis[0], bladeOrigin );
break;
case 2:
VectorMA( bladeOrigin, 6*scale, axis[1], bladeOrigin );
VectorMA( bladeOrigin, 24*scale, axis[0], bladeOrigin );
break;
case 3:
VectorMA( bladeOrigin, -32*scale, axis[0], bladeOrigin );
VectorScale( axis[0], -1, axis[0] );
break;
}
break;
case SABER_SITH_SWORD:
//no blade
break;
}
}
if ( saberType == SABER_SITH_SWORD )
{//draw no blade
return;
}
UI_DoSaber( bladeOrigin, axis[0], bladeLength, bladeLength, bladeRadius, bladeColor );
}
extern qboolean ItemParse_asset_model_go( itemDef_t *item, const char *name );
extern qboolean ItemParse_model_g2skin_go( itemDef_t *item, const char *skinName );
void UI_GetSaberForMenu( char *saber, int saberNum )
{
char saberTypeString[MAX_QPATH]={0};
saberType_t saberType = SABER_NONE;
if ( saberNum == 0 )
{
DC->getCVarString( "g_saber", saber, MAX_QPATH );
}
else
{
DC->getCVarString( "g_saber2", saber, MAX_QPATH );
}
//read this from the sabers.cfg
UI_SaberTypeForSaber( saber, saberTypeString );
if ( saberTypeString[0] )
{
saberType = TranslateSaberType( saberTypeString );
}
switch ( uiInfo.movesTitleIndex )
{
case 0://MD_ACROBATICS:
break;
case 1://MD_SINGLE_FAST:
case 2://MD_SINGLE_MEDIUM:
case 3://MD_SINGLE_STRONG:
if ( saberType != SABER_SINGLE )
{
Q_strncpyz(saber,"single_1",MAX_QPATH,qtrue);
}
break;
case 4://MD_DUAL_SABERS:
if ( saberType != SABER_SINGLE )
{
Q_strncpyz(saber,"single_1",MAX_QPATH,qtrue);
}
break;
case 5://MD_SABER_STAFF:
if ( saberType == SABER_SINGLE || saberType == SABER_NONE )
{
Q_strncpyz(saber,"dual_1",MAX_QPATH,qtrue);
}
break;
}
}
void UI_SaberDrawBlades( itemDef_t *item, vec3_t origin, float curYaw )
{
//NOTE: only allows one saber type in view at a time
char saber[MAX_QPATH];
int saberNum = 0;
int saberModel = 0;
int numSabers = 1;
if ( (item->flags&ITF_ISCHARACTER)//hacked sabermoves sabers in character's hand
&& uiInfo.movesTitleIndex == 4 /*MD_DUAL_SABERS*/ )
{
numSabers = 2;
}
for ( saberNum = 0; saberNum < numSabers; saberNum++ )
{
if ( (item->flags&ITF_ISCHARACTER) )//hacked sabermoves sabers in character's hand
{
UI_GetSaberForMenu( saber, saberNum );
saberModel = saberNum + 1;
}
else if ( (item->flags&ITF_ISSABER) )
{
DC->getCVarString( "ui_saber", saber, sizeof(saber) );
saberModel = 0;
}
else if ( (item->flags&ITF_ISSABER2) )
{
DC->getCVarString( "ui_saber2", saber, sizeof(saber) );
saberModel = 0;
}
else
{
return;
}
if ( saber[0] )
{
int numBlades = UI_SaberNumBladesForSaber( saber );
if ( numBlades )
{//okay, here we go, time to draw each blade...
char saberTypeString[MAX_QPATH]={0};
UI_SaberTypeForSaber( saber, saberTypeString );
saberType_t saberType = TranslateSaberType( saberTypeString );
for ( int curBlade = 0; curBlade < numBlades; curBlade++ )
{
UI_SaberDrawBlade( item, saber, saberModel, saberType, origin, curYaw, curBlade );
}
}
}
}
}
void UI_SaberAttachToChar( itemDef_t *item )
{
int numSabers = 1;
int saberNum = 0;
if ( item->ghoul2.size() > 2 && item->ghoul2[2].mModelindex >=0 )
{//remove any extra models
DC->g2_RemoveGhoul2Model(item->ghoul2, 2);
}
if ( item->ghoul2.size() > 1 && item->ghoul2[1].mModelindex >=0)
{//remove any extra models
DC->g2_RemoveGhoul2Model(item->ghoul2, 1);
}
if ( uiInfo.movesTitleIndex == 4 /*MD_DUAL_SABERS*/ )
{
numSabers = 2;
}
if ( Cvar_Get("ui_move_title", "4", 0)->integer == 4)
{
numSabers = 2;
}
for ( saberNum = 0; saberNum < numSabers; saberNum++ )
{
//bolt sabers
char modelPath[MAX_QPATH];
char skinPath[MAX_QPATH];
char saber[MAX_QPATH];
UI_GetSaberForMenu( saber, saberNum );
if ( UI_SaberModelForSaber( saber, modelPath ) )
{//successfully found a model
int g2Saber = DC->g2_InitGhoul2Model(item->ghoul2, modelPath, 0, 0, 0, 0, 0); //add the model
if (g2Saber)
{
//get the customSkin, if any
if ( UI_SaberSkinForSaber( saber, skinPath ) )
{
int g2skin = DC->registerSkin(skinPath);
DC->g2_SetSkin( &item->ghoul2[g2Saber], 0, g2skin );//this is going to set the surfs on/off matching the skin file
}
else
{
DC->g2_SetSkin( &item->ghoul2[g2Saber], -1, 0 );//turn off custom skin
}
int boltNum;
if ( saberNum == 0 )
{
boltNum = G2API_AddBolt(&item->ghoul2[0], "*r_hand");
}
else
{
boltNum = G2API_AddBolt(&item->ghoul2[0], "*l_hand");
}
G2API_AttachG2Model(&item->ghoul2[g2Saber], &item->ghoul2[0], boltNum, 0);
}
}
}
}

12322
code/ui/ui_shared.cpp Normal file

File diff suppressed because it is too large Load Diff

535
code/ui/ui_shared.h Normal file
View File

@@ -0,0 +1,535 @@
#ifndef __UI_SHARED_H
#define __UI_SHARED_H
#define MAX_TOKENLENGTH 1024
#define MAX_OPEN_MENUS 16
#define MAX_TEXTSCROLL_LINES 256
#define MAX_EDITFIELD 256
#ifndef TT_STRING
//token types
#define TT_STRING 1 // string
#define TT_LITERAL 2 // literal
#define TT_NUMBER 3 // number
#define TT_NAME 4 // name
#define TT_PUNCTUATION 5 // punctuation
#endif
#define SLIDER_WIDTH 128.0
#define SLIDER_HEIGHT 16.0
#define SLIDER_THUMB_WIDTH 12.0
#define SLIDER_THUMB_HEIGHT 16.0
#define SCROLLBAR_SIZE 16.0
typedef struct pc_token_s
{
int type;
int subtype;
int intvalue;
float floatvalue;
char string[MAX_TOKENLENGTH];
} pc_token_t;
// FIXME: combine flags into bitfields to save space
// FIXME: consolidate all of the common stuff in one structure for menus and items
// THINKABOUTME: is there any compelling reason not to have items contain items
// and do away with a menu per say.. major issue is not being able to dynamically allocate
// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have
// the engine just allocate the pool for it based on a cvar
// many of the vars are re-used for different item types, as such they are not always named appropriately
// the benefits of c++ in DOOM will greatly help crap like this
// FIXME: need to put a type ptr that points to specific type info per type
//
#define MAX_LB_COLUMNS 16
typedef struct columnInfo_s {
int pos;
int width;
int maxChars;
} columnInfo_t;
typedef struct listBoxDef_s {
int startPos;
int endPos;
int drawPadding;
int cursorPos;
float elementWidth;
float elementHeight;
int elementStyle;
int numColumns;
columnInfo_t columnInfo[MAX_LB_COLUMNS];
const char *doubleClick;
qboolean notselectable;
//JLF MPMOVED
qboolean scrollhidden;
qhandle_t selectionShader;
} listBoxDef_t;
typedef struct editFieldDef_s {
float minVal; // edit field limits
float maxVal; //
float defVal; //
float range; //
int maxChars; // for edit fields
int maxPaintChars; // for edit fields
int paintOffset; //
} editFieldDef_t;
#define MAX_MULTI_CVARS 64//32
typedef struct multiDef_s {
const char *cvarList[MAX_MULTI_CVARS];
const char *cvarStr[MAX_MULTI_CVARS];
float cvarValue[MAX_MULTI_CVARS];
int count;
qboolean strDef;
} multiDef_t;
#define CVAR_ENABLE 0x00000001
#define CVAR_DISABLE 0x00000002
#define CVAR_SHOW 0x00000004
#define CVAR_HIDE 0x00000008
#define CVAR_SUBSTRING 0x00000010 //when using enable or disable, just check for strstr instead of ==
#ifdef _XBOX
// Super small - doesn't need to be bigger yet, helps us get into 64 MB
//#define STRING_POOL_SIZE 16*1024
#define STRING_POOL_SIZE 128*1024
#else
#ifdef CGAME
#define STRING_POOL_SIZE 128*1024
#else
#define STRING_POOL_SIZE 384*1024
#endif
#endif
//#define NUM_CROSSHAIRS 9
#define NUM_CROSSHAIRS 1
typedef struct {
qhandle_t qhMediumFont;
qhandle_t cursor;
qhandle_t gradientBar;
qhandle_t scrollBarArrowUp;
qhandle_t scrollBarArrowDown;
qhandle_t scrollBarArrowLeft;
qhandle_t scrollBarArrowRight;
qhandle_t scrollBar;
qhandle_t scrollBarThumb;
qhandle_t buttonMiddle;
qhandle_t buttonInside;
qhandle_t solidBox;
qhandle_t sliderBar;
// qhandle_t sliderThumb;
sfxHandle_t menuEnterSound;
sfxHandle_t menuExitSound;
sfxHandle_t menuBuzzSound;
sfxHandle_t itemFocusSound;
sfxHandle_t forceChosenSound;
sfxHandle_t forceUnchosenSound;
sfxHandle_t datapadmoveRollSound;
sfxHandle_t datapadmoveJumpSound;
sfxHandle_t datapadmoveSaberSound1;
sfxHandle_t datapadmoveSaberSound2;
sfxHandle_t datapadmoveSaberSound3;
sfxHandle_t datapadmoveSaberSound4;
sfxHandle_t datapadmoveSaberSound5;
sfxHandle_t datapadmoveSaberSound6;
sfxHandle_t nullSound;
#ifdef _IMMERSION
ffHandle_t menuEnterForce;
ffHandle_t menuExitForce;
ffHandle_t menuBuzzForce;
ffHandle_t itemFocusForce;
#endif // _IMMERSION
float fadeClamp;
int fadeCycle;
float fadeAmount;
float shadowX;
float shadowY;
vec4_t shadowColor;
float shadowFadeClamp;
qboolean fontRegistered;
// player settings
// qhandle_t fxBasePic;
// qhandle_t fxPic[7];
qhandle_t crosshairShader[NUM_CROSSHAIRS];
} cachedAssets_t;
struct itemDef_s;
typedef struct {
void (*addRefEntityToScene) (const refEntity_t *re );
void (*clearScene) ();
void (*drawHandlePic) (float x, float y, float w, float h, qhandle_t asset);
void (*drawRect) ( float x, float y, float w, float h, float size, const vec4_t color);
void (*drawSides) (float x, float y, float w, float h, float size);
void (*drawText) (float x, float y, float scale, vec4_t color, const char *text, int iMaxPixelWidth, int style, int iFontIndex );
void (*drawTextWithCursor)(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int iMaxPixelWidth, int style, int iFontIndex);
void (*drawTopBottom) (float x, float y, float w, float h, float size);
void (*executeText)(int exec_when, const char *text );
int (*feederCount)(float feederID);
void (*feederSelection)(float feederID, int index, struct itemDef_s *item);
void (*fillRect) ( float x, float y, float w, float h, const vec4_t color);
void (*getBindingBuf)( int keynum, char *buf, int buflen );
void (*getCVarString)(const char *cvar, char *buffer, int bufsize);
float (*getCVarValue)(const char *cvar);
qboolean (*getOverstrikeMode)();
float (*getValue) (int ownerDraw);
void (*keynumToStringBuf)( int keynum, char *buf, int buflen );
void (*modelBounds) (qhandle_t model, vec3_t min, vec3_t max);
qboolean (*ownerDrawHandleKey)(int ownerDraw, int flags, float *special, int key);
void (*ownerDrawItem) (float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle, int iFontIndex);
qboolean (*ownerDrawVisible) (int flags);
int (*ownerDrawWidth)(int ownerDraw, float scale);
void (*Pause)(qboolean b);
void (*Print)(const char *msg, ...);
int (*registerFont) (const char *pFontname);
qhandle_t (*registerModel) (const char *p);
qhandle_t (*registerShaderNoMip) (const char *p);
sfxHandle_t (*registerSound)(const char *name, qboolean compressed);
void (*renderScene) ( const refdef_t *fd );
qboolean (*runScript)(const char **p);
qboolean (*deferScript)(const char **p);
void (*setBinding)( int keynum, const char *binding );
void (*setColor) (const vec4_t v);
void (*setCVar)(const char *cvar, const char *value);
void (*setOverstrikeMode)(qboolean b);
void (*startLocalSound)( sfxHandle_t sfx, int channelNum );
void (*stopCinematic)(int handle);
int (*textHeight) (const char *text, float scale, int iFontIndex);
int (*textWidth) (const char *text, float scale, int iFontIndex);
qhandle_t (*feederItemImage) (float feederID, int index);
const char *(*feederItemText) (float feederID, int index, int column, qhandle_t *handle);
qhandle_t (*registerSkin)( const char *name );
//rww - ghoul2 stuff. Add whatever you need here, remember to set it in _UI_Init or it will crash when you try to use it.
#ifdef _XBOX // No default arguments on function pointers
qboolean g2_SetSkin(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin = 0)
{
return G2API_SetSkin(ghlInfo, customSkin, renderSkin);
}
qboolean g2_SetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int startFrame, const int endFrame,
const int flags, const float animSpeed, const int currentTime, const float setFrame = -1, const int blendTime = -1)
{
return G2API_SetBoneAnim(ghlInfo, boneName, startFrame, endFrame, flags, animSpeed, currentTime, setFrame, blendTime);
}
#else
qboolean (*g2_SetSkin)(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin = 0);
qboolean (*g2_SetBoneAnim)(CGhoul2Info *ghlInfo, const char *boneName, const int startFrame, const int endFrame,
const int flags, const float animSpeed, const int currentTime, const float setFrame = -1, const int blendTime = -1);
#endif
qboolean (*g2_RemoveGhoul2Model)(CGhoul2Info_v &ghlInfo, const int modelIndex);
int (*g2_InitGhoul2Model)(CGhoul2Info_v &ghoul2, const char *fileName, int, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias);
void (*g2_CleanGhoul2Models)(CGhoul2Info_v &ghoul2);
int (*g2_AddBolt)(CGhoul2Info *ghlInfo, const char *boneName);
qboolean (*g2_GetBoltMatrix)(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix,
const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, const vec3_t scale);
void (*g2_GiveMeVectorFromMatrix)(mdxaBone_t &boltMatrix, Eorientations flags, vec3_t &vec);
//Utility functions that don't immediately redirect to ghoul2 functions
int (*g2hilev_SetAnim)(CGhoul2Info *ghlInfo, const char *boneName, int animNum, const qboolean freeze);
#ifdef _IMMERSION
ffHandle_t (*registerForce)(const char *name, int channel=FF_CHANNEL_MENU);
void (*startForce)(ffHandle_t ff);
#endif // _IMMERSION
float yscale;
float xscale;
float bias;
int realTime;
int frameTime;
qboolean cursorShow;
int cursorx;
int cursory;
qboolean debug;
cachedAssets_t Assets;
glconfig_t glconfig;
qhandle_t whiteShader;
qhandle_t gradientImage;
float FPS;
} displayContextDef_t;
void UI_InitMemory( void );
#define MAX_COLOR_RANGES 10
#define MAX_MENUITEMS 200
#define MAX_MENUS 64
#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive
#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive
#define WINDOW_VISIBLE 0x00000004 // is visible
#define WINDOW_INACTIVE 0x00000008 // is visible but grey ( non-active )
#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc..
#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active
#define WINDOW_FADINGIN 0x00000040 // fading in
#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive
#define WINDOW_INTRANSITION 0x00000100 // window is in transition
#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not )
#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal
#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow
#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow
#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb
#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up
#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down
#define WINDOW_ORBITING 0x00010000 // item is in orbit
#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click
#define WINDOW_WRAPPED 0x00040000 // manually wrap text
#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text
#define WINDOW_FORCED 0x00100000 // forced open
#define WINDOW_POPUP 0x00200000 // popup
#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set
#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented )
#define WINDOW_PLAYERCOLOR 0x01000000 // hack the forecolor to match ui_char_color_*
#define WINDOW_SCRIPTWAITING 0x02000000 // delayed script waiting to run
//JLF MPMOVED
#define WINDOW_INTRANSITIONMODEL 0x04000000 // delayed script waiting to run
#define WINDOW_IGNORE_ESCAPE 0x08000000 // ignore normal closeall menus escape functionality
typedef struct {
float x; // horiz position
float y; // vert position
float w; // width
float h; // height;
} rectDef_t;
typedef rectDef_t UIRectangle;
// FIXME: do something to separate text vs window stuff
typedef struct {
UIRectangle rect; // client coord rectangle
UIRectangle rectClient; // screen coord rectangle
char *name; //
char *group; // if it belongs to a group
// const char *cinematicName; // cinematic name
// int cinematic; // cinematic handle
int style; //
int border; //
int ownerDraw; // ownerDraw style
int ownerDrawFlags; // show flags for ownerdraw items
float borderSize; //
int flags; // visible, focus, mouseover, cursor
UIRectangle rectEffects; // for various effects
UIRectangle rectEffects2; // for various effects
int offsetTime; // time based value for various effects
int nextTime; // time next effect should cycle
int delayTime; // time when delay expires
char *delayedScript; // points into another script's text while delaying
vec4_t foreColor; // text color
vec4_t backColor; // border color
vec4_t borderColor; // border color
// vec4_t outlineColor; // border color
qhandle_t background; // background asset
} windowDef_t;
typedef windowDef_t Window;
typedef struct {
vec4_t color; //
float low; //
float high; //
} colorRangeDef_t;
typedef struct modelDef_s {
int angle;
vec3_t origin;
float fov_x;
float fov_y;
int rotationSpeed;
vec3_t g2mins; //required
vec3_t g2maxs; //required
int g2skin; //optional
int g2anim; //optional
//JLF MPMOVED
//Transition extras
vec3_t g2mins2, g2maxs2, g2minsEffect, g2maxsEffect;
float fov_x2, fov_y2, fov_Effectx, fov_Effecty;
} modelDef_t;
#define ITF_G2VALID 0x0001 // indicates whether or not g2 instance is valid.
#define ITF_ISCHARACTER 0x0002 // a character item, uses customRGBA
#define ITF_ISSABER 0x0004 // first saber item, draws blade
#define ITF_ISSABER2 0x0008 // second saber item, draws blade
#define ITF_ISANYSABER (ITF_ISSABER|ITF_ISSABER2) //either saber
typedef struct itemDef_s {
Window window; // common positional, border, style, layout info
UIRectangle textRect; // rectangle the text ( if any ) consumes
int type; // text, button, radiobutton, checkbox, textfield, listbox, combo
int alignment; // left center right
int textalignment; // ( optional ) alignment for text within rect based on text width
float textalignx; // ( optional ) text alignment x coord
float textaligny; // ( optional ) text alignment y coord
// float text2alignx; // ( optional ) text2 alignment x coord
// float text2aligny; // ( optional ) text2 alignment y coord
float textscale; // scale percentage from 72pts
int textStyle; // ( optional ) style, normal and shadowed are it for now
char *text; // display text
// char *text2; // display text2
// char *descText; // Description text
void *parent; // menu owner
qhandle_t asset; // handle to asset
CGhoul2Info_v ghoul2; // ghoul2 instance if available instead of a model.
int flags; // flags like g2valid, character, saber, saber2, etc.
// const char *mouseEnterText; // mouse enter script
// const char *mouseExitText; // mouse exit script
// const char *mouseEnter; // mouse enter script
// const char *mouseExit; // mouse exit script
const char *action; // select script
//JLFACCEPT MPMOVED
// const char *accept;
//JLFDPADSCRIPT MPMOVED
const char * selectionNext;
const char * selectionPrev;
const char *onFocus; // select script
const char *leaveFocus; // select script
const char *cvar; // associated cvar
const char *cvarTest; // associated cvar for enable actions
const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list
int cvarFlags; // what type of action to take on cvarenables
sfxHandle_t focusSound; //
#ifdef _IMMERSION
ffHandle_t focusForce;
#endif // _IMMERSION
// int numColors; // number of color ranges
// colorRangeDef_t colorRanges[MAX_COLOR_RANGES];
float special; // used for feeder id's etc.. diff per type
int cursorPos; // cursor position in characters
void *typeData; // type specific data ptr's
// int appearanceSlot; // order of appearance
int value; // used by ITEM_TYPE_MULTI that aren't linked to a particular cvar.
int font; // FONT_SMALL,FONT_MEDIUM,FONT_LARGE
// int invertYesNo;
int xoffset;
} itemDef_t;
typedef struct {
Window window;
const char *font; // font
qboolean fullScreen; // covers entire screen
int itemCount; // number of items;
int fontIndex; //
int cursorItem; // which item as the cursor
int fadeCycle; //
float fadeClamp; //
float fadeAmount; //
const char *onOpen; // run when the menu is first opened
const char *onClose; // run when the menu is closed
//JLFACCEPT MPMOVED
const char *onAccept; // run when menu is closed with acceptance
const char *onESC; // run when the menu is closed
const char *xScript; // run when X button is pressed
const char *yScript; // run when Y button is pressed
const char *whiteScript; // run when White button is pressed
const char *soundName; // background loop sound for menu
vec4_t focusColor; // focus color for items
vec4_t disableColor; // focus color for items
itemDef_t *items[MAX_MENUITEMS]; // items this menu contains
float appearanceTime; // when next item should appear
int appearanceCnt; // current item displayed
float appearanceIncrement; //
int descX; // X position of description
int descY; // X position of description
vec4_t descColor; // description text color for items
int descAlignment; // Description of alignment
float descScale; // Description scale
int descTextStyle; // ( optional ) style, normal and shadowed are it for now
} menuDef_t;
typedef struct textScrollDef_s
{
int startPos;
int endPos;
float lineHeight;
int maxLineChars;
int drawPadding;
// changed spelling to make them fall out during compile while I made them asian-aware -Ste
//
int iLineCount;
const char* pLines[MAX_TEXTSCROLL_LINES]; // can contain NULL ptrs that you should skip over during paint.
} textScrollDef_t;
typedef struct
{
const char *name;
qboolean (*handler) (itemDef_t *item, const char** args);
} commandDef_t;
menuDef_t *Menu_GetFocused(void);
void Controls_GetConfig( void );
void Controls_SetConfig(qboolean restart);
qboolean Display_KeyBindPending(void);
qboolean Display_MouseMove(void *p, int x, int y);
int Display_VisibleMenuCount(void);
qboolean Int_Parse(const char **p, int *i);
void Init_Display(displayContextDef_t *dc);
void Menus_Activate(menuDef_t *menu);
menuDef_t *Menus_ActivateByName(const char *p);
qboolean Menus_AnyFullScreenVisible(void);
void Menus_CloseAll(void);
int Menu_Count(void);
itemDef_t *Menu_FindItemByName(menuDef_t *menu, const char *p);
void Menu_HandleKey(menuDef_t *menu, int key, qboolean down);
void Menu_New(char *buffer);
void Menus_OpenByName(const char *p);
void Menu_PaintAll(void);
void Menu_Reset(void);
void PC_EndParseSession(char *buffer);
qboolean PC_Float_Parse(int handle, float *f);
qboolean PC_ParseString(const char **tempStr);
qboolean PC_ParseStringMem(const char **out);
void PC_ParseWarning(const char *message);
qboolean PC_String_Parse(int handle, const char **out);
#ifdef _XBOX
int PC_StartParseSession(const char *fileName,char **buffer, bool nested = false);
#else
int PC_StartParseSession(const char *fileName,char **buffer);
#endif
char *PC_ParseExt(void);
qboolean PC_ParseInt(int *number);
qboolean PC_ParseFloat(float *number);
qboolean PC_ParseColor(vec4_t *c);
void PC_SkipBracedSection( void );
const char *String_Alloc(const char *p);
void String_Init(void);
qboolean String_Parse(const char **p, const char **out);
void String_Report(void);
void UI_Cursor_Show(qboolean flag);
itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char *name);
extern displayContextDef_t *DC;
#endif

372
code/ui/ui_splash.cpp Normal file
View File

@@ -0,0 +1,372 @@
#include "../client/client.h"
#include "../renderer/tr_local.h"
#include "../win32/glw_win_dx8.h"
#include "../win32/win_local.h"
#include "../win32/win_file.h"
#include "../ui/ui_splash.h"
extern bool Sys_QuickStart( void );
/*********
Globals
*********/
static bool SP_LicenseDone = false;
/*********
SP_DisplayIntros
Draws intro movies to the screen
*********/
void SP_DisplayLogos(void)
{
if( !Sys_QuickStart() )
CIN_PlayAllFrames( "logos", 0, 0, 640, 480, 0, true );
}
/*********
SP_DrawTexture
*********/
void SP_DrawTexture(void* pixels, float width, float height, float vShift)
{
if (!pixels)
{
// Ug. We were not even able to load the error message texture.
return;
}
// Create a texture from the buffered file
GLuint texid;
qglGenTextures(1, &texid);
qglBindTexture(GL_TEXTURE_2D, texid);
qglTexImage2D(GL_TEXTURE_2D, 0, GL_DDS1_EXT, width, height, 0, GL_DDS1_EXT, GL_UNSIGNED_BYTE, pixels);
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
// Reset every GL state we've got. Who knows what state
// the renderer could be in when this function gets called.
qglColor3f(1.f, 1.f, 1.f);
#ifdef _XBOX
if(glw_state->isWidescreen)
qglViewport(0, 0, 720, 480);
else
#endif
qglViewport(0, 0, 640, 480);
GLboolean alpha = qglIsEnabled(GL_ALPHA_TEST);
qglDisable(GL_ALPHA_TEST);
GLboolean blend = qglIsEnabled(GL_BLEND);
qglDisable(GL_BLEND);
GLboolean cull = qglIsEnabled(GL_CULL_FACE);
qglDisable(GL_CULL_FACE);
GLboolean depth = qglIsEnabled(GL_DEPTH_TEST);
qglDisable(GL_DEPTH_TEST);
GLboolean fog = qglIsEnabled(GL_FOG);
qglDisable(GL_FOG);
GLboolean lighting = qglIsEnabled(GL_LIGHTING);
qglDisable(GL_LIGHTING);
GLboolean offset = qglIsEnabled(GL_POLYGON_OFFSET_FILL);
qglDisable(GL_POLYGON_OFFSET_FILL);
GLboolean scissor = qglIsEnabled(GL_SCISSOR_TEST);
qglDisable(GL_SCISSOR_TEST);
GLboolean stencil = qglIsEnabled(GL_STENCIL_TEST);
qglDisable(GL_STENCIL_TEST);
GLboolean texture = qglIsEnabled(GL_TEXTURE_2D);
qglEnable(GL_TEXTURE_2D);
qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity();
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
#ifdef _XBOX
if(glw_state->isWidescreen)
qglOrtho(0, 720, 0, 480, 0, 1);
else
#endif
qglOrtho(0, 640, 0, 480, 0, 1);
qglMatrixMode(GL_TEXTURE0);
qglLoadIdentity();
qglMatrixMode(GL_TEXTURE1);
qglLoadIdentity();
qglActiveTextureARB(GL_TEXTURE0_ARB);
qglClientActiveTextureARB(GL_TEXTURE0_ARB);
memset(&tess, 0, sizeof(tess));
// Draw the error message
qglBeginFrame();
if (!SP_LicenseDone)
{
// clear the screen if we haven't done the
// license yet...
qglClearColor(0, 0, 0, 1);
qglClear(GL_COLOR_BUFFER_BIT);
}
float x1, x2, y1, y2;
#ifdef _XBOX
if(glw_state->isWidescreen)
{
x1 = 0;
x2 = 720;
y1 = 0;
y2 = 480;
}
else {
#endif
x1 = 0;
x2 = 640;
y1 = 0;
y2 = 480;
#ifdef _XBOX
}
#endif
y1 += vShift;
y2 += vShift;
qglBeginEXT (GL_TRIANGLE_STRIP, 4, 0, 0, 4, 0);
qglTexCoord2f( 0, 0 );
qglVertex2f(x1, y1);
qglTexCoord2f( 1 , 0 );
qglVertex2f(x2, y1);
qglTexCoord2f( 0, 1 );
qglVertex2f(x1, y2);
qglTexCoord2f( 1, 1 );
qglVertex2f(x2, y2);
qglEnd();
qglEndFrame();
qglFlush();
// Restore (most) of the render states we reset
if (alpha) qglEnable(GL_ALPHA_TEST);
else qglDisable(GL_ALPHA_TEST);
if (blend) qglEnable(GL_BLEND);
else qglDisable(GL_BLEND);
if (cull) qglEnable(GL_CULL_FACE);
else qglDisable(GL_CULL_FACE);
if (depth) qglEnable(GL_DEPTH_TEST);
else qglDisable(GL_DEPTH_TEST);
if (fog) qglEnable(GL_FOG);
else qglDisable(GL_FOG);
if (lighting) qglEnable(GL_LIGHTING);
else qglDisable(GL_LIGHTING);
if (offset) qglEnable(GL_POLYGON_OFFSET_FILL);
else qglDisable(GL_POLYGON_OFFSET_FILL);
if (scissor) qglEnable(GL_SCISSOR_TEST);
else qglDisable(GL_SCISSOR_TEST);
if (stencil) qglEnable(GL_STENCIL_TEST);
else qglDisable(GL_STENCIL_TEST);
if (texture) qglEnable(GL_TEXTURE_2D);
else qglDisable(GL_TEXTURE_2D);
// Kill the texture
qglDeleteTextures(1, &texid);
}
/*********
SP_GetLanguageExt
Retuns the extension for the current language, or
english if the language is unknown.
*********/
char* SP_GetLanguageExt()
{
switch(XGetLanguage())
{
case XC_LANGUAGE_ENGLISH:
return "EN";
// case XC_LANGUAGE_JAPANESE:
// return "JA";
case XC_LANGUAGE_GERMAN:
return "GE";
// case XC_LANGUAGE_SPANISH:
// return "SP";
// case XC_LANGUAGE_ITALIAN:
// return "IT";
// case XC_LANGUAGE_KOREAN:
// return "KO";
// case XC_LANGUAGE_TCHINESE:
// return "CH";
// case XC_LANGUAGE_PORTUGUESE:
// return "PO";
case XC_LANGUAGE_FRENCH:
return "FR";
default:
return "EN";
}
}
/*********
SP_LoadFileWithLanguage
Loads a screen with the appropriate language
*********/
void *SP_LoadFileWithLanguage(const char *name)
{
char fullname[MAX_QPATH];
void *buffer = NULL;
char *ext;
// get the language extension
ext = SP_GetLanguageExt();
// creat the fullpath name and try to load the texture
sprintf(fullname, "%s_%s.dds", name, ext);
buffer = SP_LoadFile(fullname);
if (!buffer)
{
sprintf(fullname, "%s.dds", name);
buffer = SP_LoadFile(fullname);
}
return buffer;
}
/*********
SP_LoadFile
*********/
void* SP_LoadFile(const char* name)
{
wfhandle_t h = WF_Open(name, true, false);
if (h < 0) return NULL;
if (WF_Seek(0, SEEK_END, h))
{
WF_Close(h);
return NULL;
}
int len = WF_Tell(h);
if (WF_Seek(0, SEEK_SET, h))
{
WF_Close(h);
return NULL;
}
void *buf = Z_Malloc(len, TAG_TEMP_WORKSPACE, false, 32);
if (WF_Read(buf, len, h) != len)
{
Z_Free(buf);
WF_Close(h);
return NULL;
}
WF_Close(h);
return buf;
}
/********
SP_DoLicense
Draws the license splash to the screen
*********/
void SP_DoLicense(void)
{
if( Sys_QuickStart() )
return;
// Load the license screen
void *license;
extern const char *Sys_RemapPath( const char *filename );
license = SP_LoadFileWithLanguage( Sys_RemapPath( "base\\media\\LicenseScreen" ) );
if (license)
{
SP_DrawTexture(license, 512, 512, 0);
Z_Free(license);
}
SP_LicenseDone = true;
}
/*
SP_DrawMPLoadScreen
Draws the Multiplayer loading screen
*/
void SP_DrawMPLoadScreen( void )
{
// Load the texture:
void *image = SP_LoadFileWithLanguage("d:\\base\\media\\LoadMP");
if( image )
{
SP_DrawTexture(image, 512, 512, 0);
Z_Free(image);
}
}
/*
SP_DrawSPLoadScreen
Draws the single player loading screen - used when skipping the logo movies
*/
void SP_DrawSPLoadScreen( void )
{
// Load the texture:
extern const char *Sys_RemapPath( const char *filename );
void *image = SP_LoadFileWithLanguage( Sys_RemapPath("base\\media\\LoadSP") );
if( image )
{
SP_DrawTexture(image, 512, 512, 0);
Z_Free(image);
}
}
/*
ERR_DiscFail
Draws the damaged/dirty disc message, looping forever
*/
void ERR_DiscFail(bool poll)
{
// Load the texture:
extern const char *Sys_RemapPath( const char *filename );
void *image = SP_LoadFileWithLanguage( Sys_RemapPath("base\\media\\DiscErr") );
if( image )
{
SP_DrawTexture(image, 512, 512, 0);
Z_Free(image);
}
for (;;)
{
extern void MuteBinkSystem(void);
MuteBinkSystem();
extern void S_Update_(void);
S_Update_();
}
}

11
code/ui/ui_splash.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef __UI_SPLASH_H
#define __UI_SPLASH_H
void SP_DisplayLogos(void);
void SP_DoLicense(void);
void* SP_LoadFile(const char* name);
void* SP_LoadFileWithLanguage(const char *name);
char* SP_GetLanguageExt();
void SP_DrawTexture(void* pixels, float width, float height, float vShift);
#endif

177
code/ui/ui_syscalls.cpp Normal file
View File

@@ -0,0 +1,177 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
// leave this at the top of all UI_xxxx files for PCH reasons...
//
#include "../server/exe_headers.h"
#include "ui_local.h"
#ifdef _IMMERSION
#include "../ff/ff.h"
#endif // _IMMERSION
// this file is only included when building a dll
// syscalls.asm is included instead when building a qvm
static int (*syscall)( int arg, ... ) = (int (*)( int, ...))-1;
void dllEntry( int (*syscallptr)( int arg,... ) ) {
syscall = syscallptr;
// CG_PreInit();
}
inline int PASSFLOAT( float x )
{
float floatTemp;
floatTemp = x;
return *(int *)&floatTemp;
}
int CL_UISystemCalls( int *args );
int FloatAsInt( float f );
float trap_Cvar_VariableValue( const char *var_name )
{
int temp;
// temp = syscall( UI_CVAR_VARIABLEVALUE, var_name );
temp = FloatAsInt( Cvar_VariableValue(var_name) );
return (*(float*)&temp);
}
void trap_R_ClearScene( void )
{
ui.R_ClearScene();
}
void trap_R_AddRefEntityToScene( const refEntity_t *re )
{
ui.R_AddRefEntityToScene(re);
}
void trap_R_RenderScene( const refdef_t *fd )
{
// syscall( UI_R_RENDERSCENE, fd );
ui.R_RenderScene(fd);
}
void trap_R_SetColor( const float *rgba )
{
// syscall( UI_R_SETCOLOR, rgba );
// re.SetColor( rgba );
ui.R_SetColor(rgba);
}
void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader )
{
// syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader );
// re.DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );
ui.R_DrawStretchPic( x, y, w, h, s1, t1, s2, t2, hShader );
}
void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs )
{
// syscall( UI_R_MODELBOUNDS, model, mins, maxs );
ui.R_ModelBounds(model, mins, maxs);
}
void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum )
{
// syscall( UI_S_STARTLOCALSOUND, sfx, channelNum );
S_StartLocalSound( sfx, channelNum );
}
void trap_S_StopSounds( void )
{
S_StopSounds( );
}
sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed )
{
return S_RegisterSound(sample);
}
#ifdef _IMMERSION
void trap_FF_Start( ffHandle_t ff )
{
FF_AddForce( ff );
}
ffHandle_t trap_FF_Register( const char *name, int channel )
{
return FF_Register( name, channel, qtrue );
}
#endif // _IMMERSION
void trap_Key_SetBinding( int keynum, const char *binding )
{
Key_SetBinding( keynum, binding);
}
qboolean trap_Key_GetOverstrikeMode( void )
{
return Key_GetOverstrikeMode();
}
void trap_Key_SetOverstrikeMode( qboolean state )
{
Key_SetOverstrikeMode( state );
}
void trap_Key_ClearStates( void )
{
Key_ClearStates();
}
int Key_GetCatcher( void );
int trap_Key_GetCatcher( void )
{
return Key_GetCatcher();
}
void Key_SetCatcher( int catcher );
void trap_Key_SetCatcher( int catcher )
{
Key_SetCatcher( catcher );
}
/*
void trap_GetClipboardData( char *buf, int bufsize ) {
syscall( UI_GETCLIPBOARDDATA, buf, bufsize );
}
void trap_GetClientState( uiClientState_t *state ) {
syscall( UI_GETCLIENTSTATE, state );
}
*/
void CL_GetGlconfig( glconfig_t *glconfig );
void trap_GetGlconfig( glconfig_t *glconfig )
{
// syscall( UI_GETGLCONFIG, glconfig );
CL_GetGlconfig( glconfig );
}
#ifndef _XBOX
// this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate)
int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile) {
return syscall(UI_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile);
}
#endif
// stops playing the cinematic and ends it. should always return FMV_EOF
// cinematics must be stopped in reverse order of when they are started
int trap_CIN_StopCinematic(int handle)
{
return syscall(UI_CIN_STOPCINEMATIC, handle);
}