ALL: Sync with ScummVM - rev. 87ebc7140c

This commit is contained in:
Bastien Bouclet 2017-09-02 13:27:05 +02:00
parent 0a212398b3
commit 84e62b6c8d
261 changed files with 27464 additions and 13852 deletions

View file

@ -87,6 +87,7 @@ struct WidgetDrawData {
E.g. when taking into account rounded corners, drop shadows, etc
Used when restoring the widget background */
uint16 _backgroundOffset;
uint16 _shadowOffset;
bool _buffer;
@ -271,6 +272,10 @@ void ThemeItemDrawData::drawSelf(bool draw, bool restore) {
Common::Rect extendedRect = _area;
extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset);
if (_data->_shadowOffset > _data->_backgroundOffset) {
extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset;
extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset;
}
if (restore)
_engine->restoreBackground(extendedRect);
@ -288,6 +293,10 @@ void ThemeItemDrawDataClip::drawSelf(bool draw, bool restore) {
Common::Rect extendedRect = _area;
extendedRect.grow(_engine->kDirtyRectangleThreshold + _data->_backgroundOffset);
if (_data->_shadowOffset > _data->_backgroundOffset) {
extendedRect.right += _data->_shadowOffset - _data->_backgroundOffset;
extendedRect.bottom += _data->_shadowOffset - _data->_backgroundOffset;
}
if (restore)
_engine->restoreBackground(extendedRect);
@ -621,6 +630,7 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
_bytesPerPixel = sizeof(uint16);
break;
}
// fall through
default:
error("Invalid graphics mode");
}
@ -646,17 +656,18 @@ void ThemeEngine::setGraphicsMode(GraphicsMode mode) {
}
void WidgetDrawData::calcBackgroundOffset() {
uint maxShadow = 0;
uint maxShadow = 0, maxBevel = 0;
for (Common::List<Graphics::DrawStep>::const_iterator step = _steps.begin();
step != _steps.end(); ++step) {
if ((step->autoWidth || step->autoHeight) && step->shadow > maxShadow)
maxShadow = step->shadow;
if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxShadow)
maxShadow = step->bevel;
if (step->drawingCall == &Graphics::VectorRenderer::drawCallback_BEVELSQ && step->bevel > maxBevel)
maxBevel = step->bevel;
}
_backgroundOffset = maxShadow;
_backgroundOffset = maxBevel;
_shadowOffset = maxShadow;
}
void ThemeEngine::restoreBackground(Common::Rect r) {
@ -722,7 +733,9 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file, const Com
#ifdef USE_TRANSLATION
TransMan.setLanguage("C");
#endif
warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", localized.c_str());
warning("Failed to load localized font '%s'.", localized.c_str());
return false;
}
}
@ -810,7 +823,9 @@ bool ThemeEngine::addAlphaBitmap(const Common::String &filename) {
if (surf)
return true;
#ifdef USE_PNG
const Graphics::TransparentSurface *srcSurface = 0;
#endif
if (filename.hasSuffix(".png")) {
// Maybe it is PNG?
@ -1306,7 +1321,7 @@ void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect
queueDDClip(dd, r2, clippingRect);
r2.left = r2.right + checkBoxSize;
r2.right = r.right;
r2.right = MAX(r2.left, r.right);
queueDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
}
@ -1517,7 +1532,7 @@ void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect
queueDDClip(dd, r, clip);
if (!sel.empty()) {
if (!sel.empty() && r.width() >= 13 && r.height() >= 1) {
Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
queueDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
}
@ -1618,28 +1633,34 @@ void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, co
}
}
void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, int tabHeight, const Common::Array<int> &tabWidths, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
if (!ready())
return;
assert(tabs.size() == tabWidths.size());
queueDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip);
for (int i = 0; i < (int)tabs.size(); ++i) {
if (i == active)
int width = 0;
int activePos = -1;
for (int i = 0; i < (int)tabs.size(); width += tabWidths[i++]) {
if (r.left + width > r.right || r.left + width + tabWidths[i] > r.right)
continue;
if (r.left + i * tabWidth > r.right || r.left + (i + 1) * tabWidth > r.right)
if (i == active) {
activePos = width;
continue;
}
Common::Rect tabRect(r.left + i * tabWidth, r.top, r.left + (i + 1) * tabWidth, r.top + tabHeight);
Common::Rect tabRect(r.left + width, r.top, r.left + width + tabWidths[i], r.top + tabHeight);
queueDDClip(kDDTabInactive, tabRect, clip);
queueDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
}
if (active >= 0 &&
(r.left + active * tabWidth < r.right) && (r.left + (active + 1) * tabWidth < r.right)) {
Common::Rect tabRect(r.left + active * tabWidth, r.top, r.left + (active + 1) * tabWidth, r.top + tabHeight);
const uint16 tabLeft = active * tabWidth;
if (activePos >= 0) {
Common::Rect tabRect(r.left + activePos, r.top, r.left + activePos + tabWidths[active], r.top + tabHeight);
const uint16 tabLeft = activePos;
const uint16 tabRight = MAX(r.right - tabRect.right, 0);
queueDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF));
queueDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
@ -2412,19 +2433,32 @@ Common::String ThemeEngine::getThemeId(const Common::String &filename) {
return "builtin";
Common::FSNode node(filename);
if (!node.exists())
return "builtin";
if (node.exists()) {
if (node.getName().matchString("*.zip", true)) {
Common::String id = node.getName();
if (node.getName().matchString("*.zip", true)) {
Common::String id = node.getName();
for (int i = 0; i < 4; ++i)
id.deleteLastChar();
for (int i = 0; i < 4; ++i)
id.deleteLastChar();
return id;
} else {
return node.getName();
return id;
} else {
return node.getName();
}
}
// FIXME:
// A very ugly hack to map a id to a filename, this will generate
// a complete theme list, thus it is slower than it could be.
// But it is the easiest solution for now.
Common::List<ThemeDescriptor> list;
listUsableThemes(list);
for (Common::List<ThemeDescriptor>::const_iterator i = list.begin(); i != list.end(); ++i) {
if (filename.equalsIgnoreCase(i->filename))
return i->id;
}
return "builtin";
}
void ThemeEngine::showCursor() {