2008-07-03 10:10:29 +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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-07-07 15:42:26 +00:00
|
|
|
#ifndef COMMON_VIRTUAL_KEYBOARD_H
|
|
|
|
#define COMMON_VIRTUAL_KEYBOARD_H
|
2008-07-03 10:10:29 +00:00
|
|
|
|
|
|
|
class OSystem;
|
|
|
|
|
2008-07-07 14:30:11 +00:00
|
|
|
#include "common/events.h"
|
2008-07-03 22:38:19 +00:00
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
2008-07-07 15:06:43 +00:00
|
|
|
#include "common/image-map.h"
|
2008-07-04 17:55:19 +00:00
|
|
|
#include "common/keyboard.h"
|
2008-07-09 13:33:36 +00:00
|
|
|
#include "common/queue.h"
|
2008-07-03 10:10:29 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
2008-07-07 15:42:26 +00:00
|
|
|
namespace Common {
|
2008-07-03 10:10:29 +00:00
|
|
|
|
2008-07-03 22:38:19 +00:00
|
|
|
class VirtualKeyboardParser;
|
|
|
|
|
2008-07-04 11:38:15 +00:00
|
|
|
class VirtualKeyboard {
|
2008-07-07 14:30:11 +00:00
|
|
|
|
2008-07-03 22:38:19 +00:00
|
|
|
enum EventType {
|
|
|
|
kEventKey,
|
|
|
|
kEventSwitchMode,
|
2008-07-07 15:45:48 +00:00
|
|
|
kEventClose
|
2008-07-03 22:38:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Event {
|
|
|
|
Common::String name;
|
|
|
|
EventType type;
|
2008-07-11 20:10:14 +00:00
|
|
|
Graphics::Surface *rollOverImage;
|
2008-07-03 22:38:19 +00:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, Event, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> EventMap;
|
|
|
|
|
|
|
|
struct Mode {
|
|
|
|
Common::String name;
|
|
|
|
Common::String resolution;
|
|
|
|
Common::String bitmapName;
|
|
|
|
Graphics::Surface *image;
|
2008-07-11 20:10:14 +00:00
|
|
|
OverlayColor transparentColor;
|
2008-07-03 22:38:19 +00:00
|
|
|
Common::ImageMap imageMap;
|
|
|
|
EventMap events;
|
2008-07-04 17:55:19 +00:00
|
|
|
Mode() : image(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, Mode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ModeMap;
|
|
|
|
|
|
|
|
enum HorizontalAlignment {
|
|
|
|
kAlignLeft,
|
|
|
|
kAlignCentre,
|
|
|
|
kAlignRight
|
|
|
|
};
|
|
|
|
|
|
|
|
enum VerticalAlignment {
|
|
|
|
kAlignTop,
|
|
|
|
kAlignMiddle,
|
|
|
|
kAlignBottom
|
2008-07-03 22:38:19 +00:00
|
|
|
};
|
2008-07-03 10:10:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
VirtualKeyboard();
|
|
|
|
virtual ~VirtualKeyboard();
|
2008-07-11 20:10:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads the keyboard pack with the given name.
|
|
|
|
* The system first looks for an uncompressed keyboard pack by searching
|
|
|
|
* for packName.xml in the filesystem, if this does not exist then it
|
|
|
|
* searches for a compressed keyboard pack by looking for packName.zip.
|
|
|
|
* @param packName name of the keyboard pack
|
|
|
|
*/
|
2008-07-03 22:38:19 +00:00
|
|
|
bool loadKeyboardPack(Common::String packName);
|
2008-07-11 20:10:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the keyboard, starting an event loop that will intercept all
|
|
|
|
* user input (like a modal GUI dialog).
|
|
|
|
* It is assumed that the game has been paused, before this is called
|
|
|
|
*/
|
2008-07-03 10:10:29 +00:00
|
|
|
void show();
|
2008-07-11 20:10:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the keyboard, ending the event loop.
|
|
|
|
*/
|
2008-07-07 14:30:11 +00:00
|
|
|
void hide();
|
2008-07-11 20:10:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the keyboard is currently being shown
|
|
|
|
*/
|
2008-07-07 14:30:11 +00:00
|
|
|
bool isDisplaying() {
|
|
|
|
return _displaying;
|
|
|
|
}
|
2008-07-11 20:10:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the keyboard is loaded and ready to be shown
|
|
|
|
*/
|
2008-07-07 14:52:30 +00:00
|
|
|
bool isLoaded() {
|
|
|
|
return _loaded;
|
|
|
|
}
|
2008-07-07 14:30:11 +00:00
|
|
|
|
2008-07-08 15:03:39 +00:00
|
|
|
protected:
|
2008-07-03 10:10:29 +00:00
|
|
|
OSystem *_system;
|
2008-07-08 15:03:39 +00:00
|
|
|
|
|
|
|
static const int SNAP_WIDTH = 10;
|
2008-07-03 22:38:19 +00:00
|
|
|
|
|
|
|
friend class VirtualKeyboardParser;
|
|
|
|
VirtualKeyboardParser *_parser;
|
2008-07-03 10:10:29 +00:00
|
|
|
|
2008-07-04 17:55:19 +00:00
|
|
|
// TODO : sort order of all this stuff
|
|
|
|
void reset();
|
2008-07-09 13:33:36 +00:00
|
|
|
void deleteEventData();
|
|
|
|
void screenChanged();
|
2008-07-09 11:30:49 +00:00
|
|
|
bool checkModeResolutions();
|
2008-07-08 15:03:39 +00:00
|
|
|
void setDefaultPosition();
|
|
|
|
void move(int16 x, int16 y);
|
2008-07-07 14:30:11 +00:00
|
|
|
void switchMode(Mode *newMode);
|
2008-07-04 17:55:19 +00:00
|
|
|
void switchMode(const Common::String& newMode);
|
2008-07-08 15:03:39 +00:00
|
|
|
Common::String findArea(int16 x, int16 y);
|
|
|
|
void processClick(const Common::String &area);
|
2008-07-03 10:10:29 +00:00
|
|
|
void runLoop();
|
2008-07-07 14:30:11 +00:00
|
|
|
void redraw();
|
2008-07-03 10:10:29 +00:00
|
|
|
|
2008-07-11 20:10:14 +00:00
|
|
|
Graphics::Surface _overlayBackup;
|
|
|
|
|
2008-07-07 14:52:30 +00:00
|
|
|
bool _loaded;
|
2008-07-04 17:55:19 +00:00
|
|
|
bool _displaying;
|
2008-07-07 14:30:11 +00:00
|
|
|
bool _needRedraw;
|
2008-07-08 15:03:39 +00:00
|
|
|
bool _firstRun;
|
2008-07-04 17:55:19 +00:00
|
|
|
|
|
|
|
ModeMap _modes;
|
|
|
|
Mode *_initialMode;
|
|
|
|
Mode *_currentMode;
|
|
|
|
|
2008-07-09 13:33:36 +00:00
|
|
|
int _lastScreenChanged;
|
2008-07-08 15:03:39 +00:00
|
|
|
Common::Rect _kbdBound;
|
|
|
|
|
2008-07-04 17:55:19 +00:00
|
|
|
HorizontalAlignment _hAlignment;
|
|
|
|
VerticalAlignment _vAlignment;
|
|
|
|
|
2008-07-08 15:03:39 +00:00
|
|
|
Common::String _areaDown;
|
|
|
|
Common::Point _dragPoint;
|
|
|
|
bool _drag;
|
2008-07-07 14:30:11 +00:00
|
|
|
|
2008-07-09 13:33:36 +00:00
|
|
|
Common::Queue<Common::KeyState> _keyQueue;
|
2008-07-07 14:30:11 +00:00
|
|
|
Common::KeyState *_keyDown;
|
2008-07-04 17:55:19 +00:00
|
|
|
|
2008-07-11 20:10:14 +00:00
|
|
|
static const int kCursorAnimateDelay = 250;
|
|
|
|
int _cursorAnimateCounter;
|
|
|
|
int _cursorAnimateTimer;
|
|
|
|
byte _cursor[2048];
|
|
|
|
void setupCursor();
|
|
|
|
void removeCursor();
|
|
|
|
void animateCursor();
|
|
|
|
|
2008-07-03 10:10:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // End of namespace GUI
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|