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-12-20 09:18:43 +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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-12-20 09:18:43 +00:00
|
|
|
* 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-12-20 09:18:43 +00:00
|
|
|
*
|
2006-02-11 10:01:01 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-12-20 09:18:43 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 18:04:13 +00:00
|
|
|
#ifndef SWORD1_CONTROL_H
|
|
|
|
#define SWORD1_CONTROL_H
|
2003-12-20 09:18:43 +00:00
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/scummsys.h"
|
2007-06-22 21:34:03 +00:00
|
|
|
#include "common/events.h"
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/sworddefs.h"
|
2003-12-20 09:18:43 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
class OSystem;
|
2005-05-10 23:17:38 +00:00
|
|
|
namespace Common {
|
|
|
|
class SaveFileManager;
|
|
|
|
}
|
2004-01-11 15:47:41 +00:00
|
|
|
|
|
|
|
namespace Sword1 {
|
|
|
|
|
2003-12-20 09:18:43 +00:00
|
|
|
class ObjectMan;
|
|
|
|
class ResMan;
|
2004-01-11 15:47:41 +00:00
|
|
|
class Mouse;
|
|
|
|
class Music;
|
|
|
|
class Sound;
|
2003-12-20 09:18:43 +00:00
|
|
|
|
|
|
|
#define MAX_BUTTONS 16
|
|
|
|
|
|
|
|
#define CONTROL_NOTHING_DONE 0
|
|
|
|
#define CONTROL_GAME_RESTORED 1
|
|
|
|
#define CONTROL_RESTART_GAME 2
|
|
|
|
|
|
|
|
class ControlButton {
|
|
|
|
public:
|
2005-08-24 16:10:09 +00:00
|
|
|
ControlButton(uint16 x, uint16 y, uint32 resId, uint8 id, uint8 flag, ResMan *pResMan, uint8 *screenBuf, OSystem *system);
|
2003-12-20 09:18:43 +00:00
|
|
|
~ControlButton(void);
|
|
|
|
void draw(void);
|
|
|
|
bool wasClicked(uint16 mouseX, uint16 mouseY);
|
|
|
|
void setSelected(uint8 selected);
|
|
|
|
bool isSaveslot(void);
|
|
|
|
uint8 _id;
|
2005-08-24 16:10:09 +00:00
|
|
|
uint8 _flag;
|
2003-12-20 09:18:43 +00:00
|
|
|
private:
|
|
|
|
int _frameIdx;
|
|
|
|
uint16 _x, _y;
|
|
|
|
uint16 _width, _height;
|
|
|
|
uint32 _resId;
|
|
|
|
ResMan *_resMan;
|
|
|
|
uint8 *_dstBuf;
|
|
|
|
OSystem *_system;
|
|
|
|
};
|
|
|
|
|
2005-08-24 16:10:09 +00:00
|
|
|
enum {
|
|
|
|
kButtonOk = 1,
|
|
|
|
kButtonCancel = 2
|
|
|
|
};
|
|
|
|
|
2003-12-20 09:18:43 +00:00
|
|
|
struct ButtonInfo {
|
|
|
|
uint16 x, y;
|
|
|
|
uint32 resId, id;
|
2005-08-24 16:10:09 +00:00
|
|
|
uint8 flag;
|
2003-12-20 09:18:43 +00:00
|
|
|
};
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
class Control {
|
2003-12-20 09:18:43 +00:00
|
|
|
public:
|
2005-05-10 23:17:38 +00:00
|
|
|
Control(Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic);
|
2003-12-20 09:18:43 +00:00
|
|
|
uint8 runPanel(void);
|
|
|
|
void doRestore(void);
|
2003-12-30 22:57:52 +00:00
|
|
|
void askForCd(void);
|
|
|
|
bool savegamesExist(void);
|
2006-04-18 18:23:57 +00:00
|
|
|
bool restoreGameFromFile(uint8 slot);
|
2003-12-20 09:18:43 +00:00
|
|
|
private:
|
2004-03-28 12:59:51 +00:00
|
|
|
int displayMessage(const char *altButton, const char *message, ...);
|
|
|
|
|
2003-12-20 09:18:43 +00:00
|
|
|
void saveGameToFile(uint8 slot);
|
|
|
|
void readSavegameDescriptions(void);
|
|
|
|
void writeSavegameDescriptions(void);
|
|
|
|
void showSavegameNames(void);
|
|
|
|
void deselectSaveslots(void);
|
|
|
|
uint8 *_restoreBuf;
|
|
|
|
uint8 _saveFiles;
|
2008-08-15 20:49:56 +00:00
|
|
|
uint8 _numSaves;
|
2003-12-20 09:18:43 +00:00
|
|
|
uint8 _saveScrollPos;
|
|
|
|
uint8 _selectedSavegame;
|
2003-12-31 17:38:27 +00:00
|
|
|
uint8 _saveNames[64][32];
|
|
|
|
uint8 _oldName[32];
|
2004-05-12 06:21:44 +00:00
|
|
|
uint8 _cursorTick;
|
|
|
|
bool _cursorVisible;
|
2003-12-20 09:18:43 +00:00
|
|
|
|
|
|
|
uint8 getClicks(uint8 mode, uint8 *retVal);
|
|
|
|
uint8 handleButtonClick(uint8 id, uint8 mode, uint8 *retVal);
|
2004-01-07 17:47:46 +00:00
|
|
|
void handleVolumeClicks(void);
|
|
|
|
void changeVolume(uint8 id, uint8 action);
|
2003-12-20 09:18:43 +00:00
|
|
|
|
|
|
|
void setupMainPanel(void);
|
|
|
|
void setupSaveRestorePanel(bool saving);
|
2003-12-23 16:58:06 +00:00
|
|
|
void setupVolumePanel(void);
|
2004-01-04 06:31:29 +00:00
|
|
|
bool getConfirm(const uint8 *title);
|
2003-12-23 16:58:06 +00:00
|
|
|
|
2003-12-20 09:18:43 +00:00
|
|
|
void saveNameScroll(uint8 scroll, bool saving);
|
|
|
|
void saveNameSelect(uint8 id, bool saving);
|
|
|
|
bool saveToFile(void);
|
|
|
|
bool restoreFromFile(void);
|
2007-06-22 21:34:03 +00:00
|
|
|
bool keyAccepted(uint16 ascii);
|
|
|
|
void handleSaveKey(Common::KeyState kbd);
|
2003-12-20 09:18:43 +00:00
|
|
|
|
2004-01-07 17:47:46 +00:00
|
|
|
void renderVolumeBar(uint8 id, uint8 volL, uint8 volR);
|
2003-12-31 17:38:27 +00:00
|
|
|
uint16 getTextWidth(const uint8 *str);
|
|
|
|
void renderText(const uint8 *str, uint16 x, uint16 y, uint8 mode);
|
2003-12-20 09:18:43 +00:00
|
|
|
uint8 _numButtons;
|
|
|
|
uint8 _selectedButton;
|
|
|
|
void createButtons(const ButtonInfo *buttons, uint8 num);
|
|
|
|
void destroyButtons(void);
|
|
|
|
ControlButton *_buttons[MAX_BUTTONS];
|
2004-01-07 17:47:46 +00:00
|
|
|
static const ButtonInfo _deathButtons[3], _panelButtons[7], _saveButtons[16], _volumeButtons[4];
|
2003-12-31 17:38:27 +00:00
|
|
|
static const uint8 _languageStrings[8 * 20][43];
|
|
|
|
const uint8 (*_lStrings)[43];
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::SaveFileManager *_saveFileMan;
|
2003-12-20 09:18:43 +00:00
|
|
|
ObjectMan *_objMan;
|
|
|
|
ResMan *_resMan;
|
|
|
|
OSystem *_system;
|
2004-01-11 15:47:41 +00:00
|
|
|
Mouse *_mouse;
|
|
|
|
Music *_music;
|
|
|
|
Sound *_sound;
|
2003-12-29 15:38:16 +00:00
|
|
|
uint8 *_font, *_redFont;
|
2003-12-20 09:18:43 +00:00
|
|
|
uint8 *_screenBuf;
|
2007-06-22 21:34:03 +00:00
|
|
|
Common::KeyState _keyPressed;
|
2003-12-20 09:18:43 +00:00
|
|
|
void delay(uint32 msecs);
|
2007-11-28 15:00:41 +00:00
|
|
|
Common::Point _mouseCoord;
|
|
|
|
uint16 _mouseState;
|
2004-01-07 17:47:46 +00:00
|
|
|
bool _mouseDown;
|
2003-12-20 09:18:43 +00:00
|
|
|
};
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
} // End of namespace Sword1
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-12-20 09:18:43 +00:00
|
|
|
#endif //BSCONTROL_H
|
|
|
|
|