예제 #1
0
void FrotzScreen::loadVersion6Fonts(Common::Archive *archive) {
	// Set the basic font properties
	MonoFontInfo &mi = g_conf->_monoInfo;
	PropFontInfo &pi = g_conf->_propInfo;
	mi._size = pi._size = 7;
	mi._aspect = pi._aspect = 1.0;
	pi._quotes = 0;
	pi._dashes = 0;
	pi._spaces = 0;
	pi._morePrompt = "[MORE]";
	pi._lineSeparation = 0;

	g_vm->_defaultForeground = 0;
	g_vm->_defaultBackground = (int)zcolor_Transparent;
	g_conf->_tMarginX = 3;

	for (uint idx = 0; idx < style_NUMSTYLES; ++idx) {
		g_conf->_tStyles[idx].bg = g_conf->_tStylesDefault[idx].bg = zcolor_Transparent;
		g_conf->_gStyles[idx].bg = g_conf->_gStylesDefault[idx].bg = zcolor_Transparent;
	}

	_fonts.resize(8);

	// Load up the 8x8 Infocom font
	Image::BitmapDecoder decoder;
	Common::File f;
	if (!f.open("infocom6x8.bmp", *archive))
		error("Could not load font");

	Common::Point fontSize(6, 8);
	decoder.loadStream(f);
	f.close();

	// Add normal fonts
	_fonts[MONOR] = new FixedWidthBitmapFont(*decoder.getSurface(), fontSize, 6, 8);
	_fonts[MONOB] = new FixedWidthBitmapFont(*decoder.getSurface(), fontSize, 6, 8);
	_fonts[PROPR] = new VariableWidthBitmapFont(*decoder.getSurface(), fontSize, 6, 8);
	_fonts[PROPB] = new VariableWidthBitmapFont(*decoder.getSurface(), fontSize, 6, 8);

	// Create a new version of the font with every character unlined for the emphasized fonts
	const Graphics::Surface &norm = *decoder.getSurface();
	Graphics::ManagedSurface emph(norm.w, norm.h);
	emph.blitFrom(norm);

	for (int y = 8 - 2; y < emph.h; y += 8) {
		byte *lineP = (byte *)emph.getBasePtr(0, y);
		Common::fill(lineP, lineP + emph.w, 0);
	}

	// Add them to the font list
	_fonts[MONOI] = new FixedWidthBitmapFont(emph, fontSize, 6, 8);
	_fonts[MONOZ] = new FixedWidthBitmapFont(emph, fontSize, 6, 8);
	_fonts[PROPI] = new VariableWidthBitmapFont(emph, fontSize, 6, 8);
	_fonts[PROPZ] = new VariableWidthBitmapFont(emph, fontSize, 6, 8);
}
예제 #2
0
void splashScreen() {
	Common::MemoryReadStream stream(logo_data, ARRAYSIZE(logo_data));

	Image::BitmapDecoder bitmap;

	if (!bitmap.loadStream(stream)) {
		warning("Error loading logo file");
		return;
	}

	g_system->showOverlay();

	// Fill with blue - ResidualVM theme
	Graphics::Surface screen;
	screen.create(g_system->getOverlayWidth(), g_system->getOverlayHeight(), g_system->getOverlayFormat());
	screen.fillRect(Common::Rect(screen.w, screen.h), screen.format.ARGBToColor(0xff, 0x1e, 0x6f, 0x95)); // ResidualVM theme

	// Load logo
	Graphics::Surface *logo = bitmap.getSurface()->convertTo(g_system->getOverlayFormat(), bitmap.getPalette());
	int lx = MAX((g_system->getOverlayWidth() - logo->w) / 2, 0);
	int ly = MAX((g_system->getOverlayHeight() - logo->h) / 2, 0);

	// Print version information
	const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kConsoleFont);
	int w = font->getStringWidth(gScummVMVersionDate);
	int x = g_system->getOverlayWidth() - w - 5; // lx + logo->w - w + 5;
	int y = g_system->getOverlayHeight() - font->getFontHeight() - 5; //ly + logo->h + 5;
	font->drawString(&screen, gScummVMVersionDate, x, y, w, screen.format.ARGBToColor(0xff, 0, 0, 0));

	g_system->copyRectToOverlay(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h);
	screen.free();

	// Draw logo
	int lw = MIN<uint16>(logo->w, g_system->getOverlayWidth() - lx);
	int lh = MIN<uint16>(logo->h, g_system->getOverlayHeight() - ly);

	g_system->copyRectToOverlay(logo->getPixels(), logo->pitch, lx, ly, lw, lh);
	logo->free();
	delete logo;

	g_system->updateScreen();

	// Delay 0.6 secs
	uint time0 = g_system->getMillis();
	Common::Event event;
	while (time0 + 600 > g_system->getMillis()) {
		(void)g_system->getEventManager()->pollEvent(event);
		g_system->delayMillis(10);
	}
	g_system->hideOverlay();

	splash = true;
}
예제 #3
0
void Cursor::loadAvailableCursors() {
	assert(_textures.empty());

	// Load available cursors
	for (uint i = 0; i < ARRAYSIZE(availableCursors); i++) {
		// Check if a cursor sharing the same texture has already been loaded
		if (_textures.contains(availableCursors[i].nodeID)) continue;

		// Load the cursor bitmap
		const DirectorySubEntry *cursorDesc = _vm->getFileDescription("GLOB", availableCursors[i].nodeID, 0, DirectorySubEntry::kRawData);
		if (!cursorDesc)
			error("Cursor %d does not exist", availableCursors[i].nodeID);

		Common::MemoryReadStream *bmpStream = cursorDesc->getData();

		Image::BitmapDecoder bitmapDecoder;
		if (!bitmapDecoder.loadStream(*bmpStream))
			error("Could not decode Myst III bitmap");
		const Graphics::Surface *surfaceBGRA = bitmapDecoder.getSurface();
		Graphics::Surface *surfaceRGBA = surfaceBGRA->convertTo(Texture::getRGBAPixelFormat());

		delete bmpStream;

		// Apply the colorkey for transparency
		for (uint y = 0; y < surfaceRGBA->h; y++) {
			byte *pixels = (byte *)(surfaceRGBA->getBasePtr(0, y));
			for (uint x = 0; x < surfaceRGBA->w; x++) {
				byte *r = pixels + 0;
				byte *g = pixels + 1;
				byte *b = pixels + 2;
				byte *a = pixels + 3;

				if (*r == 0 && *g == 0xFF && *b == 0 && *a == 0xFF) {
					*g = 0;
					*a = 0;
				}

				pixels += 4;
			}
		}

		// Create and store the texture
		_textures.setVal(availableCursors[i].nodeID, _vm->_gfx->createTexture(surfaceRGBA));

		surfaceRGBA->free();
		delete surfaceRGBA;
	}
}
예제 #4
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);

		Image::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());

		for (int j = 0; j < _arrayBmp[i * 2]->h; j++) {
			byte *src = (byte *)_arrayBmp[i * 2]->getBasePtr(0, j);
			byte *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);
	}
}
예제 #5
0
void FrotzScreen::loadExtraFonts(Common::Archive *archive) {
	Image::BitmapDecoder decoder;
	Common::File f;
	if (!f.open("infocom_graphics.bmp", *archive))
		error("Could not load font");

	Common::Point fontSize(_fonts[0]->getMaxCharWidth(), _fonts[0]->getFontHeight());
	decoder.loadStream(f);
	_fonts.push_back(new FixedWidthBitmapFont(*decoder.getSurface(), fontSize));
	f.close();

	// Add Runic font. It provides cleaner versions of the runic characters in the
	// character graphics font
	if (!f.open("NotoSansRunic-Regular.ttf", *archive))
		error("Could not load font");

	_fonts.push_back(Graphics::loadTTFFont(f, g_conf->_propInfo._size, Graphics::kTTFSizeModeCharacter));
	f.close();
}
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);
		Image::BitmapDecoder bmpDecoder;
		if (bmpDecoder.loadStream(thumbStream)) {
			const Graphics::Surface *bmpSurface = bmpDecoder.getSurface();
			Graphics::TransparentSurface *scaleableSurface = new Graphics::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);
}
예제 #7
0
void Cursor::loadAvailableCursors() {
	assert(_textures.empty());

	// Load available cursors
	for (uint i = 0; i < ARRAYSIZE(availableCursors); i++) {
		// Check if a cursor sharing the same texture has already been loaded
		if (_textures.contains(availableCursors[i].nodeID)) continue;

		// Load the cursor bitmap
		const DirectorySubEntry *cursorDesc = _vm->getFileDescription("GLOB", availableCursors[i].nodeID, 0, DirectorySubEntry::kRawData);
		if (!cursorDesc)
			error("Cursor %d does not exist", availableCursors[i].nodeID);

		Common::MemoryReadStream *bmpStream = cursorDesc->getData();

		Image::BitmapDecoder bitmapDecoder;
		if (!bitmapDecoder.loadStream(*bmpStream))
			error("Could not decode Myst III bitmap");
		const Graphics::Surface *surfaceBGRA = bitmapDecoder.getSurface();
		Graphics::Surface *surfaceRGBA = surfaceBGRA->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));

		delete bmpStream;

		// Apply the colorkey for transparency
		for (uint u = 0; u < surfaceRGBA->w; u++) {
			for (uint v = 0; v < surfaceRGBA->h; v++) {
				uint32 *pixel = (uint32*)(surfaceRGBA->getBasePtr(u, v));
				if (*pixel == 0xFF00FF00)
					*pixel = 0x0000FF00;

			}
		}

		// Create and store the texture
		_textures.setVal(availableCursors[i].nodeID, _vm->_gfx->createTexture(surfaceRGBA));

		surfaceRGBA->free();
		delete surfaceRGBA;
	}
}