Cleanup.
svn-id: r18324
This commit is contained in:
parent
ec958e975e
commit
41f69db19f
4 changed files with 18 additions and 58 deletions
|
@ -296,18 +296,15 @@ ButtonWidget *Dialog::addButton(GuiObject *boss, int x, int y, const Common::Str
|
|||
}
|
||||
|
||||
CheckboxWidget *Dialog::addCheckbox(GuiObject *boss, int x, int y, const Common::String &label, uint32 cmd, char hotkey, WidgetSize ws) {
|
||||
const Graphics::Font *font;
|
||||
int w, h;
|
||||
|
||||
if (ws == kBigWidgetSize) {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
h = kBigButtonHeight;
|
||||
} else {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
h = kButtonHeight;
|
||||
}
|
||||
|
||||
w = font->getFontHeight() + 10 + font->getStringWidth(label);
|
||||
w = g_gui.getFontHeight() + 10 + g_gui.getStringWidth(label);
|
||||
|
||||
return new CheckboxWidget(boss, x, y, w, h, label, cmd, hotkey, ws);
|
||||
}
|
||||
|
@ -327,15 +324,7 @@ SliderWidget *Dialog::addSlider(GuiObject *boss, int x, int y, uint32 cmd, Widge
|
|||
}
|
||||
|
||||
PopUpWidget *Dialog::addPopUp(GuiObject *boss, int x, int y, int w, const Common::String &label, uint labelWidth, WidgetSize ws) {
|
||||
const Graphics::Font *font;
|
||||
|
||||
if (ws == kBigWidgetSize) {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
} else {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
}
|
||||
|
||||
return new PopUpWidget(boss, x, y, w, font->getFontHeight() + 2, label, labelWidth, ws);
|
||||
return new PopUpWidget(boss, x, y, w, kLineHeight, label, labelWidth, ws);
|
||||
}
|
||||
|
||||
uint32 GuiObject::getMillis() {
|
||||
|
|
|
@ -188,24 +188,14 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
|
|||
tab->addTab("Game");
|
||||
yoffset = vBorder;
|
||||
|
||||
const Graphics::Font *font;
|
||||
|
||||
if (ws == GUI::kBigWidgetSize) {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
} else {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
}
|
||||
|
||||
int lineHeight = font->getFontHeight() + 2;
|
||||
|
||||
// GUI: Label & edit widget for the game ID
|
||||
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, lineHeight, "ID: ", kTextAlignRight, ws);
|
||||
_domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, lineHeight, _domain, ws);
|
||||
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "ID: ", kTextAlignRight, ws);
|
||||
_domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, kLineHeight, _domain, ws);
|
||||
yoffset += _domainWidget->getHeight() + 3;
|
||||
|
||||
// GUI: Label & edit widget for the description
|
||||
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, lineHeight, "Name: ", kTextAlignRight, ws);
|
||||
_descriptionWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, lineHeight, description, ws);
|
||||
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "Name: ", kTextAlignRight, ws);
|
||||
_descriptionWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10 - x, kLineHeight, description, ws);
|
||||
yoffset += _descriptionWidget->getHeight() + 3;
|
||||
|
||||
// Language popup
|
||||
|
@ -234,12 +224,12 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
|
|||
|
||||
// GUI: Button + Label for the game path
|
||||
addButton(tab, x, yoffset, "Game Path:", kCmdGameBrowser, 0, ws);
|
||||
_gamePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, gamePath, kTextAlignLeft, ws);
|
||||
_gamePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, gamePath, kTextAlignLeft, ws);
|
||||
yoffset += buttonHeight + 4;
|
||||
|
||||
// GUI: Button + Label for the additional path
|
||||
addButton(tab, x, yoffset, "Extra Path:", kCmdExtraBrowser, 0, ws);
|
||||
_extraPathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, extraPath, kTextAlignLeft, ws);
|
||||
_extraPathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, extraPath, kTextAlignLeft, ws);
|
||||
if (extraPath.isEmpty() || !ConfMan.hasKey("extrapath", _domain)) {
|
||||
_extraPathWidget->setLabel("None");
|
||||
}
|
||||
|
@ -247,7 +237,7 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
|
|||
|
||||
// GUI: Button + Label for the save path
|
||||
addButton(tab, x, yoffset, "Save Path:", kCmdSaveBrowser, 0, ws);
|
||||
_savePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, lineHeight, savePath, kTextAlignLeft, ws);
|
||||
_savePathWidget = new StaticTextWidget(tab, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, savePath, kTextAlignLeft, ws);
|
||||
if (savePath.isEmpty() || !ConfMan.hasKey("savepath", _domain)) {
|
||||
_savePathWidget->setLabel("Default");
|
||||
}
|
||||
|
@ -507,25 +497,19 @@ LauncherDialog::LauncherDialog(GameDetector &detector)
|
|||
_h = screenH;
|
||||
|
||||
GUI::WidgetSize ws;
|
||||
int lineHeight;
|
||||
int buttonHeight;
|
||||
const Graphics::Font *font;
|
||||
int top;
|
||||
|
||||
if (screenW >= 400 && screenH >= 300) {
|
||||
ws = GUI::kBigWidgetSize;
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
lineHeight = font->getFontHeight() + 2;
|
||||
buttonHeight = kBigButtonHeight;
|
||||
} else {
|
||||
ws = GUI::kNormalWidgetSize;
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
lineHeight = font->getFontHeight() + 2;
|
||||
buttonHeight = kButtonHeight;
|
||||
}
|
||||
|
||||
// Show ScummVM version
|
||||
new StaticTextWidget(this, hBorder, 8, _w - 2*hBorder, lineHeight, gScummVMFullVersion, kTextAlignCenter, ws);
|
||||
new StaticTextWidget(this, hBorder, 8, _w - 2*hBorder, kLineHeight, gScummVMFullVersion, kTextAlignCenter, ws);
|
||||
|
||||
// Add some buttons at the bottom
|
||||
// TODO: Rearrange them a bit? In particular, we could put a slightly smaller space
|
||||
|
@ -551,7 +535,7 @@ LauncherDialog::LauncherDialog(GameDetector &detector)
|
|||
|
||||
|
||||
// Add list with game titles
|
||||
_list = new ListWidget(this, hBorder, lineHeight + 16, _w - 2 * hBorder, top - lineHeight - 20, ws);
|
||||
_list = new ListWidget(this, hBorder, kLineHeight + 16, _w - 2 * hBorder, top - kLineHeight - 20, ws);
|
||||
_list->setEditable(false);
|
||||
_list->setNumberingMode(kListNumberingOff);
|
||||
|
||||
|
|
|
@ -41,19 +41,14 @@ MessageDialog::MessageDialog(const Common::String &message, const char *defaultB
|
|||
const int screenH = g_system->getOverlayHeight();
|
||||
|
||||
GUI::WidgetSize ws;
|
||||
int lineHeight;
|
||||
int buttonWidth, buttonHeight;
|
||||
const Graphics::Font *font;
|
||||
|
||||
if (screenW >= 400 && screenH >= 300) {
|
||||
ws = GUI::kBigWidgetSize;
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
lineHeight = font->getFontHeight() + 2;
|
||||
buttonWidth = kBigButtonWidth;
|
||||
buttonHeight = kBigButtonHeight;
|
||||
} else {
|
||||
ws = GUI::kNormalWidgetSize;
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
lineHeight = font->getFontHeight() + 2;
|
||||
buttonWidth = kButtonWidth;
|
||||
buttonHeight = kButtonHeight;
|
||||
}
|
||||
|
@ -64,7 +59,7 @@ MessageDialog::MessageDialog(const Common::String &message, const char *defaultB
|
|||
// the real size of the dialog
|
||||
Common::StringList lines;
|
||||
int lineCount, okButtonPos, cancelButtonPos;
|
||||
int maxlineWidth = font->wordWrapText(message, screenW - 2 * 20, lines);
|
||||
int maxlineWidth = g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines);
|
||||
|
||||
// Calculate the desired dialog size (maxing out at 300*180 for now)
|
||||
_w = maxlineWidth + 20;
|
||||
|
@ -75,10 +70,10 @@ MessageDialog::MessageDialog(const Common::String &message, const char *defaultB
|
|||
_h += buttonHeight + 8;
|
||||
|
||||
// Limit the number of lines so that the dialog still fits on the screen.
|
||||
if (lineCount > (screenH - 20 - _h) / lineHeight) {
|
||||
lineCount = (screenH - 20 - _h) / lineHeight;
|
||||
if (lineCount > (screenH - 20 - _h) / kLineHeight) {
|
||||
lineCount = (screenH - 20 - _h) / kLineHeight;
|
||||
}
|
||||
_h += lineCount * lineHeight;
|
||||
_h += lineCount * kLineHeight;
|
||||
|
||||
// Center the dialog
|
||||
_x = (screenW - _w) / 2;
|
||||
|
@ -86,7 +81,7 @@ MessageDialog::MessageDialog(const Common::String &message, const char *defaultB
|
|||
|
||||
// Each line is represented by one static text item.
|
||||
for (int i = 0; i < lineCount; i++) {
|
||||
new StaticTextWidget(this, 10, 10 + i * lineHeight, maxlineWidth, lineHeight,
|
||||
new StaticTextWidget(this, 10, 10 + i * kLineHeight, maxlineWidth, kLineHeight,
|
||||
lines[i], kTextAlignCenter, ws);
|
||||
}
|
||||
|
||||
|
|
|
@ -439,18 +439,10 @@ int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset, WidgetSize ws
|
|||
"Speech volume:"
|
||||
};
|
||||
|
||||
const Graphics::Font *font;
|
||||
|
||||
if (ws == kBigWidgetSize) {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
} else {
|
||||
font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
}
|
||||
|
||||
int textwidth = 0;
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(slider_labels); i++) {
|
||||
int width = font->getStringWidth(slider_labels[i]);
|
||||
int width = g_gui.getStringWidth(slider_labels[i]);
|
||||
|
||||
if (width > textwidth)
|
||||
textwidth = width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue