[Scummvm-cvs-logs] SF.net SVN: scummvm: [31378] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Apr 4 10:13:38 CEST 2008


Revision: 31378
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31378&view=rev
Author:   lordhoto
Date:     2008-04-04 01:13:35 -0700 (Fri, 04 Apr 2008)

Log Message:
-----------
Implemented game options menu.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_v2.cpp
    scummvm/trunk/engines/kyra/gui_v2.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/kyra/timer_v2.cpp

Modified: scummvm/trunk/engines/kyra/gui_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v2.cpp	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/gui_v2.cpp	2008-04-04 08:13:35 UTC (rev 31378)
@@ -230,6 +230,7 @@
 void KyraEngine_v2::loadButtonShapes() {
 	const uint8 *src = _screen->getCPagePtr(3);
 	_screen->loadBitmap("_BUTTONS.CSH", 3, 3, 0);
+
 	_gui->_scrollUpButton.data0ShapePtr = _buttonShapes[0] = _screen->makeShapeCopy(src, 0);
 	_gui->_scrollUpButton.data2ShapePtr = _buttonShapes[1] = _screen->makeShapeCopy(src, 1);
 	_gui->_scrollUpButton.data1ShapePtr = _buttonShapes[2] = _screen->makeShapeCopy(src, 2);
@@ -247,6 +248,30 @@
 	_buttonShapes[18] = _screen->makeShapeCopy(src, 18);
 }
 
+void KyraEngine_v2::setupLangButtonShapes() {
+	switch (_lang) {
+	case 0:
+		_inventoryButtons[0].data0ShapePtr = _buttonShapes[6];
+		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7];
+		break;
+
+	case 1:
+		_inventoryButtons[0].data0ShapePtr = _buttonShapes[8];
+		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[9];
+		break;
+
+	case 2:
+		_inventoryButtons[0].data0ShapePtr = _buttonShapes[10];
+		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[11];
+		break;
+
+	default:
+		_inventoryButtons[0].data0ShapePtr = _buttonShapes[6];
+		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7];
+		break;
+	}
+}
+
 GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {
 	_backUpButtonList = _unknownButtonList = 0;
 	initStaticData();
@@ -1208,6 +1233,7 @@
 	}
 
 	initMenuLayout(_mainMenu);
+	initMenuLayout(_gameOptions);
 	//XXX
 	initMenuLayout(_choiceMenu);
 	_loadMenu.numberOfItems = 6;
@@ -1276,7 +1302,7 @@
 
 	if (!_loadedSave && _reloadTemporarySave) {
 		_vm->_unkSceneScreenFlag1 = true;
-		//XXX
+		_vm->loadGame("TEMP.SAV");
 		_vm->_unkSceneScreenFlag1 = false;
 	}
 
@@ -1285,6 +1311,19 @@
 
 #pragma mark -
 
+void GUI_v2::renewHighlight(Menu &menu) {
+	if (!_displayMenu)
+		return;
+
+	MenuItem &item = menu.item[menu.highlightedItem];
+	int x = item.x + menu.x; int y = item.y + menu.y;
+	int x2 = x + item.width - 1; int y2 = y + item.height - 1;
+	redrawText(menu);
+	_screen->fillRect(x+2, y+2, x2-2, y2-2, item.bkgdColor);
+	redrawHighlight(menu);
+	_screen->updateScreen();
+}
+
 void GUI_v2::setupPalette() {
 	//if (_isDeathMenu)
 	//	memcpy(_vm->_unkBuffer1040Bytes, _screen->getPalette(0), 768);
@@ -1434,6 +1473,126 @@
 	return 0;
 }
 
+int GUI_v2::gameOptions(Button *caller) {
+	updateMenuButton(caller);
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+	bool textEnabled = _vm->textEnabled();
+	int lang = _vm->_lang;
+
+	setupOptionsButtons();
+	initMenu(_gameOptions);
+	_isOptionsMenu = true;
+
+	while (_isOptionsMenu) {
+		processHighlights(_gameOptions, _vm->_mouseX, _vm->_mouseY);
+		getInput();
+	}
+
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+
+	if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) {
+		_vm->_configVoice = 1;
+		choiceDialog(0x1E, 0);
+	}
+
+	if (_vm->_lang != lang) {
+		_reloadTemporarySave = true;
+		_vm->saveGame("TEMP.SAV", "Temporary Kyrandia 2 Savegame");
+		_vm->loadCCodeBuffer("C_CODE.XXX");
+		if (_vm->_flags.isTalkie)
+			_vm->loadOptionsBuffer("OPTIONS.XXX");
+		else
+			_vm->_optionsBuffer = _vm->_cCodeBuffer;
+		_vm->loadChapterBuffer(_vm->_newChapterFile);
+		_vm->loadNPCScript();
+		_vm->setupLangButtonShapes();
+	}
+
+	_vm->writeSettings();
+
+	initMenu(*_currentMenu);
+	updateAllMenuButtons();
+	return 0;
+}
+
+int GUI_v2::quitOptionsMenu(Button *caller) {
+	updateMenuButton(caller);
+	_isOptionsMenu = false;
+	return 0;
+}
+
+int GUI_v2::toggleWalkspeed(Button *caller) {
+	updateMenuButton(caller);
+	if (_vm->_configWalkspeed == 5)
+		_vm->_configWalkspeed = 3;
+	else
+		_vm->_configWalkspeed = 5;
+	_vm->_timer->setDelay(0, _vm->_configWalkspeed); 
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+int GUI_v2::changeLanguage(Button *caller) {
+	updateMenuButton(caller);
+	++_vm->_lang;
+	_vm->_lang %= 3;
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+int GUI_v2::toggleText(Button *caller) {
+	updateMenuButton(caller);
+	
+	if (_vm->textEnabled()) {
+		if (_vm->speechEnabled())
+			_vm->_configVoice = 1;
+		else
+			_vm->_configVoice = 3;
+	} else {
+		if (_vm->speechEnabled())
+			_vm->_configVoice = 2;
+		else
+			_vm->_configVoice = 0;
+	}
+
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+void GUI_v2::setupOptionsButtons() {
+	if (_vm->_configWalkspeed == 3)
+		_gameOptions.item[0].itemId = 28;
+	else
+		_gameOptions.item[0].itemId = 27;
+
+	if (_vm->textEnabled())
+		_gameOptions.item[2].itemId = 18;
+	else
+		_gameOptions.item[2].itemId = 17;
+
+	switch (_vm->_lang) {
+	case 0:
+		_gameOptions.item[1].itemId = 31;
+		break;
+	
+	case 1:
+		_gameOptions.item[1].itemId = 32;
+		break;
+
+	case 2:
+		_gameOptions.item[1].itemId = 33;
+		break;
+
+	default:
+		break;
+	}
+}
+
 int GUI_v2::loadMenu(Button *caller) {
 	if (!_vm->_menuDirectlyToLoad) {
 		updateMenuButton(caller);

Modified: scummvm/trunk/engines/kyra/gui_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_v2.h	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/gui_v2.h	2008-04-04 08:13:35 UTC (rev 31378)
@@ -111,7 +111,7 @@
 	Button _menuButtons[7];
 	Button _scrollUpButton;
 	Button _scrollDownButton;
-	Menu _mainMenu, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
+	Menu _mainMenu, _gameOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
 	void initStaticData();
 
 	const char *getMenuTitle(const Menu &menu);
@@ -133,6 +133,8 @@
 	uint8 defaultColor1() const { return 0xCF; }
 	uint8 defaultColor2() const { return 0xF8; }
 
+	void renewHighlight(Menu &menu);
+
 	void setupPalette();
 	void restorePalette();
 
@@ -153,6 +155,7 @@
 	bool _isDeathMenu;
 	bool _isSaveMenu;
 	bool _isChoiceMenu;
+	bool _isOptionsMenu;
 	bool _madeSave;
 	bool _loadedSave;
 	bool _restartGame;
@@ -166,6 +169,16 @@
 	int quitGame(Button *caller);
 	int resumeGame(Button *caller);
 
+	// options menu
+	int gameOptions(Button *caller);
+	int quitOptionsMenu(Button *caller);
+
+	int toggleWalkspeed(Button *caller);
+	int changeLanguage(Button *caller);
+	int toggleText(Button *caller);
+
+	void setupOptionsButtons();
+
 	// load menu
 	bool _noLoadProcess;
 	int loadMenu(Button *caller);

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-04-04 08:13:35 UTC (rev 31378)
@@ -359,11 +359,12 @@
 	_gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
 	_itemList = new Item[30];
 	memset(_itemList, 0, sizeof(Item)*30);
+	loadButtonShapes();
 	resetItemList();
-	loadButtonShapes();
 	_loadedZTable = 1;
 	loadZShapes(_loadedZTable);
 	initInventoryButtonList();
+	setupLangButtonShapes();
 	loadInventoryShapes();
 
 	_res->loadFileToBuf("PALETTE.COL", _screen->_currentPalette, 0x300);
@@ -404,7 +405,7 @@
 
 	setNextIdleAnimTimer();
 	//XXX
-	_timer->setDelay(0, 5);
+	setWalkspeed(_configWalkspeed);
 }
 
 void KyraEngine_v2::runLoop() {

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-04-04 08:13:35 UTC (rev 31378)
@@ -612,6 +612,7 @@
 	GUI_v2 *_gui;
 
 	void loadButtonShapes();
+	void setupLangButtonShapes();
 	uint8 *_buttonShapes[19];
 
 	void initInventoryButtonList();

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-04-04 08:13:35 UTC (rev 31378)
@@ -1470,28 +1470,6 @@
 	for (int i = 5; i <= 14; ++i)
 		_inventoryButtons[i].buttonCallback = inventoryCallback;
 
-	switch (_lang) {
-	case 0:
-		_inventoryButtons[0].data0ShapePtr = _buttonShapes[6];
-		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7];
-		break;
-
-	case 1:
-		_inventoryButtons[0].data0ShapePtr = _buttonShapes[8];
-		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[9];
-		break;
-
-	case 2:
-		_inventoryButtons[0].data0ShapePtr = _buttonShapes[10];
-		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[11];
-		break;
-
-	default:
-		_inventoryButtons[0].data0ShapePtr = _buttonShapes[6];
-		_inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7];
-		break;
-	}
-
 	_buttonList = &_inventoryButtons[0];
 	for (size_t i = 1; i < 15; ++i)
 		_buttonList = _gui->addButtonToList(_buttonList, &_inventoryButtons[i]);
@@ -1518,6 +1496,7 @@
 	_mainMenu.item[1].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::saveMenu);
 	GUI_V2_MENU_ITEM(_mainMenu.item[2], 1, 0x23, -1, 0x40, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
 	GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 0x04, -1, 0x51, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+	_mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::gameOptions);
 	GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 0x25, -1, 0x62, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
 	GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 0x05, -1, 0x73, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
 	_mainMenu.item[5].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitGame);
@@ -1526,6 +1505,20 @@
 	for (int i = 0; i < 7; ++i)
 		_mainMenu.item[i].itemId = menuStr[0 * 8 + i + 1];
 
+	GUI_V2_MENU(_gameOptions, -1, -1, 0x120, 0x88, 0xF8, 0xF9, 0xFA, menuStr[1 * 8], 0xFB, -1, 8, 4, 4, -1, -1, -1, -1);
+	GUI_V2_MENU_ITEM(_gameOptions.item[0], 1, 0, 0xA0, 0x1E, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x15, 8, 0x20, 0);
+	_gameOptions.item[0].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::toggleWalkspeed);
+	GUI_V2_MENU_ITEM(_gameOptions.item[1], 1, 0, 0xA0, 0x2F, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x26, 8, 0x31, 0);
+	_gameOptions.item[1].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::changeLanguage);
+	GUI_V2_MENU_ITEM(_gameOptions.item[2], 1, 0, 0xA0, 0x40, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x16, 8, 0x42, 0);
+	_gameOptions.item[2].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::toggleText);
+	GUI_V2_MENU_ITEM(_gameOptions.item[3], 1, 0x10, -1, 0x6E, 0x6C, 0x0F, 0xFD, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+	_gameOptions.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitOptionsMenu);
+	for (int i = 4; i <= 6; ++i)
+		_gameOptions.item[i].enabled = false;
+	for (int i = 0; i < 7; ++i)
+		_gameOptions.item[i].itemId = menuStr[1 * 8 + i + 1];
+
 	GUI_V2_MENU(_choiceMenu, -1, -1, 0x140, 0x38, 0xF8, 0xF9, 0xFA, 0, 0xFE, -1, 8, 0, 2, -1, -1, -1, -1);
 	GUI_V2_MENU_ITEM(_choiceMenu.item[0], 1, 0x14, 0x18, 0x1E, 0x48, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
 	_choiceMenu.item[0].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::choiceYes);

Modified: scummvm/trunk/engines/kyra/timer_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/timer_v2.cpp	2008-04-04 07:28:32 UTC (rev 31377)
+++ scummvm/trunk/engines/kyra/timer_v2.cpp	2008-04-04 08:13:35 UTC (rev 31378)
@@ -113,7 +113,8 @@
 	else
 		newSpeed = 5;
 
-	_timer->setDelay(5, newSpeed);
+	_configWalkspeed = newSpeed;
+	_timer->setDelay(0, newSpeed);
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list