void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
	Common::String filename = getFilenameForSlot(slot);
	debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot);
	if (DID_FAIL(readHeader(filename))) {
		warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str());
		return;
	}
	desc.setSaveSlot(slot);
	desc.setDescription(_savedDescription);
	desc.setDeletableFlag(true);
	desc.setWriteProtectedFlag(false);

	if (_thumbnailDataSize > 0) {
		Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize);
		Graphics::BitmapDecoder bmpDecoder;
		if (bmpDecoder.loadStream(thumbStream)) {
			Graphics::Surface *surf = NULL;
			surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat());
			TransparentSurface *scaleableSurface = new TransparentSurface(*surf, false);
			Graphics::Surface *scaled = scaleableSurface->scale(kThumbnailWidth, kThumbnailHeight2);
			desc.setThumbnail(scaled);
			delete scaleableSurface;
			delete surf;
		}
	}

	desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday);
	desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min);
	desc.setPlayTime(0);
}
bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) {
	assert(!_mode->resolution.empty());

	String res = node->values["resolution"];

	if (res != _mode->resolution) {
		node->ignore = true;
		return true;
	}

	_mode->bitmapName = node->values["bitmap"];

	SeekableReadStream *file = _keyboard->_fileArchive->createReadStreamForMember(_mode->bitmapName);
	if (!file)
		return parserError("Bitmap '" + _mode->bitmapName + "' not found");

	const Graphics::PixelFormat format = g_system->getOverlayFormat();

	{
		Graphics::BitmapDecoder bmp;
		if (!bmp.loadStream(*file))
			return parserError("Error loading bitmap '" + _mode->bitmapName + "'");

		_mode->image = bmp.getSurface()->convertTo(format);
	}

	delete file;

	int r, g, b;
	if (node->values.contains("transparent_color")) {
		if (!parseIntegerKey(node->values["transparent_color"], 3, &r, &g, &b))
			return parserError("Could not parse color value");
	} else {
		// default to purple
		r = 255;
		g = 0;
		b = 255;
	}
	_mode->transparentColor = format.RGBToColor(r, g, b);

	if (node->values.contains("display_font_color")) {
		if (!parseIntegerKey(node->values["display_font_color"], 3, &r, &g, &b))
			return parserError("Could not parse color value");
	} else {
		r = g = b = 0; // default to black
	}
	_mode->displayFontColor = format.RGBToColor(r, g, b);

	_layoutParsed = true;

	return true;
}
Exemple #3
0
void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
	_arraySize = in.readUint16BE();

	delete _arrayBmp;
	_arrayBmp = new Graphics::Surface *[_arraySize * 2];
	for (int i = 0; i < _arraySize; i++) {
		uint16 bmpSize = in.readUint16BE();
		uint32 filPos = in.pos();
		Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize);

		Graphics::BitmapDecoder bitmapDecoder;
		if (!bitmapDecoder.loadStream(stream))
			error("TopMenu::loadBmpArr(): Could not load bitmap");

		const Graphics::Surface *bitmapSrc = bitmapDecoder.getSurface();
		if (bitmapSrc->format.bytesPerPixel == 1)
			error("TopMenu::loadBmpArr(): Unhandled paletted image");

		_arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat());
		_arrayBmp[i * 2 + 1] = new Graphics::Surface();
		_arrayBmp[i * 2 + 1]->create(_arrayBmp[i * 2]->w * 2, _arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat());
		byte *src = (byte *)_arrayBmp[i * 2]->getPixels();
		byte *dst = (byte *)_arrayBmp[i * 2 + 1]->getPixels();

		for (int j = 0; j < _arrayBmp[i * 2]->h; j++) {
			src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j);
			dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
			for (int k = _arrayBmp[i * 2]->w; k > 0; k--) {
				for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
					*dst++ = *src++;
				}
				src -= _arrayBmp[i * 2]->format.bytesPerPixel;

				for (int m = _arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) {
					*dst++ = *src++;
				}
			}
			src = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2);
			dst = (byte *)_arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2 + 1);
			for (int k = _arrayBmp[i * 2 + 1]->pitch; k > 0; k--) {
				*dst++ = *src++;
			}
		}

		in.seek(filPos + bmpSize);
	}
}
Exemple #4
0
void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
    Common::String filename = getFilenameForSlot(slot);
    debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot);
    if (DID_FAIL(readHeader(filename))) {
        debugC(kWintermuteDebugSaveGame, "getSavedDesc(%d) - Failed for %s", slot, filename.c_str());
        return;
    }
    desc.setSaveSlot(slot);
    desc.setDescription(_savedDescription);
    desc.setDeletableFlag(true);
    desc.setWriteProtectedFlag(false);

    int thumbSize = 0;
    byte *thumbData = nullptr;
    if (_scummVMThumbSize > 0) {
        thumbSize = _scummVMThumbSize;
        thumbData = _scummVMThumbnailData;
    } else if (_thumbnailDataSize > 0) {
        thumbSize = _thumbnailDataSize;
        thumbData = _thumbnailData;
    }

    if (thumbSize > 0) {
        Common::MemoryReadStream thumbStream(thumbData, thumbSize, DisposeAfterUse::NO);
        Graphics::BitmapDecoder bmpDecoder;
        if (bmpDecoder.loadStream(thumbStream)) {
            const Graphics::Surface *bmpSurface = bmpDecoder.getSurface();
            TransparentSurface *scaleableSurface = new TransparentSurface(*bmpSurface, false);
            Graphics::Surface *scaled = scaleableSurface->scale(kThumbnailWidth, kThumbnailHeight2);
            Graphics::Surface *thumb = scaled->convertTo(g_system->getOverlayFormat());
            desc.setThumbnail(thumb);
            delete scaleableSurface;
            scaled->free();
            delete scaled;
        }
    }

    desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday);
    desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min);
    desc.setPlayTime(0);
}