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.
|
2005-04-05 18:08:02 +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
|
2005-04-05 18:08:02 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* 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.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2005-04-05 18:08:02 +00:00
|
|
|
#ifndef GOB_UTIL_H
|
|
|
|
#define GOB_UTIL_H
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-06-23 17:00:27 +00:00
|
|
|
#include "common/keyboard.h"
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/video.h"
|
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
#define KEYBUFSIZE 16
|
|
|
|
|
|
|
|
class Util {
|
|
|
|
public:
|
|
|
|
struct ListNode;
|
2006-01-29 02:27:10 +00:00
|
|
|
struct ListNode {
|
2006-01-03 23:14:39 +00:00
|
|
|
void *pData;
|
|
|
|
struct ListNode *pNext;
|
|
|
|
struct ListNode *pPrev;
|
|
|
|
ListNode() : pData(0), pNext(0), pPrev(0) {}
|
2006-01-29 02:27:10 +00:00
|
|
|
};
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
struct List {
|
2006-01-03 23:14:39 +00:00
|
|
|
ListNode *pHead;
|
|
|
|
ListNode *pTail;
|
|
|
|
List() : pHead(0), pTail(0) {}
|
2006-01-29 02:27:10 +00:00
|
|
|
};
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
uint32 getTimeKey(void);
|
|
|
|
int16 getRandom(int16 max);
|
|
|
|
void beep(int16 freq);
|
|
|
|
|
|
|
|
void delay(uint16 msecs);
|
|
|
|
void longDelay(uint16 msecs);
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void initInput(void);
|
2007-04-13 07:48:26 +00:00
|
|
|
void processInput(bool scroll = false);
|
2007-03-20 14:51:57 +00:00
|
|
|
void clearKeyBuf(void);
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 getKey(void);
|
|
|
|
int16 checkKey(void);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void getMouseState(int16 *pX, int16 *pY, int16 *pButtons);
|
|
|
|
void setMousePos(int16 x, int16 y);
|
|
|
|
void waitMouseUp(void);
|
|
|
|
void waitMouseDown(void);
|
2007-03-20 14:51:57 +00:00
|
|
|
void waitMouseRelease(char drawMouse);
|
2007-04-16 05:05:35 +00:00
|
|
|
void forceMouseUp(bool onlyWhenSynced = false);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
void clearPalette(void);
|
2007-03-20 14:51:57 +00:00
|
|
|
void setFrameRate(int16 rate);
|
|
|
|
void waitEndFrame();
|
|
|
|
void setScrollOffset(int16 x = -1, int16 y = -1);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
Video::FontDesc *loadFont(const char *path);
|
2007-03-20 14:51:57 +00:00
|
|
|
void freeFont(Video::FontDesc *fontDesc);
|
|
|
|
|
2006-01-29 19:18:15 +00:00
|
|
|
static void insertStr(const char *str1, char *str2, int16 pos);
|
|
|
|
static void cutFromStr(char *str, int16 from, int16 cutlen);
|
|
|
|
static void prepareStr(char *str);
|
2007-04-28 21:16:13 +00:00
|
|
|
static void replaceChar(char *str, char c1, char c2);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
static void listInsertFront(List *list, void *data);
|
|
|
|
static void listInsertBack(List *list, void *data);
|
|
|
|
static void listDropFront(List *list);
|
|
|
|
static void deleteList(List *list);
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
Util(GobEngine *vm);
|
|
|
|
|
|
|
|
protected:
|
2007-03-18 18:10:34 +00:00
|
|
|
int16 _mouseButtons;
|
2007-06-23 17:00:27 +00:00
|
|
|
Common::KeyState _keyBuffer[KEYBUFSIZE];
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 _keyBufferHead;
|
|
|
|
int16 _keyBufferTail;
|
|
|
|
|
2007-04-13 19:55:09 +00:00
|
|
|
uint8 _fastMode;
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
GobEngine *_vm;
|
|
|
|
|
|
|
|
bool keyBufferEmpty();
|
2007-06-23 17:00:27 +00:00
|
|
|
void addKeyToBuffer(const Common::KeyState &key);
|
|
|
|
bool getKeyFromBuffer(Common::KeyState &key);
|
|
|
|
int16 translateKey(const Common::KeyState &key);
|
2006-01-03 23:14:39 +00:00
|
|
|
void checkJoystick();
|
|
|
|
};
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} // End of namespace Gob
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#endif // GOB_UTIL_H
|