[Scummvm-cvs-logs] CVS: scummvm/gui console.cpp,1.47,1.48 newgui.cpp,1.84,1.85 newgui.h,1.44,1.45

Max Horn fingolfin at users.sourceforge.net
Sun Aug 15 06:17:19 CEST 2004


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

Modified Files:
	console.cpp newgui.cpp newgui.h 
Log Message:
Removed some obsolete stuff; made switching to the alt font less intrusive (you only have to recompile a single file now); foundation for future run-time font switching...

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- console.cpp	23 May 2004 14:06:52 -0000	1.47
+++ console.cpp	15 Aug 2004 13:15:55 -0000	1.48
@@ -26,7 +26,8 @@
 #include "base/version.h"
 
 #include "graphics/font.h"
-#define kCharWidth	g_guifont.getMaxCharWidth()
+
+#define kCharWidth	g_gui.getFont().getMaxCharWidth()
 
 
 namespace GUI {

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- newgui.cpp	28 Mar 2004 16:30:48 -0000	1.84
+++ newgui.cpp	15 Aug 2004 13:15:55 -0000	1.85
@@ -24,6 +24,11 @@
 #include "gui/dialog.h"
 
 
+// Uncomment the following to enable the new font code:
+//#define NEW_FONT_CODE
+
+
+
 namespace GUI {
 
 /*
@@ -239,6 +244,14 @@
 
 #pragma mark -
 
+const Graphics::Font &NewGui::getFont() const {
+#ifdef NEW_FONT_CODE
+	return Graphics::g_sysfont;
+#else
+	return Graphics::g_scummfont;
+#endif
+}
+
 OverlayColor *NewGui::getBasePtr(int x, int y) {
 	return (OverlayColor *)((byte *)_screen.pixels + x * _screen.bytesPerPixel + y * _screen.pitch);
 }
@@ -361,47 +374,19 @@
 }
 
 void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color) {
-	g_guifont.drawChar(&_screen, chr, xx, yy, color);
+	getFont().drawChar(&_screen, chr, xx, yy, color);
 }
 
 int NewGui::getStringWidth(const String &str) {
-	return g_guifont.getStringWidth(str);
+	return getFont().getStringWidth(str);
 }
 
 int NewGui::getCharWidth(byte c) {
-	return g_guifont.getCharWidth(c);
+	return getFont().getCharWidth(c);
 }
 
 void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) {
-	g_guifont.drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis);
-}
-
-//
-// Blit from a buffer to the display
-//
-void NewGui::blitFromBuffer(int x, int y, int w, int h, const byte *buf, int pitch) {
-	OverlayColor *ptr = getBasePtr(x, y);
-
-	assert(buf);
-	while (h--) {
-		memcpy(ptr, buf, w*2);
-		ptr += _screenPitch;
-		buf += pitch;
-	}
-}
-
-//
-// Blit from the display to a buffer
-//
-void NewGui::blitToBuffer(int x, int y, int w, int h, byte *buf, int pitch) {
-	OverlayColor *ptr = getBasePtr(x, y);
-
-	assert(buf);
-	while (h--) {
-		memcpy(buf, ptr, w * 2);
-		ptr += _screenPitch;
-		buf += pitch;
-	}
+	getFont().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.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- newgui.h	5 May 2004 01:19:42 -0000	1.44
+++ newgui.h	15 Aug 2004 13:15:55 -0000	1.45
@@ -28,10 +28,6 @@
 #include "common/system.h"	// For events
 #include "graphics/font.h"
 
-// Uncomment the following to enable the new font code:
-//#define NEW_FONT_CODE
-
-
 namespace GUI {
 
 class Dialog;
@@ -40,12 +36,7 @@
 
 
 // Height of a single text line
-#ifdef NEW_FONT_CODE
-#define		g_guifont		Graphics::g_sysfont
-#else
-#define		g_guifont		Graphics::g_scummfont
-#endif
-#define kLineHeight	(g_guifont.getFontHeight() + 2)
+#define kLineHeight	(g_gui.getFont().getFontHeight() + 2)
 
 
 using Graphics::TextAlignment;
@@ -117,15 +108,19 @@
 	void animateCursor();
 	void updateColors();
 
+	OverlayColor *getBasePtr(int x, int y);
+
 public:
 	// Theme colors
 	OverlayColor _color, _shadowcolor;
 	OverlayColor _bgcolor;
 	OverlayColor _textcolor;
 	OverlayColor _textcolorhi;
+	
+	// Font
+	const Graphics::Font &getFont() const;
 
 	// Drawing primitives
-	OverlayColor *getBasePtr(int x, int y);
 	void box(int x, int y, int width, int height, OverlayColor colorA, OverlayColor colorB);
 	void hLine(int x, int y, int x2, OverlayColor color);
 	void vLine(int x, int y, int y2, OverlayColor color);
@@ -138,9 +133,6 @@
 	int getCharWidth(byte c);
 	void drawString(const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment align = Graphics::kTextAlignLeft, int deltax = 0, bool useEllipsis = true);
 
-	void blitFromBuffer(int x, int y, int w, int h, const byte *buf, int pitch);
-	void blitToBuffer(int x, int y, int w, int h, byte *buf, int pitch);
-
 	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