SCI: class menu renamed to GfxMenu - now getting called directly, also fix for loading savedgames

svn-id: r47792
This commit is contained in:
Martin Kiewitz 2010-02-01 09:53:42 +00:00
parent c72c2ff711
commit 845c245ff3
7 changed files with 46 additions and 54 deletions

View file

@ -29,6 +29,7 @@
#include "sci/engine/kernel.h"
#include "sci/graphics/gui.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/menu.h"
namespace Sci {
@ -36,7 +37,7 @@ reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) {
Common::String title = s->strSplit(s->_segMan->getString(argv[0]).c_str());
Common::String content = s->_segMan->getString(argv[1]);
s->_gui->menuAdd(title, content, argv[1]);
s->_gfxMenu->kernelAddEntry(title, content, argv[1]);
return s->r_acc;
}
@ -51,7 +52,7 @@ reg_t kSetMenu(EngineState *s, int argc, reg_t *argv) {
attributeId = argv[argPos].toUint16();
if ((argPos + 1) >= argc)
error("Too few parameters for kSetMenu");
s->_gui->menuSet(menuId, itemId, attributeId, argv[argPos + 1]);
s->_gfxMenu->kernelSetAttribute(menuId, itemId, attributeId, argv[argPos + 1]);
argPos += 2;
}
return s->r_acc;
@ -62,7 +63,7 @@ reg_t kGetMenu(EngineState *s, int argc, reg_t *argv) {
uint16 itemId = argv[0].toUint16() & 0xFF;
uint16 attributeId = argv[1].toUint16();
return s->_gui->menuGet(menuId, itemId, attributeId);
return s->_gfxMenu->kernelGetAttribute(menuId, itemId, attributeId);
}
@ -93,7 +94,7 @@ reg_t kMenuSelect(EngineState *s, int argc, reg_t *argv) {
//bool pauseSound = argc > 1 ? (argv[1].isNull() ? false : true) : false;
// TODO: pauseSound implementation
return s->_gui->menuSelect(eventObject);
return s->_gfxMenu->kernelSelect(eventObject);
}
} // End of namespace Sci

View file

@ -944,6 +944,14 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
retval = new EngineState(s->resMan, s->_kernel, s->_voc, s->_segMan, s->_gui, s->_audio);
retval->_event = new SciEvent();
retval->_gfxAnimate = s->_gfxAnimate;
retval->_gfxCache = s->_gfxCache;
retval->_gfxControls = s->_gfxControls;
retval->_gfxMenu = s->_gfxMenu;
retval->_gfxPalette = s->_gfxPalette;
retval->_gfxPorts = s->_gfxPorts;
retval->_gfxScreen = s->_gfxScreen;
#ifdef ENABLE_SCI32
// Copy the Gui32 pointer over to the new EngineState, if it exists
retval->_gui32 = s->_gui32;

View file

@ -50,10 +50,10 @@ namespace Common {
namespace Sci {
class SciEvent;
class Menubar;
class GfxAnimate;
class GfxCache;
class GfxControls;
class GfxMenu;
class GfxPalette;
class GfxPorts;
class GfxScreen;
@ -160,6 +160,7 @@ public:
GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
GfxCache *_gfxCache;
GfxControls *_gfxControls; // Controls for 16-bit gfx
GfxMenu *_gfxMenu; // Menu for 16-bit gfx
GfxPalette *_gfxPalette;
GfxPorts *_gfxPorts; // Port managment for 16-bit gfx
GfxScreen *_gfxScreen;

View file

@ -61,7 +61,8 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
_text16 = new GfxText16(_s->resMan, _cache, _ports, _paint16, _screen);
_controls = new GfxControls(_s->_segMan, _ports, _paint16, _text16, _screen);
_s->_gfxControls = _controls;
_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
_menu = new GfxMenu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
_s->_gfxMenu = _menu;
}
SciGui::~SciGui() {
@ -277,23 +278,8 @@ void SciGui::drawMenuBar(bool clear) {
void SciGui::menuReset() {
delete _menu;
_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
}
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) {
_menu->setAttribute(menuId, itemId, attributeId, value);
}
reg_t SciGui::menuGet(uint16 menuId, uint16 itemId, uint16 attributeId) {
return _menu->getAttribute(menuId, itemId, attributeId);
}
reg_t SciGui::menuSelect(reg_t eventObject) {
return _menu->select(eventObject);
_menu = new GfxMenu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
_s->_gfxMenu = _menu;
}
void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {

View file

@ -50,7 +50,7 @@ class GfxPorts;
class GfxPaint16;
class GfxAnimate;
class GfxControls;
class Menu;
class GfxMenu;
class GfxText16;
class Transitions;
@ -76,10 +76,6 @@ public:
virtual void drawStatus(const char *text, int16 colorPen, int16 colorBack);
virtual void drawMenuBar(bool clear);
virtual void menuReset();
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);
virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
virtual void drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo, bool hiresMode = false, reg_t upscaledHiresHandle = NULL_REG);
@ -149,7 +145,7 @@ private:
AudioPlayer *_audio;
GfxAnimate *_animate;
GfxControls *_controls;
Menu *_menu;
GfxMenu *_menu;
GfxText16 *_text16;
Transitions *_transitions;
int16 _palVaryId;

View file

@ -43,7 +43,7 @@
namespace Sci {
Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor)
GfxMenu::GfxMenu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor)
: _event(event), _segMan(segMan), _gui(gui), _ports(ports), _paint16(paint16), _text16(text16), _screen(screen), _cursor(cursor) {
_listCount = 0;
@ -57,11 +57,11 @@ Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, Gf
_oldPort = NULL;
}
Menu::~Menu() {
GfxMenu::~GfxMenu() {
// TODO: deallocate _list and _itemList
}
void Menu::add(Common::String title, Common::String content, reg_t contentVmPtr) {
void GfxMenu::kernelAddEntry(Common::String title, Common::String content, reg_t contentVmPtr) {
GuiMenuEntry *menuEntry;
uint16 itemCount = 0;
GuiMenuItemEntry *itemEntry;
@ -225,7 +225,7 @@ void Menu::add(Common::String title, Common::String content, reg_t contentVmPtr)
} while (curPos < contentSize);
}
GuiMenuItemEntry *Menu::findItem(uint16 menuId, uint16 itemId) {
GuiMenuItemEntry *GfxMenu::findItem(uint16 menuId, uint16 itemId) {
GuiMenuItemList::iterator listIterator;
GuiMenuItemList::iterator listEnd = _itemList.end();
GuiMenuItemEntry *listEntry;
@ -241,7 +241,7 @@ GuiMenuItemEntry *Menu::findItem(uint16 menuId, uint16 itemId) {
return NULL;
}
void Menu::setAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value) {
void GfxMenu::kernelSetAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value) {
EngineState *s = ((SciEngine *)g_engine)->getEngineState(); // HACK: needed for strSplit()
GuiMenuItemEntry *itemEntry = findItem(menuId, itemId);
if (!itemEntry)
@ -273,7 +273,7 @@ void Menu::setAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t
}
}
reg_t Menu::getAttribute(uint16 menuId, uint16 itemId, uint16 attributeId) {
reg_t GfxMenu::kernelGetAttribute(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);
@ -297,7 +297,7 @@ reg_t Menu::getAttribute(uint16 menuId, uint16 itemId, uint16 attributeId) {
return NULL_REG;
}
void Menu::drawBar() {
void GfxMenu::drawBar() {
GuiMenuEntry *listEntry;
GuiMenuList::iterator listIterator;
GuiMenuList::iterator listEnd = _list.end();
@ -318,7 +318,7 @@ void Menu::drawBar() {
}
// This helper calculates all text widths for all menus/items
void Menu::calculateTextWidth() {
void GfxMenu::calculateTextWidth() {
GuiMenuList::iterator menuIterator;
GuiMenuList::iterator menuEnd = _list.end();
GuiMenuEntry *menuEntry;
@ -345,7 +345,7 @@ void Menu::calculateTextWidth() {
}
}
reg_t Menu::select(reg_t eventObject) {
reg_t GfxMenu::kernelSelect(reg_t eventObject) {
int16 eventType = GET_SEL32V(_segMan, eventObject, type);
int16 keyPress, keyModifier;
Common::Point mousePosition;
@ -434,7 +434,7 @@ reg_t Menu::select(reg_t eventObject) {
return NULL_REG;
}
GuiMenuItemEntry *Menu::interactiveGetItem(uint16 menuId, uint16 itemId, bool menuChanged) {
GuiMenuItemEntry *GfxMenu::interactiveGetItem(uint16 menuId, uint16 itemId, bool menuChanged) {
GuiMenuItemList::iterator itemIterator = _itemList.begin();
GuiMenuItemList::iterator itemEnd = _itemList.end();
GuiMenuItemEntry *itemEntry;
@ -463,7 +463,7 @@ GuiMenuItemEntry *Menu::interactiveGetItem(uint16 menuId, uint16 itemId, bool me
return firstItemEntry;
}
void Menu::drawMenu(uint16 oldMenuId, uint16 newMenuId) {
void GfxMenu::drawMenu(uint16 oldMenuId, uint16 newMenuId) {
GuiMenuEntry *listEntry;
GuiMenuList::iterator listIterator;
GuiMenuList::iterator listEnd = _list.end();
@ -569,7 +569,7 @@ void Menu::drawMenu(uint16 oldMenuId, uint16 newMenuId) {
_paint16->bitsShow(_menuRect);
}
void Menu::invertMenuSelection(uint16 itemId) {
void GfxMenu::invertMenuSelection(uint16 itemId) {
Common::Rect itemRect = _menuRect;
if (itemId == 0)
@ -583,17 +583,17 @@ void Menu::invertMenuSelection(uint16 itemId) {
_paint16->bitsShow(itemRect);
}
void Menu::interactiveShowMouse() {
void GfxMenu::interactiveShowMouse() {
_mouseOldState = _cursor->isVisible();
_cursor->show();
}
void Menu::interactiveRestoreMouse() {
void GfxMenu::interactiveRestoreMouse() {
if (!_mouseOldState)
_cursor->hide();
}
uint16 Menu::mouseFindMenuSelection(Common::Point mousePosition) {
uint16 GfxMenu::mouseFindMenuSelection(Common::Point mousePosition) {
GuiMenuEntry *listEntry;
GuiMenuList::iterator listIterator;
GuiMenuList::iterator listEnd = _list.end();
@ -611,7 +611,7 @@ uint16 Menu::mouseFindMenuSelection(Common::Point mousePosition) {
return 0;
}
uint16 Menu::mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menuId) {
uint16 GfxMenu::mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menuId) {
GuiMenuItemEntry *listItemEntry;
GuiMenuItemList::iterator listItemIterator;
GuiMenuItemList::iterator listItemEnd = _itemList.end();
@ -639,7 +639,7 @@ uint16 Menu::mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menu
return itemId;
}
GuiMenuItemEntry *Menu::interactiveWithKeyboard() {
GuiMenuItemEntry *GfxMenu::interactiveWithKeyboard() {
sciEvent curEvent;
uint16 newMenuId = _curMenuId;
uint16 newItemId = _curItemId;
@ -763,7 +763,7 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() {
// Mouse button is currently pressed - we are now interpreting mouse coordinates till mouse button is released
// The menu item that is selected at that time is chosen. If no menu item is selected we cancel
// No keyboard interaction is allowed, cause that wouldnt make any sense at all
GuiMenuItemEntry *Menu::interactiveWithMouse() {
GuiMenuItemEntry *GfxMenu::interactiveWithMouse() {
sciEvent curEvent;
uint16 newMenuId = 0, newItemId = 0;
uint16 curMenuId = 0, curItemId = 0;

View file

@ -76,18 +76,18 @@ struct GuiMenuItemEntry {
};
typedef Common::List<GuiMenuItemEntry *> GuiMenuItemList;
class Menu {
class GfxMenu {
public:
Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor);
~Menu();
GfxMenu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor);
~GfxMenu();
void reset();
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 kernelAddEntry(Common::String title, Common::String content, reg_t contentVmPtr);
void kernelSetAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value);
reg_t kernelGetAttribute(uint16 menuId, uint16 itemId, uint16 attributeId);
void drawBar();
reg_t select(reg_t eventObject);
reg_t kernelSelect(reg_t eventObject);
private:
GuiMenuItemEntry *findItem(uint16 menuId, uint16 itemId);