mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-23 11:04:44 +00:00
Use Common::Keycode and enums in interface buttons
This commit is contained in:
parent
19303c49cf
commit
a5553b3197
@ -335,16 +335,16 @@ void DisplayMan::setUpScreens() {
|
||||
// It's very convenient to have those shortcut, so I added them
|
||||
// for all versions. (Strangerke)
|
||||
uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
|
||||
moveButtonList->push_back(e->createButton( 1, y, 0, 't', moveImages[0], moveImages[1]));
|
||||
moveButtonList->push_back(e->createButton( 33, y, 1, 'm', moveImages[2], moveImages[3]));
|
||||
moveButtonList->push_back(e->createButton( 65, y, 2, 'o', moveImages[4], moveImages[5]));
|
||||
moveButtonList->push_back(e->createButton( 97, y, 3, 'c', moveImages[6], moveImages[7]));
|
||||
moveButtonList->push_back(e->createButton(129, y, 4, 'l', moveImages[8], moveImages[9]));
|
||||
moveButtonList->push_back(e->createButton(161, y, 5, 'i', moveImages[12], moveImages[13]));
|
||||
moveButtonList->push_back(e->createButton(193, y, 6, VKEY_LTARROW, moveImages[14], moveImages[15]));
|
||||
moveButtonList->push_back(e->createButton(225, y, 7, VKEY_UPARROW, moveImages[16], moveImages[17]));
|
||||
moveButtonList->push_back(e->createButton(257, y, 8, VKEY_RTARROW, moveImages[18], moveImages[19]));
|
||||
moveButtonList->push_back(e->createButton(289, y, 9, 'p', moveImages[10], moveImages[11]));
|
||||
moveButtonList->push_back(e->createButton( 1, y, 0, Common::KEYCODE_t, moveImages[0], moveImages[1]));
|
||||
moveButtonList->push_back(e->createButton( 33, y, 1, Common::KEYCODE_m, moveImages[2], moveImages[3]));
|
||||
moveButtonList->push_back(e->createButton( 65, y, 2, Common::KEYCODE_o, moveImages[4], moveImages[5]));
|
||||
moveButtonList->push_back(e->createButton( 97, y, 3, Common::KEYCODE_c, moveImages[6], moveImages[7]));
|
||||
moveButtonList->push_back(e->createButton(129, y, 4, Common::KEYCODE_l, moveImages[8], moveImages[9]));
|
||||
moveButtonList->push_back(e->createButton(161, y, 5, Common::KEYCODE_i, moveImages[12], moveImages[13]));
|
||||
moveButtonList->push_back(e->createButton(193, y, 6, Common::KEYCODE_LEFT, moveImages[14], moveImages[15]));
|
||||
moveButtonList->push_back(e->createButton(225, y, 7, Common::KEYCODE_UP, moveImages[16], moveImages[17]));
|
||||
moveButtonList->push_back(e->createButton(257, y, 8, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19]));
|
||||
moveButtonList->push_back(e->createButton(289, y, 9, Common::KEYCODE_p, moveImages[10], moveImages[11]));
|
||||
|
||||
// TODO: The INV file is not present in the Amiga version
|
||||
Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
|
||||
@ -355,18 +355,18 @@ void DisplayMan::setUpScreens() {
|
||||
for (int imgIdx = 0; imgIdx < 6; imgIdx++)
|
||||
_vm->_invImages[imgIdx] = new Image(invFile, _vm);
|
||||
}
|
||||
invButtonList->push_back(e->createButton( 24, y, 0, 'm', invImages[0], invImages[1]));
|
||||
invButtonList->push_back(e->createButton( 56, y, 1, 'g', invImages[2], invImages[3]));
|
||||
invButtonList->push_back(e->createButton( 94, y, 2, 'u', invImages[4], invImages[5]));
|
||||
invButtonList->push_back(e->createButton(126, y, 3, 'l', moveImages[8], moveImages[9]));
|
||||
invButtonList->push_back(e->createButton(164, y, 4, VKEY_LTARROW, moveImages[14], moveImages[15]));
|
||||
invButtonList->push_back(e->createButton(196, y, 5, VKEY_RTARROW, moveImages[18], moveImages[19]));
|
||||
invButtonList->push_back(e->createButton( 24, y, 0, Common::KEYCODE_ESCAPE, invImages[0], invImages[1]));
|
||||
invButtonList->push_back(e->createButton( 56, y, 1, Common::KEYCODE_g, invImages[2], invImages[3]));
|
||||
invButtonList->push_back(e->createButton( 94, y, 2, Common::KEYCODE_u, invImages[4], invImages[5]));
|
||||
invButtonList->push_back(e->createButton(126, y, 3, Common::KEYCODE_l, moveImages[8], moveImages[9]));
|
||||
invButtonList->push_back(e->createButton(164, y, 4, Common::KEYCODE_LEFT, moveImages[14], moveImages[15]));
|
||||
invButtonList->push_back(e->createButton(196, y, 5, Common::KEYCODE_RIGHT, moveImages[18], moveImages[19]));
|
||||
|
||||
// The windows version has 2 extra buttons for breadcrumb trail
|
||||
// CHECKME: the game is really hard to play without those, maybe we could add something to enable that.
|
||||
if (_vm->getPlatform() == Common::kPlatformWindows) {
|
||||
invButtonList->push_back(e->createButton(234, y, 6, 'b', invImages[6], invImages[7]));
|
||||
invButtonList->push_back(e->createButton(266, y, 7, 'f', invImages[8], invImages[9]));
|
||||
invButtonList->push_back(e->createButton(234, y, 6, Common::KEYCODE_b, invImages[6], invImages[7]));
|
||||
invButtonList->push_back(e->createButton(266, y, 7, Common::KEYCODE_f, invImages[8], invImages[9]));
|
||||
}
|
||||
|
||||
delete invFile;
|
||||
|
@ -77,19 +77,6 @@ enum Monitors {
|
||||
//kMonitorLevers = 82
|
||||
};
|
||||
|
||||
enum MainButtons {
|
||||
kButtonPickup,
|
||||
kButtonUse,
|
||||
kButtonOpen,
|
||||
kButtonClose,
|
||||
kButtonLook,
|
||||
kButtonInventory,
|
||||
kButtonLeft,
|
||||
kButtonForward,
|
||||
kButtonRight,
|
||||
kButtonMap
|
||||
};
|
||||
|
||||
enum AltButtons {
|
||||
kButtonMainDisplay,
|
||||
kButtonSaveLoad,
|
||||
@ -505,24 +492,9 @@ void LabEngine::mainGameLoop() {
|
||||
_anim->diffNextFrame();
|
||||
|
||||
if (_followingCrumbs) {
|
||||
int result = followCrumbs();
|
||||
|
||||
if (result != 0) {
|
||||
uint16 code = 0;
|
||||
switch (result) {
|
||||
case VKEY_UPARROW:
|
||||
code = kButtonForward;
|
||||
break;
|
||||
case VKEY_LTARROW:
|
||||
code = kButtonLeft;
|
||||
break;
|
||||
case VKEY_RTARROW:
|
||||
code = kButtonRight;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MainButton code = followCrumbs();
|
||||
|
||||
if (code == kButtonForward || code == kButtonLeft || code == kButtonRight) {
|
||||
gotMessage = true;
|
||||
mayShowCrumbIndicator();
|
||||
_graphics->screenUpdate();
|
||||
@ -1100,18 +1072,18 @@ void LabEngine::go() {
|
||||
_music->freeMusic();
|
||||
}
|
||||
|
||||
int LabEngine::followCrumbs() {
|
||||
MainButton LabEngine::followCrumbs() {
|
||||
// kDirectionNorth, kDirectionSouth, kDirectionEast, kDirectionWest
|
||||
int movement[4][4] = {
|
||||
{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
|
||||
{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
|
||||
{ VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW },
|
||||
{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
|
||||
MainButton movement[4][4] = {
|
||||
{ kButtonForward, kButtonRight, kButtonRight, kButtonLeft },
|
||||
{ kButtonRight, kButtonForward, kButtonLeft, kButtonRight },
|
||||
{ kButtonLeft, kButtonRight, kButtonForward, kButtonRight },
|
||||
{ kButtonRight, kButtonLeft, kButtonRight, kButtonForward }
|
||||
};
|
||||
|
||||
if (_isCrumbWaiting) {
|
||||
if (_system->getMillis() <= _crumbTimestamp)
|
||||
return 0;
|
||||
return kButtonNone;
|
||||
|
||||
_isCrumbWaiting = false;
|
||||
}
|
||||
@ -1125,10 +1097,10 @@ int LabEngine::followCrumbs() {
|
||||
_breadCrumbs[0]._roomNum = 0;
|
||||
_droppingCrumbs = false;
|
||||
_followingCrumbs = false;
|
||||
return 0;
|
||||
return kButtonNone;
|
||||
}
|
||||
|
||||
int exitDir;
|
||||
Direction exitDir;
|
||||
// which direction is last crumb
|
||||
if (_breadCrumbs[_numCrumbs]._direction == kDirectionEast)
|
||||
exitDir = kDirectionWest;
|
||||
@ -1139,7 +1111,7 @@ int LabEngine::followCrumbs() {
|
||||
else
|
||||
exitDir = kDirectionNorth;
|
||||
|
||||
int moveDir = movement[_direction][exitDir];
|
||||
MainButton moveDir = movement[_direction][exitDir];
|
||||
|
||||
if (_numCrumbs == 0) {
|
||||
_isCrumbTurning = false;
|
||||
@ -1147,7 +1119,7 @@ int LabEngine::followCrumbs() {
|
||||
_droppingCrumbs = false;
|
||||
_followingCrumbs = false;
|
||||
} else {
|
||||
_isCrumbTurning = (moveDir != VKEY_UPARROW);
|
||||
_isCrumbTurning = (moveDir != kButtonForward);
|
||||
_isCrumbWaiting = true;
|
||||
|
||||
int theDelay = (_followCrumbsFast ? 1000 / 4 : 1000);
|
||||
|
@ -46,11 +46,6 @@ enum MessageClasses {
|
||||
kMessageDeltaMove
|
||||
};
|
||||
|
||||
#define VKEY_UPARROW 273
|
||||
#define VKEY_DNARROW 274
|
||||
#define VKEY_RTARROW 275
|
||||
#define VKEY_LTARROW 276
|
||||
|
||||
struct IntuiMessage {
|
||||
uint32 _msgClass;
|
||||
uint16 _code; // KeyCode or Button Id
|
||||
@ -61,7 +56,7 @@ struct IntuiMessage {
|
||||
|
||||
struct Button {
|
||||
uint16 _x, _y, _buttonId;
|
||||
uint16 _keyEquiv; // if not zero, a key that activates button
|
||||
Common::KeyCode _keyEquiv; // if not zero, a key that activates button
|
||||
bool _isEnabled;
|
||||
Image *_image, *_altImage;
|
||||
};
|
||||
@ -95,7 +90,7 @@ private:
|
||||
* Checks whether or not the coords fall within one of the buttons in a list
|
||||
* of buttons.
|
||||
*/
|
||||
Button *checkNumButtonHit(ButtonList *buttonList, uint16 key);
|
||||
Button *checkNumButtonHit(ButtonList *buttonList, Common::KeyCode key);
|
||||
|
||||
/**
|
||||
* Make a key press have the right case for a button KeyEquiv value.
|
||||
@ -106,7 +101,7 @@ public:
|
||||
EventManager (LabEngine *vm);
|
||||
|
||||
void attachButtonList(ButtonList *buttonList);
|
||||
Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage);
|
||||
Button *createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage);
|
||||
void toggleButton(Button *button, uint16 penColor, bool enable);
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
namespace Lab {
|
||||
|
||||
Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage) {
|
||||
Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, Common::KeyCode key, Image *image, Image *altImage) {
|
||||
Button *button = new Button();
|
||||
|
||||
if (button) {
|
||||
@ -92,7 +92,7 @@ uint16 EventManager::makeButtonKeyEquiv(uint16 key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
|
||||
Button *EventManager::checkNumButtonHit(ButtonList *buttonList, Common::KeyCode key) {
|
||||
uint16 gkey = key - '0';
|
||||
|
||||
if (!buttonList)
|
||||
@ -100,9 +100,10 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
|
||||
|
||||
for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
|
||||
Button *button = *buttonItr;
|
||||
if (((gkey - 1 == button->_buttonId) || ((gkey == 0) && (button->_buttonId == 9))
|
||||
|| ((button->_keyEquiv != 0) && (makeButtonKeyEquiv(key) == button->_keyEquiv)))
|
||||
&& button->_isEnabled) {
|
||||
if (!button->_isEnabled)
|
||||
continue;
|
||||
|
||||
if ((gkey - 1 == button->_buttonId) || (gkey == 0 && button->_buttonId == 9) || (button->_keyEquiv != Common::KEYCODE_INVALID && key == button->_keyEquiv)) {
|
||||
button->_altImage->drawImage(button->_x, button->_y);
|
||||
_vm->_system->delayMillis(80);
|
||||
button->_image->drawImage(button->_x, button->_y);
|
||||
|
@ -97,6 +97,20 @@ enum Direction {
|
||||
kDirectionWest
|
||||
};
|
||||
|
||||
enum MainButton {
|
||||
kButtonNone = -1,
|
||||
kButtonPickup,
|
||||
kButtonUse,
|
||||
kButtonOpen,
|
||||
kButtonClose,
|
||||
kButtonLook,
|
||||
kButtonInventory,
|
||||
kButtonLeft,
|
||||
kButtonForward,
|
||||
kButtonRight,
|
||||
kButtonMap
|
||||
};
|
||||
|
||||
class LabEngine : public Engine {
|
||||
private:
|
||||
bool _interfaceOff;
|
||||
@ -346,7 +360,7 @@ private:
|
||||
/**
|
||||
* New code to allow quick(er) return navigation in game.
|
||||
*/
|
||||
int followCrumbs();
|
||||
MainButton followCrumbs();
|
||||
void freeMapData();
|
||||
void freeScreens();
|
||||
bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
|
||||
|
@ -75,9 +75,9 @@ void LabEngine::loadMapData() {
|
||||
_imgPath = new Image(mapImages, this);
|
||||
_imgBridge = new Image(mapImages, this);
|
||||
|
||||
_mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages, this), new Image(mapImages, this))); // back
|
||||
_mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages, this), new Image(mapImages, this))); // up
|
||||
_mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages, this), new Image(mapImages, this))); // down
|
||||
_mapButtonList.push_back(_event->createButton( 8, _utils->vgaScaleY(105), 0, Common::KEYCODE_ESCAPE, new Image(mapImages, this), new Image(mapImages, this))); // back
|
||||
_mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, Common::KEYCODE_UP, new Image(mapImages, this), new Image(mapImages, this))); // up
|
||||
_mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, Common::KEYCODE_DOWN, new Image(mapImages, this), new Image(mapImages, this))); // down
|
||||
|
||||
delete mapImages;
|
||||
|
||||
|
@ -128,9 +128,9 @@ void LabEngine::loadJournalData() {
|
||||
_journalTextTitle = _resource->getText("Lab:Rooms/jt");
|
||||
|
||||
Common::File *journalFile = _resource->openDataFile("P:JImage");
|
||||
_journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this))); // back
|
||||
_journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, 0, new Image(journalFile, this), new Image(journalFile, this))); // cancel
|
||||
_journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this))); // forward
|
||||
_journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, Common::KEYCODE_LEFT, new Image(journalFile, this), new Image(journalFile, this))); // back
|
||||
_journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2, Common::KEYCODE_ESCAPE, new Image(journalFile, this), new Image(journalFile, this))); // cancel
|
||||
_journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, Common::KEYCODE_RIGHT, new Image(journalFile, this), new Image(journalFile, this))); // forward
|
||||
delete journalFile;
|
||||
|
||||
_anim->_noPalChange = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user