2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2003-07-28 01:44:38 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2006-02-09 15:12:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
#include "common/stream.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/defs.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/logic.h"
|
2005-02-19 14:02:16 +00:00
|
|
|
#include "sword2/mouse.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/resman.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
void Mouse::addMenuObject(byte *ptr) {
|
2004-04-04 15:16:05 +00:00
|
|
|
assert(_totalTemp < TOTAL_engine_pockets);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
|
|
|
|
Common::MemoryReadStream readS(ptr, 2 * sizeof(int32));
|
|
|
|
|
|
|
|
_tempList[_totalTemp].icon_resource = readS.readSint32LE();
|
|
|
|
_tempList[_totalTemp].luggage_resource = readS.readSint32LE();
|
2004-04-04 15:16:05 +00:00
|
|
|
_totalTemp++;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-04-24 12:13:03 +00:00
|
|
|
void Mouse::addSubject(int32 id, int32 ref) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint32 in_subject = _vm->_logic->readVar(IN_SUBJECT);
|
|
|
|
|
|
|
|
if (in_subject == 0) {
|
2005-04-24 12:13:03 +00:00
|
|
|
// This is the start of the new subject list. Set the default
|
|
|
|
// repsonse id to zero in case we're never passed one.
|
|
|
|
_defaultResponseId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id == -1) {
|
|
|
|
// Id -1 is used for setting the default response, i.e. the
|
|
|
|
// response when someone uses an object on a person and he
|
|
|
|
// doesn't know anything about it. See fnChoose().
|
|
|
|
|
|
|
|
_defaultResponseId = ref;
|
|
|
|
} else {
|
|
|
|
debug(5, "fnAddSubject res %d, uid %d", id, ref);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_subjectList[in_subject].res = id;
|
|
|
|
_subjectList[in_subject].ref = ref;
|
|
|
|
_vm->_logic->writeVar(IN_SUBJECT, in_subject + 1);
|
2005-04-24 12:13:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
/**
|
|
|
|
* Create and start the inventory (bottom) menu
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
void Mouse::buildMenu() {
|
2004-04-04 15:16:05 +00:00
|
|
|
uint32 i, j;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Clear the temporary inventory list, since we are going to build a
|
|
|
|
// new one from scratch.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
for (i = 0; i < TOTAL_engine_pockets; i++)
|
|
|
|
_tempList[i].icon_resource = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
_totalTemp = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Run the 'build_menu' script in the 'menu_master' object. This will
|
|
|
|
// register all carried menu objects.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_vm->_logic->runResScript(MENU_MASTER_OBJECT, 0);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Create a new master list based on the old master inventory list and
|
|
|
|
// the new temporary inventory list. The purpose of all this is, as
|
|
|
|
// far as I can tell, that the new list is ordered in the same way as
|
|
|
|
// the old list, with new objects added to the end of it.
|
|
|
|
|
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
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
for (i = 0; i < _totalMasters; i++) {
|
|
|
|
bool found_in_temp = false;
|
|
|
|
|
|
|
|
for (j = 0; j < TOTAL_engine_pockets; j++) {
|
|
|
|
if (_masterMenuList[i].icon_resource == _tempList[j].icon_resource) {
|
|
|
|
// We alread know about this object, so kill it
|
|
|
|
// in the temporary list.
|
|
|
|
_tempList[j].icon_resource = 0;
|
|
|
|
found_in_temp = true;
|
|
|
|
break;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-04-04 15:16:05 +00:00
|
|
|
|
|
|
|
if (!found_in_temp) {
|
|
|
|
// The object is in the master list, but not in the
|
|
|
|
// temporary list. The player must have lost the object
|
|
|
|
// since the last time we checked, so kill it in the
|
|
|
|
// master list.
|
|
|
|
_masterMenuList[i].icon_resource = 0;
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Eliminate blank entries from the master list.
|
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
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
for (i = 0; i < TOTAL_engine_pockets; i++) {
|
|
|
|
if (_masterMenuList[i].icon_resource) {
|
|
|
|
if (i != _totalMasters) {
|
|
|
|
memcpy(&_masterMenuList[_totalMasters], &_masterMenuList[i], sizeof(MenuObject));
|
|
|
|
_masterMenuList[i].icon_resource = 0;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Add the new objects - i.e. the ones still in the temporary list but
|
|
|
|
// not yet in the master list - to the end of the master.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
for (i = 0; i < TOTAL_engine_pockets; i++) {
|
|
|
|
if (_tempList[i].icon_resource) {
|
|
|
|
memcpy(&_masterMenuList[_totalMasters++], &_tempList[i], sizeof(MenuObject));
|
2003-09-17 16:59:12 +00:00
|
|
|
}
|
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Initialise the menu from the master list.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
for (i = 0; i < 15; i++) {
|
|
|
|
uint32 res = _masterMenuList[i].icon_resource;
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *icon = NULL;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
if (res) {
|
|
|
|
bool icon_coloured;
|
2003-09-17 16:59:12 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
uint32 object_held = _vm->_logic->readVar(OBJECT_HELD);
|
|
|
|
uint32 combine_base = _vm->_logic->readVar(COMBINE_BASE);
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
if (_examiningMenuIcon) {
|
|
|
|
// When examining an object, that object is
|
|
|
|
// coloured. The rest are greyed out.
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
icon_coloured = (res == object_held);
|
|
|
|
} else if (combine_base) {
|
2004-04-04 15:16:05 +00:00
|
|
|
// When combining two menu object (i.e. using
|
|
|
|
// one on another), both are coloured. The rest
|
|
|
|
// are greyed out.
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
icon_coloured = (res == object_held || combine_base);
|
2003-09-17 16:59:12 +00:00
|
|
|
} else {
|
2004-04-04 15:16:05 +00:00
|
|
|
// If an object is selected but we are not yet
|
|
|
|
// doing anything with it, the selected object
|
|
|
|
// is greyed out. The rest are coloured.
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
icon_coloured = (res != object_held);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
icon = _vm->_resman->openResource(res) + ResHeader::size();
|
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);
|
2004-04-04 15:16:05 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
setMenuIcon(RDMENU_BOTTOM, i, icon);
|
2004-04-04 15:16:05 +00:00
|
|
|
|
|
|
|
if (res)
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_resman->closeResource(res);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
showMenu(RDMENU_BOTTOM);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
/**
|
|
|
|
* Build a fresh system (top) menu.
|
|
|
|
*/
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
void Mouse::buildSystemMenu() {
|
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
|
|
|
|
};
|
|
|
|
|
2004-04-04 15:16:05 +00:00
|
|
|
// Build them all high in full colour - when one is clicked on all the
|
|
|
|
// rest will grey out.
|
2003-09-17 16:59:12 +00:00
|
|
|
|
2003-11-03 07:47:42 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(icon_list); i++) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
byte *icon = _vm->_resman->openResource(icon_list[i]) + ResHeader::size();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
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
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (!_vm->_logic->readVar(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
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
setMenuIcon(RDMENU_TOP, i, icon);
|
|
|
|
_vm->_resman->closeResource(icon_list[i]);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
showMenu(RDMENU_TOP);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword2
|