2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-06-22 21:42:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* 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
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-06-22 21:42:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 17:52:55 +00:00
|
|
|
#ifndef SKY_CONTROL_H
|
|
|
|
#define SKY_CONTROL_H
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-22 22:18:56 +00:00
|
|
|
#include "common/events.h"
|
2003-06-22 21:42:59 +00:00
|
|
|
#include "common/scummsys.h"
|
2010-03-18 15:09:24 +00:00
|
|
|
#include "common/str-array.h"
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2004-01-03 01:58:58 +00:00
|
|
|
class OSystem;
|
2005-05-10 23:17:38 +00:00
|
|
|
namespace Common {
|
2011-04-25 19:29:26 +00:00
|
|
|
class SaveFileManager;
|
2005-05-10 23:17:38 +00:00
|
|
|
}
|
2004-01-03 01:58:58 +00:00
|
|
|
|
|
|
|
namespace Sky {
|
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
class Disk;
|
|
|
|
class Screen;
|
|
|
|
class Logic;
|
|
|
|
class Mouse;
|
|
|
|
class Text;
|
|
|
|
class MusicBase;
|
|
|
|
class Sound;
|
2004-12-15 06:48:08 +00:00
|
|
|
class SkyCompact;
|
2003-10-05 20:21:20 +00:00
|
|
|
struct Compact;
|
2009-03-06 00:41:46 +00:00
|
|
|
struct DataFileHeader;
|
2003-10-05 20:21:20 +00:00
|
|
|
struct MegaSet;
|
2003-07-01 13:04:00 +00:00
|
|
|
|
2003-06-22 21:42:59 +00:00
|
|
|
#define MAX_SAVE_GAMES 999
|
|
|
|
#define MAX_TEXT_LEN 80
|
|
|
|
#define PAN_LINE_WIDTH 184
|
|
|
|
#define PAN_CHAR_HEIGHT 12
|
2003-07-05 16:40:12 +00:00
|
|
|
#define STATUS_WIDTH 146
|
2003-06-22 21:42:59 +00:00
|
|
|
#define MPNL_X 60 // Main Panel
|
|
|
|
#define MPNL_Y 10
|
|
|
|
|
|
|
|
#define SPNL_X 20 // Save Panel
|
|
|
|
#define SPNL_Y 20
|
|
|
|
#define SP_HEIGHT 149
|
|
|
|
#define SP_TOP_GAP 12
|
|
|
|
#define SP_BOT_GAP 27
|
2003-07-04 22:39:10 +00:00
|
|
|
#define CROSS_SZ_X 27
|
|
|
|
#define CROSS_SZ_Y 22
|
|
|
|
|
|
|
|
#define TEXT_FLAG_MASK (SF_ALLOW_SPEECH | SF_ALLOW_TEXT)
|
2003-06-22 21:42:59 +00:00
|
|
|
|
|
|
|
#define GAME_NAME_X (SPNL_X + 18) // x coordinate of game names
|
|
|
|
#define GAME_NAME_Y (SPNL_Y + SP_TOP_GAP) // start y coord of game names
|
|
|
|
#define MAX_ON_SCREEN ((SP_HEIGHT - SP_TOP_GAP - SP_BOT_GAP) / PAN_CHAR_HEIGHT) // no of save games on screen
|
|
|
|
#define CP_PANEL 60400 // main panel sprite
|
|
|
|
|
|
|
|
#define MAINPANEL 0
|
|
|
|
#define SAVEPANEL 1
|
|
|
|
|
|
|
|
#define NO_MASK false
|
|
|
|
#define WITH_MASK true
|
|
|
|
|
|
|
|
// resource's onClick routines
|
|
|
|
#define DO_NOTHING 0
|
|
|
|
#define REST_GAME_PANEL 1
|
|
|
|
#define SAVE_GAME_PANEL 2
|
|
|
|
#define SAVE_A_GAME 3
|
|
|
|
#define RESTORE_A_GAME 4
|
|
|
|
#define SP_CANCEL 5
|
|
|
|
#define SHIFT_DOWN_FAST 6
|
|
|
|
#define SHIFT_DOWN_SLOW 7
|
|
|
|
#define SHIFT_UP_FAST 8
|
|
|
|
#define SHIFT_UP_SLOW 9
|
|
|
|
#define SPEED_SLIDE 10
|
|
|
|
#define MUSIC_SLIDE 11
|
|
|
|
#define TOGGLE_FX 12
|
|
|
|
#define TOGGLE_MS 13
|
2003-06-27 02:54:05 +00:00
|
|
|
#define TOGGLE_TEXT 14
|
|
|
|
#define EXIT 15
|
|
|
|
#define RESTART 16
|
|
|
|
#define QUIT_TO_DOS 17
|
2003-07-11 22:19:16 +00:00
|
|
|
#define RESTORE_AUTO 18
|
2003-06-22 21:42:59 +00:00
|
|
|
|
|
|
|
// onClick return codes
|
|
|
|
#define CANCEL_PRESSED 100
|
|
|
|
#define NAME_TOO_SHORT 101
|
|
|
|
#define GAME_SAVED 102
|
|
|
|
#define SHIFTED 103
|
|
|
|
#define TOGGLED 104
|
|
|
|
#define RESTARTED 105
|
|
|
|
#define GAME_RESTORED 106
|
|
|
|
#define RESTORE_FAILED 107
|
|
|
|
#define NO_DISK_SPACE 108
|
|
|
|
#define SPEED_CHANGED 109
|
|
|
|
#define QUIT_PANEL 110
|
|
|
|
|
|
|
|
#define SLOW 0
|
|
|
|
#define FAST 1
|
|
|
|
|
2009-02-14 00:21:53 +00:00
|
|
|
#define SPEED_MULTIPLY 12
|
2003-06-27 02:54:05 +00:00
|
|
|
|
|
|
|
//-
|
|
|
|
#define SAVE_EXT 1
|
|
|
|
#define SAVE_MEGA0 2
|
|
|
|
#define SAVE_MEGA1 4
|
|
|
|
#define SAVE_MEGA2 8
|
|
|
|
#define SAVE_MEGA3 16
|
2003-07-01 01:29:29 +00:00
|
|
|
#define SAVE_GRAFX 32
|
|
|
|
#define SAVE_TURNP 64
|
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
#define SAVE_FILE_REVISION 6
|
|
|
|
#define OLD_SAVEGAME_TYPE 5
|
2003-06-27 02:54:05 +00:00
|
|
|
|
2003-07-01 01:29:29 +00:00
|
|
|
struct AllocedMem {
|
|
|
|
uint16 *mem;
|
|
|
|
AllocedMem *next;
|
|
|
|
};
|
2003-06-27 02:54:05 +00:00
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
class ConResource {
|
2003-06-22 21:42:59 +00:00
|
|
|
public:
|
2004-01-03 15:57:57 +00:00
|
|
|
ConResource(void *pSpData, uint32 pNSprites, uint32 pCurSprite, uint16 pX, uint16 pY, uint32 pText, uint8 pOnClick, OSystem *system, uint8 *screen);
|
2009-11-02 21:54:57 +00:00
|
|
|
virtual ~ConResource() {}
|
2012-02-15 15:53:31 +00:00
|
|
|
void setSprite(void *pSpData) { _spriteData = (DataFileHeader *)pSpData; }
|
2007-04-25 19:31:23 +00:00
|
|
|
void setText(uint32 pText) { if (pText) _text = pText + 0x7000; else _text = 0; }
|
|
|
|
void setXY(uint16 x, uint16 y) { _x = x; _y = y; }
|
2003-06-22 21:42:59 +00:00
|
|
|
bool isMouseOver(uint32 mouseX, uint32 mouseY);
|
|
|
|
virtual void drawToScreen(bool doMask);
|
|
|
|
|
2009-03-06 00:41:46 +00:00
|
|
|
DataFileHeader *_spriteData;
|
2003-06-22 21:42:59 +00:00
|
|
|
uint32 _numSprites, _curSprite;
|
|
|
|
uint16 _x, _y;
|
|
|
|
uint32 _text;
|
|
|
|
uint8 _onClick;
|
|
|
|
OSystem *_system;
|
|
|
|
uint8 *_screen;
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
class TextResource : public ConResource {
|
2003-06-22 21:42:59 +00:00
|
|
|
public:
|
2004-01-03 15:57:57 +00:00
|
|
|
TextResource(void *pSpData, uint32 pNSprites, uint32 pCurSprite, uint16 pX, uint16 pY, uint32 pText, uint8 pOnClick, OSystem *system, uint8 *screen);
|
2009-11-02 21:54:57 +00:00
|
|
|
virtual ~TextResource();
|
2003-06-22 21:42:59 +00:00
|
|
|
virtual void drawToScreen(bool doMask);
|
2009-11-02 21:54:57 +00:00
|
|
|
void flushForRedraw();
|
2003-06-22 21:42:59 +00:00
|
|
|
private:
|
|
|
|
uint16 _oldX, _oldY;
|
|
|
|
uint8 *_oldScreen;
|
|
|
|
};
|
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
class ControlStatus {
|
2003-07-05 16:40:12 +00:00
|
|
|
public:
|
2004-01-03 15:57:57 +00:00
|
|
|
ControlStatus(Text *skyText, OSystem *system, uint8 *scrBuf);
|
2009-11-02 21:54:57 +00:00
|
|
|
~ControlStatus();
|
2003-07-05 16:40:12 +00:00
|
|
|
void setToText(const char *newText);
|
|
|
|
void setToText(uint16 textNum);
|
2009-11-02 21:54:57 +00:00
|
|
|
void drawToScreen();
|
2003-07-05 16:40:12 +00:00
|
|
|
private:
|
2004-01-03 15:57:57 +00:00
|
|
|
TextResource *_statusText;
|
2009-03-06 00:41:46 +00:00
|
|
|
DataFileHeader *_textData;
|
2004-01-03 15:57:57 +00:00
|
|
|
Text *_skyText;
|
2003-07-05 16:40:12 +00:00
|
|
|
OSystem *_system;
|
|
|
|
uint8 *_screenBuf;
|
|
|
|
};
|
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
class Control {
|
2003-06-22 21:42:59 +00:00
|
|
|
public:
|
2005-05-10 23:17:38 +00:00
|
|
|
Control(Common::SaveFileManager *saveFileMan, Screen *screen, Disk *disk, Mouse *mouse, Text *text, MusicBase *music, Logic *logic, Sound *sound, SkyCompact *skyCompact, OSystem *system);
|
2009-11-02 21:54:57 +00:00
|
|
|
void doControlPanel();
|
|
|
|
void doLoadSavePanel();
|
|
|
|
void restartGame();
|
|
|
|
void showGameQuitMsg();
|
|
|
|
void doAutoSave();
|
2003-07-12 05:26:23 +00:00
|
|
|
uint16 quickXRestore(uint16 slot);
|
2009-11-02 21:54:57 +00:00
|
|
|
bool loadSaveAllowed();
|
2003-11-08 20:27:27 +00:00
|
|
|
|
2008-11-12 20:41:19 +00:00
|
|
|
uint16 _selectedGame;
|
2012-02-13 20:23:47 +00:00
|
|
|
uint16 saveGameToFile(bool fromControlPanel, const char *filename = 0);
|
2008-11-12 20:41:19 +00:00
|
|
|
|
2010-03-18 15:09:24 +00:00
|
|
|
void loadDescriptions(Common::StringArray &list);
|
|
|
|
void saveDescriptions(const Common::StringArray &list);
|
2008-11-12 20:41:19 +00:00
|
|
|
|
2003-06-22 21:42:59 +00:00
|
|
|
private:
|
2009-07-03 10:40:49 +00:00
|
|
|
int displayMessage(const char *altButton, const char *message, ...) GCC_PRINTF(3, 4);
|
2004-07-18 18:25:16 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void initPanel();
|
|
|
|
void removePanel();
|
2003-07-01 01:29:29 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void drawMainPanel();
|
2003-07-01 01:29:29 +00:00
|
|
|
|
2012-03-27 02:04:35 +00:00
|
|
|
/**
|
|
|
|
* Waits for a specified amount while still processing events.
|
|
|
|
*
|
|
|
|
* @param amount The duration in milliseconds to wait
|
|
|
|
*/
|
2003-07-01 23:31:29 +00:00
|
|
|
void delay(unsigned int amount);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2009-08-30 20:50:23 +00:00
|
|
|
void animClick(ConResource *pButton);
|
2003-07-05 15:47:45 +00:00
|
|
|
bool getYesNo(char *text);
|
2004-01-03 15:57:57 +00:00
|
|
|
void buttonControl(ConResource *pButton);
|
|
|
|
uint16 handleClick(ConResource *pButton);
|
2009-11-02 21:54:57 +00:00
|
|
|
uint16 doMusicSlide();
|
|
|
|
uint16 doSpeedSlide();
|
2007-02-10 18:10:55 +00:00
|
|
|
void toggleFx(ConResource *pButton);
|
2009-11-02 21:54:57 +00:00
|
|
|
uint16 toggleText();
|
2007-02-10 18:10:55 +00:00
|
|
|
void toggleMusic(ConResource *pButton);
|
2003-06-22 21:42:59 +00:00
|
|
|
uint16 shiftDown(uint8 speed);
|
|
|
|
uint16 shiftUp(uint8 speed);
|
2003-07-04 22:39:10 +00:00
|
|
|
void drawTextCross(uint32 flags);
|
|
|
|
void drawCross(uint16 x, uint16 y);
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2003-07-01 23:31:29 +00:00
|
|
|
uint16 saveRestorePanel(bool allowSave);
|
2010-03-18 15:09:24 +00:00
|
|
|
void setUpGameSprites(const Common::StringArray &saveGameNames, DataFileHeader **nameSprites, uint16 firstNum, uint16 selectedGame);
|
2009-03-06 00:41:46 +00:00
|
|
|
void showSprites(DataFileHeader **nameSprites, bool allowSave);
|
2008-02-27 15:44:39 +00:00
|
|
|
void handleKeyPress(Common::KeyState kbd, Common::String &textBuf);
|
2003-07-01 01:29:29 +00:00
|
|
|
|
2003-06-27 02:54:05 +00:00
|
|
|
uint32 prepareSaveData(uint8 *destBuf);
|
2003-07-01 01:29:29 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
bool autoSaveExists();
|
2003-07-11 22:19:16 +00:00
|
|
|
uint16 restoreGameFromFile(bool autoSave);
|
2004-12-15 06:48:08 +00:00
|
|
|
void importOldMegaSet(uint8 **srcPos, MegaSet *mega);
|
|
|
|
void importOldCompact(Compact* destCpt, uint8 **srcPos, uint16 numElems, uint16 type, char *name);
|
2003-07-01 01:29:29 +00:00
|
|
|
uint16 parseSaveData(uint8 *srcBuf);
|
|
|
|
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::SaveFileManager *_saveFileMan;
|
2004-12-15 06:48:08 +00:00
|
|
|
SkyCompact *_skyCompact;
|
2004-01-03 15:57:57 +00:00
|
|
|
Screen *_skyScreen;
|
|
|
|
Disk *_skyDisk;
|
|
|
|
Mouse *_skyMouse;
|
|
|
|
Text *_skyText;
|
|
|
|
MusicBase *_skyMusic;
|
|
|
|
Logic *_skyLogic;
|
|
|
|
Sound *_skySound;
|
2003-06-22 21:42:59 +00:00
|
|
|
OSystem *_system;
|
|
|
|
bool _mouseClicked;
|
2007-06-22 22:18:56 +00:00
|
|
|
Common::KeyState _keyPressed;
|
2006-03-26 06:22:41 +00:00
|
|
|
int _mouseWheel;
|
2003-06-22 21:42:59 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint8 *controlPanel;
|
|
|
|
uint8 *button;
|
|
|
|
uint8 *buttonDown;
|
|
|
|
uint8 *savePanel;
|
|
|
|
uint8 *yesNo;
|
|
|
|
uint8 *slide;
|
|
|
|
uint8 *slode;
|
|
|
|
uint8 *slode2;
|
|
|
|
uint8 *slide2;
|
|
|
|
uint8 *musicBodge;
|
|
|
|
} _sprites;
|
|
|
|
|
|
|
|
uint8 *_screenBuf;
|
|
|
|
int _lastButton;
|
|
|
|
uint32 _curButtonText;
|
|
|
|
uint16 _firstText;
|
2003-07-01 16:06:09 +00:00
|
|
|
uint16 _savedMouse;
|
2003-07-09 17:50:57 +00:00
|
|
|
uint32 _savedCharSet;
|
2003-07-04 20:31:41 +00:00
|
|
|
uint16 _enteredTextWidth;
|
2003-11-08 20:27:27 +00:00
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
ConResource *createResource(void *pSpData, uint32 pNSprites, uint32 pCurSprite, int16 pX, int16 pY, uint32 pText, uint8 pOnClick, uint8 panelType);
|
2003-07-01 23:31:29 +00:00
|
|
|
|
2009-03-06 00:41:46 +00:00
|
|
|
DataFileHeader *_textSprite;
|
2004-01-03 15:57:57 +00:00
|
|
|
TextResource *_text;
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
ConResource *_controlPanel, *_exitButton, *_slide, *_slide2, *_slode;
|
|
|
|
ConResource *_restorePanButton, *_savePanButton, *_dosPanButton, *_restartPanButton, *_fxPanButton, *_musicPanButton;
|
|
|
|
ConResource *_bodge, *_yesNo;
|
|
|
|
ConResource *_controlPanLookList[9];
|
2003-06-22 21:42:59 +00:00
|
|
|
|
|
|
|
//- Save/restore panel
|
2004-01-03 15:57:57 +00:00
|
|
|
ConResource *_savePanel;
|
|
|
|
ConResource *_saveButton, *_downFastButton, *_downSlowButton;
|
|
|
|
ConResource *_upFastButton, *_upSlowButton, *_quitButton, *_restoreButton;
|
|
|
|
ConResource *_autoSaveButton;
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
ConResource *_savePanLookList[6], *_restorePanLookList[7];
|
2003-07-03 22:32:18 +00:00
|
|
|
|
2004-01-03 15:57:57 +00:00
|
|
|
ControlStatus *_statusBar;
|
2003-07-05 16:40:12 +00:00
|
|
|
|
2003-07-12 03:40:44 +00:00
|
|
|
static char _quitTexts[16][35];
|
2003-07-04 22:39:10 +00:00
|
|
|
static uint8 _crossImg[594];
|
2003-06-22 21:42:59 +00:00
|
|
|
};
|
|
|
|
|
2004-01-03 01:58:58 +00:00
|
|
|
} // End of namespace Sky
|
|
|
|
|
2003-06-22 21:42:59 +00:00
|
|
|
#endif // CONTROL_H
|