[Scummvm-cvs-logs] CVS: scummvm/gui about.h,1.13,1.14 console.h,1.31,1.32 dialog.cpp,1.58,1.59 dialog.h,1.39,1.40 message.h,1.17,1.18 newgui.cpp,1.114,1.115 newgui.h,1.59,1.60
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Thu Jun 2 05:31:09 CEST 2005
Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32102/gui
Modified Files:
about.h console.h dialog.cpp dialog.h message.h newgui.cpp
newgui.h
Log Message:
The GUI has reached the point where I think it's safe to begin removing the
old auto-scaling hack. Removed wantsScaling(), USE_AUTO_SCALING,
_scaleFactor and _scaleEnable.
Also removed drawBitmap() since we no longer use bitmaps for widget
decorations.
Index: about.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/about.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- about.h 17 May 2005 23:41:35 -0000 1.13
+++ about.h 2 Jun 2005 12:29:01 -0000 1.14
@@ -58,9 +58,6 @@
void handleMouseUp(int x, int y, int button, int clickCount);
void handleKeyDown(uint16 ascii, int keycode, int modifiers);
void handleKeyUp(uint16 ascii, int keycode, int modifiers);
-
- // disable scaling
- bool wantsScaling() const { return false; }
};
} // End of namespace GUI
Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- console.h 17 Apr 2005 12:03:03 -0000 1.31
+++ console.h 2 Jun 2005 12:29:01 -0000 1.32
@@ -113,9 +113,6 @@
_completionCallbackRefCon = refCon;
}
- // disable scaling
- bool wantsScaling() const { return false; }
-
protected:
inline char &buffer(int idx) {
return _buffer[idx % kBufferSize];
Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- dialog.cpp 20 May 2005 15:03:25 -0000 1.58
+++ dialog.cpp 2 Jun 2005 12:29:01 -0000 1.59
@@ -100,10 +100,6 @@
g_gui._needRedraw = true;
}
-bool Dialog::wantsScaling() const {
- return true;
-}
-
void Dialog::drawDialog() {
if (!isVisible())
Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- dialog.h 20 May 2005 15:03:25 -0000 1.39
+++ dialog.h 2 Jun 2005 12:29:01 -0000 1.40
@@ -58,16 +58,6 @@
void releaseFocus();
- /**
- * We can optionally scale dialogs by a factor of two. This is the
- * default behaviour if the GUI is displayed on a 640x400 or bigger
- * screen. However, some dialogs can cope with multiple screen sizes,
- * and thus do not want automatic scaling.
- *
- * @return true if the dialog adjusts itself to the screen size
- */
- virtual bool wantsScaling() const;
-
protected:
virtual void open();
virtual void close();
Index: message.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/message.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- message.h 15 May 2005 17:01:31 -0000 1.17
+++ message.h 2 Jun 2005 12:29:01 -0000 1.18
@@ -40,9 +40,6 @@
MessageDialog(const Common::String &message, const char *defaultButton = "OK", const char *altButton = 0);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
-
- // disable scaling
- bool wantsScaling() const { return false; }
};
/**
Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- newgui.cpp 20 May 2005 15:03:25 -0000 1.114
+++ newgui.cpp 2 Jun 2005 12:29:01 -0000 1.115
@@ -49,10 +49,8 @@
};
-#define USE_AUTO_SCALING false
-
// Constructor
-NewGui::NewGui() : _scaleEnable(USE_AUTO_SCALING), _needRedraw(false),
+NewGui::NewGui() : _needRedraw(false),
_stateIsSaved(false), _font(0), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
_system = &OSystem::instance();
@@ -77,23 +75,18 @@
}
void NewGui::updateScaleFactor() {
- if (!_scaleEnable) {
- _scaleFactor = 1;
- } else {
- enum {
- kDefaultGUIWidth = 320,
- kDefaultGUIHeight = 200
- };
-
- // NES has 256 pixels width which makes MIN() return 0 here.
- _scaleFactor = MAX(MIN(_system->getOverlayWidth() / kDefaultGUIWidth, _system->getOverlayHeight() / kDefaultGUIHeight), 1);
- }
+ const int screenW = g_system->getOverlayWidth();
+ const int screenH = g_system->getOverlayHeight();
- // Pick the font depending on the scale factor.
- if (_scaleFactor == 1)
- _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
- else
+ // TODO: Perhaps we should also set the widget size here. That'd allow
+ // us to remove much of the screen size checking from the individual
+ // widgets.
+
+ if (screenW >= 400 && screenH >= 300) {
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
+ } else {
+ _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ }
}
void NewGui::runLoop() {
@@ -108,7 +101,6 @@
// EVENT_SCREEN_CHANGED is received. However, not yet all backends support
// that event, so we also do it "manually" whenever a run loop is entered.
updateColors();
- _scaleEnable = USE_AUTO_SCALING && activeDialog->wantsScaling();
updateScaleFactor();
if (!_stateIsSaved) {
@@ -127,7 +119,6 @@
for (int i = 0; i < _dialogStack.size(); i++) {
// For each dialog we draw we have to ensure the correct
// scaling mode is active.
- _scaleEnable = USE_AUTO_SCALING && _dialogStack[i]->wantsScaling();
updateScaleFactor();
_dialogStack[i]->drawDialog();
}
@@ -141,9 +132,7 @@
uint32 time = _system->getMillis();
while (_system->pollEvent(event)) {
- Common::Point mouse(event.mouse.x - (activeDialog->_x * _scaleFactor), event.mouse.y - (activeDialog->_y * _scaleFactor));
- mouse.x /= _scaleFactor;
- mouse.y /= _scaleFactor;
+ Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
switch (event.type) {
case OSystem::EVENT_KEYDOWN:
@@ -302,15 +291,15 @@
}
void NewGui::hLine(int x, int y, int x2, OverlayColor color) {
- _screen.hLine(x * _scaleFactor, y * _scaleFactor, x2 * _scaleFactor, color);
+ _screen.hLine(x, y, x2, color);
}
void NewGui::vLine(int x, int y, int y2, OverlayColor color) {
- _screen.vLine(x * _scaleFactor, y * _scaleFactor, y2 * _scaleFactor, color);
+ _screen.vLine(x, y, y2, color);
}
void NewGui::copyToSurface(Graphics::Surface *s, int x, int y, int w, int h) {
- Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor);
+ Common::Rect rect(x, y, x + w, y + h);
rect.clip(_screen.w, _screen.h);
if (!rect.isValidRect())
@@ -336,7 +325,7 @@
}
void NewGui::drawSurface(const Graphics::Surface &s, int x, int y) {
- Common::Rect rect(x * _scaleFactor, y * _scaleFactor, x * _scaleFactor + s.w, y * _scaleFactor + s.h);
+ Common::Rect rect(x, y, x + s.w, y + s.h);
rect.clip(_screen.w, _screen.h);
if (!rect.isValidRect())
@@ -361,7 +350,7 @@
#ifdef NEWGUI_256
fillRect(x, y, w, h, color);
#else
- Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor);
+ Common::Rect rect(x, y, x + w, y + h);
rect.clip(_screen.w, _screen.h);
if (!rect.isValidRect())
@@ -423,15 +412,15 @@
}
void NewGui::fillRect(int x, int y, int w, int h, OverlayColor color) {
- _screen.fillRect(Common::Rect(x * _scaleFactor, y * _scaleFactor, (x+w) * _scaleFactor, (y+h) * _scaleFactor), color);
+ _screen.fillRect(Common::Rect(x, y, x + w, y + h), color);
}
void NewGui::frameRect(int x, int y, int w, int h, OverlayColor color) {
- _screen.frameRect(Common::Rect(x * _scaleFactor, y * _scaleFactor, (x+w) * _scaleFactor, (y+h) * _scaleFactor), color);
+ _screen.frameRect(Common::Rect(x, y, x + w, y + h), color);
}
void NewGui::addDirtyRect(int x, int y, int w, int h) {
- Common::Rect rect(x * _scaleFactor, y * _scaleFactor, (x + w) * _scaleFactor, (y + h) * _scaleFactor);
+ Common::Rect rect(x, y, x + w, y + h);
rect.clip(_screen.w, _screen.h);
if (!rect.isValidRect())
@@ -447,53 +436,27 @@
void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) {
if (font == 0)
font = &getFont();
- font->drawChar(&_screen, chr, xx * _scaleFactor, yy * _scaleFactor, color);
+ font->drawChar(&_screen, chr, xx, yy, color);
}
int NewGui::getStringWidth(const String &str) const {
- return getFont().getStringWidth(str) / _scaleFactor;
+ return getFont().getStringWidth(str);
}
int NewGui::getCharWidth(byte c) const {
- return getFont().getCharWidth(c) / _scaleFactor;
+ return getFont().getCharWidth(c);
}
int NewGui::getFontHeight() const {
- return getFont().getFontHeight() / _scaleFactor;
+ return getFont().getFontHeight();
}
void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) {
- getFont().drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
+ getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis);
}
void NewGui::drawString(const Graphics::Font *font, const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) {
- font->drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
-}
-
-//
-// Draw an 8x8 bitmap at location (x,y)
-//
-void NewGui::drawBitmap(uint32 *bitmap, int tx, int ty, OverlayColor color, int h) {
- tx *= _scaleFactor; ty *= _scaleFactor;
- h *= _scaleFactor;
- OverlayColor *ptr = getBasePtr(tx, ty);
-
- for (int y = 0; y < h; y++, ptr += _screenPitch) {
- uint32 mask = 0xF0000000;
- if (ty + y < 0 || ty + y >= _screen.h)
- continue;
- for (int x = 0; x < 8 * _scaleFactor; x++) {
- if (!(x % 2) && _scaleFactor != 1 && x != 0)
- mask >>= 4;
- else if (_scaleFactor == 1)
- mask >>= 4;
-
- if (tx + x < 0 || tx + x >= _screen.w)
- continue;
- if (bitmap[y / _scaleFactor] & mask)
- ptr[x] = color;
- }
- }
+ font->drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis);
}
//
Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- newgui.h 20 May 2005 15:03:26 -0000 1.59
+++ newgui.h 2 Jun 2005 12:29:01 -0000 1.60
@@ -72,9 +72,6 @@
Graphics::Surface _screen;
int _screenPitch;
- int _scaleFactor;
- bool _scaleEnable;
-
bool _needRedraw;
DialogStack _dialogStack;
@@ -127,7 +124,7 @@
// Font
const Graphics::Font &getFont() const;
-
+
// Screen surface
Graphics::Surface &getScreen() { return _screen; }
@@ -160,8 +157,6 @@
int getCharWidth(byte c) const;
int getFontHeight() const;
- void drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h = 8);
-
void addDirtyRect(int x, int y, int w, int h);
};
More information about the Scummvm-git-logs
mailing list