Пример #1
0
int MenuSystem::run() {

	//debug("MenuSystem::run()");

	_background = new Graphics::Surface();
	_background->create(640, 400, Graphics::PixelFormat::createFormatCLUT8());

	// Save original background
	Graphics::Surface backgroundOrig;
	backgroundOrig.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
	memcpy(backgroundOrig.getBasePtr(0,0), _vm->_screen->_frontScreen, 640 * 400);

	_currMenuID = kMenuIdNone;
	_newMenuID = kMenuIdMain;
	_currItemID = kItemIdNone;
	_editingDescription = false;
	_cfgText = true;
	_cfgVoices = true;
	_cfgMasterVolume = 10;
	_cfgVoicesVolume = 10;
	_cfgMusicVolume = 10;
	_cfgSoundFXVolume = 10;
	_cfgBackgroundVolume = 10;
	_running = true;    	
	_top = 30 - _vm->_guiHeight / 2;
	_needRedraw = false;

	// TODO: buildColorTransTable2
	_vm->_palette->buildColorTransTable(0, 16, 7);

	_vm->_screen->_renderQueue->clear();
	// Draw the menu background and frame
	_vm->_screen->blastSprite(0x140 + _vm->_cameraX, 0x175 + _vm->_cameraY, 0, 1, 0x4000);
	shadeRect(60, 39, 520, 246, 30, 94);

	memcpy(_background->pixels, _vm->_screen->_frontScreen, 640 * 400);

	while (_running) {
		update();
		_vm->_system->updateScreen();
	}
	
	// Restore original background
	memcpy(_vm->_screen->_frontScreen, backgroundOrig.getBasePtr(0,0), 640 * 400);
	_vm->_system->copyRectToScreen((const byte *)_vm->_screen->_frontScreen, 640, 0, 0, 640, 400);
	_vm->_system->updateScreen();

	// Cleanup
	backgroundOrig.free();
	_background->free();
	delete _background;

	return 0;	
}
Пример #2
0
int MenuSystem::run(MenuID menuId) {
	_background = new Graphics::Surface();
	_background->create(640, 400, Graphics::PixelFormat::createFormatCLUT8());

	// Save original background
	Graphics::Surface backgroundOrig;
	backgroundOrig.create(640, 400, Graphics::PixelFormat::createFormatCLUT8());
	memcpy(backgroundOrig.getBasePtr(0,0), _vm->_screen->_frontScreen, 640 * 400);

	_currMenuID = kMenuIdNone;
	_newMenuID = menuId;
	_currItemID = kItemIdNone;
	_editingDescription = false;

	_running = true;
	_top = 30 - _vm->_guiHeight / 2;

	_needRedraw = false;

	_vm->_palette->buildColorTransTable(0, 16, 7);

	_vm->_screen->_renderQueue->clear();
	// Draw the menu background and frame
	_vm->_screen->blastSprite(0x140 + _vm->_cameraX, 0x175 + _vm->_cameraY, 0, 1, 0x4000);
	shadeRect(60, 39, 520, 247, 225, 229);

	memcpy(_background->getPixels(), _vm->_screen->_frontScreen, 640 * 400);

	while (_running) {
		update();
		_vm->_system->updateScreen();
	}

	// Restore original background
	memcpy(_vm->_screen->_frontScreen, backgroundOrig.getBasePtr(0,0), 640 * 400);
	_vm->_system->copyRectToScreen(_vm->_screen->_frontScreen, 640, 0, 0, 640, 400);
	_vm->_system->updateScreen();

	// Cleanup
	backgroundOrig.free();
	_background->free();
	delete _background;

	return 0;
}
Пример #3
0
void MenuSystem::initMenu(MenuID menuID) {
	_items.clear();

	memcpy(_vm->_screen->_frontScreen, _background->getPixels(), 640 * 400);

	switch (menuID) {
	case kMenuIdMain:
		drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrWhatCanIDoForYou));
		addClickTextItem(kItemIdLoad, 0, 116, 320, 0, _vm->getSysString(kStrLoad), 253, 255);
		addClickTextItem(kItemIdSave, 0, 136, 320, 0, _vm->getSysString(kStrSave), 253, 255);
		addClickTextItem(kItemIdToggleText, 0, 166, 320, 0, _vm->getSysString(_vm->_cfgText ? kStrTextOn : kStrTextOff), 253, 255);
		addClickTextItem(kItemIdToggleVoices, 0, 186, 320, 0, _vm->getSysString(_vm->_cfgVoices ? kStrVoicesOn : kStrVoicesOff), 253, 255);
		addClickTextItem(kItemIdVolumesMenu, 0, 216, 320, 0, _vm->getSysString(kStrVolume), 253, 255);
		addClickTextItem(kItemIdPlay, 0, 246, 320, 0, _vm->getSysString(kStrPlay), 253, 255);
		addClickTextItem(kItemIdQuit, 0, 276, 320, 0, _vm->getSysString(kStrQuit), 253, 255);
		break;
	case kMenuIdLoad:
		if (ConfMan.getBool("originalsaveload")) {
			shadeRect(80, 92, 440, 141, 226, 225);
			drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrLoadGame));
			addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255);
			addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255);
			addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255);
			for (int i = 1; i <= 7; i++) {
				Common::String saveDesc = Common::String::format("SAVEGAME %d", i);
				addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234);
			}
			loadSavegamesList();
			setSavegameCaptions(true);
		} else {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
			int slot = dialog->runModalWithCurrentTarget();
			delete dialog;

			if (slot >= 0)
				_vm->requestLoadgame(slot);

			_running = false;
		}
		break;
	case kMenuIdSave:
		if (ConfMan.getBool("originalsaveload")) {
			shadeRect(80, 92, 440, 141, 226, 225);
			drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrSaveGame));
			addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255);
			addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255);
			addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255);
			for (int i = 1; i <= 7; i++) {
				Common::String saveDesc = Common::String::format("SAVEGAME %d", i);
				addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234);
			}
			int newSlotNum = loadSavegamesList() + 1;
			_savegames.push_back(SavegameItem(newSlotNum, Common::String::format("GAME %04d", _savegames.size())));
			setSavegameCaptions(true);
		} else {
			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
			int slot = dialog->runModalWithCurrentTarget();
			Common::String desc = dialog->getResultString();
			if (desc.empty()) {
				// Create our own description for the saved game, the user didn't enter one
				desc = dialog->createDefaultSaveDescription(slot);
			}

			if (slot >= 0)
				_vm->requestSavegame(slot, desc);

			_running = false;
		}
		break;
	case kMenuIdVolumes:
		drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrAdjustVolume));
		drawString(0, 131, 200, 0, 246, _vm->getSysString(kStrMaster));
		drawString(0, 156, 200, 0, 244, _vm->getSysString(kStrVoices));
		drawString(0, 181, 200, 0, 244, _vm->getSysString(kStrMusic));
		drawString(0, 206, 200, 0, 244, _vm->getSysString(kStrSoundFx));
		drawString(0, 231, 200, 0, 244, _vm->getSysString(kStrBackground));
		addClickTextItem(kItemIdDone, 0, 276, 200, 0, _vm->getSysString(kStrDone), 253, 255);
		addClickTextItem(kItemIdCancel, 0, 276, 440, 0, _vm->getSysString(kStrCancel), 253, 255);
		addClickTextItem(kItemIdMasterDown, 0, 131 + 25 * 0, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdVoicesDown, 0, 131 + 25 * 1, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdMusicDown, 0, 131 + 25 * 2, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdSoundFXDown, 0, 131 + 25 * 3, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdBackgroundDown, 0, 131 + 25 * 4, 348, 1, "[", 243, 246);
		addClickTextItem(kItemIdMasterUp, 0, 131 + 25 * 0, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdVoicesUp, 0, 131 + 25 * 1, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdMusicUp, 0, 131 + 25 * 2, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdSoundFXUp, 0, 131 + 25 * 3, 372, 1, "]", 243, 246);
		addClickTextItem(kItemIdBackgroundUp, 0, 131 + 25 * 4, 372, 1, "]", 243, 246);
		drawVolumeBar(kItemIdMaster);
		drawVolumeBar(kItemIdVoices);
		drawVolumeBar(kItemIdMusic);
		drawVolumeBar(kItemIdSoundFX);
		drawVolumeBar(kItemIdBackground);
		break;
	default:
		break;
	}

	for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); ++iter) {
		if ((*iter).enabled)
			drawItem((*iter).id, false);
	}

	// Check if the mouse is already over an item
	_currItemID = kItemIdNone;
	Common::Point mousePos = _vm->_system->getEventManager()->getMousePos();
	handleMouseMove(mousePos.x, mousePos.y);
}