[Scummvm-cvs-logs] CVS: scummvm/sword2 function.cpp,1.80,1.81 icons.cpp,1.42,1.43 logic.cpp,1.54,1.55 logic.h,1.43,1.44 mouse.cpp,1.72,1.73 mouse.h,1.19,1.20 sword2.cpp,1.140,1.141 speech.h,1.9,NONE
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Sun Apr 24 05:13:34 CEST 2005
Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26473
Modified Files:
function.cpp icons.cpp logic.cpp logic.h mouse.cpp mouse.h
sword2.cpp
Removed Files:
speech.h
Log Message:
Moved conversation stuff from Logic to Mouse.
Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- function.cpp 22 Apr 2005 17:40:09 -0000 1.80
+++ function.cpp 24 Apr 2005 12:13:02 -0000 1.81
@@ -146,26 +146,7 @@
int32 Logic::fnAddSubject(int32 *params) {
// params: 0 id
// 1 daves reference number
-
- if (_scriptVars[IN_SUBJECT] == 0) {
- // 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 (params[0] == -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() below.
-
- _defaultResponseId = params[1];
- } else {
- debug(5, "fnAddSubject res %d, uid %d", params[0], params[1]);
- _subjectList[_scriptVars[IN_SUBJECT]].res = params[0];
- _subjectList[_scriptVars[IN_SUBJECT]].ref = params[1];
- _scriptVars[IN_SUBJECT]++;
- }
-
+ _vm->_mouse->addSubject(params[0], params[1]);
return IR_CONT;
}
@@ -194,109 +175,12 @@
// values, to be used with the CP_JUMP_ON_RETURNED opcode. As far as I
// can tell, this is the only function that uses that feature.
- uint i;
-
- _scriptVars[AUTO_SELECTED] = 0;
-
- if (_scriptVars[OBJECT_HELD]) {
- // The player used an object on a person. In this case it
- // triggered a conversation menu. Act as if the user tried to
- // talk to the person about that object. If the person doesn't
- // know anything about it, use the default response.
-
- uint32 response = _defaultResponseId;
-
- for (i = 0; i < _scriptVars[IN_SUBJECT]; i++) {
- if (_subjectList[i].res == _scriptVars[OBJECT_HELD]) {
- response = _subjectList[i].ref;
- break;
- }
- }
-
- // The user won't be holding the object any more, and the
- // conversation menu will be closed.
-
- _scriptVars[OBJECT_HELD] = 0;
- _scriptVars[IN_SUBJECT] = 0;
- return IR_CONT | (response << 3);
- }
-
- if (_scriptVars[CHOOSER_COUNT_FLAG] == 0 && _scriptVars[IN_SUBJECT] == 1 && _subjectList[0].res == EXIT_ICON) {
- // This is the first time the chooser is coming up in this
- // conversation, there is only one subject and that's the
- // EXIT icon.
- //
- // In other words, the player doesn't have anything to talk
- // about. Skip it.
-
- // The conversation menu will be closed. We set AUTO_SELECTED
- // because the speech script depends on it.
-
- _scriptVars[AUTO_SELECTED] = 1;
- _scriptVars[IN_SUBJECT] = 0;
- return IR_CONT | (_subjectList[0].ref << 3);
- }
-
- byte *icon;
-
- if (!_choosing) {
- // This is a new conversation menu.
-
- if (!_scriptVars[IN_SUBJECT])
- error("fnChoose with no subjects");
-
- for (i = 0; i < _scriptVars[IN_SUBJECT]; i++) {
- icon = _vm->_resman->openResource(_subjectList[i].res) + sizeof(StandardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
- _vm->_mouse->setMenuIcon(RDMENU_BOTTOM, i, icon);
- _vm->_resman->closeResource(_subjectList[i].res);
- }
-
- for (; i < 15; i++)
- _vm->_mouse->setMenuIcon(RDMENU_BOTTOM, (uint8) i, NULL);
-
- _vm->_mouse->showMenu(RDMENU_BOTTOM);
- _vm->_mouse->setMouse(NORMAL_MOUSE_ID);
- _choosing = true;
- return IR_REPEAT;
- }
-
- // The menu is there - we're just waiting for a click. We only care
- // about left clicks.
-
- MouseEvent *me = _vm->mouseEvent();
- int mouseX, mouseY;
-
- _vm->_mouse->getPos(mouseX, mouseY);
-
- if (!me || !(me->buttons & RD_LEFTBUTTONDOWN) || mouseY < 400)
- return IR_REPEAT;
-
- // Check for click on a menu.
+ uint32 response = _vm->_mouse->chooseMouse();
- int hit = _vm->_mouse->menuClick(_scriptVars[IN_SUBJECT]);
- if (hit < 0)
+ if (response == (uint32) -1)
return IR_REPEAT;
- // Hilight the clicked icon by greying the others.
-
- for (i = 0; i < _scriptVars[IN_SUBJECT]; i++) {
- if ((int) i != hit) {
- icon = _vm->_resman->openResource(_subjectList[i].res) + sizeof(StandardHeader);
- _vm->_mouse->setMenuIcon(RDMENU_BOTTOM, i, icon);
- _vm->_resman->closeResource(_subjectList[i].res);
- }
- }
-
- // For non-speech scripts that manually call the chooser
- _scriptVars[RESULT] = _subjectList[hit].res;
-
- // The conversation menu will be closed
-
- _choosing = false;
- _scriptVars[IN_SUBJECT] = 0;
- _vm->_mouse->setMouse(0);
-
- return IR_CONT | (_subjectList[hit].ref << 3);
+ return IR_CONT | (response << 3);
}
/**
@@ -3255,7 +3139,7 @@
screenInfo->new_palette = 99;
- if (!_vm->_mouse->getMouseStatus() || _choosing)
+ if (!_vm->_mouse->getMouseStatus() || _vm->_mouse->isChoosing())
_vm->_mouse->setMouse(NORMAL_MOUSE_ID);
if (_scriptVars[DEAD])
Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- icons.cpp 9 Apr 2005 13:07:59 -0000 1.42
+++ icons.cpp 24 Apr 2005 12:13:03 -0000 1.43
@@ -33,6 +33,27 @@
_totalTemp++;
}
+void Mouse::addSubject(int32 id, int32 ref) {
+ if (Logic::_scriptVars[IN_SUBJECT] == 0) {
+ // 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);
+ _subjectList[Logic::_scriptVars[IN_SUBJECT]].res = id;
+ _subjectList[Logic::_scriptVars[IN_SUBJECT]].ref = ref;
+ Logic::_scriptVars[IN_SUBJECT]++;
+ }
+}
+
/**
* Create and start the inventory (bottom) menu
*/
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- logic.cpp 10 Apr 2005 16:22:06 -0000 1.54
+++ logic.cpp 24 Apr 2005 12:13:03 -0000 1.55
@@ -34,11 +34,9 @@
_vm(vm), _kills(0), _currentRunList(0), _smackerLeadIn(0),
_smackerLeadOut(0), _sequenceTextLines(0), _speechTime(0), _animId(0),
_speechAnimType(0), _leftClickDelay(0), _rightClickDelay(0),
- _defaultResponseId(0), _officialTextNumber(0), _speechTextBlocNo(0),
- _choosing(false) {
+ _officialTextNumber(0), _speechTextBlocNo(0) {
_scriptVars = NULL;
- memset(_subjectList, 0, sizeof(_subjectList));
memset(_eventList, 0, sizeof(_eventList));
memset(_syncList, 0, sizeof(_syncList));
_router = new Router(_vm);
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- logic.h 22 Feb 2005 07:37:49 -0000 1.43
+++ logic.h 24 Apr 2005 12:13:03 -0000 1.44
@@ -23,8 +23,6 @@
#ifndef _LOGIC
#define _LOGIC
-#include "sword2/speech.h"
-
namespace Sword2 {
struct MovieTextObject;
@@ -98,15 +96,6 @@
void createSequenceSpeech(MovieTextObject *sequenceText[]);
void clearSequenceSpeech(MovieTextObject *sequenceText[]);
- // array of these for subject menu build up
-
- struct SubjectUnit {
- uint32 res;
- uint32 ref;
- };
-
- SubjectUnit _subjectList[MAX_SUBJECT_LIST];
-
// when not playing a wav we calculate the speech time based upon
// length of ascii
@@ -120,12 +109,6 @@
uint32 _leftClickDelay; // click-delay for LEFT mouse button
uint32 _rightClickDelay; // click-delay for RIGHT mouse button
- // 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;
-
// calculated by locateTalker() for use in speech-panning & text-sprite
// positioning
@@ -161,9 +144,6 @@
// so speech text cleared when running a new start-script
uint32 _speechTextBlocNo;
- // could alternately use logic->looping of course
- bool _choosing;
-
int runScript(char *scriptData, char *objectData, uint32 *offset);
void sendEvent(uint32 id, uint32 interact_id);
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- mouse.cpp 11 Apr 2005 06:25:05 -0000 1.72
+++ mouse.cpp 24 Apr 2005 12:13:03 -0000 1.73
@@ -85,6 +85,10 @@
_totalMasters = 0;
memset(_masterMenuList, 0, sizeof(_masterMenuList));
memset(_mouseList, 0, sizeof(_mouseList));
+ memset(_subjectList, 0, sizeof(_subjectList));
+
+ _defaultResponseId = 0;
+ _choosing = false;
_iconCount = 0;
@@ -253,7 +257,7 @@
return (_pos.x - RDMENU_ICONSTART) / (RDMENU_ICONWIDE + RDMENU_ICONSPACING);
}
-void Mouse::systemMenuMouse(void) {
+void Mouse::systemMenuMouse() {
uint32 safe_looping_music_id;
MouseEvent *me;
int hit;
@@ -400,7 +404,7 @@
_vm->_logic->fnStopMusic(NULL);
}
-void Mouse::dragMouse(void) {
+void Mouse::dragMouse() {
byte buf1[NAME_LEN], buf2[NAME_LEN];
MouseEvent *me;
int hit;
@@ -602,7 +606,7 @@
}
}
-void Mouse::normalMouse(void) {
+void Mouse::normalMouse() {
// The gane is playing and none of the menus are activated - but, we
// need to check if a menu is to start. Note, won't have luggage
@@ -821,6 +825,117 @@
}
}
+uint32 Mouse::chooseMouse() {
+ // Unlike the other mouse "engines", this one is called directly by the
+ // fnChoose() opcode.
+
+ uint i;
+
+ Logic::_scriptVars[AUTO_SELECTED] = 0;
+
+ if (Logic::_scriptVars[OBJECT_HELD]) {
+ // The player used an object on a person. In this case it
+ // triggered a conversation menu. Act as if the user tried to
+ // talk to the person about that object. If the person doesn't
+ // know anything about it, use the default response.
+
+ uint32 response = _defaultResponseId;
+
+ for (i = 0; i < Logic::_scriptVars[IN_SUBJECT]; i++) {
+ if (_subjectList[i].res == Logic::_scriptVars[OBJECT_HELD]) {
+ response = _subjectList[i].ref;
+ break;
+ }
+ }
+
+ // The user won't be holding the object any more, and the
+ // conversation menu will be closed.
+
+ Logic::_scriptVars[OBJECT_HELD] = 0;
+ Logic::_scriptVars[IN_SUBJECT] = 0;
+ return response;
+ }
+
+ if (Logic::_scriptVars[CHOOSER_COUNT_FLAG] == 0 && Logic::_scriptVars[IN_SUBJECT] == 1 && _subjectList[0].res == EXIT_ICON) {
+ // This is the first time the chooser is coming up in this
+ // conversation, there is only one subject and that's the
+ // EXIT icon.
+ //
+ // In other words, the player doesn't have anything to talk
+ // about. Skip it.
+
+ // The conversation menu will be closed. We set AUTO_SELECTED
+ // because the speech script depends on it.
+
+ Logic::_scriptVars[AUTO_SELECTED] = 1;
+ Logic::_scriptVars[IN_SUBJECT] = 0;
+ return _subjectList[0].ref;
+ }
+
+ byte *icon;
+
+ if (!_choosing) {
+ // This is a new conversation menu.
+
+ if (!Logic::_scriptVars[IN_SUBJECT])
+ error("fnChoose with no subjects");
+
+ for (i = 0; i < Logic::_scriptVars[IN_SUBJECT]; i++) {
+ icon = _vm->_resman->openResource(_subjectList[i].res) + sizeof(StandardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
+ setMenuIcon(RDMENU_BOTTOM, i, icon);
+ _vm->_resman->closeResource(_subjectList[i].res);
+ }
+
+ for (; i < 15; i++)
+ setMenuIcon(RDMENU_BOTTOM, (uint8) i, NULL);
+
+ showMenu(RDMENU_BOTTOM);
+ setMouse(NORMAL_MOUSE_ID);
+ _choosing = true;
+ return (uint32) -1;
+ }
+
+ // The menu is there - we're just waiting for a click. We only care
+ // about left clicks.
+
+ MouseEvent *me = _vm->mouseEvent();
+ int mouseX, mouseY;
+
+ getPos(mouseX, mouseY);
+
+ if (!me || !(me->buttons & RD_LEFTBUTTONDOWN) || mouseY < 400)
+ return (uint32) -1;
+
+ // Check for click on a menu.
+
+ int hit = _vm->_mouse->menuClick(Logic::_scriptVars[IN_SUBJECT]);
+ if (hit < 0)
+ return (uint32) -1;
+
+ // Hilight the clicked icon by greying the others. This can look a bit
+ // odd when you click on the exit icon, but there are also cases when
+ // it looks strange if you don't do it.
+
+ for (i = 0; i < Logic::_scriptVars[IN_SUBJECT]; i++) {
+ if ((int) i != hit) {
+ icon = _vm->_resman->openResource(_subjectList[i].res) + sizeof(StandardHeader);
+ _vm->_mouse->setMenuIcon(RDMENU_BOTTOM, i, icon);
+ _vm->_resman->closeResource(_subjectList[i].res);
+ }
+ }
+
+ // For non-speech scripts that manually call the chooser
+ Logic::_scriptVars[RESULT] = _subjectList[hit].res;
+
+ // The conversation menu will be closed
+
+ _choosing = false;
+ Logic::_scriptVars[IN_SUBJECT] = 0;
+ setMouse(0);
+
+ return _subjectList[hit].ref;
+}
+
void Mouse::mouseOnOff() {
// this handles the cursor graphic when moving on and off mouse areas
// it also handles the luggage thingy
Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mouse.h 28 Feb 2005 14:03:53 -0000 1.19
+++ mouse.h 24 Apr 2005 12:13:03 -0000 1.20
@@ -21,6 +21,8 @@
#ifndef MOUSE_H
#define MOUSE_H
+#define MAX_SUBJECT_LIST 30 // is that enough?
+
#define TOTAL_mouse_list 50
namespace Sword2 {
@@ -99,6 +101,13 @@
int32 pointer_text;
};
+// Array of these for subject menu build up
+
+ struct SubjectUnit {
+ uint32 res;
+ uint32 ref;
+};
+
class Mouse {
private:
Sword2Engine *_vm;
@@ -114,6 +123,17 @@
MenuObject _masterMenuList[TOTAL_engine_pockets];
uint32 _totalMasters;
+ 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;
+
uint8 _menuStatus[2];
byte *_icons[2][RDMENU_MAXPOCKETS];
uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
@@ -200,6 +220,8 @@
void processMenu();
void addMenuObject(MenuObject *obj);
+ void addSubject(int32 id, int32 ref);
+
void buildMenu();
void buildSystemMenu();
@@ -231,6 +253,9 @@
void dragMouse();
void systemMenuMouse();
+ bool isChoosing() { return _choosing; }
+ uint32 chooseMouse();
+
int menuClick(int menu_items);
};
Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -d -r1.140 -r1.141
--- sword2.cpp 25 Mar 2005 17:55:57 -0000 1.140
+++ sword2.cpp 24 Apr 2005 12:13:03 -0000 1.141
@@ -331,7 +331,7 @@
pauseGame();
break;
case 'c':
- if (!Logic::_scriptVars[DEMO] && !_logic->_choosing)
+ if (!Logic::_scriptVars[DEMO] && !_mouse->isChoosing())
_logic->fnPlayCredits(NULL);
break;
#ifdef SWORD2_DEBUG
@@ -658,7 +658,7 @@
_gamePaused = false;
// If mouse is about or we're in a chooser menu
- if (!_mouse->getMouseStatus() || _logic->_choosing)
+ if (!_mouse->getMouseStatus() || _mouse->isChoosing())
_mouse->setMouse(NORMAL_MOUSE_ID);
}
--- speech.h DELETED ---
More information about the Scummvm-git-logs
mailing list