Unified
Split
Showing
with
193 additions
and 405 deletions.
- +4 −0 engines/zvision/core/menu.cpp
- +6 −5 engines/zvision/file/search_manager.cpp
- +2 −1 engines/zvision/file/zfs_archive.cpp
- +1 −1 engines/zvision/file/zfs_archive.h
- +4 −2 engines/zvision/graphics/cursors/cursor_manager.cpp
- +3 −0 engines/zvision/graphics/render_table.cpp
- +0 −76 engines/zvision/graphics/truetype_font.cpp
- +0 −39 engines/zvision/graphics/truetype_font.h
- +98 −7 engines/zvision/scripting/actions.cpp
- +0 −5 engines/zvision/scripting/actions.h
- +3 −1 engines/zvision/scripting/controls/input_control.cpp
- +4 −1 engines/zvision/scripting/controls/lever_control.cpp
- +1 −1 engines/zvision/scripting/controls/paint_control.cpp
- +1 −0 engines/zvision/scripting/controls/push_toggle_control.cpp
- +4 −3 engines/zvision/scripting/controls/save_control.cpp
- +4 −2 engines/zvision/scripting/controls/slot_control.cpp
- +1 −1 engines/zvision/scripting/puzzle.h
- +1 −1 engines/zvision/scripting/scr_file_handling.cpp
- +1 −1 engines/zvision/scripting/script_manager.cpp
- +27 −18 engines/zvision/scripting/sidefx/music_node.cpp
- +1 −2 engines/zvision/scripting/sidefx/music_node.h
- +2 −0 engines/zvision/scripting/sidefx/timer_node.cpp
- +3 −1 engines/zvision/sound/midi.cpp
- +14 −8 engines/zvision/sound/zork_raw.cpp
- +2 −200 engines/zvision/text/string_manager.cpp
- +0 −25 engines/zvision/text/string_manager.h
- +0 −4 engines/zvision/text/text.h
- +6 −0 engines/zvision/zvision.cpp
| @@ -58,6 +58,8 @@ MenuZGI::MenuZGI(ZVision *engine) : | ||
| scrollPos[1] = 0.0; | ||
| scrollPos[2] = 0.0; | ||
| mouseOnItem = -1; | ||
| redraw = false; | ||
| clean = false; | ||
|
|
||
| char buf[24]; | ||
| for (int i = 1; i < 4; i++) { | ||
| @@ -557,6 +559,8 @@ MenuNemesis::MenuNemesis(ZVision *engine) : | ||
| scrolled = false; | ||
| scrollPos = 0.0; | ||
| mouseOnItem = -1; | ||
| redraw = false; | ||
| delay = 0; | ||
|
|
||
| char buf[24]; | ||
| for (int i = 0; i < 4; i++) | ||
| @@ -265,13 +265,14 @@ void SearchManager::addDir(const Common::String &name) { | ||
|
|
||
| void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const Common::FSNode &fsNode, int depth) { | ||
| Common::FSList fsList; | ||
| fsNode.getChildren(fsList); | ||
| if ( fsNode.getChildren(fsList) ) { | ||
|
|
||
| _list.push_back(fsNode.getPath()); | ||
| _list.push_back(fsNode.getPath()); | ||
|
|
||
| if (depth > 1) | ||
| for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) | ||
| listDirRecursive(_list, *it, depth - 1); | ||
| if (depth > 1) | ||
| for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) | ||
| listDirRecursive(_list, *it, depth - 1); | ||
| } | ||
| } | ||
|
|
||
| } // End of namespace ZVision | ||
| @@ -31,6 +31,7 @@ namespace ZVision { | ||
|
|
||
| ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { | ||
| Common::File zfsFile; | ||
| memset(&_header, 0, sizeof(_header)); | ||
|
|
||
| if (!zfsFile.open(_fileName)) { | ||
| warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); | ||
| @@ -140,7 +141,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common:: | ||
| byte *buffer = (byte *)malloc(entryHeader->size); | ||
| zfsArchive.read(buffer, entryHeader->size); | ||
| // Decrypt the data in place | ||
| if (_header.xorKey != 0) | ||
| if (_header.xorKey[0] + _header.xorKey[1] + _header.xorKey[2] + _header.xorKey[3] != 0) | ||
| unXor(buffer, entryHeader->size, _header.xorKey); | ||
|
|
||
| return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); | ||
| @@ -39,7 +39,7 @@ struct ZfsHeader { | ||
| uint32 maxNameLength; | ||
| uint32 filesPerBlock; | ||
| uint32 fileCount; | ||
| byte xorKey[4]; | ||
| uint8 xorKey[4]; | ||
| uint32 fileSectionOffset; | ||
| }; | ||
|
|
||
| @@ -50,7 +50,8 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel | ||
| _pixelFormat(pixelFormat), | ||
| _cursorIsPushed(false), | ||
| _item(0), | ||
| _lastitem(0) { | ||
| _lastitem(0), | ||
| _currentCursor(CursorIndex_Idle) { | ||
| for (int i = 0; i < NUM_CURSORS; i++) { | ||
| if (_engine->getGameId() == GID_NEMESIS) { | ||
| Common::String name; | ||
| @@ -61,7 +62,8 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel | ||
| } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { | ||
| _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor | ||
| char buffer[25]; | ||
| strcpy(buffer, _zgiCursorFileNames[i]); | ||
| memset(buffer, 0, 25); | ||
| strncpy(buffer, _zgiCursorFileNames[i], 24); | ||
| buffer[3] += 2; | ||
| _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor | ||
| } | ||
| @@ -34,6 +34,9 @@ RenderTable::RenderTable(uint numColumns, uint numRows) | ||
| assert(numRows != 0 && numColumns != 0); | ||
|
|
||
| _internalBuffer = new Common::Point[numRows * numColumns]; | ||
|
|
||
| memset(&_panoramaOptions, 0, sizeof(_panoramaOptions)); | ||
| memset(&_tiltOptions, 0, sizeof(_tiltOptions)); | ||
| } | ||
|
|
||
| RenderTable::~RenderTable() { | ||
| @@ -36,82 +36,6 @@ | ||
|
|
||
| namespace ZVision { | ||
|
|
||
| TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) | ||
| : _engine(engine), | ||
| _fontHeight(fontHeight), | ||
| _font(0), | ||
| _lineHeight(0), | ||
| _maxCharWidth(0), | ||
| _maxCharHeight(0) { | ||
| } | ||
|
|
||
| TruetypeFont::~TruetypeFont(void) { | ||
| delete _font; | ||
| } | ||
|
|
||
| bool TruetypeFont::loadFile(const Common::String &filename) { | ||
| Common::File file; | ||
|
|
||
| bool fileOpened = false; | ||
| if (!Common::File::exists(filename)) { | ||
| debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str()); | ||
| fileOpened = file.open("arial.ttf"); | ||
| } else { | ||
| fileOpened = file.open(filename); | ||
| } | ||
|
|
||
| if (!fileOpened) { | ||
| debug("TTF file could not be opened"); | ||
| return false; | ||
| } | ||
|
|
||
| _font = Graphics::loadTTFFont(file, _fontHeight); | ||
| _lineHeight = _font->getFontHeight(); | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) { | ||
| if (text.equals("")) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| Graphics::Surface *surface = new Graphics::Surface(); | ||
|
|
||
| if (!wrap) { | ||
| int width = MIN(_font->getStringWidth(text), maxWidth); | ||
| surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); | ||
| // TODO: Add better alpha support by getting the pixels from the backbuffer. | ||
| // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background. | ||
| surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); | ||
|
|
||
| _font->drawString(surface, text, 0, 0, maxWidth, textColor, align); | ||
| return surface; | ||
| } | ||
|
|
||
| Common::Array<Common::String> lines; | ||
| _font->wordWrapText(text, maxWidth, lines); | ||
|
|
||
| while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) { | ||
| lines.pop_back(); | ||
| } | ||
| if (lines.size() == 0) { | ||
| delete surface; | ||
| return nullptr; | ||
| } | ||
|
|
||
| surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); | ||
| surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); | ||
|
|
||
| int heightOffset = 0; | ||
| for (Common::Array<Common::String>::iterator it = lines.begin(); it != lines.end(); it++) { | ||
| _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align); | ||
| heightOffset += _lineHeight; | ||
| } | ||
|
|
||
| return surface; | ||
| } | ||
|
|
||
| StyledTTFont::StyledTTFont(ZVision *engine) { | ||
| _engine = engine; | ||
| _style = 0; | ||
| @@ -36,45 +36,6 @@ namespace ZVision { | ||
|
|
||
| class ZVision; | ||
|
|
||
| class TruetypeFont { | ||
| public: | ||
| TruetypeFont(ZVision *engine, int32 fontHeight); | ||
| ~TruetypeFont(); | ||
|
|
||
| private: | ||
| ZVision *_engine; | ||
| Graphics::Font *_font; | ||
| int _lineHeight; | ||
|
|
||
| size_t _maxCharWidth; | ||
| size_t _maxCharHeight; | ||
|
|
||
| public: | ||
| int32 _fontHeight; | ||
|
|
||
| public: | ||
| /** | ||
| * Loads a .ttf file into memory. This must be called | ||
| * before any calls to drawTextToSurface | ||
| * | ||
| * @param filename The file name of the .ttf file to load | ||
| */ | ||
| bool loadFile(const Common::String &filename); | ||
| /** | ||
| * Renders the supplied text to a Surface using 0x0 as the | ||
| * background color. | ||
| * | ||
| * @param text The to render | ||
| * @param textColor The color to render the text with | ||
| * @param maxWidth The max width the text should take up. | ||
| * @param maxHeight The max height the text should take up. | ||
| * @param align The alignment of the text within the bounds of maxWidth | ||
| * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit | ||
| * @return A Surface containing the rendered text | ||
| */ | ||
| Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap); | ||
| }; | ||
|
|
||
| // Styled TTF | ||
| class StyledTTFont { | ||
| public: | ||
Oops, something went wrong.