[Scummvm-cvs-logs] SF.net SVN: scummvm:[45671] scummvm/trunk/engines/sci/gui
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Wed Nov 4 17:11:47 CET 2009
Revision: 45671
http://scummvm.svn.sourceforge.net/scummvm/?rev=45671&view=rev
Author: m_kiewitz
Date: 2009-11-04 16:11:44 +0000 (Wed, 04 Nov 2009)
Log Message:
-----------
SCI/newgui: SciGuiMenu - set()/get() implemented
Modified Paths:
--------------
scummvm/trunk/engines/sci/gui/gui.cpp
scummvm/trunk/engines/sci/gui/gui.h
scummvm/trunk/engines/sci/gui/gui_menu.cpp
scummvm/trunk/engines/sci/gui/gui_menu.h
Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp 2009-11-04 15:51:50 UTC (rev 45670)
+++ scummvm/trunk/engines/sci/gui/gui.cpp 2009-11-04 16:11:44 UTC (rev 45671)
@@ -62,7 +62,7 @@
_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::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) {
Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h 2009-11-04 15:51:50 UTC (rev 45670)
+++ scummvm/trunk/engines/sci/gui/gui.h 2009-11-04 16:11:44 UTC (rev 45671)
@@ -81,7 +81,7 @@
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);
Modified: scummvm/trunk/engines/sci/gui/gui_menu.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_menu.cpp 2009-11-04 15:51:50 UTC (rev 45670)
+++ scummvm/trunk/engines/sci/gui/gui_menu.cpp 2009-11-04 16:11:44 UTC (rev 45671)
@@ -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 @@
} 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 @@
} 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;
}
Modified: scummvm/trunk/engines/sci/gui/gui_menu.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_menu.h 2009-11-04 15:51:50 UTC (rev 45670)
+++ scummvm/trunk/engines/sci/gui/gui_menu.h 2009-11-04 16:11:44 UTC (rev 45671)
@@ -31,7 +31,7 @@
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 @@
uint16 id;
Common::String text;
- GuiMenuEntry(uint16 id_)
- : id(id_) { }
+ GuiMenuEntry(uint16 curId)
+ : id(curId) { }
};
typedef Common::List<GuiMenuEntry *> GuiMenuList;
@@ -60,28 +60,35 @@
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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list