scummvm/engines/hopkins/dialogs.cpp

767 lines
28 KiB
C++
Raw Normal View History

/* 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.
*
2012-10-29 22:38:31 +00:00
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
2012-10-29 22:38:31 +00:00
* 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
2012-10-29 22:38:31 +00:00
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/events.h"
#include "common/file.h"
#include "common/util.h"
#include "hopkins/dialogs.h"
#include "hopkins/events.h"
#include "hopkins/files.h"
#include "hopkins/globals.h"
#include "hopkins/graphics.h"
#include "hopkins/hopkins.h"
#include "hopkins/sound.h"
namespace Hopkins {
DialogsManager::DialogsManager() {
INVENTFLAG = false;
2012-12-10 06:54:03 +00:00
_inventDisplayedFl = false;
VIRE_INVENT = false;
2012-12-10 06:54:03 +00:00
_inventX = _inventY = 0;
_inventWidth = _inventHeight = 0;
Winventaire = NULL;
inventaire2 = g_PTRNUL;
}
DialogsManager::~DialogsManager() {
_vm->_globals.dos_free2(Winventaire);
}
void DialogsManager::setParent(HopkinsEngine *vm) {
_vm = vm;
}
void DialogsManager::showOptionsDialog() {
bool doneFlag;
doneFlag = false;
_vm->_eventsManager.CHANGE_MOUSE(0);
_vm->_eventsManager.VBL();
if (_vm->_globals.FR == 1)
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIFR.SPR");
else if (!_vm->_globals.FR)
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIAN.SPR");
else if (_vm->_globals.FR == 2)
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIES.SPR");
2012-12-09 19:22:12 +00:00
_vm->_globals.OPTION_SPR = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER);
_vm->_globals.OPTION_FLAG = true;
do {
if (_vm->_eventsManager.BMOUSE()) {
Common::Point mousePos(_vm->_eventsManager.XMOUSE(), _vm->_eventsManager.YMOUSE());
mousePos.x = _vm->_eventsManager.XMOUSE();
mousePos.y = _vm->_eventsManager.YMOUSE();
if (!_vm->_soundManager.MUSICOFF) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 138) {
// Change the music volume
++_vm->_soundManager.MUSICVOL;
_vm->_soundManager.OLD_MUSICVOL = _vm->_soundManager.MUSICVOL;
if (_vm->_soundManager.MUSICVOL <= 12)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.MUSICVOL = 12;
_vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
_vm->_soundManager.updateScummVMSoundSettings();
}
if (!_vm->_soundManager.MUSICOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 138) {
--_vm->_soundManager.MUSICVOL;
if (_vm->_soundManager.MUSICVOL >= 0)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.MUSICVOL = 0;
_vm->_soundManager.OLD_MUSICVOL = _vm->_soundManager.MUSICVOL;
_vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
_vm->_soundManager.updateScummVMSoundSettings();
}
}
if (!_vm->_soundManager.SOUNDOFF) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 165) {
++_vm->_soundManager.SOUNDVOL;
if (_vm->_soundManager.SOUNDVOL <= 16)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.SOUNDVOL = 16;
_vm->_soundManager.OLD_SOUNDVOL = _vm->_soundManager.SOUNDVOL;
_vm->_soundManager.MODSetSampleVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
if (!_vm->_soundManager.SOUNDOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 165) {
--_vm->_soundManager.SOUNDVOL;
if (_vm->_soundManager.SOUNDVOL >= 0)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.SOUNDVOL = 0;
_vm->_soundManager.OLD_SOUNDVOL = _vm->_soundManager.SOUNDVOL;
_vm->_soundManager.MODSetSampleVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
}
if (!_vm->_soundManager.VOICEOFF) {
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 192) {
++_vm->_soundManager.VOICEVOL;
if (_vm->_soundManager.VOICEVOL <= 16)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.VOICEVOL = 16;
_vm->_soundManager.OLD_VOICEVOL = _vm->_soundManager.VOICEVOL;
_vm->_soundManager.MODSetVoiceVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
if (!_vm->_soundManager.VOICEOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 192) {
--_vm->_soundManager.VOICEVOL;
if (_vm->_soundManager.VOICEVOL >= 0)
_vm->_soundManager.PLAY_SOUND("bruit2.wav");
else
_vm->_soundManager.VOICEVOL = 0;
_vm->_soundManager.OLD_VOICEVOL = _vm->_soundManager.VOICEVOL;
_vm->_soundManager.MODSetVoiceVolume();
_vm->_soundManager.updateScummVMSoundSettings();
}
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
if (mousePos.y > 194 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 219)
_vm->_soundManager.TEXTOFF = _vm->_soundManager.TEXTOFF != 1;
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
if (mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 192) {
_vm->_soundManager.VOICEOFF = _vm->_soundManager.VOICEOFF != 1;
_vm->_soundManager.updateScummVMSoundSettings();
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
if (mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 138) {
if (_vm->_soundManager.MUSICOFF == 1) {
_vm->_soundManager.MUSICOFF = 0;
_vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
} else {
_vm->_soundManager.MUSICOFF = 1;
_vm->_soundManager.MODSetMusicVolume(0);
}
_vm->_soundManager.updateScummVMSoundSettings();
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 165) {
_vm->_soundManager.SOUNDOFF = _vm->_soundManager.SOUNDOFF != 1;
_vm->_soundManager.updateScummVMSoundSettings();
}
}
}
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 175 && mousePos.y > 285 && mousePos.x <= _vm->_graphicsManager.ofscroll + 281 && mousePos.y <= 310) {
_vm->_globals.SORTIE = 300;
doneFlag = true;
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 355 && mousePos.y > 285 && mousePos.x <= _vm->_graphicsManager.ofscroll + 490 && mousePos.y <= 310)
doneFlag = true;
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 194 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 219) {
switch (_vm->_graphicsManager.SPEED_SCROLL) {
case 1:
_vm->_graphicsManager.SPEED_SCROLL = 2;
break;
case 2:
_vm->_graphicsManager.SPEED_SCROLL = 4;
break;
case 4:
_vm->_graphicsManager.SPEED_SCROLL = 8;
break;
case 8:
_vm->_graphicsManager.SPEED_SCROLL = 16;
break;
case 16:
_vm->_graphicsManager.SPEED_SCROLL = 32;
break;
case 32:
_vm->_graphicsManager.SPEED_SCROLL = 48;
break;
case 48:
_vm->_graphicsManager.SPEED_SCROLL = 64;
break;
case 64:
_vm->_graphicsManager.SPEED_SCROLL = 128;
break;
case 128:
_vm->_graphicsManager.SPEED_SCROLL = 160;
break;
case 160:
_vm->_graphicsManager.SPEED_SCROLL = 320;
break;
case 320:
_vm->_graphicsManager.SPEED_SCROLL = 1;
break;
}
}
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 348 && mousePos.y > 248 && mousePos.x <= _vm->_graphicsManager.ofscroll + 394 && mousePos.y <= 273)
_vm->_globals.vitesse = 2;
if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 221 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 246)
_vm->_globals.SVGA = 2;
if (mousePos.x < _vm->_graphicsManager.ofscroll + 165 || mousePos.x > _vm->_graphicsManager.ofscroll + 496 || (uint)(mousePos.y - 107) > 0xD3u)
doneFlag = true;
}
if (!_vm->_graphicsManager.MANU_SCROLL)
_vm->_globals.opt_scrtype = 2;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.MANU_SCROLL == 1)
_vm->_globals.opt_scrtype = 1;
2012-11-21 21:42:51 +00:00
if (_vm->_globals.vitesse == 1)
_vm->_globals.opt_vitesse = 6;
2012-11-21 21:42:51 +00:00
else if (_vm->_globals.vitesse == 2)
_vm->_globals.opt_vitesse = 5;
2012-11-21 21:42:51 +00:00
else if (_vm->_globals.vitesse == 3)
_vm->_globals.opt_vitesse = 4;
_vm->_globals.opt_txt = !_vm->_soundManager.TEXTOFF ? 7 : 8;
_vm->_globals.opt_voice = !_vm->_soundManager.VOICEOFF ? 7 : 8;
_vm->_globals.opt_sound = !_vm->_soundManager.SOUNDOFF ? 7 : 8;
_vm->_globals.opt_music = !_vm->_soundManager.MUSICOFF ? 7 : 8;
if (_vm->_globals.SVGA == 1)
_vm->_globals.opt_anm = 10;
2012-11-21 21:42:51 +00:00
else if (_vm->_globals.SVGA == 2)
_vm->_globals.opt_anm = 9;
2012-11-21 21:42:51 +00:00
else if (_vm->_globals.SVGA == 3)
_vm->_globals.opt_anm = 11;
2012-11-21 21:42:51 +00:00
if (_vm->_graphicsManager.SPEED_SCROLL == 1)
_vm->_globals.opt_scrspeed = 12;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 2)
_vm->_globals.opt_scrspeed = 13;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 4)
_vm->_globals.opt_scrspeed = 14;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 8)
_vm->_globals.opt_scrspeed = 15;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 16)
_vm->_globals.opt_scrspeed = 16;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 32)
_vm->_globals.opt_scrspeed = 17;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 48)
_vm->_globals.opt_scrspeed = 18;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 64)
_vm->_globals.opt_scrspeed = 19;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 128)
_vm->_globals.opt_scrspeed = 20;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 160)
_vm->_globals.opt_scrspeed = 21;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 320)
_vm->_globals.opt_scrspeed = 22;
2012-11-21 21:42:51 +00:00
else if (_vm->_graphicsManager.SPEED_SCROLL == 640)
_vm->_globals.opt_scrspeed = 23;
_vm->_eventsManager.VBL();
} while (!doneFlag);
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_graphicsManager.ofscroll + 164,
107, 335, 215, _vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll + 164, 107);
_vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_graphicsManager.ofscroll + 164, 107,
_vm->_graphicsManager.ofscroll + 498, 320);
_vm->_globals.OPTION_SPR = _vm->_globals.dos_free2(_vm->_globals.OPTION_SPR);
_vm->_globals.OPTION_FLAG = false;
}
void DialogsManager::showInventory() {
2012-12-10 06:54:03 +00:00
if (!VIRE_INVENT && !_inventDisplayedFl && !_vm->_globals.DESACTIVE_INVENT) {
_vm->_graphicsManager.no_scroll = 1;
_vm->_objectsManager.FLAG_VISIBLE_EFFACE = 4;
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.FLAG_VISIBLE = false;
for (int v1 = 0; v1 <= 1; v1++) {
INVENT_ANIM();
_vm->_eventsManager.XMOUSE();
_vm->_eventsManager.YMOUSE();
_vm->_eventsManager.VBL();
}
_vm->_dialogsManager.Winventaire = g_PTRNUL;
LABEL_7:
_vm->_eventsManager.souris_bb = 0;
_vm->_eventsManager.souris_b = 0;
_vm->_globals.DESACTIVE_INVENT = true;
_vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
switch (_vm->_globals.FR) {
case 0:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTAN.SPR");
break;
case 1:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTFR.SPR");
break;
case 2:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTES.SPR");
break;
}
2012-11-23 21:21:35 +00:00
Common::File f;
if (!f.open(_vm->_globals.NFICHIER))
error("Error opening file - %s", _vm->_globals.NFICHIER.c_str());
2012-11-23 21:21:35 +00:00
size_t filesize = f.size();
_vm->_dialogsManager.Winventaire = _vm->_globals.dos_malloc2(filesize);
2012-12-09 19:22:12 +00:00
_vm->_fileManager.readStream(f, _vm->_dialogsManager.Winventaire, filesize);
f.close();
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENT2.SPR");
inventaire2 = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER);
2012-12-10 06:54:03 +00:00
int v19 = _inventX = _vm->_graphicsManager.ofscroll + 152;
_inventY = 114;
int v18 = _inventWidth = _vm->_objectsManager.getWidth(_vm->_dialogsManager.Winventaire, 0);
int v17 = _inventHeight = _vm->_objectsManager.getHeight(_vm->_dialogsManager.Winventaire, 0);
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire,
v19 + 300, 414, 0, 0, 0, 0);
2012-11-23 21:21:35 +00:00
int v15 = 0;
int v4 = 0;
for (int v14 = 1; v14 <= 5; v14++) {
2012-11-23 21:21:35 +00:00
int v16 = 0;
for (int v5 = 1; v5 <= 6; v5++) {
++v4;
2012-11-23 21:21:35 +00:00
int v6 = _vm->_globals.INVENTAIRE[v4];
if (v6 && v4 <= 29) {
2012-11-23 21:21:35 +00:00
byte *v7 = _vm->_objectsManager.CAPTURE_OBJET(v6, 0);
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v7, v19 + v16 + 6,
v15 + 120, _vm->_globals.OBJL, _vm->_globals.OBJH);
_vm->_globals.dos_free2(v7);
}
v16 += 54;
};
v15 += 38;
}
2012-12-10 06:54:03 +00:00
_vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire, _inventX, _inventY, _inventWidth, _inventHeight);
_vm->_eventsManager.souris_bb = 0;
2012-11-23 21:21:35 +00:00
bool v20 = false;
int v13 = 0;
// Main loop to select an inventory item
while (!_vm->shouldQuit()) {
// Turn on drawing the inventory dialog in the event manager
2012-12-10 06:54:03 +00:00
_inventDisplayedFl = true;
2012-11-23 21:21:35 +00:00
int v8 = _vm->_eventsManager.XMOUSE();
int v9 = _vm->_eventsManager.YMOUSE();
int v12 = _vm->_eventsManager.BMOUSE();
int v10 = v13;
int v11 = _vm->_linesManager.ZONE_OBJET(v8, v9);
v13 = v11;
if (v11 != v10)
_vm->_objectsManager.PARAMCADRE(v11);
if (_vm->_eventsManager.btsouris != 16) {
if ((uint16)(_vm->_eventsManager.btsouris - 1) > 1u) {
if (_vm->_eventsManager.btsouris != 3) {
if (v12 == 2) {
_vm->_objectsManager.OBJETPLUS(v13);
if (_vm->_eventsManager.btsouris != 23)
_vm->_eventsManager.CHANGE_MOUSE(_vm->_eventsManager.btsouris);
}
}
}
}
if (v12 == 1) {
if (_vm->_eventsManager.btsouris == 1 || _vm->_eventsManager.btsouris == 16 || !_vm->_eventsManager.btsouris || (uint16)(_vm->_eventsManager.btsouris - 2) <= 1u)
break;
v9 = v13;
_vm->_objectsManager.VALID_OBJET(_vm->_globals.INVENTAIRE[v13]);
if (_vm->_eventsManager.btsouris == 8)
2012-11-23 21:21:35 +00:00
v20 = true;
if (!v20) {
_vm->_scriptManager.TRAVAILOBJET = 1;
_vm->_globals.SAUVEGARDE->data[svField3] = _vm->_globals.OBJET_EN_COURS;
_vm->_globals.SAUVEGARDE->data[svField8] = _vm->_globals.INVENTAIRE[v13];
_vm->_globals.SAUVEGARDE->data[svField9] = _vm->_eventsManager.btsouris;
_vm->_objectsManager.OPTI_OBJET();
_vm->_scriptManager.TRAVAILOBJET = 0;
if (_vm->_soundManager.VOICEOFF == 1) {
do
_vm->_eventsManager.VBL();
while (!_vm->_globals.SORTIE && _vm->_eventsManager.BMOUSE() != 1);
_vm->_fontManager.TEXTE_OFF(9);
}
if (_vm->_globals.SORTIE) {
if (_vm->_globals.SORTIE == 2)
2012-11-23 21:21:35 +00:00
v20 = true;
_vm->_globals.SORTIE = 0;
2012-11-23 21:21:35 +00:00
if (!v20) {
inventaire2 = _vm->_globals.dos_free2(inventaire2);
if (g_PTRNUL != _vm->_dialogsManager.Winventaire)
_vm->_dialogsManager.Winventaire = _vm->_globals.dos_free2(_vm->_dialogsManager.Winventaire);
goto LABEL_7;
}
2012-11-23 21:21:35 +00:00
} else if (!v20) {
2012-12-10 06:54:03 +00:00
_inventDisplayedFl = true;
}
}
}
if (VIRE_INVENT == true)
2012-11-23 21:21:35 +00:00
v20 = true;
if (v20)
break;
_vm->_eventsManager.VBL();
if ((uint16)(_vm->_globals.ECRAN - 35) <= 5u)
_vm->_objectsManager.SPECIAL_JEU();
}
_vm->_fontManager.TEXTE_OFF(9);
2012-12-10 06:54:03 +00:00
if (_inventDisplayedFl) {
_inventDisplayedFl = false;
2012-11-23 21:21:35 +00:00
// v9 = 114;
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, v19, 114, v18, v17, _vm->_graphicsManager.VESA_BUFFER, v19, 114);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v19, 114, v19 + v18, v18 + 114);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.BOBTOUS = true;
}
if (_vm->_dialogsManager.Winventaire != g_PTRNUL)
_vm->_dialogsManager.Winventaire = _vm->_globals.dos_free2(_vm->_dialogsManager.Winventaire);
inventaire2 = _vm->_globals.dos_free2(inventaire2);
if (_vm->_eventsManager.btsouris == 1)
showOptionsDialog();
2012-12-10 06:54:03 +00:00
else if (_vm->_eventsManager.btsouris == 3)
_vm->_dialogsManager.showLoadGame();
else if (_vm->_eventsManager.btsouris == 2)
_vm->_dialogsManager.showSaveGame();
_vm->_eventsManager.btsouris = 4;
_vm->_eventsManager.CHANGE_MOUSE(4);
_vm->_objectsManager.old_cady = 0;
_vm->_objectsManager.cady = 0;
_vm->_objectsManager.old_cadx = 0;
_vm->_objectsManager.cadx = 0;
_vm->_globals.DESACTIVE_INVENT = false;
_vm->_graphicsManager.no_scroll = 0;
}
}
void DialogsManager::INVENT_ANIM() {
if (!_vm->_globals.DESACTIVE_INVENT) {
if (_vm->_objectsManager.FLAG_VISIBLE_EFFACE && !_vm->_objectsManager.FLAG_VISIBLE) {
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_objectsManager.I_old_x, 27, 48, 38,
_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.I_old_x, 27);
_vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_objectsManager.I_old_x, 27, _vm->_objectsManager.I_old_x + 48, 65);
--_vm->_objectsManager.FLAG_VISIBLE_EFFACE;
}
if (_vm->_objectsManager.FLAG_VISIBLE) {
if (_vm->_objectsManager.I_old_x <= 1)
_vm->_objectsManager.I_old_x = 2;
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_objectsManager.I_old_x, 27, 48, 38,
_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.I_old_x, 27);
_vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_objectsManager.I_old_x, 27, _vm->_objectsManager.I_old_x + 48, 65);
2012-11-23 21:21:35 +00:00
int v0 = _vm->_graphicsManager.ofscroll + 2;
int v1 = _vm->_graphicsManager.ofscroll + 2;
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.ICONE, v1 + 300, 327, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(v1, 27, v1 + 45, 62);
_vm->_objectsManager.I_old_x = v0;
}
if (_vm->_globals.SAUVEGARDE->data[svField357] == 1) {
if (_vm->_globals.SAUVEGARDE->data[svField353] == 1)
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
if (_vm->_globals.SAUVEGARDE->data[svField355] == 1)
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 866, 325, 1, 0, 0, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
_vm->_graphicsManager.Ajoute_Segment_Vesa(566, 25, 594, 60);
}
if (_vm->_globals.SAUVEGARDE->data[svField356] == 1) {
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
}
if (_vm->_globals.SAUVEGARDE->data[svField354] == 1) {
_vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
_vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
}
}
}
2012-12-10 06:54:03 +00:00
/**
* Test dialog opening
*/
void DialogsManager::testDialogOpening() {
if (_vm->_globals.PLAN_FLAG)
_vm->_eventsManager.GAME_KEY = KEY_NONE;
if (_vm->_eventsManager.GAME_KEY != KEY_NONE) {
if (!INVENTFLAG) {
2012-10-28 11:17:55 +00:00
DIALOG_KEY key = _vm->_eventsManager.GAME_KEY;
_vm->_eventsManager.GAME_KEY = KEY_NONE;
INVENTFLAG = true;
switch (key) {
case KEY_INVENTORY:
_vm->_dialogsManager.showInventory();
break;
case KEY_OPTIONS:
_vm->_graphicsManager.no_scroll = 1;
_vm->_dialogsManager.showOptionsDialog();
_vm->_graphicsManager.no_scroll = 0;
break;
case KEY_LOAD:
_vm->_graphicsManager.no_scroll = 1;
2012-12-10 06:54:03 +00:00
_vm->_dialogsManager.showLoadGame();
_vm->_graphicsManager.no_scroll = 0;
break;
case KEY_SAVE:
_vm->_graphicsManager.no_scroll = 1;
2012-12-10 06:54:03 +00:00
_vm->_dialogsManager.showSaveGame();
_vm->_graphicsManager.no_scroll = 0;
break;
default:
break;
}
INVENTFLAG = false;
_vm->_eventsManager.GAME_KEY = KEY_NONE;
}
}
}
2012-12-10 06:54:03 +00:00
/**
* Load Game dialog
*/
void DialogsManager::showLoadGame() {
int slotNumber;
_vm->_eventsManager.VBL();
2012-12-10 06:54:03 +00:00
showSaveLoad(2);
do {
do {
2012-12-10 06:54:03 +00:00
slotNumber = searchSavegames();
_vm->_eventsManager.VBL();
} while (_vm->_eventsManager.BMOUSE() != 1);
} while (!slotNumber);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.SL_FLAG = false;
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
_vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, 457, 413);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.BOBTOUS = true;
_vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
_vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
_vm->_objectsManager.SL_X = 0;
_vm->_objectsManager.SL_Y = 0;
if (slotNumber != 7) {
_vm->_saveLoadManager.restore(slotNumber);
}
_vm->_objectsManager.CHANGE_OBJET(14);
}
2012-12-10 06:54:03 +00:00
/**
* Save Game dialog
*/
void DialogsManager::showSaveGame() {
int slotNumber;
Common::String saveName;
_vm->_eventsManager.VBL();
2012-12-10 06:54:03 +00:00
showSaveLoad(1);
do {
do {
2012-12-10 06:54:03 +00:00
slotNumber = searchSavegames();
_vm->_eventsManager.VBL();
} while (!_vm->shouldQuit() && _vm->_eventsManager.BMOUSE() != 1);
} while (!_vm->shouldQuit() && !slotNumber);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.SL_FLAG = false;
_vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
_vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, _vm->_eventsManager.start_x + 457, 413);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.BOBTOUS = true;
_vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
_vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
_vm->_objectsManager.SL_X = 0;
_vm->_objectsManager.SL_Y = 0;
if (slotNumber != 7) {
// Since the original GUI doesn't support save names, use a default name
saveName = Common::String::format("Save #%d", slotNumber);
// Save the game
_vm->_saveLoadManager.save(slotNumber, saveName);
}
}
2012-12-10 06:54:03 +00:00
/**
* Load/Save dialog
*/
void DialogsManager::showSaveLoad(int a1) {
int slotNumber;
hopkinsSavegameHeader header;
byte *thumb;
switch (_vm->_globals.FR) {
case 0:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEAN.SPR");
break;
case 1:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEFR.SPR");
break;
case 2:
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEES.SPR");
break;
}
_vm->_objectsManager.SL_SPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
2012-12-09 19:22:12 +00:00
_vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVE2.SPR");
_vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 483, 360, 0);
if (_vm->_globals.FR) {
if (a1 == 1)
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 525, 375, 1);
if (a1 == 2)
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 515, 375, 2);
} else {
if (a1 == 1)
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 535, 372, 1);
if (a1 == 2)
_vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 539, 372, 2);
}
for (slotNumber = 1; slotNumber <= 6; ++slotNumber) {
if (_vm->_saveLoadManager.readSavegameHeader(slotNumber, header)) {
2012-11-30 12:15:47 +00:00
Graphics::Surface thumb8;
_vm->_saveLoadManager.convertThumb16To8(header.thumbnail, &thumb8);
thumb = (byte *)thumb8.pixels;
switch (slotNumber) {
case 1:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 112, 0x80u, 87);
break;
case 2:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 112, 0x80u, 87);
break;
case 3:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 203, 0x80u, 87);
break;
case 4:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 203, 0x80u, 87);
break;
case 5:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 294, 0x80u, 87);
break;
case 6:
_vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 294, 0x80u, 87);
break;
}
2012-11-30 12:15:47 +00:00
thumb8.free();
header.thumbnail->free();
delete header.thumbnail;
}
}
_vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 183, 60, 0x112u, 353);
2012-10-29 22:08:23 +00:00
_vm->_objectsManager.SL_FLAG = true;
_vm->_objectsManager.SL_MODE = a1;
_vm->_objectsManager.SL_X = 0;
_vm->_objectsManager.SL_Y = 0;
}
2012-12-10 06:54:03 +00:00
/**
* Search savegames
*/
int DialogsManager::searchSavegames() {
int slotNumber = 0;
int xp = _vm->_eventsManager.XMOUSE();
int yp = _vm->_eventsManager.YMOUSE();
_vm->_graphicsManager.ofscroll = _vm->_eventsManager.start_x;
if ((uint16)(yp - 112) <= 0x56u) {
if (xp > _vm->_eventsManager.start_x + 189 && xp < _vm->_eventsManager.start_x + 318)
slotNumber = 1;
if ((uint16)(yp - 112) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
slotNumber = 2;
}
if ((uint16)(yp - 203) <= 0x56u) {
if (xp > _vm->_graphicsManager.ofscroll + 189 && xp < _vm->_graphicsManager.ofscroll + 318)
slotNumber = 3;
if ((uint16)(yp - 203) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
slotNumber = 4;
}
if ((uint16)(yp - 294) <= 0x56u) {
if (xp > _vm->_graphicsManager.ofscroll + 189 && xp < _vm->_graphicsManager.ofscroll + 318)
slotNumber = 5;
if ((uint16)(yp - 294) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
slotNumber = 6;
}
if ((uint16)(yp - 388) <= 0x10u && xp > _vm->_graphicsManager.ofscroll + 273 && xp < _vm->_graphicsManager.ofscroll + 355)
slotNumber = 7;
2012-11-21 21:42:51 +00:00
switch (slotNumber) {
case 1:
_vm->_objectsManager.SL_X = 189;
_vm->_objectsManager.SL_Y = 111;
2012-11-21 21:42:51 +00:00
break;
case 2:
_vm->_objectsManager.SL_X = 322;
_vm->_objectsManager.SL_Y = 111;
2012-11-21 21:42:51 +00:00
break;
case 3:
_vm->_objectsManager.SL_X = 189;
_vm->_objectsManager.SL_Y = 202;
2012-11-21 21:42:51 +00:00
break;
case 4:
_vm->_objectsManager.SL_X = 322;
_vm->_objectsManager.SL_Y = 202;
2012-11-21 21:42:51 +00:00
break;
case 5:
_vm->_objectsManager.SL_X = 189;
_vm->_objectsManager.SL_Y = 293;
2012-11-21 21:42:51 +00:00
break;
case 6:
_vm->_objectsManager.SL_X = 322;
_vm->_objectsManager.SL_Y = 293;
2012-11-21 21:42:51 +00:00
break;
case 0:
case 7:
_vm->_objectsManager.SL_X = 0;
_vm->_objectsManager.SL_Y = 0;
2012-11-21 21:42:51 +00:00
break;
}
return slotNumber;
}
} // End of namespace Hopkins