mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
TSAGE: Implemented Blue Force Options dialog and moved Inventory dialog to Ringworld namespace
This commit is contained in:
parent
bb694c9e1c
commit
9debde02e4
@ -187,6 +187,7 @@ void RightClickDialog::execute() {
|
||||
break;
|
||||
case 4:
|
||||
// Options dialog
|
||||
BlueForce::OptionsDialog::show();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -428,6 +429,73 @@ int RadioConvDialog::show() {
|
||||
return btnIndex;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void OptionsDialog::show() {
|
||||
OptionsDialog *dlg = new OptionsDialog();
|
||||
dlg->draw();
|
||||
|
||||
GfxButton *btn = dlg->execute();
|
||||
|
||||
if (btn == &dlg->_btnQuit) {
|
||||
// Quit game
|
||||
if (MessageDialog::show(QUIT_CONFIRM_MSG, CANCEL_BTN_STRING, QUIT_BTN_STRING) == 1) {
|
||||
g_vm->quitGame();
|
||||
}
|
||||
} else if (btn == &dlg->_btnRestart) {
|
||||
// Restart game
|
||||
g_globals->_game->restartGame();
|
||||
} else if (btn == &dlg->_btnSound) {
|
||||
// Sound dialog
|
||||
SoundDialog::execute();
|
||||
} else if (btn == &dlg->_btnSave) {
|
||||
// Save button
|
||||
g_globals->_game->saveGame();
|
||||
} else if (btn == &dlg->_btnRestore) {
|
||||
// Restore button
|
||||
g_globals->_game->restoreGame();
|
||||
}
|
||||
|
||||
dlg->remove();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
OptionsDialog::OptionsDialog() {
|
||||
// Set the element text
|
||||
_gfxMessage.set(OPTIONS_MSG, 140, ALIGN_LEFT);
|
||||
_btnRestore.setText(RESTORE_BTN_STRING);
|
||||
_btnSave.setText(SAVE_BTN_STRING);
|
||||
_btnRestart.setText(RESTART_BTN_STRING);
|
||||
_btnQuit.setText(QUIT_BTN_STRING);
|
||||
_btnSound.setText(SOUND_BTN_STRING);
|
||||
_btnResume.setText(RESUME_BTN_STRING);
|
||||
|
||||
// Set position of the elements
|
||||
_gfxMessage._bounds.moveTo(0, 1);
|
||||
_btnRestore._bounds.moveTo(0, _gfxMessage._bounds.bottom + 1);
|
||||
_btnSave._bounds.moveTo(0, _btnRestore._bounds.bottom + 1);
|
||||
_btnRestart._bounds.moveTo(0, _btnSave._bounds.bottom + 1);
|
||||
_btnQuit._bounds.moveTo(0, _btnRestart._bounds.bottom + 1);
|
||||
_btnSound._bounds.moveTo(0, _btnQuit._bounds.bottom + 1);
|
||||
_btnResume._bounds.moveTo(0, _btnSound._bounds.bottom + 1);
|
||||
|
||||
// Set all the buttons to the widest button
|
||||
GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
|
||||
int16 btnWidth = 0;
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnList[idx]->_bounds.setWidth(btnWidth);
|
||||
|
||||
// Add the items to the dialog
|
||||
addElements(&_gfxMessage, &_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume, NULL);
|
||||
|
||||
// Set the dialog size and position
|
||||
frame();
|
||||
_bounds.collapse(-6, -6);
|
||||
setCenter(160, 90);
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace BlueForce
|
||||
|
||||
|
@ -85,6 +85,20 @@ public:
|
||||
static int show();
|
||||
};
|
||||
|
||||
class OptionsDialog: public GfxDialog {
|
||||
private:
|
||||
GfxButton _btnSave, _btnRestore, _btnRestart;
|
||||
GfxButton _btnQuit, _btnResume;
|
||||
GfxButton _btnSound;
|
||||
GfxMessage _gfxMessage;
|
||||
public:
|
||||
OptionsDialog();
|
||||
virtual ~OptionsDialog() {}
|
||||
|
||||
static void show();
|
||||
};
|
||||
|
||||
|
||||
} // End of namespace BlueForce
|
||||
|
||||
} // End of namespace TsAGE
|
||||
|
@ -181,242 +181,6 @@ void ModalDialog::drawFrame() {
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
bool GfxInvImage::process(Event &event) {
|
||||
if (!event.handled && (event.eventType == EVENT_BUTTON_DOWN)) {
|
||||
event.handled = _bounds.contains(event.mousePos);
|
||||
return event.handled;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void InventoryDialog::show() {
|
||||
// Determine how many items are in the player's inventory
|
||||
int itemCount = 0;
|
||||
SynchronizedList<InvObject *>::iterator i;
|
||||
for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
|
||||
if ((*i)->inInventory())
|
||||
++itemCount;
|
||||
}
|
||||
|
||||
if (itemCount == 0) {
|
||||
MessageDialog::show(INV_EMPTY_MSG, OK_BTN_STRING);
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryDialog *dlg = new InventoryDialog();
|
||||
dlg->draw();
|
||||
dlg->execute();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
InventoryDialog::InventoryDialog() {
|
||||
// Determine the maximum size of the image of any item in the player's inventory
|
||||
int imgWidth = 0, imgHeight = 0;
|
||||
|
||||
SynchronizedList<InvObject *>::iterator i;
|
||||
for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
|
||||
InvObject *invObject = *i;
|
||||
if (invObject->inInventory()) {
|
||||
// Get the image for the item
|
||||
GfxSurface itemSurface = surfaceFromRes(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
|
||||
|
||||
// Maintain the dimensions of the largest item image
|
||||
imgWidth = MAX(imgWidth, (int)itemSurface.getBounds().width());
|
||||
imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height());
|
||||
|
||||
// Add the item to the display list
|
||||
GfxInvImage *img = new GfxInvImage();
|
||||
_images.push_back(img);
|
||||
img->setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
|
||||
img->_invObject = invObject;
|
||||
add(img);
|
||||
}
|
||||
}
|
||||
assert(_images.size() > 0);
|
||||
|
||||
// Figure out the number of columns/rows to show all the items
|
||||
int cellsSize = 3;
|
||||
while ((cellsSize * cellsSize) < (int)_images.size())
|
||||
++cellsSize;
|
||||
|
||||
// Set the position of each inventory item to be displayed
|
||||
int cellX = 0;
|
||||
Common::Point pt(0, 0);
|
||||
|
||||
for (uint idx = 0; idx < _images.size(); ++idx) {
|
||||
if (cellX == cellsSize) {
|
||||
// Move to the start of the next line
|
||||
pt.x = 0;
|
||||
pt.y += imgHeight + 2;
|
||||
cellX = 0;
|
||||
}
|
||||
|
||||
_images[idx]->_bounds.moveTo(pt.x, pt.y);
|
||||
|
||||
pt.x += imgWidth + 2;
|
||||
++cellX;
|
||||
}
|
||||
|
||||
// Set up the buttons
|
||||
pt.y += imgHeight + 2;
|
||||
_btnOk.setText(OK_BTN_STRING);
|
||||
_btnOk._bounds.moveTo((imgWidth + 2) * cellsSize - _btnOk._bounds.width(), pt.y);
|
||||
_btnLook.setText(LOOK_BTN_STRING);
|
||||
_btnLook._bounds.moveTo(_btnOk._bounds.left - _btnLook._bounds.width() - 2, _btnOk._bounds.top);
|
||||
addElements(&_btnLook, &_btnOk, NULL);
|
||||
|
||||
frame();
|
||||
setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y);
|
||||
}
|
||||
|
||||
InventoryDialog::~InventoryDialog() {
|
||||
for (uint idx = 0; idx < _images.size(); ++idx)
|
||||
delete _images[idx];
|
||||
}
|
||||
|
||||
void InventoryDialog::execute() {
|
||||
if ((RING_INVENTORY._selectedItem) && RING_INVENTORY._selectedItem->inInventory())
|
||||
RING_INVENTORY._selectedItem->setCursor();
|
||||
|
||||
GfxElement *hiliteObj;
|
||||
bool lookFlag = false;
|
||||
_gfxManager.activate();
|
||||
|
||||
while (!g_vm->shouldQuit()) {
|
||||
// Get events
|
||||
Event event;
|
||||
while (!g_globals->_events.getEvent(event) && !g_vm->shouldQuit()) {
|
||||
g_system->delayMillis(10);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
if (g_vm->shouldQuit())
|
||||
break;
|
||||
|
||||
hiliteObj = NULL;
|
||||
if ((event.eventType == EVENT_BUTTON_DOWN) && !_bounds.contains(event.mousePos))
|
||||
break;
|
||||
|
||||
// Pass event to elements
|
||||
event.mousePos.x -= _gfxManager._bounds.left;
|
||||
event.mousePos.y -= _gfxManager._bounds.top;
|
||||
|
||||
for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
|
||||
if ((*i)->process(event))
|
||||
hiliteObj = *i;
|
||||
}
|
||||
|
||||
if (!event.handled && event.eventType == EVENT_KEYPRESS) {
|
||||
if ((event.kbd.keycode == Common::KEYCODE_RETURN) || (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
|
||||
// Exit the dialog
|
||||
//hiliteObj = &_btnOk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hiliteObj == &_btnOk) {
|
||||
// Ok button clicked
|
||||
if (lookFlag)
|
||||
g_globals->_events.setCursor(CURSOR_WALK);
|
||||
break;
|
||||
} else if (hiliteObj == &_btnLook) {
|
||||
// Look button clicked
|
||||
if (_btnLook._message == LOOK_BTN_STRING) {
|
||||
_btnLook._message = PICK_BTN_STRING;
|
||||
lookFlag = 1;
|
||||
g_globals->_events.setCursor(CURSOR_LOOK);
|
||||
} else {
|
||||
_btnLook._message = LOOK_BTN_STRING;
|
||||
lookFlag = 0;
|
||||
g_globals->_events.setCursor(CURSOR_WALK);
|
||||
}
|
||||
|
||||
hiliteObj->draw();
|
||||
} else if (hiliteObj) {
|
||||
// Inventory item selected
|
||||
InvObject *invObject = static_cast<GfxInvImage *>(hiliteObj)->_invObject;
|
||||
if (lookFlag) {
|
||||
g_globals->_screenSurface.displayText(invObject->_description);
|
||||
} else {
|
||||
RING_INVENTORY._selectedItem = invObject;
|
||||
invObject->setCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_gfxManager.deactivate();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void OptionsDialog::show() {
|
||||
OptionsDialog *dlg = new OptionsDialog();
|
||||
dlg->draw();
|
||||
|
||||
GfxButton *btn = dlg->execute();
|
||||
|
||||
if (btn == &dlg->_btnQuit) {
|
||||
// Quit game
|
||||
if (MessageDialog::show(QUIT_CONFIRM_MSG, CANCEL_BTN_STRING, QUIT_BTN_STRING) == 1) {
|
||||
g_vm->quitGame();
|
||||
}
|
||||
} else if (btn == &dlg->_btnRestart) {
|
||||
// Restart game
|
||||
g_globals->_game->restartGame();
|
||||
} else if (btn == &dlg->_btnSound) {
|
||||
// Sound dialog
|
||||
SoundDialog::execute();
|
||||
} else if (btn == &dlg->_btnSave) {
|
||||
// Save button
|
||||
g_globals->_game->saveGame();
|
||||
} else if (btn == &dlg->_btnRestore) {
|
||||
// Restore button
|
||||
g_globals->_game->restoreGame();
|
||||
}
|
||||
|
||||
dlg->remove();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
OptionsDialog::OptionsDialog() {
|
||||
// Set the element text
|
||||
_gfxMessage.set(OPTIONS_MSG, 140, ALIGN_LEFT);
|
||||
_btnRestore.setText(RESTORE_BTN_STRING);
|
||||
_btnSave.setText(SAVE_BTN_STRING);
|
||||
_btnRestart.setText(RESTART_BTN_STRING);
|
||||
_btnQuit.setText(QUIT_BTN_STRING);
|
||||
_btnSound.setText(SOUND_BTN_STRING);
|
||||
_btnResume.setText(RESUME_BTN_STRING);
|
||||
|
||||
// Set position of the elements
|
||||
_gfxMessage._bounds.moveTo(0, 1);
|
||||
_btnRestore._bounds.moveTo(0, _gfxMessage._bounds.bottom + 1);
|
||||
_btnSave._bounds.moveTo(0, _btnRestore._bounds.bottom + 1);
|
||||
_btnRestart._bounds.moveTo(0, _btnSave._bounds.bottom + 1);
|
||||
_btnQuit._bounds.moveTo(0, _btnRestart._bounds.bottom + 1);
|
||||
_btnSound._bounds.moveTo(0, _btnQuit._bounds.bottom + 1);
|
||||
_btnResume._bounds.moveTo(0, _btnSound._bounds.bottom + 1);
|
||||
|
||||
// Set all the buttons to the widest button
|
||||
GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
|
||||
int16 btnWidth = 0;
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnList[idx]->_bounds.setWidth(btnWidth);
|
||||
|
||||
// Add the items to the dialog
|
||||
addElements(&_gfxMessage, &_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume, NULL);
|
||||
|
||||
// Set the dialog size and position
|
||||
frame();
|
||||
setCenter(160, 100);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void SoundDialog::execute() {
|
||||
ConfigDialog *dlg = new ConfigDialog();
|
||||
dlg->runModal();
|
||||
|
@ -60,47 +60,6 @@ public:
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
class GfxInvImage : public GfxImage {
|
||||
public:
|
||||
InvObject *_invObject;
|
||||
public:
|
||||
GfxInvImage() : GfxImage(), _invObject(NULL) {}
|
||||
|
||||
virtual bool process(Event &event);
|
||||
};
|
||||
|
||||
#define MAX_INVOBJECT_DISPLAY 20
|
||||
|
||||
class InventoryDialog : public ModalDialog {
|
||||
private:
|
||||
Common::Array<GfxInvImage *> _images;
|
||||
GfxButton _btnOk, _btnLook;
|
||||
public:
|
||||
InventoryDialog();
|
||||
virtual ~InventoryDialog();
|
||||
void execute();
|
||||
|
||||
static void show();
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
class OptionsDialog : public ModalDialog {
|
||||
private:
|
||||
GfxButton _btnSave, _btnRestore, _btnRestart;
|
||||
GfxButton _btnQuit, _btnResume;
|
||||
GfxButton _btnSound;
|
||||
GfxMessage _gfxMessage;
|
||||
public:
|
||||
OptionsDialog();
|
||||
virtual ~OptionsDialog() {}
|
||||
GfxButton *execute() { return GfxDialog::execute(&_btnResume); }
|
||||
|
||||
static void show();
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
class SoundDialog {
|
||||
public:
|
||||
static void execute();
|
||||
|
@ -210,13 +210,249 @@ void RightClickDialog::execute() {
|
||||
break;
|
||||
case 6:
|
||||
// Dialog options
|
||||
OptionsDialog::show();
|
||||
Ringworld::OptionsDialog::show();
|
||||
break;
|
||||
}
|
||||
|
||||
_gfxManager.deactivate();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void OptionsDialog::show() {
|
||||
OptionsDialog *dlg = new OptionsDialog();
|
||||
dlg->draw();
|
||||
|
||||
GfxButton *btn = dlg->execute();
|
||||
|
||||
if (btn == &dlg->_btnQuit) {
|
||||
// Quit game
|
||||
if (MessageDialog::show(QUIT_CONFIRM_MSG, CANCEL_BTN_STRING, QUIT_BTN_STRING) == 1) {
|
||||
g_vm->quitGame();
|
||||
}
|
||||
} else if (btn == &dlg->_btnRestart) {
|
||||
// Restart game
|
||||
g_globals->_game->restartGame();
|
||||
} else if (btn == &dlg->_btnSound) {
|
||||
// Sound dialog
|
||||
SoundDialog::execute();
|
||||
} else if (btn == &dlg->_btnSave) {
|
||||
// Save button
|
||||
g_globals->_game->saveGame();
|
||||
} else if (btn == &dlg->_btnRestore) {
|
||||
// Restore button
|
||||
g_globals->_game->restoreGame();
|
||||
}
|
||||
|
||||
dlg->remove();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
OptionsDialog::OptionsDialog() {
|
||||
// Set the element text
|
||||
_gfxMessage.set(OPTIONS_MSG, 140, ALIGN_LEFT);
|
||||
_btnRestore.setText(RESTORE_BTN_STRING);
|
||||
_btnSave.setText(SAVE_BTN_STRING);
|
||||
_btnRestart.setText(RESTART_BTN_STRING);
|
||||
_btnQuit.setText(QUIT_BTN_STRING);
|
||||
_btnSound.setText(SOUND_BTN_STRING);
|
||||
_btnResume.setText(RESUME_BTN_STRING);
|
||||
|
||||
// Set position of the elements
|
||||
_gfxMessage._bounds.moveTo(0, 1);
|
||||
_btnRestore._bounds.moveTo(0, _gfxMessage._bounds.bottom + 1);
|
||||
_btnSave._bounds.moveTo(0, _btnRestore._bounds.bottom + 1);
|
||||
_btnRestart._bounds.moveTo(0, _btnSave._bounds.bottom + 1);
|
||||
_btnQuit._bounds.moveTo(0, _btnRestart._bounds.bottom + 1);
|
||||
_btnSound._bounds.moveTo(0, _btnQuit._bounds.bottom + 1);
|
||||
_btnResume._bounds.moveTo(0, _btnSound._bounds.bottom + 1);
|
||||
|
||||
// Set all the buttons to the widest button
|
||||
GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
|
||||
int16 btnWidth = 0;
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
|
||||
for (int idx = 0; idx < 6; ++idx)
|
||||
btnList[idx]->_bounds.setWidth(btnWidth);
|
||||
|
||||
// Add the items to the dialog
|
||||
addElements(&_gfxMessage, &_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume, NULL);
|
||||
|
||||
// Set the dialog size and position
|
||||
frame();
|
||||
setCenter(160, 100);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
bool GfxInvImage::process(Event &event) {
|
||||
if (!event.handled && (event.eventType == EVENT_BUTTON_DOWN)) {
|
||||
event.handled = _bounds.contains(event.mousePos);
|
||||
return event.handled;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void InventoryDialog::show() {
|
||||
// Determine how many items are in the player's inventory
|
||||
int itemCount = 0;
|
||||
SynchronizedList<InvObject *>::iterator i;
|
||||
for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
|
||||
if ((*i)->inInventory())
|
||||
++itemCount;
|
||||
}
|
||||
|
||||
if (itemCount == 0) {
|
||||
MessageDialog::show(INV_EMPTY_MSG, OK_BTN_STRING);
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryDialog *dlg = new InventoryDialog();
|
||||
dlg->draw();
|
||||
dlg->execute();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
InventoryDialog::InventoryDialog() {
|
||||
// Determine the maximum size of the image of any item in the player's inventory
|
||||
int imgWidth = 0, imgHeight = 0;
|
||||
|
||||
SynchronizedList<InvObject *>::iterator i;
|
||||
for (i = RING_INVENTORY._itemList.begin(); i != RING_INVENTORY._itemList.end(); ++i) {
|
||||
InvObject *invObject = *i;
|
||||
if (invObject->inInventory()) {
|
||||
// Get the image for the item
|
||||
GfxSurface itemSurface = surfaceFromRes(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
|
||||
|
||||
// Maintain the dimensions of the largest item image
|
||||
imgWidth = MAX(imgWidth, (int)itemSurface.getBounds().width());
|
||||
imgHeight = MAX(imgHeight, (int)itemSurface.getBounds().height());
|
||||
|
||||
// Add the item to the display list
|
||||
GfxInvImage *img = new GfxInvImage();
|
||||
_images.push_back(img);
|
||||
img->setDetails(invObject->_displayResNum, invObject->_rlbNum, invObject->_cursorNum);
|
||||
img->_invObject = invObject;
|
||||
add(img);
|
||||
}
|
||||
}
|
||||
assert(_images.size() > 0);
|
||||
|
||||
// Figure out the number of columns/rows to show all the items
|
||||
int cellsSize = 3;
|
||||
while ((cellsSize * cellsSize) < (int)_images.size())
|
||||
++cellsSize;
|
||||
|
||||
// Set the position of each inventory item to be displayed
|
||||
int cellX = 0;
|
||||
Common::Point pt(0, 0);
|
||||
|
||||
for (uint idx = 0; idx < _images.size(); ++idx) {
|
||||
if (cellX == cellsSize) {
|
||||
// Move to the start of the next line
|
||||
pt.x = 0;
|
||||
pt.y += imgHeight + 2;
|
||||
cellX = 0;
|
||||
}
|
||||
|
||||
_images[idx]->_bounds.moveTo(pt.x, pt.y);
|
||||
|
||||
pt.x += imgWidth + 2;
|
||||
++cellX;
|
||||
}
|
||||
|
||||
// Set up the buttons
|
||||
pt.y += imgHeight + 2;
|
||||
_btnOk.setText(OK_BTN_STRING);
|
||||
_btnOk._bounds.moveTo((imgWidth + 2) * cellsSize - _btnOk._bounds.width(), pt.y);
|
||||
_btnLook.setText(LOOK_BTN_STRING);
|
||||
_btnLook._bounds.moveTo(_btnOk._bounds.left - _btnLook._bounds.width() - 2, _btnOk._bounds.top);
|
||||
addElements(&_btnLook, &_btnOk, NULL);
|
||||
|
||||
frame();
|
||||
setCenter(SCREEN_CENTER_X, SCREEN_CENTER_Y);
|
||||
}
|
||||
|
||||
InventoryDialog::~InventoryDialog() {
|
||||
for (uint idx = 0; idx < _images.size(); ++idx)
|
||||
delete _images[idx];
|
||||
}
|
||||
|
||||
void InventoryDialog::execute() {
|
||||
if ((RING_INVENTORY._selectedItem) && RING_INVENTORY._selectedItem->inInventory())
|
||||
RING_INVENTORY._selectedItem->setCursor();
|
||||
|
||||
GfxElement *hiliteObj;
|
||||
bool lookFlag = false;
|
||||
_gfxManager.activate();
|
||||
|
||||
while (!g_vm->shouldQuit()) {
|
||||
// Get events
|
||||
Event event;
|
||||
while (!g_globals->_events.getEvent(event) && !g_vm->shouldQuit()) {
|
||||
g_system->delayMillis(10);
|
||||
g_system->updateScreen();
|
||||
}
|
||||
if (g_vm->shouldQuit())
|
||||
break;
|
||||
|
||||
hiliteObj = NULL;
|
||||
if ((event.eventType == EVENT_BUTTON_DOWN) && !_bounds.contains(event.mousePos))
|
||||
break;
|
||||
|
||||
// Pass event to elements
|
||||
event.mousePos.x -= _gfxManager._bounds.left;
|
||||
event.mousePos.y -= _gfxManager._bounds.top;
|
||||
|
||||
for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
|
||||
if ((*i)->process(event))
|
||||
hiliteObj = *i;
|
||||
}
|
||||
|
||||
if (!event.handled && event.eventType == EVENT_KEYPRESS) {
|
||||
if ((event.kbd.keycode == Common::KEYCODE_RETURN) || (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
|
||||
// Exit the dialog
|
||||
//hiliteObj = &_btnOk;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hiliteObj == &_btnOk) {
|
||||
// Ok button clicked
|
||||
if (lookFlag)
|
||||
g_globals->_events.setCursor(CURSOR_WALK);
|
||||
break;
|
||||
} else if (hiliteObj == &_btnLook) {
|
||||
// Look button clicked
|
||||
if (_btnLook._message == LOOK_BTN_STRING) {
|
||||
_btnLook._message = PICK_BTN_STRING;
|
||||
lookFlag = 1;
|
||||
g_globals->_events.setCursor(CURSOR_LOOK);
|
||||
} else {
|
||||
_btnLook._message = LOOK_BTN_STRING;
|
||||
lookFlag = 0;
|
||||
g_globals->_events.setCursor(CURSOR_WALK);
|
||||
}
|
||||
|
||||
hiliteObj->draw();
|
||||
} else if (hiliteObj) {
|
||||
// Inventory item selected
|
||||
InvObject *invObject = static_cast<GfxInvImage *>(hiliteObj)->_invObject;
|
||||
if (lookFlag) {
|
||||
g_globals->_screenSurface.displayText(invObject->_description);
|
||||
} else {
|
||||
RING_INVENTORY._selectedItem = invObject;
|
||||
invObject->setCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_gfxManager.deactivate();
|
||||
}
|
||||
|
||||
} // End of namespace Ringworld
|
||||
|
||||
} // End of namespace TsAGE
|
||||
|
@ -63,6 +63,45 @@ public:
|
||||
void execute();
|
||||
};
|
||||
|
||||
class OptionsDialog : public ModalDialog {
|
||||
private:
|
||||
GfxButton _btnSave, _btnRestore, _btnRestart;
|
||||
GfxButton _btnQuit, _btnResume;
|
||||
GfxButton _btnSound;
|
||||
GfxMessage _gfxMessage;
|
||||
public:
|
||||
OptionsDialog();
|
||||
virtual ~OptionsDialog() {}
|
||||
GfxButton *execute() { return GfxDialog::execute(&_btnResume); }
|
||||
|
||||
static void show();
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
class GfxInvImage : public GfxImage {
|
||||
public:
|
||||
InvObject *_invObject;
|
||||
public:
|
||||
GfxInvImage() : GfxImage(), _invObject(NULL) {}
|
||||
|
||||
virtual bool process(Event &event);
|
||||
};
|
||||
|
||||
#define MAX_INVOBJECT_DISPLAY 20
|
||||
|
||||
class InventoryDialog : public ModalDialog {
|
||||
private:
|
||||
Common::Array<GfxInvImage *> _images;
|
||||
GfxButton _btnOk, _btnLook;
|
||||
public:
|
||||
InventoryDialog();
|
||||
virtual ~InventoryDialog();
|
||||
void execute();
|
||||
|
||||
static void show();
|
||||
};
|
||||
|
||||
} // End of namespace Ringworld
|
||||
|
||||
} // End of namespace TsAGE
|
||||
|
@ -77,7 +77,6 @@ const char *INV_EMPTY_MSG = "You have nothing in your possesion.";
|
||||
const char *QUIT_CONFIRM_MSG = "Do you want to quit playing this game?";
|
||||
const char *RESTART_MSG = "Do you want to restart this game?";
|
||||
const char *GAME_PAUSED_MSG = "Game is paused.";
|
||||
const char *OPTIONS_MSG = "\x01Options...";
|
||||
const char *OK_BTN_STRING = " Ok ";
|
||||
const char *CANCEL_BTN_STRING = "Cancel";
|
||||
const char *QUIT_BTN_STRING = " Quit ";
|
||||
@ -99,6 +98,7 @@ F4 - Restart\rF5 - Save game\rF7 - Restore Game\rF10 - Pause game";
|
||||
const char *WATCH_INTRO_MSG = "Do you wish to watch the introduction?";
|
||||
const char *START_PLAY_BTN_STRING = " Start Play ";
|
||||
const char *INTRODUCTION_BTN_STRING = "Introduction";
|
||||
const char *OPTIONS_MSG = "\x01Options...";
|
||||
|
||||
// Scene specific resources
|
||||
const char *EXIT_MSG = " EXIT ";
|
||||
@ -134,6 +134,7 @@ F4 - Restart\rF5 - Save game\rF7 - Restore Game\rF10 - Pause game";
|
||||
const char *WATCH_INTRO_MSG = "Do you wish to watch the introduction?";
|
||||
const char *START_PLAY_BTN_STRING = " Play ";
|
||||
const char *INTRODUCTION_BTN_STRING = " Watch ";
|
||||
const char *OPTIONS_MSG = "Options...";
|
||||
|
||||
// Blue Force general messages
|
||||
const char *BF_NAME = "Blue Force";
|
||||
@ -191,6 +192,8 @@ const char *CONSOLE_MESSAGES[] = {
|
||||
"Mozart", "Bach", "Rossini"
|
||||
};
|
||||
|
||||
const char *HELP_MSG = "\x1\rRETURN TO\r RINGWORLD\x14";
|
||||
|
||||
} // End of namespace Ringworld2
|
||||
|
||||
} // End of namespace TsAGE
|
||||
|
@ -44,7 +44,6 @@ extern const char *RESTORING_NOT_ALLOWED_MSG;
|
||||
extern const char *QUIT_CONFIRM_MSG;
|
||||
extern const char *RESTART_MSG;
|
||||
extern const char *GAME_PAUSED_MSG;
|
||||
extern const char *OPTIONS_MSG;
|
||||
extern const char *OK_BTN_STRING;
|
||||
extern const char *CANCEL_BTN_STRING;
|
||||
extern const char *QUIT_BTN_STRING;
|
||||
@ -64,6 +63,7 @@ extern const char *HELP_MSG;
|
||||
extern const char *WATCH_INTRO_MSG;
|
||||
extern const char *START_PLAY_BTN_STRING;
|
||||
extern const char *INTRODUCTION_BTN_STRING;
|
||||
extern const char *OPTIONS_MSG;
|
||||
|
||||
// Scene specific resources
|
||||
extern const char *EXIT_MSG;
|
||||
@ -98,6 +98,7 @@ extern const char *HELP_MSG;
|
||||
extern const char *WATCH_INTRO_MSG;
|
||||
extern const char *START_PLAY_BTN_STRING;
|
||||
extern const char *INTRODUCTION_BTN_STRING;
|
||||
extern const char *OPTIONS_MSG;
|
||||
|
||||
// Blue Force messages
|
||||
extern const char *BF_NAME;
|
||||
@ -148,6 +149,9 @@ namespace Ringworld2 {
|
||||
// Scene 125 - Console messages
|
||||
extern const char *CONSOLE_MESSAGES[];
|
||||
|
||||
// Dialog messages
|
||||
extern const char *HELP_MSG;
|
||||
|
||||
} // End of namespace Ringworld2
|
||||
|
||||
} // End of namespace TsAGE
|
||||
|
Loading…
Reference in New Issue
Block a user