mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-17 15:18:11 +00:00
SCI/newgui: select() implemented (interactive modes not done yet)
svn-id: r45674
This commit is contained in:
parent
c975c288ee
commit
14447f7e01
@ -62,7 +62,7 @@ SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette,
|
||||
_text = new SciGuiText(_s->resMan, _gfx, _screen);
|
||||
_windowMgr = new SciGuiWindowMgr(this, _screen, _gfx, _text);
|
||||
_controls = new SciGuiControls(_s->_segMan, _gfx, _text);
|
||||
_menu = new SciGuiMenu(_s->_segMan, _gfx, _text, _screen);
|
||||
_menu = new SciGuiMenu(_s->_segMan, _gfx, _text, _screen, _cursor);
|
||||
// _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "sci/sci.h"
|
||||
#include "sci/engine/state.h"
|
||||
#include "sci/gui/gui_gfx.h"
|
||||
#include "sci/gui/gui_cursor.h"
|
||||
#include "sci/gui/gui_font.h"
|
||||
#include "sci/gui/gui_text.h"
|
||||
#include "sci/gui/gui_screen.h"
|
||||
@ -37,8 +38,8 @@
|
||||
|
||||
namespace Sci {
|
||||
|
||||
SciGuiMenu::SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen)
|
||||
: _segMan(segMan), _gfx(gfx), _text(text), _screen(screen) {
|
||||
SciGuiMenu::SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen, SciGuiCursor *cursor)
|
||||
: _segMan(segMan), _gfx(gfx), _text(text), _screen(screen), _cursor(cursor) {
|
||||
|
||||
_listCount = 0;
|
||||
}
|
||||
@ -225,7 +226,7 @@ void SciGuiMenu::setAttribute(uint16 menuId, uint16 itemId, uint16 attributeId,
|
||||
itemEntry->textVmPtr = value;
|
||||
break;
|
||||
case SCI_MENU_ATTRIBUTE_KEYPRESS:
|
||||
itemEntry->keyPress = value.offset;
|
||||
itemEntry->keyPress = tolower(value.offset);
|
||||
itemEntry->keyModifier = 0;
|
||||
// TODO: Find out how modifier is handled
|
||||
printf("setAttr keypress %X %X\n", value.segment, value.offset);
|
||||
@ -282,7 +283,86 @@ void SciGuiMenu::drawBar() {
|
||||
_gfx->BitsShow(_gfx->_menuRect);
|
||||
}
|
||||
|
||||
void SciGuiMenu::calculateTextWidth() {
|
||||
GuiMenuList::iterator menuIterator;
|
||||
GuiMenuList::iterator menuEnd = _list.end();
|
||||
GuiMenuEntry *menuEntry;
|
||||
GuiMenuItemList::iterator itemIterator;
|
||||
GuiMenuItemList::iterator itemEnd = _itemList.end();
|
||||
GuiMenuItemEntry *itemEntry;
|
||||
int16 dummyHeight;
|
||||
|
||||
menuIterator = _list.begin();
|
||||
while (menuIterator != menuEnd) {
|
||||
menuEntry = *menuIterator;
|
||||
_text->StringWidth(menuEntry->text.c_str(), 0, menuEntry->textWidth, dummyHeight);
|
||||
|
||||
menuIterator++;
|
||||
}
|
||||
|
||||
itemIterator = _itemList.begin();
|
||||
while (itemIterator != itemEnd) {
|
||||
itemEntry = *itemIterator;
|
||||
_text->StringWidth(itemEntry->text.c_str(), 0, itemEntry->textWidth, dummyHeight);
|
||||
|
||||
itemIterator++;
|
||||
}
|
||||
}
|
||||
|
||||
GuiMenuItemEntry *SciGuiMenu::interactiveWithKeyboard() {
|
||||
calculateTextWidth();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GuiMenuItemEntry *SciGuiMenu::interactiveWithMouse() {
|
||||
calculateTextWidth();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reg_t SciGuiMenu::select(reg_t eventObject) {
|
||||
int16 eventType = GET_SEL32V(_segMan, eventObject, type);
|
||||
int16 keyPress = GET_SEL32V(_segMan, eventObject, message);
|
||||
int16 keyModifier = GET_SEL32V(_segMan, eventObject, modifiers);
|
||||
Common::Point mousePosition;
|
||||
GuiMenuItemList::iterator itemIterator = _itemList.begin();
|
||||
GuiMenuItemList::iterator itemEnd = _itemList.end();
|
||||
GuiMenuItemEntry *itemEntry = NULL;
|
||||
bool forceClaimed = false;
|
||||
|
||||
switch (eventType) {
|
||||
case SCI_EVT_KEYBOARD:
|
||||
if (keyPress == SCI_K_ESC) {
|
||||
itemEntry = interactiveWithKeyboard();
|
||||
forceClaimed = true;
|
||||
} else if (keyPress) {
|
||||
while (itemIterator != itemEnd) {
|
||||
itemEntry = *itemIterator;
|
||||
if ((itemEntry->keyPress == keyPress) && (itemEntry->keyModifier == keyModifier))
|
||||
break;
|
||||
itemIterator++;
|
||||
}
|
||||
if (itemIterator == itemEnd)
|
||||
itemEntry = NULL;
|
||||
}
|
||||
break;
|
||||
case SCI_EVT_SAID:
|
||||
break;
|
||||
case SCI_EVT_MOUSE_PRESS:
|
||||
mousePosition = _cursor->getPosition();
|
||||
if (mousePosition.y < 10) {
|
||||
itemEntry = interactiveWithMouse();
|
||||
forceClaimed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ((itemEntry) || (forceClaimed)) {
|
||||
PUT_SEL32(_segMan, eventObject, claimed, make_reg(0, 1));
|
||||
}
|
||||
if (itemEntry)
|
||||
return make_reg(0, (itemEntry->menuId << 8) | (itemEntry->id));
|
||||
return NULL_REG;
|
||||
}
|
||||
|
||||
|
@ -45,9 +45,10 @@ enum {
|
||||
struct GuiMenuEntry {
|
||||
uint16 id;
|
||||
Common::String text;
|
||||
int16 textWidth;
|
||||
|
||||
GuiMenuEntry(uint16 curId)
|
||||
: id(curId) { }
|
||||
: id(curId), textWidth(0) { }
|
||||
};
|
||||
typedef Common::List<GuiMenuEntry *> GuiMenuList;
|
||||
|
||||
@ -63,11 +64,12 @@ struct GuiMenuItemEntry {
|
||||
reg_t saidVmPtr;
|
||||
Common::String text;
|
||||
reg_t textVmPtr;
|
||||
int16 textWidth;
|
||||
Common::String textRightAligned;
|
||||
|
||||
GuiMenuItemEntry(uint16 curMenuId, uint16 curId)
|
||||
: menuId(curMenuId), id(curId),
|
||||
enabled(true), tag(0), keyPress(0), keyModifier(0), separatorLine(false) {
|
||||
enabled(true), tag(0), keyPress(0), keyModifier(0), separatorLine(false), textWidth(0) {
|
||||
saidVmPtr = NULL_REG;
|
||||
textVmPtr = NULL_REG;
|
||||
}
|
||||
@ -76,7 +78,7 @@ typedef Common::List<GuiMenuItemEntry *> GuiMenuItemList;
|
||||
|
||||
class SciGuiMenu {
|
||||
public:
|
||||
SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen);
|
||||
SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen, SciGuiCursor *cursor);
|
||||
~SciGuiMenu();
|
||||
|
||||
void add(Common::String title, Common::String content, reg_t contentVmPtr);
|
||||
@ -88,11 +90,15 @@ public:
|
||||
|
||||
private:
|
||||
GuiMenuItemEntry *findItem(uint16 menuId, uint16 itemId);
|
||||
void calculateTextWidth();
|
||||
GuiMenuItemEntry *interactiveWithKeyboard();
|
||||
GuiMenuItemEntry *interactiveWithMouse();
|
||||
|
||||
SegManager *_segMan;
|
||||
SciGuiGfx *_gfx;
|
||||
SciGuiText *_text;
|
||||
SciGuiScreen *_screen;
|
||||
SciGuiCursor *_cursor;
|
||||
|
||||
uint16 _listCount;
|
||||
GuiMenuList _list;
|
||||
|
Loading…
Reference in New Issue
Block a user