codemp/ui/ui_force.c File Reference

#include "ui_local.h"
#include "../qcommon/qfiles.h"
#include "ui_force.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Functions

const char * UI_TeamName (int team)
void Menu_ShowItemByName (menuDef_t *menu, const char *p, qboolean bShow)
void UI_InitForceShaders (void)
void UI_DrawForceStars (rectDef_t *rect, float scale, vec4_t color, int textStyle, int forceindex, int val, int min, int max)
void UI_UpdateClientForcePowers (const char *teamArg)
int UI_TranslateFCFIndex (int index)
void UI_SaveForceTemplate ()
qboolean UI_TrueJediEnabled (void)
void UpdateForceUsed ()
void UI_ReadLegalForce (void)
void UI_UpdateForcePowers ()
qboolean UI_SkinColor_HandleKey (int flags, float *special, int key, int num, int min, int max, int type)
qboolean UI_ForceSide_HandleKey (int flags, float *special, int key, int num, int min, int max, int type)
qboolean UI_JediNonJedi_HandleKey (int flags, float *special, int key, int num, int min, int max, int type)
qboolean UI_ForceMaxRank_HandleKey (int flags, float *special, int key, int num, int min, int max, int type)
qboolean UI_ForcePowerRank_HandleKey (int flags, float *special, int key, int num, int min, int max, int type)
void UI_ForceConfigHandle (int oldindex, int newindex)

Variables

int uiForceSide = FORCE_LIGHTSIDE
int uiJediNonJedi = -1
int uiForceRank = FORCE_MASTERY_JEDI_KNIGHT
int uiMaxRank = MAX_FORCE_RANK
int uiMaxPoints = 20
int uiForceUsed = 0
int uiForceAvailable = 0
qboolean gTouchedForce = qfalse
vmCvar_t ui_freeSaber
vmCvar_t ui_forcePowerDisable
qboolean uiForcePowersDisabled [NUM_FORCE_POWERS]
int uiForcePowersRank [NUM_FORCE_POWERS]
int uiForcePowerDarkLight [NUM_FORCE_POWERS]
int uiForceStarShaders [NUM_FORCE_STAR_IMAGES][2]
int uiSaberColorShaders [NUM_SABER_COLORS]
int uiSkinColor
int uiHoldSkinColor
int gCustRank = 0
int gCustSide = 0
int gCustPowersRank [NUM_FORCE_POWERS]


Function Documentation

void Menu_ShowItemByName menuDef_t menu,
const char *  p,
qboolean  bShow
 

Definition at line 1467 of file ui_shared.c.

01467                                                                          {
01468         itemDef_t *item;
01469         int i;
01470         int count = Menu_ItemsMatchingGroup(menu, p);
01471         for (i = 0; i < count; i++) {
01472                 item = Menu_GetMatchingItemByNumber(menu, i, p);
01473                 if (item != NULL) {
01474                         if (bShow) {
01475                                 item->window.flags |= WINDOW_VISIBLE;
01476                         } else {
01477                                 item->window.flags &= ~WINDOW_VISIBLE;
01478                                 // stop cinematics playing in the window
01479                                 if (item->window.cinematic >= 0) {
01480                                         DC->stopCinematic(item->window.cinematic);
01481                                         item->window.cinematic = -1;
01482                                 }
01483                         }
01484                 }
01485         }
01486 }

void UI_DrawForceStars rectDef_t rect,
float  scale,
vec4_t  color,
int  textStyle,
int  forceindex,
int  val,
int  min,
int  max
 

Definition at line 129 of file ui_force.c.

References bgForcePowerCost, FORCE_LEVEL_1, min, NULL, trap_R_SetColor(), UI_DrawHandlePic(), uiForcePowersDisabled, uiForceStarShaders, vec4_t, rectDef_t::x, and rectDef_t::y.

00130 {
00131         int     i,pad = 4;
00132         int     xPos,width = 16;
00133         int starcolor;
00134 
00135         if (val < min || val > max) 
00136         {
00137                 val = min;
00138         }
00139 
00140         if (1)  // if (val)
00141         {
00142                 xPos = rect->x;
00143 
00144                 for (i=FORCE_LEVEL_1;i<=max;i++)
00145                 {
00146                         starcolor = bgForcePowerCost[forceindex][i];
00147 
00148                         if (uiForcePowersDisabled[forceindex])
00149                         {
00150                                 vec4_t grColor = {0.2f, 0.2f, 0.2f, 1.0f};
00151                                 trap_R_SetColor(grColor);
00152                         }
00153 
00154                         if (val >= i)
00155                         {       // Draw a star.
00156                                 UI_DrawHandlePic( xPos, rect->y+6, width, width, uiForceStarShaders[starcolor][1] );
00157                         }
00158                         else
00159                         {       // Draw a circle.
00160                                 UI_DrawHandlePic( xPos, rect->y+6, width, width, uiForceStarShaders[starcolor][0] );
00161                         }
00162 
00163                         if (uiForcePowersDisabled[forceindex])
00164                         {
00165                                 trap_R_SetColor(NULL);
00166                         }
00167 
00168                         xPos += width + pad;
00169                 }
00170         }
00171 }

void UI_ForceConfigHandle int  oldindex,
int  newindex
 

Definition at line 1110 of file ui_force.c.

References atoi(), BG_LegalizedForcePowers(), bgForcePowerCost, CS_SERVERINFO, fileHandle_t, FORCE_DARKSIDE, FORCE_LEVEL_1, FORCE_LEVEL_3, FORCE_LIGHTSIDE, uiInfo_t::forceConfigCount, uiInfo_t::forceConfigDarkIndexBegin, uiInfo_t::forceConfigLightIndexBegin, uiInfo_t::forceConfigNames, forceMasteryPoints, FP_LEVITATION, FP_SABER_DEFENSE, FP_SABER_OFFENSE, FS_READ, gCustPowersRank, gCustRank, gCustSide, gTouchedForce, Info_ValueForKey(), vmCvar_t::integer, MAX_INFO_VALUE, NUM_FORCE_POWERS, qtrue, TEAM_BLUE, TEAM_RED, trap_Cvar_VariableValue(), trap_FS_FCloseFile(), trap_FS_FOpenFile(), trap_FS_Read(), trap_GetConfigString(), ui_freeSaber, uiForceAvailable, uiForcePowerDarkLight, uiForcePowersRank, uiForceRank, uiForceSide, uiForceUsed, uiInfo, uiMaxRank, UpdateForceUsed(), and va().

Referenced by UI_FeederSelection().

01111 {
01112         fileHandle_t f;
01113         int len = 0;
01114         int i = 0;
01115         int c = 0;
01116         int iBuf = 0, forcePowerRank, currank;
01117         char fcfBuffer[8192];
01118         char singleBuf[64];
01119         char info[MAX_INFO_VALUE];
01120         int forceTeam = 0;
01121 
01122         if (oldindex == 0)
01123         { //switching out from custom config, so first shove the current values into the custom storage
01124                 i = 0;
01125 
01126                 while (i < NUM_FORCE_POWERS)
01127                 {
01128                         gCustPowersRank[i] = uiForcePowersRank[i];
01129                         i++;
01130                 }
01131                 gCustRank = uiForceRank;
01132                 gCustSide = uiForceSide;
01133         }
01134 
01135         if (newindex == 0)
01136         { //switching back to custom, shove the values back in from the custom storage
01137                 i = 0;
01138                 uiForceUsed = 0;
01139                 gTouchedForce = qtrue;
01140 
01141                 while (i < NUM_FORCE_POWERS)
01142                 {
01143                         uiForcePowersRank[i] = gCustPowersRank[i];
01144                         uiForceUsed += uiForcePowersRank[i];
01145                         i++;
01146                 }
01147                 uiForceRank = gCustRank;
01148                 uiForceSide = gCustSide;
01149 
01150                 UpdateForceUsed();
01151                 return;
01152         }
01153 
01154         //If we made it here, we want to load in a new config
01155         if (uiForceSide == FORCE_LIGHTSIDE)
01156         { //we should only be displaying lightside configs, so.. look in the light folder
01157                 newindex += uiInfo.forceConfigLightIndexBegin;
01158                 if (newindex >= uiInfo.forceConfigCount)
01159                 {
01160                         return;
01161                 }
01162                 len = trap_FS_FOpenFile(va("forcecfg/light/%s.fcf", uiInfo.forceConfigNames[newindex]), &f, FS_READ);
01163         }
01164         else
01165         { //else dark
01166                 newindex += uiInfo.forceConfigDarkIndexBegin;
01167                 if (newindex >= uiInfo.forceConfigCount || newindex > uiInfo.forceConfigLightIndexBegin)
01168                 { //dark gets read in before light
01169                         return;
01170                 }
01171                 len = trap_FS_FOpenFile(va("forcecfg/dark/%s.fcf", uiInfo.forceConfigNames[newindex]), &f, FS_READ);
01172         }
01173 
01174         if (len <= 0)
01175         { //This should not have happened. But, before we quit out, attempt searching the other light/dark folder for the file.
01176                 if (uiForceSide == FORCE_LIGHTSIDE)
01177                 {
01178                         len = trap_FS_FOpenFile(va("forcecfg/dark/%s.fcf", uiInfo.forceConfigNames[newindex]), &f, FS_READ);
01179                 }
01180                 else
01181                 {
01182                         len = trap_FS_FOpenFile(va("forcecfg/light/%s.fcf", uiInfo.forceConfigNames[newindex]), &f, FS_READ);
01183                 }
01184 
01185                 if (len <= 0)
01186                 { //still failure? Oh well.
01187                         return;
01188                 }
01189         }
01190 
01191         if (len >= 8192)
01192         {
01193                 return;
01194         }
01195 
01196         trap_FS_Read(fcfBuffer, len, f);
01197         fcfBuffer[len] = 0;
01198         trap_FS_FCloseFile(f);
01199 
01200         i = 0;
01201 
01202         info[0] = '\0';
01203         trap_GetConfigString(CS_SERVERINFO, info, sizeof(info));
01204 
01205         if (atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) ))
01206         {
01207                 switch((int)(trap_Cvar_VariableValue("ui_myteam")))
01208                 {
01209                 case TEAM_RED:
01210                         forceTeam = FORCE_DARKSIDE;
01211                         break;
01212                 case TEAM_BLUE:
01213                         forceTeam = FORCE_LIGHTSIDE;
01214                         break;
01215                 default:
01216                         break;
01217                 }
01218         }
01219 
01220         BG_LegalizedForcePowers(fcfBuffer, uiMaxRank, ui_freeSaber.integer, forceTeam, atoi( Info_ValueForKey( info, "g_gametype" )), 0);
01221         //legalize the config based on the max rank
01222 
01223         //now that we're done with the handle, it's time to parse our force data out of the string
01224         //we store strings in rank-side-xxxxxxxxx format (where the x's are individual force power levels)
01225         while (fcfBuffer[i] && fcfBuffer[i] != '-')
01226         {
01227                 singleBuf[c] = fcfBuffer[i];
01228                 c++;
01229                 i++;
01230         }
01231         singleBuf[c] = 0;
01232         c = 0;
01233         i++;
01234 
01235         iBuf = atoi(singleBuf);
01236 
01237         if (iBuf > uiMaxRank || iBuf < 0)
01238         { //this force config uses a rank level higher than our currently restricted level.. so we can't use it
01239           //FIXME: Print a message indicating this to the user
01240                 return;
01241         }
01242 
01243         uiForceRank = iBuf;
01244 
01245         while (fcfBuffer[i] && fcfBuffer[i] != '-')
01246         {
01247                 singleBuf[c] = fcfBuffer[i];
01248                 c++;
01249                 i++;
01250         }
01251         singleBuf[c] = 0;
01252         c = 0;
01253         i++;
01254 
01255         uiForceSide = atoi(singleBuf);
01256 
01257         if (uiForceSide != FORCE_LIGHTSIDE &&
01258                 uiForceSide != FORCE_DARKSIDE)
01259         {
01260                 uiForceSide = FORCE_LIGHTSIDE;
01261                 return;
01262         }
01263 
01264         //clear out the existing powers
01265         while (c < NUM_FORCE_POWERS)
01266         {
01267                 /*
01268                 if (c==FP_LEVITATION)
01269                 {
01270                         uiForcePowersRank[c]=1;
01271                 }
01272                 else if (c==FP_SABER_OFFENSE && ui_freeSaber.integer)
01273                 {
01274                         uiForcePowersRank[c]=1;
01275                 }
01276                 else if (c==FP_SABER_DEFENSE && ui_freeSaber.integer)
01277                 {
01278                         uiForcePowersRank[c]=1;
01279                 }
01280                 else
01281                 {
01282                         uiForcePowersRank[c] = 0;
01283                 }
01284                 */
01285                 //rww - don't need to do these checks. Just trust whatever the saber config says.
01286                 uiForcePowersRank[c] = 0;
01287                 c++;
01288         }
01289         uiForceUsed = 0;
01290         uiForceAvailable = forceMasteryPoints[uiForceRank];
01291         gTouchedForce = qtrue;
01292 
01293         for (c=0;fcfBuffer[i]&&c<NUM_FORCE_POWERS;c++,i++)
01294         {
01295                 singleBuf[0] = fcfBuffer[i];
01296                 singleBuf[1] = 0;
01297                 iBuf = atoi(singleBuf); // So, that means that Force Power "c" wants to be set to rank "iBuf".
01298                 
01299                 if (iBuf < 0)
01300                 {
01301                         iBuf = 0;
01302                 }
01303 
01304                 forcePowerRank = iBuf;
01305 
01306                 if (forcePowerRank > FORCE_LEVEL_3 || forcePowerRank < 0)
01307                 { //err..  not correct
01308                         continue;  // skip this power
01309                 }
01310 
01311                 if (uiForcePowerDarkLight[c] && uiForcePowerDarkLight[c] != uiForceSide)
01312                 { //Apparently the user has crafted a force config that has powers that don't fit with the config's side.
01313                         continue;  // skip this power
01314                 }
01315 
01316                 // Accrue cost for each assigned rank for this power.
01317                 for (currank=FORCE_LEVEL_1;currank<=forcePowerRank;currank++)
01318                 {       
01319                         if (bgForcePowerCost[c][currank] > uiForceAvailable)
01320                         {       // Break out, we can't afford any more power.
01321                                 break;
01322                         }
01323                         // Pay for this rank of this power.
01324                         uiForceUsed += bgForcePowerCost[c][currank];
01325                         uiForceAvailable -= bgForcePowerCost[c][currank];
01326 
01327                         uiForcePowersRank[c]++;
01328                 }
01329         }
01330 
01331         if (uiForcePowersRank[FP_LEVITATION] < 1)
01332         {
01333                 uiForcePowersRank[FP_LEVITATION]=1;
01334         }
01335         if (uiForcePowersRank[FP_SABER_OFFENSE] < 1 && ui_freeSaber.integer)
01336         {
01337                 uiForcePowersRank[FP_SABER_OFFENSE]=1;
01338         }
01339         if (uiForcePowersRank[FP_SABER_DEFENSE] < 1 && ui_freeSaber.integer)
01340         {
01341                 uiForcePowersRank[FP_SABER_DEFENSE]=1;
01342         }
01343 
01344         UpdateForceUsed();
01345 }

qboolean UI_ForceMaxRank_HandleKey int  flags,
float *  special,
int  key,
int  num,
int  min,
int  max,
int  type
 

Definition at line 947 of file ui_force.c.

References A_ENTER, A_KP_ENTER, A_MOUSE1, A_MOUSE2, gTouchedForce, min, qboolean, qfalse, qtrue, trap_Cvar_Set(), uiMaxRank, UpdateForceUsed(), and va().

00948 {
00949   if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER) 
00950   {
00951         int i = num;
00952 
00953         if (key == A_MOUSE2)
00954         {
00955             i--;
00956         }
00957         else
00958         {
00959             i++;
00960         }
00961 
00962     if (i < min)
00963         {
00964                 i = max;
00965         }
00966         else if (i > max)
00967         {
00968       i = min;
00969     }
00970 
00971     num = i;
00972 
00973         uiMaxRank = num;
00974 
00975         trap_Cvar_Set( "g_maxForceRank", va("%i", num));
00976 
00977         // The update force used will remove overallocated powers automatically.
00978         UpdateForceUsed();
00979 
00980         gTouchedForce = qtrue;
00981 
00982     return qtrue;
00983   }
00984   return qfalse;
00985 }

qboolean UI_ForcePowerRank_HandleKey int  flags,
float *  special,
int  key,
int  num,
int  min,
int  max,
int  type
 

Definition at line 989 of file ui_force.c.

References A_BACKSPACE, A_ENTER, A_KP_ENTER, A_MOUSE1, A_MOUSE2, bgForcePowerCost, FP_SABER_DEFENSE, FP_SABER_OFFENSE, FP_SABERTHROW, gTouchedForce, vmCvar_t::integer, min, qboolean, qfalse, qtrue, UI_FORCE_RANK, UI_FORCE_RANK_LEVITATION, UI_FORCE_RANK_SABERATTACK, UI_FORCE_RANK_SABERDEFEND, ui_freeSaber, uiForceAvailable, uiForcePowerDarkLight, uiForcePowersDisabled, uiForcePowersRank, uiForceSide, uiForceUsed, and UpdateForceUsed().

00990 {
00991         qboolean raising;
00992 
00993         if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER || key == A_BACKSPACE) 
00994         {
00995                 int forcepower, rank;
00996 
00997                 //this will give us the index as long as UI_FORCE_RANK is always one below the first force rank index
00998                 forcepower = (type-UI_FORCE_RANK)-1;
00999                 
01000                 //the power is disabled on the server
01001                 if (uiForcePowersDisabled[forcepower])
01002                 {
01003                         return qtrue;
01004                 }
01005 
01006                 // If we are not on the same side as a power, or if we are not of any rank at all.
01007                 if (uiForcePowerDarkLight[forcepower] && uiForceSide != uiForcePowerDarkLight[forcepower])
01008                 {
01009                         return qtrue;
01010                 }
01011                 else if (forcepower == FP_SABER_DEFENSE || forcepower == FP_SABERTHROW)
01012                 {       // Saberdefend and saberthrow can't be bought if there is no saberattack
01013                         if (uiForcePowersRank[FP_SABER_OFFENSE] < 1)
01014                         {
01015                                 return qtrue;
01016                         }
01017                 }
01018 
01019                 if (type == UI_FORCE_RANK_LEVITATION)
01020                 {
01021                         min += 1;
01022                 }
01023                 if (type == UI_FORCE_RANK_SABERATTACK && ui_freeSaber.integer)
01024                 {
01025                         min += 1;
01026                 }
01027                 if (type == UI_FORCE_RANK_SABERDEFEND && ui_freeSaber.integer)
01028                 {
01029                         min += 1;
01030                 }
01031 
01032                 if (key == A_MOUSE2 || key == A_BACKSPACE)
01033                 {       // Lower a point.
01034                         if (uiForcePowersRank[forcepower]<=min)
01035                         {
01036                                 return qtrue;
01037                         }
01038                         raising = qfalse;
01039                 }
01040                 else
01041                 {       // Raise a point.
01042                         if (uiForcePowersRank[forcepower]>=max)
01043                         {
01044                                 return qtrue;
01045                         }
01046                         raising = qtrue;
01047                 }
01048 
01049                 if (raising)
01050                 {       // Check if we can accrue the cost of this power.
01051                         rank = uiForcePowersRank[forcepower]+1;
01052                         if (bgForcePowerCost[forcepower][rank] > uiForceAvailable)
01053                         {       // We can't afford this power.  Abandon ship.
01054                                 return qtrue;
01055                         }
01056                         else
01057                         {       // Sure we can afford it.
01058                                 uiForceUsed += bgForcePowerCost[forcepower][rank];
01059                                 uiForceAvailable -= bgForcePowerCost[forcepower][rank];
01060                                 uiForcePowersRank[forcepower]=rank;
01061                         }
01062                 }
01063                 else
01064                 {       // Lower the point.
01065                         rank = uiForcePowersRank[forcepower];
01066                         uiForceUsed -= bgForcePowerCost[forcepower][rank];
01067                         uiForceAvailable += bgForcePowerCost[forcepower][rank];
01068                         uiForcePowersRank[forcepower]--;
01069                 }
01070 
01071                 UpdateForceUsed();
01072 
01073                 gTouchedForce = qtrue;
01074 
01075                 return qtrue;
01076         }
01077         return qfalse;
01078 }

qboolean UI_ForceSide_HandleKey int  flags,
float *  special,
int  key,
int  num,
int  min,
int  max,
int  type
 

Definition at line 802 of file ui_force.c.

References A_ENTER, A_KP_ENTER, A_MOUSE1, A_MOUSE2, atoi(), CS_SERVERINFO, FEEDER_FORCECFG, gTouchedForce, Info_ValueForKey(), MAX_INFO_VALUE, Menu_SetFeederSelection(), min, NULL, NUM_FORCE_POWERS, qboolean, qfalse, qtrue, TEAM_BLUE, TEAM_RED, trap_Cvar_VariableValue(), trap_GetConfigString(), uiForcePowerDarkLight, uiForcePowersRank, uiForceSide, and UpdateForceUsed().

00803 {
00804         char info[MAX_INFO_VALUE];
00805 
00806         info[0] = '\0';
00807         trap_GetConfigString(CS_SERVERINFO, info, sizeof(info));
00808 
00809         if (atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) ))
00810         {
00811                 switch((int)(trap_Cvar_VariableValue("ui_myteam")))
00812                 {
00813                 case TEAM_RED:
00814                         return qfalse;
00815                 case TEAM_BLUE:
00816                         return qfalse;
00817                 default:
00818                         break;
00819                 }
00820         }
00821 
00822         if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER) 
00823         {
00824                 int i = num;
00825                 int x = 0;
00826 
00827                 //update the feeder item selection, it might be different depending on side
00828                 Menu_SetFeederSelection(NULL, FEEDER_FORCECFG, 0, NULL);
00829 
00830                 if (key == A_MOUSE2)
00831                 {
00832                         i--;
00833                 }
00834                 else
00835                 {
00836                         i++;
00837                 }
00838 
00839                 if (i < min)
00840                 {
00841                         i = max;
00842                 }
00843                 else if (i > max)
00844                 {
00845                         i = min;
00846                 }
00847 
00848                 num = i;
00849 
00850                 uiForceSide = num;
00851 
00852                 // Resetting power ranks based on if light or dark side is chosen
00853                 while (x < NUM_FORCE_POWERS)
00854                 {
00855                         if (uiForcePowerDarkLight[x] && uiForceSide != uiForcePowerDarkLight[x])
00856                         {
00857                                 uiForcePowersRank[x] = 0;
00858                         }
00859                         x++;
00860                 }
00861 
00862                 UpdateForceUsed();
00863 
00864                 gTouchedForce = qtrue;
00865                 return qtrue;
00866         }
00867         return qfalse;
00868 }

void UI_InitForceShaders void   ) 
 

Definition at line 99 of file ui_force.c.

References SABER_BLUE, SABER_GREEN, SABER_ORANGE, SABER_PURPLE, SABER_RED, SABER_YELLOW, trap_R_RegisterShaderNoMip(), uiForceStarShaders, and uiSaberColorShaders.

Referenced by _UI_Init().

00100 {
00101         uiForceStarShaders[0][0] = trap_R_RegisterShaderNoMip("forcestar0");
00102         uiForceStarShaders[0][1] = trap_R_RegisterShaderNoMip("forcestar0");
00103         uiForceStarShaders[1][0] = trap_R_RegisterShaderNoMip("forcecircle1");
00104         uiForceStarShaders[1][1] = trap_R_RegisterShaderNoMip("forcestar1");
00105         uiForceStarShaders[2][0] = trap_R_RegisterShaderNoMip("forcecircle2");
00106         uiForceStarShaders[2][1] = trap_R_RegisterShaderNoMip("forcestar2");
00107         uiForceStarShaders[3][0] = trap_R_RegisterShaderNoMip("forcecircle3");
00108         uiForceStarShaders[3][1] = trap_R_RegisterShaderNoMip("forcestar3");
00109         uiForceStarShaders[4][0] = trap_R_RegisterShaderNoMip("forcecircle4");
00110         uiForceStarShaders[4][1] = trap_R_RegisterShaderNoMip("forcestar4");
00111         uiForceStarShaders[5][0] = trap_R_RegisterShaderNoMip("forcecircle5");
00112         uiForceStarShaders[5][1] = trap_R_RegisterShaderNoMip("forcestar5");
00113         uiForceStarShaders[6][0] = trap_R_RegisterShaderNoMip("forcecircle6");
00114         uiForceStarShaders[6][1] = trap_R_RegisterShaderNoMip("forcestar6");
00115         uiForceStarShaders[7][0] = trap_R_RegisterShaderNoMip("forcecircle7");
00116         uiForceStarShaders[7][1] = trap_R_RegisterShaderNoMip("forcestar7");
00117         uiForceStarShaders[8][0] = trap_R_RegisterShaderNoMip("forcecircle8");
00118         uiForceStarShaders[8][1] = trap_R_RegisterShaderNoMip("forcestar8");
00119 
00120         uiSaberColorShaders[SABER_RED]          = trap_R_RegisterShaderNoMip("menu/art/saber_red");
00121         uiSaberColorShaders[SABER_ORANGE]       = trap_R_RegisterShaderNoMip("menu/art/saber_orange");
00122         uiSaberColorShaders[SABER_YELLOW]       = trap_R_RegisterShaderNoMip("menu/art/saber_yellow");
00123         uiSaberColorShaders[SABER_GREEN]        = trap_R_RegisterShaderNoMip("menu/art/saber_green");
00124         uiSaberColorShaders[SABER_BLUE]         = trap_R_RegisterShaderNoMip("menu/art/saber_blue");
00125         uiSaberColorShaders[SABER_PURPLE]       = trap_R_RegisterShaderNoMip("menu/art/saber_purple");
00126 }

qboolean UI_JediNonJedi_HandleKey int  flags,
float *  special,
int  key,
int  num,
int  min,
int  max,
int  type
 

Definition at line 870 of file ui_force.c.

References A_ENTER, A_KP_ENTER, A_MOUSE1, A_MOUSE2, CS_SERVERINFO, FORCE_LEVEL_1, FP_LEVITATION, FP_SABER_OFFENSE, gTouchedForce, MAX_INFO_VALUE, min, NULL, NUM_FORCE_POWERS, qboolean, qfalse, qtrue, TEAM_SPECTATOR, trap_Cvar_VariableValue(), trap_GetConfigString(), UI_TeamName(), UI_TrueJediEnabled(), UI_UpdateClientForcePowers(), uiForcePowersRank, uiJediNonJedi, and UpdateForceUsed().

00871 {
00872         char info[MAX_INFO_VALUE];
00873 
00874         info[0] = '\0';
00875         trap_GetConfigString(CS_SERVERINFO, info, sizeof(info));
00876 
00877         if ( !UI_TrueJediEnabled() )
00878         {//true jedi mode is not set
00879                 return qfalse;
00880         }
00881 
00882         if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER) 
00883         {
00884                 int i = num;
00885                 int x = 0;
00886 
00887                 if (key == A_MOUSE2)
00888                 {
00889                         i--;
00890                 }
00891                 else
00892                 {
00893                         i++;
00894                 }
00895 
00896                 if (i < min)
00897                 {
00898                         i = max;
00899                 }
00900                 else if (i > max)
00901                 {
00902                         i = min;
00903                 }
00904 
00905                 num = i;
00906 
00907                 uiJediNonJedi = num;
00908 
00909                 // Resetting power ranks based on if light or dark side is chosen
00910                 if ( !num )
00911                 {//not a jedi?
00912                         int myTeam = (int)(trap_Cvar_VariableValue("ui_myteam"));
00913                         while ( x < NUM_FORCE_POWERS )
00914                         {//clear all force powers
00915                                 uiForcePowersRank[x] = 0;
00916                                 x++;
00917                         }
00918                         if ( myTeam != TEAM_SPECTATOR )
00919                         {
00920                                 UI_UpdateClientForcePowers(UI_TeamName(myTeam));//will cause him to respawn, if it's been 5 seconds since last one
00921                         }
00922                         else
00923                         {
00924                                 UI_UpdateClientForcePowers(NULL);//just update powers
00925                         }
00926                 }
00927                 else if ( num )
00928                 {//a jedi, set the minimums, hopefuly they know to set the rest!
00929                         if ( uiForcePowersRank[FP_LEVITATION] < FORCE_LEVEL_1 )
00930                         {//force jump 1 minimum
00931                                 uiForcePowersRank[FP_LEVITATION] = FORCE_LEVEL_1;
00932                         }
00933                         if ( uiForcePowersRank[FP_SABER_OFFENSE] < FORCE_LEVEL_1 )
00934                         {//saber attack 1, minimum
00935                                 uiForcePowersRank[FP_SABER_OFFENSE] = FORCE_LEVEL_1;
00936                         }
00937                 }
00938 
00939                 UpdateForceUsed();
00940 
00941                 gTouchedForce = qtrue;
00942                 return qtrue;
00943         }
00944         return qfalse;
00945 }

void UI_ReadLegalForce void   ) 
 

Definition at line 465 of file ui_force.c.

References atoi(), BG_LegalizedForcePowers(), bgForcePowerCost, Com_sprintf(), CS_SERVERINFO, FORCE_DARKSIDE, FORCE_LEVEL_1, FORCE_LEVEL_3, FORCE_LIGHTSIDE, forceMasteryPoints, FP_LEVITATION, FP_SABER_DEFENSE, FP_SABER_OFFENSE, gTouchedForce, Info_ValueForKey(), vmCvar_t::integer, MAX_INFO_VALUE, NULL, NUM_FORCE_POWERS, qboolean, qfalse, qtrue, strlen(), TEAM_BLUE, TEAM_RED, trap_Cvar_VariableValue(), trap_GetConfigString(), ui_freeSaber, UI_UpdateClientForcePowers(), uiForceAvailable, uiForcePowerDarkLight, uiForcePowersRank, uiForceRank, uiForceSide, uiForceUsed, uiMaxRank, and UpdateForceUsed().

Referenced by _UI_Refresh().

00466 {
00467         char fcfString[512];
00468         char forceStringValue[4];
00469         int strPlace = 0;
00470         int forcePlace = 0;
00471         int i = 0;
00472         char singleBuf[64];
00473         char info[MAX_INFO_VALUE];
00474         int c = 0;
00475         int iBuf = 0;
00476         int forcePowerRank = 0;
00477         int currank = 0;
00478         int forceTeam = 0;
00479         qboolean updateForceLater = qfalse;
00480 
00481         //First, stick them into a string.
00482         Com_sprintf(fcfString, sizeof(fcfString), "%i-%i-", uiForceRank, uiForceSide);
00483         strPlace = strlen(fcfString);
00484 
00485         while (forcePlace < NUM_FORCE_POWERS)
00486         {
00487                 Com_sprintf(forceStringValue, sizeof(forceStringValue), "%i", uiForcePowersRank[forcePlace]);
00488                 //Just use the force digit even if multiple digits. Shouldn't be longer than 1.
00489                 fcfString[strPlace] = forceStringValue[0];
00490                 strPlace++;
00491                 forcePlace++;
00492         }
00493         fcfString[strPlace] = '\n';
00494         fcfString[strPlace+1] = 0;
00495 
00496         info[0] = '\0';
00497         trap_GetConfigString(CS_SERVERINFO, info, sizeof(info));
00498 
00499         if (atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) ))
00500         {
00501                 switch((int)(trap_Cvar_VariableValue("ui_myteam")))
00502                 {
00503                 case TEAM_RED:
00504                         forceTeam = FORCE_DARKSIDE;
00505                         break;
00506                 case TEAM_BLUE:
00507                         forceTeam = FORCE_LIGHTSIDE;
00508                         break;
00509                 default:
00510                         break;
00511                 }
00512         }
00513         //Second, legalize them.
00514         if (!BG_LegalizedForcePowers(fcfString, uiMaxRank, ui_freeSaber.integer, forceTeam, atoi( Info_ValueForKey( info, "g_gametype" )), 0))
00515         { //if they were illegal, we should refresh them.
00516                 updateForceLater = qtrue;
00517         }
00518 
00519         //Lastly, put them back into the UI storage from the legalized string
00520         i = 0;
00521 
00522         while (fcfString[i] && fcfString[i] != '-')
00523         {
00524                 singleBuf[c] = fcfString[i];
00525                 c++;
00526                 i++;
00527         }
00528         singleBuf[c] = 0;
00529         c = 0;
00530         i++;
00531 
00532         iBuf = atoi(singleBuf);
00533 
00534         if (iBuf > uiMaxRank || iBuf < 0)
00535         { //this force config uses a rank level higher than our currently restricted level.. so we can't use it
00536           //FIXME: Print a message indicating this to the user
00537         //      return;
00538         }
00539 
00540         uiForceRank = iBuf;
00541 
00542         while (fcfString[i] && fcfString[i] != '-')
00543         {
00544                 singleBuf[c] = fcfString[i];
00545                 c++;
00546                 i++;
00547         }
00548         singleBuf[c] = 0;
00549         c = 0;
00550         i++;
00551 
00552         uiForceSide = atoi(singleBuf);
00553 
00554         if (uiForceSide != FORCE_LIGHTSIDE &&
00555                 uiForceSide != FORCE_DARKSIDE)
00556         {
00557                 uiForceSide = FORCE_LIGHTSIDE;
00558                 return;
00559         }
00560 
00561         //clear out the existing powers
00562         while (c < NUM_FORCE_POWERS)
00563         {
00564                 uiForcePowersRank[c] = 0;
00565                 c++;
00566         }
00567         uiForceUsed = 0;
00568         uiForceAvailable = forceMasteryPoints[uiForceRank];
00569         gTouchedForce = qtrue;
00570 
00571         for (c=0;fcfString[i]&&c<NUM_FORCE_POWERS;c++,i++)
00572         {
00573                 singleBuf[0] = fcfString[i];
00574                 singleBuf[1] = 0;
00575                 iBuf = atoi(singleBuf); // So, that means that Force Power "c" wants to be set to rank "iBuf".
00576                 
00577                 if (iBuf < 0)
00578                 {
00579                         iBuf = 0;
00580                 }
00581 
00582                 forcePowerRank = iBuf;
00583 
00584                 if (forcePowerRank > FORCE_LEVEL_3 || forcePowerRank < 0)
00585                 { //err..  not correct
00586                         continue;  // skip this power
00587                 }
00588 
00589                 if (uiForcePowerDarkLight[c] && uiForcePowerDarkLight[c] != uiForceSide)
00590                 { //Apparently the user has crafted a force config that has powers that don't fit with the config's side.
00591                         continue;  // skip this power
00592                 }
00593 
00594                 // Accrue cost for each assigned rank for this power.
00595                 for (currank=FORCE_LEVEL_1;currank<=forcePowerRank;currank++)
00596                 {       
00597                         if (bgForcePowerCost[c][currank] > uiForceAvailable)
00598                         {       // Break out, we can't afford any more power.
00599                                 break;
00600                         }
00601                         // Pay for this rank of this power.
00602                         uiForceUsed += bgForcePowerCost[c][currank];
00603                         uiForceAvailable -= bgForcePowerCost[c][currank];
00604 
00605                         uiForcePowersRank[c]++;
00606                 }
00607         }
00608 
00609         if (uiForcePowersRank[FP_LEVITATION] < 1)
00610         {
00611                 uiForcePowersRank[FP_LEVITATION]=1;
00612         }
00613         if (uiForcePowersRank[FP_SABER_OFFENSE] < 1 && ui_freeSaber.integer)
00614         {
00615                 uiForcePowersRank[FP_SABER_OFFENSE]=1;
00616         }
00617         if (uiForcePowersRank[FP_SABER_DEFENSE] < 1 && ui_freeSaber.integer)
00618         {
00619                 uiForcePowersRank[FP_SABER_DEFENSE]=1;
00620         }
00621 
00622         UpdateForceUsed();
00623 
00624         if (updateForceLater)
00625         {
00626                 gTouchedForce = qtrue;
00627                 UI_UpdateClientForcePowers(NULL);
00628         }
00629 }

void UI_SaveForceTemplate  ) 
 

Definition at line 210 of file ui_force.c.

References Com_Printf(), Com_sprintf(), FEEDER_FORCECFG, fileHandle_t, FORCE_DARKSIDE, FORCE_LIGHTSIDE, uiInfo_t::forceConfigCount, uiInfo_t::forceConfigNames, uiInfo_t::forceConfigSide, FS_WRITE, Menu_SetFeederSelection(), NULL, NUM_FORCE_POWERS, Q_stricmp(), qboolean, qfalse, qtrue, strlen(), trap_FS_FCloseFile(), trap_FS_FOpenFile(), trap_FS_Write(), UI_Cvar_VariableString(), UI_LoadForceConfig_List(), UI_TranslateFCFIndex(), uiForcePowersRank, uiForceRank, uiForceSide, uiInfo, and va().

00211 {
00212         char *selectedName = UI_Cvar_VariableString("ui_SaveFCF");
00213         char fcfString[512];
00214         char forceStringValue[4];
00215         fileHandle_t f;
00216         int strPlace = 0;
00217         int forcePlace = 0;
00218         int i = 0;
00219         qboolean foundFeederItem = qfalse;
00220 
00221         if (!selectedName || !selectedName[0])
00222         {
00223                 Com_Printf("You did not provide a name for the template.\n");
00224                 return;
00225         }
00226 
00227         if (uiForceSide == FORCE_LIGHTSIDE)
00228         { //write it into the light side folder
00229                 trap_FS_FOpenFile(va("forcecfg/light/%s.fcf", selectedName), &f, FS_WRITE);
00230         }
00231         else
00232         { //if it isn't light it must be dark
00233                 trap_FS_FOpenFile(va("forcecfg/dark/%s.fcf", selectedName), &f, FS_WRITE);
00234         }
00235 
00236         if (!f)
00237         {
00238                 Com_Printf("There was an error writing the template file (read-only?).\n");
00239                 return;
00240         }
00241 
00242         Com_sprintf(fcfString, sizeof(fcfString), "%i-%i-", uiForceRank, uiForceSide);
00243         strPlace = strlen(fcfString);
00244 
00245         while (forcePlace < NUM_FORCE_POWERS)
00246         {
00247                 Com_sprintf(forceStringValue, sizeof(forceStringValue), "%i", uiForcePowersRank[forcePlace]);
00248                 //Just use the force digit even if multiple digits. Shouldn't be longer than 1.
00249                 fcfString[strPlace] = forceStringValue[0];
00250                 strPlace++;
00251                 forcePlace++;
00252         }
00253         fcfString[strPlace] = '\n';
00254         fcfString[strPlace+1] = 0;
00255 
00256         trap_FS_Write(fcfString, strlen(fcfString), f);
00257         trap_FS_FCloseFile(f);
00258 
00259         Com_Printf("Template saved as \"%s\".\n", selectedName);
00260 
00261         //Now, update the FCF list
00262         UI_LoadForceConfig_List();
00263 
00264         //Then, scroll through and select the template for the file we just saved
00265         while (i < uiInfo.forceConfigCount)
00266         {
00267                 if (!Q_stricmp(uiInfo.forceConfigNames[i], selectedName))
00268                 {
00269                         if ((uiForceSide == FORCE_LIGHTSIDE && uiInfo.forceConfigSide[i]) ||
00270                                 (uiForceSide == FORCE_DARKSIDE && !uiInfo.forceConfigSide[i]))
00271                         {
00272                                 Menu_SetFeederSelection(NULL, FEEDER_FORCECFG, UI_TranslateFCFIndex(i), NULL);
00273                                 foundFeederItem = qtrue;
00274                         }
00275                 }
00276 
00277                 i++;
00278         }
00279 
00280         //Else, go back to 0
00281         if (!foundFeederItem)
00282         {
00283                 Menu_SetFeederSelection(NULL, FEEDER_FORCECFG, 0, NULL);
00284         }
00285 }

qboolean UI_SkinColor_HandleKey int  flags,
float *  special,
int  key,
int  num,
int  min,
int  max,
int  type
 

Definition at line 762 of file ui_force.c.

References A_ENTER, A_KP_ENTER, A_MOUSE1, A_MOUSE2, FEEDER_Q3HEADS, min, NULL, uiInfo_t::q3SelectedHead, qboolean, qfalse, qtrue, UI_FeederSelection(), uiHoldSkinColor, uiInfo, and uiSkinColor.

00763 {
00764   if (key == A_MOUSE1 || key == A_MOUSE2 || key == A_ENTER || key == A_KP_ENTER) 
00765   {
00766         int i = num;
00767 
00768         if (key == A_MOUSE2)
00769         {
00770             i--;
00771         }
00772         else
00773         {
00774             i++;
00775         }
00776 
00777     if (i < min)
00778         {
00779                 i = max;
00780         }
00781         else if (i > max)
00782         {
00783       i = min;
00784     }
00785 
00786     num = i;
00787 
00788         uiSkinColor = num;
00789 
00790         uiHoldSkinColor = uiSkinColor;
00791 
00792         UI_FeederSelection(FEEDER_Q3HEADS, uiInfo.q3SelectedHead, NULL);
00793 
00794     return qtrue;
00795   }
00796   return qfalse;
00797 }

const char* UI_TeamName int  team  ) 
 

Definition at line 621 of file ui_main.c.

References TEAM_BLUE, TEAM_RED, and TEAM_SPECTATOR.

Referenced by UI_JediNonJedi_HandleKey(), and UpdateForceUsed().

00621                                    {
00622         if (team==TEAM_RED)
00623                 return "RED";
00624         else if (team==TEAM_BLUE)
00625                 return "BLUE";
00626         else if (team==TEAM_SPECTATOR)
00627                 return "SPECTATOR";
00628         return "FREE";
00629 }

int UI_TranslateFCFIndex int  index  ) 
 

Definition at line 200 of file ui_force.c.

References FORCE_LIGHTSIDE, uiInfo_t::forceConfigDarkIndexBegin, uiInfo_t::forceConfigLightIndexBegin, uiForceSide, and uiInfo.

Referenced by UI_SaveForceTemplate().

00201 {
00202         if (uiForceSide == FORCE_LIGHTSIDE)
00203         {
00204                 return index-uiInfo.forceConfigLightIndexBegin;
00205         }
00206 
00207         return index-uiInfo.forceConfigDarkIndexBegin;
00208 }

qboolean UI_TrueJediEnabled void   ) 
 

Definition at line 1970 of file ui_main.c.

References atoi(), CS_SERVERINFO, GT_HOLOCRON, GT_JEDIMASTER, Info_ValueForKey(), MAX_INFO_STRING, qboolean, qfalse, trap_GetConfigString(), and UI_HasSetSaberOnly().

Referenced by UI_JediNonJedi_HandleKey(), UpdateForceStatus(), and UpdateForceUsed().

01971 {
01972         char    info[MAX_INFO_STRING];
01973         int             gametype = 0, disabledForce = 0, trueJedi = 0;
01974         qboolean saberOnly = qfalse, allForceDisabled = qfalse;
01975 
01976         trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
01977 
01978         //already have serverinfo at this point for stuff below. Don't bother trying to use ui_forcePowerDisable.
01979         //if (ui_forcePowerDisable.integer)
01980         //if (atoi(Info_ValueForKey(info, "g_forcePowerDisable")))
01981         disabledForce = atoi(Info_ValueForKey(info, "g_forcePowerDisable"));
01982         allForceDisabled = UI_AllForceDisabled(disabledForce);
01983         gametype = atoi(Info_ValueForKey(info, "g_gametype"));
01984         saberOnly = UI_HasSetSaberOnly();
01985 
01986         if ( gametype == GT_HOLOCRON 
01987                 || gametype == GT_JEDIMASTER 
01988                 || saberOnly 
01989                 || allForceDisabled )
01990         {
01991                 trueJedi = 0;
01992         }
01993         else
01994         {
01995                 trueJedi = atoi( Info_ValueForKey( info, "g_jediVmerc" ) );
01996         }
01997         return (trueJedi != 0);
01998 }

void UI_UpdateClientForcePowers const char *  teamArg  ) 
 

Definition at line 174 of file ui_force.c.

References EXEC_APPEND, gTouchedForce, qfalse, trap_Cmd_ExecuteText(), trap_Cvar_Set(), uiForcePowersRank, uiForceRank, uiForceSide, and va().

Referenced by UI_JediNonJedi_HandleKey(), UI_ReadLegalForce(), UI_UpdateForcePowers(), and UpdateForceUsed().

00175 {
00176         trap_Cvar_Set( "forcepowers", va("%i-%i-%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i",
00177                 uiForceRank, uiForceSide, uiForcePowersRank[0], uiForcePowersRank[1],
00178                 uiForcePowersRank[2], uiForcePowersRank[3], uiForcePowersRank[4],
00179                 uiForcePowersRank[5], uiForcePowersRank[6], uiForcePowersRank[7],
00180                 uiForcePowersRank[8], uiForcePowersRank[9], uiForcePowersRank[10],
00181                 uiForcePowersRank[11], uiForcePowersRank[12], uiForcePowersRank[13],
00182                 uiForcePowersRank[14], uiForcePowersRank[15], uiForcePowersRank[16],
00183                 uiForcePowersRank[17]) );
00184 
00185         if (gTouchedForce)
00186         {
00187                 if (teamArg && teamArg[0])
00188                 {
00189                         trap_Cmd_ExecuteText( EXEC_APPEND, va("forcechanged \"%s\"\n", teamArg) );
00190                 }
00191                 else
00192                 {
00193                         trap_Cmd_ExecuteText( EXEC_APPEND, "forcechanged\n" );
00194                 }
00195         }
00196 
00197         gTouchedForce = qfalse;
00198 }

void UI_UpdateForcePowers  ) 
 

Definition at line 631 of file ui_force.c.

References atoi(), FP_HEAL, FP_LEVITATION, FP_SABER_DEFENSE, FP_SABER_OFFENSE, vmCvar_t::integer, NULL, NUM_FORCE_POWERS, UI_Cvar_VariableString(), ui_freeSaber, UI_UpdateClientForcePowers(), uiForcePowersRank, uiForceRank, uiForceSide, uiMaxRank, and UpdateForceUsed().

Referenced by _UI_Init().

00632 {
00633         char *forcePowers = UI_Cvar_VariableString("forcepowers");
00634         char readBuf[256];
00635         int i = 0, i_f = 0, i_r = 0;
00636 
00637         uiForceSide = 0;
00638 
00639         if (forcePowers && forcePowers[0])
00640         {
00641                 while (forcePowers[i])
00642                 {
00643                         i_r = 0;
00644 
00645                         while (forcePowers[i] && forcePowers[i] != '-' && i_r < 255)
00646                         {
00647                                 readBuf[i_r] = forcePowers[i];
00648                                 i_r++;
00649                                 i++;
00650                         }
00651                         readBuf[i_r] = '\0';
00652                         if (i_r >= 255 || !forcePowers[i] || forcePowers[i] != '-')
00653                         {
00654                                 uiForceSide = 0;
00655                                 goto validitycheck;
00656                         }
00657                         uiForceRank = atoi(readBuf);
00658                         i_r = 0;
00659 
00660                         if (uiForceRank > uiMaxRank)
00661                         {
00662                                 uiForceRank = uiMaxRank;
00663                         }
00664 
00665                         i++;
00666 
00667                         while (forcePowers[i] && forcePowers[i] != '-' && i_r < 255)
00668                         {
00669                                 readBuf[i_r] = forcePowers[i];
00670                                 i_r++;
00671                                 i++;
00672                         }
00673                         readBuf[i_r] = '\0';
00674                         if (i_r >= 255 || !forcePowers[i] || forcePowers[i] != '-')
00675                         {
00676                                 uiForceSide = 0;
00677                                 goto validitycheck;
00678                         }
00679                         uiForceSide = atoi(readBuf);
00680                         i_r = 0;
00681 
00682                         i++;
00683 
00684                         i_f = FP_HEAL;
00685 
00686                         while (forcePowers[i] && i_f < NUM_FORCE_POWERS)
00687                         {
00688                                 readBuf[0] = forcePowers[i];
00689                                 readBuf[1] = '\0';
00690                                 uiForcePowersRank[i_f] = atoi(readBuf);
00691 
00692                                 if (i_f == FP_LEVITATION &&
00693                                         uiForcePowersRank[i_f] < 1)
00694                                 {
00695                                         uiForcePowersRank[i_f] = 1;
00696                                 }
00697 
00698                                 if (i_f == FP_SABER_OFFENSE &&
00699                                         uiForcePowersRank[i_f] < 1 &&
00700                                         ui_freeSaber.integer)
00701                                 {
00702                                         uiForcePowersRank[i_f] = 1;
00703                                 }
00704 
00705                                 if (i_f == FP_SABER_DEFENSE &&
00706                                         uiForcePowersRank[i_f] < 1 &&
00707                                         ui_freeSaber.integer)
00708                                 {
00709                                         uiForcePowersRank[i_f] = 1;
00710                                 }
00711 
00712                                 i_f++;
00713                                 i++;
00714                         }
00715 
00716                         if (i_f < NUM_FORCE_POWERS)
00717                         { //info for all the powers wasn't there..
00718                                 uiForceSide = 0;
00719                                 goto validitycheck;
00720                         }
00721                         i++;
00722                 }
00723         }
00724 
00725 validitycheck:
00726 
00727         if (!uiForceSide)
00728         {
00729                 uiForceSide = 1;
00730                 uiForceRank = 1;
00731                 i = 0;
00732                 while (i < NUM_FORCE_POWERS)
00733                 {
00734                         if (i == FP_LEVITATION)
00735                         {
00736                                 uiForcePowersRank[i] = 1;
00737                         }
00738                         else if (i == FP_SABER_OFFENSE && ui_freeSaber.integer)
00739                         {
00740                                 uiForcePowersRank[i] = 1;
00741                         }
00742                         else if (i == FP_SABER_DEFENSE && ui_freeSaber.integer)
00743                         {
00744                                 uiForcePowersRank[i] = 1;
00745                         }
00746                         else
00747                         {
00748                                 uiForcePowersRank[i] = 0;
00749                         }
00750 
00751                         i++;
00752                 }
00753 
00754                 UI_UpdateClientForcePowers(NULL);
00755         }
00756 
00757         UpdateForceUsed();
00758 }

void UpdateForceUsed  ) 
 

Definition at line 290 of file ui_force.c.

References bgForcePowerCost, FORCE_JEDI, FORCE_LEVEL_1, FORCE_NONJEDI, forceMasteryPoints, FP_LEVITATION, FP_SABER_DEFENSE, FP_SABER_OFFENSE, FP_SABERTHROW, vmCvar_t::integer, Menu_ShowItemByName(), Menus_FindByName(), NULL, NUM_FORCE_POWER_LEVELS, NUM_FORCE_POWERS, qboolean, qfalse, qtrue, TEAM_SPECTATOR, trap_Cvar_VariableValue(), ui_freeSaber, UI_TeamName(), UI_TrueJediEnabled(), UI_UpdateClientForcePowers(), uiForceAvailable, uiForcePowersRank, uiForceRank, uiForceUsed, uiJediNonJedi, and uiMaxRank.

Referenced by _UI_Refresh(), _UI_SetActiveMenu(), UI_ForceConfigHandle(), UI_ForceMaxRank_HandleKey(), UI_ForcePowerRank_HandleKey(), UI_ForceSide_HandleKey(), UI_JediNonJedi_HandleKey(), UI_ReadLegalForce(), and UI_UpdateForcePowers().

00291 {
00292         int curpower, currank;
00293         menuDef_t *menu;
00294 
00295         // Currently we don't make a distinction between those that wish to play Jedi of lower than maximum skill.
00296         uiForceRank = uiMaxRank;
00297 
00298         uiForceUsed = 0;
00299         uiForceAvailable = forceMasteryPoints[uiForceRank];
00300 
00301         // Make sure that we have one freebie in jump.
00302         if (uiForcePowersRank[FP_LEVITATION]<1)
00303         {
00304                 uiForcePowersRank[FP_LEVITATION]=1;
00305         }
00306 
00307         if ( UI_TrueJediEnabled() )
00308         {//true jedi mode is set
00309                 if ( uiJediNonJedi == -1 )
00310                 {
00311                         int x = 0;
00312                         qboolean clear = qfalse, update = qfalse;
00313                         uiJediNonJedi = FORCE_NONJEDI;
00314                         while ( x < NUM_FORCE_POWERS )
00315                         {//if any force power is set, we must be a jedi
00316                                 if ( x == FP_LEVITATION || x == FP_SABER_OFFENSE )
00317                                 {
00318                                         if ( uiForcePowersRank[x] > 1 )
00319                                         {
00320                                                 uiJediNonJedi = FORCE_JEDI;
00321                                                 break;
00322                                         }
00323                                         else if ( uiForcePowersRank[x] > 0 )
00324                                         {
00325                                                 clear = qtrue;
00326                                         }
00327                                 }
00328                                 else if ( uiForcePowersRank[x] > 0 )
00329                                 {
00330                                         uiJediNonJedi = FORCE_JEDI;
00331                                         break;
00332                                 }
00333                                 x++;
00334                         }
00335                         if ( uiJediNonJedi == FORCE_JEDI )
00336                         {
00337                                 if ( uiForcePowersRank[FP_SABER_OFFENSE] < 1 )
00338                                 {
00339                                         uiForcePowersRank[FP_SABER_OFFENSE]=1;
00340                                         update = qtrue;
00341                                 }
00342                         }
00343                         else if ( clear )
00344                         {
00345                                 x = 0;
00346                                 while ( x < NUM_FORCE_POWERS )
00347                                 {//clear all force
00348                                         uiForcePowersRank[x] = 0;
00349                                         x++;
00350                                 }
00351                                 update = qtrue;
00352                         }
00353                         if ( update )
00354                         {
00355                                 int myTeam;
00356                                 myTeam = (int)(trap_Cvar_VariableValue("ui_myteam"));
00357                                 if ( myTeam != TEAM_SPECTATOR )
00358                                 {
00359                                         UI_UpdateClientForcePowers(UI_TeamName(myTeam));//will cause him to respawn, if it's been 5 seconds since last one
00360                                 }
00361                                 else
00362                                 {
00363                                         UI_UpdateClientForcePowers(NULL);//just update powers
00364                                 }
00365                         }
00366                 }
00367         }
00368 
00369         menu = Menus_FindByName("ingame_playerforce");
00370         // Set the cost of the saberattack according to whether its free.
00371         if (ui_freeSaber.integer)
00372         {       // Make saber free
00373                 bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 0;
00374                 bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 0;
00375                 // Make sure that we have one freebie in saber if applicable.
00376                 if (uiForcePowersRank[FP_SABER_OFFENSE]<1)
00377                 {
00378                         uiForcePowersRank[FP_SABER_OFFENSE]=1;
00379                 }
00380                 if (uiForcePowersRank[FP_SABER_DEFENSE]<1)
00381                 {
00382                         uiForcePowersRank[FP_SABER_DEFENSE]=1;
00383                 }
00384                 if (menu)
00385                 {
00386                         Menu_ShowItemByName(menu, "setFP_SABER_DEFENSE", qtrue);
00387                         Menu_ShowItemByName(menu, "setfp_saberthrow", qtrue);
00388                         Menu_ShowItemByName(menu, "effectentry", qtrue);
00389                         Menu_ShowItemByName(menu, "effectfield", qtrue);
00390                         Menu_ShowItemByName(menu, "nosaber", qfalse);
00391                 }
00392         }
00393         else
00394         {       // Make saber normal cost
00395                 bgForcePowerCost[FP_SABER_OFFENSE][FORCE_LEVEL_1] = 1;
00396                 bgForcePowerCost[FP_SABER_DEFENSE][FORCE_LEVEL_1] = 1;
00397                 // Also, check if there is no saberattack.  If there isn't, there had better not be any defense or throw!
00398                 if (uiForcePowersRank[FP_SABER_OFFENSE]<1)
00399                 {
00400                         uiForcePowersRank[FP_SABER_DEFENSE]=0;
00401                         uiForcePowersRank[FP_SABERTHROW]=0;
00402                         if (menu)
00403                         {
00404                                 Menu_ShowItemByName(menu, "setfp_saberdefend", qfalse);
00405                                 Menu_ShowItemByName(menu, "setfp_saberthrow", qfalse);
00406                                 Menu_ShowItemByName(menu, "effectentry", qfalse);
00407                                 Menu_ShowItemByName(menu, "effectfield", qfalse);
00408                                 Menu_ShowItemByName(menu, "nosaber", qtrue);
00409                         }
00410                 }
00411                 else
00412                 {
00413                         if (menu)
00414                         {
00415                                 Menu_ShowItemByName(menu, "setfp_saberdefend", qtrue);
00416                                 Menu_ShowItemByName(menu, "setfp_saberthrow", qtrue);
00417                                 Menu_ShowItemByName(menu, "effectentry", qtrue);
00418                                 Menu_ShowItemByName(menu, "effectfield", qtrue);
00419                                 Menu_ShowItemByName(menu, "nosaber", qfalse);
00420                         }
00421                 }
00422         }
00423 
00424         // Make sure that we're still legal.
00425         for (curpower=0;curpower<NUM_FORCE_POWERS;curpower++)
00426         {       // Make sure that our ranks are within legal limits.
00427                 if (uiForcePowersRank[curpower]<0)
00428                         uiForcePowersRank[curpower]=0;
00429                 else if (uiForcePowersRank[curpower]>=NUM_FORCE_POWER_LEVELS)
00430                         uiForcePowersRank[curpower]=(NUM_FORCE_POWER_LEVELS-1);
00431 
00432                 for (currank=FORCE_LEVEL_1;currank<=uiForcePowersRank[curpower];currank++)
00433                 {       // Check on this force power
00434                         if (uiForcePowersRank[curpower]>0)
00435                         {       // Do not charge the player for the one freebie in jump, or if there is one in saber.
00436                                 if  (   (curpower == FP_LEVITATION && currank == FORCE_LEVEL_1) ||
00437                                                 (curpower == FP_SABER_OFFENSE && currank == FORCE_LEVEL_1 && ui_freeSaber.integer) ||
00438                                                 (curpower == FP_SABER_DEFENSE && currank == FORCE_LEVEL_1 && ui_freeSaber.integer) )
00439                                 {
00440                                         // Do nothing (written this way for clarity)
00441                                 }
00442                                 else
00443                                 {       // Check if we can accrue the cost of this power.
00444                                         if (bgForcePowerCost[curpower][currank] > uiForceAvailable)
00445                                         {       // We can't afford this power.  Break to the next one.
00446                                                 // Remove this power from the player's roster.
00447                                                 uiForcePowersRank[curpower] = currank-1;
00448                                                 break;
00449                                         }
00450                                         else
00451                                         {       // Sure we can afford it.
00452                                                 uiForceUsed += bgForcePowerCost[curpower][currank];
00453                                                 uiForceAvailable -= bgForcePowerCost[curpower][currank];
00454                                         }
00455                                 }
00456                         }
00457                 }
00458         }
00459 
00460 }


Variable Documentation

int gCustPowersRank[NUM_FORCE_POWERS]
 

Initial value:

 {
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
}

Definition at line 1084 of file ui_force.c.

Referenced by UI_ForceConfigHandle().

int gCustRank = 0
 

Definition at line 1081 of file ui_force.c.

Referenced by UI_ForceConfigHandle().

int gCustSide = 0
 

Definition at line 1082 of file ui_force.c.

Referenced by UI_ForceConfigHandle().

qboolean gTouchedForce = qfalse
 

Definition at line 25 of file ui_force.c.

Referenced by UI_ForceConfigHandle(), UI_ForceMaxRank_HandleKey(), UI_ForcePowerRank_HandleKey(), UI_ForceSide_HandleKey(), UI_JediNonJedi_HandleKey(), UI_ReadLegalForce(), and UI_UpdateClientForcePowers().

vmCvar_t ui_forcePowerDisable
 

Definition at line 26 of file ui_force.c.

vmCvar_t ui_freeSaber
 

Definition at line 26 of file ui_force.c.

Referenced by _UI_Refresh(), UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ReadLegalForce(), UI_UpdateForcePowers(), UpdateForceStatus(), and UpdateForceUsed().

int uiForceAvailable = 0
 

Definition at line 21 of file ui_force.c.

Referenced by UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ReadLegalForce(), and UpdateForceUsed().

int uiForcePowerDarkLight[NUM_FORCE_POWERS]
 

Initial value:

Definition at line 74 of file ui_force.c.

Referenced by UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ForceSide_HandleKey(), and UI_ReadLegalForce().

qboolean uiForcePowersDisabled[NUM_FORCE_POWERS]
 

Initial value:

Definition at line 32 of file ui_force.c.

Referenced by UI_DrawForceStars(), and UI_ForcePowerRank_HandleKey().

int uiForcePowersRank[NUM_FORCE_POWERS]
 

Initial value:

 {
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        1,
        0
}

Definition at line 53 of file ui_force.c.

Referenced by _UI_Refresh(), UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ForceSide_HandleKey(), UI_JediNonJedi_HandleKey(), UI_ReadLegalForce(), UI_SaveForceTemplate(), UI_UpdateClientForcePowers(), UI_UpdateForcePowers(), UpdateForceStatus(), and UpdateForceUsed().

int uiForceRank = FORCE_MASTERY_JEDI_KNIGHT
 

Definition at line 17 of file ui_force.c.

Referenced by _UI_Refresh(), UI_ForceConfigHandle(), UI_ReadLegalForce(), UI_SaveForceTemplate(), UI_UpdateClientForcePowers(), UI_UpdateForcePowers(), and UpdateForceUsed().

int uiForceSide = FORCE_LIGHTSIDE
 

Definition at line 15 of file ui_force.c.

Referenced by UI_FeederSelection(), UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ForceSide_HandleKey(), UI_ReadLegalForce(), UI_SaveForceTemplate(), UI_TranslateFCFIndex(), UI_UpdateClientForcePowers(), UI_UpdateForcePowers(), and UpdateForceStatus().

int uiForceStarShaders[NUM_FORCE_STAR_IMAGES][2]
 

Definition at line 97 of file ui_force.c.

Referenced by UI_DrawForceStars(), and UI_InitForceShaders().

int uiForceUsed = 0
 

Definition at line 20 of file ui_force.c.

Referenced by UI_ForceConfigHandle(), UI_ForcePowerRank_HandleKey(), UI_ReadLegalForce(), and UpdateForceUsed().

int uiHoldSkinColor
 

Definition at line 760 of file ui_force.c.

Referenced by UI_SkinColor_HandleKey(), and UpdateForceStatus().

int uiJediNonJedi = -1
 

Definition at line 16 of file ui_force.c.

Referenced by UI_JediNonJedi_HandleKey(), UpdateForceStatus(), and UpdateForceUsed().

int uiMaxPoints = 20
 

Definition at line 19 of file ui_force.c.

int uiMaxRank = MAX_FORCE_RANK
 

Definition at line 18 of file ui_force.c.

Referenced by _UI_Refresh(), UI_ForceConfigHandle(), UI_ForceMaxRank_HandleKey(), UI_ReadLegalForce(), UI_UpdateForcePowers(), and UpdateForceUsed().

int uiSaberColorShaders[NUM_SABER_COLORS]
 

Definition at line 98 of file ui_force.c.

Referenced by UI_InitForceShaders().

int uiSkinColor
 

Definition at line 759 of file ui_force.c.

Referenced by UI_SkinColor_HandleKey(), and UpdateForceStatus().