Skip to content

Commit

Permalink
Doom|Heretic|Hexen: Fixed scaling of statusbar at 4:3 aspect ratios
Browse files Browse the repository at this point in the history
The engine knows how to calculate aspect correct scale factors, so
make use of it in the games when drawing the head-up displays.
  • Loading branch information
danij-deng committed Jan 1, 2012
1 parent 80d952a commit c3cad9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
14 changes: 6 additions & 8 deletions doomsday/plugins/jdoom/src/st_stuff.c
Expand Up @@ -2527,19 +2527,17 @@ static void drawUIWidgetsForPlayer(player_t* plr)
#define DISPLAY_BORDER (2) /// Units in fixed 320x200 screen space.

const int playerNum = plr - players;
const int fullscreenMode = headupDisplayMode(playerNum);
const int displayMode = headupDisplayMode(playerNum);
hudstate_t* hud = hudStates + playerNum;
Size2Raw size, portSize;
uiwidget_t* obj;
float scale;
assert(plr);

// Scale from viewport space to fixed 320x200 space.
R_ViewPortSize(playerNum, &portSize);

if(portSize.width >= portSize.height)
scale = (float)portSize.height/SCREENHEIGHT;
else
scale = (float)portSize.width/SCREENWIDTH;
R_ChooseAlignModeAndScaleFactor(&scale, SCREENWIDTH, SCREENHEIGHT,
portSize.width, portSize.height, SCALEMODE_SMART_STRETCH);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
Expand All @@ -2552,7 +2550,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)

GUI_DrawWidgetXY(obj, 0, 0);

if(hud->statusbarActive || (fullscreenMode < 3 || hud->alpha > 0))
if(hud->statusbarActive || (displayMode < 3 || hud->alpha > 0))
{
float opacity = /**\kludge: clamp*/MIN_OF(1.0f, hud->alpha)/**kludge end*/ * (1-hud->hideAmount);
Size2Raw drawnSize = { 0, 0 };
Expand Down Expand Up @@ -2603,7 +2601,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)
GUI_DrawWidget(obj, &displayRegion.origin);

// The other displays are always visible except when using the "no-hud" mode.
if(hud->statusbarActive || fullscreenMode < 3)
if(hud->statusbarActive || displayMode < 3)
opacity = 1.0f;

obj = GUI_MustFindObjectById(hud->widgetGroupIds[UWG_TOPCENTER]);
Expand Down
14 changes: 6 additions & 8 deletions doomsday/plugins/jheretic/src/st_stuff.c
Expand Up @@ -2400,19 +2400,17 @@ static void drawUIWidgetsForPlayer(player_t* plr)
#define PADDING (2)

const int playerNum = plr - players;
const int fullscreen = headupDisplayMode(playerNum);
const int displayMode = headupDisplayMode(playerNum);
hudstate_t* hud = hudStates + playerNum;
Size2Raw size, portSize;
uiwidget_t* obj;
float scale;
assert(plr);

// Scale from viewport space to fixed 320x200 space.
R_ViewPortSize(playerNum, &portSize);

if(portSize.width >= portSize.height)
scale = (float)portSize.height/SCREENHEIGHT;
else
scale = (float)portSize.width/SCREENWIDTH;
R_ChooseAlignModeAndScaleFactor(&scale, SCREENWIDTH, SCREENHEIGHT,
portSize.width, portSize.height, SCALEMODE_SMART_STRETCH);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
Expand All @@ -2425,7 +2423,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)

GUI_DrawWidgetXY(obj, 0, 0);

if(hud->statusbarActive || (fullscreen < 3 || hud->alpha > 0))
if(hud->statusbarActive || (displayMode < 3 || hud->alpha > 0))
{
float opacity = /**\kludge: clamp*/MIN_OF(1.0f, hud->alpha)/**kludge end*/ * (1-hud->hideAmount);
Size2Raw drawnSize = { 0, 0 };
Expand Down Expand Up @@ -2493,7 +2491,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)
GUI_DrawWidget(obj, &displayRegion.origin);

// The other displays are always visible except when using the "no-hud" mode.
if(hud->statusbarActive || fullscreen < 3)
if(hud->statusbarActive || displayMode < 3)
opacity = 1.0f;

obj = GUI_MustFindObjectById(hud->widgetGroupIds[UWG_TOP]);
Expand Down
14 changes: 6 additions & 8 deletions doomsday/plugins/jhexen/src/st_stuff.c
Expand Up @@ -3612,19 +3612,17 @@ static void drawUIWidgetsForPlayer(player_t* plr)
#define PADDING (2)

const int playerNum = plr - players;
const int fullscreen = headupDisplayMode(playerNum);
const int displayMode = headupDisplayMode(playerNum);
hudstate_t* hud = hudStates + playerNum;
Size2Raw size, portSize;
uiwidget_t* obj;
float scale;
assert(plr);

// Scale from viewport space to fixed 320x200 space.
R_ViewPortSize(playerNum, &portSize);

if(portSize.width >= portSize.height)
scale = (float)portSize.height/SCREENHEIGHT;
else
scale = (float)portSize.width/SCREENWIDTH;
R_ChooseAlignModeAndScaleFactor(&scale, SCREENWIDTH, SCREENHEIGHT,
portSize.width, portSize.height, SCALEMODE_SMART_STRETCH);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
Expand All @@ -3637,7 +3635,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)

GUI_DrawWidgetXY(obj, 0, 0);

if(hud->statusbarActive || (fullscreen < 3 || hud->alpha > 0))
if(hud->statusbarActive || (displayMode < 3 || hud->alpha > 0))
{
float opacity = /**\kludge: clamp*/MIN_OF(1.0f, hud->alpha)/**kludge end*/ * (1-hud->hideAmount);
Size2Raw drawnSize = { 0, 0 };
Expand Down Expand Up @@ -3688,7 +3686,7 @@ static void drawUIWidgetsForPlayer(player_t* plr)
GUI_DrawWidget(obj, &displayRegion.origin);

// The other displays are always visible except when using the "no-hud" mode.
if(hud->statusbarActive || fullscreen < 3)
if(hud->statusbarActive || displayMode < 3)
opacity = 1.0f;

obj = GUI_MustFindObjectById(hud->widgetGroupIds[UWG_TOP]);
Expand Down

0 comments on commit c3cad9d

Please sign in to comment.