aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2004-03-21 21:20:25 +0000
committerMax Horn2004-03-21 21:20:25 +0000
commita9789acfc61a057c82c6cc42386afc9b23813c24 (patch)
tree3e36be49dd35ceb59ce98f74aec92cd9c60198a4
parent23dbd0de994ebfc97c65ab9deb96b052d1983426 (diff)
downloadscummvm-rg350-a9789acfc61a057c82c6cc42386afc9b23813c24.tar.gz
scummvm-rg350-a9789acfc61a057c82c6cc42386afc9b23813c24.tar.bz2
scummvm-rg350-a9789acfc61a057c82c6cc42386afc9b23813c24.zip
Moved Surface/Font code into new 'graphics' module
svn-id: r13357
-rw-r--r--Makefile.common1
-rw-r--r--backends/sdl/graphics.cpp10
-rw-r--r--graphics/animation.cpp23
-rw-r--r--graphics/animation.h56
-rw-r--r--graphics/font.cpp (renamed from gui/font.cpp)6
-rw-r--r--graphics/font.h (renamed from gui/font.h)19
-rw-r--r--graphics/module.mk13
-rw-r--r--graphics/newfont.cpp (renamed from gui/newfont.cpp)6
-rw-r--r--graphics/scummfont.cpp (renamed from gui/scummfont.cpp)8
-rw-r--r--graphics/surface.h46
-rw-r--r--gui/console.cpp2
-rw-r--r--gui/module.mk8
-rw-r--r--gui/newgui.h16
-rw-r--r--gui/widget.h3
-rw-r--r--sword1/animation.h28
-rw-r--r--sword2/driver/animation.h29
16 files changed, 174 insertions, 100 deletions
diff --git a/Makefile.common b/Makefile.common
index b1ad7a57d6..7ad95aa335 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -88,6 +88,7 @@ endif
# After the game specific modules follow the shared modules
MODULES += \
gui \
+ graphics \
backends \
sound \
common
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index 8a2ff446f5..7ebb5e5d41 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -23,7 +23,7 @@
#include "backends/sdl/sdl-common.h"
#include "common/scaler.h"
#include "common/util.h"
-#include "gui/font.h"
+#include "graphics/font.h"
static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
{"1x", "Normal (no scaling)", GFX_NORMAL},
@@ -1180,7 +1180,7 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
if (SDL_LockSurface(_osdSurface))
error("displayMessageOnOSD: SDL_LockSurface failed: %s", SDL_GetError());
- GUI::Surface dst;
+ Graphics::Surface dst;
dst.pixels = _osdSurface->pixels;
dst.w = _osdSurface->w;
dst.h = _osdSurface->h;
@@ -1188,8 +1188,8 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
dst.bytesPerPixel = _osdSurface->format->BytesPerPixel;
// The font we are going to use:
-// const GUI::Font *font = &GUI::g_sysfont;
- const GUI::Font *font = &GUI::g_scummfont;
+// const Graphics::Font *font = &Graphics::g_sysfont;
+ const Graphics::Font *font = &Graphics::g_scummfont;
// Clear everything with the "transparent" color, i.e. the colorkey
SDL_FillRect(_osdSurface, 0, kOSDColorKey);
@@ -1236,7 +1236,7 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
font->drawString(&dst, lines[i],
osdRect.x, osdRect.y + i * lineHeight + vOffset + lineSpacing, osdRect.w,
SDL_MapRGB(_osdSurface->format, 255, 255, 255),
- GUI::kTextAlignCenter);
+ Graphics::kTextAlignCenter);
}
// Finished drawing, so unlock the OSD surface again
diff --git a/graphics/animation.cpp b/graphics/animation.cpp
new file mode 100644
index 0000000000..44d0d854eb
--- /dev/null
+++ b/graphics/animation.cpp
@@ -0,0 +1,23 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2004 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "common/stdafx.h"
+#include "graphics/animation.h"
diff --git a/graphics/animation.h b/graphics/animation.h
new file mode 100644
index 0000000000..ce3ff6620f
--- /dev/null
+++ b/graphics/animation.h
@@ -0,0 +1,56 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2004 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef GRAPHICS_ANIMATION_H
+#define GRAPHICS_ANIMATION_H
+
+// Uncomment this if you are using libmpeg2 0.3.1.
+// #define USE_MPEG2_0_3_1
+
+#ifdef _MSC_VER
+typedef int8 int8_t;
+typedef int16 int16_t;
+typedef int32 int32_t;
+
+typedef uint8 uint8_t;
+typedef uint16 uint16_t;
+typedef uint32 uint32_t;
+#else
+#include <inttypes.h>
+#endif
+
+#ifdef USE_MPEG2
+extern "C" {
+ #include <mpeg2dec/mpeg2.h>
+}
+
+#ifdef USE_MPEG2_0_3_1
+typedef int mpeg2_state_t;
+typedef sequence_t mpeg2_sequence_t;
+#define STATE_BUFFER -1
+#endif
+
+#endif
+
+
+
+
+#endif \ No newline at end of file
diff --git a/gui/font.cpp b/graphics/font.cpp
index 5d68eb7f07..e57cb3aae1 100644
--- a/gui/font.cpp
+++ b/graphics/font.cpp
@@ -19,9 +19,9 @@
*/
#include "common/stdafx.h"
-#include "gui/font.h"
+#include "graphics/font.h"
-namespace GUI {
+namespace Graphics {
int NewFont::getCharWidth(byte chr) const {
// If no width table is specified, return the maximum width
@@ -153,4 +153,4 @@ void Font::drawString(const Surface *dst, const Common::String &s, int x, int y,
}
-} // End of namespace GUI
+} // End of namespace Graphics
diff --git a/gui/font.h b/graphics/font.h
index 207b42a493..2d5d6c9bd4 100644
--- a/gui/font.h
+++ b/graphics/font.h
@@ -22,8 +22,9 @@
#define FONT_H
#include "common/str.h"
+#include "graphics/surface.h"
-namespace GUI {
+namespace Graphics {
// Text alignment modes for drawString()
enum TextAlignment {
@@ -33,20 +34,6 @@ enum TextAlignment {
};
/**
- * An arbitrary graphics surface, which can be the target (or source) of blit
- * operations, font rendering, etc.
- * @todo This shouldn't be in font.h, but rather in e.g. graphics/surface.h
- */
-struct Surface {
- void *pixels;
- uint16 w;
- uint16 h;
- uint16 pitch;
- uint8 bytesPerPixel;
- Surface() : pixels(0), w(0), h(0), pitch(0), bytesPerPixel(0) {}
-};
-
-/**
* Instances of this class represent a distinct font, with a built-in renderer.
* @todo Maybe move the high-level methods (drawString etc.) to a separate
* FontRenderer class? That way, we could have different variants... ?
@@ -115,6 +102,6 @@ public:
extern const NewFont g_sysfont;
-} // End of namespace GUI
+} // End of namespace Graphics
#endif
diff --git a/graphics/module.mk b/graphics/module.mk
new file mode 100644
index 0000000000..1eb103267a
--- /dev/null
+++ b/graphics/module.mk
@@ -0,0 +1,13 @@
+MODULE := graphics
+
+MODULE_OBJS := \
+ graphics/animation.o \
+ graphics/font.o \
+ graphics/scummfont.o \
+ graphics/newfont.o
+
+MODULE_DIRS += \
+ graphics
+
+# Include common rules
+include $(srcdir)/common.rules
diff --git a/gui/newfont.cpp b/graphics/newfont.cpp
index 1654db6448..a308bb6656 100644
--- a/gui/newfont.cpp
+++ b/graphics/newfont.cpp
@@ -1,6 +1,6 @@
/* Generated by convbdf on Thu Nov 20 00:15:51 2003. */
#include "common/stdafx.h"
-#include "gui/font.h"
+#include "graphics/font.h"
/* Font information:
name: 04b-16b-10
@@ -16,7 +16,7 @@
*/
-namespace GUI {
+namespace Graphics {
/* Font character bitmap data. */
static const bitmap_t _font_bits[] = {
@@ -2597,4 +2597,4 @@ const Font g_sysfont = {
};
#endif
-} // End of namespace GUI
+} // End of namespace Graphics
diff --git a/gui/scummfont.cpp b/graphics/scummfont.cpp
index 263f7a50d3..e6df7e68ba 100644
--- a/gui/scummfont.cpp
+++ b/graphics/scummfont.cpp
@@ -19,9 +19,9 @@
*/
#include "stdafx.h"
-#include "gui/font.h"
+#include "graphics/font.h"
-namespace GUI {
+namespace Graphics {
#ifdef __PALM_OS__
static const byte *guifont;
@@ -92,14 +92,14 @@ void ScummFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 colo
const ScummFont g_scummfont;
-} // End of namespace GUI
+} // End of namespace Graphics
#ifdef __PALM_OS__
#include "scumm_globals.h"
_GINIT(NewGui)
#ifndef NEW_FONT_CODE
-_GSETPTR(GUI::guifont, GBVARS_GUIFONT_INDEX, byte, GBVARS_SCUMM)
+_GSETPTR(Graphics::guifont, GBVARS_GUIFONT_INDEX, byte, GBVARS_SCUMM)
#endif
_GEND
diff --git a/graphics/surface.h b/graphics/surface.h
new file mode 100644
index 0000000000..a45df31748
--- /dev/null
+++ b/graphics/surface.h
@@ -0,0 +1,46 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2004 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ */
+
+#ifndef GRAPHICS_SURFACE_H
+#define GRAPHICS_SURFACE_H
+
+#include "common/scummsys.h"
+
+namespace Graphics {
+
+
+/**
+ * An arbitrary graphics surface, which can be the target (or source) of blit
+ * operations, font rendering, etc.
+ */
+struct Surface {
+ void *pixels;
+ uint16 w;
+ uint16 h;
+ uint16 pitch;
+ uint8 bytesPerPixel;
+ Surface() : pixels(0), w(0), h(0), pitch(0), bytesPerPixel(0) {}
+};
+
+
+} // End of namespace Graphics
+
+
+#endif
diff --git a/gui/console.cpp b/gui/console.cpp
index 08780c17af..a97dec3d86 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -25,7 +25,7 @@
#include "base/engine.h"
#include "base/version.h"
-#include "gui/font.h"
+#include "graphics/font.h"
#define kCharWidth g_guifont.getMaxCharWidth()
diff --git a/gui/module.mk b/gui/module.mk
index 6a7b6b6805..95b4d15b99 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -17,14 +17,6 @@ MODULE_OBJS := \
gui/TabWidget.o \
gui/widget.o
-# TODO: Move the fonts to a separate dir?
-MODULE_OBJS += \
- gui/font.o \
- gui/scummfont.o \
- gui/newfont.o
-
-
-
MODULE_DIRS += \
gui
diff --git a/gui/newgui.h b/gui/newgui.h
index c54df2f203..19be0bbfb1 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -25,7 +25,7 @@
#include "common/singleton.h"
#include "common/str.h"
#include "common/system.h" // For events
-#include "gui/font.h"
+#include "graphics/font.h"
// Uncomment the following to enable the new font code:
//#define NEW_FONT_CODE
@@ -43,13 +43,19 @@ class Dialog;
// Height of a single text line
#ifdef NEW_FONT_CODE
-#define g_guifont g_sysfont
+#define g_guifont Graphics::g_sysfont
#else
-#define g_guifont g_scummfont
+#define g_guifont Graphics::g_scummfont
#endif
#define kLineHeight (g_guifont.getFontHeight() + 2)
+using Graphics::TextAlignment;
+using Graphics::kTextAlignCenter;
+using Graphics::kTextAlignLeft;
+using Graphics::kTextAlignRight;
+
+
// Extremly simple stack class, doesn't even do any error checking (for now)
class DialogStack {
protected:
@@ -84,7 +90,7 @@ public:
protected:
OSystem *_system;
- Surface _screen;
+ Graphics::Surface _screen;
int _screenPitch;
bool _needRedraw;
@@ -142,7 +148,7 @@ public:
void drawChar(byte c, int x, int y, OverlayColor color);
int getStringWidth(const String &str);
int getCharWidth(byte c);
- void drawString(const String &str, int x, int y, int w, OverlayColor color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true);
+ 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);
diff --git a/gui/widget.h b/gui/widget.h
index a435e418b8..964f2e10c2 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -23,7 +23,7 @@
#include "common/scummsys.h"
#include "common/str.h"
-#include "gui/font.h"
+#include "graphics/font.h"
#include "gui/object.h"
namespace GUI {
@@ -127,6 +127,7 @@ protected:
class StaticTextWidget : public Widget {
protected:
typedef Common::String String;
+ typedef Graphics::TextAlignment TextAlignment;
String _label;
TextAlignment _align;
diff --git a/sword1/animation.h b/sword1/animation.h
index 1c55bc4f07..1d9a2aecec 100644
--- a/sword1/animation.h
+++ b/sword1/animation.h
@@ -22,33 +22,7 @@
#ifndef ANIMATION_H
#define ANIMATION_H
-// Uncomment this if you are using libmpeg2 0.3.1.
-// #define USE_MPEG2_0_3_1
-
-#ifdef _MSC_VER
-typedef int8 int8_t;
-typedef int16 int16_t;
-typedef int32 int32_t;
-
-typedef uint8 uint8_t;
-typedef uint16 uint16_t;
-typedef uint32 uint32_t;
-#else
-#include <inttypes.h>
-#endif
-
-#ifdef USE_MPEG2
-extern "C" {
- #include <mpeg2dec/mpeg2.h>
-}
-
-#ifdef USE_MPEG2_0_3_1
-typedef int mpeg2_state_t;
-typedef sequence_t mpeg2_sequence_t;
-#define STATE_BUFFER -1
-#endif
-
-#endif
+#include "graphics/animation.h"
#include "sword1/screen.h"
#include "sword1/sound.h"
diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h
index ab88b869df..5d399c7c63 100644
--- a/sword2/driver/animation.h
+++ b/sword2/driver/animation.h
@@ -22,35 +22,10 @@
#ifndef ANIMATION_H
#define ANIMATION_H
-#include "sound/mixer.h"
-
-// Uncomment this if you are using libmpeg2 0.3.1.
-// #define USE_MPEG2_0_3_1
-
-#ifdef _MSC_VER
-typedef int8 int8_t;
-typedef signed short int16_t;
-typedef int32 int32_t;
-
-typedef uint8 uint8_t;
-typedef uint16 uint16_t;
-typedef uint32 uint32_t;
-#else
-#include <inttypes.h>
-#endif
+#include "graphics/animation.h"
-#ifdef USE_MPEG2
-extern "C" {
- #include <mpeg2dec/mpeg2.h>
-}
-
-#ifdef USE_MPEG2_0_3_1
-typedef int mpeg2_state_t;
-typedef sequence_t mpeg2_sequence_t;
-#define STATE_BUFFER -1
-#endif
+#include "sound/mixer.h"
-#endif
namespace Sword2 {