aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-11-04 16:11:44 +0000
committerMartin Kiewitz2009-11-04 16:11:44 +0000
commita53fda32bb0a90dc945a2e921513e8cd3aaa774e (patch)
tree5f71a7d606bf25d88c5e2cff520cf7660c2b3e70 /engines/sci
parent6ea1cf73769a17a556588347e9177e49960bff6f (diff)
downloadscummvm-rg350-a53fda32bb0a90dc945a2e921513e8cd3aaa774e.tar.gz
scummvm-rg350-a53fda32bb0a90dc945a2e921513e8cd3aaa774e.tar.bz2
scummvm-rg350-a53fda32bb0a90dc945a2e921513e8cd3aaa774e.zip
SCI/newgui: SciGuiMenu - set()/get() implemented
svn-id: r45671
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gui/gui.cpp6
-rw-r--r--engines/sci/gui/gui.h2
-rw-r--r--engines/sci/gui/gui_menu.cpp77
-rw-r--r--engines/sci/gui/gui_menu.h23
4 files changed, 92 insertions, 16 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index e6b3bf422b..18ef57f9fd 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -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(_gfx, _text, _screen);
+ _menu = new SciGuiMenu(_s->_segMan, _gfx, _text, _screen);
// _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes
}
@@ -314,8 +314,8 @@ void SciGui::drawMenuBar(bool clear) {
}
}
-void SciGui::menuAdd(Common::String title, Common::String content, reg_t entriesBase) {
- _menu->add(title, content);
+void SciGui::menuAdd(Common::String title, Common::String content, reg_t contentVmPtr) {
+ _menu->add(title, content, contentVmPtr);
}
void SciGui::menuSet(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value) {
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index 008aae1c92..13756f37ae 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -81,7 +81,7 @@ public:
virtual void drawStatus(const char *text, int16 colorPen, int16 colorBack);
virtual void drawMenuBar(bool clear);
- virtual void menuAdd(Common::String title, Common::String content, reg_t entriesBase);
+ virtual void menuAdd(Common::String title, Common::String content, reg_t contentVmPtr);
virtual void menuSet(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value);
virtual reg_t menuGet(uint16 menuId, uint16 itemId, uint16 attributeId);
virtual reg_t menuSelect(reg_t eventObject);
diff --git a/engines/sci/gui/gui_menu.cpp b/engines/sci/gui/gui_menu.cpp
index 737e90f35e..7c81b8a017 100644
--- a/engines/sci/gui/gui_menu.cpp
+++ b/engines/sci/gui/gui_menu.cpp
@@ -37,14 +37,16 @@
namespace Sci {
-SciGuiMenu::SciGuiMenu(SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen)
- : _gfx(gfx), _text(text), _screen(screen) {
+SciGuiMenu::SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen)
+ : _segMan(segMan), _gfx(gfx), _text(text), _screen(screen) {
+
+ _listCount = 0;
}
SciGuiMenu::~SciGuiMenu() {
}
-void SciGuiMenu::add(Common::String title, Common::String content) {
+void SciGuiMenu::add(Common::String title, Common::String content, reg_t contentVmPtr) {
GuiMenuEntry *menuEntry;
uint16 itemCount = 0;
GuiMenuItemEntry *itemEntry;
@@ -166,6 +168,8 @@ void SciGuiMenu::add(Common::String title, Common::String content) {
} else {
itemEntry->text = Common::String(content.c_str() + beginPos, tempPos - beginPos);
}
+ itemEntry->textVmPtr = contentVmPtr;
+ itemEntry->textVmPtr.offset += beginPos;
if (rightAlignedPos) {
rightAlignedPos++;
@@ -188,11 +192,76 @@ void SciGuiMenu::add(Common::String title, Common::String content) {
} while (curPos < contentSize);
}
+GuiMenuItemEntry *SciGuiMenu::findItem(uint16 menuId, uint16 itemId) {
+ GuiMenuItemList::iterator listIterator;
+ GuiMenuItemList::iterator listEnd = _itemList.end();
+ GuiMenuItemEntry *listEntry;
+
+ listIterator = _itemList.begin();
+ while (listIterator != listEnd) {
+ listEntry = *listIterator;
+ if ((listEntry->menuId == menuId) && (listEntry->id == itemId))
+ return listEntry;
+
+ listIterator++;
+ }
+ return NULL;
+}
+
void SciGuiMenu::setAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value) {
- warning("setAttr: %d %d %d", menuId, itemId, attributeId);
+ GuiMenuItemEntry *itemEntry = findItem(menuId, itemId);
+ if (!itemEntry)
+ error("Tried to setAttribute() on non-existant menu-item %d:%d", menuId, itemId);
+ switch (attributeId) {
+ case SCI_MENU_ATTRIBUTE_ENABLED:
+ itemEntry->enabled = value.isNull() ? false : true;
+ break;
+ case SCI_MENU_ATTRIBUTE_SAID:
+ itemEntry->said = _segMan->getString(value);
+ itemEntry->saidVmPtr = value;
+ break;
+ case SCI_MENU_ATTRIBUTE_TEXT:
+ itemEntry->text = _segMan->getString(value);
+ itemEntry->textVmPtr = value;
+ break;
+ case SCI_MENU_ATTRIBUTE_KEYPRESS:
+ itemEntry->keyPress = value.offset;
+ itemEntry->keyModifier = 0;
+ // TODO: Find out how modifier is handled
+ printf("setAttr keypress %X %X\n", value.segment, value.offset);
+ break;
+ case SCI_MENU_ATTRIBUTE_TAG:
+ itemEntry->tag = value.offset;
+ break;
+ default:
+ error("setAttribute() called with unsupported attributeId %X", attributeId);
+ }
}
reg_t SciGuiMenu::getAttribute(uint16 menuId, uint16 itemId, uint16 attributeId) {
+ GuiMenuItemEntry *itemEntry = findItem(menuId, itemId);
+ if (!itemEntry)
+ error("Tried to getAttribute() on non-existant menu-item %d:%d", menuId, itemId);
+ switch (attributeId) {
+ case SCI_MENU_ATTRIBUTE_ENABLED:
+ if (itemEntry->enabled)
+ return make_reg(0, 1);
+ break;
+ case SCI_MENU_ATTRIBUTE_SAID:
+ return itemEntry->saidVmPtr;
+ break;
+ case SCI_MENU_ATTRIBUTE_TEXT:
+ return itemEntry->textVmPtr;
+ break;
+ case SCI_MENU_ATTRIBUTE_KEYPRESS:
+ // TODO: Find out how modifier is handled
+ return make_reg(0, itemEntry->keyPress);
+ break;
+ case SCI_MENU_ATTRIBUTE_TAG:
+ return make_reg(0, itemEntry->tag);
+ default:
+ error("setAttribute() called with unsupported attributeId %X", attributeId);
+ }
return NULL_REG;
}
diff --git a/engines/sci/gui/gui_menu.h b/engines/sci/gui/gui_menu.h
index 32fbbbaf9a..c511ea7c95 100644
--- a/engines/sci/gui/gui_menu.h
+++ b/engines/sci/gui/gui_menu.h
@@ -31,7 +31,7 @@ namespace Sci {
enum {
SCI_MENU_ATTRIBUTE_SAID = 0x6d,
SCI_MENU_ATTRIBUTE_TEXT = 0x6e,
- SCI_MENU_ATTRIBUTE_KEY = 0x6f,
+ SCI_MENU_ATTRIBUTE_KEYPRESS = 0x6f,
SCI_MENU_ATTRIBUTE_ENABLED = 0x70,
SCI_MENU_ATTRIBUTE_TAG = 0x71
};
@@ -46,8 +46,8 @@ struct GuiMenuEntry {
uint16 id;
Common::String text;
- GuiMenuEntry(uint16 id_)
- : id(id_) { }
+ GuiMenuEntry(uint16 curId)
+ : id(curId) { }
};
typedef Common::List<GuiMenuEntry *> GuiMenuList;
@@ -60,28 +60,35 @@ struct GuiMenuItemEntry {
uint16 keyModifier;
bool separatorLine;
Common::String said;
+ reg_t saidVmPtr;
Common::String text;
+ reg_t textVmPtr;
Common::String textRightAligned;
- GuiMenuItemEntry(uint16 menuId_, uint16 id_)
- : menuId(menuId_), id(id_),
- enabled(true), tag(0), keyPress(0), keyModifier(0), separatorLine(false) { }
+ GuiMenuItemEntry(uint16 curMenuId, uint16 curId)
+ : menuId(curMenuId), id(curId),
+ enabled(true), tag(0), keyPress(0), keyModifier(0), separatorLine(false) {
+ saidVmPtr = NULL_REG;
+ textVmPtr = NULL_REG;
+ }
};
typedef Common::List<GuiMenuItemEntry *> GuiMenuItemList;
class SciGuiMenu {
public:
- SciGuiMenu(SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen);
+ SciGuiMenu(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text, SciGuiScreen *screen);
~SciGuiMenu();
- void add(Common::String title, Common::String content);
+ void add(Common::String title, Common::String content, reg_t contentVmPtr);
void setAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value);
reg_t getAttribute(uint16 menuId, uint16 itemId, uint16 attributeId);
void drawBar();
private:
+ GuiMenuItemEntry *findItem(uint16 menuId, uint16 itemId);
+ SegManager *_segMan;
SciGuiGfx *_gfx;
SciGuiText *_text;
SciGuiScreen *_screen;