aboutsummaryrefslogtreecommitdiff
path: root/engines/cine
diff options
context:
space:
mode:
authorEugene Sandulenko2006-11-18 15:16:44 +0000
committerEugene Sandulenko2006-11-18 15:16:44 +0000
commit53c4684bbeb9bde65d80709f94d9c036b4415aef (patch)
treedabff40ad0f55105d2fd31b4658ee2a1413ec769 /engines/cine
parente28a1ca46ddef13b896ea0097c0f04059da8b88b (diff)
downloadscummvm-rg350-53c4684bbeb9bde65d80709f94d9c036b4415aef.tar.gz
scummvm-rg350-53c4684bbeb9bde65d80709f94d9c036b4415aef.tar.bz2
scummvm-rg350-53c4684bbeb9bde65d80709f94d9c036b4415aef.zip
Implement naming save games in cinE. See also FR #1579780: "FW: naming save
games" svn-id: r24731
Diffstat (limited to 'engines/cine')
-rw-r--r--engines/cine/main_loop.cpp11
-rw-r--r--engines/cine/script.cpp2
-rw-r--r--engines/cine/texte.cpp80
-rw-r--r--engines/cine/texte.h2
-rw-r--r--engines/cine/various.cpp288
-rw-r--r--engines/cine/various.h3
6 files changed, 308 insertions, 78 deletions
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index c8bc8f530d..5b5a927be6 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -39,6 +39,8 @@ mouseStatusStruct mouseData;
uint16 mouseRight = 0;
uint16 mouseLeft = 0;
+char lastKeyStroke = 0;
+
uint16 mouseUpdateStatus;
uint16 dummyU16;
@@ -110,6 +112,7 @@ void manageEvents(int count) {
}
break;
default:
+ lastKeyStroke = event.kbd.ascii;
break;
}
break;
@@ -155,6 +158,14 @@ void getMouseData(uint16 param, uint16 *pButton, uint16 *pX, uint16 *pY) {
}
}
+int getKeyData() {
+ int k = lastKeyStroke;
+
+ lastKeyStroke = -1;
+
+ return k;
+}
+
void mainLoop(int bootScriptIdx) {
uint16 var_6;
uint16 quitFlag;
diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp
index 44b8f56435..026fab7f2a 100644
--- a/engines/cine/script.cpp
+++ b/engines/cine/script.cpp
@@ -2233,8 +2233,6 @@ void decompileScript(byte *scriptPtr, int16 *stackPtr, uint16 scriptSize, uint16
opcode = 0;
}
- printf("%X\n", opcode - 1);
-
strcpy(lineBuffer, "");
switch (opcode - 1) {
diff --git a/engines/cine/texte.cpp b/engines/cine/texte.cpp
index a3ebcd3afd..c49f7f964c 100644
--- a/engines/cine/texte.cpp
+++ b/engines/cine/texte.cpp
@@ -226,7 +226,6 @@ void initLanguage(Common::Language lang) {
"Loading | %s",
"Loading canceled ...",
"No baclup in the drive...",
- "temporary save name",
"Please enter the backup name",
"on"
};
@@ -300,7 +299,6 @@ void initLanguage(Common::Language lang) {
"Sauvegarde de | %s",
"Sauvegarde Annul\x82""e ...",
"Aucune sauvegarde dans le lecteur ...",
- "temporary save name", //
"Veuillez entrer le Nom de la Sauvegarde .",
"sur"
};
@@ -318,7 +316,7 @@ void initLanguage(Common::Language lang) {
"No he debido entenderte",
// INVENTORY
"Es inutil",
- "Tienes algo mejor que hacer"
+ "Tienes algo mejor que hacer",
"Vamos. No perdamos tiempo",
"Esa no es una buena idea",
// USE
@@ -364,12 +362,11 @@ void initLanguage(Common::Language lang) {
static const char *otherMessages_ES[] = {
"Esta granacion no existe",
- "Could not create save file ..." //
+ "Could not create save file ...", //
"PAUSE",
"Gabacion de| %s",
"Rrabacion anulada",
"No hay partidas grabadas en este disco...",
- "temporary save name", //
"Teclea el nombre de la partida grabada",
"donde"
};
@@ -438,7 +435,6 @@ void initLanguage(Common::Language lang) {
"Er L\x84""dt | %s",
"Ladevorgang Abgebrochen...",
"Kein Backup im Laufwerk...",
- "temporary save name", //
"Geben Sie den Namen|der Sicherungsdiskette ein",
"gegen"
};
@@ -507,7 +503,6 @@ void initLanguage(Common::Language lang) {
"Caricamento di| %s",
"Caricamento annullato...",
"Nessun salvataggio su questo disco...",
- "temporary save name", //
"Vogliate accedere con il nome del salvataggio",
"su"
};
@@ -519,7 +514,7 @@ void initLanguage(Common::Language lang) {
systemMenu = systemMenu_FR;
confirmMenu = confirmMenu_FR;
otherMessages = otherMessages_FR;
- commandPrepositionOn = otherMessages_FR[8];
+ commandPrepositionOn = otherMessages_FR[7];
break;
case Common::ES_ESP:
@@ -528,7 +523,7 @@ void initLanguage(Common::Language lang) {
systemMenu = systemMenu_ES;
confirmMenu = confirmMenu_ES;
otherMessages = otherMessages_ES;
- commandPrepositionOn = otherMessages_ES[8];
+ commandPrepositionOn = otherMessages_ES[7];
break;
case Common::DE_DEU:
@@ -537,7 +532,7 @@ void initLanguage(Common::Language lang) {
systemMenu = systemMenu_DE;
confirmMenu = confirmMenu_DE;
otherMessages = otherMessages_DE;
- commandPrepositionOn = otherMessages_DE[8];
+ commandPrepositionOn = otherMessages_DE[7];
break;
case Common::IT_ITA:
@@ -546,7 +541,7 @@ void initLanguage(Common::Language lang) {
systemMenu = systemMenu_IT;
confirmMenu = confirmMenu_IT;
otherMessages = otherMessages_IT;
- commandPrepositionOn = otherMessages_IT[8];
+ commandPrepositionOn = otherMessages_IT[7];
break;
default:
@@ -555,7 +550,7 @@ void initLanguage(Common::Language lang) {
systemMenu = systemMenu_EN;
confirmMenu = confirmMenu_EN;
otherMessages = otherMessages_EN;
- commandPrepositionOn = otherMessages_EN[8];
+ commandPrepositionOn = otherMessages_EN[7];
break;
}
@@ -616,4 +611,65 @@ void freePoldatDat() {
fontParamTable = 0;
}
+uint16 computeMessageLength(const byte *ptr, uint16 width, uint16 *numWords, uint16 *messageWidth, uint16 *lineResult) {
+ const byte *localPtr = ptr;
+
+ uint16 var_2 = 0;
+ uint16 localLineResult = 0;
+ uint16 var_6 = 0;
+ uint16 var_8 = 0;
+ uint16 localMessageWidth = 0;
+ uint16 var_16 = 0;
+ uint16 finished = 0;
+ uint16 si = 0;
+ uint16 di = 0;
+
+ while (!finished) {
+ byte character = *(localPtr++);
+
+ if (character == ' ') {
+ var_8 = var_16;
+ var_6 = localMessageWidth;
+ localLineResult = si;
+ var_2 = di;
+
+ if (si + 5 < width) {
+ var_16++;
+ si += 5;
+ } else {
+ finished = 1;
+ }
+ } else if (character == 0x7C || character == 0) {
+ finished = 1;
+ si = 0;
+ } else {
+ if (fontParamTable[character].characterWidth) {
+ uint16 var_C = fontParamTable[character].characterWidth + 1;
+
+ if (si + var_C < width) {
+ si += var_C;
+ localMessageWidth += var_C;
+ } else {
+ finished = 1;
+
+ if (localLineResult) {
+ var_16 = var_8;
+ localMessageWidth = var_6;
+ si = localLineResult;
+ di = var_2;
+ }
+ }
+ }
+ }
+
+ di++;
+ }
+
+ *numWords = var_16;
+ *messageWidth = localMessageWidth;
+ *lineResult = si;
+
+ return di;
+}
+
} // End of namespace Cine
diff --git a/engines/cine/texte.h b/engines/cine/texte.h
index 91fe22002e..17202ee42a 100644
--- a/engines/cine/texte.h
+++ b/engines/cine/texte.h
@@ -55,6 +55,8 @@ void freeErrmessDat(void);
void loadPoldatDat(const char *fname);
void freePoldatDat(void);
+uint16 computeMessageLength(const byte *ptr, uint16 width, uint16 *numWords, uint16 *messageWidth, uint16 *lineResult);
+
} // End of namespace Cine
#endif
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index f52dcc8b3b..25d801ad31 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -1000,8 +1000,13 @@ void CineEngine::makeSystemMenu(void) {
if (selectedSave >= 0) {
char saveFileName[256];
- //makeTextEntryMenu(otherMessages[7], &currentSaveName[selectedSave], 120);
- sprintf(currentSaveName[selectedSave], otherMessages[6]);
+ char saveName[20];
+ saveName[0] = 0;
+
+ if (!makeTextEntryMenu(otherMessages[6], saveName, 20, 120))
+ break;
+
+ strncpy(currentSaveName[selectedSave], saveName, 20);
sprintf(saveFileName, "%s.%1d", _targetName.c_str(), selectedSave);
@@ -2246,67 +2251,6 @@ void backupOverlayPage(void) {
}
}
-uint16 computeMessageLength(const byte *ptr, uint16 width, uint16 *numWords, uint16 *messageWidth, uint16 *lineResult) {
- const byte *localPtr = ptr;
-
- uint16 var_2 = 0;
- uint16 localLineResult = 0;
- uint16 var_6 = 0;
- uint16 var_8 = 0;
- uint16 localMessageWidth = 0;
- uint16 var_16 = 0;
- uint16 finished = 0;
- uint16 si = 0;
- uint16 di = 0;
-
- while (!finished) {
- byte character = *(localPtr++);
-
- if (character == ' ') {
- var_8 = var_16;
- var_6 = localMessageWidth;
- localLineResult = si;
- var_2 = di;
-
- if (si + 5 < width) {
- var_16++;
- si += 5;
- } else {
- finished = 1;
- }
- } else if (character == 0x7C || character == 0) {
- finished = 1;
- si = 0;
- } else {
- if (fontParamTable[character].characterWidth) {
- uint16 var_C = fontParamTable[character].characterWidth + 1;
-
- if (si + var_C < width) {
- si += var_C;
- localMessageWidth += var_C;
- } else {
- finished = 1;
-
- if (localLineResult) {
- var_16 = var_8;
- localMessageWidth = var_6;
- si = localLineResult;
- di = var_2;
- }
- }
- }
- }
-
- di++;
- }
-
- *numWords = var_16;
- *messageWidth = localMessageWidth;
- *lineResult = si;
-
- return di;
-}
-
void drawDialogueMessage(byte msgIdx, int16 x, int16 y, int16 width, int16 color) {
byte color2 = 2;
byte endOfMessageReached = 0;
@@ -2455,7 +2399,7 @@ void drawFailureMessage(byte cmd) {
messagePtr += messageLength;
- messageLength = computeMessageLength((const byte *) messagePtr, localWidth, &numWords, &messageWidth, &lineResult);
+ messageLength = computeMessageLength((const byte *)messagePtr, localWidth, &numWords, &messageWidth, &lineResult);
endOfMessagePtr = messagePtr + messageLength;
@@ -3104,4 +3048,220 @@ void processSeqList(void) {
}
}
+
+bool makeTextEntryMenu(const char *messagePtr, char *inputString, int stringMaxLength, int y) {
+ byte color2 = defaultMenuBoxColor2;
+ byte endOfMessageReached = 0;
+ int16 localX;
+ int16 localY;
+ int16 localWidth;
+ int margins = 16;
+
+ int len = strlen(messagePtr);
+
+ int16 width = 6 * len + 20;
+
+ if (width > 250)
+ width = 250;
+
+ if (width < 180)
+ width = 180;
+
+ int16 x = (320 - width) / 2;
+ int16 color = 2;
+
+ gfxDrawPlainBoxRaw(x - margins, y, x + width + margins, y + 4, color2, page1Raw);
+
+ localX = x + 4;
+ localY = y + 4;
+ localWidth = width;
+
+ getKeyData(); // clear input key
+
+ do {
+ uint16 messageLength = 0;
+ uint16 numWords;
+ uint16 messageWidth;
+ uint16 lineResult;
+ const char *endOfMessagePtr;
+ uint16 fullLineWidth;
+ uint16 interWordSize;
+ uint16 interWordSizeRemain;
+ byte currentChar;
+ byte characterWidth;
+
+ while (messagePtr[messageLength] == ' ') {
+ messageLength++;
+ }
+
+ messagePtr += messageLength;
+
+ messageLength = computeMessageLength((const byte *)messagePtr, localWidth, &numWords, &messageWidth, &lineResult);
+
+ endOfMessagePtr = messagePtr + messageLength;
+
+ if (lineResult) {
+ fullLineWidth = localWidth - messageWidth;
+
+ if (numWords) {
+ interWordSize = fullLineWidth / numWords;
+ interWordSizeRemain = fullLineWidth % numWords;
+ } else {
+ interWordSize = 5;
+ interWordSizeRemain = 0;
+ }
+ } else {
+ interWordSize = 5;
+ interWordSizeRemain = 0;
+ }
+
+ gfxDrawPlainBoxRaw(x - margins, localY, x + width + margins, localY + 9, color2, page1Raw);
+
+ do {
+ currentChar = *(messagePtr++);
+
+ if (currentChar == 0) {
+ endOfMessageReached = 1;
+ } else if (currentChar == ' ') {
+ localX += interWordSizeRemain + interWordSize;
+
+ if (interWordSizeRemain)
+ interWordSizeRemain = 0;
+ } else {
+ characterWidth = fontParamTable[currentChar].characterWidth;
+
+ if (characterWidth) {
+ byte characterIdx = fontParamTable[currentChar].characterIdx;
+ drawSpriteRaw(textTable[characterIdx][0], textTable[characterIdx][1], 2, 8, page1Raw, localX, localY);
+ localX += characterWidth + 1;
+ }
+ }
+ } while ((messagePtr < endOfMessagePtr) && !endOfMessageReached);
+
+ localX = x + 4;
+ localY += 9;
+ } while (!endOfMessageReached);
+
+ // Input string
+ gfxDrawPlainBoxRaw(x - margins, localY, x + width + margins, localY + 9, color2, page1Raw);
+ localY += 9;
+
+ x -= margins;
+ width += margins * 2;
+
+ gfxDrawPlainBoxRaw(x, localY, x + width, localY + 4, color2, page1Raw);
+
+ gfxDrawLine(x + 1, y + 1, x + width - 1, y + 1, 0, page1Raw); // top
+ gfxDrawLine(x + 1, localY + 3, x + width - 1, localY + 3, 0, page1Raw); // bottom
+ gfxDrawLine(x + 1, y + 1, x + 1, localY + 3, 0, page1Raw); // left
+ gfxDrawLine(x + width - 1, y + 1, x + width - 1, localY + 3, 0, page1Raw); // right
+
+ gfxDrawLine(x, y, x + width, y, color, page1Raw);
+ gfxDrawLine(x, localY + 4, x + width, localY + 4, color, page1Raw);
+ gfxDrawLine(x, y, x, localY + 4, color, page1Raw);
+ gfxDrawLine(x + width, y, x + width, localY + 4, color, page1Raw);
+
+ x += margins;
+ width -= margins * 2;
+ localY -= 9;
+
+
+ int quit = 0;
+ bool redraw = true;
+ commandeType tempString;
+ int inputLength = strlen(inputString);
+ int inputPos = inputLength + 1;
+
+ while (!quit) {
+ if (redraw) {
+ gfxDrawPlainBoxRaw(x, localY - 1, x + width, localY + 8, 0, page1Raw);
+
+ int currentX = x + 4;
+
+ for (uint j = 0; j < strlen(inputString); j++) {
+ char currentChar = inputString[j];
+
+ if (currentChar == ' ') {
+ currentX += 5;
+ } else {
+ byte characterWidth = fontParamTable[currentChar].characterWidth;
+
+ if (characterWidth) {
+ byte characterIdx = fontParamTable[currentChar].characterIdx;
+ drawSpriteRaw(textTable[characterIdx][0], textTable[characterIdx][1], 2, 8, page1Raw, currentX, localY);
+ currentX += characterWidth + 1;
+ }
+ }
+ }
+
+ gfxDrawLine(currentX, localY - 1, currentX, localY + 8, color, page1Raw); // cursor
+
+ blitRawScreen(page1Raw);
+ redraw = false;
+ }
+
+ char ch[2];
+ memset(tempString, 0, stringMaxLength);
+ ch[1] = 0;
+
+ manageEvents();
+ int ascii = getKeyData();
+
+ switch (ascii) {
+ case 13:
+ quit = 1;
+ break;
+ case 27: // esc
+ quit = 2;
+ break;
+ case 8: // backspace
+ if (inputPos <= 1) {
+ break;
+ }
+ inputPos--;
+ redraw = true;
+ if (inputPos != 1) {
+ strncpy(tempString, inputString, inputPos - 1);
+ }
+ if (inputPos != inputLength) {
+ strncat(tempString, &inputString[inputPos], inputLength - inputPos);
+ }
+ strcpy(inputString, tempString);
+ inputLength = strlen(inputString);
+ redraw = true;
+ break;
+ default:
+ if (((ascii >= 'a') && (ascii <='z')) ||
+ ((ascii >= '0') && (ascii <='9')) ||
+ ((ascii >= 'A') && (ascii <='Z')) ||
+ (ascii == ' ')) {
+ if (inputLength < stringMaxLength - 1) {
+ ch[0] = ascii;
+ if (inputPos != 1) {
+ strncpy(tempString, inputString, inputPos - 1);
+ strcat(tempString, ch);
+ }
+ if ((inputLength == 0) || (inputPos == 1)) {
+ strcpy(tempString, ch);
+ }
+ if ((inputLength != 0) && (inputPos != inputLength)) {
+ strncat(tempString, &inputString[inputPos - 1], inputLength - inputPos + 1);
+ }
+
+ strcpy(inputString, tempString);
+ inputLength = strlen(inputString);
+ inputPos++;
+ redraw = true;
+ }
+ }
+ break;
+ }
+ }
+
+ if (quit == 2)
+ return false;
+
+ return true;
+}
+
} // End of namespace Cine
diff --git a/engines/cine/various.h b/engines/cine/various.h
index bef5c55759..5a6565fde6 100644
--- a/engines/cine/various.h
+++ b/engines/cine/various.h
@@ -138,6 +138,7 @@ extern uint16 mouseUpdateStatus;
extern uint16 dummyU16;
void getMouseData(uint16 param, uint16 *pButton, uint16 *pX, uint16 *pY);
+int getKeyData(void);
uint16 processKeyboard(uint16 param);
@@ -181,6 +182,8 @@ void addSeqListElement(int16 param0, int16 param1, int16 param2, int16 param3, i
void resetSeqList();
void processSeqList(void);
+bool makeTextEntryMenu(const char *caption, char *string, int strLen, int y);
+
} // End of namespace Cine
#endif