diff options
author | Max Horn | 2005-05-17 21:40:29 +0000 |
---|---|---|
committer | Max Horn | 2005-05-17 21:40:29 +0000 |
commit | 42db49b15ad30641d80d57f1e57f74ac2dbd1afd (patch) | |
tree | d7b52e29aeadcf127f3efa4fc619c124a3286b84 | |
parent | bfbbf485859c18591c20ca6019ff8eb8ef62ad54 (diff) | |
download | scummvm-rg350-42db49b15ad30641d80d57f1e57f74ac2dbd1afd.tar.gz scummvm-rg350-42db49b15ad30641d80d57f1e57f74ac2dbd1afd.tar.bz2 scummvm-rg350-42db49b15ad30641d80d57f1e57f74ac2dbd1afd.zip |
Center about dialog, and make it just wide enough to display the credits, but not wider
svn-id: r18139
-rw-r--r-- | gui/about.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gui/about.cpp b/gui/about.cpp index 2457ca69df..e762da8bbe 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -88,13 +88,17 @@ AboutDialog::AboutDialog() int i; - _w = g_system->getOverlayWidth() - 2 * 10; - _h = g_system->getOverlayHeight() - 20 - 16; + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + _w = screenW - 2 * 10; + _h = screenH - 20 - 16; - if (_w >= 400 && _h >= 300) + if (_w >= 400 && _h >= 300) { _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - else + } else { _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); + } _lineHeight = _font->getFontHeight() + 3; @@ -131,6 +135,20 @@ AboutDialog::AboutDialog() for (i = 0; i < ARRAYSIZE(credits); i++) _lines.push_back(credits[i]); + + // Compute 'optimal' dialog width + int maxW = _w; + _w = 0; + for (i = 0; i < (int)_lines.size(); ++i) { + _w = MAX(_w, _font->getStringWidth(_lines[i])); + } + if (_w > maxW) + _w = maxW; + + + // Center the dialog + _x = (screenW - _w) / 2; + _y = (screenH - _h) / 2; } void AboutDialog::open() { |