mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Adjust the objectives menu accordingly depending on the game message box which depends on the compass scale
This commit is contained in:
parent
6bc621462c
commit
05e14f6364
5 changed files with 42 additions and 21 deletions
|
@ -675,14 +675,17 @@ void CG_DrawObjectives()
|
|||
{
|
||||
float vColor[4];
|
||||
float fX, fY;
|
||||
int iNumObjectives;
|
||||
float fObjectivesTop;
|
||||
static float fWidth;
|
||||
float fHeight;
|
||||
int iNumLines[20];
|
||||
int iTotalNumLines;
|
||||
int i;
|
||||
int ii;
|
||||
int iCurrentObjective;
|
||||
float fTimeDelta;
|
||||
const char *pszLocalizedText;
|
||||
const char *pszLine;
|
||||
|
||||
iTotalNumLines = 0;
|
||||
for (i = CS_OBJECTIVES; i < CS_OBJECTIVES + MAX_OBJECTIVES; ++i) {
|
||||
|
@ -702,26 +705,30 @@ void CG_DrawObjectives()
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_OBJECTIVES; i++) {
|
||||
if ((cg.Objectives[i].flags & 0xFFFFFFFE)) {
|
||||
iNumLines[i] = 0;
|
||||
// Added in 2.0
|
||||
// Get the minimum Y value, it should be below the compass
|
||||
fObjectivesTop = cgi.UI_GetObjectivesTop();
|
||||
iNumObjectives = 0;
|
||||
|
||||
for (ii = 0; ii < MAX_STRING_CHARS; ii++) {
|
||||
if (cg.Objectives[i].text[ii] == '\n') {
|
||||
iTotalNumLines++;
|
||||
iNumLines[i]++;
|
||||
} else if (!cg.Objectives[i].text[ii]) {
|
||||
iTotalNumLines++;
|
||||
iNumLines[i]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < MAX_OBJECTIVES; i++) {
|
||||
if ((cg.Objectives[i].flags == OBJ_FLAG_NONE) || (cg.Objectives[i].flags & OBJ_FLAG_HIDDEN)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
iNumObjectives++;
|
||||
iNumLines[i] = 0;
|
||||
pszLocalizedText = cgi.LV_ConvertString(cg.Objectives[i].text);
|
||||
|
||||
for (pszLine = strchr(pszLocalizedText, '\n'); pszLine; pszLine = strchr(pszLine, '\n')) {
|
||||
iNumLines[i]++;
|
||||
}
|
||||
|
||||
iTotalNumLines += iNumLines[i];
|
||||
}
|
||||
|
||||
fX = 25.0;
|
||||
fY = 125.0;
|
||||
fWidth = (float)(25 * iTotalNumLines + 155) + 5.0 - 130.0;
|
||||
fY = fObjectivesTop + 5;
|
||||
fWidth = (float)(iTotalNumLines * 12 + fObjectivesTop + iNumObjectives * 25 + 32) - fY;
|
||||
vColor[2] = 0.2f;
|
||||
vColor[1] = 0.2f;
|
||||
vColor[0] = 0.2f;
|
||||
|
@ -730,7 +737,7 @@ void CG_DrawObjectives()
|
|||
cgi.R_DrawStretchPic(fX, fY, 450.0, fWidth, 0.0, 0.0, 1.0, 1.0, cgs.media.objectivesBackShader);
|
||||
|
||||
fX = 30.0;
|
||||
fY = 130.0;
|
||||
fY = fObjectivesTop + 10;
|
||||
vColor[0] = 1.0;
|
||||
vColor[1] = 1.0;
|
||||
vColor[2] = 1.0;
|
||||
|
@ -740,12 +747,12 @@ void CG_DrawObjectives()
|
|||
fY = fY + 5.0;
|
||||
|
||||
cgi.R_DrawString(cgs.media.objectiveFont, "_______________________________________________________", fX, fY, -1, 0);
|
||||
fHeight = 155.0;
|
||||
fHeight = fObjectivesTop + 35;
|
||||
|
||||
for (i = 0; i < MAX_OBJECTIVES; ++i) {
|
||||
qhandle_t hBoxShader;
|
||||
|
||||
if ((cg.Objectives[i].flags & OBJ_FLAG_HIDDEN) || !cg.Objectives[i].flags) {
|
||||
|
||||
if ((cg.Objectives[i].flags == OBJ_FLAG_NONE) || (cg.Objectives[i].flags & OBJ_FLAG_HIDDEN)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -789,7 +796,7 @@ void CG_DrawObjectives()
|
|||
cgi.R_SetColor(vColor);
|
||||
cgi.R_DrawStretchPic(fX, fY, 16.0, 16.0, 0.0, 0.0, 1.0, 1.0, hBoxShader);
|
||||
|
||||
fHeight += 25 * iNumLines[i];
|
||||
fHeight += iNumLines[i] * 12 + 25;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -361,6 +361,8 @@ functions exported to the main executable
|
|||
void (*UI_ShowMenu)(const char *name, qboolean bForce);
|
||||
void (*UI_HideMenu)(const char *name, qboolean bForce);
|
||||
int (*UI_FontStringWidth)(fontheader_t *font, const char *string, int maxLen);
|
||||
// Added in 2.0
|
||||
float (*UI_GetObjectivesTop)(void);
|
||||
|
||||
int (*Key_StringToKeynum)(const char *str);
|
||||
const char *(*Key_KeynumToBindString)(int keyNum);
|
||||
|
|
|
@ -773,6 +773,7 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) {
|
|||
cgi->UI_ShowMenu = UI_ShowMenu;
|
||||
cgi->UI_HideMenu = UI_HideMenu;
|
||||
cgi->UI_FontStringWidth = CL_FontStringWidth;
|
||||
cgi->UI_GetObjectivesTop = UI_GetObjectivesTop;
|
||||
cgi->Key_StringToKeynum = Key_StringToKeynum;
|
||||
cgi->Key_KeynumToBindString = Key_KeynumToBindString;
|
||||
cgi->Key_GetKeysForCommand = Key_GetKeysForCommand;
|
||||
|
|
|
@ -1211,6 +1211,16 @@ static UIRect2D getDefaultDMBoxRectangle(void)
|
|||
return UIRect2D(width, 0, cls.glconfig.vidWidth - (width + 192.0f), 120.0f);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
UI_GetObjectivesTop
|
||||
====================
|
||||
*/
|
||||
float UI_GetObjectivesTop(void)
|
||||
{
|
||||
return getDefaultGMBoxRectangle().pos.y;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
UI_ShowHudList
|
||||
|
|
|
@ -56,6 +56,7 @@ const char *CvarGetForUI(const char *name, const char *defval);
|
|||
void UI_ClearState(void);
|
||||
void CL_BeginRegistration(void);
|
||||
void CL_EndRegistration(void);
|
||||
float UI_GetObjectivesTop(void);
|
||||
|
||||
//
|
||||
// menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue