aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/EventRecorder.cpp4
-rw-r--r--gui/ThemeEngine.cpp498
-rw-r--r--gui/ThemeEngine.h110
-rw-r--r--gui/Tooltip.cpp3
-rw-r--r--gui/Tooltip.h14
-rw-r--r--gui/about.cpp4
-rw-r--r--gui/about.h14
-rw-r--r--gui/console.cpp55
-rw-r--r--gui/console.h55
-rw-r--r--gui/credits.h7
-rw-r--r--gui/debugger.cpp8
-rw-r--r--gui/dialog.cpp2
-rw-r--r--gui/editgamedialog.cpp20
-rw-r--r--gui/editgamedialog.h4
-rw-r--r--gui/launcher.cpp72
-rw-r--r--gui/launcher.h2
-rw-r--r--gui/massadd.cpp50
-rw-r--r--gui/massadd.h5
-rw-r--r--gui/module.mk1
-rw-r--r--gui/object.cpp4
-rw-r--r--gui/object.h5
-rw-r--r--gui/options.h6
-rw-r--r--gui/predictivedialog.cpp6
-rw-r--r--gui/recorderdialog.cpp4
-rw-r--r--gui/themes/translations.datbin746444 -> 750409 bytes
-rw-r--r--gui/unknown-game-dialog.cpp220
-rw-r--r--gui/unknown-game-dialog.h59
-rw-r--r--gui/widget.cpp180
-rw-r--r--gui/widget.h8
-rw-r--r--gui/widgets/editable.cpp15
-rw-r--r--gui/widgets/edittext.cpp8
-rw-r--r--gui/widgets/list.cpp17
-rw-r--r--gui/widgets/popup.cpp19
-rw-r--r--gui/widgets/scrollbar.cpp6
-rw-r--r--gui/widgets/scrollcontainer.cpp8
-rw-r--r--gui/widgets/scrollcontainer.h2
-rw-r--r--gui/widgets/tab.cpp9
-rw-r--r--gui/widgets/tab.h18
38 files changed, 640 insertions, 882 deletions
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 849405410a..560df0ec35 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -600,13 +600,13 @@ void EventRecorder::setFileHeader() {
return;
}
TimeDate t;
- GameDescriptor desc = EngineMan.findGame(ConfMan.getActiveDomainName());
+ PlainGameDescriptor desc = EngineMan.findGame(ConfMan.getActiveDomainName());
g_system->getTimeAndDate(t);
if (_author.empty()) {
setAuthor("Unknown Author");
}
if (_name.empty()) {
- g_eventRec.setName(Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description());
+ g_eventRec.setName(Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description);
}
_playbackFile->getHeader().author = _author;
_playbackFile->getHeader().notes = _desc;
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index b16a6cfe4f..2dc4c063ab 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -211,8 +211,6 @@ ThemeEngine::ThemeEngine(Common::String id, GraphicsMode mode) :
_cursorWidth = _cursorHeight = 0;
_cursorPalSize = 0;
- _needPaletteUpdates = false;
-
// We prefer files in archive bundles over the common search paths.
_themeFiles.add("default", &SearchMan, 0, false);
}
@@ -853,38 +851,9 @@ void ThemeEngine::drawDD(DrawData type, const Common::Rect &r, uint32 dynamic, b
extendedRect.bottom += drawData->_shadowOffset - drawData->_backgroundOffset;
}
- if (forceRestore || drawData->_layer == kDrawLayerBackground)
- restoreBackground(extendedRect);
-
- if (drawData->_layer == _layerToDraw) {
- Common::List<Graphics::DrawStep>::const_iterator step;
- for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step)
- _vectorRenderer->drawStep(area, *step, dynamic);
-
- addDirtyRect(extendedRect);
- }
-}
-
-void ThemeEngine::drawDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic,
- bool forceRestore) {
- WidgetDrawData *drawData = _widgets[type];
-
- if (!drawData)
- return;
-
- if (kDrawDataDefaults[type].parent != kDDNone && kDrawDataDefaults[type].parent != type)
- drawDDClip(kDrawDataDefaults[type].parent, r, clippingRect);
-
- Common::Rect area = r;
- area.clip(_screen.w, _screen.h);
-
- Common::Rect extendedRect = area;
- extendedRect.grow(kDirtyRectangleThreshold + drawData->_backgroundOffset);
- if (drawData->_shadowOffset > drawData->_backgroundOffset) {
- extendedRect.right += drawData->_shadowOffset - drawData->_backgroundOffset;
- extendedRect.bottom += drawData->_shadowOffset - drawData->_backgroundOffset;
+ if (!_clip.isEmpty()) {
+ extendedRect.clip(_clip);
}
- extendedRect.clip(clippingRect);
if (forceRestore || drawData->_layer == kDrawLayerBackground)
restoreBackground(extendedRect);
@@ -892,7 +861,7 @@ void ThemeEngine::drawDDClip(DrawData type, const Common::Rect &r, const Common:
if (drawData->_layer == _layerToDraw) {
Common::List<Graphics::DrawStep>::const_iterator step;
for (step = drawData->_steps.begin(); step != drawData->_steps.end(); ++step) {
- _vectorRenderer->drawStepClip(area, clippingRect, *step, dynamic);
+ _vectorRenderer->drawStepClip(area, _clip, *step, dynamic);
}
addDirtyRect(extendedRect);
@@ -913,31 +882,9 @@ void ThemeEngine::drawDDText(TextData type, TextColor color, const Common::Rect
if (dirty.isEmpty()) dirty = area;
else dirty.clip(area);
- if (restoreBg)
- restoreBackground(dirty);
-
- _vectorRenderer->setFgColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
- _vectorRenderer->drawString(_texts[type]->_fontPtr, text, area, alignH, alignV, deltax, ellipsis, drawableTextArea);
-
- addDirtyRect(dirty);
-}
-
-void ThemeEngine::drawDDTextClip(TextData type, TextColor color, const Common::Rect &r,
- const Common::Rect &clippingArea, const Common::String &text, bool restoreBg,
- bool ellipsis, Graphics::TextAlign alignH, TextAlignVertical alignV, int deltax,
- const Common::Rect &drawableTextArea) {
-
- if (type == kTextDataNone || !_texts[type] || _layerToDraw == kDrawLayerBackground)
- return;
-
- Common::Rect area = r;
- area.clip(_screen.w, _screen.h);
-
- Common::Rect dirty = drawableTextArea;
- if (dirty.isEmpty()) dirty = area;
- else dirty.clip(area);
-
- dirty.clip(clippingArea);
+ if (!_clip.isEmpty()) {
+ dirty.clip(_clip);
+ }
// HACK: One small pixel should be invisible enough
if (dirty.isEmpty()) dirty = Common::Rect(0, 0, 1, 1);
@@ -959,39 +906,12 @@ void ThemeEngine::drawBitmap(const Graphics::Surface *bitmap, const Common::Rect
area.clip(_screen.w, _screen.h);
if (alpha)
- _vectorRenderer->blitKeyBitmap(bitmap, r);
- else
- _vectorRenderer->blitSubSurface(bitmap, r);
-
- addDirtyRect(r);
-}
-
-void ThemeEngine::drawABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha) {
- if (_layerToDraw == kDrawLayerBackground)
- return;
-
- Common::Rect area = r;
- area.clip(_screen.w, _screen.h);
-
- _vectorRenderer->blitAlphaBitmap(bitmap, area, autoscale, Graphics::DrawStep::kVectorAlignManual, Graphics::DrawStep::kVectorAlignManual, alpha);
-
- addDirtyRect(area);
-}
-
-void ThemeEngine::drawBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &r, const Common::Rect &clip, bool alpha) {
- if (_layerToDraw == kDrawLayerBackground)
- return;
-
- Common::Rect area = r;
- area.clip(_screen.w, _screen.h);
-
- if (alpha)
- _vectorRenderer->blitKeyBitmapClip(bitmap, area, clip);
+ _vectorRenderer->blitKeyBitmapClip(bitmap, area, _clip);
else
- _vectorRenderer->blitSubSurfaceClip(bitmap, area, clip);
+ _vectorRenderer->blitSubSurfaceClip(bitmap, area, _clip);
Common::Rect dirtyRect = area;
- dirtyRect.clip(clip);
+ dirtyRect.clip(_clip);
addDirtyRect(dirtyRect);
}
@@ -1014,42 +934,17 @@ void ThemeEngine::drawButton(const Common::Rect &r, const Common::String &str, W
dd = kDDButtonPressed;
drawDD(dd, r, 0, hints & WIDGET_CLEARBG);
- drawDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
-}
-
-void ThemeEngine::drawButtonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, WidgetStateInfo state, uint16 hints) {
- if (!ready())
- return;
-
- DrawData dd = kDDButtonIdle;
-
- if (state == kStateEnabled)
- dd = kDDButtonIdle;
- else if (state == kStateHighlight)
- dd = kDDButtonHover;
- else if (state == kStateDisabled)
- dd = kDDButtonDisabled;
- else if (state == kStatePressed)
- dd = kDDButtonPressed;
-
- drawDDClip(dd, r, clippingRect, 0, hints & WIDGET_CLEARBG);
- drawDDTextClip(getTextData(dd), getTextColor(dd), r, clippingRect, str, false, true, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDText(getTextData(dd), getTextColor(dd), r, str, false, true, _widgets[dd]->_textAlignH,
+ _widgets[dd]->_textAlignV);
}
-void ThemeEngine::drawLineSeparator(const Common::Rect &r, WidgetStateInfo state) {
+void ThemeEngine::drawLineSeparator(const Common::Rect &r) {
if (!ready())
return;
drawDD(kDDSeparator, r);
}
-void ThemeEngine::drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingRect, WidgetStateInfo state) {
- if (!ready())
- return;
-
- drawDDClip(kDDSeparator, r, clippingRect);
-}
-
void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
if (!ready())
return;
@@ -1073,33 +968,8 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str,
r2.left = r2.right + checkBoxSize;
r2.right = r.right;
- drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
-}
-
-void ThemeEngine::drawCheckboxClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &str, bool checked, WidgetStateInfo state) {
- if (!ready())
- return;
-
- Common::Rect r2 = r;
- DrawData dd = kDDCheckboxDefault;
-
- if (checked)
- dd = kDDCheckboxSelected;
-
- if (state == kStateDisabled)
- dd = kDDCheckboxDisabled;
-
- const int checkBoxSize = MIN((int)r.height(), getFontHeight());
-
- r2.bottom = r2.top + checkBoxSize;
- r2.right = r2.left + checkBoxSize;
-
- drawDDClip(dd, r2, clip);
-
- r2.left = r2.right + checkBoxSize;
- r2.right = r.right;
-
- drawDDTextClip(getTextData(dd), getTextColor(dd), r2, clip, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDCheckboxDefault]->_textAlignH,
+ _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) {
@@ -1123,35 +993,10 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s
drawDD(dd, r2);
r2.left = r2.right + checkBoxSize;
- r2.right = r.right;
-
- drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
-}
-
-void ThemeEngine::drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str, bool checked, WidgetStateInfo state) {
- if (!ready())
- return;
-
- Common::Rect r2 = r;
- DrawData dd = kDDRadiobuttonDefault;
-
- if (checked)
- dd = kDDRadiobuttonSelected;
-
- if (state == kStateDisabled)
- dd = kDDRadiobuttonDisabled;
-
- const int checkBoxSize = MIN((int)r.height(), getFontHeight());
-
- r2.bottom = r2.top + checkBoxSize;
- r2.right = r2.left + checkBoxSize;
-
- drawDDClip(dd, r2, clippingRect);
-
- r2.left = r2.right + checkBoxSize;
r2.right = MAX(r2.left, r.right);
- drawDDTextClip(getTextData(dd), getTextColor(dd), r2, clippingRect, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV);
+ drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, _widgets[kDDRadiobuttonDefault]->_textAlignH,
+ _widgets[dd]->_textAlignV);
}
void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) {
@@ -1167,34 +1012,14 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s
Common::Rect r2 = r;
r2.setWidth(MIN((int16)width, r.width()));
-// r2.top++; r2.bottom--; r2.left++; r2.right--;
-
- drawWidgetBackground(r, 0, kWidgetBackgroundSlider, kStateEnabled);
-
- drawDD(dd, r2);
-}
-
-void ThemeEngine::drawSliderClip(const Common::Rect &r, const Common::Rect &clip, int width, WidgetStateInfo state) {
- if (!ready())
- return;
-
- DrawData dd = kDDSliderFull;
-
- if (state == kStateHighlight)
- dd = kDDSliderHover;
- else if (state == kStateDisabled)
- dd = kDDSliderDisabled;
-
- Common::Rect r2 = r;
- r2.setWidth(MIN((int16)width, r.width()));
// r2.top++; r2.bottom--; r2.left++; r2.right--;
- drawWidgetBackgroundClip(r, clip, 0, kWidgetBackgroundSlider, kStateEnabled);
+ drawWidgetBackground(r, 0, kWidgetBackgroundSlider);
- drawDDClip(dd, r2, clip);
+ drawDD(dd, r2);
}
-void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
+void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState) {
if (!ready())
return;
@@ -1204,46 +1029,22 @@ void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHe
const int buttonExtra = (r.width() * 120) / 100;
r2.bottom = r2.top + buttonExtra;
- drawDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleUp);
+ drawDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2,
+ Graphics::VectorRenderer::kTriangleUp);
r2.translate(0, r.height() - r2.height());
- drawDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, Graphics::VectorRenderer::kTriangleDown);
+ drawDD(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2,
+ Graphics::VectorRenderer::kTriangleDown);
r2 = r;
r2.left += 1;
r2.right -= 1;
r2.top += sliderY;
r2.bottom = r2.top + sliderHeight;
-
- //r2.top += r.width() / 5;
- //r2.bottom -= r.width() / 5;
drawDD(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2);
}
-void ThemeEngine::drawScrollbarClip(const Common::Rect &r, const Common::Rect &clippingRect, int sliderY, int sliderHeight, ScrollbarState scrollState, WidgetStateInfo state) {
- if (!ready())
- return;
-
- drawDDClip(kDDScrollbarBase, r, clippingRect);
-
- Common::Rect r2 = r;
- const int buttonExtra = (r.width() * 120) / 100;
-
- r2.bottom = r2.top + buttonExtra;
- drawDDClip(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleUp);
-
- r2.translate(0, r.height() - r2.height());
- drawDDClip(scrollState == kScrollbarStateDown ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2, clippingRect, Graphics::VectorRenderer::kTriangleDown);
-
- r2 = r;
- r2.left += 1;
- r2.right -= 1;
- r2.top += sliderY;
- r2.bottom = r2.top + sliderHeight;
- drawDDClip(scrollState == kScrollbarStateSlider ? kDDScrollbarHandleHover : kDDScrollbarHandleIdle, r2, clippingRect);
-}
-
-void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype, WidgetStateInfo state) {
+void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground bgtype) {
if (!ready())
return;
@@ -1268,41 +1069,12 @@ void ThemeEngine::drawDialogBackground(const Common::Rect &r, DialogBackground b
drawDD(kDDDefaultBackground, r);
break;
case kDialogBackgroundNone:
- break;
- }
-}
-
-void ThemeEngine::drawDialogBackgroundClip(const Common::Rect &r, const Common::Rect &clip, DialogBackground bgtype, WidgetStateInfo state) {
- if (!ready())
- return;
-
- switch (bgtype) {
- case kDialogBackgroundMain:
- drawDDClip(kDDMainDialogBackground, r, clip);
- break;
-
- case kDialogBackgroundSpecial:
- drawDDClip(kDDSpecialColorBackground, r, clip);
- break;
-
- case kDialogBackgroundPlain:
- drawDDClip(kDDPlainColorBackground, r, clip);
- break;
-
- case kDialogBackgroundTooltip:
- drawDDClip(kDDTooltipBackground, r, clip);
- break;
-
- case kDialogBackgroundDefault:
- drawDDClip(kDDDefaultBackground, r, clip);
- break;
- case kDialogBackgroundNone:
// no op
break;
}
}
-void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state) {
+void ThemeEngine::drawCaret(const Common::Rect &r, bool erase) {
if (!ready())
return;
@@ -1312,17 +1084,7 @@ void ThemeEngine::drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo s
drawDD(kDDCaret, r);
}
-void ThemeEngine::drawCaretClip(const Common::Rect &r, const Common::Rect &clip, bool erase, WidgetStateInfo state) {
- if (!ready())
- return;
-
- if (erase) {
- restoreBackground(r);
- } else
- drawDDClip(kDDCaret, r, clip);
-}
-
-void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) {
+void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax, WidgetStateInfo state) {
if (!ready())
return;
@@ -1337,55 +1099,21 @@ void ThemeEngine::drawPopUpWidget(const Common::Rect &r, const Common::String &s
drawDD(dd, r);
- if (!sel.empty()) {
- Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
- drawDDText(getTextData(dd), getTextColor(dd), text, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
- }
-}
-
-void ThemeEngine::drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect &clip, const Common::String &sel, int deltax, WidgetStateInfo state, Graphics::TextAlign align) {
- if (!ready())
- return;
-
- DrawData dd = kDDPopUpIdle;
-
- if (state == kStateEnabled)
- dd = kDDPopUpIdle;
- else if (state == kStateHighlight)
- dd = kDDPopUpHover;
- else if (state == kStateDisabled)
- dd = kDDPopUpDisabled;
-
- drawDDClip(dd, r, clip);
-
if (!sel.empty() && r.width() >= 13 && r.height() >= 1) {
Common::Rect text(r.left + 3, r.top + 1, r.right - 10, r.bottom);
- drawDDTextClip(getTextData(dd), getTextColor(dd), text, clip, sel, true, false, _widgets[dd]->_textAlignH, _widgets[dd]->_textAlignV, deltax);
+ drawDDText(getTextData(dd), getTextColor(dd), text, sel, true, false, _widgets[dd]->_textAlignH,
+ _widgets[dd]->_textAlignV, deltax);
}
}
-void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
+void ThemeEngine::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans) {
if (!ready())
return;
drawBitmap(&surface, r, themeTrans);
}
-void ThemeEngine::drawASurface(const Common::Rect &r, Graphics::TransparentSurface &surface, AutoScaleMode autoscale, int alpha) {
- if (!ready())
- return;
-
- drawABitmap(&surface, r, autoscale, alpha);
-}
-
-void ThemeEngine::drawSurfaceClip(const Common::Rect &r, const Common::Rect &clip, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
- if (!ready())
- return;
-
- drawBitmapClip(&surface, r, clip, themeTrans);
-}
-
-void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
+void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background) {
if (!ready())
return;
@@ -1408,64 +1136,14 @@ void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, Widg
}
}
-void ThemeEngine::drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clip, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
- if (!ready())
- return;
-
- switch (background) {
- case kWidgetBackgroundBorderSmall:
- drawDDClip(kDDWidgetBackgroundSmall, r, clip);
- break;
-
- case kWidgetBackgroundEditText:
- drawDDClip(kDDWidgetBackgroundEditText, r, clip);
- break;
-
- case kWidgetBackgroundSlider:
- drawDDClip(kDDWidgetBackgroundSlider, r, clip);
- break;
-
- default:
- drawDDClip(kDDWidgetBackgroundDefault, r, clip);
- break;
- }
-}
-
-void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state) {
- if (!ready())
- return;
-
- drawDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
-
- for (int i = 0; i < (int)tabs.size(); ++i) {
- if (i == active)
- continue;
-
- if (r.left + i * tabWidth > r.right || r.left + (i + 1) * tabWidth > r.right)
- continue;
-
- Common::Rect tabRect(r.left + i * tabWidth, r.top, r.left + (i + 1) * tabWidth, r.top + tabHeight);
- drawDD(kDDTabInactive, tabRect);
- drawDDText(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, 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;
- const uint16 tabRight = MAX(r.right - tabRect.right, 0);
- drawDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
- drawDDText(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
- }
-}
-
-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) {
+void ThemeEngine::drawTab(const Common::Rect &r, int tabHeight, const Common::Array<int> &tabWidths,
+ const Common::Array<Common::String> &tabs, int active) {
if (!ready())
return;
assert(tabs.size() == tabWidths.size());
- drawDDClip(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight), clip);
+ drawDD(kDDTabBackground, Common::Rect(r.left, r.top, r.right, r.top + tabHeight));
int width = 0;
int activePos = -1;
@@ -1480,20 +1158,24 @@ void ThemeEngine::drawTabClip(const Common::Rect &r, const Common::Rect &clip, i
Common::Rect tabRect(r.left + width, r.top, r.left + width + tabWidths[i], r.top + tabHeight);
- drawDDClip(kDDTabInactive, tabRect, clip);
- drawDDTextClip(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, clip, tabs[i], false, false, _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
+ drawDD(kDDTabInactive, tabRect);
+ drawDDText(getTextData(kDDTabInactive), getTextColor(kDDTabInactive), tabRect, tabs[i], false, false,
+ _widgets[kDDTabInactive]->_textAlignH, _widgets[kDDTabInactive]->_textAlignV);
}
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);
- drawDDClip(kDDTabActive, tabRect, clip, (tabLeft << 16) | (tabRight & 0xFFFF));
- drawDDTextClip(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, clip, tabs[active], false, false, _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
+ drawDD(kDDTabActive, tabRect, (tabLeft << 16) | (tabRight & 0xFFFF));
+ drawDDText(getTextData(kDDTabActive), getTextColor(kDDTabActive), tabRect, tabs[active], false, false,
+ _widgets[kDDTabActive]->_textAlignH, _widgets[kDDTabActive]->_textAlignV);
}
}
-void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) {
+void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state,
+ Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis,
+ FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) {
if (!ready())
return;
@@ -1566,80 +1248,7 @@ void ThemeEngine::drawText(const Common::Rect &r, const Common::String &str, Wid
drawDDText(textId, colorId, r, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
}
-void ThemeEngine::drawTextClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &str, WidgetStateInfo state, Graphics::TextAlign align, TextInversionState inverted, int deltax, bool useEllipsis, FontStyle font, FontColor color, bool restore, const Common::Rect &drawableTextArea) {
- if (!ready())
- return;
-
- TextColor colorId = kTextColorMAX;
-
- switch (color) {
- case kFontColorNormal:
- if (inverted) {
- colorId = kTextColorNormalInverted;
- } else {
- switch (state) {
- case kStateDisabled:
- colorId = kTextColorNormalDisabled;
- break;
-
- case kStateHighlight:
- colorId = kTextColorNormalHover;
- break;
-
- case kStateEnabled:
- case kStatePressed:
- colorId = kTextColorNormal;
- break;
- }
- }
- break;
-
- case kFontColorAlternate:
- if (inverted) {
- colorId = kTextColorAlternativeInverted;
- } else {
- switch (state) {
- case kStateDisabled:
- colorId = kTextColorAlternativeDisabled;
- break;
-
- case kStateHighlight:
- colorId = kTextColorAlternativeHover;
- break;
-
- case kStateEnabled:
- case kStatePressed:
- colorId = kTextColorAlternative;
- break;
- }
- }
- break;
-
- default:
- return;
- }
-
- TextData textId = fontStyleToData(font);
-
- switch (inverted) {
- case kTextInversion:
- drawDDClip(kDDTextSelectionBackground, r, clippingArea);
- restore = false;
- break;
-
- case kTextInversionFocus:
- drawDDClip(kDDTextSelectionFocusBackground, r, clippingArea);
- restore = false;
- break;
-
- default:
- break;
- }
-
- drawDDTextClip(textId, colorId, r, clippingArea, str, restore, useEllipsis, align, kTextAlignVCenter, deltax, drawableTextArea);
-}
-
-void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) {
+void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, FontColor color) {
if (!ready())
return;
@@ -1648,20 +1257,7 @@ void ThemeEngine::drawChar(const Common::Rect &r, byte ch, const Graphics::Font
uint32 rgbColor = _overlayFormat.RGBToColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
- restoreBackground(charArea);
- font->drawChar(&_screen, ch, charArea.left, charArea.top, rgbColor);
- addDirtyRect(charArea);
-}
-
-void ThemeEngine::drawCharClip(const Common::Rect &r, const Common::Rect &clip, byte ch, const Graphics::Font *font, WidgetStateInfo state, FontColor color) {
- if (!ready())
- return;
-
- Common::Rect charArea = r;
- charArea.clip(_screen.w, _screen.h);
- if (!clip.isEmpty()) charArea.clip(clip);
-
- uint32 rgbColor = _overlayFormat.RGBToColor(_textColors[color]->r, _textColors[color]->g, _textColors[color]->b);
+ // TODO: Handle clipping when drawing chars
restoreBackground(charArea);
font->drawChar(&_screen, ch, charArea.left, charArea.top, rgbColor);
@@ -2282,4 +1878,10 @@ void ThemeEngine::drawToScreen() {
_vectorRenderer->setSurface(&_screen);
}
+Common::Rect ThemeEngine::swapClipRect(const Common::Rect &newRect) {
+ Common::Rect oldRect = _clip;
+ _clip = newRect;
+ return oldRect;
+}
+
} // End of namespace GUI.
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index 5675f0c5d7..984ac0f083 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -376,75 +376,56 @@ public:
//@}
+ /**
+ * Set the clipping rect to be used by the widget drawing methods defined below.
+ *
+ * Widgets are not drawn outside of the clipping rect. Widgets that overlap the
+ * clipping rect are drawn partially.
+ *
+ * @param newRect The new clipping rect
+ * @return The previous clipping rect
+ */
+ Common::Rect swapClipRect(const Common::Rect &newRect);
/** @name WIDGET DRAWING METHODS */
//@{
- void drawWidgetBackground(const Common::Rect &r, uint16 hints,
- WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
- void drawWidgetBackgroundClip(const Common::Rect &r, const Common::Rect &clippingArea, uint16 hints,
- WidgetBackground background = kWidgetBackgroundPlain, WidgetStateInfo state = kStateEnabled);
-
- void drawButton(const Common::Rect &r, const Common::String &str,
- WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
- void drawButtonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str,
- WidgetStateInfo state = kStateEnabled, uint16 hints = 0);
+ void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain);
- void drawSurface(const Common::Rect &r, const Graphics::Surface &surface,
- WidgetStateInfo state = kStateEnabled, int alpha = 255, bool themeTrans = false);
- void drawSurfaceClip(const Common::Rect &r, const Common::Rect &clippingRect, const Graphics::Surface &surface,
- WidgetStateInfo state = kStateEnabled, int alpha = 255, bool themeTrans = false);
+ void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
+ uint16 hints = 0);
- void drawASurface(const Common::Rect &r, Graphics::TransparentSurface &surface, AutoScaleMode autoscale, int alpha);
+ void drawSurface(const Common::Rect &r, const Graphics::Surface &surface, bool themeTrans = false);
- void drawSlider(const Common::Rect &r, int width,
- WidgetStateInfo state = kStateEnabled);
- void drawSliderClip(const Common::Rect &r, const Common::Rect &clippingRect, int width,
- WidgetStateInfo state = kStateEnabled);
+ void drawSlider(const Common::Rect &r, int width, WidgetStateInfo state = kStateEnabled);
- void drawCheckbox(const Common::Rect &r, const Common::String &str,
- bool checked, WidgetStateInfo state = kStateEnabled);
- void drawCheckboxClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str,
- bool checked, WidgetStateInfo state = kStateEnabled);
+ void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked,
+ WidgetStateInfo state = kStateEnabled);
- void drawRadiobutton(const Common::Rect &r, const Common::String &str,
- bool checked, WidgetStateInfo state = kStateEnabled);
- void drawRadiobuttonClip(const Common::Rect &r, const Common::Rect &clippingRect, const Common::String &str,
- bool checked, WidgetStateInfo state = kStateEnabled);
+ void drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked,
+ WidgetStateInfo state = kStateEnabled);
- void drawTab(const Common::Rect &r, int tabHeight, int tabWidth,
- const Common::Array<Common::String> &tabs, int active, uint16 hints,
- int titleVPad, WidgetStateInfo state = kStateEnabled);
- void drawTabClip(const Common::Rect &r, const Common::Rect &clippingRect, int tabHeight, const Common::Array<int> &tabWidths,
- const Common::Array<Common::String> &tabs, int active, uint16 hints,
- int titleVPad, WidgetStateInfo state = kStateEnabled);
+ void drawTab(const Common::Rect &r, int tabHeight, const Common::Array<int> &tabWidths,
+ const Common::Array<Common::String> &tabs, int active);
- void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight,
- ScrollbarState, WidgetStateInfo state = kStateEnabled);
- void drawScrollbarClip(const Common::Rect &r, const Common::Rect &clippingRect, int sliderY, int sliderHeight,
- ScrollbarState scrollState, WidgetStateInfo state = kStateEnabled);
+ void drawScrollbar(const Common::Rect &r, int sliderY, int sliderHeight, ScrollbarState scrollState);
- void drawPopUpWidget(const Common::Rect &r, const Common::String &sel,
- int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft);
- void drawPopUpWidgetClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &sel,
- int deltax, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignLeft);
+ void drawPopUpWidget(const Common::Rect &r, const Common::String &sel, int deltax,
+ WidgetStateInfo state = kStateEnabled);
- void drawCaret(const Common::Rect &r, bool erase,
- WidgetStateInfo state = kStateEnabled);
- void drawCaretClip(const Common::Rect &r, const Common::Rect &clip, bool erase,
- WidgetStateInfo state = kStateEnabled);
+ void drawCaret(const Common::Rect &r, bool erase);
- void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
- void drawLineSeparatorClip(const Common::Rect &r, const Common::Rect &clippingArea, WidgetStateInfo state = kStateEnabled);
+ void drawLineSeparator(const Common::Rect &r);
- void drawDialogBackground(const Common::Rect &r, DialogBackground type, WidgetStateInfo state = kStateEnabled);
- void drawDialogBackgroundClip(const Common::Rect &r, const Common::Rect &clip, DialogBackground type, WidgetStateInfo state = kStateEnabled);
+ void drawDialogBackground(const Common::Rect &r, DialogBackground type);
- void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignCenter, TextInversionState inverted = kTextInversionNone, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold, FontColor color = kFontColorNormal, bool restore = true, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void drawTextClip(const Common::Rect &r, const Common::Rect &clippingArea, const Common::String &str, WidgetStateInfo state = kStateEnabled, Graphics::TextAlign align = Graphics::kTextAlignCenter, TextInversionState inverted = kTextInversionNone, int deltax = 0, bool useEllipsis = true, FontStyle font = kFontStyleBold, FontColor color = kFontColorNormal, bool restore = true, const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
+ void drawText(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled,
+ Graphics::TextAlign align = Graphics::kTextAlignCenter,
+ TextInversionState inverted = kTextInversionNone, int deltax = 0, bool useEllipsis = true,
+ FontStyle font = kFontStyleBold, FontColor color = kFontColorNormal, bool restore = true,
+ const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled, FontColor color = kFontColorNormal);
- void drawCharClip(const Common::Rect &r, const Common::Rect &clippingArea, byte ch, const Graphics::Font *font, WidgetStateInfo state = kStateEnabled, FontColor color = kFontColorNormal);
+ void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, FontColor color = kFontColorNormal);
//@}
@@ -606,15 +587,6 @@ public:
int getGraphicsMode() const { return _graphicsMode; }
protected:
- /**
- * Initializes the drawing screen surfaces, _screen and _backBuffer.
- * If the surfaces already exist, they are cleared and re-initialized.
- *
- * @param backBuffer Sets whether the _backBuffer surface should be initialized.
- * @template PixelType C type which specifies the size of each pixel.
- * Defaults to uint16 (2 BPP for the surfaces)
- */
- template<typename PixelType> void screenInit(bool backBuffer = true);
/**
* Loads the given theme into the ThemeEngine.
@@ -657,21 +629,11 @@ protected:
* These functions are called from all the Widget drawing methods.
*/
void drawDD(DrawData type, const Common::Rect &r, uint32 dynamic = 0, bool forceRestore = false);
- void drawDDClip(DrawData type, const Common::Rect &r, const Common::Rect &clippingRect, uint32 dynamic = 0,
- bool forceRestore = false);
void drawDDText(TextData type, TextColor color, const Common::Rect &r, const Common::String &text, bool restoreBg,
bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void drawDDTextClip(TextData type, TextColor color, const Common::Rect &r, const Common::Rect &clippingRect,
- const Common::String &text, bool restoreBg,
- bool elipsis, Graphics::TextAlign alignH = Graphics::kTextAlignLeft,
- TextAlignVertical alignV = kTextAlignVTop, int deltax = 0,
- const Common::Rect &drawableTextArea = Common::Rect(0, 0, 0, 0));
- void drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &r, bool alpha);
- void drawBitmapClip(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, const Common::Rect &r,
- bool alpha);
- void drawABitmap(Graphics::TransparentSurface *bitmap, const Common::Rect &r, AutoScaleMode autoscale, int alpha);
+ void drawBitmap(const Graphics::Surface *bitmap, const Common::Rect &clippingRect, bool alpha);
/**
* DEBUG: Draws a white square and writes some text next to it.
@@ -732,7 +694,6 @@ protected:
GraphicsMode _graphicsMode;
/** Font info. */
- Common::String _fontName;
const Graphics::Font *_font;
/**
@@ -773,10 +734,11 @@ protected:
MAX_CURS_COLORS = 255
};
byte *_cursor;
- bool _needPaletteUpdates;
uint _cursorWidth, _cursorHeight;
byte _cursorPal[3 * MAX_CURS_COLORS];
byte _cursorPalSize;
+
+ Common::Rect _clip;
};
} // End of namespace GUI.
diff --git a/gui/Tooltip.cpp b/gui/Tooltip.cpp
index bcaa8cee2a..50f10272fb 100644
--- a/gui/Tooltip.cpp
+++ b/gui/Tooltip.cpp
@@ -64,7 +64,8 @@ void Tooltip::drawDialog(DrawLayer layerToDraw) {
for (Common::StringArray::const_iterator i = _wrappedLines.begin(); i != _wrappedLines.end(); ++i, ++num) {
g_gui.theme()->drawText(
- Common::Rect(_x + 1, _y + 1 + num * h, _x + 1 +_w, _y + 1+ (num + 1) * h), *i,
+ Common::Rect(_x + 1, _y + 1 + num * h, _x + 1 + _w, _y + 1 + (num + 1) * h),
+ *i,
ThemeEngine::kStateEnabled,
Graphics::kTextAlignLeft,
ThemeEngine::kTextInversionNone,
diff --git a/gui/Tooltip.h b/gui/Tooltip.h
index 64496fff9d..e812ebed8c 100644
--- a/gui/Tooltip.h
+++ b/gui/Tooltip.h
@@ -42,29 +42,29 @@ public:
void drawDialog(DrawLayer layerToDraw) override;
- virtual void receivedFocus(int x = -1, int y = -1) {}
+ virtual void receivedFocus(int x = -1, int y = -1) override {}
protected:
- virtual void handleMouseDown(int x, int y, int button, int clickCount) {
+ virtual void handleMouseDown(int x, int y, int button, int clickCount) override {
close();
_parent->handleMouseDown(x + (getAbsX() - _parent->getAbsX()), y + (getAbsY() - _parent->getAbsY()), button, clickCount);
}
- virtual void handleMouseUp(int x, int y, int button, int clickCount) {
+ virtual void handleMouseUp(int x, int y, int button, int clickCount) override {
close();
_parent->handleMouseUp(x + (getAbsX() - _parent->getAbsX()), y + (getAbsY() - _parent->getAbsY()), button, clickCount);
}
- virtual void handleMouseWheel(int x, int y, int direction) {
+ virtual void handleMouseWheel(int x, int y, int direction) override {
close();
_parent->handleMouseWheel(x + (getAbsX() - _parent->getAbsX()), y + (getAbsX() - _parent->getAbsX()), direction);
}
- virtual void handleKeyDown(Common::KeyState state) {
+ virtual void handleKeyDown(Common::KeyState state) override {
close();
_parent->handleKeyDown(state);
}
- virtual void handleKeyUp(Common::KeyState state) {
+ virtual void handleKeyUp(Common::KeyState state) override {
close();
_parent->handleKeyUp(state);
}
- virtual void handleMouseMoved(int x, int y, int button) {
+ virtual void handleMouseMoved(int x, int y, int button) override {
close();
}
diff --git a/gui/about.cpp b/gui/about.cpp
index 0d70f3dd42..869e0f82ba 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -242,7 +242,9 @@ void AboutDialog::drawDialog(DrawLayer layerToDraw) {
str++;
if (*str)
- g_gui.theme()->drawText(Common::Rect(_x + _xOff, y, _x + _w - _xOff, y + g_gui.theme()->getFontHeight()), str, state, align, ThemeEngine::kTextInversionNone, 0, false, ThemeEngine::kFontStyleBold, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
+ g_gui.theme()->drawText(Common::Rect(_x + _xOff, y, _x + _w - _xOff, y + g_gui.theme()->getFontHeight()),
+ str, state, align, ThemeEngine::kTextInversionNone, 0, false,
+ ThemeEngine::kFontStyleBold, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
y += _lineHeight;
}
}
diff --git a/gui/about.h b/gui/about.h
index b6510772bf..a6b13cd1da 100644
--- a/gui/about.h
+++ b/gui/about.h
@@ -46,15 +46,15 @@ protected:
public:
AboutDialog();
- void open();
- void close();
+ void open() override;
+ void close() override;
void drawDialog(DrawLayer layerToDraw) override;
- void handleTickle();
- void handleMouseUp(int x, int y, int button, int clickCount);
- void handleKeyDown(Common::KeyState state);
- void handleKeyUp(Common::KeyState state);
+ void handleTickle() override;
+ void handleMouseUp(int x, int y, int button, int clickCount) override;
+ void handleKeyDown(Common::KeyState state) override;
+ void handleKeyUp(Common::KeyState state) override;
- void reflowLayout();
+ void reflowLayout() override;
};
} // End of namespace GUI
diff --git a/gui/console.cpp b/gui/console.cpp
index 1c7be32286..5e9def8740 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -243,9 +243,19 @@ void ConsoleDialog::handleMouseWheel(int x, int y, int direction) {
_scrollBar->handleMouseWheel(x, y, direction);
}
-void ConsoleDialog::handleKeyDown(Common::KeyState state) {
- int i;
+Common::String ConsoleDialog::getUserInput() {
+ assert(_promptEndPos >= _promptStartPos);
+ int len = _promptEndPos - _promptStartPos;
+
+ // Copy the user input to str
+ Common::String str;
+ for (int i = 0; i < len; i++)
+ str.insertChar(buffer(_promptStartPos + i), i);
+ return str;
+}
+
+void ConsoleDialog::handleKeyDown(Common::KeyState state) {
if (_slideMode != kNoSlideMode)
return;
@@ -257,26 +267,16 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
nextLine();
- assert(_promptEndPos >= _promptStartPos);
- int len = _promptEndPos - _promptStartPos;
bool keepRunning = true;
-
- if (len > 0) {
-
- Common::String str;
-
- // Copy the user input to str
- for (i = 0; i < len; i++)
- str.insertChar(buffer(_promptStartPos + i), i);
-
+ Common::String userInput = getUserInput();
+ if (!userInput.empty()) {
// Add the input to the history
- addToHistory(str);
+ addToHistory(userInput);
// Pass it to the input callback, if any
if (_callbackProc)
- keepRunning = (*_callbackProc)(this, str.c_str(), _callbackRefCon);
-
+ keepRunning = (*_callbackProc)(this, userInput.c_str(), _callbackRefCon);
}
print(PROMPT);
@@ -311,7 +311,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
char *str = new char[len + 1];
// Copy the user input to str
- for (i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
str[i] = buffer(_promptStartPos + i);
str[len] = '\0';
@@ -504,7 +504,7 @@ void ConsoleDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
}
}
-void ConsoleDialog::specialKeys(int keycode) {
+void ConsoleDialog::specialKeys(Common::KeyCode keycode) {
switch (keycode) {
case Common::KEYCODE_a:
_currentPos = _promptStartPos;
@@ -528,6 +528,23 @@ void ConsoleDialog::specialKeys(int keycode) {
killLastWord();
g_gui.scheduleTopDialogRedraw();
break;
+ case Common::KEYCODE_v:
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport) && g_system->hasTextInClipboard()) {
+ Common::String text = g_system->getTextFromClipboard();
+ insertIntoPrompt(text.c_str());
+ scrollToCurrent();
+ drawLine(pos2line(_currentPos));
+ }
+ break;
+ case Common::KEYCODE_c:
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ Common::String userInput = getUserInput();
+ if (!userInput.empty())
+ g_system->setTextInClipboard(userInput);
+ }
+ break;
+ default:
+ break;
}
}
@@ -712,7 +729,7 @@ void ConsoleDialog::drawCaret(bool erase) {
int y = _y + _topPadding + displayLine * kConsoleLineHeight;
_caretVisible = !erase;
- g_gui.theme()->drawCaret(Common::Rect(x, y, x+1, y+kConsoleLineHeight), erase);
+ g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + kConsoleLineHeight), erase);
}
void ConsoleDialog::scrollToCurrent() {
diff --git a/gui/console.h b/gui/console.h
index 04ad5526a6..2445005afc 100644
--- a/gui/console.h
+++ b/gui/console.h
@@ -69,29 +69,29 @@ public:
protected:
enum {
- kBufferSize = 32768,
+ kBufferSize = 32768,
kCharsPerLine = 128,
- kHistorySize = 20
+ kHistorySize = 20
};
const Graphics::Font *_font;
- char _buffer[kBufferSize];
- int _linesInBuffer;
+ char _buffer[kBufferSize];
+ int _linesInBuffer;
- int _pageWidth;
- int _linesPerPage;
+ int _pageWidth;
+ int _linesPerPage;
- int _currentPos;
- int _scrollLine;
- int _firstLineInBuffer;
+ int _currentPos;
+ int _scrollLine;
+ int _firstLineInBuffer;
- int _promptStartPos;
- int _promptEndPos;
+ int _promptStartPos;
+ int _promptEndPos;
- bool _caretVisible;
- uint32 _caretTime;
+ bool _caretVisible;
+ uint32 _caretTime;
enum SlideMode {
kNoSlideMode,
@@ -99,8 +99,8 @@ protected:
kDownSlideMode
};
- SlideMode _slideMode;
- uint32 _slideTime;
+ SlideMode _slideMode;
+ uint32 _slideTime;
ScrollBarWidget *_scrollBar;
@@ -120,25 +120,25 @@ protected:
float _widthPercent, _heightPercent;
- int _leftPadding;
- int _rightPadding;
- int _topPadding;
- int _bottomPadding;
+ int _leftPadding;
+ int _rightPadding;
+ int _topPadding;
+ int _bottomPadding;
void slideUpAndClose();
public:
ConsoleDialog(float widthPercent, float heightPercent);
- void open();
- void close();
+ void open() override;
+ void close() override;
void drawDialog(DrawLayer layerToDraw) override;
- void handleTickle();
- void reflowLayout();
- void handleMouseWheel(int x, int y, int direction);
- void handleKeyDown(Common::KeyState state);
- void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+ void handleTickle() override;
+ void reflowLayout() override;
+ void handleMouseWheel(int x, int y, int direction) override;
+ void handleKeyDown(Common::KeyState state) override;
+ void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
int printFormat(int dummy, const char *format, ...) GCC_PRINTF(3, 4);
int vprintFormat(int dummy, const char *format, va_list argptr);
@@ -174,11 +174,12 @@ protected:
void print(const char *str);
void updateScrollBuffer();
void scrollToCurrent();
+ Common::String getUserInput();
void defaultKeyDownHandler(Common::KeyState &state);
// Line editing
- void specialKeys(int keycode);
+ void specialKeys(Common::KeyCode keycode);
void nextLine();
void killChar();
void killLine();
diff --git a/gui/credits.h b/gui/credits.h
index 8f3f934024..82cc27bf8b 100644
--- a/gui/credits.h
+++ b/gui/credits.h
@@ -362,6 +362,13 @@ static const char *credits[] = {
"C0""Einar Johan T. S\370m\345en",
"C0""Tobia Tesan",
"",
+"C1""Xeen",
+"C0""Paul Gilbert",
+"C0""David Goldsmith",
+"C2""(analysis)",
+"C0""Matt Taylor",
+"C2""(analysis)",
+"",
"C1""Z-Vision",
"C0""Adrian Astley",
"C0""Filippos Karapetis",
diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index ce4661e9cb..9b559d8bb9 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -404,17 +404,17 @@ void Debugger::splitCommand(char *input, int &argc, const char **argv) {
byte c;
enum states { DULL, IN_WORD, IN_STRING } state = DULL;
const char *paramStart = nullptr;
-
+
argc = 0;
for (char *p = input; *p; ++p) {
c = (byte)*p;
switch (state) {
- case DULL:
+ case DULL:
// not in a word, not in a double quoted string
if (isspace(c))
break;
-
+
// not a space -- if it's a double quote we go to IN_STRING, else to IN_WORD
if (c == '"') {
state = IN_STRING;
@@ -470,7 +470,7 @@ bool Debugger::tabComplete(const char *input, Common::String &completion) const
CommandsMap::const_iterator i, e = _cmds.end();
for (i = _cmds.begin(); i != e; ++i) {
- if (i->_key.hasPrefix(input)) {
+ if (i->_key.hasPrefixIgnoreCase(input)) {
uint commandlen = i->_key.size();
if (commandlen == inputlen) { // perfect match, so no tab completion possible
return false;
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index 6f4e8e6b44..560c29174a 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -167,7 +167,7 @@ void Dialog::drawDialog(DrawLayer layerToDraw) {
return;
g_gui.theme()->_layerToDraw = layerToDraw;
- g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h), _backgroundType);
+ g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType);
markWidgetsAsDirty();
drawWidgets();
diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp
index 4192c4058a..80fb41fad1 100644
--- a/gui/editgamedialog.cpp
+++ b/gui/editgamedialog.cpp
@@ -95,7 +95,7 @@ protected:
}
};
-EditGameDialog::EditGameDialog(const String &domain, const String &desc)
+EditGameDialog::EditGameDialog(const String &domain)
: OptionsDialog(domain, "GameOptions") {
// Retrieve all game specific options.
const Plugin *plugin = nullptr;
@@ -106,7 +106,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
gameId = domain;
// Retrieve the plugin, since we need to access the engine's MetaEngine
// implementation.
- EngineMan.findGame(gameId, &plugin);
+ PlainGameDescriptor pgd = EngineMan.findGame(gameId, &plugin);
if (plugin) {
_engineOptions = plugin->get<MetaEngine>().getExtraGuiOptions(domain);
} else {
@@ -120,8 +120,8 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
// GAME: Determine the description string
String description(ConfMan.get("description", domain));
- if (description.empty() && !desc.empty()) {
- description = desc;
+ if (description.empty() && pgd.description) {
+ description = pgd.description;
}
// GUI: Add tab widget
@@ -384,35 +384,35 @@ void EditGameDialog::open() {
void EditGameDialog::apply() {
ConfMan.set("description", _descriptionWidget->getEditString(), _domain);
-
+
Common::Language lang = (Common::Language)_langPopUp->getSelectedTag();
if (lang < 0)
ConfMan.removeKey("language", _domain);
else
ConfMan.set("language", Common::getLanguageCode(lang), _domain);
-
+
String gamePath(_gamePathWidget->getLabel());
if (!gamePath.empty())
ConfMan.set("path", gamePath, _domain);
-
+
String extraPath(_extraPathWidget->getLabel());
if (!extraPath.empty() && (extraPath != _c("None", "path")))
ConfMan.set("extrapath", extraPath, _domain);
else
ConfMan.removeKey("extrapath", _domain);
-
+
String savePath(_savePathWidget->getLabel());
if (!savePath.empty() && (savePath != _("Default")))
ConfMan.set("savepath", savePath, _domain);
else
ConfMan.removeKey("savepath", _domain);
-
+
Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag();
if (platform < 0)
ConfMan.removeKey("platform", _domain);
else
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);
-
+
// Set the state of engine-specific checkboxes
for (uint i = 0; i < _engineOptions.size(); i++) {
ConfMan.setBool(_engineOptions[i].configOption, _engineCheckboxes[i]->getState(), _domain);
diff --git a/gui/editgamedialog.h b/gui/editgamedialog.h
index a317e364c6..7c6a08eb3c 100644
--- a/gui/editgamedialog.h
+++ b/gui/editgamedialog.h
@@ -40,8 +40,6 @@ class StaticTextWidget;
class EditTextWidget;
class SaveLoadChooser;
-Common::String addGameToConf(const GameDescriptor &result);
-
/*
* A dialog that allows the user to edit a config game entry.
* TODO: add widgets for some/all of the following
@@ -62,7 +60,7 @@ class EditGameDialog : public OptionsDialog {
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
public:
- EditGameDialog(const String &domain, const String &desc);
+ EditGameDialog(const String &domain);
void open();
virtual void apply();
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 4fe1ae79c8..214dc30834 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -45,6 +45,7 @@
#include "gui/EventRecorder.h"
#endif
#include "gui/saveload.h"
+#include "gui/unknown-game-dialog.h"
#include "gui/widgets/edittext.h"
#include "gui/widgets/list.h"
#include "gui/widgets/tab.h"
@@ -266,9 +267,9 @@ void LauncherDialog::updateListing() {
if (gameid.empty())
gameid = iter->_key;
if (description.empty()) {
- GameDescriptor g = EngineMan.findGame(gameid);
- if (g.contains("description"))
- description = g.description();
+ PlainGameDescriptor g = EngineMan.findGame(gameid);
+ if (g.description)
+ description = g.description;
}
if (description.empty()) {
@@ -375,45 +376,6 @@ void LauncherDialog::addGame() {
} while (looping);
}
-Common::String addGameToConf(const GameDescriptor &result) {
- // The auto detector or the user made a choice.
- // Pick a domain name which does not yet exist (after all, we
- // are *adding* a game to the config, not replacing).
- Common::String domain = result.preferredtarget();
-
- assert(!domain.empty());
- if (ConfMan.hasGameDomain(domain)) {
- int suffixN = 1;
- Common::String gameid(domain);
-
- while (ConfMan.hasGameDomain(domain)) {
- domain = gameid + Common::String::format("-%d", suffixN);
- suffixN++;
- }
- }
-
- // Add the name domain
- ConfMan.addGameDomain(domain);
-
- // Copy all non-empty key/value pairs into the new domain
- for (GameDescriptor::const_iterator iter = result.begin(); iter != result.end(); ++iter) {
- if (!iter->_value.empty() && iter->_key != "preferredtarget")
- ConfMan.set(iter->_key, iter->_value, domain);
- }
-
- // TODO: Setting the description field here has the drawback
- // that the user does never notice when we upgrade our descriptions.
- // It might be nice ot leave this field empty, and only set it to
- // a value when the user edits the description string.
- // However, at this point, that's impractical. Once we have a method
- // to query all backends for the proper & full description of a given
- // game target, we can change this (currently, you can only query
- // for the generic gameid description; it's not possible to obtain
- // a description which contains extended information like language, etc.).
-
- return domain;
-}
-
void LauncherDialog::removeGame(int item) {
MessageDialog alert(_("Do you really want to remove this game configuration?"), _("Yes"), _("No"));
@@ -442,7 +404,8 @@ void LauncherDialog::editGame(int item) {
String gameId(ConfMan.get("gameid", _domains[item]));
if (gameId.empty())
gameId = _domains[item];
- EditGameDialog editDialog(_domains[item], EngineMan.findGame(gameId).description());
+
+ EditGameDialog editDialog(_domains[item]);
if (editDialog.runModal() > 0) {
// User pressed OK, so make changes permanent
@@ -573,7 +536,17 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
// ...so let's determine a list of candidates, games that
// could be contained in the specified directory.
- GameList candidates(EngineMan.detectGames(files));
+ DetectionResults detectionResults = EngineMan.detectGames(files);
+
+ if (detectionResults.foundUnknownGames()) {
+ Common::String report = detectionResults.generateUnknownGameReport(false, 80);
+ g_system->logMessage(LogMessageType::kInfo, report.c_str());
+
+ UnknownGameDialog dialog(detectionResults);
+ dialog.runModal();
+ }
+
+ Common::Array<DetectedGame> candidates = detectionResults.listRecognizedGames();
int idx;
if (candidates.empty()) {
@@ -589,22 +562,19 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
// Display the candidates to the user and let her/him pick one
StringArray list;
for (idx = 0; idx < (int)candidates.size(); idx++)
- list.push_back(candidates[idx].description());
+ list.push_back(candidates[idx].description);
ChooserDialog dialog(_("Pick the game:"));
dialog.setList(list);
idx = dialog.runModal();
}
if (0 <= idx && idx < (int)candidates.size()) {
- GameDescriptor result = candidates[idx];
-
- // TODO: Change the detectors to set "path" !
- result["path"] = dir.getPath();
+ const DetectedGame &result = candidates[idx];
- Common::String domain = addGameToConf(result);
+ Common::String domain = EngineMan.createTargetForGame(result);
// Display edit dialog for the new entry
- EditGameDialog editDialog(domain, result.description());
+ EditGameDialog editDialog(domain);
if (editDialog.runModal() > 0) {
// User pressed OK, so make changes permanent
diff --git a/gui/launcher.h b/gui/launcher.h
index 08413fe3d2..9f0a1c8e95 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -38,8 +38,6 @@ class StaticTextWidget;
class EditTextWidget;
class SaveLoadChooser;
-Common::String addGameToConf(const GameDescriptor &result);
-
class LauncherDialog : public Dialog {
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
diff --git a/gui/massadd.cpp b/gui/massadd.cpp
index db569fac82..8bc5a10720 100644
--- a/gui/massadd.cpp
+++ b/gui/massadd.cpp
@@ -28,10 +28,7 @@
#include "common/taskbar.h"
#include "common/translation.h"
-#include "gui/launcher.h" // For addGameToConf()
#include "gui/massadd.h"
-#include "gui/widget.h"
-#include "gui/widgets/list.h"
#ifndef DISABLE_MASS_ADD
namespace GUI {
@@ -120,14 +117,14 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
}
struct GameTargetLess {
- bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
- return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0;
+ bool operator()(const DetectedGame &x, const DetectedGame &y) const {
+ return x.preferredTarget.compareToIgnoreCase(y.preferredTarget) < 0;
}
};
struct GameDescLess {
- bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
- return x.description().compareToIgnoreCase(y.description()) < 0;
+ bool operator()(const DetectedGame &x, const DetectedGame &y) const {
+ return x.description.compareToIgnoreCase(y.description) < 0;
}
};
@@ -143,13 +140,13 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
if (cmd == kOkCmd) {
// Sort the detected games. This is not strictly necessary, but nice for
// people who want to edit their config file by hand after a mass add.
- sort(_games.begin(), _games.end(), GameTargetLess());
+ Common::sort(_games.begin(), _games.end(), GameTargetLess());
// Add all the detected games to the config
- for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
+ for (DetectedGames::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
debug(1, " Added gameid '%s', desc '%s'\n",
- (*iter)["gameid"].c_str(),
- (*iter)["description"].c_str());
- (*iter)["gameid"] = addGameToConf(*iter);
+ iter->gameId.c_str(),
+ iter->description.c_str());
+ iter->gameId = EngineMan.createTargetForGame(*iter);
}
// Write everything to disk
@@ -157,8 +154,8 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
// And scroll to first detected game
if (!_games.empty()) {
- sort(_games.begin(), _games.end(), GameDescLess());
- ConfMan.set("temp_selection", _games.front().gameid());
+ Common::sort(_games.begin(), _games.end(), GameDescLess());
+ ConfMan.set("temp_selection", _games.front().gameId);
}
close();
@@ -187,7 +184,12 @@ void MassAddDialog::handleTickle() {
}
// Run the detector on the dir
- GameList candidates(EngineMan.detectGames(files));
+ DetectionResults detectionResults = EngineMan.detectGames(files);
+
+ if (detectionResults.foundUnknownGames()) {
+ Common::String report = detectionResults.generateUnknownGameReport(false, 80);
+ g_system->logMessage(LogMessageType::kInfo, report.c_str());
+ }
// Just add all detected games / game variants. If we get more than one,
// that either means the directory contains multiple games, or the detector
@@ -195,8 +197,10 @@ void MassAddDialog::handleTickle() {
// case, let the user choose which entries he wants to keep.
//
// However, we only add games which are not already in the config file.
- for (GameList::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
- GameDescriptor result = *cand;
+ DetectedGames candidates = detectionResults.listRecognizedGames();
+ for (DetectedGames::const_iterator cand = candidates.begin(); cand != candidates.end(); ++cand) {
+ const DetectedGame &result = *cand;
+
Common::String path = dir.getPath();
// Remove trailing slashes
@@ -205,6 +209,9 @@ void MassAddDialog::handleTickle() {
// Check for existing config entries for this path/gameid/lang/platform combination
if (_pathToTargets.contains(path)) {
+ const char *resultPlatformCode = Common::getPlatformCode(result.platform);
+ const char *resultLanguageCode = Common::getLanguageCode(result.language);
+
bool duplicate = false;
const StringArray &targets = _pathToTargets[path];
for (StringArray::const_iterator iter = targets.begin(); iter != targets.end(); ++iter) {
@@ -212,9 +219,9 @@ void MassAddDialog::handleTickle() {
Common::ConfigManager::Domain *dom = ConfMan.getDomain(*iter);
assert(dom);
- if ((*dom)["gameid"] == result["gameid"] &&
- (*dom)["platform"] == result["platform"] &&
- (*dom)["language"] == result["language"]) {
+ if ((*dom)["gameid"] == result.gameId &&
+ (*dom)["platform"] == resultPlatformCode &&
+ (*dom)["language"] == resultLanguageCode) {
duplicate = true;
break;
}
@@ -224,10 +231,9 @@ void MassAddDialog::handleTickle() {
break; // Skip duplicates
}
}
- result["path"] = path;
_games.push_back(result);
- _list->append(result.description());
+ _list->append(result.description);
}
diff --git a/gui/massadd.h b/gui/massadd.h
index 116a420d79..b81a6046e2 100644
--- a/gui/massadd.h
+++ b/gui/massadd.h
@@ -24,6 +24,7 @@
#define MASSADD_DIALOG_H
#include "gui/dialog.h"
+#include "gui/widgets/list.h"
#include "common/fs.h"
#include "common/hashmap.h"
#include "common/stack.h"
@@ -44,13 +45,13 @@ public:
Common::String getFirstAddedTarget() const {
if (!_games.empty())
- return _games.front().gameid();
+ return _games.front().gameId;
return Common::String();
}
private:
Common::Stack<Common::FSNode> _scanStack;
- GameList _games;
+ DetectedGames _games;
/**
* Map each path occuring in the config file to the target(s) using that path.
diff --git a/gui/module.mk b/gui/module.mk
index eb3ee88a9a..0218e082b4 100644
--- a/gui/module.mk
+++ b/gui/module.mk
@@ -25,6 +25,7 @@ MODULE_OBJS := \
ThemeLayout.o \
ThemeParser.o \
Tooltip.o \
+ unknown-game-dialog.o \
animation/Animation.o \
animation/RepeatAnimationWrapper.o \
animation/SequenceAnimationComposite.o \
diff --git a/gui/object.cpp b/gui/object.cpp
index 327bc27894..d2a6701443 100644
--- a/gui/object.cpp
+++ b/gui/object.cpp
@@ -67,4 +67,8 @@ void GuiObject::removeWidget(Widget *del) {
}
}
+Common::Rect GuiObject::getClipRect() const {
+ return Common::Rect(getAbsX(), getAbsY(), getAbsX() + getWidth(), getAbsY() + getHeight());
+}
+
} // End of namespace GUI
diff --git a/gui/object.h b/gui/object.h
index 40ea2da636..33d6ec3c8f 100644
--- a/gui/object.h
+++ b/gui/object.h
@@ -95,6 +95,11 @@ public:
return (x >= _x && x < (_x + _w) && (y >= _y) && (y < _y + _h));
}
+ /**
+ * Returns the clipping rect to be used when drawing the children widgets of this object
+ */
+ virtual Common::Rect getClipRect() const;
+
protected:
virtual void releaseFocus() = 0;
};
diff --git a/gui/options.h b/gui/options.h
index b1666c2fff..bc58d7a63e 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -81,7 +81,7 @@ protected:
ButtonWidget *_soundFontButton;
StaticTextWidget *_soundFont;
ButtonWidget *_soundFontClearButton;
-
+
virtual void build();
virtual void clean();
void rebuild();
@@ -115,7 +115,7 @@ protected:
int _pathsTabId;
private:
-
+
//
// Control controls
//
@@ -143,7 +143,7 @@ private:
CheckboxWidget *_aspectCheckbox;
StaticTextWidget *_renderModePopUpDesc;
PopUpWidget *_renderModePopUp;
-
+
//
// Shader controls
//
diff --git a/gui/predictivedialog.cpp b/gui/predictivedialog.cpp
index 5650fd8e94..b01e4950d5 100644
--- a/gui/predictivedialog.cpp
+++ b/gui/predictivedialog.cpp
@@ -35,7 +35,7 @@
#include "common/file.h"
#include "common/savefile.h"
-#ifdef __DS__
+#if defined(__DS__) && defined(ENABLE_AGI)
#include "backends/platform/ds/arm9/source/wordcompletion.h"
#endif
@@ -945,7 +945,7 @@ void PredictiveDialog::loadDictionary(Common::SeekableReadStream *in, Dict &dict
while ((ptr = strchr(ptr, '\n'))) {
*ptr = 0;
ptr++;
-#ifdef __DS__
+#if defined(__DS__) && defined(ENABLE_AGI)
// Pass the line on to the DS word list
DS::addAutoCompleteLine(dict.dictLine[i - 1]);
#endif
@@ -960,7 +960,7 @@ void PredictiveDialog::loadDictionary(Common::SeekableReadStream *in, Dict &dict
// FIXME: We use binary search on _predictiveDict.dictLine, yet we make no at_tempt
// to ever sort this array (except for the DS port). That seems risky, doesn't it?
-#ifdef __DS__
+#if defined(__DS__) && defined(ENABLE_AGI)
// Sort the DS word completion list, to allow for a binary chop later (in the ds backend)
DS::sortAutoCompleteWordList();
#endif
diff --git a/gui/recorderdialog.cpp b/gui/recorderdialog.cpp
index cd89b58f00..7a2cd048f4 100644
--- a/gui/recorderdialog.cpp
+++ b/gui/recorderdialog.cpp
@@ -167,9 +167,9 @@ void RecorderDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kRecordCmd: {
TimeDate t;
Common::String gameId = ConfMan.get("gameid", _target);
- GameDescriptor desc = EngineMan.findGame(gameId);
+ PlainGameDescriptor desc = EngineMan.findGame(gameId);
g_system->getTimeAndDate(t);
- EditRecordDialog editDlg(_("Unknown Author"), Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description(), "");
+ EditRecordDialog editDlg(_("Unknown Author"), Common::String::format("%.2d.%.2d.%.4d ", t.tm_mday, t.tm_mon, 1900 + t.tm_year) + desc.description, "");
if (editDlg.runModal() != kOKCmd) {
return;
}
diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat
index d9d35d8201..d6ad2ccbb7 100644
--- a/gui/themes/translations.dat
+++ b/gui/themes/translations.dat
Binary files differ
diff --git a/gui/unknown-game-dialog.cpp b/gui/unknown-game-dialog.cpp
new file mode 100644
index 0000000000..561d39457b
--- /dev/null
+++ b/gui/unknown-game-dialog.cpp
@@ -0,0 +1,220 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "gui/unknown-game-dialog.h"
+
+#include "common/translation.h"
+#include "common/str-array.h"
+#include "common/system.h"
+
+#include "gui/gui-manager.h"
+#include "gui/message.h"
+#include "gui/ThemeEval.h"
+#include "gui/widgets/popup.h"
+#include "gui/widgets/scrollcontainer.h"
+
+namespace GUI {
+
+enum {
+ kCopyToClipboard = 'cpcl',
+ kOpenBugtrackerURL = 'ourl',
+ kClose = 'clse',
+ kScrollContainerReflow = 'SCRf'
+};
+
+UnknownGameDialog::UnknownGameDialog(const DetectionResults &detectionResults) :
+ Dialog(30, 20, 260, 124),
+ _detectionResults(detectionResults) {
+ // For now place the buttons with a default place and size. They will be resized and moved when rebuild() is called.
+ _closeButton = new ButtonWidget(this, 0, 0, 0, 0, _("Close"), 0, kClose);
+
+ //Check if we have clipboard functionality
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ _copyToClipboardButton = new ButtonWidget(this, 0, 0, 0, 0, _("Copy to clipboard"), 0, kCopyToClipboard);
+ } else
+ _copyToClipboardButton = nullptr;
+
+#if 0
+ // Do not create the button for reporting the game directly to the bugtracker
+ // for now until we find a proper solution for the problem that a change
+ // to our bugtracker system might break the URL generation. A possible approach
+ // for solving this would be to have a ULR under the .scummvm.org (of the type
+ // https://www.scummvm.org/unknowngame?engine=Foo&description=Bar) that would
+ // redirect to whatever our bugtracker system is.
+
+ //Check if we have support for opening URLs
+ if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
+ buttonPos -= openBugtrackerURLButtonWidth + 5;
+ _openBugTrackerUrlButton = new ButtonWidget(this, 0, 0, 0, 0, _("Report game"), 0, kOpenBugtrackerURL);
+ //Formatting the reportData for bugtracker submission [replace line breaks]...
+ _bugtrackerGameData = _reportData;
+ while (_bugtrackerGameData.contains("\n")) {
+ Common::replace(_bugtrackerGameData, "\n", "%0A");
+ }
+ } else
+#endif
+ _openBugTrackerUrlButton = nullptr;
+
+ // Use a ScrollContainer for the report in case we have a lot of lines.
+ _textContainer = new ScrollContainerWidget(this, 0, 0, 0, 0, kScrollContainerReflow);
+ _textContainer->setTarget(this);
+
+ rebuild();
+}
+
+void UnknownGameDialog::reflowLayout() {
+ rebuild();
+ Dialog::reflowLayout();
+}
+
+void UnknownGameDialog::rebuild() {
+ // First remove the old text widgets
+ for (uint i = 0; i < _textWidgets.size() ; i++) {
+ _textContainer->removeWidget(_textWidgets[i]);
+ delete _textWidgets[i];
+ }
+ _textWidgets.clear();
+
+ // Work out dialog size and position of the various elements in the dialog.
+ // Limit the width of the dialog to 600 - 2 * 10 pixels.
+ const int screenW = MIN((int)g_system->getOverlayWidth(), 600);
+ const int screenH = g_system->getOverlayHeight();
+
+ int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
+ int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
+
+ Common::String reportTranslated = _detectionResults.generateUnknownGameReport(true);
+
+ // Check if we have clipboard functionality and expand the reportTranslated message if needed...
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ reportTranslated += "\n";
+ reportTranslated += _("Use the button below to copy the required game information into your clipboard.");
+ }
+
+#if 0
+ // Check if we have support for opening URLs and expand the reportTranslated message if needed...
+ if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
+ reportTranslated += "\n";
+ reportTranslated += _("You can also directly report your game to the Bug Tracker.");
+ }
+#endif
+
+ // We use a ScrollContainer to display the text, with a 2 * 8 pixels margin to the dialog border,
+ // the scrollbar, and 2 * 10 margin for the text in the container.
+ // We also keep 2 * 10 pixels between the screen border and the dialog.
+ int scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
+ Common::Array<Common::String> lines;
+ int maxlineWidth = g_gui.getFont().wordWrapText(reportTranslated, screenW - 2 * 20 - 16 - scrollbarWidth, lines);
+
+ int lineCount = lines.size() + 1;
+
+ _h = MIN(screenH - 20, lineCount * kLineHeight + kLineHeight + buttonHeight + 24);
+
+ int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_closeButton->getLabel()) + 10);
+ int copyToClipboardButtonWidth = 0, openBugtrackerURLButtonWidth = 0, totalButtonWidth = closeButtonWidth;
+ if (_copyToClipboardButton) {
+ copyToClipboardButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_copyToClipboardButton->getLabel()) + 10);
+ totalButtonWidth += copyToClipboardButtonWidth + 10;
+ }
+ if (_openBugTrackerUrlButton) {
+ openBugtrackerURLButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_openBugTrackerUrlButton->getLabel()) + 10);
+ totalButtonWidth += openBugtrackerURLButtonWidth + 10;
+ }
+
+ _w = MAX(MAX(maxlineWidth, 0) + 16 + scrollbarWidth, totalButtonWidth) + 20;
+
+ // Center the dialog on the screen
+ _x = (g_system->getOverlayWidth() - _w) / 2;
+ _y = (g_system->getOverlayHeight() - _h) / 2;
+
+ // Now move the buttons and text container to their proper place
+ int buttonPos = _w - closeButtonWidth - 10;
+ _closeButton->resize(buttonPos, _h - buttonHeight - 8, closeButtonWidth, buttonHeight);
+ if (_copyToClipboardButton) {
+ buttonPos -= copyToClipboardButtonWidth + 5;
+ _copyToClipboardButton->resize(buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight);
+ }
+ if (_openBugTrackerUrlButton) {
+ buttonPos -= openBugtrackerURLButtonWidth + 5;
+ _openBugTrackerUrlButton->resize(buttonPos, _h - buttonHeight - 8, openBugtrackerURLButtonWidth, buttonHeight);
+ }
+
+ int containerHeight = _h - kLineHeight - buttonHeight - 16;
+ _textContainer->resize(8, 8, _w - 16, containerHeight);
+
+ // And create text widgets
+ uint y = 8;
+ for (uint i = 0; i < lines.size() ; i++) {
+ StaticTextWidget *widget = new StaticTextWidget(_textContainer, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ _textWidgets.push_back(widget);
+ y += kLineHeight;
+ }
+}
+
+
+Common::String UnknownGameDialog::generateBugtrackerURL() {
+ // TODO: Remove the filesystem path from the bugtracker report
+ Common::String report = _detectionResults.generateUnknownGameReport(false);
+
+ // Formatting the report for bugtracker submission [replace line breaks]...
+ while (report.contains("\n")) {
+ Common::replace(report, "\n", "%0A");
+ }
+
+ return Common::String::format(
+ "https://bugs.scummvm.org/newticket?"
+ "&description=%s"
+ "&type=enhancement"
+ "&keywords=unknown-game",
+ report.c_str());
+}
+
+void UnknownGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch(cmd) {
+ case kCopyToClipboard: {
+ // TODO: Remove the filesystem path from the report
+ Common::String report = _detectionResults.generateUnknownGameReport(false);
+
+ if (g_system->setTextInClipboard(report)) {
+ g_system->displayMessageOnOSD(
+ _("All necessary information about your game has been copied into the clipboard"));
+ } else {
+ g_system->displayMessageOnOSD(_("Copying the game information to the clipboard has failed!"));
+ }
+ break;
+ }
+ case kClose:
+ // When the detection entry comes from the fallback detector, the game can be added / launched anyways.
+ // TODO: Add a button to cancel adding the game. And make it clear that launching the game may not work properly.
+ close();
+ break;
+ case kOpenBugtrackerURL:
+ g_system->openUrl(generateBugtrackerURL());
+ break;
+ case kScrollContainerReflow:
+ for (uint i = 0; i < _textWidgets.size() ; i++)
+ _textWidgets[i]->setVisible(true);
+ break;
+ }
+}
+
+} // End of namespace GUI
diff --git a/gui/unknown-game-dialog.h b/gui/unknown-game-dialog.h
new file mode 100644
index 0000000000..bad61d7064
--- /dev/null
+++ b/gui/unknown-game-dialog.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GUI_UNKNOWN_GAME_DIALOG_H
+#define GUI_UNKNOWN_GAME_DIALOG_H
+
+#include "gui/dialog.h"
+#include "common/array.h"
+#include "engines/game.h"
+
+namespace GUI {
+
+class StaticTextWidget;
+class ScrollContainerWidget;
+class ButtonWidget;
+
+class UnknownGameDialog : public Dialog {
+public:
+ UnknownGameDialog(const DetectionResults &detectionResults);
+
+private:
+ void rebuild();
+
+ // Dialog API
+ void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
+ void reflowLayout() override;
+
+ Common::String generateBugtrackerURL();
+
+ const DetectionResults &_detectionResults;
+ ScrollContainerWidget *_textContainer;
+ Common::Array<StaticTextWidget *> _textWidgets;
+ ButtonWidget* _openBugTrackerUrlButton;
+ ButtonWidget* _copyToClipboardButton;
+ ButtonWidget* _closeButton;
+};
+
+} // End of namespace GUI
+
+#endif
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 9993d64dbb..1dfd069f29 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -54,31 +54,6 @@ void Widget::init() {
_needsRedraw = true;
}
-Common::Rect Widget::getBossClipRect() const {
- int bx = _boss->getAbsX();
- int by = _boss->getAbsY();
- Common::Rect result = Common::Rect(bx, by, bx + _boss->getWidth(), by + _boss->getHeight());
- bool needsClipping = false;
-
- //check whether clipping area is inside the screen
- if (result.left < 0 && (needsClipping = true))
- warning("Widget <%s> has clipping area x < 0 (%d)", _name.c_str(), result.left);
- if (result.left >= g_gui.getWidth() && (needsClipping = true))
- warning("Widget <%s> has clipping area x > %d (%d)", _name.c_str(), g_gui.getWidth(), result.left);
- if (result.right > g_gui.getWidth() && (needsClipping = true))
- warning("Widget <%s> has clipping area x + w > %d (%d)", _name.c_str(), g_gui.getWidth(), result.right);
- if (result.top < 0 && (needsClipping = true))
- warning("Widget <%s> has clipping area y < 0 (%d)", _name.c_str(), result.top);
- if (result.top >= g_gui.getHeight() && (needsClipping = true))
- warning("Widget <%s> has clipping area y > %d (%d)", _name.c_str(), g_gui.getHeight(), result.top);
- if (result.bottom > g_gui.getHeight() && (needsClipping = true))
- warning("Widget <%s> has clipping area y + h > %d (%d)", _name.c_str(), g_gui.getHeight(), result.bottom);
-
- if (needsClipping)
- result.clip(g_gui.getWidth(), g_gui.getHeight());
- return result;
-}
-
Widget::~Widget() {
delete _next;
_next = 0;
@@ -134,9 +109,12 @@ void Widget::draw() {
_x = getAbsX();
_y = getAbsY();
+ Common::Rect oldClip = g_gui.theme()->swapClipRect(_boss->getClipRect());
+
// Draw border
if (_flags & WIDGET_BORDER) {
- g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
+ ThemeEngine::kWidgetBackgroundBorder);
_x += 4;
_y += 4;
_w -= 8;
@@ -146,6 +124,8 @@ void Widget::draw() {
// Now perform the actual widget draw
drawWidget();
+ g_gui.theme()->swapClipRect(oldClip);
+
// Restore x/y
if (_flags & WIDGET_BORDER) {
_x -= 4;
@@ -318,9 +298,9 @@ void StaticTextWidget::setAlign(Graphics::TextAlign align) {
void StaticTextWidget::drawWidget() {
- g_gui.theme()->drawTextClip(
- Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(),
- _label, _state, _align, ThemeEngine::kTextInversionNone, 0, true, _font
+ g_gui.theme()->drawText(
+ Common::Rect(_x, _y, _x + _w, _y + _h),
+ _label, _state, _align, ThemeEngine::kTextInversionNone, 0, true, _font
);
}
@@ -360,10 +340,7 @@ void ButtonWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
void ButtonWidget::drawWidget() {
- g_gui.theme()->drawButtonClip(
- Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(),
- _label, _state, getFlags()
- );
+ g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, getFlags());
}
void ButtonWidget::setLabel(const Common::String &label) {
@@ -411,19 +388,17 @@ void ButtonWidget::setUnpressedState() {
PicButtonWidget::PicButtonWidget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, x, y, w, h, "", tooltip, cmd, hotkey),
- _alpha(255), _transparency(false), _showButton(true), _isAlpha(false) {
+ _alpha(255), _transparency(false), _showButton(true) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
- _mode = ThemeEngine::kAutoScaleNone;
}
PicButtonWidget::PicButtonWidget(GuiObject *boss, const Common::String &name, const char *tooltip, uint32 cmd, uint8 hotkey)
: ButtonWidget(boss, name, "", tooltip, cmd, hotkey),
- _alpha(255), _transparency(false), _showButton(true), _isAlpha(false) {
+ _alpha(255), _transparency(false), _showButton(true) {
setFlags(WIDGET_ENABLED/* | WIDGET_BORDER*/ | WIDGET_CLEARBG);
_type = kButtonWidget;
- _mode = ThemeEngine::kAutoScaleNone;
}
PicButtonWidget::~PicButtonWidget() {
@@ -451,23 +426,6 @@ void PicButtonWidget::setGfx(const Graphics::Surface *gfx, int statenum) {
_gfx[statenum].copyFrom(*gfx);
}
-void PicButtonWidget::setAGfx(const Graphics::TransparentSurface *gfx, int statenum, ThemeEngine::AutoScaleMode mode) {
- _agfx[statenum].free();
-
- if (!gfx || !gfx->getPixels())
- return;
-
- if (gfx->format.bytesPerPixel == 1) {
- warning("PicButtonWidget::setGfx got paletted surface passed");
- return;
- }
-
- _agfx[statenum].copyFrom(*gfx);
-
- _isAlpha = true;
- _mode = mode;
-}
-
void PicButtonWidget::setGfx(int w, int h, int r, int g, int b, int statenum) {
if (w == -1)
w = _w;
@@ -483,62 +441,34 @@ void PicButtonWidget::setGfx(int w, int h, int r, int g, int b, int statenum) {
void PicButtonWidget::drawWidget() {
if (_showButton)
- g_gui.theme()->drawButtonClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), "", _state, getFlags());
+ g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), "", _state, getFlags());
- if (!_isAlpha) {
- Graphics::Surface *gfx;
+ Graphics::Surface *gfx;
- if (_state == ThemeEngine::kStateHighlight)
- gfx = &_gfx[kPicButtonHighlight];
- else if (_state == ThemeEngine::kStateDisabled)
- gfx = &_gfx[kPicButtonStateDisabled];
- else if (_state == ThemeEngine::kStatePressed)
- gfx = &_gfx[kPicButtonStatePressed];
- else
- gfx = &_gfx[kPicButtonStateEnabled];
+ if (_state == ThemeEngine::kStateHighlight)
+ gfx = &_gfx[kPicButtonHighlight];
+ else if (_state == ThemeEngine::kStateDisabled)
+ gfx = &_gfx[kPicButtonStateDisabled];
+ else if (_state == ThemeEngine::kStatePressed)
+ gfx = &_gfx[kPicButtonStatePressed];
+ else
+ gfx = &_gfx[kPicButtonStateEnabled];
- if (!gfx->getPixels())
- gfx = &_gfx[kPicButtonStateEnabled];
+ if (!gfx->getPixels())
+ gfx = &_gfx[kPicButtonStateEnabled];
- if (gfx->getPixels()) {
+ if (gfx->getPixels()) {
// Check whether the set up surface needs to be converted to the GUI
// color format.
- const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- if (gfx->format != requiredFormat) {
- gfx->convertToInPlace(requiredFormat);
- }
-
- const int x = _x + (_w - gfx->w) / 2;
- const int y = _y + (_h - gfx->h) / 2;
-
- g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + gfx->w, y + gfx->h), getBossClipRect(), *gfx, _state, _alpha, _transparency);
+ const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
+ if (gfx->format != requiredFormat) {
+ gfx->convertToInPlace(requiredFormat);
}
- } else {
- Graphics::TransparentSurface *gfx;
-
- if (_state == ThemeEngine::kStateHighlight)
- gfx = &_agfx[kPicButtonHighlight];
- else if (_state == ThemeEngine::kStateDisabled)
- gfx = &_agfx[kPicButtonStateDisabled];
- else if (_state == ThemeEngine::kStatePressed)
- gfx = &_agfx[kPicButtonStatePressed];
- else
- gfx = &_agfx[kPicButtonStateEnabled];
-
- if (!gfx->getPixels())
- gfx = &_agfx[kPicButtonStateEnabled];
- if (gfx->getPixels()) {
- if (_mode == GUI::ThemeEngine::kAutoScaleNone) {
- const int x = _x + (_w - gfx->w) / 2;
- const int y = _y + (_h - gfx->h) / 2;
+ const int x = _x + (_w - gfx->w) / 2;
+ const int y = _y + (_h - gfx->h) / 2;
- g_gui.theme()->drawASurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _mode, _alpha);
-
- } else {
- g_gui.theme()->drawASurface(Common::Rect(_x, _y, _x + _w, _y + _h), *gfx, _mode, _alpha);
- }
- }
+ g_gui.theme()->drawSurface(Common::Rect(x, y, x + gfx->w, y + gfx->h), *gfx, _transparency);
}
}
@@ -573,7 +503,7 @@ void CheckboxWidget::setState(bool state) {
}
void CheckboxWidget::drawWidget() {
- g_gui.theme()->drawCheckboxClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _label, _state, Widget::_state);
+ g_gui.theme()->drawCheckbox(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state);
}
#pragma mark -
@@ -642,7 +572,7 @@ void RadiobuttonWidget::setState(bool state, bool setGroup) {
}
void RadiobuttonWidget::drawWidget() {
- g_gui.theme()->drawRadiobuttonClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _label, _state, Widget::_state);
+ g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state, Widget::_state);
}
#pragma mark -
@@ -710,7 +640,7 @@ void SliderWidget::handleMouseWheel(int x, int y, int direction) {
}
void SliderWidget::drawWidget() {
- g_gui.theme()->drawSliderClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), valueToBarWidth(_value), _state);
+ g_gui.theme()->drawSlider(Common::Rect(_x, _y, _x + _w, _y + _h), valueToBarWidth(_value), _state);
}
int SliderWidget::valueToBarWidth(int value) {
@@ -764,26 +694,6 @@ void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
_gfx.copyFrom(*gfx);
}
-void GraphicsWidget::setAGfx(const Graphics::TransparentSurface *gfx, ThemeEngine::AutoScaleMode mode) {
- _agfx.free();
-
- if (!gfx || !gfx->getPixels())
- return;
-
- if (gfx->format.bytesPerPixel == 1) {
- warning("GraphicsWidget::setGfx got paletted surface passed");
- return;
- }
-
- if ((gfx->w > _w || gfx->h > _h) && mode == ThemeEngine::kAutoScaleNone) {
- warning("GraphicsWidget has size %dx%d, but a surface with %dx%d is to be set", _w, _h, gfx->w, gfx->h);
- return;
- }
-
- _agfx.copyFrom(*gfx);
- _mode = mode;
-}
-
void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
if (w == -1)
w = _w;
@@ -809,24 +719,7 @@ void GraphicsWidget::drawWidget() {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
- g_gui.theme()->drawSurfaceClip(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), getBossClipRect(), _gfx, _state, _alpha, _transparency);
- } else if (_agfx.getPixels()) {
- // Check whether the set up surface needs to be converted to the GUI
- // color format.
- const Graphics::PixelFormat &requiredFormat = g_gui.theme()->getPixelFormat();
- if (_agfx.format != requiredFormat) {
- _agfx.convertToInPlace(requiredFormat);
- }
-
- if (_mode == GUI::ThemeEngine::kAutoScaleNone) {
- const int x = _x + (_w - _agfx.w) / 2;
- const int y = _y + (_h - _agfx.h) / 2;
-
- g_gui.theme()->drawASurface(Common::Rect(x, y, x + _agfx.w, y + _agfx.h), _agfx, _mode, _alpha);
-
- } else {
- g_gui.theme()->drawASurface(Common::Rect(_x, _y, _x + _w, _y + _h), _agfx, _mode, _alpha);
- }
+ g_gui.theme()->drawSurface(Common::Rect(x, y, x + _gfx.w, y + _gfx.h), _gfx, _transparency);
}
}
@@ -867,7 +760,8 @@ void ContainerWidget::removeWidget(Widget *widget) {
}
void ContainerWidget::drawWidget() {
- g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
+ ThemeEngine::kWidgetBackgroundBorder);
}
} // End of namespace GUI
diff --git a/gui/widget.h b/gui/widget.h
index e57f3cde51..f87816b2e3 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -123,7 +123,6 @@ public:
virtual int16 getAbsX() const { return _x + _boss->getChildX(); }
virtual int16 getAbsY() const { return _y + _boss->getChildY(); }
- virtual Common::Rect getBossClipRect() const;
virtual void setPos(int x, int y) { _x = x; _y = y; }
virtual void setSize(int w, int h) { _w = w; _h = h; }
@@ -240,7 +239,6 @@ public:
~PicButtonWidget();
void setGfx(const Graphics::Surface *gfx, int statenum = kPicButtonStateEnabled);
- void setAGfx(const Graphics::TransparentSurface *gfx, int statenum = kPicButtonStateEnabled, ThemeEngine::AutoScaleMode mode = ThemeEngine::kAutoScaleNone);
void setGfx(int w, int h, int r, int g, int b, int statenum = kPicButtonStateEnabled);
void useAlpha(int alpha) { _alpha = alpha; }
@@ -251,12 +249,9 @@ protected:
void drawWidget();
Graphics::Surface _gfx[kPicButtonStateMax + 1];
- Graphics::TransparentSurface _agfx[kPicButtonStateMax + 1];
int _alpha;
bool _transparency;
bool _showButton;
- bool _isAlpha;
- ThemeEngine::AutoScaleMode _mode;
};
/* CheckboxWidget */
@@ -375,7 +370,6 @@ public:
void setGfx(const Graphics::Surface *gfx);
void setGfx(int w, int h, int r, int g, int b);
- void setAGfx(const Graphics::TransparentSurface *gfx, ThemeEngine::AutoScaleMode mode = ThemeEngine::kAutoScaleNone);
void useAlpha(int alpha) { _alpha = alpha; }
void useThemeTransparency(bool enable) { _transparency = enable; }
@@ -384,10 +378,8 @@ protected:
void drawWidget();
Graphics::Surface _gfx;
- Graphics::TransparentSurface _agfx;
int _alpha;
bool _transparency;
- ThemeEngine::AutoScaleMode _mode;
};
/* ContainerWidget */
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 5e7c94b64a..2af078f9f6 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -200,6 +200,15 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
}
break;
+ case Common::KEYCODE_c:
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport) && state.flags & Common::KBD_CTRL) {
+ if (!getEditString().empty())
+ g_system->setTextInClipboard(getEditString());
+ } else {
+ defaultKeyDownHandler(state, dirty, forcecaret, handled);
+ }
+ break;
+
#ifdef MACOSX
// Let ctrl-a / ctrl-e move the caret to the start / end of the line.
//
@@ -289,7 +298,7 @@ void EditableWidget::drawCaret(bool erase) {
x += getAbsX();
y += getAbsY();
- g_gui.theme()->drawCaretClip(Common::Rect(x, y, x + 1, y + editRect.height()), getBossClipRect(), erase);
+ g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + editRect.height()), erase);
if (erase) {
GUI::EditableWidget::String character;
@@ -318,7 +327,9 @@ void EditableWidget::drawCaret(bool erase) {
// possible glitches due to different methods used.
width = MIN(editRect.width() - caretOffset, width);
if (width > 0) {
- g_gui.theme()->drawTextClip(Common::Rect(x, y, x + width, y + editRect.height()), getBossClipRect(), character, _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
+ g_gui.theme()->drawText(Common::Rect(x, y, x + width, y + editRect.height()), character,
+ _state, Graphics::kTextAlignLeft, _inversion, 0, false, _font,
+ ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
}
diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp
index 97366741d0..b0e68985d1 100644
--- a/gui/widgets/edittext.cpp
+++ b/gui/widgets/edittext.cpp
@@ -97,7 +97,8 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) {
}
void EditTextWidget::drawWidget() {
- g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundEditText);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
+ ThemeEngine::kWidgetBackgroundEditText);
// Draw the text
adjustOffset();
@@ -105,7 +106,10 @@ void EditTextWidget::drawWidget() {
const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h);
setTextDrawableArea(r);
- g_gui.theme()->drawTextClip(Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h), getBossClipRect(), _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
+ g_gui.theme()->drawText(
+ Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
+ _editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone,
+ -_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
Common::Rect EditTextWidget::getEditRect() const {
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index df12d6fd5f..6dd4ab4dd5 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -495,7 +495,8 @@ void ListWidget::drawWidget() {
Common::String buffer;
// Draw a thin frame around the list.
- g_gui.theme()->drawWidgetBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(), 0, ThemeEngine::kWidgetBackgroundBorder);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
+ ThemeEngine::kWidgetBackgroundBorder);
// Draw the list items
for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) {
@@ -513,8 +514,8 @@ void ListWidget::drawWidget() {
// If in numbering mode, we first print a number prefix
if (_numberingMode != kListNumberingOff) {
buffer = Common::String::format("%2d. ", (pos + _numberingMode));
- g_gui.theme()->drawTextClip(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
- getBossClipRect(), buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
+ g_gui.theme()->drawText(Common::Rect(_x + _hlLeftPadding, y, _x + r.left + _leftPadding, y + fontHeight - 2),
+ buffer, _state, Graphics::kTextAlignLeft, inverted, _leftPadding, true);
pad = 0;
}
@@ -531,14 +532,12 @@ void ListWidget::drawWidget() {
buffer = _editString;
color = _editColor;
adjustOffset();
- g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
- getBossClipRect(), buffer, _state,
- Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
+ g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
+ Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
} else {
buffer = _list[pos];
- g_gui.theme()->drawTextClip(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2),
- getBossClipRect(), buffer, _state,
- Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
+ g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.right, y + fontHeight - 2), buffer, _state,
+ Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
}
}
}
diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp
index 40af769a34..a36a652e5b 100644
--- a/gui/widgets/popup.cpp
+++ b/gui/widgets/popup.cpp
@@ -50,10 +50,10 @@ public:
void drawDialog(DrawLayer layerToDraw) override;
- void handleMouseUp(int x, int y, int button, int clickCount);
- void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel
- void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position
- void handleKeyDown(Common::KeyState state); // Scroll through entries with arrow keys etc.
+ void handleMouseUp(int x, int y, int button, int clickCount) override;
+ void handleMouseWheel(int x, int y, int direction) override; // Scroll through entries with scroll wheel
+ void handleMouseMoved(int x, int y, int button) override; // Redraw selections depending on mouse position
+ void handleKeyDown(Common::KeyState state) override; // Scroll through entries with arrow keys etc.
protected:
void drawMenuEntry(int entry, bool hilite);
@@ -151,7 +151,7 @@ void PopUpDialog::drawDialog(DrawLayer layerToDraw) {
Dialog::drawDialog(layerToDraw);
// Draw the menu border
- g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x+_w, _y+_h), 0);
+ g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0);
/*if (_twoColumns)
g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/
@@ -367,10 +367,10 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
if (name.size() == 0) {
// Draw a separator
- g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x+w, y+kLineHeight));
+ g_gui.theme()->drawLineSeparator(Common::Rect(x, y, x + w, y + kLineHeight));
} else {
g_gui.theme()->drawText(
- Common::Rect(x+1, y+2, x+w, y+2+kLineHeight),
+ Common::Rect(x + 1, y + 2, x + w, y + 2 + kLineHeight),
name, hilite ? ThemeEngine::kStateHighlight : ThemeEngine::kStateEnabled,
Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone, _leftPadding
);
@@ -478,10 +478,7 @@ void PopUpWidget::drawWidget() {
Common::String sel;
if (_selectedItem >= 0)
sel = _entries[_selectedItem].name;
- g_gui.theme()->drawPopUpWidgetClip(
- Common::Rect(_x, _y, _x + _w, _y + _h), getBossClipRect(),
- sel, _leftPadding, _state, Graphics::kTextAlignLeft
- );
+ g_gui.theme()->drawPopUpWidget(Common::Rect(_x, _y, _x + _w, _y + _h), sel, _leftPadding, _state);
}
} // End of namespace GUI
diff --git a/gui/widgets/scrollbar.cpp b/gui/widgets/scrollbar.cpp
index b0e2576ec1..38cdc6fda6 100644
--- a/gui/widgets/scrollbar.cpp
+++ b/gui/widgets/scrollbar.cpp
@@ -203,11 +203,7 @@ void ScrollBarWidget::drawWidget() {
state = ThemeEngine::kScrollbarStateSlider;
}
- Common::Rect clipRect = getBossClipRect();
- //scrollbar is not a usual child of ScrollContainerWidget, so it gets this special treatment
- if (dynamic_cast<ScrollContainerWidget *>(_boss))
- clipRect.right += _w;
- g_gui.theme()->drawScrollbarClip(Common::Rect(_x, _y, _x+_w, _y+_h), clipRect, _sliderPos, _sliderHeight, state, _state);
+ g_gui.theme()->drawScrollbar(Common::Rect(_x, _y, _x + _w, _y + _h), _sliderPos, _sliderHeight, state);
}
} // End of namespace GUI
diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp
index d6b1b740fd..7994c0078d 100644
--- a/gui/widgets/scrollcontainer.cpp
+++ b/gui/widgets/scrollcontainer.cpp
@@ -140,7 +140,8 @@ void ScrollContainerWidget::reflowLayout() {
}
void ScrollContainerWidget::drawWidget() {
- g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), getBossClipRect(), ThemeEngine::kDialogBackgroundDefault);
+ g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1),
+ ThemeEngine::kDialogBackgroundDefault);
}
bool ScrollContainerWidget::containsWidget(Widget *w) const {
@@ -155,4 +156,9 @@ Widget *ScrollContainerWidget::findWidget(int x, int y) {
return Widget::findWidgetInChain(_firstWidget, x + _scrolledX, y + _scrolledY);
}
+Common::Rect ScrollContainerWidget::getClipRect() const {
+ // Make sure the clipping rect contains the scrollbar so it is properly redrawn
+ return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight());
+}
+
} // End of namespace GUI
diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h
index 9366a0b658..c4b2f716e6 100644
--- a/gui/widgets/scrollcontainer.h
+++ b/gui/widgets/scrollcontainer.h
@@ -48,6 +48,8 @@ public:
virtual bool containsWidget(Widget *) const;
+ Common::Rect getClipRect() const override;
+
protected:
// We overload getChildY to make sure child widgets are positioned correctly.
// Essentially this compensates for the space taken up by the tab title header.
diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp
index dfcb919264..977aaaf021 100644
--- a/gui/widgets/tab.cpp
+++ b/gui/widgets/tab.cpp
@@ -167,7 +167,7 @@ void TabWidget::setActiveTab(int tabID) {
}
_activeTab = tabID;
_firstWidget = _tabs[tabID].firstWidget;
-
+
// Also ensure the tab is visible in the tab bar
if (_firstVisibleTab > tabID)
setFirstVisible(tabID, true);
@@ -320,9 +320,12 @@ void TabWidget::drawWidget() {
tabs.push_back(_tabs[i].title);
widths.push_back(_tabs[i]._tabWidth);
}
- g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x + _bodyLP, _y + _bodyTP, _x+_w-_bodyRP, _y+_h-_bodyBP+_tabHeight), getBossClipRect(), _bodyBackgroundType);
+ g_gui.theme()->drawDialogBackground(
+ Common::Rect(_x + _bodyLP, _y + _bodyTP, _x + _w - _bodyRP, _y + _h - _bodyBP + _tabHeight),
+ _bodyBackgroundType);
- g_gui.theme()->drawTabClip(Common::Rect(_x, _y, _x+_w, _y+_h), getBossClipRect(), _tabHeight, widths, tabs, _activeTab - _firstVisibleTab, 0, _titleVPad);
+ g_gui.theme()->drawTab(Common::Rect(_x, _y, _x + _w, _y + _h), _tabHeight, widths, tabs,
+ _activeTab - _firstVisibleTab);
}
void TabWidget::draw() {
diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h
index bdd3e56b46..f85d30a9c6 100644
--- a/gui/widgets/tab.h
+++ b/gui/widgets/tab.h
@@ -101,15 +101,15 @@ public:
_tabs[tabID].title = title;
}
- virtual void handleMouseDown(int x, int y, int button, int clickCount);
- virtual bool handleKeyDown(Common::KeyState state);
- virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+ virtual void handleMouseDown(int x, int y, int button, int clickCount) override;
+ virtual bool handleKeyDown(Common::KeyState state) override;
+ virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
virtual int getFirstVisible() const;
virtual void setFirstVisible(int tabID, bool adjustIfRoom = false);
- virtual bool containsWidget(Widget *) const;
+ virtual bool containsWidget(Widget *) const override;
- virtual void reflowLayout();
+ virtual void reflowLayout() override;
void draw() override;
void markAsDirty() override;
@@ -117,12 +117,12 @@ public:
protected:
// We overload getChildY to make sure child widgets are positioned correctly.
// Essentially this compensates for the space taken up by the tab title header.
- virtual int16 getChildY() const;
- virtual uint16 getHeight() const;
+ virtual int16 getChildY() const override;
+ virtual uint16 getHeight() const override;
- virtual void drawWidget();
+ virtual void drawWidget() override;
- virtual Widget *findWidget(int x, int y);
+ virtual Widget *findWidget(int x, int y) override;
virtual void adjustTabs(int value);