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

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Sat Jun 20 16:26:01 CEST 2009


Revision: 41713
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41713&view=rev
Author:   athrxx
Date:     2009-06-20 14:26:01 +0000 (Sat, 20 Jun 2009)

Log Message:
-----------
LOL: implemented save menu

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_lol.cpp
    scummvm/trunk/engines/kyra/gui_lol.h
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/gui_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_lol.cpp	2009-06-20 14:15:30 UTC (rev 41712)
+++ scummvm/trunk/engines/kyra/gui_lol.cpp	2009-06-20 14:26:01 UTC (rev 41713)
@@ -31,6 +31,7 @@
 #include "kyra/resource.h"
 
 #include "common/savefile.h"
+#include "graphics/scaler.h"
 
 #include "base/version.h"
 
@@ -2227,6 +2228,13 @@
 	_savegameOffset = 0;
 	backupPage0();
 
+	const ScreenDim *d = _screen->getScreenDim(8);
+	uint32 textCursorTimer = 0;
+	uint8 textCursorStatus = 1;
+	int wW = _screen->getCharWidth('W');
+	int fW = (d->w << 3) - wW;	
+	int fC = 0;
+
 	// LoL doesnt't have default higlighted items. No item should be
 	// highlighted when entering a new menu.
 	// Instead, the respevtive struct entry is used to determine whether
@@ -2305,9 +2313,47 @@
 			_screen->updateScreen();
 		}
 
+		if (_currentMenu == &_savenameMenu) {
+			int mx = (d->sx << 3) - 1;
+			int my = d->sy - 1;
+			int mw = (d->w << 3) + 1;
+			int mh = d->h + 1;
+			_screen->drawShadedBox(mx, my, mx + mw, my + mh, 227, 223, Screen::kShadeTypeLol);
+			int pg = _screen->setCurPage(0);
+			_vm->_txt->clearDim(8);
+			textCursorTimer = 0;
+			textCursorStatus = 1;
+
+			fC = _screen->getTextWidth(_saveDescription);
+			while (fC >= fW) {
+				_saveDescription[strlen(_saveDescription) - 1] = 0;
+				fC = _screen->getTextWidth(_saveDescription);
+			}
+
+			_screen->fprintString(_saveDescription, (d->sx << 3), d->sy + 2, d->unk8, d->unkA, 0);	
+			_screen->fillRect((d->sx << 3) + fC, d->sy, (d->sx << 3) + fC + wW, d->sy + d->h - 1, d->unk8, 0);
+			_screen->setCurPage(pg);
+			_screen->updateScreen();
+		}
+
 		while (!_newMenu && _displayMenu) {
-			processHighlights(*_currentMenu);			
-			if (getInput()) {
+			processHighlights(*_currentMenu);
+
+			if (_currentMenu == &_savenameMenu) {
+				fC = _screen->getTextWidth(_saveDescription);
+				int pg = _screen->setCurPage(0);
+
+				if (textCursorTimer <= _vm->_system->getMillis()) {
+					textCursorStatus ^= 1;
+					textCursorTimer = _vm->_system->getMillis() + 20 * _vm->_tickLength;
+					_screen->fillRect((d->sx << 3) + fC, d->sy, (d->sx << 3) + fC + wW, d->sy + d->h - 1, textCursorStatus ? d->unk8 : d->unkA, 0);
+				}
+				
+				_screen->updateScreen();
+				_screen->setCurPage(pg);
+			}
+
+			if (getInput()) {			
 				if (!_newMenu)
 					_newMenu = _currentMenu;
 				else
@@ -2332,6 +2378,13 @@
 	return _menuResult;
 }
 
+void GUI_LoL::createScreenThumbnail(Graphics::Surface &dst) {
+	uint8 *screenPal = new uint8[768];
+	_screen->getRealPalette(1, screenPal);
+	::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal);
+	delete[] screenPal;
+}
+
 void GUI_LoL::backupPage0() {
 	_screen->copyPage(0, 7);
 }
@@ -2356,14 +2409,14 @@
 	KyraEngine_v1::SaveHeader header;
 	Common::InSaveFile *in;
 	for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); ++i) {
-		if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header)) != 0) {
+		if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset - startSlot]), header)) != 0) {
 			strncpy(s, header.description.c_str(), 80);
 			s[79] = 0;
 
 			for (uint32 ii = 0; ii < strlen(s); ii++) {
-				for (int iii = 0; iii < _vm->_fontConversionTableGermanSize; iii += 2) {
-					if ((uint8)s[ii] == _vm->_fontConversionTableGerman[iii]) {
-						s[ii] = (uint8)_vm->_fontConversionTableGerman[iii + 1];
+				for (int iii = 0; iii < _vm->_fontConversionTableSize; iii += 2) {
+					if ((uint8)s[ii] == _vm->_fontConversionTable[iii]) {
+						s[ii] = (uint8)_vm->_fontConversionTable[iii + 1];
 						break;
 					}
 				}
@@ -2378,13 +2431,12 @@
 	}
 
 	if (_savegameOffset == 0) {
-		/*if (&menu == &_saveMenu) {
-			char *dst = _vm->getLangString(menu.item[0].itemId);
-			const char *src = _vm->getLangString(_vm->gameFlags().isTalkie ? 10 : 18);
-			strcpy(dst, src);
-			menu.item[0].saveSlot = -2;
+		if (&menu == &_saveMenu) {
+			strcpy(s, _vm->getLangString(0x4010));
+			menu.item[0].itemString = s;
+			menu.item[0].saveSlot = -3;
 			menu.item[0].enabled = true;
-		}*/
+		}
 	}
 }
 
@@ -2408,13 +2460,45 @@
 	Common::Point p = _vm->getMousePos();
 	_vm->_mouseX = p.x;
 	_vm->_mouseY = p.y;
+
+	if (_currentMenu == &_savenameMenu) {
+		_vm->updateInput();
+
+		for (Common::List<KyraEngine_v1::Event>::const_iterator evt = _vm->_eventList.begin(); evt != _vm->_eventList.end(); evt++) {
+			if (evt->event.type == Common::EVENT_KEYDOWN)
+				_keyPressed = evt->event.kbd;
+		}
+	}
+
 	int inputFlag = _vm->checkInput(_menuButtonList);
+
+	if (_currentMenu == &_savenameMenu && _keyPressed.ascii){
+		for (int i = 0; i < _vm->_fontConversionTableSize; i += 2) {
+			if (_keyPressed.ascii == _vm->_fontConversionTable[i]) {
+				_keyPressed.ascii = _vm->_fontConversionTable[i + 1];
+				break;
+			}
+		}
+
+		if (_keyPressed.ascii > 31 && _keyPressed.ascii < 226) {
+			_saveDescription[strlen(_saveDescription) + 1] = 0;
+			_saveDescription[strlen(_saveDescription)] = _keyPressed.ascii;
+			inputFlag |= 0x8000;
+		} else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE && strlen(_saveDescription)) {
+			_saveDescription[strlen(_saveDescription) - 1] = 0;
+			inputFlag |= 0x8000;			
+		} else {
+
+		}
+	}
+
 	_vm->removeInputTop();
+	_keyPressed.reset();
 
 	if (_vm->shouldQuit())
 		_displayMenu = false;
 
-	_vm->delay(10);
+	_vm->delay(8);
 	return inputFlag & 0x8000 ? 1 : 0;
 }
 
@@ -2427,7 +2511,7 @@
 		break;
 	case 0x4002:
 		_savegameOffset = 0;
-		//_newMenu = &_saveMenu;
+		_newMenu = &_saveMenu;
 		break;		
 	case 0x4003:
 		_savegameOffset = 0;
@@ -2471,16 +2555,34 @@
 int GUI_LoL::clickedSaveMenu(Button *button) {
 	updateMenuButton(button);
 	
+	if (button->arg == 0x4011) {
+		_newMenu = &_mainMenu;
+		return 1;
+	}
+
+	_newMenu = &_savenameMenu;
+	int16 s = (int16)button->arg;
+	_menuResult = _saveMenu.item[-s - 2].saveSlot + 1;
+	_saveDescription = (char*)_vm->_tempBuffer5120 + 1000;
+	_saveDescription[0] = 0;
+	if (_saveMenu.item[-s - 2].saveSlot != -3)
+		strcpy(_saveDescription, _saveMenu.item[-s - 2].itemString);
+	
 	return 1;
 }
 
 int GUI_LoL::clickedDeleteMenu(Button *button) {
 	updateMenuButton(button);
 	
+	if (button->arg == 0x4011) {
+		_newMenu = &_mainMenu;
+		return 1;
+	}
+
 	_choiceMenu.menuNameId = 0x400b;
-	_newMenu = (button->arg == 0x4011) ? _lastMenu : &_choiceMenu;	
+	_newMenu = &_choiceMenu;
 	int16 s = (int16)button->arg;
-	_menuResult = _deleteMenu.item[-s - 2].saveSlot;
+	_menuResult = _deleteMenu.item[-s - 2].saveSlot + 1;
 
 	return 1;
 }
@@ -2531,13 +2633,53 @@
 	return 1;
 }
 
+int GUI_LoL::clickedSavenameMenu(Button *button) {
+	updateMenuButton(button);
+	if (button->arg == _savenameMenu.item[0].itemId) {
+		for (uint32 i = 0; i < strlen(_saveDescription); i++) {
+			for (int ii = 0; ii < _vm->_fontConversionTableSize; ii += 2) {
+				if ((uint8)_saveDescription[i] == _vm->_fontConversionTable[ii + 1]) {
+					_saveDescription[i] = (char)_vm->_fontConversionTable[ii];
+					break;
+				}
+			}
+		}
+		
+		int slot = _menuResult == -2 ? getNextSavegameSlot() : _menuResult;
+		Graphics::Surface thumb;
+		createScreenThumbnail(thumb);
+		_vm->saveGameState(slot, _saveDescription, &thumb);
+		thumb.free();
+
+		_displayMenu = false;
+
+	} else if (button->arg == _savenameMenu.item[1].itemId) {
+		_newMenu = &_saveMenu;
+	}
+
+	return 1;
+}
+
 int GUI_LoL::clickedChoiceMenu(Button *button) {
 	updateMenuButton(button);
 	if (button->arg == _choiceMenu.item[0].itemId) {
 		if (_lastMenu == &_mainMenu) {
 			_vm->quitGame();
 		} else if (_lastMenu == &_deleteMenu) {
-			_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_menuResult));
+			_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_menuResult - 1));
+			Common::Array<int>::iterator i = Common::find(_saveSlots.begin(), _saveSlots.end(), _menuResult);
+			while (i != _saveSlots.end()) {
+				++i;
+				if (i == _saveSlots.end())
+					break;
+				// We are only renaming all savefiles until we get some slots missing
+				// Also not rename quicksave slot filenames
+				if (*(i-1) != *i || *i >= 990)
+					break;
+				Common::String oldName = _vm->getSavegameFilename(*i);
+				Common::String newName = _vm->getSavegameFilename(*i-1);
+				_vm->_saveFileMan->renameSavefile(oldName, newName);
+			}
 			_newMenu = &_mainMenu;
 		}
 	} else if (button->arg == _choiceMenu.item[1].itemId) {

Modified: scummvm/trunk/engines/kyra/gui_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_lol.h	2009-06-20 14:15:30 UTC (rev 41712)
+++ scummvm/trunk/engines/kyra/gui_lol.h	2009-06-20 14:26:01 UTC (rev 41713)
@@ -96,7 +96,7 @@
 	int runMenu(Menu &menu);
 
 	// utilities for thumbnail creation
-	void createScreenThumbnail(Graphics::Surface &dst) {}
+	void createScreenThumbnail(Graphics::Surface &dst);
 
 private:
 	void backupPage0();
@@ -115,6 +115,7 @@
 	int clickedDeleteMenu(Button *button);
 	int clickedOptionsMenu(Button *button);
 	int clickedDeathMenu(Button *button);
+	int clickedSavenameMenu(Button *button);
 	int clickedChoiceMenu(Button *button);
 
 	int scrollUp(Button *button);
@@ -141,6 +142,7 @@
 	Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu;
 	Menu *_currentMenu, *_lastMenu, *_newMenu;
 	int _menuResult;
+	char *_saveDescription;
 
 	LoLEngine *_vm;
 	Screen_LoL *_screen;

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-06-20 14:15:30 UTC (rev 41712)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2009-06-20 14:26:01 UTC (rev 41713)
@@ -278,10 +278,10 @@
 			} else {
 				switch(event.kbd.keycode) {
 				case Common::KEYCODE_SPACE:
-					keys = 43;
+					keys = 61;
 					break;
 				case Common::KEYCODE_RETURN:
-					keys = 61;
+					keys = 43;
 					break;
 				case Common::KEYCODE_UP:
 				case Common::KEYCODE_KP8:

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-06-20 14:15:30 UTC (rev 41712)
+++ scummvm/trunk/engines/kyra/lol.h	2009-06-20 14:26:01 UTC (rev 41713)
@@ -855,8 +855,8 @@
 
 	// TODO: Rethink of a proper way for conversion, currently our GUI charset isn't defined
 	// properly, thus this might not work on every system.
-	static const uint8 _fontConversionTableGerman[];
-	static const int _fontConversionTableGermanSize;
+	static const uint8 _fontConversionTable[];
+	static const int _fontConversionTableSize;
 
 	// graphics
 	void setupScreenDims();

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2009-06-20 14:15:30 UTC (rev 41712)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2009-06-20 14:26:01 UTC (rev 41713)
@@ -2078,6 +2078,13 @@
 	for (int i = 0; i < 2; ++i)
 		_deathMenu.item[i].callback = deathMenuFunctor;
 
+	GUI_LOL_MENU(_savenameMenu, 7, 0x4053, 0, 2, -1, -1, -1, -1);
+	GUI_LOL_MENU_ITEM(_savenameMenu.item[0], 0x4012, 8, 38, 72, 15, 0, 43);
+	GUI_LOL_MENU_ITEM(_savenameMenu.item[1], 0x4011, 176, 38, 72, 15, 0, 110);
+	Button::Callback savenameMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedSavenameMenu);
+	for (int i = 0; i < 2; ++i)
+		_savenameMenu.item[i].callback = savenameMenuFunctor;
+
 	GUI_LOL_MENU(_choiceMenu, 11, 0, 0, 2, -1, -1, -1, -1);
 	GUI_LOL_MENU_ITEM(_choiceMenu.item[0], 0x4007, 8, 30, 72, 15, 0, 0);
 	GUI_LOL_MENU_ITEM(_choiceMenu.item[1], 0x4008, 208, 30, 72, 15, 0, 0);
@@ -3316,15 +3323,21 @@
 	0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100
 };
 
-const uint8 LoLEngine::_fontConversionTableGerman[] = {
+const uint8 LoLEngine::_fontConversionTable[] = {
 	(const uint8)'\xC4', 0x8e, (const uint8)'\xE4', 0x84, (const uint8)'\xD6', 0x99,
 	(const uint8)'\xF6', 0x94, (const uint8)'\xDC', 0x9a, (const uint8)'\xFC', 0x81,
-	(const uint8)'\xDF', 0xe1
+	(const uint8)'\xDF', 0xe1, (const uint8)'\xC9', 0x90, (const uint8)'\xE9', 0x82,
+	(const uint8)'\xE8', 0x8a, (const uint8)'\xEA', 0x88, (const uint8)'\xE0', 0x85,
+	(const uint8)'\xE2', 0x83, (const uint8)'\xF4', 0x93,	(const uint8)'\xC7', 0x80,
+	(const uint8)'\xE7', 0x87, (const uint8)'\xEB', 0x89, (const uint8)'\xE5', 0x86,
+	(const uint8)'\xEF', 0x8b, (const uint8)'\xEE', 0x8c, (const uint8)'\xEC', 0x8d,
+	(const uint8)'\xC5', 0x8f, (const uint8)'\xE6', 0x91, (const uint8)'\xC6', 0x92,
+	(const uint8)'\xF2', 0x95, (const uint8)'\xFB', 0x96, (const uint8)'\xF9', 0x97,
+	(const uint8)'\xE1', 0xa0
 };
 
-const int LoLEngine::_fontConversionTableGermanSize = ARRAYSIZE(LoLEngine::_fontConversionTableGerman);
+const int LoLEngine::_fontConversionTableSize = ARRAYSIZE(LoLEngine::_fontConversionTable);
 
 #endif // ENABLE_LOL
 
 } // End of namespace Kyra
-


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