2002-07-05 16:56:53 +00:00
|
|
|
|
/* ScummVM - Scumm Interpreter
|
2003-03-06 21:46:56 +00:00
|
|
|
|
* Copyright (C) 2002-2003 The ScummVM project
|
2002-07-05 16:56:53 +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
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* $Header$
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2003-08-01 12:21:04 +00:00
|
|
|
|
#include "common/util.h"
|
2002-07-05 16:56:53 +00:00
|
|
|
|
#include "newgui.h"
|
2002-08-29 23:45:15 +00:00
|
|
|
|
#include "dialog.h"
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
2003-07-22 08:33:13 +00:00
|
|
|
|
#ifdef __PALM_OS__
|
|
|
|
|
# include "palm.h"
|
|
|
|
|
#endif
|
2002-09-22 04:03:45 +00:00
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
|
namespace GUI {
|
|
|
|
|
|
2002-07-07 22:44:30 +00:00
|
|
|
|
/*
|
|
|
|
|
* TODO list
|
2002-09-19 21:45:56 +00:00
|
|
|
|
* - get a nicer font which contains diacrits (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> etc.)
|
2002-09-22 04:03:45 +00:00
|
|
|
|
* - add more widgets: edit field, popup, radio buttons, ...
|
|
|
|
|
*
|
|
|
|
|
* Other ideas:
|
2002-07-08 01:04:29 +00:00
|
|
|
|
* - allow multi line (l/c/r aligned) text via StaticTextWidget ?
|
2002-07-07 22:44:30 +00:00
|
|
|
|
* - add "close" widget to all dialogs (with a flag to turn it off) ?
|
|
|
|
|
* - make dialogs "moveable" ?
|
2002-09-19 21:45:56 +00:00
|
|
|
|
* - come up with a new look & feel / theme for the GUI
|
2002-07-07 22:44:30 +00:00
|
|
|
|
* - ...
|
|
|
|
|
*/
|
|
|
|
|
|
2002-09-30 12:56:59 +00:00
|
|
|
|
enum {
|
2003-03-06 19:52:54 +00:00
|
|
|
|
kDoubleClickDelay = 500, // milliseconds
|
2003-08-28 19:20:30 +00:00
|
|
|
|
kCursorAnimateDelay = 250,
|
2002-09-30 12:56:59 +00:00
|
|
|
|
kKeyRepeatInitialDelay = 400,
|
2002-12-25 00:48:13 +00:00
|
|
|
|
kKeyRepeatSustainDelay = 100
|
2002-09-30 12:56:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#ifdef __PALM_OS__
|
|
|
|
|
static byte *guifont;
|
|
|
|
|
#else
|
2002-09-19 17:44:41 +00:00
|
|
|
|
// Built-in font
|
2002-09-19 22:37:00 +00:00
|
|
|
|
static byte guifont[] = {
|
|
|
|
|
0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7,
|
2003-06-14 21:16:22 +00:00
|
|
|
|
7,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,8,5,8,8,7,7,7,6,7,7,7,7,7,5,6,7,5,8,7,7,7,7,7,7,7,7,7,8,7,7,7,5,3,5,7,8,7,7,7,7,7,7,0,6,7,7,7,5,5,5,7,0,6,8,8,7,7,7,7,7,0,7,7,0,0,
|
2002-09-19 17:44:41 +00:00
|
|
|
|
0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,1,3,6,12,
|
|
|
|
|
24,62,3,0,128,192,96,48,24,124,192,0,0,3,62,24,12,6,3,1,0,192,124,24,48,96,192,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,74,72,0,0,0,0,0,128,128,128,0,0,0,0,0,0,0,0,0,0,0,0,0,60,66,153,161,161,153,66,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,96,96,96,96,0,0,96,0,102,102,102,0,0,0,0,0,102,102,255,102,255,102,102,0,24,62,96,60,6,124,24,0,98,102,12,24,48,102,70,0,60,102,60,56,103,102,63,0,96,48,16,0,0,0,0,0,24,48,96,96,96,48,24,0,96,48,24,24,24,48,96,0,
|
|
|
|
|
0,102,60,255,60,102,0,0,0,24,24,126,24,24,0,0,0,0,0,0,0,48,48,96,0,0,0,126,0,0,0,0,0,0,0,0,0,96,96,0,0,3,6,12,24,48,96,0,60,102,102,102,102,102,60,0,24,24,56,24,24,24,126,0,60,102,6,12,48,96,126,0,60,102,6,28,6,102,60,0,6,
|
|
|
|
|
14,30,102,127,6,6,0,126,96,124,6,6,102,60,0,60,102,96,124,102,102,60,0,126,102,12,24,24,24,24,0,60,102,102,60,102,102,60,0,60,102,102,62,6,102,60,0,0,0,96,0,0,96,0,0,0,0,48,0,0,48,48,96,14,24,48,96,48,24,14,0,0,0,120,0,120,0,0,0,112,24,
|
|
|
|
|
12,6,12,24,112,0,60,102,6,12,24,0,24,0,0,0,0,255,255,0,0,0,24,60,102,126,102,102,102,0,124,102,102,124,102,102,124,0,60,102,96,96,96,102,60,0,120,108,102,102,102,108,120,0,126,96,96,120,96,96,126,0,126,96,96,120,96,96,96,0,60,102,96,110,102,102,60,0,102,102,102,
|
|
|
|
|
126,102,102,102,0,120,48,48,48,48,48,120,0,30,12,12,12,12,108,56,0,102,108,120,112,120,108,102,0,96,96,96,96,96,96,126,0,99,119,127,107,99,99,99,0,102,118,126,126,110,102,102,0,60,102,102,102,102,102,60,0,124,102,102,124,96,96,96,0,60,102,102,102,102,60,14,0,124,102,102,124,
|
|
|
|
|
120,108,102,0,60,102,96,60,6,102,60,0,126,24,24,24,24,24,24,0,102,102,102,102,102,102,60,0,102,102,102,102,102,60,24,0,99,99,99,107,127,119,99,0,102,102,60,24,60,102,102,0,102,102,102,60,24,24,24,0,126,6,12,24,48,96,126,0,120,96,96,96,96,96,120,0,3,6,12,24,48,
|
|
|
|
|
96,192,0,120,24,24,24,24,24,120,0,0,0,0,0,0,219,219,0,0,0,0,0,0,0,0,255,102,102,102,0,0,0,0,0,0,0,60,6,62,102,62,0,0,96,96,124,102,102,124,0,0,0,60,96,96,96,60,0,0,6,6,62,102,102,62,0,0,0,60,102,126,96,60,0,0,14,24,62,24,24,
|
|
|
|
|
24,0,0,0,62,102,102,62,6,124,0,96,96,124,102,102,102,0,0,48,0,112,48,48,120,0,0,12,0,12,12,12,12,120,0,96,96,108,120,108,102,0,0,112,48,48,48,48,120,0,0,0,102,127,127,107,99,0,0,0,124,102,102,102,102,0,0,0,60,102,102,102,60,0,0,0,124,102,102,124,96,
|
|
|
|
|
96,0,0,62,102,102,62,6,6,0,0,124,102,96,96,96,0,0,0,62,96,60,6,124,0,0,24,126,24,24,24,14,0,0,0,102,102,102,102,62,0,0,0,102,102,102,60,24,0,0,0,99,107,127,62,54,0,0,0,102,60,24,60,102,0,0,0,102,102,102,62,12,120,0,0,126,12,24,48,126,0,
|
2003-06-14 21:16:22 +00:00
|
|
|
|
24,48,48,96,48,48,24,0,96,96,96,0,96,96,96,0,96,48,48,24,48,48,96,0,0,0,97,153,134,0,0,0,8,12,14,255,255,14,12,8,60,102,96,96,102,60,24,56,102,0,102,102,102,102,62,0,12,24,60,102,126,96,60,0,24,36,60,6,62,102,62,0,102,0,60,6,62,102,62,0,48,
|
2002-09-19 17:44:41 +00:00
|
|
|
|
24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,60,96,96,96,60,24,56,24,36,60,102,126,96,60,0,102,0,60,102,126,96,60,0,48,24,60,102,126,96,60,0,0,216,0,112,48,48,120,0,48,72,0,112,48,48,120,0,96,48,0,112,48,48,120,0,102,24,60,102,126,102,102,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,24,48,124,96,120,96,124,0,0,0,108,26,126,216,110,0,30,40,40,126,72,136,142,0,24,36,60,102,102,102,60,0,102,0,60,102,102,102,60,0,48,24,60,102,102,102,60,0,24,36,0,102,102,102,62,0,48,24,102,102,102,102,62,0,0,0,0,0,0,0,0,0,102,60,102,
|
|
|
|
|
102,102,102,60,0,102,0,102,102,102,102,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,24,60,6,62,102,62,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
2002-09-19 22:37:00 +00:00
|
|
|
|
0,0,0,0,0,0,28,54,54,124,102,102,124,64,0,0,0
|
|
|
|
|
};
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#endif
|
2002-09-19 17:44:41 +00:00
|
|
|
|
|
|
|
|
|
// Constructor
|
2003-11-02 02:18:16 +00:00
|
|
|
|
NewGui::NewGui() : _screen(0), _needRedraw(false),
|
2003-03-06 19:52:54 +00:00
|
|
|
|
_stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
|
2003-11-02 02:18:16 +00:00
|
|
|
|
|
|
|
|
|
_system = OSystem::instance();
|
|
|
|
|
|
2002-09-19 23:06:54 +00:00
|
|
|
|
// Clear the cursor
|
|
|
|
|
memset(_cursor, 0xFF, sizeof(_cursor));
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-11-22 14:02:54 +00:00
|
|
|
|
// Reset key repeat
|
|
|
|
|
_currentKeyDown.keycode = 0;
|
2002-07-07 22:44:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-06 20:21:54 +00:00
|
|
|
|
void NewGui::updateColors() {
|
|
|
|
|
// Setup some default GUI colors.
|
|
|
|
|
_bgcolor = _system->RGBToColor(0, 0, 0);
|
2003-11-03 01:16:29 +00:00
|
|
|
|
_color = _system->RGBToColor(104, 104, 104);
|
2003-09-06 20:21:54 +00:00
|
|
|
|
_shadowcolor = _system->RGBToColor(64, 64, 64);
|
|
|
|
|
_textcolor = _system->RGBToColor(32, 160, 32);
|
|
|
|
|
_textcolorhi = _system->RGBToColor(0, 255, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::runLoop() {
|
2002-10-16 17:37:30 +00:00
|
|
|
|
Dialog *activeDialog = _dialogStack.top();
|
|
|
|
|
bool didSaveState = false;
|
2002-07-26 19:41:20 +00:00
|
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
|
if (activeDialog == 0)
|
|
|
|
|
return;
|
2002-09-22 04:03:45 +00:00
|
|
|
|
|
2003-09-06 20:21:54 +00:00
|
|
|
|
// Setup some default GUI colors. Normally this will be done whenever an
|
|
|
|
|
// EVENT_SCREEN_CHANGED is received. However, not all backends support
|
|
|
|
|
// that even at this time, so we also do it "manually" whenever a run loop
|
|
|
|
|
// is entered.
|
|
|
|
|
updateColors();
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
|
if (!_stateIsSaved) {
|
|
|
|
|
saveState();
|
|
|
|
|
didSaveState = true;
|
|
|
|
|
}
|
2002-07-13 22:41:29 +00:00
|
|
|
|
|
2002-12-25 00:46:34 +00:00
|
|
|
|
while (!_dialogStack.empty() && activeDialog == _dialogStack.top()) {
|
2003-07-22 08:33:13 +00:00
|
|
|
|
#ifdef __PALM_OS__
|
|
|
|
|
// There is no exit(.) function under PalmOS, to exit an app
|
|
|
|
|
// we need to send an 'exit' event to the event handler
|
|
|
|
|
// and then the system return to the launcher. But this event
|
|
|
|
|
// is not handled by the following loop and so we need to force exit.
|
|
|
|
|
// In other systems like Windows ScummVM exit immediatly and so this doesn't appear.
|
|
|
|
|
if (((OSystem_PALMOS *)_system)->_quit)
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
2002-09-22 04:03:45 +00:00
|
|
|
|
activeDialog->handleTickle();
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-09-28 16:19:28 +00:00
|
|
|
|
if (_needRedraw) {
|
2002-09-22 04:03:45 +00:00
|
|
|
|
// Restore the overlay to its initial state, then draw all dialogs.
|
|
|
|
|
// This is necessary to get the blending right.
|
|
|
|
|
_system->clear_overlay();
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_system->grab_overlay(_screen, _screenPitch);
|
2002-10-16 17:37:30 +00:00
|
|
|
|
for (int i = 0; i < _dialogStack.size(); i++)
|
2002-11-10 19:39:32 +00:00
|
|
|
|
_dialogStack[i]->drawDialog();
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_needRedraw = false;
|
2002-09-22 04:03:45 +00:00
|
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
|
animateCursor();
|
|
|
|
|
_system->update_screen();
|
|
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
|
OSystem::Event event;
|
2003-11-02 02:18:16 +00:00
|
|
|
|
uint32 time = _system->get_msecs();
|
2002-09-30 12:56:59 +00:00
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
|
while (_system->poll_event(&event)) {
|
2003-09-24 06:33:59 +00:00
|
|
|
|
switch (event.event_code) {
|
|
|
|
|
case OSystem::EVENT_KEYDOWN:
|
2003-07-22 16:29:23 +00:00
|
|
|
|
#if !defined(_WIN32_WCE) && !defined(__PALM_OS__)
|
2003-09-24 06:33:59 +00:00
|
|
|
|
// init continuous event stream
|
|
|
|
|
// not done on WinCE because keyboard is emulated and
|
|
|
|
|
// keyup is not generated
|
|
|
|
|
_currentKeyDown.ascii = event.kbd.ascii;
|
|
|
|
|
_currentKeyDown.keycode = event.kbd.keycode;
|
|
|
|
|
_currentKeyDown.flags = event.kbd.flags;
|
|
|
|
|
_keyRepeatTime = time + kKeyRepeatInitialDelay;
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#endif
|
2003-09-24 06:33:59 +00:00
|
|
|
|
activeDialog->handleKeyDown(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_KEYUP:
|
|
|
|
|
activeDialog->handleKeyUp(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
|
|
|
|
|
if (event.kbd.keycode == _currentKeyDown.keycode)
|
|
|
|
|
// only stop firing events if it's the current key
|
|
|
|
|
_currentKeyDown.keycode = 0;
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
|
activeDialog->handleMouseMoved(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 0);
|
|
|
|
|
break;
|
|
|
|
|
// We don't distinguish between mousebuttons (for now at least)
|
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN: {
|
|
|
|
|
if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
|
|
|
|
|
&& ABS(_lastClick.x - event.mouse.x) < 3
|
|
|
|
|
&& ABS(_lastClick.y - event.mouse.y) < 3) {
|
|
|
|
|
_lastClick.count++;
|
|
|
|
|
} else {
|
|
|
|
|
_lastClick.x = event.mouse.x;
|
|
|
|
|
_lastClick.y = event.mouse.y;
|
|
|
|
|
_lastClick.count = 1;
|
|
|
|
|
}
|
|
|
|
|
_lastClick.time = time;
|
|
|
|
|
}
|
|
|
|
|
activeDialog->handleMouseDown(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count);
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_LBUTTONUP:
|
|
|
|
|
case OSystem::EVENT_RBUTTONUP:
|
|
|
|
|
activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count);
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_WHEELUP:
|
|
|
|
|
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1);
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_WHEELDOWN:
|
|
|
|
|
activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1);
|
|
|
|
|
break;
|
|
|
|
|
case OSystem::EVENT_QUIT:
|
|
|
|
|
_system->quit();
|
|
|
|
|
return;
|
|
|
|
|
case OSystem::EVENT_SCREEN_CHANGED:
|
|
|
|
|
updateColors();
|
|
|
|
|
break;
|
2002-07-13 18:32:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-22 04:03:45 +00:00
|
|
|
|
// check if event should be sent again (keydown)
|
2003-03-06 19:52:54 +00:00
|
|
|
|
if (_currentKeyDown.keycode != 0) {
|
|
|
|
|
if (_keyRepeatTime < time) {
|
2002-09-22 04:03:45 +00:00
|
|
|
|
// fire event
|
2002-11-22 14:02:54 +00:00
|
|
|
|
activeDialog->handleKeyDown(_currentKeyDown.ascii, _currentKeyDown.keycode, _currentKeyDown.flags);
|
2002-09-30 12:56:59 +00:00
|
|
|
|
_keyRepeatTime = time + kKeyRepeatSustainDelay;
|
2002-09-22 04:03:45 +00:00
|
|
|
|
}
|
2002-07-18 14:47:25 +00:00
|
|
|
|
}
|
2002-09-22 04:03:45 +00:00
|
|
|
|
|
|
|
|
|
// Delay for a moment
|
|
|
|
|
_system->delay_msecs(10);
|
2002-07-18 14:47:25 +00:00
|
|
|
|
}
|
2002-09-27 13:06:58 +00:00
|
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
|
if (didSaveState)
|
|
|
|
|
restoreState();
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::saveState() {
|
2002-12-28 04:51:34 +00:00
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
|
// Backup old cursor
|
2002-09-19 23:06:54 +00:00
|
|
|
|
_oldCursorMode = _system->show_mouse(true);
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2003-09-20 00:47:56 +00:00
|
|
|
|
// Enable the overlay
|
2002-09-19 16:06:51 +00:00
|
|
|
|
_system->show_overlay();
|
2003-09-20 00:47:56 +00:00
|
|
|
|
|
|
|
|
|
// Create a screen buffer for the overlay data, and fill it with
|
|
|
|
|
// whatever is visible on the screen rught now.
|
|
|
|
|
int sys_height = _system->get_overlay_height();
|
|
|
|
|
int sys_width = _system->get_overlay_width();
|
|
|
|
|
_screen = (NewGuiColor*)calloc(sys_width * sys_height, sizeof(NewGuiColor));
|
2002-12-28 04:51:34 +00:00
|
|
|
|
_screenPitch = sys_width;
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_system->grab_overlay(_screen, _screenPitch);
|
2002-10-16 17:37:30 +00:00
|
|
|
|
|
2002-11-22 14:02:54 +00:00
|
|
|
|
_currentKeyDown.keycode = 0;
|
2002-10-16 17:37:30 +00:00
|
|
|
|
_lastClick.x = _lastClick.y = 0;
|
|
|
|
|
_lastClick.time = 0;
|
|
|
|
|
_lastClick.count = 0;
|
|
|
|
|
|
|
|
|
|
_stateIsSaved = true;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::restoreState() {
|
2002-09-19 23:06:54 +00:00
|
|
|
|
_system->show_mouse(_oldCursorMode);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
2002-09-19 16:06:51 +00:00
|
|
|
|
_system->hide_overlay();
|
|
|
|
|
if (_screen) {
|
2003-04-30 13:57:57 +00:00
|
|
|
|
free(_screen);
|
2002-09-19 16:06:51 +00:00
|
|
|
|
_screen = 0;
|
|
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-10-16 17:37:30 +00:00
|
|
|
|
_system->update_screen();
|
|
|
|
|
|
|
|
|
|
_stateIsSaved = false;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::openDialog(Dialog *dialog) {
|
2002-07-07 21:46:53 +00:00
|
|
|
|
_dialogStack.push(dialog);
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_needRedraw = true;
|
2002-07-07 21:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::closeTopDialog() {
|
2002-07-10 16:49:45 +00:00
|
|
|
|
// Don't do anything if no dialog is open
|
|
|
|
|
if (_dialogStack.empty())
|
|
|
|
|
return;
|
2003-03-06 19:52:54 +00:00
|
|
|
|
|
2002-07-10 16:49:45 +00:00
|
|
|
|
// Remove the dialog from the stack
|
2002-07-07 21:46:53 +00:00
|
|
|
|
_dialogStack.pop();
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_needRedraw = true;
|
2002-07-07 21:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
|
#pragma mark -
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *NewGui::getBasePtr(int x, int y) {
|
2002-09-28 16:19:28 +00:00
|
|
|
|
return _screen + x + y * _screenPitch;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-02 18:57:20 +00:00
|
|
|
|
void NewGui::box(int x, int y, int width, int height, NewGuiColor colorA, NewGuiColor colorB) {
|
2003-10-01 15:00:26 +00:00
|
|
|
|
hLine(x + 1, y, x + width - 2, colorA);
|
|
|
|
|
hLine(x, y + 1, x + width - 1, colorA);
|
|
|
|
|
vLine(x, y + 1, y + height - 2, colorA);
|
|
|
|
|
vLine(x + 1, y, y + height - 1, colorA);
|
|
|
|
|
|
|
|
|
|
hLine(x + 1, y + height - 2, x + width - 1, colorB);
|
|
|
|
|
hLine(x + 1, y + height - 1, x + width - 2, colorB);
|
|
|
|
|
vLine(x + width - 1, y + 1, y + height - 2, colorB);
|
|
|
|
|
vLine(x + width - 2, y + 1, y + height - 1, colorB);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::line(int x, int y, int x2, int y2, NewGuiColor color) {
|
|
|
|
|
NewGuiColor *ptr;
|
2002-07-07 13:14:34 +00:00
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
|
if (x2 < x)
|
2002-11-05 22:34:50 +00:00
|
|
|
|
SWAP(x2, x);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
|
|
|
|
if (y2 < y)
|
2002-11-05 22:34:50 +00:00
|
|
|
|
SWAP(y2, y);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
|
|
|
|
ptr = getBasePtr(x, y);
|
|
|
|
|
|
|
|
|
|
if (x == x2) {
|
|
|
|
|
/* vertical line */
|
|
|
|
|
while (y++ <= y2) {
|
|
|
|
|
*ptr = color;
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (y == y2) {
|
|
|
|
|
/* horizontal line */
|
|
|
|
|
while (x++ <= x2) {
|
|
|
|
|
*ptr++ = color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::blendRect(int x, int y, int w, int h, NewGuiColor color, int level) {
|
|
|
|
|
#ifdef NEWGUI_256
|
2003-11-03 01:14:40 +00:00
|
|
|
|
fillRect(x, y, w, h, color);
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#else
|
2002-12-14 16:07:26 +00:00
|
|
|
|
int r, g, b;
|
2002-12-13 16:15:58 +00:00
|
|
|
|
uint8 ar, ag, ab;
|
2003-03-08 06:53:32 +00:00
|
|
|
|
_system->colorToRGB(color, ar, ag, ab);
|
2002-12-14 16:07:26 +00:00
|
|
|
|
r = ar * level;
|
|
|
|
|
g = ag * level;
|
|
|
|
|
b = ab * level;
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-07-10 16:49:45 +00:00
|
|
|
|
|
|
|
|
|
while (h--) {
|
|
|
|
|
for (int i = 0; i < w; i++) {
|
2003-03-08 06:53:32 +00:00
|
|
|
|
_system->colorToRGB(ptr[i], ar, ag, ab);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
ptr[i] = _system->RGBToColor((ar + r) / (level+1),
|
|
|
|
|
(ag + g) / (level+1),
|
|
|
|
|
(ab + b) / (level+1));
|
2002-07-10 16:49:45 +00:00
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-10 16:49:45 +00:00
|
|
|
|
}
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#endif
|
2002-07-10 16:49:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::fillRect(int x, int y, int w, int h, NewGuiColor color) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
int i;
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
|
|
|
|
while (h--) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
for (i = 0; i < w; i++) {
|
2002-07-10 16:49:45 +00:00
|
|
|
|
ptr[i] = color;
|
2002-07-09 12:33:09 +00:00
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::checkerRect(int x, int y, int w, int h, NewGuiColor color) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
int i;
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-07-12 16:24:11 +00:00
|
|
|
|
|
|
|
|
|
while (h--) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
for (i = 0; i < w; i++) {
|
2002-07-12 16:24:11 +00:00
|
|
|
|
if ((h ^ i) & 1)
|
|
|
|
|
ptr[i] = color;
|
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-12 16:24:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::frameRect(int x, int y, int w, int h, NewGuiColor color) {
|
2002-07-10 22:49:41 +00:00
|
|
|
|
int i;
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr, *basePtr = getBasePtr(x, y);
|
2002-07-10 22:49:41 +00:00
|
|
|
|
if (basePtr == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ptr = basePtr;
|
|
|
|
|
for (i = 0; i < w; i++, ptr++)
|
|
|
|
|
*ptr = color;
|
|
|
|
|
ptr--;
|
2002-09-28 16:19:28 +00:00
|
|
|
|
for (i = 0; i < h; i++, ptr += _screenPitch)
|
2002-07-10 22:49:41 +00:00
|
|
|
|
*ptr = color;
|
|
|
|
|
ptr = basePtr;
|
2002-09-28 16:19:28 +00:00
|
|
|
|
for (i = 0; i < h; i++, ptr += _screenPitch)
|
2002-07-10 22:49:41 +00:00
|
|
|
|
*ptr = color;
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr -= _screenPitch;
|
2002-07-10 22:49:41 +00:00
|
|
|
|
for (i = 0; i < w; i++, ptr++)
|
|
|
|
|
*ptr = color;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::addDirtyRect(int x, int y, int w, int h) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
// For now we don't keep yet another list of dirty rects but simply
|
|
|
|
|
// blit the affected area directly to the overlay. At least for our current
|
|
|
|
|
// GUI/widget/dialog code that is just fine.
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *buf = getBasePtr(x, y);
|
2002-09-28 16:19:28 +00:00
|
|
|
|
_system->copy_rect_overlay(buf, _screenPitch, x, y, w, h);
|
2002-07-08 00:10:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::drawChar(const byte chr, int xx, int yy, NewGuiColor color) {
|
2002-07-05 16:56:53 +00:00
|
|
|
|
unsigned int buffer = 0, mask = 0, x, y;
|
|
|
|
|
byte *tmp;
|
|
|
|
|
|
2002-09-19 22:37:00 +00:00
|
|
|
|
tmp = guifont + 224 + (chr + 1) * 8;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(xx, yy);
|
2002-07-07 13:14:34 +00:00
|
|
|
|
|
2002-07-05 16:56:53 +00:00
|
|
|
|
for (y = 0; y < 8; y++) {
|
|
|
|
|
for (x = 0; x < 8; x++) {
|
2002-09-19 16:06:51 +00:00
|
|
|
|
unsigned char c;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
if ((mask >>= 1) == 0) {
|
|
|
|
|
buffer = *tmp++;
|
|
|
|
|
mask = 0x80;
|
|
|
|
|
}
|
2002-09-19 16:06:51 +00:00
|
|
|
|
c = ((buffer & mask) != 0);
|
|
|
|
|
if (c)
|
|
|
|
|
ptr[x] = color;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-07 23:37:47 +00:00
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
int NewGui::getStringWidth(const String &str) {
|
2002-09-19 17:03:24 +00:00
|
|
|
|
int space = 0;
|
2002-09-26 11:44:02 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < str.size(); ++i)
|
|
|
|
|
space += getCharWidth(str[i]);
|
2002-09-19 17:03:24 +00:00
|
|
|
|
return space;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
|
int NewGui::getCharWidth(byte c) {
|
2002-09-19 22:37:00 +00:00
|
|
|
|
return guifont[c+6];
|
2002-09-19 17:03:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 22:00:36 +00:00
|
|
|
|
void NewGui::drawString(const String &s, int x, int y, int w, NewGuiColor color, int align, int deltax, bool useEllipsis) {
|
2002-11-05 13:33:34 +00:00
|
|
|
|
const int leftX = x, rightX = x + w;
|
2003-11-04 22:00:36 +00:00
|
|
|
|
int i;
|
|
|
|
|
int width = getStringWidth(s);
|
|
|
|
|
String str;
|
|
|
|
|
|
|
|
|
|
if (useEllipsis && width > w) {
|
|
|
|
|
// String is too wide. So we shorten it "intellegently", by replacing
|
|
|
|
|
// parts of it by an ellipsis ("..."). There are three possibilities
|
|
|
|
|
// for this: replace the start, the end, or the middle of the string.
|
|
|
|
|
// What is best really depends on the context; but unless we want to
|
|
|
|
|
// make this configurable, replacing the middle probably is a good
|
|
|
|
|
// compromise.
|
|
|
|
|
const int ellipsisWidth = getStringWidth("...");
|
|
|
|
|
|
|
|
|
|
// SLOW algorithm to remove enough of the middle. But it is good enough
|
|
|
|
|
// for now.
|
|
|
|
|
const int halfWidth = (w - ellipsisWidth) / 2;
|
|
|
|
|
int w2 = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < s.size(); ++i) {
|
|
|
|
|
int charWidth = getCharWidth(s[i]);
|
|
|
|
|
if (w2 + charWidth > halfWidth)
|
|
|
|
|
break;
|
|
|
|
|
w2 += charWidth;
|
|
|
|
|
str += s[i];
|
|
|
|
|
}
|
|
|
|
|
// At this point we know that the first 'i' chars are together 'w2'
|
|
|
|
|
// pixels wide. We took the first i-1, and add "..." to them.
|
|
|
|
|
str += "...";
|
|
|
|
|
|
|
|
|
|
// The original string is width wide. Of those we already skipped past
|
|
|
|
|
// w2 pixels, which means (width - w2) remain.
|
|
|
|
|
// The new str is (w2+ellipsisWidth) wide, so we can accomodate about
|
|
|
|
|
// (w - (w2+ellipsisWidth)) more pixels.
|
|
|
|
|
// Thus we skip ((width - w2) - (w - (w2+ellipsisWidth))) =
|
|
|
|
|
// (width + ellipsisWidth - w)
|
|
|
|
|
int skip = width + ellipsisWidth - w;
|
|
|
|
|
for (; i < s.size() && skip > 0; ++i) {
|
|
|
|
|
skip -= getCharWidth(s[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Append the remaining chars, if any
|
|
|
|
|
for (; i < s.size(); ++i) {
|
|
|
|
|
str += s[i];
|
|
|
|
|
}
|
2003-11-08 23:22:16 +00:00
|
|
|
|
|
2003-11-04 22:00:36 +00:00
|
|
|
|
width = getStringWidth(str);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
|
2003-11-04 22:00:36 +00:00
|
|
|
|
} else {
|
|
|
|
|
str = s;
|
|
|
|
|
}
|
2003-11-08 23:22:16 +00:00
|
|
|
|
|
2002-09-19 17:03:24 +00:00
|
|
|
|
if (align == kTextAlignCenter)
|
|
|
|
|
x = x + (w - width - 1)/2;
|
|
|
|
|
else if (align == kTextAlignRight)
|
|
|
|
|
x = x + w - width;
|
2003-05-05 16:10:19 +00:00
|
|
|
|
x += deltax;
|
2002-09-26 11:44:02 +00:00
|
|
|
|
|
2003-11-04 22:00:36 +00:00
|
|
|
|
for (i = 0; i < str.size(); ++i) {
|
2002-11-05 13:33:34 +00:00
|
|
|
|
w = getCharWidth(str[i]);
|
|
|
|
|
if (x+w > rightX)
|
|
|
|
|
break;
|
|
|
|
|
if (x >= leftX)
|
|
|
|
|
drawChar(str[i], x, y, color);
|
|
|
|
|
x += w;
|
2002-07-05 16:56:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-07 23:37:47 +00:00
|
|
|
|
|
2002-12-12 12:07:46 +00:00
|
|
|
|
//
|
|
|
|
|
// Blit from a buffer to the display
|
|
|
|
|
//
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::blitFromBuffer(int x, int y, int w, int h, const byte *buf, int pitch) {
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-12-12 12:07:46 +00:00
|
|
|
|
|
|
|
|
|
assert(buf);
|
|
|
|
|
while (h--) {
|
|
|
|
|
memcpy(ptr, buf, w*2);
|
|
|
|
|
ptr += _screenPitch;
|
|
|
|
|
buf += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Blit from the display to a buffer
|
|
|
|
|
//
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::blitToBuffer(int x, int y, int w, int h, byte *buf, int pitch) {
|
2003-04-30 13:57:57 +00:00
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-12-12 12:07:46 +00:00
|
|
|
|
|
|
|
|
|
assert(buf);
|
|
|
|
|
while (h--) {
|
2003-11-08 23:22:16 +00:00
|
|
|
|
memcpy(buf, ptr, w * 2);
|
2002-12-12 12:07:46 +00:00
|
|
|
|
ptr += _screenPitch;
|
|
|
|
|
buf += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-19 23:06:54 +00:00
|
|
|
|
//
|
|
|
|
|
// Draw an 8x8 bitmap at location (x,y)
|
|
|
|
|
//
|
2003-04-30 13:57:57 +00:00
|
|
|
|
void NewGui::drawBitmap(uint32 *bitmap, int x, int y, NewGuiColor color, int h) {
|
|
|
|
|
NewGuiColor *ptr = getBasePtr(x, y);
|
2002-07-07 23:37:47 +00:00
|
|
|
|
|
2002-12-12 23:22:48 +00:00
|
|
|
|
for (y = 0; y < h; y++) {
|
2002-07-07 23:37:47 +00:00
|
|
|
|
uint32 mask = 0xF0000000;
|
2002-12-12 23:22:48 +00:00
|
|
|
|
for (x = 0; x < 8; x++) {
|
|
|
|
|
if (bitmap[y] & mask)
|
|
|
|
|
ptr[x] = color;
|
2002-07-07 23:37:47 +00:00
|
|
|
|
mask >>= 4;
|
|
|
|
|
}
|
2002-09-28 16:19:28 +00:00
|
|
|
|
ptr += _screenPitch;
|
2002-07-10 16:49:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-19 23:06:54 +00:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Draw the mouse cursor (animated). This is mostly ripped from the cursor code in gfx.cpp
|
|
|
|
|
// We could plug in a different cursor here if we like to.
|
|
|
|
|
//
|
2003-03-06 19:52:54 +00:00
|
|
|
|
void NewGui::animateCursor() {
|
2003-11-02 02:18:16 +00:00
|
|
|
|
int time = _system->get_msecs();
|
2002-09-22 04:03:45 +00:00
|
|
|
|
if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
|
2002-09-19 23:06:54 +00:00
|
|
|
|
const byte colors[4] = { 15, 15, 7, 8 };
|
2002-09-22 04:03:45 +00:00
|
|
|
|
const byte color = colors[_cursorAnimateCounter];
|
2002-09-19 23:06:54 +00:00
|
|
|
|
int i;
|
|
|
|
|
|
2002-09-28 15:58:25 +00:00
|
|
|
|
for (i = 0; i < 15; i++) {
|
|
|
|
|
if ((i < 6) || (i > 8)) {
|
|
|
|
|
_cursor[16 * 7 + i] = color;
|
|
|
|
|
_cursor[16 * i + 7] = color;
|
2002-09-19 23:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-28 15:58:25 +00:00
|
|
|
|
_system->set_mouse_cursor(_cursor, 16, 16, 7, 7);
|
2002-09-22 04:03:45 +00:00
|
|
|
|
|
|
|
|
|
_cursorAnimateTimer = time;
|
|
|
|
|
_cursorAnimateCounter = (_cursorAnimateCounter + 1) % 4;
|
2002-09-19 23:06:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-30 13:57:57 +00:00
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
|
} // End of namespace GUI
|
|
|
|
|
|
2003-04-30 13:57:57 +00:00
|
|
|
|
#ifdef __PALM_OS__
|
2003-08-18 10:59:21 +00:00
|
|
|
|
#include "scumm_globals.h"
|
|
|
|
|
|
|
|
|
|
_GINIT(NewGui)
|
|
|
|
|
_GSETPTR(guifont, GBVARS_GUIFONT_INDEX, byte, GBVARS_SCUMM)
|
|
|
|
|
_GEND
|
|
|
|
|
|
|
|
|
|
_GRELEASE(NewGui)
|
|
|
|
|
_GRELEASEPTR(GBVARS_GUIFONT_INDEX, GBVARS_SCUMM)
|
|
|
|
|
_GEND
|
|
|
|
|
|
2003-04-30 21:37:02 +00:00
|
|
|
|
#endif
|