CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), _cursorIsPushed(false), _item(0), _lastitem(0), _currentCursor(CursorIndex_Idle) { for (int i = 0; i < NUM_CURSORS; i++) { if (_engine->getGameId() == GID_NEMESIS) { Common::String name; if (i == 1) { // Cursors "arrowa.zcr" and "arrowb.zcr" are missing _cursors[i][0] = _cursors[i][1] = ZorkCursor(); continue; } name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor char buffer[25]; memset(buffer, 0, 25); strncpy(buffer, _zgiCursorFileNames[i], 24); buffer[3] += 2; _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor } } }
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), _cursorIsPushed(false) { // WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly if (_engine->getGameId() == GID_NEMESIS) { Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX])); _idleCursor = ZorkCursor(name); } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]); } }
void CursorManager::setItemID(int id) { if (id != _item) { if (id) { Common::String file; if (_engine->getGameId() == GID_NEMESIS) { file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a'); _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b'); _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a'); _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b'); _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id); _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id); _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id); _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id); _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file); } else return; } _item = id; changeCursor(CursorIndex_Idle); } }
void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) { if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed) return; if (_cursorIsPushed != pushed) _cursorIsPushed = pushed; if (cursorName == "idle" && !pushed) { CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat); return; } for (int i = 0; i < NUM_CURSORS; ++i) { if (_engine->getGameId() == GID_NEMESIS) { if (cursorName.equals(_cursorNames[i])) { _currentCursor = cursorName; // ZNem uses a/b at the end of the file to signify not pushed/pushed respectively Common::String pushedFlag = pushed ? "b" : "a"; Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag.c_str()); changeCursor(ZorkCursor(name)); return; } } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { if (cursorName.equals(_cursorNames[i])) { _currentCursor = cursorName; if (!pushed) { changeCursor(ZorkCursor(_zgiCursorFileNames[i])); } else { // ZGI flips not pushed/pushed between a/c and b/d // It flips the 4th character of the name char buffer[25]; strcpy(buffer, _zgiCursorFileNames[i]); buffer[3] += 2; changeCursor(ZorkCursor(buffer)); } return; } } } // If we get here, something went wrong warning("No cursor found for identifier %s", cursorName.c_str()); }
CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), _cursorIsPushed(false), _item(0), _lastitem(0) { for (int i = 0; i < NUM_CURSORS; i++) { if (_engine->getGameId() == GID_NEMESIS) { Common::String name; name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor char buffer[25]; strcpy(buffer, _zgiCursorFileNames[i]); buffer[3] += 2; _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor } } }