mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
- cleanup popup menu sizing so it looks more clean
This commit is contained in:
parent
bc5c32deb1
commit
22e28c323f
@ -698,6 +698,9 @@ void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
|
||||
x= (metrics.getVirtualW()-w)/2;
|
||||
y= (metrics.getVirtualH()-h)/2;
|
||||
|
||||
int textHeight = GraphicButton::defH;
|
||||
int textHeightSpacing = 6;
|
||||
|
||||
int maxButtonWidth = -1;
|
||||
for(unsigned int i = 0; i < menuItems.size(); ++i) {
|
||||
int currentButtonWidth = -1;
|
||||
@ -715,15 +718,28 @@ void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
|
||||
}
|
||||
|
||||
if(maxButtonWidth < 0 || currentButtonWidth > maxButtonWidth) {
|
||||
maxButtonWidth = currentButtonWidth + 5;
|
||||
maxButtonWidth = currentButtonWidth + textHeightSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
int textHeight = 30;
|
||||
int yStartOffset = y + (h/2) + (textHeight/2);
|
||||
int yStartOffset = y + h - (textHeight * 2);
|
||||
|
||||
if(maxButtonWidth >= w) {
|
||||
w = maxButtonWidth + textHeightSpacing;
|
||||
x= (metrics.getVirtualW()-w)/2;
|
||||
}
|
||||
|
||||
int offsetH = (yStartOffset - y);
|
||||
int maxH = (offsetH + ((menuItems.size() -1 ) * (textHeight + textHeightSpacing)));
|
||||
if(maxH >= h) {
|
||||
h = maxH;
|
||||
y= (metrics.getVirtualH()-h)/2;
|
||||
yStartOffset = y + h - (textHeight * 2);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < menuItems.size(); ++i) {
|
||||
GraphicButton button;
|
||||
button.init(x+(w-maxButtonWidth)/2, yStartOffset - (i*textHeight));
|
||||
button.init(x+(w-maxButtonWidth)/2, yStartOffset - (i*(textHeight + textHeightSpacing)));
|
||||
button.setText(menuItems[i]);
|
||||
button.setW(maxButtonWidth);
|
||||
|
||||
|
@ -953,8 +953,8 @@ void Game::init(bool initForPreviewOnly)
|
||||
menuItems.push_back(lang.get("Keyboardsetup"));
|
||||
keyboardSetupPopupMenuIndex = menuItems.size()-1;
|
||||
menuItems.push_back(lang.get("Cancel"));
|
||||
popupMenu.setW(200);
|
||||
popupMenu.setH(200);
|
||||
popupMenu.setW(100);
|
||||
popupMenu.setH(100);
|
||||
popupMenu.init(lang.get("GameMenuTitle"),menuItems);
|
||||
popupMenu.setEnabled(false);
|
||||
popupMenu.setVisible(false);
|
||||
@ -1427,8 +1427,8 @@ void Game::mouseDownLeft(int x, int y) {
|
||||
menuItems.push_back(lang.get("Cancel"));
|
||||
switchTeamIndexMap[menuItems.size()-1] = CANCEL_SWITCH_TEAM;
|
||||
|
||||
popupMenuSwitchTeams.setW(400);
|
||||
popupMenuSwitchTeams.setH(400);
|
||||
popupMenuSwitchTeams.setW(100);
|
||||
popupMenuSwitchTeams.setH(100);
|
||||
popupMenuSwitchTeams.init(lang.get("SwitchTeams"),menuItems);
|
||||
popupMenuSwitchTeams.setEnabled(true);
|
||||
popupMenuSwitchTeams.setVisible(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user