void PartyMngt_Script_DialogButton(char **args) { int button; if (!Int_Parse(args, &button)) { return; } if (button < PDLGRESP_OK || button > PDLGRESP_CANCEL) { // Invalid button return; } if (PDlgData.InUse) { if (PDlgData.type == PDLG_TEXT) { menuDef_t *menu; itemDef_t *item; menu = Menus_FindByName("jkg_partymanagement"); if (menu) { item = Menu_FindItemByName(menu, "dlg_textentry"); if (item) { (*PDlgData.callback)(button, item->typeData.edit->buffer); return; } } (*PDlgData.callback)(button, ""); } else { (*PDlgData.callback)(button, NULL); } } }
int Interface_GetMenu( lua_State *L ) { int arg1Type = lua_type( L, 1 ); if ( arg1Type == LUA_TNUMBER ) { menuDef_t *menu = Menus_FindByID( luaL_checkinteger( L, 1 ) ); if ( menu ) { Menu_CreateRef( L, menu ); } else { lua_pushnil( L ); } } else if ( arg1Type == LUA_TSTRING ) { menuDef_t *menu = Menus_FindByName( lua_tostring( L, 1) ); if ( menu ) { Menu_CreateRef( L, menu ); } else { lua_pushnil( L ); } } else { lua_pushnil( L ); } return 1; }
void JKG_Slice_Script_OnEsc(char **args) { menuDef_t *menu; menu = Menus_FindByName("jkg_slice"); if (!menu) { // wtf? return; } // The escape button was pressed, see if we're currently displaying a dialog if (sliceData.dlgActive) { // Yes we are, check the type and process it if (sliceData.dlgType != DLGTYPE_BLANK) { if (sliceData.dlgid == DLGID_SERVER) { cgImports->SendClientCommand("~slc dlgresp 0"); } JKG_Slice_Dialog_Close(); } } else { // No dialogs are up, see if we're trying to run a program if (sliceData.inputState != INPUTSTATE_NORMAL) { // Abort the program sliceData.inputState = INPUTSTATE_NORMAL; Menu_ItemDisable(menu, "btn_stopslicing", 0); Menu_SetItemText(menu, "btn_runprogram", "Run program"); Menu_ItemDisable(menu, "proglist", 0); Menu_SetItemText(menu, "progdesc", sliceData.programs[sliceData.selectedProgram].desc); } else { // Bring up the stop slicing dialog JKG_Slice_Dialog_Show("Are you sure you wish to stop slicing?", NULL, NULL, DLGTYPE_YESNO, DLGID_STOPSLICING); } } }
void Menu_FadeMenuByName(const char *p, qboolean *bAbort, qboolean fadeOut) { menuDef_t *menu = Menus_FindByName(p); if (menu) { int i; itemDef_t *item; for (i = 0; i < menu->itemCount; i++) { item = menu->items[i]; if (fadeOut) { item->window.flags |= (WINDOW_FADINGOUT | WINDOW_VISIBLE); item->window.flags &= ~WINDOW_FADINGIN; } else { item->window.flags |= (WINDOW_VISIBLE | WINDOW_FADINGIN); item->window.flags &= ~WINDOW_FADINGOUT; } } } }
void Script_SetMenuItemColor(itemDef_t *item, qboolean *bAbort, char **args) { const char *menuname = NULL; const char *itemname = NULL; const char *name = NULL; // expecting type of color to set and 4 args for the color if (String_Parse(args, &menuname) && String_Parse(args, &itemname) && String_Parse(args, &name)) { menuDef_t *menu = Menus_FindByName(menuname); itemDef_t *item2; vec4_t color; vec4_t *out; int j, i; int count; if (!menu) { return; } count = Menu_ItemsMatchingGroup(menu, itemname); if (!Color_Parse(args, &color)) { return; } for (j = 0; j < count; j++) { item2 = Menu_GetMatchingItemByNumber(menu, j, itemname); if (item2 != NULL) { out = NULL; if (Q_stricmp(name, "backcolor") == 0) { out = &item2->window.backColor; } else if (Q_stricmp(name, "forecolor") == 0) { out = &item2->window.foreColor; item2->window.flags |= WINDOW_FORECOLORSET; } else if (Q_stricmp(name, "bordercolor") == 0) { out = &item2->window.borderColor; } if (out) { for (i = 0; i < 4; i++) { (*out)[i] = color[i]; } } } } } }
void JKG_Shop_UpdateNotify(int msg) { menuDef_t* menu = Menus_FindByName("jkg_shop"); if (menu && Menus_ActivateByName("jkg_shop")) { JKG_ConstructShopLists(); trap->Key_SetCatcher( trap->Key_GetCatcher() | KEYCATCH_UI ); } }
void Menus_ShowByName(const char *p) { menuDef_t *menu = Menus_FindByName(p); if (menu) { Menus_Activate(menu); } }
/* ======================== 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 ); }
qboolean JKG_Slice_ProgramSelection(int index) { menuDef_t *menu; sliceData.selectedProgram = index; menu = Menus_FindByName("jkg_slice"); if (menu) { Menu_SetItemText(menu, "progdesc", sliceData.programs[index].desc); } return qtrue; }
void JKG_Slice_Script_RunProgram(char **args) { menuDef_t *menu; menu = Menus_FindByName("jkg_slice"); if (!menu) { // wtf? return; } if (sliceData.selectedProgram == -1) { return; } if (sliceData.inputState != INPUTSTATE_NORMAL) { // Abort program sliceData.inputState = INPUTSTATE_NORMAL; Menu_ItemDisable(menu, "btn_stopslicing", 0); Menu_SetItemText(menu, "btn_runprogram", "Run program"); Menu_ItemDisable(menu, "proglist", 0); Menu_SetItemText(menu, "progdesc", sliceData.programs[sliceData.selectedProgram].desc); return; } switch (sliceData.programs[sliceData.selectedProgram].type) { case PROGTYPE_NORMAL: cgImports->SendClientCommand(va("~slc runprog %s", sliceData.programs[sliceData.selectedProgram].ID)); break; case PROGTYPE_NODE: sliceData.inputState = INPUTSTATE_AWAITINGNODE; Menu_ItemDisable(menu, "btn_stopslicing", 1); Menu_SetItemText(menu, "btn_runprogram", "Abort program"); Menu_ItemDisable(menu, "proglist", 1); Menu_SetItemText(menu, "progdesc", "Please choose a node to run this program on"); break; case PROGTYPE_INACTIVENODE: sliceData.inputState = INPUTSTATE_AWAITINGINACTIVENODE; Menu_ItemDisable(menu, "btn_stopslicing", 1); Menu_SetItemText(menu, "btn_runprogram", "Abort program"); Menu_ItemDisable(menu, "proglist", 1); Menu_SetItemText(menu, "progdesc", "Please choose an inactive node to run this program on"); break; case PROGTYPE_LINE: sliceData.inputState = INPUTSTATE_AWAITINGLINE; Menu_ItemDisable(menu, "btn_stopslicing", 1); Menu_SetItemText(menu, "btn_runprogram", "Abort program"); Menu_ItemDisable(menu, "proglist", 1); Menu_SetItemText(menu, "progdesc", "Please choose a row or column to run this program on"); break; } }
static void JKG_PartyMngt_UpdateSeekers() { // Updates team state (invites/team members) teamPartyList_t *list; uiClientState_t cs; menuDef_t *menu; char buff[1024]; int i; int j=0; menu = Menus_FindByName("jkg_partymanagement"); if (!menu) { return; } trap->GetClientState( &cs ); list = (teamPartyList_t *)cgImports->PartyMngtDataRequest(PARTYREQUEST_SEEKERS); if (!list) { return; } PMngtData.seekerListPending = 0; PMngtData.amSeeker = 0; for (i=0; i<PARTY_SLOT_MAX; i++) { if (list[i].id == PARTY_SLOT_EMPTY) { continue; } PMngtData.partySeeker[j].id = list[i].id; if (list[i].id == cs.clientNum) { PMngtData.amSeeker = 1; } trap->GetConfigString(CS_PLAYERS + list[i].id, buff, sizeof(buff)); Q_strncpyz(PMngtData.partySeeker[j].playerName, Info_ValueForKey(buff, "n"), 64); Q_strncpyz(PMngtData.partySeeker[j].message, list[i].message, 64); Q_strncpyz(PMngtData.partySeeker[j].playerClass, "N/A", 64); j++; } PMngtData.partySeekers = j; if (!PMngtData.inParty) { // If we're in a party, the other function will have taken care of the button here // So only change it if we're not in a party Menu_ShowItemByName(menu, "btn_bottom", qfalse); if (PMngtData.amSeeker) { Menu_ShowItemByName(menu, "btn_removefromlist", qtrue); } else { Menu_ShowItemByName(menu, "btn_addtolist", qtrue); } } }
void Script_SetMenuFocus(itemDef_t *item, qboolean *bAbort, char **args) { const char *name; if (String_Parse(args, &name)) { menuDef_t *focusMenu = Menus_FindByName(name); if (focusMenu && !(focusMenu->window.flags & WINDOW_HASFOCUS)) { Menu_ClearFocus(item->parent); focusMenu->window.flags |= WINDOW_HASFOCUS; } } }
static void JKG_Slice_Dialog_Show(const char *line1, const char *line2, const char *line3, int type, int dlgid) { menuDef_t *menu; sliceData.dlgActive = qtrue; if (line1) { Q_strncpyz(&sliceData.dlgText1[0], line1, 255); } else { sliceData.dlgText1[0] = 0; } if (line2) { Q_strncpyz(&sliceData.dlgText2[0], line2, 255); } else { sliceData.dlgText2[0] = 0; } if (line3) { Q_strncpyz(&sliceData.dlgText3[0], line3, 255); } else { sliceData.dlgText3[0] = 0; } sliceData.dlgType = type; sliceData.dlgid = dlgid; menu = Menus_FindByName("jkg_slice"); if (!menu) { return; } // First, disable all controls on the interface Menu_ItemDisable(menu, "grid", 1); Menu_ItemDisable(menu, "prog", 1); Menu_ItemDisable(menu, "btns", 1); Menu_ClearFocus(menu); Menu_ShowItemByName(menu, "dialog", qtrue); if (type == DLGTYPE_OK) { Menu_ShowItemByName(menu, "btn_dialogok", qtrue); } else if (type == DLGTYPE_YESNO) { Menu_ShowItemByName(menu, "btn_dialogyesno", qtrue); } }
void JKG_Slice_ProgramListReset() { menuDef_t *menu; itemDef_t *item; listBoxDef_t *listPtr; menu = Menus_FindByName("jkg_slice"); if (!menu) return; item = Menu_FindItemByName(menu, "proglist"); item->cursorPos = -1; listPtr = item->typeData.listbox; listPtr->cursorPos = -1; Menu_SetItemText(menu, "progdesc", "Please select a program"); }
void JKG_Slice_ProgramSetParameter(int param) { menuDef_t *menu; itemDef_t *item; cgImports->SendClientCommand(va("~slc runprog %s %i", sliceData.programs[sliceData.selectedProgram].ID, param)); sliceData.inputState = 0; menu = Menus_FindByName("jkg_slice"); if (!menu) return; item = Menu_FindItemByName(menu, "proglist"); item->disabled = qfalse; Menu_SetItemText(menu, "progdesc", sliceData.programs[sliceData.selectedProgram].desc); Menu_SetItemText(menu, "btn_runprogram", "Run program"); }
static void JKG_Slice_Dialog_Close() { menuDef_t *menu; sliceData.dlgActive = 0; menu = Menus_FindByName("jkg_slice"); if (!menu) { return; } Menu_ShowItemByName(menu, "dialog", qfalse); Menu_ShowItemByName(menu, "btn_dialogok", qfalse); Menu_ShowItemByName(menu, "btn_dialogyesno", qfalse); Menu_ItemDisable(menu, "grid", 0); Menu_ItemDisable(menu, "prog", 0); Menu_ItemDisable(menu, "btns", 0); Menu_ClearFocus(menu); }
void Menus_CloseByName(const char *p) { menuDef_t *menu = Menus_FindByName(p); if (menu != NULL) { int i; // Gordon: make sure no edit fields are left hanging for (i = 0; i < menu->itemCount; i++) { if (g_editItem == menu->items[i]) { g_editingField = qfalse; g_editItem = NULL; } } menu->cursorItem = -1; Menu_ClearFocus(menu); Menu_RunCloseScript(menu); menu->window.flags &= ~(WINDOW_VISIBLE | WINDOW_HASFOCUS | WINDOW_MOUSEOVER); if (menu->window.flags & WINDOW_MODAL) { if (modalMenuCount <= 0) { Com_Printf(S_COLOR_YELLOW "WARNING: tried closing a modal window with an empty modal stack!\n"); } else { modalMenuCount--; // if modal doesn't have a parent, the stack item may be NULL .. just go back to the main menu then if (modalMenuStack[modalMenuCount]) { Menus_ActivateByName(modalMenuStack[modalMenuCount]->window.name, qfalse); // don't try to push the one we are opening to the stack } } } } }
static void PartyMngt_Dialog_Close() { menuDef_t *menu; PDlgData.InUse = 0; menu = Menus_FindByName("jkg_partymanagement"); if (!menu) { return; } Menu_ShowItemByName(menu, "dialog", qfalse); Menu_ShowItemByName(menu, "btn_dialogok", qfalse); Menu_ShowItemByName(menu, "btn_dialogyesno", qfalse); Menu_ShowItemByName(menu, "btn_dialogtext", qfalse); Menu_ItemDisable(menu, "list", 0); Menu_ItemDisable(menu, "btn_noparty", 0); Menu_ItemDisable(menu, "btn_inparty", 0); Menu_ItemDisable(menu, "btn_inpartylead", 0); Menu_ItemDisable(menu, "btn_bottom", 0); Menu_ClearFocus(menu); }
void Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name) { if (menu == NULL) { if (name == NULL) { menu = Menu_GetFocused(); } else { menu = Menus_FindByName(name); } } if (menu) { int i; for (i = 0; i < menu->itemCount; i++) { if (menu->items[i]->special == feeder) { if (index == 0) { listBoxDef_t *listPtr = (listBoxDef_t *)menu->items[i]->typeData; listPtr->cursorPos = 0; listPtr->startPos = 0; } menu->items[i]->cursorPos = index; DC->feederSelection(menu->items[i]->special, menu->items[i]->cursorPos); return; } } } }
static void PartyMngt_Dialog_Show(const char *line1, const char *line2, const char *line3, int type, PDlgCallback callback) { menuDef_t *menu; itemDef_t *item; if (!callback) { return; } PDlgData.InUse = 1; if (line1) { Q_strncpyz(&PDlgData.line1[0], line1, 255); } else { PDlgData.line1[0] = 0; } if (line2) { Q_strncpyz(&PDlgData.line2[0], line2, 255); } else { PDlgData.line2[0] = 0; } if (line3) { Q_strncpyz(&PDlgData.line3[0], line3, 255); } else { PDlgData.line3[0] = 0; } PDlgData.type = type; PDlgData.callback = callback; menu = Menus_FindByName("jkg_partymanagement"); if (!menu) { return; } // First, disable all controls on the interface Menu_ItemDisable(menu, "list", 1); Menu_ItemDisable(menu, "btn_noparty", 1); Menu_ItemDisable(menu, "btn_inparty", 1); Menu_ItemDisable(menu, "btn_inpartylead", 1); Menu_ItemDisable(menu, "btn_bottom", 1); Menu_ClearFocus(menu); Menu_ShowItemByName(menu, "dialog", qtrue); if (type == PDLG_OK) { Menu_ShowItemByName(menu, "btn_dialogok", qtrue); } else if (type == PDLG_YESNO) { Menu_ShowItemByName(menu, "btn_dialogyesno", qtrue); } else if (type == PDLG_TEXT) { Menu_ShowItemByName(menu, "btn_dialogtext", qtrue); // Clear the text item = Menu_FindItemByName(menu, "dlg_textentry"); if (item) { item->typeData.edit->buffer[0] = 0; item->cursorPos = 0; Menu_SetTextFieldFocus(item); } } else { // Invalid dialog type! assert(0); } }
static void JKG_PartyMngt_UpdateState() { // Updates team state (invites/team members) teamParty_t *party; uiClientState_t cs; menuDef_t *menu; char buff[1024]; int i; int j=0; menu = Menus_FindByName("jkg_partymanagement"); if (!menu) { return; } trap->GetClientState( &cs ); party = (teamParty_t *)cgImports->PartyMngtDataRequest(PARTYREQUEST_PARTY); if (!party) { return; } if (party->active) { PMngtData.inParty = 1; PMngtData.partyLead = 0; for (i=0; i<PARTY_SLOT_MEMBERS; i++) { if (party->members[i].id == PARTY_SLOT_EMPTY) { continue; } PMngtData.Data.PartyMembers[j].slotid = i; PMngtData.Data.PartyMembers[j].id = party->members[i].id; if (party->members[i].id == cs.clientNum && party->members[i].status == 1) { PMngtData.partyLead = 1; } trap->GetConfigString(CS_PLAYERS + party->members[i].id, buff, sizeof(buff)); Q_strncpyz(PMngtData.Data.PartyMembers[j].playerName, Info_ValueForKey(buff, "n"), 64); if (party->members[i].status == -1) { Q_strncpyz(PMngtData.Data.PartyMembers[j].playerStatus, "Pending", 64); } else if (party->members[i].status == 0) { Q_strncpyz(PMngtData.Data.PartyMembers[j].playerStatus, "Member", 64); } else if (party->members[i].status == 1) { Q_strncpyz(PMngtData.Data.PartyMembers[j].playerStatus, "Leader", 64); } else { Q_strncpyz(PMngtData.Data.PartyMembers[j].playerStatus, "Unknown", 64); } Q_strncpyz(PMngtData.Data.PartyMembers[j].location, "N/A", 64); Q_strncpyz(PMngtData.Data.PartyMembers[j].playerClass, "N/A", 64); j++; } PMngtData.partyListEntries = j; if (PMngtData.partyLead) { Menu_ShowItemByName(menu, "noparty", qfalse); Menu_ShowItemByName(menu, "btn_noparty", qfalse); Menu_ShowItemByName(menu, "inparty", qtrue); Menu_ShowItemByName(menu, "btn_inparty", qfalse); Menu_ShowItemByName(menu, "inpartylead", qtrue); Menu_ShowItemByName(menu, "btn_inpartylead", qtrue); Menu_ShowItemByName(menu, "btn_bottom", qfalse); } else { Menu_ShowItemByName(menu, "noparty", qfalse); Menu_ShowItemByName(menu, "btn_noparty", qfalse); Menu_ShowItemByName(menu, "inparty", qtrue); Menu_ShowItemByName(menu, "btn_inparty", qtrue); Menu_ShowItemByName(menu, "inpartylead", qfalse); Menu_ShowItemByName(menu, "btn_inpartylead", qfalse); Menu_ShowItemByName(menu, "btn_bottom", qfalse); } } else { PMngtData.inParty = 0; j=0; for (i=0; i<PARTY_SLOT_INVITES; i++) { if (party->invites[i].id == PARTY_SLOT_EMPTY) { continue; } PMngtData.Data.Invites[j].slotid = i; PMngtData.Data.Invites[j].id = party->invites[i].id; trap->GetConfigString(CS_PLAYERS + party->invites[i].leaderId, buff, sizeof(buff)); Q_strncpyz(PMngtData.Data.Invites[j].leaderName, Info_ValueForKey(buff, "n"), 64); Com_sprintf(PMngtData.Data.Invites[j].memberCount, 6, "%i", party->invites[i].memberCount); j++; } PMngtData.partyListEntries = j; Menu_ShowItemByName(menu, "noparty", qtrue); Menu_ShowItemByName(menu, "btn_noparty", qtrue); Menu_ShowItemByName(menu, "inparty", qfalse); Menu_ShowItemByName(menu, "btn_inparty", qfalse); Menu_ShowItemByName(menu, "inpartylead", qfalse); Menu_ShowItemByName(menu, "btn_inpartylead", qfalse); Menu_ShowItemByName(menu, "btn_bottom", qfalse); if (PMngtData.amSeeker) { Menu_ShowItemByName(menu, "btn_removefromlist", qtrue); } else { Menu_ShowItemByName(menu, "btn_addtolist", qtrue); } } }
/* ================ CG_DrawHUD ================ */ void CG_DrawHUD(centity_t *cent) { menuDef_t *menuHUD = NULL; vec4_t opacity = {1, 1, 1, 1}; AdjustOpacityLevels(); MAKERGBA(opacity, 1, 1, 1, cg.jkg_HUDOpacity); if (cg.captureFlagPercent > 0 && cg.captureFlagPercent < 100 && cg.capturingFlag) {// For attack/defence/scenario gametype flag captures... int x = 600; int y = 154; vec3_t color; if (cg.captureFlagPercent > 100) cg.captureFlagPercent = 100; FlagCaptureBar(); VectorSet(color, 250, 100, 1); if (next_color_update < cg.time) { // Cycle writing color... if (color_forwards) { if (color_selector >= 250) { color_forwards = qfalse; color_selector--; } else { color_selector++; } } else { if (color_selector <= 50) { color_forwards = qtrue; color_selector++; } else { color_selector--; } } next_color_update = cg.time + 10; } color[0] = color_selector; color[1] = color_selector; color[2] = 1; if (cg.recaptureingFlag) { x-=15; UI_DrawScaledProportionalString(x, y, va("Consolidating Control Point"), UI_RIGHT|UI_DROPSHADOW, color, 0.4); } else UI_DrawScaledProportionalString(x, y, va("Capturing Control Point"), UI_RIGHT|UI_DROPSHADOW, color, 0.4); } else if (cg.captureFlagPercent >= 100 && cg.capturingFlag) {// For attack/defence/scenario gametype flag captures... int x = 600; int y = 154; vec3_t color; if (cg.captureFlagPercent > 100) cg.captureFlagPercent = 100; FlagCaptureBar(); VectorSet(color, 250, 250, 0); UI_DrawScaledProportionalString(x, y, va("^3Control Point Captured!"), UI_RIGHT|UI_DROPSHADOW, color, 0.4); } if (cgs.gametype >= GT_TEAM) { // tint the hud items based on team if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) hudTintColor = redhudtint; else if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) hudTintColor = bluehudtint; else // If we're not on a team for whatever reason, leave things as they are. hudTintColor = colorTable[CT_WHITE]; } else { // tint the hud items white (dont' tint) hudTintColor = colorTable[CT_WHITE]; } // Jedi Knight Galaxies -- Put in our own HUD components here // Render the top-left stuff menuHUD = Menus_FindByName("hud_topleft"); CG_DrawTopLeftHUD (menuHUD, opacity); // Render the minimap menuHUD = Menus_FindByName("hud_minimap"); CG_DrawMiniMap (menuHUD, opacity); // Render the hotkey bar menuHUD = Menus_FindByName("hud_hotkey"); CG_DrawHotkeyBar (menuHUD, opacity); menuHUD = Menus_FindByName("hud_bottomright"); CG_DrawBottomRightHUD (menuHUD, cent, opacity); }
// Message Processor void JKG_Slice_ProcessCommand_f(void) { char arg[1024] = {0}; char data[840]; int len; int i, row, col; sfxHandle_t sfx; bitstream_t stream; trap->Cmd_Argv(1, arg, 1024); len = Base128_DecodeLength(strlen(arg)); Base128_Decode(arg, strlen(arg), data, 840); BitStream_Init(&stream, (unsigned char *)data, len); BitStream_BeginReading(&stream); for (;;) { switch (BitStream_ReadBits(&stream, 4)) // Get the next instruction { case SLICECMD_EOM: // End of message return; case SLICECMD_START: // Reset data memset(&sliceData, 0, sizeof(sliceData)); sliceData.active = qtrue; // Bring up UI trap->Cvar_Set("ui_hidehud", "1"); Menus_CloseAll(); if (Menus_ActivateByName("jkg_slice")) { trap->Key_SetCatcher( trap->Key_GetCatcher() | KEYCATCH_UI & ~KEYCATCH_CONSOLE ); } Menu_ClearFocus(Menus_FindByName("jkg_slice")); // Field is locked until all data is available sliceData.fieldLocked = qtrue; break; case SLICECMD_STOP: // End the slicing minigame sliceData.active = qfalse; Menus_CloseByName("jkg_slice"); trap->Cvar_Set("ui_hidehud", "0"); trap->Key_SetCatcher( trap->Key_GetCatcher() & ~KEYCATCH_UI ); break; case SLICECMD_CONFIG: // Receive configuration sliceData.width = BitStream_ReadBits(&stream, 3) + 1; sliceData.height = BitStream_ReadBits(&stream, 3) + 1; sliceData.securityLevels = BitStream_ReadBits(&stream, 3); sliceData.warningThreshold = BitStream_ReadBits(&stream, 5); sliceData.intrusionDetection = BitStream_ReadBool(&stream); if (sliceData.intrusionDetection) { sliceData.intrusionTime = BitStream_ReadByte(&stream) * 10; } else { sliceData.intrusionTime = 0; } sliceData.intrusionStart = 0; break; case SLICECMD_REVEAL: row = BitStream_ReadBits(&stream, 3); col = BitStream_ReadBits(&stream, 3); sliceData.grid[row][col].active = 1; sliceData.grid[row][col].revealTime = trap->Milliseconds(); sliceData.grid[row][col].type = BitStream_ReadBits(&stream, 3); break; case SLICECMD_LOCK: if (BitStream_ReadBool(&stream)) { sliceData.fieldLocked = qtrue; } else { sliceData.fieldLocked = qfalse; } break; case SLICECMD_PROGLST: JKG_Slice_ProgramListReset(); sliceData.selectedProgram = -1; sliceData.programCount = BitStream_ReadBits(&stream, 4); for (i = 0; i < sliceData.programCount; i++) { Q_strncpyz(sliceData.programs[i].ID, BitStream_ReadStringBuffered(&stream), sizeof(sliceData.programs[i].ID)); Q_strncpyz(sliceData.programs[i].name, BitStream_ReadStringBuffered(&stream), sizeof(sliceData.programs[i].name)); Q_strncpyz(sliceData.programs[i].desc, BitStream_ReadStringBuffered(&stream), sizeof(sliceData.programs[i].desc)); sliceData.programs[i].type = BitStream_ReadBits(&stream, 2); } break; case SLICECMD_SHOWMSG: { int mode = BitStream_ReadBits(&stream, 2); char buffer[3][256]; BitStream_ReadString(&stream, buffer[0], 256); BitStream_ReadString(&stream, buffer[1], 256); BitStream_ReadString(&stream, buffer[2], 256); JKG_Slice_Dialog_Show(buffer[0], buffer[1], buffer[2], mode, DLGID_SERVER); } break; case SLICECMD_ENDMSG: JKG_Slice_Dialog_Close(); break; case SLICECMD_SUMMARY: // Process column summaries for (i=0; i < sliceData.width; i++) { sliceData.summaries[i].value = BitStream_ReadBits(&stream, 6); sliceData.summaries[i].alarms = BitStream_ReadBits(&stream, 4); } // Process row summaries for (i=0; i < sliceData.height; i++) { sliceData.summaries[8+i].value = BitStream_ReadBits(&stream, 6); sliceData.summaries[8+i].alarms = BitStream_ReadBits(&stream, 4); } sliceData.summariesKnown = qtrue; break; case SLICECMD_SECUPDATE: for (i = 0; i < sliceData.securityLevels; i++) { sliceData.securityState[i] = BitStream_ReadBits(&stream, 2); } break; case SLICECMD_INTRUSION: // TODO: Play sound effect? sliceData.intrusionState = BitStream_ReadBits(&stream, 2); if (sliceData.intrusionState == 1) { sliceData.intrusionStart = trap->Milliseconds(); } else { sliceData.intrusionStart = 0; } break; case SLICECMD_WARNLEVEL: sliceData.warningLevel = BitStream_ReadBits(&stream, 5); break; case SLICECMD_BLINKNODE: row = BitStream_ReadBits(&stream, 3); col = BitStream_ReadBits(&stream, 3); sliceData.grid[row][col].blinkTime = trap->Milliseconds(); sliceData.grid[row][col].blinkColor = BitStream_ReadBool(&stream); break; case SLICECMD_INITFIELD: // Ready to play sliceData.fieldLocked = qfalse; break; case SLICECMD_ALARM: sfx = trap->S_RegisterSound("sound/effects/mpalarm.wav"); trap->S_StartLocalSound(sfx, CHAN_AUTO); break; default: Com_Printf("Error processing slice command, unknown command ID\n"); return; } } }
//set up the menu void CG_BuyMenu (void) { if(cgs.gametype == GT_DUEL && cg.introend < cg.time) return; if(cg.snap->ps.persistant[PERS_TEAM] >= TEAM_SPECTATOR) return; if(cg.snap->ps.stats[STAT_HEALTH] <= 0) return; // if one is too far away from buy-point if(!(cg.snap->ps.stats[STAT_FLAGS] & SF_CANBUY) && (cgs.gametype >= GT_RTP)) return; /* as suggested by The Doctor, this test shouldn't be done in cgame, it is already done in game, it removes a bug // if it's to late to buy if(cg.time - cg.roundstarttime > BUY_TIME && cgs.gametype >= GT_RTP){ CG_Printf("60 seconds have passed ... you can't buy anything\n"); return; } */ // if we're throwing away the gatling and it's being used, abort /*if(cg.snap->ps.weapon == WP_GATLING && cg.snap->ps.stats[STAT_GATLING_MODE]) return;*/ // weapon change isn't activated anymore when buying and having a gatling // show the menu if(menuBuy == NULL) { menuBuy = Menus_FindByName("buymenu"); save_menuBuy.x = menuBuy->window.rect.x; save_menuBuy.y = menuBuy->window.rect.y; } if(menuItem == NULL) { menuItem = Menus_FindByName("buymenu_items"); save_menuItem.x = menuItem->window.rect.x; save_menuItem.y = menuItem->window.rect.y; } cgs.cursorX = cgs.cursorY = 0; cg.menu = MENU_BUY; cg.menustat = 1; cg.menumove = qtrue; cg.menuitem = 0; cg.oldbutton = qfalse; CG_ClearFocusses(); if(cgs.gametype == GT_DUEL) { int i; // set focus to 1st item cg.menuitem = 1; for(i=0; i< menuItem->itemCount; i++) { if(menuItem->items[i]->window.ownerDraw == CG_BUTTON1) { menuItem->items[i]->window.flags |= WINDOW_HASFOCUS; break; } } } trap_Cvar_Set("cl_menu", "0"); trap_Key_SetCatcher(KEYCATCH_CGAME); // Notify the server we open the buy menu. // The "client" engine code will set BUTTON_BUYMENU to usercmd_t.buttons . trap_SendConsoleCommand( "+button8" ); }
intptr_t CL_CgameSystemCalls( intptr_t *args ) { #ifndef __NO_JK2 if( com_jk2 && com_jk2->integer ) { args[0] = (intptr_t)CL_ConvertJK2SysCall((cgameJK2Import_t)args[0]); } #endif switch( args[0] ) { case CG_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case CG_ERROR: Com_Error( ERR_DROP, S_COLOR_RED"%s", VMA(1) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); case CG_CVAR_REGISTER: Cvar_Register( (vmCvar_t *) VMA(1), (const char *) VMA(2), (const char *) VMA(3), args[4] ); return 0; case CG_CVAR_UPDATE: Cvar_Update( (vmCvar_t *) VMA(1) ); return 0; case CG_CVAR_SET: Cvar_Set( (const char *) VMA(1), (const char *) VMA(2) ); return 0; case CG_ARGC: return Cmd_Argc(); case CG_ARGV: Cmd_ArgvBuffer( args[1], (char *) VMA(2), args[3] ); return 0; case CG_ARGS: Cmd_ArgsBuffer( (char *) VMA(1), args[2] ); return 0; case CG_FS_FOPENFILE: return FS_FOpenFileByMode( (const char *) VMA(1), (int *) VMA(2), (fsMode_t) args[3] ); case CG_FS_READ: FS_Read( VMA(1), args[2], args[3] ); return 0; case CG_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case CG_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case CG_SENDCONSOLECOMMAND: Cbuf_AddText( (const char *) VMA(1) ); return 0; case CG_ADDCOMMAND: CL_AddCgameCommand( (const char *) VMA(1) ); return 0; case CG_SENDCLIENTCOMMAND: CL_AddReliableCommand( (const char *) VMA(1) ); return 0; case CG_UPDATESCREEN: // this is used during lengthy level loading, so pump message loop Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN! SCR_UpdateScreen(); return 0; case CG_RMG_INIT: /* if (!com_sv_running->integer) { // don't do this if we are connected locally if (!TheRandomMissionManager) { TheRandomMissionManager = new CRMManager; } TheRandomMissionManager->SetLandScape( cmg.landScapes[args[1]] ); TheRandomMissionManager->LoadMission(qfalse); TheRandomMissionManager->SpawnMission(qfalse); cmg.landScapes[args[1]]->UpdatePatches(); } */ //this is SP.. I guess we're always the client and server. // cl.mRMGChecksum = cm.landScapes[args[1]]->get_rand_seed(); RM_CreateRandomModels(args[1], (const char *)VMA(2)); //cmg.landScapes[args[1]]->rand_seed(cl.mRMGChecksum); // restore it, in case we do a vid restart cmg.landScape->rand_seed(cmg.landScape->get_rand_seed()); // TheRandomMissionManager->CreateMap(); return 0; case CG_CM_REGISTER_TERRAIN: return CM_RegisterTerrain((const char *)VMA(1), false)->GetTerrainId(); case CG_RE_INIT_RENDERER_TERRAIN: re.InitRendererTerrain((const char *)VMA(1)); return 0; case CG_CM_LOADMAP: CL_CM_LoadMap( (const char *) VMA(1), args[2] ); return 0; case CG_CM_NUMINLINEMODELS: return CM_NumInlineModels(); case CG_CM_INLINEMODEL: return CM_InlineModel( args[1] ); case CG_CM_TEMPBOXMODEL: return CM_TempBoxModel( (const float *) VMA(1), (const float *) VMA(2) );//, (int) VMA(3) ); case CG_CM_POINTCONTENTS: return CM_PointContents( (float *)VMA(1), args[2] ); case CG_CM_TRANSFORMEDPOINTCONTENTS: return CM_TransformedPointContents( (const float *) VMA(1), args[2], (const float *) VMA(3), (const float *) VMA(4) ); case CG_CM_BOXTRACE: CM_BoxTrace( (trace_t *) VMA(1), (const float *) VMA(2), (const float *) VMA(3), (const float *) VMA(4), (const float *) VMA(5), args[6], args[7] ); return 0; case CG_CM_TRANSFORMEDBOXTRACE: CM_TransformedBoxTrace( (trace_t *) VMA(1), (const float *) VMA(2), (const float *) VMA(3), (const float *) VMA(4), (const float *) VMA(5), args[6], args[7], (const float *) VMA(8), (const float *) VMA(9) ); return 0; case CG_CM_MARKFRAGMENTS: return re.MarkFragments( args[1], (float(*)[3]) VMA(2), (const float *) VMA(3), args[4], (float *) VMA(5), args[6], (markFragment_t *) VMA(7) ); case CG_CM_SNAPPVS: CM_SnapPVS((float(*))VMA(1),(byte *) VMA(2)); return 0; case CG_S_STOPSOUNDS: S_StopSounds( ); return 0; case CG_S_STARTSOUND: // stops an ERR_DROP internally if called illegally from game side, but note that it also gets here // legally during level start where normally the internal s_soundStarted check would return. So ok to hit this. if (!cls.cgameStarted){ return 0; } S_StartSound( (float *) VMA(1), args[2], (soundChannel_t)args[3], args[4] ); return 0; case CG_S_UPDATEAMBIENTSET: // stops an ERR_DROP internally if called illegally from game side, but note that it also gets here // legally during level start where normally the internal s_soundStarted check would return. So ok to hit this. if (!cls.cgameStarted){ return 0; } S_UpdateAmbientSet( (const char *) VMA(1), (float *) VMA(2) ); return 0; case CG_S_ADDLOCALSET: return S_AddLocalSet( (const char *) VMA(1), (float *) VMA(2), (float *) VMA(3), args[4], args[5] ); case CG_AS_PARSESETS: AS_ParseSets(); return 0; case CG_AS_ADDENTRY: AS_AddPrecacheEntry( (const char *) VMA(1) ); return 0; case CG_AS_GETBMODELSOUND: return AS_GetBModelSound( (const char *) VMA(1), args[2] ); case CG_S_STARTLOCALSOUND: // stops an ERR_DROP internally if called illegally from game side, but note that it also gets here // legally during level start where normally the internal s_soundStarted check would return. So ok to hit this. if (!cls.cgameStarted){ return 0; } S_StartLocalSound( args[1], args[2] ); return 0; case CG_S_CLEARLOOPINGSOUNDS: S_ClearLoopingSounds(); return 0; case CG_S_ADDLOOPINGSOUND: // stops an ERR_DROP internally if called illegally from game side, but note that it also gets here // legally during level start where normally the internal s_soundStarted check would return. So ok to hit this. if (!cls.cgameStarted){ return 0; } S_AddLoopingSound( args[1], (const float *) VMA(2), (const float *) VMA(3), args[4], (soundChannel_t)args[5] ); return 0; case CG_S_UPDATEENTITYPOSITION: S_UpdateEntityPosition( args[1], (const float *) VMA(2) ); return 0; case CG_S_RESPATIALIZE: S_Respatialize( args[1], (const float *) VMA(2), (float(*)[3]) VMA(3), args[4] ); return 0; case CG_S_REGISTERSOUND: return S_RegisterSound( (const char *) VMA(1) ); case CG_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( (const char *) VMA(1), (const char *) VMA(2), args[3]); return 0; case CG_S_GETSAMPLELENGTH: return S_GetSampleLengthInMilliSeconds( args[1]); case CG_R_LOADWORLDMAP: re.LoadWorld( (const char *) VMA(1) ); return 0; case CG_R_REGISTERMODEL: return re.RegisterModel( (const char *) VMA(1) ); case CG_R_REGISTERSKIN: return re.RegisterSkin( (const char *) VMA(1) ); case CG_R_REGISTERSHADER: return re.RegisterShader( (const char *) VMA(1) ); case CG_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( (const char *) VMA(1) ); case CG_R_REGISTERFONT: return re.RegisterFont( (const char *) VMA(1) ); case CG_R_FONTSTRLENPIXELS: return re.Font_StrLenPixels( (const char *) VMA(1), args[2], VMF(3) ); case CG_R_FONTSTRLENCHARS: return re.Font_StrLenChars( (const char *) VMA(1) ); case CG_R_FONTHEIGHTPIXELS: return re.Font_HeightPixels( args[1], VMF(2) ); case CG_R_FONTDRAWSTRING: re.Font_DrawString(args[1],args[2], (const char *) VMA(3), (float*)args[4], args[5], args[6], VMF(7)); return 0; case CG_LANGUAGE_ISASIAN: return re.Language_IsAsian(); case CG_LANGUAGE_USESSPACES: return re.Language_UsesSpaces(); case CG_ANYLANGUAGE_READFROMSTRING: return re.AnyLanguage_ReadCharFromString( (char *) VMA(1), (int *) VMA(2), (qboolean *) VMA(3) ); case CG_ANYLANGUAGE_READFROMSTRING2: return re.AnyLanguage_ReadCharFromString2( (char **) VMA(1), (qboolean *) VMA(3) ); case CG_R_SETREFRACTIONPROP: *(re.tr_distortionAlpha()) = VMF(1); *(re.tr_distortionStretch()) = VMF(2); *(re.tr_distortionPrePost()) = (qboolean)args[3]; *(re.tr_distortionNegate()) = (qboolean)args[4]; return 0; case CG_R_CLEARSCENE: re.ClearScene(); return 0; case CG_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( (const refEntity_t *) VMA(1) ); return 0; case CG_R_INPVS: return re.R_inPVS((float *) VMA(1), (float *) VMA(2)); case CG_R_GETLIGHTING: return re.GetLighting( (const float * ) VMA(1), (float *) VMA(2), (float *) VMA(3), (float *) VMA(4) ); case CG_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], (const polyVert_t *) VMA(3) ); return 0; case CG_R_ADDLIGHTTOSCENE: #ifdef VV_LIGHTING VVLightMan.RE_AddLightToScene ( (const float *) VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); #else re.AddLightToScene( (const float *) VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); #endif return 0; case CG_R_RENDERSCENE: re.RenderScene( (const refdef_t *) VMA(1) ); return 0; case CG_R_SETCOLOR: re.SetColor( (const float *) VMA(1) ); return 0; case CG_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; // The below was commented out for whatever reason... /me shrugs --eez case CG_R_DRAWSCREENSHOT: re.DrawStretchRaw( VMF(1), VMF(2), VMF(3), VMF(4), SG_SCR_WIDTH, SG_SCR_HEIGHT, SCR_GetScreenshot(0), 0, qtrue); return 0; case CG_R_MODELBOUNDS: re.ModelBounds( args[1], (float *) VMA(2), (float *) VMA(3) ); return 0; case CG_R_LERPTAG: re.LerpTag( (orientation_t *) VMA(1), args[2], args[3], args[4], VMF(5), (const char *) VMA(6) ); return 0; case CG_R_DRAWROTATEPIC: re.DrawRotatePic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10] ); return 0; case CG_R_DRAWROTATEPIC2: re.DrawRotatePic2( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), VMF(9), args[10] ); return 0; case CG_R_SETRANGEFOG: // FIXME: Figure out if this is how it's done in MP :S --eez /*if (tr.rangedFog <= 0.0f) { g_oldRangedFog = tr.rangedFog; } tr.rangedFog = VMF(1); if (tr.rangedFog == 0.0f && g_oldRangedFog) { //restore to previous state if applicable tr.rangedFog = g_oldRangedFog; }*/ re.SetRangedFog( VMF( 1 ) ); return 0; case CG_R_LA_GOGGLES: re.LAGoggles(); return 0; case CG_R_SCISSOR: re.Scissor( VMF(1), VMF(2), VMF(3), VMF(4)); return 0; case CG_GETGLCONFIG: CL_GetGlconfig( (glconfig_t *) VMA(1) ); return 0; case CG_GETGAMESTATE: CL_GetGameState( (gameState_t *) VMA(1) ); return 0; case CG_GETCURRENTSNAPSHOTNUMBER: CL_GetCurrentSnapshotNumber( (int *) VMA(1), (int *) VMA(2) ); return 0; case CG_GETSNAPSHOT: return CL_GetSnapshot( args[1], (snapshot_t *) VMA(2) ); case CG_GETDEFAULTSTATE: return CL_GetDefaultState(args[1], (entityState_t *)VMA(2)); case CG_GETSERVERCOMMAND: return CL_GetServerCommand( args[1] ); case CG_GETCURRENTCMDNUMBER: return CL_GetCurrentCmdNumber(); case CG_GETUSERCMD: return CL_GetUserCmd( args[1], (usercmd_s *) VMA(2) ); case CG_SETUSERCMDVALUE: CL_SetUserCmdValue( args[1], VMF(2), VMF(3), VMF(4) ); return 0; case CG_SETUSERCMDANGLES: CL_SetUserCmdAngles( VMF(1), VMF(2), VMF(3) ); return 0; case COM_SETORGANGLES: Com_SetOrgAngles((float *)VMA(1),(float *)VMA(2)); return 0; /* Ghoul2 Insert Start */ case CG_G2_LISTSURFACES: re.G2API_ListSurfaces( (CGhoul2Info *) VMA(1) ); return 0; case CG_G2_LISTBONES: re.G2API_ListBones( (CGhoul2Info *) VMA(1), args[2]); return 0; case CG_G2_HAVEWEGHOULMODELS: return re.G2API_HaveWeGhoul2Models( *((CGhoul2Info_v *)VMA(1)) ); case CG_G2_SETMODELS: re.G2API_SetGhoul2ModelIndexes( *((CGhoul2Info_v *)VMA(1)),(qhandle_t *)VMA(2),(qhandle_t *)VMA(3)); return 0; /* Ghoul2 Insert End */ case CG_R_GET_LIGHT_STYLE: re.GetLightStyle(args[1], (byte*) VMA(2) ); return 0; case CG_R_SET_LIGHT_STYLE: re.SetLightStyle(args[1], args[2] ); return 0; case CG_R_GET_BMODEL_VERTS: re.GetBModelVerts( args[1], (float (*)[3])VMA(2), (float *)VMA(3) ); return 0; case CG_R_WORLD_EFFECT_COMMAND: re.WorldEffectCommand( (const char *) VMA(1) ); return 0; case CG_CIN_PLAYCINEMATIC: return CIN_PlayCinematic( (const char *) VMA(1), args[2], args[3], args[4], args[5], args[6], (const char *) VMA(7)); case CG_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case CG_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case CG_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case CG_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case CG_Z_MALLOC: return (intptr_t)Z_Malloc(args[1], (memtag_t) args[2], qfalse); case CG_Z_FREE: Z_Free((void *) VMA(1)); return 0; case CG_UI_SETACTIVE_MENU: UI_SetActiveMenu((const char *) VMA(1),NULL); return 0; case CG_UI_MENU_OPENBYNAME: Menus_OpenByName((const char *) VMA(1)); return 0; case CG_UI_MENU_RESET: Menu_Reset(); return 0; case CG_UI_MENU_NEW: Menu_New((char *) VMA(1)); return 0; case CG_UI_PARSE_INT: PC_ParseInt((int *) VMA(1)); return 0; case CG_UI_PARSE_STRING: PC_ParseString((const char **) VMA(1)); return 0; case CG_UI_PARSE_FLOAT: PC_ParseFloat((float *) VMA(1)); return 0; case CG_UI_STARTPARSESESSION: return(PC_StartParseSession((char *) VMA(1),(char **) VMA(2))); case CG_UI_ENDPARSESESSION: PC_EndParseSession((char *) VMA(1)); return 0; case CG_UI_PARSEEXT: char **holdPtr; holdPtr = (char **) VMA(1); if(!holdPtr) { Com_Error(ERR_FATAL, "CG_UI_PARSEEXT: NULL holdPtr"); } *holdPtr = PC_ParseExt(); return 0; case CG_UI_MENUCLOSE_ALL: Menus_CloseAll(); return 0; case CG_UI_MENUPAINT_ALL: Menu_PaintAll(); return 0; case CG_OPENJK_MENU_PAINT: Menu_Paint( (menuDef_t *)VMA(1), (intptr_t)VMA(2) ); return 0; case CG_OPENJK_GETMENU_BYNAME: return (intptr_t)Menus_FindByName( (const char *)VMA(1) ); case CG_UI_STRING_INIT: String_Init(); return 0; case CG_UI_GETMENUINFO: menuDef_t *menu; int *xPos,*yPos,*w,*h,result; #ifndef __NO_JK2 if(com_jk2 && !com_jk2->integer) { #endif menu = Menus_FindByName((char *) VMA(1)); // Get menu if (menu) { xPos = (int *) VMA(2); *xPos = (int) menu->window.rect.x; yPos = (int *) VMA(3); *yPos = (int) menu->window.rect.y; w = (int *) VMA(4); *w = (int) menu->window.rect.w; h = (int *) VMA(5); *h = (int) menu->window.rect.h; result = qtrue; } else { result = qfalse; } return result; #ifndef __NO_JK2 } else { menu = Menus_FindByName((char *) VMA(1)); // Get menu if (menu) { xPos = (int *) VMA(2); *xPos = (int) menu->window.rect.x; yPos = (int *) VMA(3); *yPos = (int) menu->window.rect.y; result = qtrue; } else { result = qfalse; } return result; } #endif break; case CG_UI_GETITEMTEXT: itemDef_t *item; menu = Menus_FindByName((char *) VMA(1)); // Get menu if (menu) { item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, (char *) VMA(2)); if (item) { Q_strncpyz( (char *) VMA(3), item->text, 256 ); result = qtrue; } else { result = qfalse; } } else { result = qfalse; } return result; case CG_UI_GETITEMINFO: menu = Menus_FindByName((char *) VMA(1)); // Get menu if (menu) { qhandle_t *background; item = (itemDef_s *) Menu_FindItemByName((menuDef_t *) menu, (char *) VMA(2)); if (item) { xPos = (int *) VMA(3); *xPos = (int) item->window.rect.x; yPos = (int *) VMA(4); *yPos = (int) item->window.rect.y; w = (int *) VMA(5); *w = (int) item->window.rect.w; h = (int *) VMA(6); *h = (int) item->window.rect.h; vec4_t *color; color = (vec4_t *) VMA(7); if (!color) { return qfalse; } (*color)[0] = (float) item->window.foreColor[0]; (*color)[1] = (float) item->window.foreColor[1]; (*color)[2] = (float) item->window.foreColor[2]; (*color)[3] = (float) item->window.foreColor[3]; background = (qhandle_t *) VMA(8); if (!background) { return qfalse; } *background = item->window.background; result = qtrue; } else { result = qfalse; } } else { result = qfalse; } return result; case CG_SP_GETSTRINGTEXTSTRING: #ifndef __NO_JK2 case CG_SP_GETSTRINGTEXT: if(com_jk2 && com_jk2->integer) { const char* text; assert(VMA(1)); // assert(VMA(2)); // can now pass in NULL to just query the size if (args[0] == CG_SP_GETSTRINGTEXT) { text = JK2SP_GetStringText( args[1] ); } else { text = JK2SP_GetStringTextString( (const char *) VMA(1) ); } if (VMA(2)) // only if dest buffer supplied... { if ( text[0] ) { Q_strncpyz( (char *) VMA(2), text, args[3] ); } else { Q_strncpyz( (char *) VMA(2), "??", args[3] ); } } return strlen(text); } else { #endif const char* text; assert(VMA(1)); text = SE_GetString( (const char *) VMA(1) ); if (VMA(2)) // only if dest buffer supplied... { if ( text[0] ) { Q_strncpyz( (char *) VMA(2), text, args[3] ); } else { Com_sprintf( (char *) VMA(2), args[3], "??%s", VMA(1) ); } } return strlen(text); #ifndef __NO_JK2 } //break; case CG_SP_REGISTER: return JK2SP_Register( (const char *) VMA(1), args[2]?(SP_REGISTER_MENU|SP_REGISTER_REQUIRED):SP_REGISTER_CLIENT ); #endif default: Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] ); } return 0; }
void UpdateForceUsed() { int curpower, currank; menuDef_t *menu; // Currently we don't make a distinction between those that wish to play Jedi of lower than maximum skill. uiForceRank = uiMaxRank; uiForceUsed = 0; uiForceAvailable = forceMasteryPoints[uiForceRank]; // Make sure that we have one freebie in jump. if (uiForcePowersRank[FP_LEVITATION]<1) { uiForcePowersRank[FP_LEVITATION]=1; } if ( UI_TrueJediEnabled() ) {//true jedi mode is set if ( uiJediNonJedi == -1 ) { int x = 0; qboolean clear = qfalse, update = qfalse; uiJediNonJedi = FORCE_NONJEDI; while ( x < NUM_FORCE_POWERS ) {//if any force power is set, we must be a jedi if ( x == FP_LEVITATION || x == FP_SABER_OFFENSE ) { if ( uiForcePowersRank[x] > 1 ) { uiJediNonJedi = FORCE_JEDI; break; } else if ( uiForcePowersRank[x] > 0 ) { clear = qtrue; } } else if ( uiForcePowersRank[x] > 0 ) { uiJediNonJedi = FORCE_JEDI; break; } x++; } if ( uiJediNonJedi == FORCE_JEDI ) { if ( uiForcePowersRank[FP_SABER_OFFENSE] < 1 ) { uiForcePowersRank[FP_SABER_OFFENSE]=1; update = qtrue; } } else if ( clear ) { x = 0; while ( x < NUM_FORCE_POWERS ) {//clear all force uiForcePowersRank[x] = 0; x++; } update = qtrue; } if ( update ) { int myTeam; myTeam = (int)(trap->Cvar_VariableValue("ui_myteam")); if ( myTeam != TEAM_SPECTATOR ) { UI_UpdateClientForcePowers(UI_TeamName(myTeam));//will cause him to respawn, if it's been 5 seconds since last one } else { UI_UpdateClientForcePowers(NULL);//just update powers } } } } menu = Menus_FindByName("ingame_playerforce"); // Set the cost of the saberattack according to whether its free. if (ui_freeSaber.integer) { // Make saber free bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 0; bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 0; // Make sure that we have one freebie in saber if applicable. if (uiForcePowersRank[FP_SABER_OFFENSE]<1) { uiForcePowersRank[FP_SABER_OFFENSE]=1; } if (uiForcePowersRank[FP_SABER_DEFENSE]<1) { uiForcePowersRank[FP_SABER_DEFENSE]=1; } if (menu) { Menu_ShowItemByName(menu, "setFP_SABER_DEFENSE", qtrue); Menu_ShowItemByName(menu, "setfp_saberthrow", qtrue); Menu_ShowItemByName(menu, "effectentry", qtrue); Menu_ShowItemByName(menu, "effectfield", qtrue); Menu_ShowItemByName(menu, "nosaber", qfalse); } } else { // Make saber normal cost bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 1; bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 1; // Also, check if there is no saberattack. If there isn't, there had better not be any defense or throw! if (uiForcePowersRank[FP_SABER_OFFENSE]<1) { uiForcePowersRank[FP_SABER_DEFENSE]=0; uiForcePowersRank[FP_SABERTHROW]=0; if (menu) { Menu_ShowItemByName(menu, "setfp_saberdefend", qfalse); Menu_ShowItemByName(menu, "setfp_saberthrow", qfalse); Menu_ShowItemByName(menu, "effectentry", qfalse); Menu_ShowItemByName(menu, "effectfield", qfalse); Menu_ShowItemByName(menu, "nosaber", qtrue); } } else { if (menu) { Menu_ShowItemByName(menu, "setfp_saberdefend", qtrue); Menu_ShowItemByName(menu, "setfp_saberthrow", qtrue); Menu_ShowItemByName(menu, "effectentry", qtrue); Menu_ShowItemByName(menu, "effectfield", qtrue); Menu_ShowItemByName(menu, "nosaber", qfalse); } } } // Make sure that we're still legal. for (curpower=0;curpower<NUM_FORCE_POWERS;curpower++) { // Make sure that our ranks are within legal limits. if (uiForcePowersRank[curpower]<0) uiForcePowersRank[curpower]=0; else if (uiForcePowersRank[curpower]>=NUM_FORCE_POWER_LEVELS) uiForcePowersRank[curpower]=(NUM_FORCE_POWER_LEVELS-1); for (currank=FORCE_LEVEL_1;currank<=uiForcePowersRank[curpower];currank++) { // Check on this force power if (uiForcePowersRank[curpower]>0) { // Do not charge the player for the one freebie in jump, or if there is one in saber. if ( (curpower == FP_LEVITATION && currank == FORCE_LEVEL_1) || (curpower == FP_SABER_OFFENSE && currank == FORCE_LEVEL_1 && ui_freeSaber.integer) || (curpower == FP_SABER_DEFENSE && currank == FORCE_LEVEL_1 && ui_freeSaber.integer) ) { // Do nothing (written this way for clarity) } else { // Check if we can accrue the cost of this power. if (bgForcePowerCost[curpower][currank] > uiForceAvailable) { // We can't afford this power. Break to the next one. // Remove this power from the player's roster. uiForcePowersRank[curpower] = currank-1; break; } else { // Sure we can afford it. uiForceUsed += bgForcePowerCost[curpower][currank]; uiForceAvailable -= bgForcePowerCost[curpower][currank]; } } } } } }