[Scummvm-git-logs] scummvm master -> 8e8f640e6932a9afab733ada6676e78b811fe08d
ysj1173886760
42030331+ysj1173886760 at users.noreply.github.com
Wed Aug 18 12:19:44 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8e8f640e69 DIRECTOR: fix editableText both in D2/3 and in D4.
Commit: 8e8f640e6932a9afab733ada6676e78b811fe08d
https://github.com/scummvm/scummvm/commit/8e8f640e6932a9afab733ada6676e78b811fe08d
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-08-18T20:19:18+08:00
Commit Message:
DIRECTOR: fix editableText both in D2/3 and in D4.
Changed paths:
engines/director/castmember.cpp
engines/director/castmember.h
engines/director/channel.cpp
engines/director/sprite.cpp
engines/director/sprite.h
diff --git a/engines/director/castmember.cpp b/engines/director/castmember.cpp
index b04ff19e46..bb4259565b 100644
--- a/engines/director/castmember.cpp
+++ b/engines/director/castmember.cpp
@@ -33,6 +33,7 @@
#include "director/sound.h"
#include "director/window.h"
#include "director/stxt.h"
+#include "director/sprite.h"
namespace Director {
@@ -780,11 +781,11 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
}
widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), _lineSpacing, _borderSize, _gutterSize, _boxShadow, _textShadow, _textType == kTextTypeFixed);
((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
- ((Graphics::MacText *)widget)->setEditable(_editable);
+ ((Graphics::MacText *)widget)->setEditable(channel->_sprite->_editable);
((Graphics::MacText *)widget)->draw();
// since we disable the ability of setActive in setEdtiable, then we need to set active widget manually
- if (_editable) {
+ if (channel->_sprite->_editable) {
Graphics::MacWidget *activeWidget = g_director->_wm->getActiveWidget();
if (activeWidget == nullptr || !activeWidget->isEditable())
g_director->_wm->setActiveWidget(widget);
@@ -871,17 +872,6 @@ void TextCastMember::setTextSize(int textSize) {
}
}
-bool TextCastMember::isEditable() {
- return _editable;
-}
-
-void TextCastMember::setEditable(bool editable) {
- _editable = editable;
- // if we are linking to the widget, then we can modify it directly.
- if (_widget)
- ((Graphics::MacText *)_widget)->setEditable(editable);
-}
-
void TextCastMember::updateFromWidget(Graphics::MacWidget *widget) {
if (widget && _type == kCastText) {
_ptext = ((Graphics::MacText *)widget)->getEditedString();
diff --git a/engines/director/castmember.h b/engines/director/castmember.h
index aae0c20e39..d76960ef6b 100644
--- a/engines/director/castmember.h
+++ b/engines/director/castmember.h
@@ -224,8 +224,8 @@ public:
void setText(const Common::U32String &text);
virtual Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) override;
- virtual bool isEditable() override;
- virtual void setEditable(bool editable) override;
+ virtual bool isEditable() override { return _editable; }
+ virtual void setEditable(bool editable) override { _editable = editable; }
virtual void updateFromWidget(Graphics::MacWidget *widget) override;
Graphics::TextAlign getAlignment();
diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index a5098cb2fb..07acf6afb2 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -59,7 +59,7 @@ Channel::Channel(Sprite *sp, int priority) {
_visible = true;
_dirty = true;
- _sprite->updateCast();
+ _sprite->updateEditable();
}
Channel::~Channel() {
@@ -357,7 +357,7 @@ void Channel::setClean(Sprite *nextSprite, int spriteId, bool partial) {
// for the dirty puppet sprites, we will always replaceWidget since previousCastId is 0, but we shouldn't replace the widget of there are only position changing
// e.g. we won't want a puppet editable text sprite changing because that will cause the loss of text.
if (replace) {
- _sprite->updateCast();
+ _sprite->updateEditable();
replaceWidget(previousCastId, dimsChanged || spriteTypeChanged);
}
@@ -376,6 +376,8 @@ void Channel::setClean(Sprite *nextSprite, int spriteId, bool partial) {
void Channel::updateTextCast() {
if (!_sprite->_cast || _sprite->_cast->_type != kCastText)
return;
+
+ _sprite->updateEditable();
setEditable(_sprite->_editable);
if (_widget) {
@@ -394,9 +396,6 @@ void Channel::updateTextCast() {
void Channel::setEditable(bool editable) {
if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
// if the sprite is editable, then we refresh the selEnd and setStart
- if (_sprite->_cast->isEditable() != editable)
- _sprite->_cast->setEditable(editable);
-
if (_widget) {
((Graphics::MacText *)_widget)->setEditable(editable);
// we only set the first editable text member in score active
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 4289740f6e..d5bd078d6d 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -148,13 +148,12 @@ Graphics::Surface *Sprite::getQDMatte() {
return _matte ? _matte->getMask() : nullptr;
}
-
-void Sprite::updateCast() {
+void Sprite::updateEditable() {
if (!_cast)
return;
- if (_cast->isEditable() != _editable && !_puppet)
- _cast->setEditable(_editable);
+ if (!_puppet)
+ _editable = _editable || _cast->isEditable();
}
bool Sprite::respondsToMouse() {
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index de51b0f450..26ea5a14a1 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -65,7 +65,7 @@ public:
Frame *getFrame() const { return _frame; }
Score *getScore() const { return _score; }
- void updateCast();
+ void updateEditable();
bool respondsToMouse();
bool isActive();
More information about the Scummvm-git-logs
mailing list