Implement dialogues

Detect french 256 colors version

svn-id: r29473
This commit is contained in:
Vincent Hamm 2007-11-11 01:04:40 +00:00
parent 31d04d98dc
commit 1bae92f2e1
8 changed files with 291 additions and 20 deletions

View File

@ -858,6 +858,117 @@ menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu) {
return NULL;
}
bool createDialog(int objOvl, int objIdx, int x, int y) {
bool found = false;
bool first = true;
int testState1 = -1;
int testState2 = -1;
int j;
int16 objectState;
int16 objectState2;
getSingleObjectParam(objOvl, objIdx, 5, &objectState);
menuTable[0] = createMenu(x, y, "Parler de...");
for (j = 1; j < numOfLoadedOverlay; j++) {
if (overlayTable[j].alreadyLoaded) {
int idHeader = overlayTable[j].ovlData->numMsgRelHeader;
for (int i=0; i<idHeader; i++) {
linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i];
int thisOvl = ptrHead->obj1Overlay;
if (!thisOvl) {
thisOvl = j;
}
objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number);
getSingleObjectParam(thisOvl, ptrHead->obj1Number, 5, &objectState2);
if (pObject && (pObject->_class == THEME) && (objectState2 <-1)) {
thisOvl = ptrHead->obj2Overlay;
if (!thisOvl) {
thisOvl = j;
}
if((thisOvl==objOvl) && (ptrHead->obj2Number==objIdx)) {
int verbeOvl = ptrHead->verbOverlay;
int obj1Ovl = ptrHead->obj1Overlay;
int obj2Ovl = ptrHead->obj2Overlay;
if (!verbeOvl) verbeOvl=j;
if (!obj1Ovl) obj1Ovl=j;
if (!obj2Ovl) obj2Ovl=j;
char verbe_name[80];
char obj1_name[80];
char obj2_name[80];
char r_verbe_name[80];
char r_obj1_name[80];
char r_obj2_name[80];
verbe_name[0] =0;
obj1_name[0] =0;
obj2_name[0] =0;
r_verbe_name[0] =0;
r_obj1_name[0] =0;
r_obj2_name[0] =0;
ovlDataStruct *ovl2 = NULL;
ovlDataStruct *ovl3 = NULL;
ovlDataStruct *ovl4 = NULL;
if (verbeOvl > 0)
ovl2 = overlayTable[verbeOvl].ovlData;
if (obj1Ovl > 0)
ovl3 = overlayTable[obj1Ovl].ovlData;
if (obj2Ovl > 0)
ovl4 = overlayTable[obj2Ovl].ovlData;
if ((ovl3) && (ptrHead->obj1Number >= 0)) {
testState1 = ptrHead->obj1OldState;
}
if ((ovl4) && (ptrHead->obj2Number >= 0)) {
testState2 = ptrHead->obj2OldState;
}
if ((ovl4) && (ptrHead->verbNumber>=0) &&
((testState1 == -1) || (testState1 == objectState2)) &&
((testState2 == -1) || (testState2 == objectState)) ) {
if (ovl2->nameVerbGlob) {
const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob);
strcpy(verbe_name, ptr);
if (!strlen(verbe_name))
attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL);
else if (ovl2->nameVerbGlob) {
found = true;
int color;
if(objectState2==-2)
color = colorOfSelectedSaveDrive;
else
color = -1;
ptr = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj);
addSelectableMenuEntry(j, i, menuTable[0], 1, color, ptr);
}
}
}
}
}
}
}
}
return found;
}
bool findRelation(int objOvl, int objIdx, int x, int y) {
bool found = false;
bool first = true;
@ -1094,7 +1205,7 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) {
}
if (pHeader->obj1NewState != -1) {
ASSERT(0);
objInit(obj1Ovl, pHeader->obj1Number, pHeader->obj1NewState);
}
}
@ -1141,6 +1252,25 @@ void callRelation(menuElementSubStruct *pMenuElement, int nObj2) {
}
}
void closeAllMenu(void) {
if(menuTable[0]) {
freeMenu(menuTable[0]);
menuTable[0] = NULL;
}
if(menuTable[1]) {
freeMenu(menuTable[1]);
menuTable[1] = NULL;
}
if (linkedMsgList) {
ASSERT(0);
// freeMsgList(linkedMsgList);
}
linkedMsgList = NULL;
linkedRelation = NULL;
}
int processInput(void) {
int16 mouseX = 0;
int16 mouseY = 0;
@ -1187,7 +1317,55 @@ int processInput(void) {
}
if (dialogueEnabled) {
if( menuDown || selectDown || linkedRelation ) {
closeAllMenu();
menuDown = 0;
selectDown = 0;
currentActiveMenu = -1;
changeCursor(CURSOR_NORMAL);
}
if((menuTable[0]==NULL) && (!buttonDown)) {
int dialogFound = createDialog(dialogueOvl, dialogueObj, xdial, 0);
if(menuTable[0]) {
if(dialogFound) {
currentActiveMenu = 0;
}
else {
freeMenu(menuTable[0]);
menuTable[0] = NULL;
currentActiveMenu = -1;
}
}
else {
menuDown = 0;
}
}
else {
if((button & 1) && (buttonDown == 0)) {
if(menuTable[0]) {
callRelation(getSelectedEntryInMenu(menuTable[0]), dialogueObj);
freeMenu(menuTable[0]);
menuTable[0] = NULL;
if (linkedMsgList) {
ASSERT(0);
// freeMsgList(linkedMsgList);
}
linkedMsgList = NULL;
linkedRelation = NULL;
changeCursor(CURSOR_NORMAL);
currentActiveMenu = -1;
}
buttonDown = 1;
}
}
} else if ((button & 1) && (buttonDown == 0)) {
// left click
buttonDown = 1;
@ -1220,6 +1398,8 @@ int processInput(void) {
} else { // call sub relation when clicking in inventory
ASSERT(0);
}
selectDown = 0;
menuDown = 0;
} else {
// manage click on object menu
if (menuDown == 0) {
@ -1281,6 +1461,9 @@ int processInput(void) {
changeCursor(CURSOR_CROSS);
}
}
currentActiveMenu = -1;
selectDown = 0;
}
} else {
// Handle left click in inventory

View File

@ -64,7 +64,7 @@ static const CRUISEGameDescription gameDescriptions[] = {
{
{
"cruise",
"",
"16 colors",
AD_ENTRY1("D1", "41a7a4d426dbd048eb369cfee4bb2717"),
Common::FR_FRA,
Common::kPlatformPC,
@ -72,6 +72,18 @@ static const CRUISEGameDescription gameDescriptions[] = {
},
GType_CRUISE,
0,
},
{
{
"cruise",
"256 colors",
AD_ENTRY1("D1", "e258865807ea31b2d523340e6f0a606b"),
Common::FR_FRA,
Common::kPlatformPC,
Common::ADGF_NO_FLAGS
},
GType_CRUISE,
0,
},
{
{

View File

@ -1360,25 +1360,46 @@ int16 Op_60(void) {
}
int16 Op_6F(void) {
int numArgs = popVar();
int nbp = popVar();
int param[160];
char txt[40];
char format[30];
char nbf[20];
assert(numArgs == 0);
for(int i=nbp-1; i>= 0; i--)
param[i] = popVar();
int val = popVar();
char* pDest = (char*)popPtr();
if(!nbp)
sprintf(txt, "%d", val);
else
{
popVar();
char *string = (char *)popPtr();
printf("partial opcode 6F sprintf (%s)\n", string);
strcpy(format, "%");
sprintf(nbf, "%d", param[0]);
strcat(format, nbf );
strcat(format, "d");
sprintf(txt, format, val);
}
for(int i=0; txt[i]; i++)
*(pDest++) = txt[i];
*(pDest++) = '\0';
return 0;
}
int16 Op_6E(void) {
char *ptr0 = (char *)popPtr();
char *ptr1 = (char *)popPtr();
char *pSource = (char *)popPtr();
char *pDest = (char *)popPtr();
printf("partial opcode 6E (%s)(%s)\n", ptr0, ptr1);
while(*pDest)
pDest++;
while(*pSource)
*(pDest++) = *(pSource++);
*(pDest++) = '\0';
return 0;
}
@ -1419,7 +1440,7 @@ int16 Op_SetObjectAtNode(void) {
int16 ovl = popVar();
if (!ovl)
ovl = currentScriptPtr->overlayNumber;;
ovl = currentScriptPtr->overlayNumber;
int nodeInfo[2];
@ -1476,6 +1497,42 @@ int16 Op_SetNodeColor(void) {
return 0;
}
int16 Op_SetXDial(void) {
int16 old;
old = xdial;
xdial = popVar();
return old;
}
int16 Op_DialogOn(void) {
dialogueObj = popVar();
dialogueOvl = popVar();
if(dialogueOvl == 0)
dialogueOvl = currentScriptPtr->overlayNumber;
dialogueEnabled = true;
return 0;
}
int16 Op_DialogOff(void) {
dialogueEnabled = false;
objectReset();
if(menuTable[0]) {
freeMenu(menuTable[0]);
menuTable[0] = NULL;
changeCursor(CURSOR_NORMAL);
currentActiveMenu = -1;
}
return 0;
}
void setupOpcodeTable(void) {
int i;
@ -1528,6 +1585,8 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x30] = Op_RemoveBackgroundIncrust;
opcodeTablePtr[0x31] = Op_UnmergeBackgroundIncrust;
opcodeTablePtr[0x32] = Op_freeBackgroundInscrustList;
opcodeTablePtr[0x33] = Op_DialogOn;
opcodeTablePtr[0x34] = Op_DialogOff;
opcodeTablePtr[0x37] = Op_37;
opcodeTablePtr[0x38] = Op_removeBackground;
opcodeTablePtr[0x39] = Op_SetActiveBackgroundPlane;
@ -1568,6 +1627,7 @@ void setupOpcodeTable(void) {
opcodeTablePtr[0x70] = Op_comment;
opcodeTablePtr[0x71] = Op_SetColorrawLine;
opcodeTablePtr[0x72] = Op_InitializeState2;
opcodeTablePtr[0x73] = Op_SetXDial;
opcodeTablePtr[0x74] = Op_GetInitVar1;
opcodeTablePtr[0x76] = Op_InitializeState6;
opcodeTablePtr[0x79] = Op_PlayFXnterPlayerMenu;

View File

@ -308,4 +308,18 @@ int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 *
return 0;
}
void objectReset(void) {
for(int i=1; i<numOfLoadedOverlay; i++) {
if(overlayTable[i].alreadyLoaded && overlayTable[i].ovlData) {
if(overlayTable[i].ovlData->arrayObject) {
for(int j=0; j<overlayTable[i].ovlData->numObj; j++) {
int stateIdx = overlayTable[i].state + overlayTable[i].ovlData->arrayObject[j]._stateTableIdx;
if((overlayTable[i].ovlData->arrayObject[j]._class == THEME) && (globalVars[stateIdx] == -2))
globalVars[stateIdx] = 0;
}
}
}
}
}
} // End of namespace Cruise

View File

@ -51,7 +51,7 @@ struct objectParamsQuery {
objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx);
int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 * returnParam);
int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuery * returnParam);
void objectReset(void);
} // End of namespace Cruise
#endif

View File

@ -230,8 +230,8 @@ int loadSavegameData(int saveGameIdx) {
userEnabled = currentSaveFile.readSint16LE();
dialogueEnabled = currentSaveFile.readSint16LE();
var7 = currentSaveFile.readSint16LE();
var8 = currentSaveFile.readSint16LE();
dialogueOvl = currentSaveFile.readSint16LE();
dialogueObj = currentSaveFile.readSint16LE();
userDelay = currentSaveFile.readSint16LE();
sysKey = currentSaveFile.readSint16LE();
sysX = currentSaveFile.readSint16LE();

View File

@ -92,6 +92,7 @@ int16 positionInStack;
actorStruct actorHead;
int16 stateID;
int16 xdial = 0;
uint8 *currentData3DataPtr;
uint8 *scriptDataPtrTable[7];
@ -110,8 +111,8 @@ int16 var4;
int16 userEnabled;
int16 var5;
int16 dialogueEnabled;
int16 var7;
int16 var8;
int16 dialogueOvl;
int16 dialogueObj;
int16 userDelay;
int16 sysKey = -1;

View File

@ -185,6 +185,7 @@ extern int16 positionInStack;
extern actorStruct actorHead;
extern int16 stateID;
extern int16 xdial;
extern uint8 *currentData3DataPtr;
extern uint8 *scriptDataPtrTable[7];
@ -203,8 +204,8 @@ extern int16 var4;
extern int16 userEnabled;
extern int16 var5;
extern int16 dialogueEnabled;
extern int16 var7;
extern int16 var8;
extern int16 dialogueOvl;
extern int16 dialogueObj;
extern int16 userDelay;
extern int16 sysKey;
extern int16 sysX;