[Scummvm-cvs-logs] CVS: scummvm/gui about.cpp,1.34,1.35

Max Horn fingolfin at users.sourceforge.net
Tue May 17 14:41:14 CEST 2005


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29612

Modified Files:
	about.cpp 
Log Message:
Center about dialog, and make it just wide enough to display the credits, but not wider

Index: about.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- about.cpp	15 May 2005 17:01:31 -0000	1.34
+++ about.cpp	17 May 2005 21:40:29 -0000	1.35
@@ -88,13 +88,17 @@
 	
 	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 @@
 	
 	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() {





More information about the Scummvm-git-logs mailing list