[Scummvm-cvs-logs] SF.net SVN: scummvm:[45624] scummvm/trunk/engines/sci/gui
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Nov 3 09:23:02 CET 2009
Revision: 45624
http://scummvm.svn.sourceforge.net/scummvm/?rev=45624&view=rev
Author: thebluegr
Date: 2009-11-03 08:23:02 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
Don't keep a reference to SegManager, as it gets deleted when loading. Fixes a crash when loading games
Modified Paths:
--------------
scummvm/trunk/engines/sci/gui/gui.cpp
scummvm/trunk/engines/sci/gui/gui_controls.cpp
scummvm/trunk/engines/sci/gui/gui_controls.h
Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp 2009-11-03 03:38:28 UTC (rev 45623)
+++ scummvm/trunk/engines/sci/gui/gui.cpp 2009-11-03 08:23:02 UTC (rev 45624)
@@ -61,7 +61,7 @@
_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 @@
switch (controlType) {
case SCI_CONTROLS_TYPE_TEXTEDIT:
// Only process textedit controls in here
- _controls->TexteditChange(controlObject, eventObject);
+ _controls->TexteditChange(_s->_segMan, controlObject, eventObject);
return;
}
}
Modified: scummvm/trunk/engines/sci/gui/gui_controls.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_controls.cpp 2009-11-03 03:38:28 UTC (rev 45623)
+++ scummvm/trunk/engines/sci/gui/gui_controls.cpp 2009-11-03 08:23:02 UTC (rev 45624)
@@ -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 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 @@
_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 @@
_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 @@
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 @@
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 @@
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 @@
}
}
- PUT_SEL32V(_segMan, controlObject, cursor, cursorPos);
+ PUT_SEL32V(segMan, controlObject, cursor, cursorPos);
}
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/gui/gui_controls.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_controls.h 2009-11-03 03:38:28 UTC (rev 45623)
+++ scummvm/trunk/engines/sci/gui/gui_controls.h 2009-11-03 08:23:02 UTC (rev 45624)
@@ -33,19 +33,18 @@
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;
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