diff options
author | Filippos Karapetis | 2009-11-03 08:23:02 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-11-03 08:23:02 +0000 |
commit | bf8f8acb47381dacb168243589df56b2832df434 (patch) | |
tree | 7ae1ae28051c68a3363696ddbb44cf26b86fb7b1 /engines/sci | |
parent | 0d5627d8f11db377ee3c32d684ddc0f19f57fa95 (diff) | |
download | scummvm-rg350-bf8f8acb47381dacb168243589df56b2832df434.tar.gz scummvm-rg350-bf8f8acb47381dacb168243589df56b2832df434.tar.bz2 scummvm-rg350-bf8f8acb47381dacb168243589df56b2832df434.zip |
Don't keep a reference to SegManager, as it gets deleted when loading. Fixes a crash when loading games
svn-id: r45624
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gui/gui.cpp | 4 | ||||
-rw-r--r-- | engines/sci/gui/gui_controls.cpp | 31 | ||||
-rw-r--r-- | engines/sci/gui/gui_controls.h | 7 |
3 files changed, 20 insertions, 22 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index ccfaecd960..be95107469 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -61,7 +61,7 @@ SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette, _animate = new SciGuiAnimate(_s, _gfx, _screen, _palette); _text = new SciGuiText(_s->resMan, _gfx, _screen); _windowMgr = new SciGuiWindowMgr(this, _screen, _gfx, _text); - _controls = new SciGuiControls(_s->_segMan, _gfx, _text); + _controls = new SciGuiControls(_gfx, _text); _menu = new SciGuiMenu(_gfx, _text, _screen); // _gui32 = new SciGui32(_s, _screen, _palette, _cursor); // for debug purposes } @@ -438,7 +438,7 @@ void SciGui::editControl(reg_t controlObject, reg_t eventObject) { switch (controlType) { case SCI_CONTROLS_TYPE_TEXTEDIT: // Only process textedit controls in here - _controls->TexteditChange(controlObject, eventObject); + _controls->TexteditChange(_s->_segMan, controlObject, eventObject); return; } } diff --git a/engines/sci/gui/gui_controls.cpp b/engines/sci/gui/gui_controls.cpp index 906cbc1257..f9239f9573 100644 --- a/engines/sci/gui/gui_controls.cpp +++ b/engines/sci/gui/gui_controls.cpp @@ -36,8 +36,8 @@ namespace Sci { -SciGuiControls::SciGuiControls(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text) - : _segMan(segMan), _gfx(gfx), _text(text) { +SciGuiControls::SciGuiControls(SciGuiGfx *gfx, SciGuiText *text) + : _gfx(gfx), _text(text) { init(); } @@ -52,7 +52,6 @@ const char controlListUpArrow[2] = { 0x18, 0 }; const char controlListDownArrow[2] = { 0x19, 0 }; void SciGuiControls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias) { - //SegManager *segMan = _s->_segMan; Common::Rect workerRect = rect; GuiResourceId oldFontId = _text->GetFontId(); int16 oldPenColor = _gfx->_curPort->penClr; @@ -107,7 +106,7 @@ void SciGuiControls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChar _text->SetFont(oldFontId); } -void SciGuiControls::TexteditCursorDraw (Common::Rect rect, const char *text, uint16 curPos) { +void SciGuiControls::TexteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos) { int16 textWidth, i; if (!_texteditCursorVisible) { textWidth = 0; @@ -138,10 +137,10 @@ void SciGuiControls::TexteditSetBlinkTime() { _texteditBlinkTime = g_system->getMillis() + (30 * 1000 / 60); } -void SciGuiControls::TexteditChange(reg_t controlObject, reg_t eventObject) { - uint16 cursorPos = GET_SEL32V(_segMan, controlObject, cursor); - uint16 maxChars = GET_SEL32V(_segMan, controlObject, max); - reg_t textReference = GET_SEL32(_segMan, controlObject, text); +void SciGuiControls::TexteditChange(SegManager *segMan, reg_t controlObject, reg_t eventObject) { + uint16 cursorPos = GET_SEL32V(segMan, controlObject, cursor); + uint16 maxChars = GET_SEL32V(segMan, controlObject, max); + reg_t textReference = GET_SEL32(segMan, controlObject, text); Common::String text; uint16 textSize, eventType, eventKey; bool textChanged = false; @@ -149,18 +148,18 @@ void SciGuiControls::TexteditChange(reg_t controlObject, reg_t eventObject) { if (textReference.isNull()) error("kEditControl called on object that doesnt have a text reference"); - text = _segMan->getString(textReference); + text = segMan->getString(textReference); if (!eventObject.isNull()) { textSize = text.size(); - eventType = GET_SEL32V(_segMan, eventObject, type); + eventType = GET_SEL32V(segMan, eventObject, type); switch (eventType) { case SCI_EVT_MOUSE_PRESS: // TODO: Implement mouse support for cursor change break; case SCI_EVT_KEYBOARD: - eventKey = GET_SEL32V(_segMan, eventObject, message); + eventKey = GET_SEL32V(segMan, eventObject, message); switch (eventKey) { case SCI_K_BACKSPACE: if (cursorPos > 0) { @@ -204,9 +203,9 @@ void SciGuiControls::TexteditChange(reg_t controlObject, reg_t eventObject) { if (textChanged) { GuiResourceId oldFontId = _text->GetFontId(); - GuiResourceId fontId = GET_SEL32V(_segMan, controlObject, font); - rect = Common::Rect(GET_SEL32V(_segMan, controlObject, nsLeft), GET_SEL32V(_segMan, controlObject, nsTop), - GET_SEL32V(_segMan, controlObject, nsRight), GET_SEL32V(_segMan, controlObject, nsBottom)); + GuiResourceId fontId = GET_SEL32V(segMan, controlObject, font); + rect = Common::Rect(GET_SEL32V(segMan, controlObject, nsLeft), GET_SEL32V(segMan, controlObject, nsTop), + GET_SEL32V(segMan, controlObject, nsRight), GET_SEL32V(segMan, controlObject, nsBottom)); TexteditCursorErase(); _gfx->EraseRect(rect); _text->Box(text.c_str(), 0, rect, SCI_TEXT_ALIGNMENT_LEFT, fontId); @@ -215,7 +214,7 @@ void SciGuiControls::TexteditChange(reg_t controlObject, reg_t eventObject) { TexteditCursorDraw(rect, text.c_str(), cursorPos); _text->SetFont(oldFontId); // Write back string - _segMan->strcpy(textReference, text.c_str()); + segMan->strcpy(textReference, text.c_str()); } else { if (g_system->getMillis() >= _texteditBlinkTime) { _gfx->InvertRect(_texteditCursorRect); @@ -225,7 +224,7 @@ void SciGuiControls::TexteditChange(reg_t controlObject, reg_t eventObject) { } } - PUT_SEL32V(_segMan, controlObject, cursor, cursorPos); + PUT_SEL32V(segMan, controlObject, cursor, cursorPos); } } // End of namespace Sci diff --git a/engines/sci/gui/gui_controls.h b/engines/sci/gui/gui_controls.h index 95e4a0e34f..33b2e54989 100644 --- a/engines/sci/gui/gui_controls.h +++ b/engines/sci/gui/gui_controls.h @@ -33,19 +33,18 @@ class SciGuiFont; class SciGuiText; class SciGuiControls { public: - SciGuiControls(SegManager *segMan, SciGuiGfx *gfx, SciGuiText *text); + SciGuiControls(SciGuiGfx *gfx, SciGuiText *text); ~SciGuiControls(); void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias); - void TexteditCursorDraw (Common::Rect rect, const char *text, uint16 curPos); + void TexteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos); void TexteditCursorErase(); - void TexteditChange(reg_t controlObject, reg_t eventObject); + void TexteditChange(SegManager *segMan, reg_t controlObject, reg_t eventObject); private: void init(); void TexteditSetBlinkTime(); - SegManager *_segMan; SciGuiGfx *_gfx; SciGuiText *_text; |