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