Skip to content

Commit

Permalink
Fixed|All Games: Positioning of HUD/status bar when game is minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 20, 2016
1 parent 0ebd7ac commit c8f3710
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 50 deletions.
24 changes: 14 additions & 10 deletions doomsday/apps/client/src/render/r_draw.cpp
Expand Up @@ -221,6 +221,8 @@ void R_DrawViewBorder()
if (vd->window.isNull()) return;
if (vd->window.size() >= port->geometry.size()) return;

Vector2i const origin = port->geometry.topLeft;

DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

Expand Down Expand Up @@ -257,31 +259,33 @@ void R_DrawViewBorder()

GL_BindTexture(matAnimator.texUnit(MaterialAnimator::TU_LAYER0).texture);
Vector2ui const &matDimensions = matAnimator.dimensions();
GL_DrawCutRectf2Tiled(0, 0, port->geometry.width(), port->geometry.height(),

GL_DrawCutRectf2Tiled(origin.x, origin.y, port->geometry.width(), port->geometry.height(),
matDimensions.x, matDimensions.y, 0, 0,
vd->window.topLeft.x - border, vd->window.topLeft.y - border,
origin.x + vd->window.topLeft.x - border,
origin.y + vd->window.topLeft.y - border,
vd->window.width() + 2 * border, vd->window.height() + 2 * border);
}
catch(world::MaterialManifest::MissingMaterialError const &)
{} // Ignore this error.

if(border)
{
R_DrawPatchTiled(borderTexture(BG_TOP), vd->window.topLeft.x, vd->window.topLeft.y - border, vd->window.width(), border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(borderTexture(BG_BOTTOM), vd->window.topLeft.x, vd->window.bottomRight.y, vd->window.width(), border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(borderTexture(BG_LEFT), vd->window.topLeft.x - border, vd->window.topLeft.y, border, vd->window.height(), gl::ClampToEdge, gl::Repeat);
R_DrawPatchTiled(borderTexture(BG_RIGHT), vd->window.topRight().x, vd->window.topRight().y, border, vd->window.height(), gl::ClampToEdge, gl::Repeat);
R_DrawPatchTiled(borderTexture(BG_TOP), origin.x + vd->window.topLeft.x, origin.y + vd->window.topLeft.y - border, vd->window.width(), border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(borderTexture(BG_BOTTOM), origin.x + vd->window.topLeft.x, origin.y + vd->window.bottomRight.y, vd->window.width(), border, gl::Repeat, gl::ClampToEdge);
R_DrawPatchTiled(borderTexture(BG_LEFT), origin.x + vd->window.topLeft.x - border, origin.y + vd->window.topLeft.y, border, vd->window.height(), gl::ClampToEdge, gl::Repeat);
R_DrawPatchTiled(borderTexture(BG_RIGHT), origin.x + vd->window.topRight().x, origin.y + vd->window.topRight().y, border, vd->window.height(), gl::ClampToEdge, gl::Repeat);
}

LIBGUI_GL.glMatrixMode(GL_TEXTURE);
LIBGUI_GL.glPopMatrix();

if(border)
{
R_DrawPatch(borderTexture(BG_TOPLEFT), vd->window.topLeft.x - border, vd->window.topLeft.y - border, border, border, false);
R_DrawPatch(borderTexture(BG_TOPRIGHT), vd->window.topRight().x, vd->window.topLeft.y - border, border, border, false);
R_DrawPatch(borderTexture(BG_BOTTOMRIGHT), vd->window.bottomRight.x, vd->window.bottomRight.y, border, border, false);
R_DrawPatch(borderTexture(BG_BOTTOMLEFT), vd->window.bottomLeft().x - border, vd->window.bottomRight.y, border, border, false);
R_DrawPatch(borderTexture(BG_TOPLEFT), origin.x + vd->window.topLeft.x - border, origin.y + vd->window.topLeft.y - border, border, border, false);
R_DrawPatch(borderTexture(BG_TOPRIGHT), origin.x + vd->window.topRight().x, origin.y + vd->window.topLeft.y - border, border, border, false);
R_DrawPatch(borderTexture(BG_BOTTOMRIGHT), origin.x + vd->window.bottomRight.x, origin.y + vd->window.bottomRight.y, border, border, false);
R_DrawPatch(borderTexture(BG_BOTTOMLEFT), origin.x + vd->window.bottomLeft().x - border, origin.y + vd->window.bottomRight.y, border, border, false);
}

LIBGUI_GL.glDisable(GL_TEXTURE_2D);
Expand Down
5 changes: 4 additions & 1 deletion doomsday/apps/plugins/common/src/hu_stuff.cpp
Expand Up @@ -1528,8 +1528,11 @@ void Hu_MapTitleDrawer(const RectRaw* portGeometry)
DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();

Point2Raw portOrigin;
R_ViewPortOrigin(DISPLAYPLAYER, &portOrigin);

// After scaling, the title is centered horizontally on the screen.
DGL_Translatef(origin.x, origin.y, 0);
DGL_Translatef(portOrigin.x + origin.x, portOrigin.y + origin.y, 0);

DGL_Scalef(scale, scale * 1.2f/*aspect correct*/, 1);

Expand Down
6 changes: 4 additions & 2 deletions doomsday/apps/plugins/doom/src/st_stuff.cpp
Expand Up @@ -506,7 +506,8 @@ static void drawUIWidgetsForPlayer(player_t *plr)
int const displayMode = ST_ActiveHud(localPlayer);
hudstate_t *hud = &hudStates[localPlayer];

Size2Raw portSize; R_ViewPortSize(localPlayer, &portSize);
Size2Raw portSize; R_ViewPortSize (localPlayer, &portSize);
Point2Raw portOrigin; R_ViewPortOrigin(localPlayer, &portOrigin);

// The automap is drawn in a viewport scaled coordinate space (of viewwindow dimensions).
HudWidget &aGroup = GUI_FindWidgetById(hud->groupIds[UWG_AUTOMAP]);
Expand All @@ -522,6 +523,7 @@ static void drawUIWidgetsForPlayer(player_t *plr)

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(portOrigin.x, portOrigin.y, 0);
DGL_Scalef(scale, scale, 1);

if(hud->statusbarActive || (displayMode < 3 || hud->alpha > 0))
Expand Down Expand Up @@ -1022,7 +1024,7 @@ void HU_WakeWidgets(int localPlayer)
HU_WakeWidgets(i);
}
}
else if(localPlayer < MAXPLAYERS)
else if(localPlayer < MAXPLAYERS)
{
if(players[localPlayer].plr->inGame)
{
Expand Down
68 changes: 35 additions & 33 deletions doomsday/apps/plugins/doom64/src/st_stuff.cpp
Expand Up @@ -100,8 +100,8 @@ struct hudstate_t {
int hideTics;
float hideAmount;
// Fullscreen HUD alpha
float alpha;
int automapCheatLevel;
float alpha;
int automapCheatLevel;

/*
* UI Widgets
Expand Down Expand Up @@ -163,39 +163,41 @@ static void drawUIWidgetsForPlayer(player_t* plr)

// Magic (not really -- standard 1.2:1 anamporphic) aspect ratio used to adjust render height
static const float ASPECT_TRIM = 1.2F;

DENG2_ASSERT(plr);

int const playerId = (plr - players);
int const hudMode = ST_ActiveHud(playerId);
hudstate_t* hud = &hudStates[playerId];

Size2Raw portSize; R_ViewPortSize(playerId, &portSize);
Size2Raw portSize; R_ViewPortSize(playerId, &portSize);
Point2Raw portOrigin; R_ViewPortOrigin(playerId, &portOrigin);

// TODO float const automapOpacity
// Automap Group
{
HudWidget& amGroup = GUI_FindWidgetById(hud->groupIds[UWG_AUTOMAP]);
amGroup.setOpacity(ST_AutomapOpacity(playerId));
amGroup.setMaximumSize(portSize);

GUI_DrawWidgetXY(&amGroup, 0, 0);
}

// Ingame UI
// hudMode >= 3 presumeable refers to `No-Hud`
// hudMode >= 3 presumeable refers to `No-Hud`
// There ought to be some constants for this
if (hud->alpha > 0 || hudMode < 3) {
float uiScale;
R_ChooseAlignModeAndScaleFactor(&uiScale, SCREENWIDTH, SCREENHEIGHT,
R_ChooseAlignModeAndScaleFactor(&uiScale, SCREENWIDTH, SCREENHEIGHT,
portSize.width, portSize.height, SCALEMODE_SMART_STRETCH);

float opacity = de::min(1.0F, hud->alpha) * (1 - hud->hideAmount);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(portOrigin.x, portOrigin.y, 0);
DGL_Scalef(uiScale, uiScale * ASPECT_TRIM, 1);

RectRaw displayRegion;
{
displayRegion.origin.x = INSET;
Expand All @@ -214,7 +216,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)
bottomGroup.setMaximumSize(displayRegion.size);

GUI_DrawWidget(&bottomGroup, &displayRegion.origin);

Size2_Raw(Rect_Size(&bottomGroup.geometry()), &regionRendered);
}

Expand All @@ -225,7 +227,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)

Size2Raw remainingVertical(displayRegion.size.width,
displayRegion.size.height - (regionRendered.height > 0 ? regionRendered.height : 0));

mapNameGroup.setMaximumSize(remainingVertical);

GUI_DrawWidget(&mapNameGroup, &displayRegion.origin);
Expand All @@ -240,7 +242,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)
opacity = 1.0F;
}

// Top Center
// Top Center
{
HudWidget& topCenter = GUI_FindWidgetById(hud->groupIds[UWG_TOPCENTER]);
topCenter.setOpacity(opacity);
Expand Down Expand Up @@ -300,7 +302,7 @@ static void setAutomapCheatLevel(AutomapWidget& map, int level)
hud->automapCheatLevel = level;

dint flags = map.flags()
& ~ (AWF_SHOW_ALLLINES
& ~ (AWF_SHOW_ALLLINES
|AWF_SHOW_THINGS
|AWF_SHOW_SPECIALLINES
|AWF_SHOW_VERTEXES
Expand All @@ -313,12 +315,12 @@ static void setAutomapCheatLevel(AutomapWidget& map, int level)

if (hud->automapCheatLevel == 2)
{
flags |= AWF_SHOW_THINGS
flags |= AWF_SHOW_THINGS
| AWF_SHOW_SPECIALLINES;
}
else if (hud->automapCheatLevel > 2)
{
flags |= AWF_SHOW_VERTEXES
flags |= AWF_SHOW_VERTEXES
| AWF_SHOW_LINE_NORMALS;
}

Expand Down Expand Up @@ -405,7 +407,7 @@ static void ST_BuildWidgets(int player)

void (*updateGeometry) (HudWidget* obj);
void (*drawer) (HudWidget* obj, Point2Raw const* origin);

uiwidgetid_t* id;
};

Expand Down Expand Up @@ -455,11 +457,11 @@ static void ST_BuildWidgets(int player)
uiwidgetdef_t const widgetDefs[] = {
{ GUI_HEALTHICON, ALIGN_BOTTOMLEFT, UWG_BOTTOMLEFT2, GF_NONE, nullptr, nullptr, &hud->healthIconId },
{ GUI_HEALTH, ALIGN_BOTTOMLEFT, UWG_BOTTOMLEFT2, GF_FONTB, function_cast<UpdateGeometryFunc>(HealthWidget_UpdateGeometry), function_cast<DrawFunc>(HealthWidget_Draw), &hud->healthId },
{ GUI_READYAMMOICON, ALIGN_BOTTOMLEFT, UWG_BOTTOMLEFT2, GF_NONE, function_cast<UpdateGeometryFunc>(ReadyAmmoIconWidget_UpdateGeometry), function_cast<DrawFunc>(ReadyAmmoIconWidget_Drawer), &hud->readyAmmoIconId },
{ GUI_READYAMMOICON, ALIGN_BOTTOMLEFT, UWG_BOTTOMLEFT2, GF_NONE, function_cast<UpdateGeometryFunc>(ReadyAmmoIconWidget_UpdateGeometry), function_cast<DrawFunc>(ReadyAmmoIconWidget_Drawer), &hud->readyAmmoIconId },
{ GUI_READYAMMO, ALIGN_BOTTOM, UWG_BOTTOMCENTER, GF_FONTB, function_cast<UpdateGeometryFunc>(ReadyAmmo_UpdateGeometry), function_cast<DrawFunc>(ReadyAmmo_Drawer), &hud->readyAmmoId },

// { GUI_FRAGS, ALIGN_BOTTOMCENTER, UWG_BOTTOMCENTER, GF_FONTA, function_cast<UpdateGeometryFunc>(FragsWidget_UpdateGeometry), function_cast<DrawFunc>(FragsWidget_Draw), &hud->fragsId },

{ GUI_KEYS, ALIGN_BOTTOMRIGHT, UWG_BOTTOMRIGHT, GF_NONE, nullptr, nullptr, &hud->keysId },
{ GUI_ARMOR, ALIGN_BOTTOMRIGHT, UWG_BOTTOMRIGHT, GF_FONTB, function_cast<UpdateGeometryFunc>(Armor_UpdateGeometry), function_cast<DrawFunc>(ArmorWidget_Draw), &hud->armorId },
{ GUI_ARMORICON, ALIGN_BOTTOMRIGHT, UWG_BOTTOMRIGHT, GF_NONE, nullptr, nullptr, &hud->armorIconId },
Expand All @@ -485,13 +487,13 @@ static void ST_BuildWidgets(int player)
case GUI_FRAGS: widget = new guidata_frags_t (def.updateGeometry, def.drawer, player); break;
case GUI_SECRETS: widget = new guidata_secrets_t (player); break;
case GUI_ITEMS: widget = new guidata_items_t (player); break;
case GUI_KILLS: widget = new guidata_kills_t (player); break;
case GUI_KILLS: widget = new guidata_kills_t (player); break;

// Handled specially
// case GUI_AUTOMAP: widget = new AutomapWidget (def.updateGeometry, def.drawer, player); break;
// case GUI_LOG: widget = new PlayerLogWidget (def.updateGeometry, def.drawer, player); break;
// case GUI_CHAT: widget = new ChatWidget (def.updateGeometry, def.drawer, player); break;

default:
LOG_SCR_ERROR ("Unknown widget type: %i. Skipping")
<< def.type;
Expand All @@ -502,7 +504,7 @@ static void ST_BuildWidgets(int player)
GUI_AddWidget(widget);
GUI_FindWidgetById(hud->groupIds[def.group]).as<GroupWidget>().addChild(widget);

if (def.id)
if (def.id)
{
*def.id = widget->id();
}
Expand Down Expand Up @@ -588,7 +590,7 @@ D_CMD(ChatOpen)
{
DENG2_UNUSED(src);

if (G_QuitInProgress())
if (G_QuitInProgress())
{
return false;
}
Expand All @@ -605,13 +607,13 @@ D_CMD(ChatOpen)
if (destination < 0)
{
LOG_SCR_ERROR("Invalid team number: %i (valid numbers in range 0 through %i")
<< destination
<< destination
<< NUMTEAMS;
return false;
}
}
}

chat->setDestination(destination);
chat->activate();
return true;
Expand All @@ -637,7 +639,7 @@ D_CMD(ChatAction)
if (chat && !chat->isActive())
{
String const command = String(argv[0] + 4 /* ghetto substring */);

if (command.compareWithoutCase("complete") == 0)
{
return chat->handleMenuCommand(MCMD_SELECT);
Expand Down Expand Up @@ -674,11 +676,11 @@ D_CMD(ChatSendMacro)
{
LOG_SCR_NOTE("Usage: %s (team) (macro number)")
<< argv[0];

LOG_SCR_MSG("Send a chat macro to other player(s). "
"If (team) is omitted, the message with be broadcast to all players.");

return true;
return true;
}
else
{
Expand All @@ -702,7 +704,7 @@ D_CMD(ChatSendMacro)
}
}
}

int macroId = parseMacroId(argc == 3 ? argv[2] : argv[1]);

if (macroId >= 0)
Expand Down Expand Up @@ -820,7 +822,7 @@ int ST_Responder(event_t* ev)
void ST_Ticker(timespan_t ticLength)
{
dd_bool const isSharpTic = DD_IsSharpTick();

for(int i = 0; i < MAXPLAYERS; ++i)
{
player_t* plr = &players[i];
Expand Down Expand Up @@ -913,7 +915,7 @@ void ST_Start(int player)

// Initialize all widgets to default values
initData(hud);

/*
* Set user preferences for layout, etc...
*/
Expand All @@ -939,7 +941,7 @@ void ST_Start(int player)
// Automap
{
AutomapWidget& map = GUI_FindWidgetById(hud->automapId).as<AutomapWidget>();

// Reset automap open state to closed
map.open(false, true /* close instantly */);

Expand Down Expand Up @@ -1303,7 +1305,7 @@ ChatWidget* ST_TryFindChatWidget(int player)
if(player >= 0 && player < MAXPLAYERS)
{
HudWidget* widgetPointer = GUI_TryFindWidgetById(hudStates[player].chatId);

if (widgetPointer)
{
return widgetPointer->maybeAs<ChatWidget>();
Expand All @@ -1318,7 +1320,7 @@ PlayerLogWidget* ST_TryFindLogWidget(int player)
if(player >= 0 && player < MAXPLAYERS)
{
HudWidget* widgetPointer = GUI_TryFindWidgetById(hudStates[player].logId);

if (widgetPointer)
{
return widgetPointer->maybeAs<PlayerLogWidget>();
Expand All @@ -1333,7 +1335,7 @@ AutomapWidget* ST_TryFindAutomapWidget(int player)
if(player >= 0 && player < MAXPLAYERS)
{
HudWidget* widgetPointer = GUI_TryFindWidgetById(hudStates[player].automapId);

if (widgetPointer)
{
return widgetPointer->maybeAs<AutomapWidget>();
Expand Down
6 changes: 4 additions & 2 deletions doomsday/apps/plugins/heretic/src/st_stuff.cpp
Expand Up @@ -486,6 +486,7 @@ static void drawUIWidgetsForPlayer(player_t *plr)

Size2Raw size, portSize;
R_ViewPortSize(playerNum, &portSize);
Point2Raw portOrigin; R_ViewPortOrigin(playerNum, &portOrigin);

// The automap is drawn in a viewport scaled coordinate space (of viewwindow dimensions).
HudWidget &aGroup = GUI_FindWidgetById(hud->groupIds[UWG_AUTOMAP]);
Expand All @@ -500,6 +501,7 @@ static void drawUIWidgetsForPlayer(player_t *plr)

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(portOrigin.x, portOrigin.y, 0);
DGL_Scalef(scale, scale, 1);

if(hud->statusbarActive || (displayMode < 3 || hud->alpha > 0))
Expand Down Expand Up @@ -1001,7 +1003,7 @@ void HU_WakeWidgets(int localPlayer)
HU_WakeWidgets(i);
}
}
else if(localPlayer < MAXPLAYERS)
else if(localPlayer < MAXPLAYERS)
{
if(players[localPlayer].plr->inGame)
{
Expand All @@ -1014,7 +1016,7 @@ void HU_WakeWidgets(int localPlayer)
void ST_CloseAll(int player, dd_bool fast)
{
NetSv_DismissHUDs(player, fast);

ST_AutomapOpen(player, false, fast);
Hu_InventoryOpen(player, false);
}
Expand Down

0 comments on commit c8f3710

Please sign in to comment.