2004-05-09 14:57:04 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2004-05-09 14:57:04 +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.
|
2004-05-09 14:57:04 +00:00
|
|
|
*
|
2006-02-11 12:47:47 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-05-09 14:57:04 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2004-05-09 14:57:04 +00:00
|
|
|
#include "CEActionsPocket.h"
|
|
|
|
#include "EventsBuffer.h"
|
|
|
|
|
|
|
|
#include "gui/message.h"
|
|
|
|
|
|
|
|
#include "scumm/scumm.h"
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
2006-01-29 23:23:17 +00:00
|
|
|
#include "gui/KeysDialog.h"
|
|
|
|
|
2005-07-05 20:51:54 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
#define KEY_ALL_SKIP 3457
|
|
|
|
#endif
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
const String pocketActionNames[] = {
|
|
|
|
"Pause",
|
|
|
|
"Save",
|
2004-05-09 14:57:04 +00:00
|
|
|
"Quit",
|
|
|
|
"Skip",
|
|
|
|
"Hide",
|
|
|
|
"Keyboard",
|
|
|
|
"Sound",
|
|
|
|
"Right click",
|
|
|
|
"Cursor",
|
|
|
|
"Free look",
|
|
|
|
"Zoom up",
|
2005-03-26 13:29:04 +00:00
|
|
|
"Zoom down",
|
2006-01-29 23:23:17 +00:00
|
|
|
"FT Cheat",
|
2006-06-10 11:06:05 +00:00
|
|
|
"Bind Keys",
|
|
|
|
"Up",
|
|
|
|
"Down",
|
|
|
|
"Left",
|
|
|
|
"Right",
|
|
|
|
"Left Click",
|
2004-05-09 14:57:04 +00:00
|
|
|
};
|
|
|
|
|
2006-06-06 19:31:49 +00:00
|
|
|
void CEActionsPocket::init() {
|
|
|
|
_instance = new CEActionsPocket(ConfMan.get("gameid"));
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-05 20:22:56 +00:00
|
|
|
String CEActionsPocket::actionName(GUI::ActionType action) {
|
2004-05-09 14:57:04 +00:00
|
|
|
return pocketActionNames[action];
|
|
|
|
}
|
|
|
|
|
|
|
|
int CEActionsPocket::size() {
|
|
|
|
return POCKET_ACTION_LAST;
|
|
|
|
}
|
|
|
|
|
|
|
|
String CEActionsPocket::domain() {
|
2006-06-10 11:06:05 +00:00
|
|
|
return ConfMan.kApplicationDomain;
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CEActionsPocket::version() {
|
|
|
|
return POCKET_ACTION_VERSION;
|
|
|
|
}
|
|
|
|
|
2006-04-12 19:04:10 +00:00
|
|
|
CEActionsPocket::CEActionsPocket(const Common::String &gameid) :
|
2006-06-06 19:31:49 +00:00
|
|
|
GUI::Actions()
|
2004-05-09 14:57:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
_right_click_needed = false;
|
|
|
|
_hide_toolbar_needed = false;
|
|
|
|
_zoom_needed = false;
|
|
|
|
|
|
|
|
for (i=0; i<POCKET_ACTION_LAST; i++) {
|
|
|
|
_action_mapping[i] = 0;
|
|
|
|
_action_enabled[i] = false;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:06:05 +00:00
|
|
|
// apply some default settings for emulated mouse
|
|
|
|
_action_enabled[POCKET_ACTION_LEFTCLICK] = true;
|
|
|
|
_action_enabled[POCKET_ACTION_UP] = true;
|
|
|
|
_action_enabled[POCKET_ACTION_DOWN] = true;
|
|
|
|
_action_enabled[POCKET_ACTION_LEFT] = true;
|
|
|
|
_action_enabled[POCKET_ACTION_RIGHT] = true;
|
|
|
|
_action_mapping[POCKET_ACTION_LEFTCLICK] = VK_RETURN;
|
|
|
|
_action_mapping[POCKET_ACTION_UP] = 0x111;
|
|
|
|
_action_mapping[POCKET_ACTION_DOWN] = 0x112;
|
|
|
|
_action_mapping[POCKET_ACTION_LEFT] = 0x114;
|
|
|
|
_action_mapping[POCKET_ACTION_RIGHT] = 0x113;
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
2005-07-05 20:22:56 +00:00
|
|
|
void CEActionsPocket::initInstanceMain(OSystem *mainSystem) {
|
2004-12-20 23:52:16 +00:00
|
|
|
// Nothing generic to do for Pocket PC
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem = static_cast<OSystem_WINCE3*>(mainSystem);
|
|
|
|
GUI_Actions::initInstanceMain(mainSystem);
|
2004-12-20 23:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CEActionsPocket::initInstanceGame() {
|
2006-04-15 17:39:14 +00:00
|
|
|
String gameid(ConfMan.get("gameid"));
|
|
|
|
bool is_simon = (strncmp(gameid.c_str(), "simon", 5) == 0);
|
|
|
|
bool is_sword1 = (gameid == "sword1");
|
|
|
|
bool is_sword2 = (strcmp(gameid.c_str(), "sword2") == 0);
|
|
|
|
bool is_queen = (gameid == "queen");
|
|
|
|
bool is_sky = (gameid == "sky");
|
|
|
|
bool is_comi = (strncmp(gameid.c_str(), "comi", 4) == 0);
|
|
|
|
bool is_gob = (strncmp(gameid.c_str(), "gob", 3) == 0);
|
|
|
|
bool is_ite = ((strncmp(gameid.c_str(), "ite", 3) == 0) ||
|
|
|
|
(strncmp(gameid.c_str(), "ihnm", 4) == 0));
|
2006-06-20 17:52:25 +00:00
|
|
|
bool is_kyra = (gameid == "kyra1");
|
2004-05-09 14:57:04 +00:00
|
|
|
|
2005-07-05 20:22:56 +00:00
|
|
|
GUI_Actions::initInstanceGame();
|
2004-05-09 14:57:04 +00:00
|
|
|
|
|
|
|
// See if a right click mapping could be needed
|
2005-04-10 21:11:02 +00:00
|
|
|
if (is_sword1 || is_sword2 || is_sky || is_queen || is_comi || is_gob ||
|
2006-04-15 17:39:14 +00:00
|
|
|
gameid == "samnmax")
|
2004-05-09 14:57:04 +00:00
|
|
|
_right_click_needed = true;
|
|
|
|
|
|
|
|
// See if a "hide toolbar" mapping could be needed
|
|
|
|
if (is_sword1 || is_sword2 || is_comi)
|
|
|
|
_hide_toolbar_needed = true;
|
|
|
|
|
|
|
|
// Initialize keys for different actions
|
|
|
|
// Pause
|
|
|
|
_key_action[POCKET_ACTION_PAUSE].setAscii(VK_SPACE);
|
|
|
|
_action_enabled[POCKET_ACTION_PAUSE] = true;
|
|
|
|
// Save
|
2006-06-20 17:52:25 +00:00
|
|
|
if (is_simon || is_sword2 || is_gob || is_kyra)
|
2004-05-09 14:57:04 +00:00
|
|
|
_action_enabled[POCKET_ACTION_SAVE] = false;
|
|
|
|
else
|
2005-10-16 22:35:38 +00:00
|
|
|
if (is_queen || is_ite) {
|
2004-05-09 14:57:04 +00:00
|
|
|
_action_enabled[POCKET_ACTION_SAVE] = true;
|
2005-10-16 22:35:38 +00:00
|
|
|
_key_action[POCKET_ACTION_SAVE].setAscii(286); // F5 key for FOTAQ & ITE
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (is_sky) {
|
|
|
|
_action_enabled[POCKET_ACTION_SAVE] = true;
|
2005-07-30 21:11:48 +00:00
|
|
|
_key_action[POCKET_ACTION_SAVE].setAscii(63);
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
_action_enabled[POCKET_ACTION_SAVE] = true;
|
|
|
|
_key_action[POCKET_ACTION_SAVE].setAscii(319); // F5 key
|
|
|
|
}
|
|
|
|
// Quit
|
|
|
|
_action_enabled[POCKET_ACTION_QUIT] = true;
|
|
|
|
// Skip
|
|
|
|
_action_enabled[POCKET_ACTION_SKIP] = true;
|
2006-06-20 17:52:25 +00:00
|
|
|
if (is_simon || is_sky || is_sword2 || is_queen || is_sword1 || is_gob || is_ite || is_kyra)
|
2004-05-09 14:57:04 +00:00
|
|
|
_key_action[POCKET_ACTION_SKIP].setAscii(VK_ESCAPE);
|
|
|
|
else
|
2005-07-05 20:51:54 +00:00
|
|
|
_key_action[POCKET_ACTION_SKIP].setAscii(KEY_ALL_SKIP);
|
2004-05-09 14:57:04 +00:00
|
|
|
// Hide
|
|
|
|
_action_enabled[POCKET_ACTION_HIDE] = true;
|
2005-07-30 21:11:48 +00:00
|
|
|
// Keyboard
|
2004-05-09 14:57:04 +00:00
|
|
|
_action_enabled[POCKET_ACTION_KEYBOARD] = true;
|
|
|
|
// Sound
|
|
|
|
_action_enabled[POCKET_ACTION_SOUND] = true;
|
|
|
|
// RightClick
|
|
|
|
_action_enabled[POCKET_ACTION_RIGHTCLICK] = true;
|
|
|
|
// Cursor
|
|
|
|
_action_enabled[POCKET_ACTION_CURSOR] = true;
|
|
|
|
// Freelook
|
|
|
|
_action_enabled[POCKET_ACTION_FREELOOK] = true;
|
|
|
|
// Zoom
|
|
|
|
if (is_sword1 || is_sword2 || is_comi) {
|
|
|
|
_zoom_needed = true;
|
|
|
|
_action_enabled[POCKET_ACTION_ZOOM_UP] = true;
|
|
|
|
_action_enabled[POCKET_ACTION_ZOOM_DOWN] = true;
|
|
|
|
}
|
2005-03-26 13:29:04 +00:00
|
|
|
// FT Cheat
|
|
|
|
_action_enabled[POCKET_ACTION_FT_CHEAT] = true;
|
|
|
|
_key_action[POCKET_ACTION_FT_CHEAT].setAscii(86); // shift-V
|
2006-01-29 23:23:17 +00:00
|
|
|
// Key bind method
|
|
|
|
_action_enabled[POCKET_ACTION_BINDKEYS] = true;
|
2004-05-09 14:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CEActionsPocket::~CEActionsPocket() {
|
|
|
|
}
|
|
|
|
|
2005-07-05 20:22:56 +00:00
|
|
|
bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
|
2006-01-29 23:23:17 +00:00
|
|
|
static bool keydialogrunning = false;
|
|
|
|
|
2004-12-21 00:31:58 +00:00
|
|
|
if (!pushed) {
|
|
|
|
switch(action) {
|
2006-06-10 11:06:05 +00:00
|
|
|
case POCKET_ACTION_RIGHTCLICK:
|
|
|
|
_CESystem->add_right_click(false);
|
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_LEFTCLICK:
|
|
|
|
_CESystem->add_left_click(false);
|
|
|
|
return true;
|
2005-01-28 23:45:53 +00:00
|
|
|
case POCKET_ACTION_PAUSE:
|
|
|
|
case POCKET_ACTION_SAVE:
|
|
|
|
case POCKET_ACTION_SKIP:
|
2005-03-26 13:29:04 +00:00
|
|
|
case POCKET_ACTION_FT_CHEAT:
|
2005-01-28 23:45:53 +00:00
|
|
|
EventsBuffer::simulateKey(&_key_action[action], false);
|
|
|
|
return true;
|
|
|
|
|
2004-12-21 00:31:58 +00:00
|
|
|
}
|
2004-05-09 14:57:04 +00:00
|
|
|
return false;
|
2004-12-21 00:31:58 +00:00
|
|
|
}
|
2004-05-09 14:57:04 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case POCKET_ACTION_PAUSE:
|
|
|
|
case POCKET_ACTION_SAVE:
|
|
|
|
case POCKET_ACTION_SKIP:
|
2005-03-26 13:29:04 +00:00
|
|
|
case POCKET_ACTION_FT_CHEAT:
|
2005-01-28 23:45:53 +00:00
|
|
|
EventsBuffer::simulateKey(&_key_action[action], true);
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_KEYBOARD:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_panel();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_HIDE:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_panel_visibility();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_SOUND:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_sound_master();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_RIGHTCLICK:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->add_right_click(true);
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_CURSOR:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_mouse_visibility();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
2005-01-28 23:45:53 +00:00
|
|
|
case POCKET_ACTION_FREELOOK:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_freeLook();
|
2005-01-28 23:45:53 +00:00
|
|
|
return true;
|
2004-05-09 14:57:04 +00:00
|
|
|
case POCKET_ACTION_ZOOM_UP:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_zoom_up();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_ZOOM_DOWN:
|
2005-07-05 20:22:56 +00:00
|
|
|
_CESystem->swap_zoom_down();
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
2006-06-10 11:06:05 +00:00
|
|
|
case POCKET_ACTION_LEFTCLICK:
|
|
|
|
_CESystem->add_left_click(true);
|
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_UP:
|
|
|
|
_CESystem->move_cursor_up();
|
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_DOWN:
|
|
|
|
_CESystem->move_cursor_down();
|
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_LEFT:
|
|
|
|
_CESystem->move_cursor_left();
|
|
|
|
return true;
|
|
|
|
case POCKET_ACTION_RIGHT:
|
|
|
|
_CESystem->move_cursor_right();
|
|
|
|
return true;
|
2004-05-09 14:57:04 +00:00
|
|
|
case POCKET_ACTION_QUIT:
|
2006-01-29 23:23:17 +00:00
|
|
|
{
|
|
|
|
GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
|
|
|
|
if (alert.runModal() == GUI::kMessageOK)
|
|
|
|
_mainSystem->quit();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case POCKET_ACTION_BINDKEYS:
|
|
|
|
if (!keydialogrunning) {
|
|
|
|
keydialogrunning = true;
|
|
|
|
GUI::KeysDialog *keysDialog = new GUI::KeysDialog();
|
|
|
|
keysDialog->runModal();
|
|
|
|
delete keysDialog;
|
|
|
|
keydialogrunning = false;
|
|
|
|
}
|
2004-05-09 14:57:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CEActionsPocket::needsRightClickMapping() {
|
|
|
|
if (!_right_click_needed)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return (_action_mapping[POCKET_ACTION_RIGHTCLICK] == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CEActionsPocket::needsHideToolbarMapping() {
|
|
|
|
if (!_hide_toolbar_needed)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return (_action_mapping[POCKET_ACTION_HIDE] == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CEActionsPocket::needsZoomMapping() {
|
|
|
|
if (!_zoom_needed)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return (_action_mapping[POCKET_ACTION_ZOOM_UP] == 0 || _action_mapping[POCKET_ACTION_ZOOM_DOWN] == 0);
|
|
|
|
}
|
|
|
|
|