diff options
author | Eugene Sandulenko | 2017-02-07 20:08:49 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2017-02-07 20:08:49 +0100 |
commit | 355435e9a7bbcfcc0e4dc23e45dfce3b5337a1cd (patch) | |
tree | 4e5ac74a4ff353cf664e78671599e682a85521e8 | |
parent | a9fb3e3225dac382318f7c1ef09e7c61aeb2ac4c (diff) | |
download | scummvm-rg350-355435e9a7bbcfcc0e4dc23e45dfce3b5337a1cd.tar.gz scummvm-rg350-355435e9a7bbcfcc0e4dc23e45dfce3b5337a1cd.tar.bz2 scummvm-rg350-355435e9a7bbcfcc0e4dc23e45dfce3b5337a1cd.zip |
DIRECTOR: Move graphics-related code to graphics.cpp
-rw-r--r-- | engines/director/director.cpp | 28 | ||||
-rw-r--r-- | engines/director/director.h | 1 | ||||
-rw-r--r-- | engines/director/graphics.cpp | 148 | ||||
-rw-r--r-- | engines/director/score.cpp | 108 |
4 files changed, 149 insertions, 136 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 9417538f54..6456da164f 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -192,32 +192,4 @@ Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Commo return nameMap; } -void DirectorEngine::setPalette(byte *palette, uint16 count) { - _currentPalette = palette; - _currentPaletteLength = count; -} - -void DirectorEngine::testFonts() { - Common::String fontName("Helvetica"); - - Common::MacResManager *fontFile = new Common::MacResManager(); - if (!fontFile->open(fontName)) - error("Could not open %s as a resource fork", fontName.c_str()); - - Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D')); - if (fonds.size() > 0) { - for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) { - Common::SeekableReadStream *stream = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator); - Common::String name = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), *iterator); - - debug("Font: %s", name.c_str()); - - Graphics::MacFontFamily font; - font.load(*stream); - } - } - - delete fontFile; -} - } // End of namespace Director diff --git a/engines/director/director.h b/engines/director/director.h index 9277abf2e2..fee36da43c 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -60,6 +60,7 @@ enum { kDebugText = 1 << 4 }; +extern byte defaultPalette[768]; class DirectorEngine : public ::Engine { public: diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp index f980edee5c..76ff41788c 100644 --- a/engines/director/graphics.cpp +++ b/engines/director/graphics.cpp @@ -19,10 +19,72 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "common/events.h" +#include "common/macresman.h" +#include "common/system.h" +#include "engines/util.h" + +#include "graphics/palette.h" +#include "graphics/fonts/macfont.h" +#include "graphics/macgui/macfontmanager.h" +#include "graphics/macgui/macwindowmanager.h" + #include "director/director.h" namespace Director { +// Referred as extern +byte defaultPalette[768] = { + 0, 0, 0, 17, 17, 17, 34, 34, 34, 68, 68, 68, 85, 85, 85, 119, + 119, 119, 136, 136, 136, 170, 170, 170, 187, 187, 187, 221, 221, 221, 238, 238, + 238, 0, 0, 17, 0, 0, 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, + 0, 0, 136, 0, 0, 170, 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, + 17, 0, 0, 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, 0, 0, 136, + 0, 0, 170, 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, 17, 0, 0, + 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, 0, 0, 136, 0, 0, 170, + 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, 0, 0, 0, 51, 0, 0, + 102, 0, 0, 153, 0, 0, 204, 0, 0, 255, 0, 51, 0, 0, 51, 51, + 0, 51, 102, 0, 51, 153, 0, 51, 204, 0, 51, 255, 0, 102, 0, 0, + 102, 51, 0, 102, 102, 0, 102, 153, 0, 102, 204, 0, 102, 255, 0, 153, + 0, 0, 153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 204, 0, 153, 255, + 0, 204, 0, 0, 204, 51, 0, 204, 102, 0, 204, 153, 0, 204, 204, 0, + 204, 255, 0, 255, 0, 0, 255, 51, 0, 255, 102, 0, 255, 153, 0, 255, + 204, 0, 255, 255, 51, 0, 0, 51, 0, 51, 51, 0, 102, 51, 0, 153, + 51, 0, 204, 51, 0, 255, 51, 51, 0, 51, 51, 51, 51, 51, 102, 51, + 51, 153, 51, 51, 204, 51, 51, 255, 51, 102, 0, 51, 102, 51, 51, 102, + 102, 51, 102, 153, 51, 102, 204, 51, 102, 255, 51, 153, 0, 51, 153, 51, + 51, 153, 102, 51, 153, 153, 51, 153, 204, 51, 153, 255, 51, 204, 0, 51, + 204, 51, 51, 204, 102, 51, 204, 153, 51, 204, 204, 51, 204, 255, 51, 255, + 0, 51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 51, 255, 255, + 102, 0, 0, 102, 0, 51, 102, 0, 102, 102, 0, 153, 102, 0, 204, 102, + 0, 255, 102, 51, 0, 102, 51, 51, 102, 51, 102, 102, 51, 153, 102, 51, + 204, 102, 51, 255, 102, 102, 0, 102, 102, 51, 102, 102, 102, 102, 102, 153, + 102, 102, 204, 102, 102, 255, 102, 153, 0, 102, 153, 51, 102, 153, 102, 102, + 153, 153, 102, 153, 204, 102, 153, 255, 102, 204, 0, 102, 204, 51, 102, 204, + 102, 102, 204, 153, 102, 204, 204, 102, 204, 255, 102, 255, 0, 102, 255, 51, + 102, 255, 102, 102, 255, 153, 102, 255, 204, 102, 255, 255, 153, 0, 0, 153, + 0, 51, 153, 0, 102, 153, 0, 153, 153, 0, 204, 153, 0, 255, 153, 51, + 0, 153, 51, 51, 153, 51, 102, 153, 51, 153, 153, 51, 204, 153, 51, 255, + 153, 102, 0, 153, 102, 51, 153, 102, 102, 153, 102, 153, 153, 102, 204, 153, + 102, 255, 153, 153, 0, 153, 153, 51, 153, 153, 102, 153, 153, 153, 153, 153, + 204, 153, 153, 255, 153, 204, 0, 153, 204, 51, 153, 204, 102, 153, 204, 153, + 153, 204, 204, 153, 204, 255, 153, 255, 0, 153, 255, 51, 153, 255, 102, 153, + 255, 153, 153, 255, 204, 153, 255, 255, 204, 0, 0, 204, 0, 51, 204, 0, + 102, 204, 0, 153, 204, 0, 204, 204, 0, 255, 204, 51, 0, 204, 51, 51, + 204, 51, 102, 204, 51, 153, 204, 51, 204, 204, 51, 255, 204, 102, 0, 204, + 102, 51, 204, 102, 102, 204, 102, 153, 204, 102, 204, 204, 102, 255, 204, 153, + 0, 204, 153, 51, 204, 153, 102, 204, 153, 153, 204, 153, 204, 204, 153, 255, + 204, 204, 0, 204, 204, 51, 204, 204, 102, 204, 204, 153, 204, 204, 204, 204, + 204, 255, 204, 255, 0, 204, 255, 51, 204, 255, 102, 204, 255, 153, 204, 255, + 204, 204, 255, 255, 255, 0, 0, 255, 0, 51, 255, 0, 102, 255, 0, 153, + 255, 0, 204, 255, 0, 255, 255, 51, 0, 255, 51, 51, 255, 51, 102, 255, + 51, 153, 255, 51, 204, 255, 51, 255, 255, 102, 0, 255, 102, 51, 255, 102, + 102, 255, 102, 153, 255, 102, 204, 255, 102, 255, 255, 153, 0, 255, 153, 51, + 255, 153, 102, 255, 153, 153, 255, 153, 204, 255, 153, 255, 255, 204, 0, 255, + 204, 51, 255, 204, 102, 255, 204, 153, 255, 204, 204, 255, 204, 255, 255, 255, + 0, 255, 255, 51, 255, 255, 102, 255, 255, 153, 255, 255, 204, 255, 255, 255 }; + + static byte director3Patterns[][8] = { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, { 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0xFF, 0x77, 0xFF }, { 0x77, 0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF }, @@ -152,4 +214,90 @@ Graphics::MacPatterns &DirectorEngine::getPatterns() { return _director3QuickDrawPatterns; } +void DirectorEngine::setPalette(byte *palette, uint16 count) { + _currentPalette = palette; + _currentPaletteLength = count; +} + +void DirectorEngine::testFontScaling() { + int x = 10; + int y = 10; + int w = 640; + int h = 480; + + initGraphics(w, h, true); + _system->getPaletteManager()->setPalette(defaultPalette, 0, 256); + + Graphics::ManagedSurface surface; + + surface.create(w, h); + surface.clear(255); + + Graphics::MacFont origFont(Graphics::kMacFontNewYork, 18); + + const Graphics::MacFONTFont *font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(origFont); + + Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y + 200, 500); + + Graphics::MacFont bigFont(Graphics::kMacFontNewYork, 15); + + font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(bigFont); + + Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y + 50 + 200, 500); + + const char *text = "d"; + + for (int i = 9; i <= 20; i++) { + Graphics::MacFont macFont(Graphics::kMacFontNewYork, i); + + const Graphics::Font *font = _wm->_fontMan->getFont(macFont); + + int width = font->getStringWidth(text); + + Common::Rect bbox = font->getBoundingBox(text, x, y, w); + surface.frameRect(bbox, 15); + + font->drawString(&surface, text, x, y, width, 0); + + x += width + 1; + } + + g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, w, h); + + Common::Event event; + + while (true) { + if (g_system->getEventManager()->pollEvent(event)) + if (event.type == Common::EVENT_QUIT) + break; + + g_system->updateScreen(); + g_system->delayMillis(10); + } +} + +void DirectorEngine::testFonts() { + Common::String fontName("Helvetica"); + + Common::MacResManager *fontFile = new Common::MacResManager(); + if (!fontFile->open(fontName)) + error("Could not open %s as a resource fork", fontName.c_str()); + + Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D')); + if (fonds.size() > 0) { + for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) { + Common::SeekableReadStream *stream = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator); + Common::String name = fontFile->getResName(MKTAG('F', 'O', 'N', 'D'), *iterator); + + debug("Font: %s", name.c_str()); + + Graphics::MacFontFamily font; + font.load(*stream); + } + } + + delete fontFile; +} + + } diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 2a29234bbc..04371e392a 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -27,7 +27,6 @@ #include "engines/util.h" #include "graphics/font.h" -#include "graphics/fonts/macfont.h" #include "graphics/palette.h" #include "graphics/macgui/macfontmanager.h" #include "graphics/macgui/macwindowmanager.h" @@ -42,113 +41,6 @@ namespace Director { -static byte defaultPalette[768] = { - 0, 0, 0, 17, 17, 17, 34, 34, 34, 68, 68, 68, 85, 85, 85, 119, - 119, 119, 136, 136, 136, 170, 170, 170, 187, 187, 187, 221, 221, 221, 238, 238, - 238, 0, 0, 17, 0, 0, 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, - 0, 0, 136, 0, 0, 170, 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, - 17, 0, 0, 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, 0, 0, 136, - 0, 0, 170, 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, 17, 0, 0, - 34, 0, 0, 68, 0, 0, 85, 0, 0, 119, 0, 0, 136, 0, 0, 170, - 0, 0, 187, 0, 0, 221, 0, 0, 238, 0, 0, 0, 0, 51, 0, 0, - 102, 0, 0, 153, 0, 0, 204, 0, 0, 255, 0, 51, 0, 0, 51, 51, - 0, 51, 102, 0, 51, 153, 0, 51, 204, 0, 51, 255, 0, 102, 0, 0, - 102, 51, 0, 102, 102, 0, 102, 153, 0, 102, 204, 0, 102, 255, 0, 153, - 0, 0, 153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 204, 0, 153, 255, - 0, 204, 0, 0, 204, 51, 0, 204, 102, 0, 204, 153, 0, 204, 204, 0, - 204, 255, 0, 255, 0, 0, 255, 51, 0, 255, 102, 0, 255, 153, 0, 255, - 204, 0, 255, 255, 51, 0, 0, 51, 0, 51, 51, 0, 102, 51, 0, 153, - 51, 0, 204, 51, 0, 255, 51, 51, 0, 51, 51, 51, 51, 51, 102, 51, - 51, 153, 51, 51, 204, 51, 51, 255, 51, 102, 0, 51, 102, 51, 51, 102, - 102, 51, 102, 153, 51, 102, 204, 51, 102, 255, 51, 153, 0, 51, 153, 51, - 51, 153, 102, 51, 153, 153, 51, 153, 204, 51, 153, 255, 51, 204, 0, 51, - 204, 51, 51, 204, 102, 51, 204, 153, 51, 204, 204, 51, 204, 255, 51, 255, - 0, 51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 51, 255, 255, - 102, 0, 0, 102, 0, 51, 102, 0, 102, 102, 0, 153, 102, 0, 204, 102, - 0, 255, 102, 51, 0, 102, 51, 51, 102, 51, 102, 102, 51, 153, 102, 51, - 204, 102, 51, 255, 102, 102, 0, 102, 102, 51, 102, 102, 102, 102, 102, 153, - 102, 102, 204, 102, 102, 255, 102, 153, 0, 102, 153, 51, 102, 153, 102, 102, - 153, 153, 102, 153, 204, 102, 153, 255, 102, 204, 0, 102, 204, 51, 102, 204, - 102, 102, 204, 153, 102, 204, 204, 102, 204, 255, 102, 255, 0, 102, 255, 51, - 102, 255, 102, 102, 255, 153, 102, 255, 204, 102, 255, 255, 153, 0, 0, 153, - 0, 51, 153, 0, 102, 153, 0, 153, 153, 0, 204, 153, 0, 255, 153, 51, - 0, 153, 51, 51, 153, 51, 102, 153, 51, 153, 153, 51, 204, 153, 51, 255, - 153, 102, 0, 153, 102, 51, 153, 102, 102, 153, 102, 153, 153, 102, 204, 153, - 102, 255, 153, 153, 0, 153, 153, 51, 153, 153, 102, 153, 153, 153, 153, 153, - 204, 153, 153, 255, 153, 204, 0, 153, 204, 51, 153, 204, 102, 153, 204, 153, - 153, 204, 204, 153, 204, 255, 153, 255, 0, 153, 255, 51, 153, 255, 102, 153, - 255, 153, 153, 255, 204, 153, 255, 255, 204, 0, 0, 204, 0, 51, 204, 0, - 102, 204, 0, 153, 204, 0, 204, 204, 0, 255, 204, 51, 0, 204, 51, 51, - 204, 51, 102, 204, 51, 153, 204, 51, 204, 204, 51, 255, 204, 102, 0, 204, - 102, 51, 204, 102, 102, 204, 102, 153, 204, 102, 204, 204, 102, 255, 204, 153, - 0, 204, 153, 51, 204, 153, 102, 204, 153, 153, 204, 153, 204, 204, 153, 255, - 204, 204, 0, 204, 204, 51, 204, 204, 102, 204, 204, 153, 204, 204, 204, 204, - 204, 255, 204, 255, 0, 204, 255, 51, 204, 255, 102, 204, 255, 153, 204, 255, - 204, 204, 255, 255, 255, 0, 0, 255, 0, 51, 255, 0, 102, 255, 0, 153, - 255, 0, 204, 255, 0, 255, 255, 51, 0, 255, 51, 51, 255, 51, 102, 255, - 51, 153, 255, 51, 204, 255, 51, 255, 255, 102, 0, 255, 102, 51, 255, 102, - 102, 255, 102, 153, 255, 102, 204, 255, 102, 255, 255, 153, 0, 255, 153, 51, - 255, 153, 102, 255, 153, 153, 255, 153, 204, 255, 153, 255, 255, 204, 0, 255, - 204, 51, 255, 204, 102, 255, 204, 153, 255, 204, 204, 255, 204, 255, 255, 255, - 0, 255, 255, 51, 255, 255, 102, 255, 255, 153, 255, 255, 204, 255, 255, 255 }; - -void DirectorEngine::testFontScaling() { - int x = 10; - int y = 10; - int w = 640; - int h = 480; - - initGraphics(w, h, true); - g_system->getPaletteManager()->setPalette(defaultPalette, 0, 256); - - Graphics::ManagedSurface surface; - - surface.create(w, h); - surface.clear(255); - - Graphics::MacFont origFont(Graphics::kMacFontNewYork, 18); - - const Graphics::MacFONTFont *font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(origFont); - - Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y + 200, 500); - - Graphics::MacFont bigFont(Graphics::kMacFontNewYork, 15); - - font1 = (const Graphics::MacFONTFont *)_wm->_fontMan->getFont(bigFont); - - Graphics::MacFONTFont::testBlit(font1, &surface, 0, x, y + 50 + 200, 500); - - const char *text = "d"; - - for (int i = 9; i <= 20; i++) { - Graphics::MacFont macFont(Graphics::kMacFontNewYork, i); - - const Graphics::Font *font = _wm->_fontMan->getFont(macFont); - - int width = font->getStringWidth(text); - - Common::Rect bbox = font->getBoundingBox(text, x, y, w); - surface.frameRect(bbox, 15); - - font->drawString(&surface, text, x, y, width, 0); - - x += width + 1; - } - - g_system->copyRectToScreen(surface.getPixels(), surface.pitch, 0, 0, w, h); - - Common::Event event; - - while (true) { - if (g_system->getEventManager()->pollEvent(event)) - if (event.type == Common::EVENT_QUIT) - break; - - g_system->updateScreen(); - g_system->delayMillis(10); - } -} - Score::Score(DirectorEngine *vm, Archive *archive) { _vm = vm; _surface = new Graphics::ManagedSurface; |