/OJRP Source/Enhanced/source/ui/ui_main.c
C | 11766 lines | 9629 code | 944 blank | 1193 comment | 1727 complexity | c4d6bbad0b25fbae46bf8471d817834e MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- // Copyright (C) 1999-2000 Id Software, Inc.
- //
- /*
- =======================================================================
- USER INTERFACE MAIN
- =======================================================================
- */
- // use this to get a demo build without an explicit demo build, i.e. to get the demo ui files to build
- //#define PRE_RELEASE_TADEMO
- #include "../ghoul2/G2.h"
- #include "ui_local.h"
- #include "../qcommon/qfiles.h"
- #include "../qcommon/game_version.h"
- #include "ui_force.h"
- #include "../cgame/animtable.h" //we want this to be compiled into the module because we access it in the shared module.
- #include "../game/bg_saga.h"
- //[Mac]
- #if MAC_PORT
- #include "../cgame/holocronicons.h"
- #else
- #include "..\cgame\holocronicons.h"
- #endif
- //[/Mac]
- extern void UI_SaberAttachToChar( itemDef_t *item );
- uiRank_t uiRank[NUM_TOTAL_SKILLS] =
- {
- {3,UI_FORCE_RANK_HEAL,FP_HEAL,FORCE_LIGHTSIDE,qfalse,0},
- {3,UI_FORCE_RANK_LEVITATION,FP_LEVITATION,0,qfalse,0},
- {3,UI_FORCE_RANK_SPEED,FP_SPEED,0,qfalse,0},
- {3,UI_FORCE_RANK_PUSH,FP_PUSH,0,qfalse,0},
- {3,UI_FORCE_RANK_PULL,FP_PULL,0,qfalse,0},
- {3,UI_FORCE_RANK_TELEPATHY,FP_TELEPATHY,FORCE_LIGHTSIDE,qfalse,0},
- {3,UI_FORCE_RANK_GRIP,FP_GRIP,FORCE_DARKSIDE,qfalse,0},
- {3,UI_FORCE_RANK_LIGHTNING,FP_LIGHTNING,FORCE_DARKSIDE,qfalse,0},
- {3,UI_FORCE_RANK_RAGE,FP_RAGE,FORCE_DARKSIDE,qfalse,0},
- {3,UI_FORCE_RANK_PROTECT,FP_PROTECT,FORCE_LIGHTSIDE,qfalse,0},
- {3,UI_FORCE_RANK_ABSORB,FP_ABSORB,FORCE_LIGHTSIDE,qfalse,0},
- {3,UI_FORCE_RANK_TEAM_HEAL,FP_TEAM_HEAL,FORCE_LIGHTSIDE,qfalse,0},
- {3,UI_FORCE_RANK_TEAM_FORCE,FP_TEAM_FORCE,FORCE_DARKSIDE,qfalse,0},
- {3,UI_FORCE_RANK_DRAIN,FP_DRAIN,FORCE_DARKSIDE,qfalse,0},
- {3,UI_FORCE_RANK_SEE,FP_SEE,0,qfalse,0},
- {3,UI_FORCE_RANK_SABERATTACK,FP_SABER_OFFENSE,0,qfalse,0},
- {3,UI_FORCE_RANK_SABERDEFEND,FP_SABER_DEFENSE,0,qfalse,0},
- {3,UI_FORCE_RANK_SABERTHROW,FP_SABERTHROW,0,qfalse,0},
- {1,UI_FORCE_RANK_JETPACK,NUM_FORCE_POWERS+SK_JETPACK,0,qfalse,0},
- {3,UI_FORCE_RANK_PISTOL,NUM_FORCE_POWERS+SK_PISTOL,0,qfalse,0},
- {3,UI_FORCE_RANK_BLASTER,NUM_FORCE_POWERS+SK_BLASTER,0,qfalse,0},
- {3,UI_FORCE_RANK_THERMALS,NUM_FORCE_POWERS+SK_THERMAL,0,qfalse,0},
- {3,UI_FORCE_RANK_ROCKETS,NUM_FORCE_POWERS+SK_ROCKET,0,qfalse,0},
- {2,UI_FORCE_RANK_BACTA,NUM_FORCE_POWERS+SK_BACTA,0,qfalse,0},
- {1,UI_FORCE_RANK_FLAMETHROWER,NUM_FORCE_POWERS+SK_FLAMETHROWER,0,qfalse,0},
- {3,UI_FORCE_RANK_BOWCASTER,NUM_FORCE_POWERS+SK_BOWCASTER,0,qfalse,0},
- {1,UI_FORCE_RANK_FORCEFIELD,NUM_FORCE_POWERS+SK_FORCEFIELD,0,qfalse,0},
- {1,UI_FORCE_RANK_CLOAK,NUM_FORCE_POWERS+SK_CLOAK,0,qfalse,0},
- {1,UI_FORCE_RANK_SEEKER,NUM_FORCE_POWERS+SK_SEEKER,0,qfalse,0},
- {1,UI_FORCE_RANK_SENTRY,NUM_FORCE_POWERS+SK_SENTRY,0,qfalse,0},
- {2,UI_FORCE_RANK_DETPACK,NUM_FORCE_POWERS+SK_DETPACK,0,qfalse,0},
- {3,UI_FORCE_RANK_REPEATER,NUM_FORCE_POWERS+SK_REPEATER,0,qfalse,0},
- {3,UI_FORCE_RANK_DISRUPTOR,NUM_FORCE_POWERS+SK_DISRUPTOR,0,qfalse,0},
- {1,UI_FORCE_RANK_BLUESTYLE,NUM_FORCE_POWERS+SK_BLUESTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_REDSTYLE,NUM_FORCE_POWERS+SK_REDSTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_PURPLESTYLE,NUM_FORCE_POWERS+SK_PURPLESTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_GREENSTYLE,NUM_FORCE_POWERS+SK_GREENSTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_DUALSTYLE,NUM_FORCE_POWERS+SK_DUALSTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_STAFFSTYLE,NUM_FORCE_POWERS+SK_STAFFSTYLE,0,qfalse,0},
- {1,UI_FORCE_RANK_REPEATERUPGRADE,NUM_FORCE_POWERS+SK_REPEATERUPGRADE,0,qfalse,0},
- {3,UI_FORCE_RANK_FLECHETTE,NUM_FORCE_POWERS+SK_FLECHETTE,0,qfalse,0},
- {1,UI_FORCE_RANK_BLASTERRATEOFFIRE,NUM_FORCE_POWERS+SK_BLASTERRATEOFFIREUPGRADE,0,qfalse,0}
- //Add new skills here
- };
- char *forcepowerDesc[NUM_FORCE_POWERS] =
- {
- "@MENUS_OF_EFFECT_JEDI_ONLY_NEFFECT",
- "@MENUS_DURATION_IMMEDIATE_NAREA",
- "@MENUS_DURATION_5_SECONDS_NAREA",
- "@MENUS_DURATION_INSTANTANEOUS",
- "@MENUS_INSTANTANEOUS_EFFECT_NAREA",
- "@MENUS_DURATION_VARIABLE_20",
- "@MENUS_DURATION_INSTANTANEOUS_NAREA",
- "@MENUS_OF_EFFECT_LIVING_PERSONS",
- "@MENUS_DURATION_VARIABLE_10",
- "@MENUS_DURATION_VARIABLE_NAREA",
- "@MENUS_DURATION_CONTINUOUS_NAREA",
- "@MENUS_OF_EFFECT_JEDI_ALLIES_NEFFECT",
- "@MENUS_EFFECT_JEDI_ALLIES_NEFFECT",
- "@MENUS_VARIABLE_NAREA_OF_EFFECT",
- "@MENUS_EFFECT_NAREA_OF_EFFECT",
- "@SP_INGAME_FORCE_SABER_OFFENSE_DESC",
- "@SP_INGAME_FORCE_SABER_DEFENSE_DESC",
- "@SP_INGAME_FORCE_SABER_THROW_DESC"
- };
- // Movedata Sounds
- typedef enum
- {
- MDS_NONE = 0,
- MDS_FORCE_JUMP,
- MDS_ROLL,
- MDS_SABER,
- MDS_MOVE_SOUNDS_MAX
- };
- typedef enum
- {
- MD_ACROBATICS = 0,
- MD_SINGLE_FAST,
- MD_SINGLE_MEDIUM,
- MD_SINGLE_STRONG,
- MD_DUAL_SABERS,
- MD_SABER_STAFF,
- MD_MOVE_TITLE_MAX
- };
- // Some hard coded badness
- // At some point maybe this should be externalized to a .dat file
- char *datapadMoveTitleData[MD_MOVE_TITLE_MAX] =
- {
- "@MENUS_ACROBATICS",
- "@MENUS_SINGLE_FAST",
- "@MENUS_SINGLE_MEDIUM",
- "@MENUS_SINGLE_STRONG",
- "@MENUS_DUAL_SABERS",
- "@MENUS_SABER_STAFF",
- };
- char *datapadMoveTitleBaseAnims[MD_MOVE_TITLE_MAX] =
- {
- "BOTH_RUN1",
- "BOTH_SABERFAST_STANCE",
- "BOTH_STAND2",
- "BOTH_SABERSLOW_STANCE",
- "BOTH_SABERDUAL_STANCE",
- "BOTH_SABERSTAFF_STANCE",
- };
- #define MAX_MOVES 16
- typedef struct
- {
- char *title;
- char *desc;
- char *anim;
- short sound;
- } datpadmovedata_t;
- static datpadmovedata_t datapadMoveData[MD_MOVE_TITLE_MAX][MAX_MOVES] =
- {
- // Acrobatics
- "@MENUS_FORCE_JUMP1", "@MENUS_FORCE_JUMP1_DESC", "BOTH_FORCEJUMP1", MDS_FORCE_JUMP,
- "@MENUS_FORCE_FLIP", "@MENUS_FORCE_FLIP_DESC", "BOTH_FLIP_F", MDS_FORCE_JUMP,
- "@MENUS_ROLL", "@MENUS_ROLL_DESC", "BOTH_ROLL_F", MDS_ROLL,
- "@MENUS_BACKFLIP_OFF_WALL", "@MENUS_BACKFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_BACK1", MDS_FORCE_JUMP,
- "@MENUS_SIDEFLIP_OFF_WALL", "@MENUS_SIDEFLIP_OFF_WALL_DESC", "BOTH_WALL_FLIP_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_WALL_RUN", "@MENUS_WALL_RUN_DESC", "BOTH_WALL_RUN_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_WALL_GRAB_JUMP", "@MENUS_WALL_GRAB_JUMP_DESC", "BOTH_FORCEWALLREBOUND_FORWARD",MDS_FORCE_JUMP,
- "@MENUS_RUN_UP_WALL_BACKFLIP", "@MENUS_RUN_UP_WALL_BACKFLIP_DESC", "BOTH_FORCEWALLRUNFLIP_START", MDS_FORCE_JUMP,
- "@MENUS_JUMPUP_FROM_KNOCKDOWN", "@MENUS_JUMPUP_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN3", MDS_NONE,
- "@MENUS_JUMPKICK_FROM_KNOCKDOWN", "@MENUS_JUMPKICK_FROM_KNOCKDOWN_DESC","BOTH_KNOCKDOWN2", MDS_NONE,
- "@MENUS_ROLL_FROM_KNOCKDOWN", "@MENUS_ROLL_FROM_KNOCKDOWN_DESC", "BOTH_KNOCKDOWN1", MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Fast Style
- "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
- "@MENUS_LUNGE_ATTACK", "@MENUS_LUNGE_ATTACK_DESC", "BOTH_LUNGE2_B__T_", MDS_SABER,
- "@MENUS_FAST_ATTACK_KATA", "@MENUS_FAST_ATTACK_KATA_DESC", "BOTH_A1_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Medium Style
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_FLIP_ATTACK", "@MENUS_FLIP_ATTACK_DESC", "BOTH_JUMPFLIPSLASHDOWN1", MDS_FORCE_JUMP,
- "@MENUS_MEDIUM_ATTACK_KATA", "@MENUS_MEDIUM_ATTACK_KATA_DESC", "BOTH_A2_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Single Saber, Strong Style
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_JUMP_ATTACK", "@MENUS_JUMP_ATTACK_DESC", "BOTH_FORCELEAP2_T__B_", MDS_FORCE_JUMP,
- "@MENUS_STRONG_ATTACK_KATA", "@MENUS_STRONG_ATTACK_KATA_DESC", "BOTH_A3_SPECIAL", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN", MDS_FORCE_JUMP,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- //Dual Sabers
- "@MENUS_SLASH_BACK", "@MENUS_SLASH_BACK_DESC", "BOTH_ATTACK_BACK", MDS_SABER,
- "@MENUS_FLIP_FORWARD_ATTACK", "@MENUS_FLIP_FORWARD_ATTACK_DESC", "BOTH_JUMPATTACK6", MDS_FORCE_JUMP,
- "@MENUS_DUAL_SABERS_TWIRL", "@MENUS_DUAL_SABERS_TWIRL_DESC", "BOTH_SPINATTACK6", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_DUAL", MDS_FORCE_JUMP,
- "@MENUS_DUAL_SABER_BARRIER", "@MENUS_DUAL_SABER_BARRIER_DESC", "BOTH_A6_SABERPROTECT", MDS_SABER,
- "@MENUS_DUAL_STAB_FRONT_BACK", "@MENUS_DUAL_STAB_FRONT_BACK_DESC", "BOTH_A6_FB", MDS_SABER,
- "@MENUS_DUAL_STAB_LEFT_RIGHT", "@MENUS_DUAL_STAB_LEFT_RIGHT_DESC", "BOTH_A6_LR", MDS_SABER,
- "@MENUS_CARTWHEEL", "@MENUS_CARTWHEEL_DESC", "BOTH_ARIAL_RIGHT", MDS_FORCE_JUMP,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- // Saber Staff
- "@MENUS_STAB_BACK", "@MENUS_STAB_BACK_DESC", "BOTH_A2_STABBACK1", MDS_SABER,
- "@MENUS_BACK_FLIP_ATTACK", "@MENUS_BACK_FLIP_ATTACK_DESC", "BOTH_JUMPATTACK7", MDS_FORCE_JUMP,
- "@MENUS_SABER_STAFF_TWIRL", "@MENUS_SABER_STAFF_TWIRL_DESC", "BOTH_SPINATTACK7", MDS_SABER,
- "@MENUS_ATTACK_ENEMYONGROUND", "@MENUS_ATTACK_ENEMYONGROUND_DESC", "BOTH_STABDOWN_STAFF", MDS_FORCE_JUMP,
- "@MENUS_SPINNING_KATA", "@MENUS_SPINNING_KATA_DESC", "BOTH_A7_SOULCAL", MDS_SABER,
- "@MENUS_KICK1", "@MENUS_KICK1_DESC", "BOTH_A7_KICK_F", MDS_FORCE_JUMP,
- "@MENUS_JUMP_KICK", "@MENUS_JUMP_KICK_DESC", "BOTH_A7_KICK_F_AIR", MDS_FORCE_JUMP,
- "@MENUS_BUTTERFLY_ATTACK", "@MENUS_BUTTERFLY_ATTACK_DESC", "BOTH_BUTTERFLY_FR1", MDS_SABER,
- "@MENUS_BOTH_ROLL_STAB", "@MENUS_BOTH_ROLL_STAB2_DESC", "BOTH_ROLL_STAB", MDS_SABER,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- NULL, NULL, 0, MDS_NONE,
- };
- /*
- ================
- vmMain
- This is the only way control passes into the module.
- !!! This MUST BE THE VERY FIRST FUNCTION compiled into the .qvm file !!!
- ================
- */
- vmCvar_t ui_debug;
- vmCvar_t ui_initialized;
- vmCvar_t ui_char_color_red;
- vmCvar_t ui_char_color_green;
- vmCvar_t ui_char_color_blue;
- vmCvar_t ui_PrecacheModels;
- vmCvar_t ui_char_anim;
- void _UI_Init( qboolean );
- void _UI_Shutdown( void );
- void _UI_KeyEvent( int key, qboolean down );
- void _UI_MouseEvent( int dx, int dy );
- void _UI_Refresh( int realtime );
- qboolean _UI_IsFullscreen( void );
- void UI_SetSiegeTeams(void);
- extern qboolean UI_SaberModelForSaber( const char *saberName, char *saberModel );
- void UI_SiegeSetCvarsForClass(siegeClass_t *scl);
- int UI_SiegeClassNum(siegeClass_t *scl);
- //[VS2005]
- //VS2005's C doesn't assume int type anymore.
- void UI_UpdateCvarsForClass(const int team,const int baseClass,const int index);
- //void UI_UpdateCvarsForClass(const int team,const baseClass,const int index);
- //[/VS2005]
- void UI_UpdateSiegeStatusIcons(void);
- void UI_ClampMaxPlayers(void);
- static void UI_CheckServerName( void );
- static qboolean UI_CheckPassword( void );
- static void UI_JoinServer( void );
- //[DynamicMemory_Sabers]
- void UI_AllocMem(void **ptr, int sze);
- void UI_FreeMem(void *ptr);
- void UI_ReaAllocMem(void **ptr, int sze, int count);
- char *UI_GetSaberHiltInfo(qboolean TwoHanded, int index);
- //[/DynamicMemory_Sabers]
- #include "../namespace_begin.h"
- // Functions in BG or ui_shared
- void Menu_ShowGroup (menuDef_t *menu, char *itemName, qboolean showFlag);
- void Menu_ItemDisable(menuDef_t *menu, char *name,int disableFlag);
- int Menu_ItemsMatchingGroup(menuDef_t *menu, const char *name);
- itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char *name);
- int BG_GetUIPortrait(const int team, const short classIndex, const short cntIndex);
- char *BG_GetUIPortraitFile(const int team, const short classIndex, const short cntIndex);
- siegeClass_t *BG_GetClassOnBaseClass(const int team, const short classIndex, const short cntIndex);
- int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
- char buffer[MAX_QPATH]="";//[AutoUpdate]
- switch ( command ) {
- case UI_GETAPIVERSION:
- return UI_API_VERSION;
- case UI_INIT:
-
- trap_Cvar_VariableStringBuffer("fs_basepath",buffer,sizeof(buffer));
- //system(va("%s\\ojpenhanced\\update.exe",buffer));//[AutoUpdate]
- _UI_Init(arg0);
- return 0;
- case UI_SHUTDOWN:
- _UI_Shutdown();
- return 0;
- case UI_KEY_EVENT:
- _UI_KeyEvent( arg0, arg1 );
- return 0;
- case UI_MOUSE_EVENT:
- _UI_MouseEvent( arg0, arg1 );
- return 0;
- case UI_REFRESH:
- _UI_Refresh( arg0 );
- return 0;
- case UI_IS_FULLSCREEN:
- return _UI_IsFullscreen();
- case UI_SET_ACTIVE_MENU:
- _UI_SetActiveMenu( arg0 );
- return 0;
- case UI_CONSOLE_COMMAND:
- return UI_ConsoleCommand(arg0);
- case UI_DRAW_CONNECT_SCREEN:
- UI_DrawConnectScreen( arg0 );
- return 0;
- case UI_HASUNIQUECDKEY: // mod authors need to observe this
- return qtrue; // bk010117 - change this to qfalse for mods!
- case UI_MENU_RESET:
- Menu_Reset();
- return 0;
- }
- return -1;
- }
- #include "../namespace_end.h"
- siegeClassDesc_t g_UIClassDescriptions[MAX_SIEGE_CLASSES];
- siegeTeam_t *siegeTeam1 = NULL;
- siegeTeam_t *siegeTeam2 = NULL;
- int g_UIGloballySelectedSiegeClass = -1;
- //Cut down version of the stuff used in the game code
- //This is just the bare essentials of what we need to load animations properly for ui ghoul2 models.
- //This function doesn't need to be sync'd with the BG_ version in bg_panimate.c unless some sort of fundamental change
- //is made. Just make sure the variables/functions accessed in ui_shared.c exist in both modules.
- qboolean UIPAFtextLoaded = qfalse;
- animation_t uiHumanoidAnimations[MAX_TOTALANIMATIONS]; //humanoid animations are the only ones that are statically allocated.
- #include "../namespace_begin.h"
- bgLoadedAnim_t bgAllAnims[MAX_ANIM_FILES];
- int uiNumAllAnims = 1; //start off at 0, because 0 will always be assigned to humanoid.
- #include "../namespace_end.h"
- animation_t *UI_AnimsetAlloc(void)
- {
- assert (uiNumAllAnims < MAX_ANIM_FILES);
- bgAllAnims[uiNumAllAnims].anims = (animation_t *) BG_Alloc(sizeof(animation_t)*MAX_TOTALANIMATIONS);
- return bgAllAnims[uiNumAllAnims].anims;
- }
- //[SIEGECVARFIX]
- char *siege_Str(void) {
- static int cur;
- static char strings[1024][256];
- return strings[cur++];
- }
- /*
- ===============
- siege_Cvar_Set
- replacement for the trap to reduce cvar usage
- ===============
- */
- void siege_Cvar_Set( const char *cvarName, const char *value )
- {
- char **tmp;
- char ui_siegeInfo[MAX_STRING_CHARS];
- int i;
- if(!ui_siegeStruct)
- {
- trap_Cvar_VariableStringBuffer( "ui_siegeInfo", ui_siegeInfo, MAX_STRING_CHARS );
- sscanf(ui_siegeInfo,"%p",&ui_siegeStruct);
- if(!ui_siegeStruct) return;
- }
- for(tmp=ui_siegeStruct;*tmp;tmp+=2)
- {
- if(*tmp && !strcmp(*tmp,cvarName)) { //cvar already exists, overwrite existing value
- Q_strncpyz(*(tmp+1),value,256); //:nervou
- return;
- }
- }
- i = tmp - ui_siegeStruct;
- ui_siegeStruct[i] = siege_Str();
- Q_strncpyz( ui_siegeStruct[i], cvarName, 256 );
- ui_siegeStruct[i+1] = siege_Str();
- Q_strncpyz( ui_siegeStruct[i+1], value, 256 );
- ui_siegeStruct[i+2] = 0;
- return;
- }
- void siege_Cvar_VariableStringBuffer( char *var_name, char *buffer, int bufsize )
- {
- char **tmp;
- char ui_siegeInfo[MAX_STRING_CHARS];
- if(!ui_siegeStruct)
- {
- trap_Cvar_VariableStringBuffer( "ui_siegeInfo", ui_siegeInfo, MAX_STRING_CHARS );
- sscanf(ui_siegeInfo,"%p",&ui_siegeStruct);
- if(!ui_siegeStruct) return;
- }
- for(tmp=ui_siegeStruct;*tmp;tmp+=2)
- {
- if(*tmp && !strcmp(*tmp,var_name)) {
- Q_strncpyz(buffer,*(tmp+1),bufsize);
- return;
- }
- }
- trap_Cvar_VariableStringBuffer( var_name, buffer, bufsize );
- return;
- }
- int siege_Cvar_VariableValue( char *var_name )
- {
- char **tmp;
- char ui_siegeInfo[MAX_STRING_CHARS];
- if(!ui_siegeStruct)
- {
- trap_Cvar_VariableStringBuffer( "ui_siegeInfo", ui_siegeInfo, MAX_STRING_CHARS );
- sscanf(ui_siegeInfo,"%p",&ui_siegeStruct);
- if(!ui_siegeStruct) return trap_Cvar_VariableValue( var_name );
- }
- for(tmp=ui_siegeStruct;*tmp;tmp+=2)
- {
- if(*tmp && !strcmp(*tmp,var_name)) {
- return atoi(*(tmp+1));
- }
- }
- return trap_Cvar_VariableValue( var_name );
- }
- //[/SIEGECVARFIX]
- /*
- ======================
- UI_ParseAnimationFile
- Read a configuration file containing animation coutns and rates
- models/players/visor/animation.cfg, etc
- ======================
- */
- #include "../namespace_begin.h"
- static char UIPAFtext[60000];
- int UI_ParseAnimationFile(const char *filename, animation_t *animset, qboolean isHumanoid)
- {
- char *text_p;
- int len;
- int i;
- char *token;
- float fps;
- int skip;
- int usedIndex = -1;
- int nextIndex = uiNumAllAnims;
- fileHandle_t f;
- int animNum;
- if (!isHumanoid)
- {
- i = 1;
- while (i < uiNumAllAnims)
- { //see if it's been loaded already
- if (!Q_stricmp(bgAllAnims[i].filename, filename))
- {
- animset = bgAllAnims[i].anims;
- return i; //alright, we already have it.
- }
- i++;
- }
- //Looks like it has not yet been loaded. Allocate space for the anim set if we need to, and continue along.
- if (!animset)
- {
- if (strstr(filename, "players/_humanoid/"))
- { //then use the static humanoid set.
- animset = uiHumanoidAnimations;
- isHumanoid = qtrue;
- nextIndex = 0;
- }
- else
- {
- animset = UI_AnimsetAlloc();
- if (!animset)
- {
- assert(!"Anim set alloc failed!");
- return -1;
- }
- }
- }
- }
- #ifdef _DEBUG
- else
- {
- assert(animset);
- }
- #endif
- // load the file
- if (!UIPAFtextLoaded || !isHumanoid)
- { //rww - We are always using the same animation config now. So only load it once.
- len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( (len <= 0) || (len >= sizeof( UIPAFtext ) - 1) )
- {
- if (len > 0)
- {
- Com_Error(ERR_DROP, "%s exceeds the allowed ui-side animation buffer!", filename);
- }
- return -1;
- }
- trap_FS_Read( UIPAFtext, len, f );
- UIPAFtext[len] = 0;
- trap_FS_FCloseFile( f );
- }
- else
- {
- return 0; //humanoid index
- }
- // parse the text
- text_p = UIPAFtext;
- skip = 0; // quiet the compiler warning
- //FIXME: have some way of playing anims backwards... negative numFrames?
- //initialize anim array so that from 0 to MAX_ANIMATIONS, set default values of 0 1 0 100
- for(i = 0; i < MAX_ANIMATIONS; i++)
- {
- animset[i].firstFrame = 0;
- animset[i].numFrames = 0;
- animset[i].loopFrames = -1;
- animset[i].frameLerp = 100;
- // animset[i].initialLerp = 100;
- }
- // read information for each frame
- while(1)
- {
- token = COM_Parse( (const char **)(&text_p) );
- if ( !token || !token[0])
- {
- break;
- }
- animNum = GetIDForString(animTable, token);
- if(animNum == -1)
- {
- //#ifndef FINAL_BUILD
- #ifdef _DEBUG
- //Com_Printf(S_COLOR_RED"WARNING: Unknown token %s in %s\n", token, filename);
- #endif
- continue;
- }
- token = COM_Parse( (const char **)(&text_p) );
- if ( !token[0] ) //[TicketFix143]
- {
- break;
- }
- animset[animNum].firstFrame = atoi( token );
- token = COM_Parse( (const char **)(&text_p) );
- if ( !token[0] ) //[TicketFix143]
- {
- break;
- }
- animset[animNum].numFrames = atoi( token );
- token = COM_Parse( (const char **)(&text_p) );
- if ( !token[0] ) //[TicketFix143]
- {
- break;
- }
- animset[animNum].loopFrames = atoi( token );
- token = COM_Parse( (const char **)(&text_p) );
- if ( !token[0] ) //[TicketFix143]
- {
- break;
- }
- fps = atof( token );
- if ( fps == 0 )
- {
- fps = 1;//Don't allow divide by zero error
- }
- if ( fps < 0 )
- {//backwards
- animset[animNum].frameLerp = floor(1000.0f / fps);
- }
- else
- {
- animset[animNum].frameLerp = ceil(1000.0f / fps);
- }
- // animset[animNum].initialLerp = ceil(1000.0f / fabs(fps));
- }
- #ifdef _DEBUG
- //Check the array, and print the ones that have nothing in them.
- /*
- for(i = 0; i < MAX_ANIMATIONS; i++)
- {
- if (animTable[i].name != NULL) // This animation reference exists.
- {
- if (animset[i].firstFrame <= 0 && animset[i].numFrames <=0)
- { // This is an empty animation reference.
- Com_Printf("***ANIMTABLE reference #%d (%s) is empty!\n", i, animTable[i].name);
- }
- }
- }
- */
- #endif // _DEBUG
- if (isHumanoid)
- {
- bgAllAnims[0].anims = animset;
- strcpy(bgAllAnims[0].filename, filename);
- UIPAFtextLoaded = qtrue;
- usedIndex = 0;
- }
- else
- {
- bgAllAnims[nextIndex].anims = animset;
- strcpy(bgAllAnims[nextIndex].filename, filename);
- usedIndex = nextIndex;
- if (nextIndex)
- { //don't bother increasing the number if this ended up as a humanoid load.
- uiNumAllAnims++;
- }
- else
- {
- UIPAFtextLoaded = qtrue;
- usedIndex = 0;
- }
- }
- return usedIndex;
- }
- //menuDef_t *Menus_FindByName(const char *p);
- void Menu_ShowItemByName(menuDef_t *menu, const char *p, qboolean bShow);
- #include "../namespace_end.h"
- void UpdateForceUsed();
- char holdSPString[MAX_STRING_CHARS]={0};
- char holdSPString2[MAX_STRING_CHARS]={0};
- uiInfo_t uiInfo;
- static void UI_StartServerRefresh(qboolean full);
- static void UI_StopServerRefresh( void );
- static void UI_DoServerRefresh( void );
- static void UI_BuildServerDisplayList(qboolean force);
- static void UI_BuildServerStatus(qboolean force);
- static void UI_BuildFindPlayerList(qboolean force);
- static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 );
- static int UI_MapCountByGameType(qboolean singlePlayer);
- static int UI_HeadCountByColor( void );
- static void UI_ParseGameInfo(const char *teamFile);
- static const char *UI_SelectedMap(int index, int *actual);
- static int UI_GetIndexFromSelection(int actual);
- static void UI_SiegeClassCnt( const int team );
- int ProcessNewUI( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6 );
- int uiSkinColor=TEAM_FREE;
- int uiHoldSkinColor=TEAM_FREE; // Stores the skin color so that in non-team games, the player screen remembers the team you chose, in case you're coming back from the force powers screen.
- static const serverFilter_t serverFilters[] = {
- //[SERVERFILTERS]
- //since OJP Enhanced only works with OJP Enhanced servers, only show them.
- {"OJP_MENUS_OJP_ENHANCED", "ojpenhanced"},
- //{"MENUS_ALL", "" },
- //{"MENUS_JEDI_ACADEMY", "" },
- //[/SERVERFILTERS]
- };
- static const int numServerFilters = sizeof(serverFilters) / sizeof(serverFilter_t);
- static const char *skillLevels[] = {
- "SKILL1",//"I Can Win",
- "SKILL2",//"Bring It On",
- "SKILL3",//"Hurt Me Plenty",
- "SKILL4",//"Hardcore",
- "SKILL5"//"Nightmare"
- };
- static const int numSkillLevels = sizeof(skillLevels) / sizeof(const char*);
- static const char *teamArenaGameTypes[] = {
- "FFA",
- "Holocron",
- "JediMaster",
- "Duel",
- "PowerDuel",
- "SP",
- "Team FFA",
- "Siege",
- "CTF",
- "CTY",
- "TeamTournament"
- };
- static int const numTeamArenaGameTypes = sizeof(teamArenaGameTypes) / sizeof(const char*);
- static char* netnames[] = {
- "???",
- "UDP",
- "IPX",
- NULL
- };
- static int gamecodetoui[] = {4,2,3,0,5,1,6};
- static int uitogamecode[] = {4,6,2,3,1,5,7};
- const char *UI_GetStringEdString(const char *refSection, const char *refName);
- const char *UI_TeamName(int team) {
- if (team==TEAM_RED)
- return "RED";
- else if (team==TEAM_BLUE)
- return "BLUE";
- else if (team==TEAM_SPECTATOR)
- return "SPECTATOR";
- return "FREE";
- }
- // returns either string or NULL for OOR...
- //
- static const char *GetCRDelineatedString( const char *psStripFileRef, const char *psStripStringRef, int iIndex)
- {
- static char sTemp[256];
- const char *psList = UI_GetStringEdString(psStripFileRef, psStripStringRef);
- char *p;
- while (iIndex--)
- {
- psList = strchr(psList,'\n');
- if (!psList){
- return NULL; // OOR
- }
- psList++;
- }
- strcpy(sTemp,psList);
- p = strchr(sTemp,'\n');
- if (p) {
- *p = '\0';
- }
- return sTemp;
- }
- static const char *GetMonthAbbrevString( int iMonth )
- {
- const char *p = GetCRDelineatedString("MP_INGAME","MONTHS", iMonth);
-
- return p ? p : "Jan"; // sanity
- }
- /*
- static const char *netSources[] = {
- "Local",
- "Internet",
- "Favorites"
- // "Mplayer"
- };
- static const int numNetSources = sizeof(netSources) / sizeof(const char*);
- */
- static const int numNetSources = 3; // now hard-entered in StringEd file
- static const char *GetNetSourceString(int iSource)
- {
- const char *p = GetCRDelineatedString("MP_INGAME","NET_SOURCES", iSource);
- return p ? p : "??";
- }
- void AssetCache() {
- int n;
- //if (Assets.textFont == NULL) {
- //}
- //Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND );
- //Com_Printf("Menu Size: %i bytes\n", sizeof(Menus));
- uiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );
- uiInfo.uiDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE );
- uiInfo.uiDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED );
- uiInfo.uiDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_ORANGE );//trap_R_RegisterShaderNoMip( ART_FX_YELLOW );
- uiInfo.uiDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW );//trap_R_RegisterShaderNoMip( ART_FX_GREEN );
- uiInfo.uiDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_GREEN );//trap_R_RegisterShaderNoMip( ART_FX_TEAL );
- uiInfo.uiDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE );
- uiInfo.uiDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_PURPLE );//trap_R_RegisterShaderNoMip( ART_FX_CYAN );
- uiInfo.uiDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE );
- uiInfo.uiDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
- uiInfo.uiDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
- uiInfo.uiDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
- uiInfo.uiDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
- uiInfo.uiDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
- uiInfo.uiDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
- uiInfo.uiDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );
- uiInfo.uiDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );
- // Icons for various server settings.
- uiInfo.uiDC.Assets.needPass = trap_R_RegisterShaderNoMip( "gfx/menus/needpass" );
- uiInfo.uiDC.Assets.noForce = trap_R_RegisterShaderNoMip( "gfx/menus/noforce" );
- uiInfo.uiDC.Assets.forceRestrict = trap_R_RegisterShaderNoMip( "gfx/menus/forcerestrict" );
- uiInfo.uiDC.Assets.saberOnly = trap_R_RegisterShaderNoMip( "gfx/menus/saberonly" );
- uiInfo.uiDC.Assets.trueJedi = trap_R_RegisterShaderNoMip( "gfx/menus/truejedi" );
-
- for( n = 0; n < NUM_CROSSHAIRS; n++ ) {
- uiInfo.uiDC.Assets.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) );
- }
- uiInfo.newHighScoreSound = 0;//trap_S_RegisterSound("sound/feedback/voc_newhighscore.wav");
- }
- void _UI_DrawSides(float x, float y, float w, float h, float size) {
- size *= uiInfo.uiDC.xscale;
- trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- }
- void _UI_DrawTopBottom(float x, float y, float w, float h, float size) {
- size *= uiInfo.uiDC.yscale;
- trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- trap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader );
- }
- /*
- ================
- UI_DrawRect
- Coordinates are 640*480 virtual values
- =================
- */
- void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color ) {
- trap_R_SetColor( color );
- _UI_DrawTopBottom(x, y, width, height, size);
- _UI_DrawSides(x, y, width, height, size);
- trap_R_SetColor( NULL );
- }
- #include "../namespace_begin.h"
- int MenuFontToHandle(int iMenuFont)
- {
- switch (iMenuFont)
- {
- case 1: return uiInfo.uiDC.Assets.qhSmallFont;
- case 2: return uiInfo.uiDC.Assets.qhMediumFont;
- case 3: return uiInfo.uiDC.Assets.qhBigFont;
- case 4: return uiInfo.uiDC.Assets.qhSmall2Font;
- }
- return uiInfo.uiDC.Assets.qhMediumFont; // 0;
- }
- #include "../namespace_end.h"
- int Text_Width(const char *text, float scale, int iMenuFont)
- {
- int iFontIndex = MenuFontToHandle(iMenuFont);
- return trap_R_Font_StrLenPixels(text, iFontIndex, scale);
- }
- int Text_Height(const char *text, float scale, int iMenuFont)
- {
- int iFontIndex = MenuFontToHandle(iMenuFont);
- return trap_R_Font_HeightPixels(iFontIndex, scale);
- }
- void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style, int iMenuFont)
- {
- int iStyleOR = 0;
- int iFontIndex = MenuFontToHandle(iMenuFont);
- //
- // kludge.. convert JK2 menu styles to SOF2 printstring ctrl codes...
- //
- switch (style)
- {
- case ITEM_TEXTSTYLE_NORMAL: iStyleOR = 0;break; // JK2 normal text
- case ITEM_TEXTSTYLE_BLINK: iStyleOR = (int)STYLE_BLINK;break; // JK2 fast blinking
- case ITEM_TEXTSTYLE_PULSE: iStyleOR = (int)STYLE_BLINK;break; // JK2 slow pulsing
- case ITEM_TEXTSTYLE_SHADOWED: iStyleOR = (int)STYLE_DROPSHADOW;break; // JK2 drop shadow
- case ITEM_TEXTSTYLE_OUTLINED: iStyleOR = (int)STYLE_DROPSHADOW;break; // JK2 drop shadow
- case ITEM_TEXTSTYLE_OUTLINESHADOWED: iStyleOR = (int)STYLE_DROPSHADOW;break; // JK2 drop shadow
- case ITEM_TEXTSTYLE_SHADOWEDMORE: iStyleOR = (int)STYLE_DROPSHADOW;break; // JK2 drop shadow
- }
- trap_R_Font_DrawString( x, // int ox
- y, // int oy
- text, // const char *text
- color, // paletteRGBA_c c
- iStyleOR | iFontIndex, // const int iFontHandle
- !limit?-1:limit, // iCharLimit (-1 = none)
- scale // const float scale = 1.0f
- );
- }
- void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style, int iMenuFont)
- {
- Text_Paint(x, y, scale, color, text, 0, limit, style, iMenuFont);
- // now print the cursor as well... (excuse the braces, it's for porting C++ to C)
- //
- {
- char sTemp[1024];
- int iCopyCount = limit ? min(strlen(text), limit) : strlen(text);
- iCopyCount = min(iCopyCount,cursorPos);
- iCopyCount = min(iCopyCount,sizeof(sTemp));
- // copy text into temp buffer for pixel measure...
- //
- strncpy(sTemp,text,iCopyCount);
- sTemp[iCopyCount] = '\0';
- {
- int iFontIndex = MenuFontToHandle( iMenuFont );
- int iNextXpos = trap_R_Font_StrLenPixels(sTemp, iFontIndex, scale );
- Text_Paint(x+iNextXpos, y, scale, color, va("%c",cursor), 0, limit, style|ITEM_TEXTSTYLE_BLINK, iMenuFont);
- }
- }
- }
- // maxX param is initially an X limit, but is also used as feedback. 0 = text was clipped to fit within, else maxX = next pos
- //
- static void Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit, int iMenuFont)
- {
- // this is kinda dirty, but...
- //
- int iFontIndex = MenuFontToHandle(iMenuFont);
-
- //float fMax = *maxX;
- int iPixelLen = trap_R_Font_StrLenPixels(text, iFontIndex, scale);
- if (x + iPixelLen > *maxX)
- {
- // whole text won't fit, so we need to print just the amount that does...
- // Ok, this is slow and tacky, but only called occasionally, and it works...
- //
- char sTemp[4096]={0}; // lazy assumption
- const char *psText = text;
- char *psOut = &sTemp[0];
- char *psOutLastGood = psOut;
- unsigned int uiLetter;
- while (*psText && (x + trap_R_Font_StrLenPixels(sTemp, iFontIndex, scale)<=*maxX)
- && psOut < &sTemp[sizeof(sTemp)-1] // sanity
- )
- {
- int iAdvanceCount;
- psOutLastGood = psOut;
-
- uiLetter = trap_AnyLanguage_ReadCharFromString(psText, &iAdvanceCount, NULL);
- psText += iAdvanceCount;
- if (uiLetter > 255)
- {
- *psOut++ = uiLetter>>8;
- *psOut++ = uiLetter&0xFF;
- }
- else
- {
- *psOut++ = uiLetter&0xFF;
- }
- }
- *psOutLastGood = '\0';
- *maxX = 0; // feedback
- Text_Paint(x, y, scale, color, sTemp, adjust, limit, ITEM_TEXTSTYLE_NORMAL, iMenuFont);
- }
- else
- {
- // whole text fits fine, so print it all...
- //
- *maxX = x + iPixelLen; // feedback the next position, as the caller expects
- Text_Paint(x, y, scale, color, text, adjust, limit, ITEM_TEXTSTYLE_NORMAL, iMenuFont);
- }
- }
- void UI_ShowPostGame(qboolean newHigh) {
- trap_Cvar_Set ("cg_cameraOrbit", "0");
- trap_Cvar_Set("cg_thirdPerson", "0");
- trap_Cvar_Set( "sv_killserver", "1" );
- uiInfo.soundHighScore = newHigh;
- _UI_SetActiveMenu(UIMENU_POSTGAME);
- }
- /*
- =================
- _UI_Refresh
- =================
- */
- void UI_DrawCenteredPic(qhandle_t image, int w, int h) {
- int x, y;
- x = (SCREEN_WIDTH - w) / 2;
- y = (SCREEN_HEIGHT - h) / 2;
- UI_DrawHandlePic(x, y, w, h, image);
- }
- int frameCount = 0;
- int startTime;
- vmCvar_t ui_rankChange;
- static void UI_BuildPlayerList();
- //[UITweaks]
- /* not used in basejka code
- //char parsedFPMessage[1024];
- #include "../namespace_begin.h"
- extern int FPMessageTime;
- #include "../namespace_end.h"
- */
- //[/UITweaks]
- void Text_PaintCenter(float x, float y, float scale, vec4_t color, const char *text, float adjust, int iMenuFont);
- const char *UI_GetStringEdString(const char *refSection, const char *refName)
- {
- static char text[1024]={0};
- trap_SP_GetStringTextString(va("%s_%s", refSection, refName), text, sizeof(text));
- return text;
- }
- #define UI_FPS_FRAMES 4
- void _UI_Refresh( int realtime )
- {
- static int index;
- static int previousTimes[UI_FPS_FRAMES];
- //if ( !( trap_Key_GetCatcher() & KEYCATCH_UI ) ) {
- // return;
- //}
- trap_G2API_SetTime(realtime, 0);
- trap_G2API_SetTime(realtime, 1);
- //ghoul2 timer must be explicitly updated during ui rendering.
- uiInfo.uiDC.frameTime = realtime - uiInfo.uiDC.realTime;
- uiInfo.uiDC.realTime = realtime;
- previousTimes[index % UI_FPS_FRAMES] = uiInfo.uiDC.frameTime;
- index++;
- if ( index > UI_FPS_FRAMES ) {
- int i, total;
- // average multiple frames together to smooth changes out a bit
- total = 0;
- for ( i = 0 ; i < UI_FPS_FRAMES ; i++ ) {
- total += previousTimes[i];
- }
- if ( !total ) {
- total = 1;
- }
- uiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total;
- }
- UI_UpdateCvars();
- if (Menu_Count() > 0) {
- // paint all the menus
- Menu_PaintAll();
- // refresh server browser list
- UI_DoServerRefresh();
- // refresh server status
- UI_BuildServerStatus(qfalse);
- // refresh find player list
- UI_BuildFindPlayerList(qfalse);
- }
- // draw cursor
- UI_SetColor( NULL );
- if (Menu_Count() > 0) {
- uiClientState_t cstate;
- trap_GetClientState( &cstate );
- if(cstate.connState <= CA_DISCONNECTED || cstate.connState >= CA_ACTIVE) {
- UI_DrawHandlePic( uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory, 48, 48, uiInfo.uiDC.Assets.cursor);
- }
- }
- #ifndef NDEBUG
- if (uiInfo.uiDC.debug)
- {
- // cursor coordinates
- //FIXME
- //UI_DrawString( 0, 0, va("(%d,%d)",uis.cursorx,uis.cursory), UI_LEFT|UI_SMALLFONT, colorRed );
- }
- #endif
- //[ExpSys]
- //only do this stuff when the your point total has changed.
- if (ui_rankChange.integer != uiMaxRank)
- //if (ui_rankChange.integer)
- //[/ExpSys]
- {
- //[UITweaks]
- //not used in basejka code
- /*
- FPMessageTime = realtime + 3000;
- if (!parsedFPMessage[0] /*&& uiMaxRank > ui_rankChange.integer*//*)
- {
- const char *printMessage = UI_GetStringEdString("MP_INGAME", "SET_NEW_RANK");
- int i = 0;
- int p = 0;
- int linecount = 0;
- while (printMessage[i] && p < 1024)
- {
- parsedFPMessage[p] = printMessage[i];
- p++;
- i++;
- linecount++;
- if (linecount > 64 && printMessage[i] == ' ')
- {
- parsedFPMessage[p] = '\n';
- p++;
- linecount = 0;
- }
- }
- parsedFPMessage[p] = '\0';
- }
- */
- //[/UITweaks]
- //if (uiMaxRank > ui_rankChange.integer)
- {
- uiMaxRank = ui_rankChange.integer;
- uiForceRank = uiMaxRank;
- /*
- while (x < NUM_FORCE_POWERS)
- {
- //For now just go ahead and clear force powers upon rank change
- uiRank[x].uiForcePowersRank = 0;
- x++;
- }
- uiRank[FP_LEVITATION].uiForcePowersRank = 1;
- uiForceUsed = 0;
- */
- //Use BG_LegalizedForcePowers and transfer the result into the UI force settings
- UI_ReadLegalForce();
- }
- if (ui_freeSaber.integer && uiRank[FP_SABER_OFFENSE].uiForcePowersRank < 1)
- {
- uiRank[FP_SABER_OFFENSE].uiForcePowersRank = 1;
- }
- if (ui_freeSaber.integer && uiRank[FP_SABER_DEFENSE].uiForcePowersRank < 1)
- {
- uiRank[FP_SABER_DEFENSE].uiForcePowersRank = 1;
- }
- //[ExpSys]
- //ui_rankChange is now treated like a variable rather than a message sender
- //trap_Cvar_Set("ui_rankChange", "0");
- //[/ExpSys]
- //remember to update the force power count after changing the max rank
- UpdateForceUsed();
- }
- if (ui_freeSaber.integer)
- {
- bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 0;
- bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 0;
- }
- else
- {
- //[ExpSys]
- //use defines since we're tweaking these values for the experience system.
- bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = SABER_OFFENSE_L1;
- bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = SABER_DEFENSE_L1;
- //bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 1;
- //bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 1;
- //[/ExpSys]
- }
- /*
- if (parsedFPMessage[0] && FPMessageTime > realtime)
- {
- vec4_t txtCol;
- int txtStyle = ITEM_TEXTSTYLE_SHADOWED;
- if ((FPMessageTime - realtime) < 2000)
- {
- txtCol[0] = colorWhite[0];
- txtCol[1] = colorWhite[1];
- txtCol[2] = colorWhite[2];
- txtCol[3] = (((float)FPMessageTime - (float)realtime)/2000);
- txtStyle = 0;
- }
- else
- {
- txtCol[0] = colorWhite[0];
- txtCol[1] = colorWhite[1];
- txtCol[2] = colorWhite[2];
- txtCol[3] = colorWhite[3];
- }
- Text_Paint(10, 0, 1, txtCol, parsedFPMessage, 0, 1024, txtStyle, FONT_MEDIUM);
- }
- */
- //For now, don't bother.
- }
- /*
- =================
- _UI_Shutdown
- =================
- */
- #include "../namespace_begin.h"
- void UI_CleanupGhoul2(void);
- #include "../namespace_end.h"
- //[DynamicMemory_Sabers]
- void UI_FreeSabers(void);
- //[/DynamicMemory_Sabers]
- void _UI_Shutdown( void ) {
- trap_LAN_SaveCachedServers();
- UI_CleanupGhoul2();
- //[DynamicMemory_Sabers]
- UI_FreeSabers();
- //[/DynamicMemory_Sabers]
- }
- char *defaultMenu = NULL;
- char *GetMenuBuffer(const char *filename) {
- int len;
- fileHandle_t f;
- static char buf[MAX_MENUFILE];
- len = trap_FS_FOpenFile( filename, &f, FS_READ );
- if ( !f ) {
- trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) );
- return defaultMenu;
- }
- if ( len >= MAX_MENUFILE ) {
- trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", filename, len, MAX_MENUFILE ) );
- trap_FS_FCloseFile( f );
- return defaultMenu;
- }
- trap_FS_Read( buf, len, f );
- buf[len] = 0;
- trap_FS_FCloseFile( f );
- //COM_Compress(buf);
- return buf;
- }
- qboolean Asset_Parse(int handle) {
- pc_token_t token;
- if (!trap_PC_ReadToken(handle, &token))
- return qfalse;
- if (Q_stricmp(token.string, "{") != 0) {
- return qfalse;
- }
-
- while ( 1 ) {
- memset(&token, 0, sizeof(pc_token_t));
- if (!trap_PC_ReadToken(handle, &token))
- return qfalse;
- if (Q_stricmp(token.string, "}") == 0) {
- return qtrue;
- }
- // font
- if (Q_stricmp(token.string, "font") == 0) {
- int pointSize;
- if (!trap_PC_ReadToken(handle, &token) || !PC_Int_Parse(handle,&pointSize)) {
- return qfalse;
- }
- //trap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.textFont);
- uiInfo.uiDC.Assets.qhMediumFont = trap_R_RegisterFont(token.string);
- uiInfo.uiDC.Assets.fontRegistered = qtrue;
- continue;
- }
- if (Q_stricmp(token.string, "smallFont") == 0) {
- int pointSize;
- if (!trap_PC_ReadToken(handle, &token) || !PC_Int_Parse(handle,&pointSize)) {
- return qfalse;
- }
- //trap_R_RegisterFont(token, pointSize, &uiInfo.uiDC.Assets.smallFont);
- uiInfo.uiDC.Assets.qhSmallFont = trap_R_RegisterFont(token.string);
- continue;
- }
- if (Q_stricmp(token.string, "small2Font") == 0) {
- int pointSize;
- if (!trap_PC_ReadToken(handle, &token) || !PC_Int_Parse(handle,&pointSize)) {
- return qfalse;
- }
- //trap_R_RegisterFont(token, pointSize, &uiInfo.uiDC.Assets.smallFont);
- uiInfo.uiDC.Assets.qhSmall2Font = trap_R_RegisterFont(token.string);
- continue;
- }
- if (Q_stricmp(token.string, "bigFont") == 0) {
- int pointSize;
- if (!trap_PC_ReadToken(handle, &token) || !PC_Int_Parse(handle,&pointSize)) {
- return qfalse;
- }
- //trap_R_RegisterFont(token, pointSize, &uiInfo.uiDC.Assets.bigFont);
- uiInfo.uiDC.Assets.qhBigFont = trap_R_RegisterFont(token.string);
- continue;
- }
- if (Q_stricmp(token.string, "cursor") == 0)
- {
- if (!PC_String_Parse(handle, &uiInfo.uiDC.Assets.cursorStr))
- {
- Com_Printf(S_COLOR_YELLOW,"Bad 1st parameter for keyword 'cursor'");
- return qfalse;
- }
- uiInfo.uiDC.Assets.cursor = trap_R_RegisterShaderNoMip( uiInfo.uiDC.Assets.cursorStr);
- continue;
- }
- // gradientbar
- if (Q_stricmp(token.string, "gradientbar") == 0) {
- if (!trap_PC_ReadToken(handle, &token)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(token.string);
- continue;
- }
- // enterMenuSound
- if (Q_stricmp(token.string, "menuEnterSound") == 0) {
- if (!trap_PC_ReadToken(handle, &token)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuEnterSound = trap_S_RegisterSound( token.string );
- continue;
- }
- // exitMenuSound
- if (Q_stricmp(token.string, "menuExitSound") == 0) {
- if (!trap_PC_ReadToken(handle, &token)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuExitSound = trap_S_RegisterSound( token.string );
- continue;
- }
- // itemFocusSound
- if (Q_stricmp(token.string, "itemFocusSound") == 0) {
- if (!trap_PC_ReadToken(handle, &token)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.itemFocusSound = trap_S_RegisterSound( token.string );
- continue;
- }
- // menuBuzzSound
- if (Q_stricmp(token.string, "menuBuzzSound") == 0) {
- if (!trap_PC_ReadToken(handle, &token)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.menuBuzzSound = trap_S_RegisterSound( token.string );
- continue;
- }
- if (Q_stricmp(token.string, "fadeClamp") == 0) {
- if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeClamp)) {
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token.string, "fadeCycle") == 0) {
- if (!PC_Int_Parse(handle, &uiInfo.uiDC.Assets.fadeCycle)) {
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token.string, "fadeAmount") == 0) {
- if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeAmount)) {
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token.string, "shadowX") == 0) {
- if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowX)) {
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token.string, "shadowY") == 0) {
- if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowY)) {
- return qfalse;
- }
- continue;
- }
- if (Q_stricmp(token.string, "shadowColor") == 0) {
- if (!PC_Color_Parse(handle, &uiInfo.uiDC.Assets.shadowColor)) {
- return qfalse;
- }
- uiInfo.uiDC.Assets.shadowFadeClamp = uiInfo.uiDC.Assets.shadowColor[3];
- continue;
- }
- if (Q_stricmp(token.string, "moveRollSound") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.moveRollSound = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "moveJumpSound") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.moveJumpSound = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound1") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound1 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound2") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound2 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound3") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound3 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound4") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound4 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound5") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound5 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- if (Q_stricmp(token.string, "datapadmoveSaberSound6") == 0)
- {
- if (trap_PC_ReadToken(handle,&token))
- {
- uiInfo.uiDC.Assets.datapadmoveSaberSound6 = trap_S_RegisterSound( token.string );
- }
- continue;
- }
- // precaching various sound files used in the menus
- if (Q_stricmp(token.string, "precacheSound") == 0)
- {
- const char *tempStr;
- if (PC_Script_Parse(handle, &tempStr))
- {
- char *soundFile;
- do
- {
- soundFile = COM_ParseExt(&tempStr, qfalse);
- if (soundFile[0] != 0 && soundFile[0] != ';') {
- trap_S_RegisterSound( soundFile);
- }
- } while (soundFile[0]);
- }
- continue;
- }
- }
- return qfalse;
- }
- void UI_Report() {
- String_Report();
- //Font_Report();
- }
- void UI_ParseMenu(const char *menuFile) {
- int handle;
- pc_token_t token;
- //Com_Printf("Parsing menu file: %s\n", menuFile);
- handle = trap_PC_LoadSource(menuFile);
- if (!handle) {
- return;
- }
- while ( 1 ) {
- memset(&token, 0, sizeof(pc_token_t));
- if (!trap_PC_ReadToken( handle, &token )) {
- break;
- }
- //if ( Q_stricmp( token, "{" ) ) {
- // Com_Printf( "Missing { in menu file\n" );
- // break;
- //}
- //if ( menuCount == MAX_MENUS ) {
- // Com_Printf( "Too many menus!\n" );
- // break;
- //}
- if ( token.string[0] == '}' ) {
- break;
- }
- if (Q_stricmp(token.string, "assetGlobalDef") == 0) {
- if (Asset_Parse(handle)) {
- continue;
- } else {
- break;
- }
- }
- if (Q_stricmp(token.string, "menudef") == 0) {
- // start a new menu
- Menu_New(handle);
- }
- }
- trap_PC_FreeSource(handle);
- }
- //[CoOp]
- void UI_LoadSingleMenuFile(const char *menuFile)
- {//load in a single menu file
- trap_PC_LoadGlobalDefines ( "ui/jamp/menudef.h" ); //Load globaldefines for parsing.
- UI_ParseMenu(menuFile);
- trap_PC_RemoveAllGlobalDefines ( ); //Close globaldefines.
- }
- //[/CoOp]
- qboolean Load_Menu(int handle) {
- pc_token_t token;
- if (!trap_PC_ReadToken(handle, &token))
- return qfalse;
- if (token.string[0] != '{') {
- return qfalse;
- }
- while ( 1 ) {
- if (!trap_PC_ReadToken(handle, &token))
- return qfalse;
-
- if ( token.string[0] == 0 ) {
- return qfalse;
- }
- if ( token.string[0] == '}' ) {
- return qtrue;
- }
- UI_ParseMenu(token.string);
- }
- return qfalse;
- }
- void UI_LoadMenus(const char *menuFile, qboolean reset) {
- pc_token_t token;
- int handle;
- int start;
- start = trap_Milliseconds();
- trap_PC_LoadGlobalDefines ( "ui/jamp/menudef.h" );
- handle = trap_PC_LoadSource( menuFile );
- if (!handle) {
- Com_Printf( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile );
- handle = trap_PC_LoadSource( "ui/jampmenus.txt" );
-
- if (!handle) {
- trap_Error( va( S_COLOR_RED "default menu file not found: ui/menus.txt, unable to continue!\n", menuFile ) );
-
- }
-
- }
- if (reset) {
- Menu_Reset();
- }
- while ( 1 ) {
- if (!trap_PC_ReadToken(handle, &token))
- break;
- if( token.string[0] == 0 || token.string[0] == '}') {
- break;
- }
- if ( token.string[0] == '}' ) {
- break;
- }
- if (Q_stricmp(token.string, "loadmenu") == 0) {
- if (Load_Menu(handle)) {
- continue;
- } else {
- break;
- }
- }
- }
- // Com_Printf("UI menu load time = %d milli seconds\n", trap_Milliseconds() - start);
- trap_PC_FreeSource( handle );
- trap_PC_RemoveAllGlobalDefines ( );
- }
- void UI_Load() {
- char *menuSet;
- char lastName[1024];
- menuDef_t *menu = Menu_GetFocused();
- if (menu && menu->window.name) {
- strcpy(lastName, menu->window.name);
- }
- else
- {
- lastName[0] = 0;
- }
- if (uiInfo.inGameLoad)
- {
- menuSet= "ui/jampingame.txt";
- }
- else
- {
- menuSet= UI_Cvar_VariableString("ui_menuFilesMP");
- }
- if (menuSet == NULL || menuSet[0] == '\0') {
- menuSet = "ui/jampmenus.txt";
- }
- String_Init();
- #ifdef PRE_RELEASE_TADEMO
- UI_ParseGameInfo("demogameinfo.txt");
- #else
- UI_ParseGameInfo("ui/jamp/gameinfo.txt");
- #endif
- UI_LoadArenas();
- UI_LoadBots();
- UI_LoadMenus(menuSet, qtrue);
- Menus_CloseAll();
- Menus_ActivateByName(lastName);
- }
- static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL};
- static void UI_DrawHandicap(rectDef_t *rect, float scale, vec4_t color, int textStyle, int iMenuFont) {
- int i, h;
- h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") );
- i = 20 - h / 5;
- Text_Paint(rect->x, rect->y, scale, color, handicapValues[i], 0, 0, textStyle, iMenuFont);
- }
- static void UI_DrawClanName(rectDef_t *rect, float sca…
Large files files are truncated, but you can click here to view the full file