2003-07-28 01:44:38 +00:00
|
|
|
/* Copyright (C) 1994-2003 Revolution Software Ltd
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
|
|
|
#include "sword2/defs.h"
|
|
|
|
#include "sword2/interpreter.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2003-10-18 08:11:50 +00:00
|
|
|
int32 Logic::fnAddMenuObject(int32 *params) {
|
|
|
|
// params: 0 pointer to a menu_object structure to copy down
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-08 15:47:51 +00:00
|
|
|
assert(_vm->_totalTemp < TOTAL_engine_pockets);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// copy the structure to our in-the-engine list
|
2003-11-16 14:18:29 +00:00
|
|
|
memcpy(&_vm->_tempList[_vm->_totalTemp], _vm->_memory->intToPtr(params[0]), sizeof(menu_object));
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->_totalTemp++;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// script continue
|
|
|
|
return IR_CONT;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-09-17 16:59:12 +00:00
|
|
|
|
2003-10-18 08:11:50 +00:00
|
|
|
int32 Logic::fnRefreshInventory(int32 *params) {
|
2003-07-28 01:44:38 +00:00
|
|
|
// called from 'menu_look_or_combine' script in 'menu_master' object
|
2003-09-17 16:59:12 +00:00
|
|
|
// to update the menu to display a combined object while George runs
|
|
|
|
// voice-over. Note that 'object_held' must be set to the graphic of
|
|
|
|
// the combined object
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-18 08:11:50 +00:00
|
|
|
// params: none
|
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// can reset this now
|
|
|
|
COMBINE_BASE = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// so that the icon in 'object_held' is coloured while the rest are
|
|
|
|
// grey
|
2003-11-08 15:47:51 +00:00
|
|
|
_vm->_examiningMenuIcon = true;
|
|
|
|
_vm->buildMenu();
|
|
|
|
_vm->_examiningMenuIcon = false;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// script continue
|
|
|
|
return IR_CONT;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
void Sword2Engine::buildMenu(void) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// create and start the inventory menu - NOW AT THE BOTTOM OF THE
|
|
|
|
// SCREEN!
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
uint32 null_pc = 0;
|
|
|
|
uint32 j, k;
|
2003-11-02 18:50:09 +00:00
|
|
|
bool icon_coloured;
|
2003-09-17 16:59:12 +00:00
|
|
|
uint8 *icon;
|
|
|
|
uint8 *head;
|
|
|
|
uint32 res;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// reset temp list which will be totally rebuilt
|
2003-11-02 15:58:45 +00:00
|
|
|
_totalTemp = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
debug(5, "build top menu %d", _totalMasters);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// clear the temp list before building a new temp list in-case list
|
|
|
|
// gets smaller. check each master
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
for (j = 0; j < TOTAL_engine_pockets; j++)
|
2003-11-02 15:58:45 +00:00
|
|
|
_tempList[j].icon_resource = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// Call menu builder script which will register all carried menu
|
|
|
|
// objects. Run the 'build_menu' script in the 'menu_master' object
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
head = _resman->openResource(MENU_MASTER_OBJECT);
|
2003-11-15 09:38:00 +00:00
|
|
|
_logic->runScript((char*) head, (char*) head, &null_pc);
|
2003-11-16 14:18:29 +00:00
|
|
|
_resman->closeResource(MENU_MASTER_OBJECT);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// Compare new with old. Anything in master thats not in new gets
|
|
|
|
// removed from master - if found in new too, remove from temp
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_totalMasters) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// check each master
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
for (j = 0; j < _totalMasters; j++) {
|
2003-09-17 16:59:12 +00:00
|
|
|
for (k = 0; k < TOTAL_engine_pockets; k++) {
|
|
|
|
res = 0;
|
|
|
|
// if master is in temp
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_masterMenuList[j].icon_resource == _tempList[k].icon_resource) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// kill it in the temp
|
2003-11-02 15:58:45 +00:00
|
|
|
_tempList[k].icon_resource = 0;
|
2003-09-17 16:59:12 +00:00
|
|
|
res = 1;
|
2003-07-28 01:44:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-09-17 16:59:12 +00:00
|
|
|
if (!res) {
|
|
|
|
// otherwise not in temp so kill in main
|
2003-11-02 15:58:45 +00:00
|
|
|
_masterMenuList[j].icon_resource = 0;
|
2003-09-27 11:02:58 +00:00
|
|
|
debug(5, "Killed menu %d", j);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// merge master downwards
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
_totalMasters = 0;
|
2003-09-17 16:59:12 +00:00
|
|
|
|
|
|
|
//check each master slot
|
|
|
|
|
|
|
|
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
|
|
|
// not current end - meaning out over the end so move down
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_masterMenuList[j].icon_resource && j != _totalMasters) {
|
|
|
|
memcpy(&_masterMenuList[_totalMasters++], &_masterMenuList[j], sizeof(menu_object));
|
2003-09-17 16:59:12 +00:00
|
|
|
|
|
|
|
// moved down now so kill here
|
2003-11-02 15:58:45 +00:00
|
|
|
_masterMenuList[j].icon_resource = 0;
|
|
|
|
} else if (_masterMenuList[j].icon_resource) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// skip full slots
|
2003-11-02 15:58:45 +00:00
|
|
|
_totalMasters++;
|
2003-09-17 16:59:12 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// add those new to menu still in temp but not yet in master to the
|
|
|
|
// end of the master
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// check each master slot
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_tempList[j].icon_resource) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// here's a new temp
|
2003-11-02 15:58:45 +00:00
|
|
|
memcpy(&_masterMenuList[_totalMasters++], &_tempList[j], sizeof(menu_object));
|
2003-09-17 16:59:12 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// init top menu from master list
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
for (j = 0; j < 15; j++) {
|
2003-11-02 15:58:45 +00:00
|
|
|
if (_masterMenuList[j].icon_resource) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// 'res' is now the resource id of the icon
|
2003-11-02 15:58:45 +00:00
|
|
|
res = _masterMenuList[j].icon_resource;
|
2003-09-17 16:59:12 +00:00
|
|
|
|
2003-11-02 18:50:09 +00:00
|
|
|
if (_examiningMenuIcon) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
|
|
|
|
// 'EXAMINE' - SELECTION COLOURED, THE REST
|
|
|
|
// GREYED OUT
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// If this is the icon being examined, make
|
|
|
|
// it coloured. If not, grey this one out.
|
|
|
|
|
|
|
|
if (res == OBJECT_HELD)
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = true;
|
2003-07-28 01:44:38 +00:00
|
|
|
else
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = false;
|
2003-09-17 16:59:12 +00:00
|
|
|
} else if (COMBINE_BASE) {
|
|
|
|
// WHEN ONE MENU OBJECT IS BEING USED WITH
|
|
|
|
// ANOTHER - BOTH TO BE COLOURED, THE REST
|
|
|
|
// GREYED OUT
|
|
|
|
|
|
|
|
// if this if either of the icons being
|
|
|
|
// combined...
|
|
|
|
|
|
|
|
if (res == OBJECT_HELD || res == COMBINE_BASE)
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = true;
|
2003-09-17 16:59:12 +00:00
|
|
|
else
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = false;
|
2003-09-17 16:59:12 +00:00
|
|
|
} else {
|
|
|
|
// NORMAL ICON SELECTION - SELECTION GREYED
|
|
|
|
// OUT, THE REST COLOURED
|
|
|
|
|
|
|
|
// If this is the selction, grey it out. If
|
|
|
|
// not, make it coloured.
|
|
|
|
|
|
|
|
if (res == OBJECT_HELD)
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = false;
|
2003-09-17 16:59:12 +00:00
|
|
|
else
|
2003-11-02 18:50:09 +00:00
|
|
|
icon_coloured = true;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
icon = _resman->openResource(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// The coloured icon is stored directly after the
|
|
|
|
// greyed out one.
|
|
|
|
|
|
|
|
if (icon_coloured)
|
|
|
|
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_graphics->setMenuIcon(RDMENU_BOTTOM, j, icon);
|
|
|
|
_resman->closeResource(res);
|
2003-09-17 16:59:12 +00:00
|
|
|
} else {
|
|
|
|
// no icon here
|
2003-11-16 14:18:29 +00:00
|
|
|
_graphics->setMenuIcon(RDMENU_BOTTOM, j, NULL);
|
2003-09-27 11:02:58 +00:00
|
|
|
debug(5, " NULL for %d", j);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_graphics->showMenu(RDMENU_BOTTOM);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 15:58:45 +00:00
|
|
|
void Sword2Engine::buildSystemMenu(void) {
|
2003-09-17 16:59:12 +00:00
|
|
|
// start a fresh top system menu
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
uint8 *icon;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
uint32 icon_list[5] = {
|
2003-07-28 01:44:38 +00:00
|
|
|
OPTIONS_ICON,
|
|
|
|
QUIT_ICON,
|
|
|
|
SAVE_ICON,
|
|
|
|
RESTORE_ICON,
|
|
|
|
RESTART_ICON
|
|
|
|
};
|
|
|
|
|
2003-09-17 16:59:12 +00:00
|
|
|
// build them all high in full colour - when one is clicked on all the
|
|
|
|
// rest will grey out
|
|
|
|
|
2003-11-03 07:47:42 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(icon_list); i++) {
|
2003-11-16 14:18:29 +00:00
|
|
|
icon = _resman->openResource(icon_list[i]) + sizeof(_standardHeader);
|
2003-09-17 16:59:12 +00:00
|
|
|
|
|
|
|
// The only case when an icon is grayed is when the player
|
|
|
|
// is dead. Then SAVE is not available.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-03 07:47:42 +00:00
|
|
|
if (!DEAD || icon_list[i] != SAVE_ICON)
|
2003-09-17 16:59:12 +00:00
|
|
|
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_graphics->setMenuIcon(RDMENU_TOP, i, icon);
|
|
|
|
_resman->closeResource(icon_list[i]);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-16 14:18:29 +00:00
|
|
|
_graphics->showMenu(RDMENU_TOP);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword2
|