Even more stuff moving into Sword2Engine. I'm tempted to make a new class

for the mouse stuff, but I need to think about that a bit more. I have a
feeling the code could be cleaned up a bit anyway...

svn-id: r11060
This commit is contained in:
Torbjörn Andersson 2003-11-02 18:50:09 +00:00
parent c58b3819bb
commit 7ec257ae3f
11 changed files with 383 additions and 410 deletions

View File

@ -212,8 +212,8 @@ void Sword2Engine::displayMsg(uint8 *text, int time) {
g_display->waitForFade();
}
Set_mouse(0);
Set_luggage(0);
setMouse(0);
setLuggage(0);
g_display->closeMenuImmediately();
g_display->clearScene();
@ -654,20 +654,20 @@ void Sword2Engine::registerFrame(int32 *params, buildit *build_unit) {
build_unit->sort_y = build_unit->y + build_unit->scaled_height - 1;
if (params[0]) {
// passed a mouse structure, so add to the mouse_list
// passed a mouse structure, so add to the _mouseList
ob_mouse = (Object_mouse *) params[0];
// only if 'pointer' isn't NULL
if (ob_mouse->pointer) {
assert(cur_mouse < TOTAL_mouse_list);
assert(_curMouse < TOTAL_mouse_list);
mouse_list[cur_mouse].x1 = build_unit->x;
mouse_list[cur_mouse].y1 = build_unit->y;
mouse_list[cur_mouse].x2 = build_unit->x + build_unit->scaled_width;
mouse_list[cur_mouse].y2 = build_unit->y + build_unit->scaled_height;
_mouseList[_curMouse].x1 = build_unit->x;
_mouseList[_curMouse].y1 = build_unit->y;
_mouseList[_curMouse].x2 = build_unit->x + build_unit->scaled_width;
_mouseList[_curMouse].y2 = build_unit->y + build_unit->scaled_height;
mouse_list[cur_mouse].priority = ob_mouse->priority;
mouse_list[cur_mouse].pointer = ob_mouse->pointer;
_mouseList[_curMouse].priority = ob_mouse->priority;
_mouseList[_curMouse].pointer = ob_mouse->pointer;
// check if pointer text field is set due to previous
// object using this slot (ie. not correct for this
@ -677,15 +677,15 @@ void Sword2Engine::registerFrame(int32 *params, buildit *build_unit) {
// isn't same is current id
// then we don't want this "left over" pointer text
if (mouse_list[cur_mouse].pointer_text && mouse_list[cur_mouse].id != (int32) ID)
mouse_list[cur_mouse].pointer_text=0;
if (_mouseList[_curMouse].pointer_text && _mouseList[_curMouse].id != (int32) ID)
_mouseList[_curMouse].pointer_text=0;
mouse_list[cur_mouse].id = ID;
_mouseList[_curMouse].id = ID;
// not using sprite as detection mask
mouse_list[cur_mouse].anim_resource = 0;
mouse_list[cur_mouse].anim_pc = 0;
_mouseList[_curMouse].anim_resource = 0;
_mouseList[_curMouse].anim_pc = 0;
cur_mouse++;
_curMouse++;
}
}

View File

@ -380,7 +380,7 @@ bool Debugger::Cmd_SaveGame(int argc, const char **argv) {
}
// if mouse if off, or system menu is locked off
if (mouse_status || mouse_mode_locked) {
if (g_sword2->_mouseStatus || g_sword2->_mouseModeLocked) {
DebugPrintf("WARNING: Cannot save game while control menu unavailable!\n");
return true;
}
@ -428,7 +428,7 @@ bool Debugger::Cmd_RestoreGame(int argc, const char **argv) {
}
// if mouse if off, or system menu is locked off
if (mouse_status || mouse_mode_locked) {
if (g_sword2->_mouseStatus || g_sword2->_mouseModeLocked) {
DebugPrintf("WARNING: Cannot restore game while control menu unavailable!\n");
return true;
}

View File

@ -1293,7 +1293,7 @@ public:
// Reset the mouse hot-spot list (see
// fnRegisterMouse and fnRegisterFrame)
Reset_mouse_list();
g_sword2->resetMouseList();
if (g_logic.processSession())
error("restore 1st cycle failed??");
@ -1465,7 +1465,7 @@ void Gui::restartControl(void) {
// reset the mouse hot-spot list (see fnRegisterMouse and
// fnRegisterFrame)
Reset_mouse_list();
g_sword2->resetMouseList();
g_display->closeMenuImmediately();

View File

@ -185,12 +185,12 @@ void Debugger::buildDebugText(void) {
makeDebugTextBlock(buf, 0, 15);
if (mouse_touching)
if (g_sword2->_mouseTouching)
sprintf(buf, "mouse %d,%d (id %d: %s)",
g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,
g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y,
mouse_touching,
FetchObjectName(mouse_touching));
g_sword2->_mouseTouching,
FetchObjectName(g_sword2->_mouseTouching));
else
sprintf(buf, "mouse %d,%d (not touching)",
g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,

View File

@ -54,9 +54,9 @@ int32 Logic::fnRefreshInventory(int32 *params) {
// so that the icon in 'object_held' is coloured while the rest are
// grey
examining_menu_icon = 1;
g_sword2->_examiningMenuIcon = true;
g_sword2->buildMenu();
examining_menu_icon = 0;
g_sword2->_examiningMenuIcon = false;
// script continue
return IR_CONT;
@ -68,7 +68,7 @@ void Sword2Engine::buildMenu(void) {
uint32 null_pc = 0;
uint32 j, k;
uint8 icon_coloured;
bool icon_coloured;
uint8 *icon;
uint8 *head;
uint32 res;
@ -154,7 +154,7 @@ void Sword2Engine::buildMenu(void) {
// 'res' is now the resource id of the icon
res = _masterMenuList[j].icon_resource;
if (examining_menu_icon) {
if (_examiningMenuIcon) {
// WHEN AN ICON HAS BEEN RIGHT-CLICKED FOR
// 'EXAMINE' - SELECTION COLOURED, THE REST
// GREYED OUT
@ -163,9 +163,9 @@ void Sword2Engine::buildMenu(void) {
// it coloured. If not, grey this one out.
if (res == OBJECT_HELD)
icon_coloured = 1;
icon_coloured = true;
else
icon_coloured = 0;
icon_coloured = false;
} else if (COMBINE_BASE) {
// WHEN ONE MENU OBJECT IS BEING USED WITH
// ANOTHER - BOTH TO BE COLOURED, THE REST
@ -175,9 +175,9 @@ void Sword2Engine::buildMenu(void) {
// combined...
if (res == OBJECT_HELD || res == COMBINE_BASE)
icon_coloured = 1;
icon_coloured = true;
else
icon_coloured = 0;
icon_coloured = false;
} else {
// NORMAL ICON SELECTION - SELECTION GREYED
// OUT, THE REST COLOURED
@ -186,9 +186,9 @@ void Sword2Engine::buildMenu(void) {
// not, make it coloured.
if (res == OBJECT_HELD)
icon_coloured = 0;
icon_coloured = false;
else
icon_coloured = 1;
icon_coloured = true;
}
icon = res_man.open(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);

File diff suppressed because it is too large Load Diff

View File

@ -22,20 +22,22 @@
#include "sword2/object.h"
namespace Sword2 {
#define TOTAL_mouse_list 50
#define MOUSE_normal 0
#define MOUSE_menu 1
#define MOUSE_drag 2
#define MOUSE_system_menu 3
#define MOUSE_holding 4
namespace Sword2 {
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 // speech chooser
};
// mouse unit - like Object_mouse, but with anim resource & pc (needed if
// sprite is to act as mouse detection mask)
typedef struct {
struct Mouse_unit {
// Top-left and bottom-right of mouse area. These coords are inclusive
int32 x1;
int32 y1;
@ -62,39 +64,7 @@ typedef struct {
// local id of text line to print when pointer highlights an object
int32 pointer_text;
} Mouse_unit;
extern uint32 cur_mouse;
extern Mouse_unit mouse_list[TOTAL_mouse_list];
extern uint32 mouse_touching;
extern uint32 mouse_mode;
extern uint8 examining_menu_icon;
// human 0 on/1 off
extern uint32 mouse_status;
// 0 not !0 mode cannot be changed from normal mouse to top menu (i.e. when
// carrying big objects)
extern uint32 mouse_mode_locked;
//last minute for pause mode
extern uint32 real_luggage_item;
void Reset_mouse_list(void);
void Normal_mouse(void);
void Menu_mouse(void);
void Drag_mouse(void);
void System_menu_mouse(void);
void Mouse_on_off(void);
uint32 Check_mouse_list(void);
void Mouse_engine(void);
void Set_mouse(uint32 res);
void Set_luggage(uint32 res);
void ClearPointerText(void);
};
} // End of namespace Sword2

View File

@ -30,7 +30,7 @@
#include "sword2/logic.h"
#include "sword2/maketext.h"
#include "sword2/memory.h"
#include "sword2/mouse.h" // for system Set_mouse & Set_luggage routines
#include "sword2/mouse.h" // for system setMouse & setLuggage routines
#include "sword2/protocol.h"
#include "sword2/resman.h"
#include "sword2/sound.h" // for Clear_fx_queue() called from cacheNewCluster()
@ -998,7 +998,7 @@ void ResourceManager::cacheNewCluster(uint32 newCluster) {
if (file == NULL) {
error("init cannot *OPEN* cd.inf");
}
}
_cd_inf cdInf;
@ -1027,8 +1027,8 @@ void ResourceManager::cacheNewCluster(uint32 newCluster) {
g_display->clearScene();
Set_mouse(0);
Set_luggage(0);
g_sword2->setMouse(0);
g_sword2->setLuggage(0);
uint8 *bgfile;
bgfile = res_man.open(2950); // open the screen resource

View File

@ -231,7 +231,7 @@ int32 Logic::fnChoose(int32 *params) {
g_display->showMenu(RDMENU_BOTTOM);
// lets have the mouse pointer back
Set_mouse(NORMAL_MOUSE_ID);
g_sword2->setMouse(NORMAL_MOUSE_ID);
choosing = 1;
@ -280,7 +280,7 @@ int32 Logic::fnChoose(int32 *params) {
IN_SUBJECT = 0;
// blank mouse again
Set_mouse(0);
g_sword2->setMouse(0);
debug(5, "hit %d - ref %d ref*8 %d", hit, subject_list[hit].ref, subject_list[hit].ref * 8);
@ -329,7 +329,7 @@ int32 Logic::fnEndConversation(int32 *params) {
if (g_display->_mouseY > 399) {
// will wait for cursor to move off the bottom menu
mouse_mode = MOUSE_holding;
g_sword2->_mouseMode = MOUSE_holding;
debug(5, " holding");
}

View File

@ -163,6 +163,23 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
memset(_masterMenuList, 0, sizeof(_masterMenuList));
memset(&_thisScreen, 0, sizeof(_thisScreen));
memset(_mouseList, 0, sizeof(_mouseList));
_mouseTouching = 0;
_oldMouseTouching = 0;
_menuSelectedPos = 0;
_examiningMenuIcon = false;
_mousePointerRes = 0;
_mouseMode = 0;
_mouseStatus = false;
_mouseModeLocked = false;
_currentLuggageResource = 0;
_oldButton = 0;
_buttonClick = 0;
_pointerTextBlocNo = 0;
_playerActivityDelay = 0;
_realLuggageItem = 0;
}
Sword2Engine::~Sword2Engine() {
@ -275,7 +292,7 @@ int32 GameCycle(void) {
// reset the mouse hot-spot list (see fnRegisterMouse
// and fnRegisterFrame)
Reset_mouse_list();
g_sword2->resetMouseList();
// keep going as long as new lists keep getting put in
// - i.e. screen changes
@ -289,7 +306,7 @@ int32 GameCycle(void) {
if (g_sword2->_thisScreen.scroll_flag)
Set_scrolling();
Mouse_engine();
g_sword2->mouseEngine();
Process_fx_queue();
// update age and calculate previous cycle memory usage
@ -325,7 +342,7 @@ void Sword2Engine::go() {
if (SaveExists(_saveSlot))
RestoreGame(_saveSlot);
else { // show restore menu
Set_mouse(NORMAL_MOUSE_ID);
setMouse(NORMAL_MOUSE_ID);
if (!gui->restoreControl())
Start_game();
}
@ -517,8 +534,8 @@ void PauseGame(void) {
PauseAllSound();
//make a normal mouse
ClearPointerText();
// make a normal mouse
g_sword2->clearPointerText();
// mouse_mode=MOUSE_normal;
@ -526,10 +543,10 @@ void PauseGame(void) {
g_display->setLuggageAnim(NULL, 0);
// blank cursor
Set_mouse(0);
g_sword2->setMouse(0);
// forces engine to choose a cursor
mouse_touching = 1;
g_sword2->_mouseTouching = 1;
// if level at max, turn down because palette-matching won't work
// when dimmed
@ -552,8 +569,8 @@ void UnpauseGame(void) {
// removed "PAUSED" from screen
// Kill_text_bloc(pause_text_bloc_no);
if (OBJECT_HELD && real_luggage_item)
Set_luggage(real_luggage_item);
if (OBJECT_HELD && g_sword2->_realLuggageItem)
g_sword2->setLuggage(g_sword2->_realLuggageItem);
UnpauseAllSound();
@ -570,8 +587,8 @@ void UnpauseGame(void) {
unpause_zone = 2;
// if mouse is about or we're in a chooser menu
if (!mouse_status || choosing)
Set_mouse(NORMAL_MOUSE_ID);
if (!g_sword2->_mouseStatus || choosing)
g_sword2->setMouse(NORMAL_MOUSE_ID);
}
} // End of namespace Sword2

View File

@ -30,6 +30,7 @@
#include "sword2/events.h"
#include "sword2/icons.h"
#include "sword2/layers.h"
#include "sword2/mouse.h"
#include "sword2/object.h"
#include "sword2/driver/d_sound.h"
#include "sword2/driver/d_draw.h"
@ -170,9 +171,6 @@ public:
uint32 _curFgp0;
uint32 _curFgp1;
// So I know if the control panel can be activated
int32 _mouseStatus;
// Debugging stuff
uint32 _largestLayerArea;
@ -227,6 +225,57 @@ public:
void setUpBackgroundLayers(void);
uint32 _curMouse;
Mouse_unit _mouseList[TOTAL_mouse_list];
// Set by checkMouseList()
uint32 _mouseTouching;
uint32 _oldMouseTouching;
uint32 _menuSelectedPos;
// If it's NORMAL_MOUSE_ID (ie. normal pointer) then it's over a floor
// area (or hidden hot-zone)
uint32 _mousePointerRes;
uint32 _mouseMode;
bool _examiningMenuIcon;
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
void resetMouseList(void);
void normalMouse(void);
void menuMouse(void);
void dragMouse(void);
void systemMenuMouse(void);
void mouseOnOff(void);
uint32 checkMouseList(void);
void mouseEngine(void);
void setMouse(uint32 res);
void setLuggage(uint32 res);
void clearPointerText(void);
void createPointerText(uint32 text_id, uint32 pointer_res);
void monitorPlayerActivity(void);
void noHuman(void);
void registerMouse(Object_mouse *ob_mouse);
void errorString(const char *buf_input, char *buf_output);
void initialiseFontResourceFlags(void);
void initialiseFontResourceFlags(uint8 language);