New feature: The menus are centered even on different resolutions. (From Jimmy Salmon)
This commit is contained in:
parent
5416d5ced6
commit
c61ee07525
2 changed files with 34 additions and 5 deletions
|
@ -556,6 +556,8 @@
|
|||
<LI>Fog of war should be working correctly now when NEW_MAPDRAW is
|
||||
defined. I also fixed a couple of redraw problems when drawing
|
||||
the selection rectangle or when units rotate when attacking.
|
||||
<LI>New feature: The menus are centered even on different resolutions.
|
||||
<LI>Fixed bug: First screen isn't correct redrawn.
|
||||
</UL>
|
||||
<LI>+++
|
||||
<LI>TODO: Fixed bug: Unit didn't return to start point, if attacking.
|
||||
|
|
|
@ -124,6 +124,12 @@ global int CurrentMenu = -1;
|
|||
local int MenuButtonUnderCursor = -1;
|
||||
local int MenuButtonCurSel = -1;
|
||||
|
||||
/**
|
||||
** Offsets from top and left, used for different resolutions
|
||||
*/
|
||||
local int OffsetX = 0;
|
||||
local int OffsetY = 0;
|
||||
|
||||
/**
|
||||
** Items for the Game Menu
|
||||
*/
|
||||
|
@ -878,8 +884,9 @@ local void NameLineDrawFunc(Menuitem *mi __attribute__((unused)))
|
|||
int nc, rc;
|
||||
|
||||
GetDefaultTextColors(&nc, &rc);
|
||||
StartMenusSetBackground(mi);
|
||||
SetDefaultTextColors(rc, rc);
|
||||
DrawTextCentered(640/2, 440, GameFont, NameLine);
|
||||
DrawTextCentered(VideoWidth/2, OffsetY + 440, GameFont, NameLine);
|
||||
SetDefaultTextColors(nc, rc);
|
||||
}
|
||||
|
||||
|
@ -1394,14 +1401,14 @@ local void GameDrawFunc(Menuitem *mi)
|
|||
GetDefaultTextColors(&nc, &rc);
|
||||
StartMenusSetBackground(mi);
|
||||
SetDefaultTextColors(rc, rc);
|
||||
DrawText(16, 360, GameFont, "Scenario:");
|
||||
DrawText(16, 360+24 , GameFont, ScenSelectFileName);
|
||||
DrawText(OffsetX + 16, OffsetY + 360, GameFont, "Scenario:");
|
||||
DrawText(OffsetX + 16, OffsetY + 360+24 , GameFont, ScenSelectFileName);
|
||||
if (ScenSelectPudInfo) {
|
||||
if (ScenSelectPudInfo->Description) {
|
||||
DrawText(16, 360+24+24, GameFont, ScenSelectPudInfo->Description);
|
||||
DrawText(OffsetX + 16, OffsetY + 360+24+24, GameFont, ScenSelectPudInfo->Description);
|
||||
}
|
||||
sprintf(buffer, "%d x %d", ScenSelectPudInfo->MapWidth, ScenSelectPudInfo->MapHeight);
|
||||
DrawText(16, 360+24+24+24, GameFont, buffer);
|
||||
DrawText(OffsetX + 16, OffsetY + 360+24+24+24, GameFont, buffer);
|
||||
}
|
||||
#if 0
|
||||
for (n = j = 0; j < 16; j++) {
|
||||
|
@ -2105,6 +2112,22 @@ global void ProcessMenu(int MenuId, int Loop)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Move buttons so they're centered on different resolutions
|
||||
*/
|
||||
local void MoveButtons()
|
||||
{
|
||||
int menus = sizeof(Menus) / sizeof(Menu);
|
||||
int i;
|
||||
|
||||
OffsetX = (VideoWidth - 640) / 2;
|
||||
OffsetY = (VideoHeight - 480) / 2;
|
||||
|
||||
for (i=0; i<menus; i++) {
|
||||
Menus[i].x += OffsetX;
|
||||
Menus[i].y += OffsetY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Init Menus for a specific race
|
||||
|
@ -2117,6 +2140,10 @@ global void InitMenus(unsigned int race)
|
|||
const char* file;
|
||||
char *buf;
|
||||
|
||||
if (last_race == -1 && VideoWidth != 640) {
|
||||
MoveButtons();
|
||||
}
|
||||
|
||||
if (race == last_race) // same race? already loaded!
|
||||
return;
|
||||
if (last_race != -1) { // free previous sprites for different race
|
||||
|
|
Loading…
Reference in a new issue