DIRECTOR: Force editable text boxes to be rendered in front

Editable text boxes don't seem to abide by the channel rendering order;
you can have a bitmap in a higher channel that entirely obscures a text
entry widget, and the widget will still be visible.

Fixes the visibility of the name entry text box in Cosmology of Kyoto.
This commit is contained in:
Scott Percival 2024-01-14 14:37:01 +08:00 committed by Eugene Sandulenko
parent d25b385651
commit a8fe30029d
3 changed files with 24 additions and 3 deletions

View File

@ -470,6 +470,15 @@ void Channel::updateTextCast() {
}
}
bool Channel::getEditable() {
if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
if (_widget && (Graphics::MacText *)_widget->isEditable()) {
return true;
}
}
return false;
}
void Channel::setEditable(bool editable) {
if (_sprite->_cast && _sprite->_cast->_type == kCastText) {
// if the sprite is editable, then we refresh the selEnd and setStart

View File

@ -63,6 +63,7 @@ public:
void setPosition(int x, int y, bool force = false);
void setCast(CastMemberID memberID);
void setClean(Sprite *nextSprite, int spriteId, bool partial = false);
bool getEditable();
void setEditable(bool editable);
void replaceSprite(Sprite *nextSprite);
void replaceWidget(CastMemberID previousCastId = CastMemberID(0, 0), bool force = false);

View File

@ -1325,11 +1325,22 @@ bool Score::checkSpriteIntersection(uint16 spriteId, Common::Point pos) {
}
Common::List<Channel *> Score::getSpriteIntersections(const Common::Rect &r) {
Common::List<Channel *>intersections;
Common::List<Channel *> intersections;
Common::List<Channel *> appendix;
for (uint i = 0; i < _channels.size(); i++) {
if (!_channels[i]->isEmpty() && !r.findIntersectingRect(_channels[i]->getBbox()).isEmpty())
intersections.push_back(_channels[i]);
if (!_channels[i]->isEmpty() && !r.findIntersectingRect(_channels[i]->getBbox()).isEmpty()) {
// Editable text sprites will (more or less) always be rendered in front of other sprites,
// regardless of their order in the channel list.
if (_channels[i]->getEditable()) {
appendix.push_back(_channels[i]);
} else {
intersections.push_back(_channels[i]);
}
}
}
for (auto &ch : appendix) {
intersections.push_back(ch);
}
return intersections;