Permalink
Browse files

mint-arena: Add screenPlacement support for Team Arena menus

Allow custom Team Arena HUDs to specify screen placement for
each menudef. This allows parts to be attached to edge of screen
in widescreen as already done by CGame for voice chat head and
vertical power up area.

It only affects the draw location. It's mainly for HUDs, not
interactive menus. Though it could be used for menu decorations.
  • Loading branch information...
zturtleman committed Jun 5, 2017
1 parent ddc4d95 commit 176ca252e99222e0d1665fd37716fd797dc4a856
Showing with 51 additions and 3 deletions.
  1. +7 −3 code/cgame/cg_main.c
  2. +44 −0 code/ui/ui_shared.c
View
@@ -2342,6 +2342,7 @@ CG_LoadHudMenu();
void CG_LoadHudMenu( void ) {
char buff[1024];
const char *hudSet;
menuDef_t *menu;
cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
cgDC.setColor = &trap_R_SetColor;
@@ -2407,12 +2408,15 @@ void CG_LoadHudMenu( void ) {
CG_LoadMenus(hudSet);
// make voice chat head stick to left side in widescreen
Menu_SetScreenPlacement( Menus_FindByName( "voiceMenu" ), PLACE_LEFT, PLACE_TOP );
menu = Menus_FindByName( "voiceMenu" );
if ( menu && !menu->forceScreenPlacement ) {
Menu_SetScreenPlacement( menu, PLACE_LEFT, PLACE_TOP );
}
// Make vertical power up area stick to the left or right side in widescreen.
// Team Arena has it on the right side but also handle custom huds that use left side.
{
menuDef_t *menu = Menus_FindByName( "powerup area" );
menu = Menus_FindByName( "powerup area" );
if ( menu && !menu->forceScreenPlacement ) {
itemDef_t *item = Menu_FindItemByName( menu, "powerupArea" );
if ( item && item->window.ownerDraw == CG_AREA_POWERUP && item->alignment == HUD_VERTICAL ) {
View
@@ -5629,6 +5629,49 @@ qboolean MenuParse_fadeCycle( itemDef_t *item, int handle ) {
return qtrue;
}
// NOTE: This only affects the draw location. It's mainly for HUDs,
// not interactive menus. Though it could be used for menu decorations.
qboolean MenuParse_screenPlacement( itemDef_t *item, int handle ) {
menuDef_t *menu = (menuDef_t*)item;
screenPlacement_e hpos, vpos;
pc_token_t token;
if (!trap_PC_ReadToken(handle, &token))
return qfalse;
if (Q_stricmp(token.string, "PLACE_RIGHT") == 0) {
hpos = PLACE_RIGHT;
} else if (Q_stricmp(token.string, "PLACE_LEFT") == 0) {
hpos = PLACE_LEFT;
} else if (Q_stricmp(token.string, "PLACE_CENTER") == 0) {
hpos = PLACE_CENTER;
} else if (Q_stricmp(token.string, "PLACE_STRETCH") == 0) {
hpos = PLACE_STRETCH;
} else {
PC_SourceError(handle, "unknown screenPlacement horizontal placement %s", token.string);
return qfalse;
}
if (!trap_PC_ReadToken(handle, &token))
return qfalse;
if (Q_stricmp(token.string, "PLACE_TOP") == 0) {
vpos = PLACE_RIGHT;
} else if (Q_stricmp(token.string, "PLACE_BOTTOM") == 0) {
vpos = PLACE_LEFT;
} else if (Q_stricmp(token.string, "PLACE_CENTER") == 0) {
vpos = PLACE_CENTER;
} else if (Q_stricmp(token.string, "PLACE_STRETCH") == 0) {
vpos = PLACE_STRETCH;
} else {
PC_SourceError(handle, "unknown screenPlacement vertical placement %s", token.string);
return qfalse;
}
Menu_SetScreenPlacement( menu, hpos, vpos );
return qtrue;
}
qboolean MenuParse_itemDef( itemDef_t *item, int handle ) {
menuDef_t *menu = (menuDef_t*)item;
@@ -5676,6 +5719,7 @@ keywordHash_t menuParseKeywords[] = {
{"fadeClamp", MenuParse_fadeClamp, NULL},
{"fadeCycle", MenuParse_fadeCycle, NULL},
{"fadeAmount", MenuParse_fadeAmount, NULL},
{"screenPlacement", MenuParse_screenPlacement, NULL},
{NULL, 0, NULL}
};

0 comments on commit 176ca25

Please sign in to comment.