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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Apr 26 23:08:47 CEST 2008


Revision: 31735
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31735&view=rev
Author:   lordhoto
Date:     2008-04-26 14:08:47 -0700 (Sat, 26 Apr 2008)

Log Message:
-----------
Added support for kyra3 inventory. (jesters staff not supported yet)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_v3.cpp
    scummvm/trunk/engines/kyra/items_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.h
    scummvm/trunk/engines/kyra/staticres.cpp

Added Paths:
-----------
    scummvm/trunk/engines/kyra/gui_v3.h

Modified: scummvm/trunk/engines/kyra/gui_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v3.cpp	2008-04-26 20:33:59 UTC (rev 31734)
+++ scummvm/trunk/engines/kyra/gui_v3.cpp	2008-04-26 21:08:47 UTC (rev 31735)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "kyra/gui_v3.h"
 #include "kyra/kyra_v3.h"
 #include "kyra/text_v3.h"
 #include "kyra/wsamovie.h"
@@ -168,7 +169,7 @@
 	_screen->copyRegion(0, 0, 0, 144, 320, 56, 2, 0, Screen::CR_NO_P_CHECK);
 	_screen->updateScreen();
 
-	//initInventoryButtonList(0);
+	initMainButtonList(false);
 
 	restorePage3();
 	_screen->showMouse();
@@ -181,7 +182,7 @@
 
 	_inventoryState = false;
 	updateCLState();
-	//initInventoryButtonList(1);
+	initMainButtonList(true);
 	
 	_screen->copyBlockToPage(3, 0, 0, 320, 56, _interface);
 	_screen->hideMouse();
@@ -428,5 +429,414 @@
 	_screen->drawShape(page, getShapePtr(item+248), _inventoryX[slot], _inventoryY[slot] + yOffset, 0, 0);
 }
 
+int KyraEngine_v3::buttonInventory(Button *button) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::buttonInventory(%p)", (const void*)button);
+	setNextIdleAnimTimer();
+	if (!_enableInventory || !_inventoryState || !_screen->isMouseVisible())
+		return 0;
+
+	const int slot = button->index - 5;
+	const int16 slotItem = (int16)_mainCharacter.inventory[slot];
+	if (_itemInHand == -1) {
+		if (slotItem == -1)
+			return 0;
+
+		_screen->hideMouse();
+		clearInventorySlot(slot, 0);
+		playSoundEffect(0x0B, 0xC8);
+		setMouseCursor(slotItem);
+		updateItemCommand(slotItem, (_lang == 1) ? getItemCommandStringPickUp(slotItem) : 0, 0xFF);
+		_itemInHand = slotItem;
+		_mainCharacter.inventory[slot] = 0xFFFF;
+		_screen->showMouse();
+	} else if (_itemInHand == 27) {
+		if (_chatText)
+			return 0;
+		//XXX
+	} else {
+		if (slotItem >= 0) {
+			if (itemInventoryMagic(_itemInHand, slot))
+				return 0;
+
+			playSoundEffect(0x0B, 0xC8);
+
+			_screen->hideMouse();
+			clearInventorySlot(slot, 0);
+			drawInventorySlot(0, _itemInHand, slot);
+			setMouseCursor(slotItem);
+			updateItemCommand(slotItem, (_lang == 1) ? getItemCommandStringPickUp(slotItem) : 0, 0xFF);
+			_mainCharacter.inventory[slot] = _itemInHand;
+			_itemInHand = slotItem;
+			_screen->showMouse();
+		} else {
+			playSoundEffect(0x0C, 0xC8);
+			_screen->hideMouse();
+			drawInventorySlot(0, _itemInHand, slot);
+			_screen->setMouseCursor(0, 0, getShapePtr(0));
+			updateItemCommand(_itemInHand, (_lang == 1) ? getItemCommandStringInv(_itemInHand) : 2, 0xFF);
+			_screen->showMouse();
+			_mainCharacter.inventory[slot] = _itemInHand;
+			_itemInHand = -1;
+		}
+	}
+
+	return 0;
+}
+
+#pragma mark -
+
+GUI_v3::GUI_v3(KyraEngine_v3 *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) {
+	_backUpButtonList = _unknownButtonList = 0;
+	_buttonListChanged = false;
+}
+
+Button *GUI_v3::addButtonToList(Button *list, Button *newButton) {
+	list = GUI::addButtonToList(list, newButton);
+	_buttonListChanged = true;
+	return list;
+}
+
+void GUI_v3::processButton(Button *button) {
+	if (!button)
+		return;
+
+	if (button->flags & 8) {
+		if (button->flags & 0x10) {
+			// XXX
+		}
+		return;
+	}
+	
+	int entry = button->flags2 & 5;
+
+	byte val1 = 0, val2 = 0, val3 = 0;
+	const uint8 *dataPtr = 0;
+	Button::Callback callback;
+	if (entry == 1) {
+		val1 = button->data1Val1;
+		dataPtr = button->data1ShapePtr;
+		callback = button->data1Callback;
+		val2 = button->data1Val2;
+		val3 = button->data1Val3;
+	} else if (entry == 4 || entry == 5) {
+		val1 = button->data2Val1;
+		dataPtr = button->data2ShapePtr;
+		callback = button->data2Callback;
+		val2 = button->data2Val2;
+		val3 = button->data2Val3;
+	} else {
+		val1 = button->data0Val1;
+		dataPtr = button->data0ShapePtr;
+		callback = button->data0Callback;
+		val2 = button->data0Val2;
+		val3 = button->data0Val3;
+	}
+
+	int x = 0, y = 0, x2 = 0, y2 = 0;
+
+	x = button->x;
+	if (x < 0)
+		x += _screen->getScreenDim(button->dimTableIndex)->w << 3;
+	x += _screen->getScreenDim(button->dimTableIndex)->sx << 3;
+	x2 = x + button->width - 1;
+
+	y = button->y;
+	if (y < 0)
+		y += _screen->getScreenDim(button->dimTableIndex)->h << 3;
+	y += _screen->getScreenDim(button->dimTableIndex)->sy << 3;
+	y2 = y + button->height - 1;
+
+	switch (val1 - 1) {
+	case 0:
+		_screen->hideMouse();
+		_screen->drawShape(_screen->_curPage, dataPtr, x, y, button->dimTableIndex, 0x10);
+		_screen->showMouse();
+		break;
+
+	case 1:
+		_screen->hideMouse();
+		_screen->printText((const char*)dataPtr, x, y, val2, val3);
+		_screen->showMouse();
+		break;
+
+	case 3:
+		if (callback)
+			(*callback)(button);
+		break;
+
+	case 4:
+		_screen->hideMouse();
+		_screen->drawBox(x, y, x2, y2, val2);
+		_screen->showMouse();
+		break;
+
+	case 5:
+		_screen->hideMouse();
+		_screen->fillRect(x, y, x2, y2, val2, -1, true);
+		_screen->showMouse();
+		break;
+
+	default:
+		break;
+	}
+
+	_screen->updateScreen();
+}
+
+int GUI_v3::processButtonList(Button *buttonList, uint16 inputFlag) {
+	static uint16 flagsModifier = 0;
+
+	if (!buttonList)
+		return inputFlag & 0x7FFF;
+
+	if (_backUpButtonList != buttonList || _buttonListChanged) {
+		_unknownButtonList = 0;
+		//flagsModifier |= 0x2200;
+		_backUpButtonList = buttonList;
+		_buttonListChanged = false;
+
+		while (buttonList) {
+			processButton(buttonList);
+			buttonList = buttonList->nextButton;
+		}
+	}
+
+	int mouseX = _vm->_mouseX;
+	int mouseY = _vm->_mouseY;
+
+	uint16 flags = 0;
+
+	if (1/*!_screen_cursorDisable*/) {
+		uint16 inFlags = inputFlag & 0xFF;
+		uint16 temp = 0;
+
+		// HACK: inFlags == 200 is our left button (up)
+		if (inFlags == 199 || inFlags == 200)
+			temp = 0x1000;
+		if (inFlags == 198)
+			temp = 0x100;
+
+		if (inputFlag & 0x800)
+			temp <<= 2;
+
+		flags |= temp;
+
+		flagsModifier &= ~((temp & 0x4400) >> 1);
+		flagsModifier |= (temp & 0x1100) * 2;
+		flags |= flagsModifier;
+		flags |= (flagsModifier << 2) ^ 0x8800;
+	}
+
+	buttonList = _backUpButtonList;
+	if (_unknownButtonList) {
+		buttonList = _unknownButtonList;
+		if (_unknownButtonList->flags & 8)
+			_unknownButtonList = 0;
+	}
+
+	int returnValue = 0;
+	while (buttonList) {
+		if (buttonList->flags & 8) {
+			buttonList = buttonList->nextButton;
+			continue;
+		}
+		buttonList->flags2 &= ~0x18;
+		buttonList->flags2 |= (buttonList->flags2 & 3) << 3;
+
+		int x = buttonList->x;
+		if (x < 0)
+			x += _screen->getScreenDim(buttonList->dimTableIndex)->w << 3;
+		x += _screen->getScreenDim(buttonList->dimTableIndex)->sx << 3;
+
+		int y = buttonList->y;
+		if (y < 0)
+			y += _screen->getScreenDim(buttonList->dimTableIndex)->h;
+		y += _screen->getScreenDim(buttonList->dimTableIndex)->sy;
+
+		bool progress = false;
+
+		if (mouseX >= x && mouseY >= y && mouseX <= x+buttonList->width && mouseY <= y+buttonList->height)
+			progress = true;
+
+		buttonList->flags2 &= ~0x80;
+		uint16 inFlags = inputFlag & 0x7FFF;
+		if (inFlags) {
+			if (buttonList->unk6 == inFlags) {
+				progress = true;
+				flags = buttonList->flags & 0x0F00;
+				buttonList->flags2 |= 0x80;
+				inputFlag = 0;
+				_unknownButtonList = buttonList;
+			} else if (buttonList->unk8 == inFlags) {
+				flags = buttonList->flags & 0xF000;
+				if (!flags)
+					flags = buttonList->flags & 0x0F00;
+				progress = true;
+				buttonList->flags2 |= 0x80;
+				inputFlag = 0;
+				_unknownButtonList = buttonList;
+			}
+		}
+
+		bool unk1 = false;
+		if (!progress)
+			buttonList->flags2 &= ~6;
+
+		if ((flags & 0x3300) && (buttonList->flags & 4) && progress && (buttonList == _unknownButtonList || !_unknownButtonList)) {
+			buttonList->flags |= 6;
+			if (!_unknownButtonList)
+				_unknownButtonList = buttonList;
+		} else if ((flags & 0x8800) && !(buttonList->flags & 4) && progress) {
+			buttonList->flags2 |= 6;
+		} else {
+			buttonList->flags2 &= ~6;
+		}
+
+		bool progressSwitch = false;
+		if (!_unknownButtonList) {
+			progressSwitch = progress;
+		} else  {
+			if (_unknownButtonList->flags & 0x40)
+				progressSwitch = (_unknownButtonList == buttonList);
+			else
+				progressSwitch = progress;
+		}
+
+		if (progressSwitch) {
+			if ((flags & 0x1100) && progress && !_unknownButtonList) {
+				inputFlag = 0;
+				_unknownButtonList = buttonList;
+			}
+
+			if ((buttonList->flags & flags) && (progress || !(buttonList->flags & 1))) {
+				uint16 combinedFlags = (buttonList->flags & flags);
+				combinedFlags = ((combinedFlags & 0xF000) >> 4) | (combinedFlags & 0x0F00);
+				combinedFlags >>= 8;
+
+				static const uint16 flagTable[] = {
+					0x000, 0x100, 0x200, 0x100, 0x400, 0x100, 0x400, 0x100, 0x800, 0x100,
+					0x200, 0x100, 0x400, 0x100, 0x400, 0x100
+				};
+
+				assert(combinedFlags < ARRAYSIZE(flagTable));
+
+				switch (flagTable[combinedFlags]) {
+				case 0x400:
+					if (!(buttonList->flags & 1) || ((buttonList->flags & 1) && _unknownButtonList == buttonList)) {
+						buttonList->flags2 ^= 1;
+						returnValue = buttonList->index | 0x8000;
+						unk1 = true;
+					}
+
+					if (!(buttonList->flags & 4)) {
+						buttonList->flags2 &= ~4;
+						buttonList->flags2 &= ~2;
+					}
+					break;
+
+				case 0x800:
+					if (!(buttonList->flags & 4)) {
+						buttonList->flags2 |= 4;
+						buttonList->flags2 |= 2;
+					}
+
+					if (!(buttonList->flags & 1))
+						unk1 = true;
+					break;
+
+				case 0x200:
+					if (buttonList->flags & 4) {
+						buttonList->flags2 |= 4;
+						buttonList->flags2 |= 2;
+					}
+
+					if (!(buttonList->flags & 1))
+						unk1 = true;
+					break;
+
+				case 0x100:
+				default:
+					buttonList->flags2 ^= 1;
+					returnValue = buttonList->index | 0x8000;
+					unk1 = true;
+					if (buttonList->flags & 4) {
+						buttonList->flags2 |= 4;
+						buttonList->flags2 |= 2;
+					}
+					_unknownButtonList = buttonList;
+					break;
+				}
+			}
+		}
+
+		bool unk2 = false;
+		if ((flags & 0x2200) && progress) {
+			buttonList->flags2 |= 6;
+			if (!(buttonList->flags & 4) && !(buttonList->flags2 & 1)) {
+				unk2 = true;
+				buttonList->flags2 |= 1;
+			}
+		}
+
+		if ((flags & 0x8800) == 0x8800) {
+			_unknownButtonList = 0;
+			if (!progress || (buttonList->flags & 4))
+				buttonList->flags2 &= ~6;
+		}
+
+		if (!progress && buttonList == _unknownButtonList && !(buttonList->flags & 0x40))
+			_unknownButtonList = 0;
+
+		if ((buttonList->flags2 & 0x18) != ((buttonList->flags2 & 3) << 3))
+			processButton(buttonList);
+
+		if (unk2)
+			buttonList->flags2 &= ~1;
+
+		if (unk1) {
+			buttonList->flags2 &= 0xFF;
+			buttonList->flags2 |= flags;
+
+			if (buttonList->buttonCallback) {
+				_vm->removeInputTop();
+				if ((*buttonList->buttonCallback.get())(buttonList))
+					break;
+			}
+			
+			if (buttonList->flags & 0x20)
+				break;
+		}
+
+		if (_unknownButtonList == buttonList && (buttonList->flags & 0x40))
+			break;
+
+		buttonList = buttonList->nextButton;
+	}
+
+	if (!returnValue)
+		returnValue = inputFlag & 0x7FFF;
+	return returnValue;
+}
+
+void GUI_v3::flagButtonEnable(Button *button) {
+	if (!button)
+		return;
+
+	if (button->flags & 8) {
+		button->flags &= ~8;
+		processButton(button);
+	}
+}
+
+void GUI_v3::flagButtonDisable(Button *button) {
+	if (!button)
+		return;
+
+	if (!(button->flags & 8)) {
+		button->flags |= 8;
+		processButton(button);
+	}
+}
+
 } // end of namespace Kyra
 

Added: scummvm/trunk/engines/kyra/gui_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_v3.h	                        (rev 0)
+++ scummvm/trunk/engines/kyra/gui_v3.h	2008-04-26 21:08:47 UTC (rev 31735)
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_GUI_V3_H
+#define KYRA_GUI_V3_H
+
+#include "kyra/gui.h"
+
+namespace Kyra {
+
+#define GUI_V3_BUTTON(button, a, b, c, d, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t) \
+	button.nextButton = 0; \
+	button.index = a; \
+	button.unk6 = b; \
+	button.unk8 = c; \
+	button.data0Val1 = d; \
+	button.data1Val1 = e; \
+	button.data2Val1 = f; \
+	button.flags = h; \
+	button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \
+	button.dimTableIndex = i; \
+	button.x = j; \
+	button.y = k; \
+	button.width = l; \
+	button.height = m; \
+	button.data0Val2 = n; \
+	button.data0Val3 = o; \
+	button.data1Val2 = p; \
+	button.data1Val3 = q; \
+	button.data2Val2 = r; \
+	button.data2Val3 = s; \
+	button.flags2 = t;
+
+class KyraEngine_v3;
+class Screen_v3;
+
+class GUI_v3 : public GUI {
+friend class KyraEngine_v3;
+public:
+	GUI_v3(KyraEngine_v3 *engine);
+
+	Button *addButtonToList(Button *list, Button *newButton);
+
+	void processButton(Button *button);
+	int processButtonList(Button *button, uint16 inputFlag);
+
+	void flagButtonEnable(Button *button);
+	void flagButtonDisable(Button *button);
+private:
+	const char *getMenuTitle(const Menu &menu) { return 0; }
+	const char *getMenuItemTitle(const MenuItem &menuItem) { return 0; }
+	const char *getMenuItemLabel(const MenuItem &menuItem) { return 0; }
+
+	Button *getButtonListData() { return 0; }
+
+	Button *getScrollUpButton() { return 0; }
+	Button *getScrollDownButton() { return 0; }
+
+	Button::Callback getScrollUpButtonHandler() const { return Button::Callback(); }
+	Button::Callback getScrollDownButtonHandler() const { return Button::Callback(); }
+
+	uint8 defaultColor1() const { return 0xCF; }
+	uint8 defaultColor2() const { return 0xF8; }
+
+	KyraEngine_v3 *_vm;
+	Screen_v3 *_screen;
+
+	bool _buttonListChanged;
+	Button *_backUpButtonList;
+	Button *_unknownButtonList;
+};
+
+} // end of namespace Kyra
+
+#endif
+


Property changes on: scummvm/trunk/engines/kyra/gui_v3.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/kyra/items_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-26 20:33:59 UTC (rev 31734)
+++ scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-26 21:08:47 UTC (rev 31735)
@@ -522,7 +522,7 @@
 
 		playSoundEffect(0x0F, 0xC8);
 
-		_itemList[itemSlot].id = resItem;
+		_itemList[itemSlot].id = (resItem == 0xFF) ? 0xFFFF : resItem;
 
 		_screen->hideMouse();
 		deleteItemAnimEntry(itemSlot);
@@ -543,6 +543,79 @@
 	return false;
 }
 
+bool KyraEngine_v3::itemInventoryMagic(int handItem, int invSlot) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::itemInventoryMagic(%d, %d)", handItem, invSlot);
+
+	uint16 item = _mainCharacter.inventory[invSlot];
+	if (_curChapter == 1 && handItem == 3 && item == 3 && queryGameFlag(0x76)) {
+		//eelScript();
+		return true;
+	} else if ((handItem == 6 || handItem == 7) && item == 2) {
+		_screen->hideMouse();
+		playSoundEffect(0x93, 0xC8);
+		for (int i = 109; i <= 141; ++i) {
+			_mainCharacter.inventory[invSlot] = i;
+			_screen->drawShape(2, getShapePtr(invSlot+422), 0, 144, 0, 0);
+			_screen->drawShape(2, getShapePtr(i+248), 0, 144, 0, 0);
+			_screen->copyRegion(0, 144, _inventoryX[invSlot], _inventoryY[invSlot], 24, 20, 2, 0, Screen::CR_NO_P_CHECK);
+			_screen->updateScreen();
+			delay(1, true);
+		}
+
+		_mainCharacter.inventory[invSlot] = 0xFFFF;
+		clearInventorySlot(invSlot, 0);
+		_screen->showMouse();
+		return true;
+	}
+
+	if (_mainCharacter.sceneId == 51 && queryGameFlag(0x19B) && !queryGameFlag(0x19C)
+		&& ((item == 63 && handItem == 56) || (item == 56 && handItem == 63))) {
+		if (queryGameFlag(0x1AC)) {
+			setGameFlag(0x19C);
+			setGameFlag(0x1AD);
+		} else {
+			setGameFlag(0x1AE);
+		}
+		
+		_timer->setCountdown(12, 1);
+		_timer->enable(12);
+	}
+
+	for (int i = 0; _itemMagicTable[i] != 0xFF; i += 4) {
+		if (_itemMagicTable[i+0] != handItem || _itemMagicTable[i+1] != item)
+			continue;
+
+		uint8 resItem = _itemMagicTable[i+2];
+		uint8 newItem = _itemMagicTable[i+3];
+
+		playSoundEffect(0x0F, 0xC8);
+
+		_mainCharacter.inventory[invSlot] = (resItem == 0xFF) ? 0xFFFF : resItem;
+
+		_screen->hideMouse();
+		clearInventorySlot(invSlot, 0);
+		drawInventorySlot(0, resItem, invSlot);
+		
+		if (newItem == 0xFE)
+			removeHandItem();
+		else if (newItem != 0xFF)
+			setHandItem(newItem);
+		_screen->showMouse();
+
+		if (_lang != 1) {
+			if (resItem == 7) {
+				updateScore(35, 100);
+				delay(60, true);
+			}
+			updateItemCommand(resItem, 3, 0xFF);
+		}
+
+		return true;
+	}
+
+	return false;
+}
+
 int KyraEngine_v3::getItemCommandStringDrop(uint16 item) {
 	debugC(9, kDebugLevelMain, "KyraEngine_v3::getItemCommandStringDrop(%u)", item);
 	assert(item < _itemStringMapSize);

Modified: scummvm/trunk/engines/kyra/kyra_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-26 20:33:59 UTC (rev 31734)
+++ scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-26 21:08:47 UTC (rev 31735)
@@ -33,6 +33,7 @@
 #include "kyra/gui.h"
 #include "kyra/timer.h"
 #include "kyra/debugger.h"
+#include "kyra/gui_v3.h"
 
 #include "common/system.h"
 #include "common/config-manager.h"
@@ -132,6 +133,10 @@
 	_score = 0;
 	memset(_scoreFlagTable, 0, sizeof(_scoreFlagTable));
 	_debugger = 0;
+	_mainButtonData = 0;
+	_mainButtonList = 0;
+	_mainButtonListInitialized = false;
+	_enableInventory = true;
 }
 
 KyraEngine_v3::~KyraEngine_v3() {
@@ -191,6 +196,8 @@
 	delete [] _newShapeFiledata;
 	delete _invWsa;
 	delete _debugger;
+	delete [] _mainButtonData;
+	delete _gui;
 }
 
 int KyraEngine_v3::init() {
@@ -209,6 +216,8 @@
 		error("_soundDigital->init() failed");
 	KyraEngine::_text = _text = new TextDisplayer_v3(this, _screen);
 	assert(_text);
+	_gui = new GUI_v3(this);
+	assert(_gui);
 
 	_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
 	_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
@@ -601,7 +610,7 @@
 	musicUpdate(0);
 	loadMalcolmShapes(_malcolmShapes);
 	musicUpdate(0);
-	//initInventoryButtonList(1);
+	initMainButtonList(true);
 	loadInterfaceShapes();
 
 	musicUpdate(0);
@@ -1004,7 +1013,7 @@
 		if (_system->getMillis() >= _nextIdleAnim)
 			showIdleAnim();
 
-		int inputFlag = checkInput(0/*_mainButtonList*/);
+		int inputFlag = checkInput(_mainButtonList);
 		removeInputTop();
 
 		update();
@@ -1414,7 +1423,7 @@
 		_eventList.erase(_eventList.begin());
 	}
 
-	return /*_gui->processButtonList(buttonList, */keys/* | 0x8000)*/;
+	return _gui->processButtonList(buttonList, keys | 0x8000);
 }
 
 void KyraEngine_v3::removeInputTop() {

Modified: scummvm/trunk/engines/kyra/kyra_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-26 20:33:59 UTC (rev 31734)
+++ scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-26 21:08:47 UTC (rev 31735)
@@ -41,11 +41,13 @@
 class WSAMovieV2;
 class TextDisplayer_v3;
 class Debugger_v3;
+class GUI_v3;
 struct Button;
 
 class KyraEngine_v3 : public KyraEngine {
 friend class Debugger_v3;
 friend class TextDisplayer_v3;
+friend class GUI_v3;
 public:
 	KyraEngine_v3(OSystem *system, const GameFlags &flags);
 	~KyraEngine_v3();
@@ -145,7 +147,18 @@
 	int _curStudioSFX;
 	void playStudioSFX(const char *str);
 
-	// main menu
+	// gui
+	GUI_v3 *_gui;
+
+	Button *_mainButtonData;
+	Button *_mainButtonList;
+	bool _mainButtonListInitialized;
+	void initMainButtonList(bool disable);
+
+	bool _enableInventory;
+	int buttonInventory(Button *button);
+
+	// -> main menu
 	void initMainMenu();
 	void uninitMainMenu();
 
@@ -332,6 +345,7 @@
 
 	static const uint8 _itemMagicTable[];
 	bool itemListMagic(int handItem, int itemSlot);
+	bool itemInventoryMagic(int handItem, int invSlot);
 
 	static const uint8 _itemStringMap[];
 	static const uint _itemStringMapSize;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-04-26 20:33:59 UTC (rev 31734)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-04-26 21:08:47 UTC (rev 31735)
@@ -36,6 +36,8 @@
 #include "kyra/screen_v3.h"
 #include "kyra/resource.h"
 #include "kyra/gui_v1.h"
+#include "kyra/gui_v2.h"
+#include "kyra/gui_v3.h"
 
 #include "gui/message.h"
 
@@ -2430,5 +2432,40 @@
 
 const int KyraEngine_v3::_scoreTableSize = ARRAYSIZE(KyraEngine_v3::_scoreTable);
 
+void KyraEngine_v3::initMainButtonList(bool disable) {
+	if (!_mainButtonListInitialized) {
+		_mainButtonData = new Button[14];
+		assert(_mainButtonData);
+
+		GUI_V3_BUTTON(_mainButtonData[0], 1, 0, 0, 4, 4, 4, 0x4487, 0,   5, 162, 50, 25, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+		GUI_V3_BUTTON(_mainButtonData[1], 2, 0, 0, 1, 1, 1, 0x4487, 0, 245, 156, 69, 33, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+		GUI_V3_BUTTON(_mainButtonData[2], 3, 0, 0, 1, 1, 1, 0x4487, 0, 215, 191, 24,  9, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+		GUI_V3_BUTTON(_mainButtonData[3], 4, 0, 0, 1, 1, 1, 0x4487, 0, 215, 155, 25, 36, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+
+		Button::Callback buttonInventoryFunctor = BUTTON_FUNCTOR(KyraEngine_v3, this, &KyraEngine_v3::buttonInventory);
+		for (int i = 0; i < 5; ++i) {
+			GUI_V3_BUTTON(_mainButtonData[i+4], i+5, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 155, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+			_mainButtonData[i+4].buttonCallback = buttonInventoryFunctor;
+		}
+
+		for (int i = 0; i < 5; ++i) {
+			GUI_V3_BUTTON(_mainButtonData[i+9], i+10, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 177, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+			_mainButtonData[i+9].buttonCallback = buttonInventoryFunctor;
+		}
+
+		for (int i = 0; i < 14; ++i)
+			_mainButtonList = _gui->addButtonToList(_mainButtonList, &_mainButtonData[i]);
+
+		_mainButtonListInitialized = true;
+	}
+
+	for (int i = 0; i < 14; ++i) {
+		if (disable)
+			_gui->flagButtonDisable(&_mainButtonData[i]);
+		else
+			_gui->flagButtonEnable(&_mainButtonData[i]);
+	}
+}
+
 } // 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