Adjust GUI to different resolutions
This commit is contained in:
parent
9b2fc5f14c
commit
50ceea3f0a
4 changed files with 64 additions and 41 deletions
38
game.h
38
game.h
|
@ -264,6 +264,11 @@ static inline void LCR_gameDrawPixelXYSafe(unsigned int x, unsigned int y,
|
|||
|
||||
#define LCR_POPUP_STR_SIZE 16
|
||||
|
||||
|
||||
#define LCR_GUI_GAP \
|
||||
((LCR_EFFECTIVE_RESOLUTION_X + LCR_EFFECTIVE_RESOLUTION_Y) / 128)
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t state;
|
||||
|
@ -1056,22 +1061,20 @@ void LCR_gameTimeToStr(uint32_t timeMS, char *str)
|
|||
|
||||
void LCR_gameDrawPopupMessage(void)
|
||||
{
|
||||
#define TEXT_SIZE 5
|
||||
#define OFFSET_V (LCR_EFFECTIVE_RESOLUTION_Y / 6)
|
||||
#define TEXT_PAD (LCR_EFFECTIVE_RESOLUTION_Y / 64)
|
||||
#define _TEXT_SIZE 5
|
||||
#define _OFFSET_V (LCR_EFFECTIVE_RESOLUTION_Y / 6)
|
||||
|
||||
int textH = LCR_rendererComputeTextHeight(TEXT_SIZE);
|
||||
int textW = LCR_rendererComputeTextWidth(LCR_game.popupStr,TEXT_SIZE);
|
||||
int textH = LCR_rendererComputeTextHeight(_TEXT_SIZE);
|
||||
int textW = LCR_rendererComputeTextWidth(LCR_game.popupStr,_TEXT_SIZE);
|
||||
|
||||
LCR_rendererDrawRect((LCR_EFFECTIVE_RESOLUTION_X - textW - 2 * TEXT_PAD) / 2,
|
||||
OFFSET_V,textW + 2 * TEXT_PAD,textH + 2 * TEXT_PAD,0xffff,1);
|
||||
LCR_rendererDrawRect((LCR_EFFECTIVE_RESOLUTION_X - textW - 2 * LCR_GUI_GAP)
|
||||
/ 2,_OFFSET_V,textW + 2 * LCR_GUI_GAP,textH + 2 * LCR_GUI_GAP,0xffff,1);
|
||||
|
||||
LCR_rendererDrawText(LCR_game.popupStr,(LCR_EFFECTIVE_RESOLUTION_X - textW)
|
||||
/ 2,OFFSET_V + TEXT_PAD,0x0300,TEXT_SIZE);
|
||||
/ 2,_OFFSET_V + LCR_GUI_GAP,0x0300,_TEXT_SIZE);
|
||||
|
||||
#undef TEXT_PAD
|
||||
#undef OFFSET_V
|
||||
#undef TEXT_SIZE
|
||||
#undef _OFFSET_V
|
||||
#undef _TEXT_SIZE
|
||||
}
|
||||
|
||||
void LCR_gameDraw3DView(void)
|
||||
|
@ -1134,14 +1137,15 @@ void LCR_gameDraw3DView(void)
|
|||
str[3] = 0;
|
||||
|
||||
LCR_rendererDrawText(str,LCR_EFFECTIVE_RESOLUTION_X -
|
||||
LCR_rendererComputeTextWidth(str,2) - 20,
|
||||
LCR_EFFECTIVE_RESOLUTION_Y - LCR_rendererComputeTextHeight(2) - 20,0,2);
|
||||
LCR_rendererComputeTextWidth(str,2) - LCR_GUI_GAP,
|
||||
LCR_EFFECTIVE_RESOLUTION_Y - LCR_rendererComputeTextHeight(2) -
|
||||
LCR_GUI_GAP,0,2);
|
||||
|
||||
LCR_gameTimeToStr(LCR_timeTicksToMS(LCR_game.runTime),str);
|
||||
|
||||
if (LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
|
||||
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
|
||||
LCR_rendererComputeTextHeight(2) - 45,0,2);
|
||||
LCR_rendererDrawText(str,LCR_GUI_GAP,LCR_EFFECTIVE_RESOLUTION_Y -
|
||||
LCR_rendererComputeTextHeight(2) - 3 * LCR_GUI_GAP,0,2);
|
||||
else
|
||||
LCR_rendererDrawText(str,((LCR_EFFECTIVE_RESOLUTION_X -
|
||||
LCR_rendererComputeTextWidth(str,4)) / 2),
|
||||
|
@ -1151,8 +1155,8 @@ void LCR_gameDraw3DView(void)
|
|||
|
||||
LCR_gameTimeToStr(LCR_currentMap.targetTime * LCR_RACING_TICK_MS,str);
|
||||
|
||||
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
|
||||
LCR_rendererComputeTextHeight(2) - 20,0x4208,2);
|
||||
LCR_rendererDrawText(str,LCR_GUI_GAP,LCR_EFFECTIVE_RESOLUTION_Y -
|
||||
LCR_rendererComputeTextHeight(2) - LCR_GUI_GAP,0x4208,2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue