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-12 19:57:23 +00:00
|
|
|
#ifndef SWORD2_MOUSE_H
|
|
|
|
#define SWORD2_MOUSE_H
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2007-02-20 17:41:26 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
|
2006-02-17 15:07:36 +00:00
|
|
|
#define MENU_MASTER_OBJECT 44
|
|
|
|
|
2005-04-24 12:13:03 +00:00
|
|
|
#define MAX_SUBJECT_LIST 30 // is that enough?
|
|
|
|
|
2006-02-17 15:07:36 +00:00
|
|
|
#define TOTAL_subjects (375 - 256 + 1) // the speech subject bar
|
|
|
|
#define TOTAL_engine_pockets (15 + 10) // +10 for overflow
|
2005-02-19 14:02:16 +00:00
|
|
|
#define TOTAL_mouse_list 50
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 18:50:09 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2006-02-23 17:51:27 +00:00
|
|
|
struct MenuObject;
|
2005-02-19 14:02:16 +00:00
|
|
|
struct BuildUnit;
|
|
|
|
|
2005-02-27 16:11:19 +00:00
|
|
|
// Menubar defines.
|
|
|
|
|
|
|
|
#define RDMENU_TOP 0
|
|
|
|
#define RDMENU_BOTTOM 1
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MOUSE_normal = 0, // normal in game
|
|
|
|
MOUSE_menu = 1, // menu chooser
|
|
|
|
MOUSE_drag = 2, // dragging luggage
|
|
|
|
MOUSE_system_menu = 3, // system menu chooser
|
|
|
|
MOUSE_holding = 4 // special
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RDMOUSE_NOFLASH,
|
|
|
|
RDMOUSE_FLASH
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RDMENU_HIDDEN,
|
|
|
|
RDMENU_SHOWN,
|
|
|
|
RDMENU_OPENING,
|
|
|
|
RDMENU_CLOSING,
|
|
|
|
RDMENU_ALMOST_HIDDEN
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RDMENU_ICONWIDE 35
|
2009-04-07 19:52:46 +00:00
|
|
|
#define RDMENU_PSXICONWIDE 36
|
2005-02-27 16:11:19 +00:00
|
|
|
#define RDMENU_ICONDEEP 30
|
|
|
|
#define RDMENU_ICONSTART 24
|
|
|
|
#define RDMENU_ICONSPACING 5
|
|
|
|
#define RDMENU_MAXPOCKETS 15
|
|
|
|
|
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
|
|
|
#define MOUSE_ANIM_HEADER_SIZE 6
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
struct MouseAnim {
|
|
|
|
uint8 runTimeComp; // type of runtime compression used for the
|
|
|
|
// frame data
|
|
|
|
uint8 noAnimFrames; // number of frames in the anim
|
2005-07-30 21:11:48 +00:00
|
|
|
int8 xHotSpot;
|
2005-02-19 14:02:16 +00:00
|
|
|
int8 yHotSpot;
|
|
|
|
uint8 mousew;
|
|
|
|
uint8 mouseh;
|
|
|
|
|
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 *data;
|
|
|
|
};
|
2003-09-19 16:08:54 +00:00
|
|
|
|
2003-11-12 08:21:18 +00:00
|
|
|
// The MOUSE_holding mode is entered when the conversation menu is closed, and
|
|
|
|
// exited when the mouse cursor moves off that menu area. I don't know why yet.
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-12-28 15:08:12 +00:00
|
|
|
// mouse unit - like ObjectMouse, but with anim resource & pc (needed if
|
2003-09-19 16:08:54 +00:00
|
|
|
// sprite is to act as mouse detection mask)
|
|
|
|
|
2003-12-28 15:08:12 +00:00
|
|
|
struct MouseUnit {
|
2005-02-28 14:03:53 +00:00
|
|
|
// Basically the same information as in ObjectMouse, except the
|
|
|
|
// coordinates are adjusted to conform to standard ScummVM usage.
|
2003-09-19 16:08:54 +00:00
|
|
|
|
2005-02-28 14:03:53 +00:00
|
|
|
Common::Rect rect;
|
2003-09-19 16:08:54 +00:00
|
|
|
int32 priority;
|
|
|
|
int32 pointer;
|
|
|
|
|
2005-02-28 14:03:53 +00:00
|
|
|
// In addition, we need an id when checking the mouse list, and a
|
|
|
|
// text id for mouse-overs.
|
2003-09-19 16:08:54 +00:00
|
|
|
|
|
|
|
int32 id;
|
|
|
|
int32 pointer_text;
|
2003-11-02 18:50:09 +00:00
|
|
|
};
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-04-24 12:13:03 +00:00
|
|
|
// Array of these for subject menu build up
|
|
|
|
|
|
|
|
struct SubjectUnit {
|
|
|
|
uint32 res;
|
|
|
|
uint32 ref;
|
|
|
|
};
|
|
|
|
|
2006-02-17 15:07:36 +00:00
|
|
|
// define these in a script and then register them with the system
|
|
|
|
|
|
|
|
struct MenuObject {
|
|
|
|
int32 icon_resource; // icon graphic graphic
|
|
|
|
int32 luggage_resource; // luggage icon resource (for attaching to
|
|
|
|
// mouse pointer)
|
|
|
|
};
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
class Mouse {
|
|
|
|
private:
|
|
|
|
Sword2Engine *_vm;
|
|
|
|
|
|
|
|
MouseUnit _mouseList[TOTAL_mouse_list];
|
|
|
|
uint32 _curMouse;
|
|
|
|
|
|
|
|
MenuObject _tempList[TOTAL_engine_pockets];
|
|
|
|
uint32 _totalTemp;
|
|
|
|
|
|
|
|
MenuObject _masterMenuList[TOTAL_engine_pockets];
|
|
|
|
uint32 _totalMasters;
|
|
|
|
|
2005-04-24 12:13:03 +00:00
|
|
|
SubjectUnit _subjectList[MAX_SUBJECT_LIST];
|
|
|
|
|
|
|
|
// ref number for default response when luggage icon is used on a
|
|
|
|
// person & it doesn't match any of the icons which would have been in
|
|
|
|
// the chooser
|
|
|
|
|
|
|
|
uint32 _defaultResponseId;
|
|
|
|
|
|
|
|
// could alternately use logic->looping of course
|
|
|
|
bool _choosing;
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
uint8 _menuStatus[2];
|
|
|
|
byte *_icons[2][RDMENU_MAXPOCKETS];
|
|
|
|
uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
|
|
|
|
|
|
|
|
uint8 _iconCount;
|
|
|
|
|
|
|
|
// If it's NORMAL_MOUSE_ID (ie. normal pointer) then it's over a floor
|
|
|
|
// area (or hidden hot-zone)
|
|
|
|
|
|
|
|
uint32 _mousePointerRes;
|
|
|
|
|
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
|
|
|
MouseAnim _mouseAnim;
|
|
|
|
MouseAnim _luggageAnim;
|
2005-02-19 14:02:16 +00:00
|
|
|
|
|
|
|
uint8 _mouseFrame;
|
|
|
|
|
|
|
|
uint32 _mouseMode;
|
|
|
|
|
|
|
|
bool _mouseStatus; // Human 0 on/1 off
|
|
|
|
bool _mouseModeLocked; // 0 not !0 mode cannot be changed from
|
|
|
|
// normal mouse to top menu (i.e. when
|
|
|
|
// carrying big objects)
|
|
|
|
uint32 _realLuggageItem; // Last minute for pause mode
|
|
|
|
uint32 _currentLuggageResource;
|
|
|
|
uint32 _oldButton; // For the re-click stuff - must be
|
|
|
|
// the same button you see
|
|
|
|
uint32 _buttonClick;
|
|
|
|
uint32 _pointerTextBlocNo;
|
|
|
|
uint32 _playerActivityDelay; // Player activity delay counter
|
|
|
|
|
|
|
|
bool _examiningMenuIcon;
|
|
|
|
|
|
|
|
// Set by checkMouseList()
|
|
|
|
uint32 _mouseTouching;
|
|
|
|
uint32 _oldMouseTouching;
|
|
|
|
|
2005-02-20 15:38:48 +00:00
|
|
|
bool _objectLabels;
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
uint32 _menuSelectedPos;
|
|
|
|
|
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 decompressMouse(byte *decomp, byte *comp, uint8 frame, int width, int height, int pitch, int xOff = 0, int yOff = 0);
|
2005-02-19 14:02:16 +00:00
|
|
|
|
|
|
|
int32 setMouseAnim(byte *ma, int32 size, int32 mouseFlash);
|
|
|
|
int32 setLuggageAnim(byte *la, int32 size);
|
|
|
|
|
|
|
|
void clearIconArea(int menu, int pocket, Common::Rect *r);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Mouse(Sword2Engine *vm);
|
|
|
|
~Mouse();
|
|
|
|
|
|
|
|
void getPos(int &x, int &y);
|
2007-03-18 12:53:28 +00:00
|
|
|
int getX();
|
|
|
|
int getY();
|
2005-02-19 14:02:16 +00:00
|
|
|
|
2005-02-20 15:38:48 +00:00
|
|
|
bool getObjectLabels() { return _objectLabels; }
|
|
|
|
void setObjectLabels(bool b) { _objectLabels = b; }
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
bool getMouseStatus() { return _mouseStatus; }
|
|
|
|
uint32 getMouseTouching() { return _mouseTouching; }
|
|
|
|
void setMouseTouching(uint32 touching) { _mouseTouching = touching; }
|
|
|
|
|
2008-05-23 17:54:47 +00:00
|
|
|
void pauseEngine(bool pause);
|
2005-02-19 14:02:16 +00:00
|
|
|
|
|
|
|
void setMouse(uint32 res);
|
|
|
|
void setLuggage(uint32 res);
|
|
|
|
|
|
|
|
void setObjectHeld(uint32 res);
|
|
|
|
|
|
|
|
void resetMouseList();
|
|
|
|
|
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 registerMouse(byte *ob_mouse, BuildUnit *build_unit);
|
2005-02-19 14:02:16 +00:00
|
|
|
void registerPointerText(int32 text_id);
|
|
|
|
|
|
|
|
void createPointerText(uint32 text_id, uint32 pointer_res);
|
|
|
|
void clearPointerText();
|
|
|
|
|
|
|
|
void drawMouse();
|
|
|
|
int32 animateMouse();
|
|
|
|
|
|
|
|
void processMenu();
|
|
|
|
|
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 addMenuObject(byte *ptr);
|
2005-04-24 12:13:03 +00:00
|
|
|
void addSubject(int32 id, int32 ref);
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
void buildMenu();
|
|
|
|
void buildSystemMenu();
|
|
|
|
|
|
|
|
int32 showMenu(uint8 menu);
|
|
|
|
int32 hideMenu(uint8 menu);
|
|
|
|
int32 setMenuIcon(uint8 menu, uint8 pocket, byte *icon);
|
|
|
|
|
|
|
|
void closeMenuImmediately();
|
|
|
|
|
|
|
|
void refreshInventory();
|
|
|
|
|
|
|
|
void startConversation();
|
|
|
|
void endConversation();
|
|
|
|
|
|
|
|
void hideMouse();
|
|
|
|
void noHuman();
|
|
|
|
void addHuman();
|
|
|
|
|
|
|
|
void resetPlayerActivityDelay() { _playerActivityDelay = 0; }
|
|
|
|
void monitorPlayerActivity();
|
|
|
|
void checkPlayerActivity(uint32 seconds);
|
|
|
|
|
|
|
|
void mouseOnOff();
|
|
|
|
uint32 checkMouseList();
|
|
|
|
void mouseEngine();
|
|
|
|
|
|
|
|
void normalMouse();
|
|
|
|
void menuMouse();
|
|
|
|
void dragMouse();
|
|
|
|
void systemMenuMouse();
|
|
|
|
|
2005-04-24 12:13:03 +00:00
|
|
|
bool isChoosing() { return _choosing; }
|
|
|
|
uint32 chooseMouse();
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
int menuClick(int menu_items);
|
2009-04-07 19:52:46 +00:00
|
|
|
|
|
|
|
int getMouseMode();
|
|
|
|
|
|
|
|
void setMouseMode(int mouseMode); // Used to force mouse mode
|
2005-02-19 14:02:16 +00:00
|
|
|
};
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#endif
|