[Scummvm-git-logs] scummvm master -> 8cb9eebd8a8f7cae2dbb68ad3398f444426929c1
criezy
criezy at scummvm.org
Sun Apr 29 22:48:00 CEST 2018
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3fe0e3c38e OSYSTEM: Add API to copy text to clipboard
0dae57ab2f SDL: Handle encoding conversion for clipboard text
e79fc3ac76 OSX: Handle encoding conversion for clipboard text
6ab6d76792 GUI: Add copy to clipboard shortcut for EditableWidget
05c1e593c0 COMMON: Add hasInstance() bool to singleton class
4220e14522 ENGINES: Add a dialog for reporting unknown games
451cf2304f ENGINES: Show the unknown Game dialog only when the detector is launched by the Add Game feature
e3ffdb4ca1 GUI: Disable the button for reporting a unknown game directly to the bugtracker for now
cf529f311f ENGINES: Use ScrollContainerWidget in unknown game dialog
8cb9eebd8a ENGINES: Improve update of the Unknown Game Dialog when the overlay size changes
Commit: 3fe0e3c38ee63534486a4353cdab1cfc76dab74f
https://github.com/scummvm/scummvm/commit/3fe0e3c38ee63534486a4353cdab1cfc76dab74f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
OSYSTEM: Add API to copy text to clipboard
This has also been implemented for the SDL2 and macOS backends.
Changed paths:
backends/platform/sdl/macosx/macosx.cpp
backends/platform/sdl/macosx/macosx.h
backends/platform/sdl/macosx/macosx_wrapper.h
backends/platform/sdl/macosx/macosx_wrapper.mm
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
common/system.h
diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 8ecbe73..6203720 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -124,6 +124,10 @@ Common::String OSystem_MacOSX::getTextFromClipboard() {
return getTextFromClipboardMacOSX();
}
+bool OSystem_MacOSX::setTextInClipboard(const Common::String &text) {
+ return setTextInClipboardMacOSX(text);
+}
+
bool OSystem_MacOSX::openUrl(const Common::String &url) {
CFURLRef urlRef = CFURLCreateWithBytes (NULL, (UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL);
OSStatus err = LSOpenCFURLRef(urlRef, NULL);
diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h
index ba07364..5ef30ba 100644
--- a/backends/platform/sdl/macosx/macosx.h
+++ b/backends/platform/sdl/macosx/macosx.h
@@ -35,6 +35,7 @@ public:
virtual bool hasTextInClipboard();
virtual Common::String getTextFromClipboard();
+ virtual bool setTextInClipboard(const Common::String &text);
virtual bool openUrl(const Common::String &url);
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h
index 84f0c1b..ca4e433 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.h
+++ b/backends/platform/sdl/macosx/macosx_wrapper.h
@@ -27,6 +27,7 @@
bool hasTextInClipboardMacOSX();
Common::String getTextFromClipboardMacOSX();
+bool setTextInClipboardMacOSX(const Common::String &text);
Common::String getDesktopPathMacOSX();
#endif
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm
index 02516e5..0a1478f 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.mm
+++ b/backends/platform/sdl/macosx/macosx_wrapper.mm
@@ -40,7 +40,7 @@ Common::String getTextFromClipboardMacOSX() {
// Note: on OS X 10.6 and above it is recommanded to use NSPasteboardTypeString rather than NSStringPboardType.
// But since we still target older version use NSStringPboardType.
NSPasteboard *pb = [NSPasteboard generalPasteboard];
- NSString* str = [pb stringForType:NSStringPboardType];
+ NSString *str = [pb stringForType:NSStringPboardType];
if (str == nil)
return Common::String();
// If the string cannot be represented using the requested encoding we get a null pointer below.
@@ -49,6 +49,12 @@ Common::String getTextFromClipboardMacOSX() {
return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]);
}
+bool setTextInClipboardMacOSX(const Common::String &text) {
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+ return [pb setString:[NSString stringWithCString:text.c_str() encoding:NSASCIIStringEncoding] forType:NSStringPboardType];
+}
+
Common::String getDesktopPathMacOSX() {
// The recommanded method is to use NSFileManager.
// NSUrl *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask] firstObject];
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 3082a69..8a60e92 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -513,6 +513,15 @@ Common::String OSystem_SDL::getTextFromClipboard() {
#endif
}
+bool OSystem_SDL::setTextInClipboard(const Common::String &text) {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ // FIXME: The string we get from SDL is in UTF-8 and should probably be converted.
+ return SDL_SetClipboardText(text.c_str()) == 0;
+#else
+ return false;
+#endif
+}
+
uint32 OSystem_SDL::getMillis(bool skipRecord) {
uint32 millis = SDL_GetTicks();
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 61513fa..c746d2d 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -72,6 +72,7 @@ public:
// Clipboard
virtual bool hasTextInClipboard();
virtual Common::String getTextFromClipboard();
+ virtual bool setTextInClipboard(const Common::String &text);
virtual void setWindowCaption(const char *caption);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
diff --git a/common/system.h b/common/system.h
index 206c313..a0034ee 100644
--- a/common/system.h
+++ b/common/system.h
@@ -324,8 +324,8 @@ public:
kFeatureDisplayLogFile,
/**
- * The presence of this feature indicates whether the hasTextInClipboard()
- * and getTextFromClipboard() calls are supported.
+ * The presence of this feature indicates whether the hasTextInClipboard(),
+ * getTextFromClipboard() and setTextInClipboard() calls are supported.
*
* This feature has no associated state.
*/
@@ -1336,6 +1336,17 @@ public:
virtual Common::String getTextFromClipboard() { return ""; }
/**
+ * Set the content of the clipboard to the given string.
+ *
+ * The kFeatureClipboardSupport feature flag can be used to
+ * test whether this call has been implemented by the active
+ * backend.
+ *
+ * @return true if the text was properly set in the clipboard, false otherwise
+ */
+ virtual bool setTextInClipboard(const Common::String &text) { return false; }
+
+ /**
* Open the given Url in the default browser (if available on the target
* system).
*
Commit: 0dae57ab2f921eef19aa6f4a357d0569c2036cc8
https://github.com/scummvm/scummvm/commit/0dae57ab2f921eef19aa6f4a357d0569c2036cc8
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
SDL: Handle encoding conversion for clipboard text
Changed paths:
backends/platform/sdl/sdl.cpp
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 8a60e92..72af6d5 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -33,6 +33,7 @@
#include "gui/EventRecorder.h"
#include "common/taskbar.h"
#include "common/textconsole.h"
+#include "common/translation.h"
#include "backends/saves/default/default-saves.h"
@@ -502,11 +503,20 @@ Common::String OSystem_SDL::getTextFromClipboard() {
#if SDL_VERSION_ATLEAST(2, 0, 0)
char *text = SDL_GetClipboardText();
+ // The string returned by SDL is in UTF-8. Convert to the
+ // current TranslationManager encoding or ISO-8859-1.
+#ifdef USE_TRANSLATION
+ char *conv_text = SDL_iconv_string(TransMan.getCurrentCharset().c_str(), "UTF-8", text, SDL_strlen(text) + 1);
+#else
+ char *conv_text = SDL_iconv_string("ISO-8859-1", "UTF-8", text, SDL_strlen(text) + 1);
+#endif
+ if (conv_text) {
+ SDL_free(text);
+ text = conv_text;
+ }
Common::String strText = text;
SDL_free(text);
- // FIXME: The string returned by SDL is in UTF-8, it is not clear
- // what encoding should be used for the returned string.
return strText;
#else
return "";
@@ -515,7 +525,18 @@ Common::String OSystem_SDL::getTextFromClipboard() {
bool OSystem_SDL::setTextInClipboard(const Common::String &text) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
- // FIXME: The string we get from SDL is in UTF-8 and should probably be converted.
+ // The encoding we need to use is UTF-8. Assume we currently have the
+ // current TranslationManager encoding or ISO-8859-1.
+#ifdef USE_TRANSLATION
+ char *utf8_text = SDL_iconv_string("UTF-8", TransMan.getCurrentCharset().c_str(), text.c_str(), text.size() + 1);
+#else
+ char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", text.c_str(), text.size() + 1);
+#endif
+ if (utf8_text) {
+ int status = SDL_SetClipboardText(utf8_text);
+ SDL_free(utf8_text);
+ return status == 0;
+ }
return SDL_SetClipboardText(text.c_str()) == 0;
#else
return false;
Commit: e79fc3ac7644552a62ebe459ee5abb024ff73e20
https://github.com/scummvm/scummvm/commit/e79fc3ac7644552a62ebe459ee5abb024ff73e20
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
OSX: Handle encoding conversion for clipboard text
Changed paths:
backends/platform/sdl/macosx/macosx_wrapper.mm
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm
index 0a1478f..32dfa04 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.mm
+++ b/backends/platform/sdl/macosx/macosx_wrapper.mm
@@ -24,11 +24,13 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "backends/platform/sdl/macosx/macosx_wrapper.h"
+#include "common/translation.h"
#include <AppKit/NSPasteboard.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSPathUtilities.h>
#include <AvailabilityMacros.h>
+#include <CoreFoundation/CFString.h>
bool hasTextInClipboardMacOSX() {
return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil;
@@ -43,16 +45,30 @@ Common::String getTextFromClipboardMacOSX() {
NSString *str = [pb stringForType:NSStringPboardType];
if (str == nil)
return Common::String();
- // If the string cannot be represented using the requested encoding we get a null pointer below.
- // This is fine as ScummVM would not know what to do with non-ASCII characters (although maybe
- // we should use NSISOLatin1StringEncoding?).
- return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]);
+
+ // If translations are supported, use the current TranslationManager charset and otherwise
+ // use ASCII. If the string cannot be represented using the requested encoding we get a null
+ // pointer below, which is fine as ScummVM would not know what to do with the string anyway.
+#ifdef USE_TRANSLATION
+ NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding];
+ NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr));
+#else
+ NSStringEncoding encoding = NSISOLatin1StringEncoding;
+#endif
+ return Common::String([str cStringUsingEncoding:encoding]);
}
bool setTextInClipboardMacOSX(const Common::String &text) {
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
- return [pb setString:[NSString stringWithCString:text.c_str() encoding:NSASCIIStringEncoding] forType:NSStringPboardType];
+
+#ifdef USE_TRANSLATION
+ NSString* encStr = [NSString stringWithCString:TransMan.getCurrentCharset().c_str() encoding:NSASCIIStringEncoding];
+ NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)encStr));
+#else
+ NSStringEncoding encoding = NSISOLatin1StringEncoding;
+#endif
+ return [pb setString:[NSString stringWithCString:text.c_str() encoding:encoding] forType:NSStringPboardType];
}
Common::String getDesktopPathMacOSX() {
Commit: 6ab6d767928b6fdc27bc4b484c2831d029d3c049
https://github.com/scummvm/scummvm/commit/6ab6d767928b6fdc27bc4b484c2831d029d3c049
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
GUI: Add copy to clipboard shortcut for EditableWidget
Changed paths:
gui/widgets/editable.cpp
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 339870f..2af078f 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.
//
Commit: 05c1e593c03a2298c50f55b58ef48d70a9ce9b6d
https://github.com/scummvm/scummvm/commit/05c1e593c03a2298c50f55b58ef48d70a9ce9b6d
Author: Lothar Serra Mari (serra at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
COMMON: Add hasInstance() bool to singleton class
Changed paths:
common/singleton.h
diff --git a/common/singleton.h b/common/singleton.h
index 9bcd590..7deb1dd 100644
--- a/common/singleton.h
+++ b/common/singleton.h
@@ -59,6 +59,10 @@ public:
public:
+ static bool hasInstance() {
+ return _singleton != 0;
+ }
+
static T& instance() {
// TODO: We aren't thread safe. For now we ignore it since the
// only thing using this singleton template is the config manager,
Commit: 4220e14522c69205e08de8c2676b6fdc858e5a42
https://github.com/scummvm/scummvm/commit/4220e14522c69205e08de8c2676b6fdc858e5a42
Author: Lothar Serra Mari (serra at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
ENGINES: Add a dialog for reporting unknown games
Thanks to the great help of @criezy, here's my implementation of an GUI
dialog that appears when an unknown game is detected.
Features:
- Allows copying the data collected by game detector to the clipboard
- Allows opening the bug tracker and pre-filling the form fiels
This closes https://bugs.scummvm.org/ticket/10435.
Changed paths:
A engines/unknown-game-dialog.cpp
A engines/unknown-game-dialog.h
engines/advancedDetector.cpp
engines/module.mk
po/POTFILES
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 9d69505..1cf18f0 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -30,6 +30,8 @@
#include "common/textconsole.h"
#include "common/translation.h"
#include "gui/EventRecorder.h"
+#include "gui/gui-manager.h"
+#include "engines/unknown-game-dialog.h"
#include "engines/advancedDetector.h"
#include "engines/obsolete.h"
@@ -326,36 +328,55 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
}
void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds) const {
- Common::String report = Common::String::format(
- _("The game in '%s' seems to be an unknown %s engine game "
- "variant.\n\nPlease report the following data to the ScummVM "
- "team at %s along with the name of the game you tried to add and "
- "its version, language, etc.:"),
- path.getPath().c_str(), getName(), "https://bugs.scummvm.org/");
+ const char *reportCommon = "The game in '%s' seems to be an unknown %s engine game "
+ "variant.\n\nPlease report the following data to the ScummVM "
+ "team at %s along with the name of the game you tried to add and "
+ "its version, language, etc.:";
+ Common::String report = Common::String::format(reportCommon, path.getPath().c_str(), getName(), "https://bugs.scummvm.org/");
+ Common::String reportTranslated = Common::String::format(_(reportCommon), path.getPath().c_str(), getName(), "https://bugs.scummvm.org/");
+ Common::String bugtrackerAffectedEngine = getName();
if (matchedGameIds.size()) {
report += "\n\n";
- report += _("Matched game IDs:");
+ reportTranslated += "\n\n";
+ report += "Matched game IDs:";
+ reportTranslated += _("Matched game IDs:");
report += " ";
+ reportTranslated += " ";
for (ADGameIdList::const_iterator gameId = matchedGameIds.begin(); gameId != matchedGameIds.end(); ++gameId) {
if (gameId != matchedGameIds.begin()) {
report += ", ";
+ reportTranslated += ", ";
}
report += *gameId;
+ reportTranslated += *gameId;
}
}
report += "\n\n";
+ reportTranslated += "\n\n";
- report.wordWrap(80);
+ reportTranslated.wordWrap(65);
+ Common::String reportLog = report;
+ reportLog.wordWrap(80);
+ Common::String unknownFiles;
for (ADFilePropertiesMap::const_iterator file = filesProps.begin(); file != filesProps.end(); ++file)
- report += Common::String::format(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size);
+ unknownFiles += Common::String::format(" {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size);
- report += "\n";
+ report += unknownFiles;
+ reportTranslated += unknownFiles;
+ reportLog += unknownFiles + "\n";
- g_system->logMessage(LogMessageType::kInfo, report.c_str());
+ // Write the original message about the unknown game to the log file
+ g_system->logMessage(LogMessageType::kInfo, reportLog.c_str());
+
+ // Check if the GUI is running, show the UnknownGameDialog and print the translated unknown game information
+ if (GUI::GuiManager::hasInstance() && g_gui.isActive()) {
+ UnknownGameDialog dialog(report, reportTranslated, bugtrackerAffectedEngine);
+ dialog.runModal();
+ }
}
void AdvancedMetaEngine::composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName) const {
diff --git a/engines/module.mk b/engines/module.mk
index 7849c2f..6c05921 100644
--- a/engines/module.mk
+++ b/engines/module.mk
@@ -6,7 +6,8 @@ MODULE_OBJS := \
engine.o \
game.o \
obsolete.o \
- savestate.o
+ savestate.o \
+ unknown-game-dialog.o
# Include common rules
include $(srcdir)/rules.mk
diff --git a/engines/unknown-game-dialog.cpp b/engines/unknown-game-dialog.cpp
new file mode 100644
index 0000000..5b124a7
--- /dev/null
+++ b/engines/unknown-game-dialog.cpp
@@ -0,0 +1,145 @@
+/* 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 "common/translation.h"
+#include "common/str-array.h"
+#include "gui/gui-manager.h"
+#include "gui/message.h"
+#include "gui/ThemeEval.h"
+#include "gui/widgets/popup.h"
+#include "engines/unknown-game-dialog.h"
+#include "backends/platform/sdl/sdl.h"
+
+enum {
+ kCopyToClipboard = 'cpcl',
+ kOpenBugtrackerURL = 'ourl',
+ kClose = 'clse'
+};
+
+UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Common::String &reportTranslated, const Common::String &bugtrackerAffectedEngine)
+ : Dialog(30, 20, 260, 124) {
+
+ _reportData = reportData;
+ _reportTranslated = reportTranslated;
+ _bugtrackerAffectedEngine = bugtrackerAffectedEngine;
+
+ //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.");
+ }
+
+ //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!");
+ }
+
+ const int screenW = g_system->getOverlayWidth();
+ const int screenH = g_system->getOverlayHeight();
+
+ int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
+ int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
+
+ //Calculate the size the dialog needs
+ Common::Array<Common::String> lines;
+ int maxlineWidth = g_gui.getFont().wordWrapText(_reportTranslated, screenW - 2 * 20, lines);
+ int lineCount = lines.size() + 1;
+
+ _h = 3 * kLineHeight + lineCount * kLineHeight;
+
+ // Buttons
+ int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Close")) + 10);
+ int copyToClipboardButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Copy to clipboard")) + 10);
+ int openBugtrackerURLButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Report game")) + 10);
+ int totalButtonWidth = closeButtonWidth;
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport))
+ totalButtonWidth += 10 + copyToClipboardButtonWidth;
+ if (g_system->hasFeature(OSystem::kFeatureOpenUrl))
+ totalButtonWidth += 10 + openBugtrackerURLButtonWidth;
+
+ _w = MAX(MAX(maxlineWidth, 0), totalButtonWidth) + 20;
+
+ int buttonPos = _w - closeButtonWidth - 10;
+ new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Close"), 0, kClose);
+
+ //Check if we have clipboard functionality
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ buttonPos -= copyToClipboardButtonWidth + 5;
+ new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight, _("Copy to clipboard"), 0, kCopyToClipboard);
+ }
+
+ //Check if we have support for opening URLs
+ if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
+ buttonPos -= openBugtrackerURLButtonWidth + 5;
+ new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, openBugtrackerURLButtonWidth, buttonHeight, _("Report game"), 0, kOpenBugtrackerURL);
+ //Formatting the reportData for bugtracker submission [replace line breaks]...
+ _bugtrackerGameData = _reportData;
+ while (_bugtrackerGameData.contains("\n")) {
+ Common::replace(_bugtrackerGameData, "\n", "%0A");
+ }
+ }
+
+ // Each line is represented by one static text item.
+ // TODO: Use a ScrollContainer widget instead of truncated text.
+ uint y = 10;
+ for (uint i = 0; i < lines.size(); i++) {
+ new GUI::StaticTextWidget(this, 10, y, _w, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ y += kLineHeight;
+ }
+}
+
+void UnknownGameDialog::reflowLayout() {
+ _x = (g_system->getOverlayWidth() - _w) / 2;
+ _y = (g_system->getOverlayHeight() - _h) / 2;
+ GUI::Dialog::reflowLayout();
+}
+
+Common::String UnknownGameDialog::generateBugtrackerURL() {
+ return Common::String::format((
+ "https://bugs.scummvm.org/newticket?"
+ "summary=[UNK] Unknown game for engine %s:"
+ "&description=%s"
+ "&component=Engine%%3A%s"
+ "&type=enhancement"
+ "&keywords=unknown-game,%s"),
+ _bugtrackerAffectedEngine.c_str(), _bugtrackerGameData.c_str(), _bugtrackerAffectedEngine.c_str(), _bugtrackerAffectedEngine.c_str());
+}
+
+void UnknownGameDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ switch(cmd) {
+ case kCopyToClipboard:
+ g_system->setTextInClipboard(_reportData);
+ if (g_system->setTextInClipboard(_reportData)) {
+ 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:
+ close();
+ break;
+ case kOpenBugtrackerURL:
+ g_system->openUrl(generateBugtrackerURL());
+ break;
+ }
+}
diff --git a/engines/unknown-game-dialog.h b/engines/unknown-game-dialog.h
new file mode 100644
index 0000000..51adf27
--- /dev/null
+++ b/engines/unknown-game-dialog.h
@@ -0,0 +1,37 @@
+/* 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/dialog.h"
+
+class UnknownGameDialog : public GUI::Dialog {
+public:
+ UnknownGameDialog(const Common::String &reportData, const Common::String &reportTranslated, const Common::String &bugtrackerAffectedEngine);
+ void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
+ virtual Common::String generateBugtrackerURL();
+ virtual void reflowLayout();
+
+private:
+ Common::String _reportData;
+ Common::String _reportTranslated;
+ Common::String _bugtrackerGameData;
+ Common::String _bugtrackerAffectedEngine;
+};
diff --git a/po/POTFILES b/po/POTFILES
index ac48660..451db74 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -35,6 +35,7 @@ common/updates.cpp
engines/advancedDetector.cpp
engines/dialogs.cpp
engines/engine.cpp
+engines/unknown-game-dialog.cpp
audio/adlib.cpp
audio/fmopl.cpp
Commit: 451cf2304f8e27b3f5aab9cfa56d7b9bcdc8ffcf
https://github.com/scummvm/scummvm/commit/451cf2304f8e27b3f5aab9cfa56d7b9bcdc8ffcf
Author: Lothar Serra Mari (serra at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
ENGINES: Show the unknown Game dialog only when the detector is launched by the Add Game feature
Changed paths:
base/plugins.cpp
engines/adl/detection.cpp
engines/advancedDetector.cpp
engines/advancedDetector.h
engines/metaengine.h
engines/scumm/detection.cpp
engines/sky/detection.cpp
engines/sword1/detection.cpp
engines/sword2/sword2.cpp
gui/launcher.cpp
diff --git a/base/plugins.cpp b/base/plugins.cpp
index b8f63fd..8527869 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -514,7 +514,7 @@ GameDescriptor EngineManager::findGameInLoadedPlugins(const Common::String &game
return result;
}
-GameList EngineManager::detectGames(const Common::FSList &fslist) const {
+GameList EngineManager::detectGames(const Common::FSList &fslist, bool useUnknownGameDialog) const {
GameList candidates;
PluginList plugins;
PluginList::const_iterator iter;
@@ -524,7 +524,7 @@ GameList EngineManager::detectGames(const Common::FSList &fslist) const {
// Iterate over all known games and for each check if it might be
// the game in the presented directory.
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
- candidates.push_back((*iter)->get<MetaEngine>().detectGames(fslist));
+ candidates.push_back((*iter)->get<MetaEngine>().detectGames(fslist, useUnknownGameDialog));
}
} while (PluginManager::instance().loadNextPlugin());
return candidates;
diff --git a/engines/adl/detection.cpp b/engines/adl/detection.cpp
index ab634bc..14646c7 100644
--- a/engines/adl/detection.cpp
+++ b/engines/adl/detection.cpp
@@ -332,7 +332,7 @@ public:
int getMaximumSaveSlot() const { return 'O' - 'A'; }
SaveStateList listSaves(const char *target) const;
void removeSaveState(const char *target, int slot) const;
- virtual ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
+ virtual ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, bool useUnknownGameDialog = false) const;
bool addFileProps(const FileMap &allFiles, Common::String fname, ADFilePropertiesMap &filePropsMap) const;
@@ -511,9 +511,9 @@ bool AdlMetaEngine::addFileProps(const FileMap &allFiles, Common::String fname,
}
// Based on AdvancedMetaEngine::detectGame
-ADGameDescList AdlMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const {
+ADGameDescList AdlMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, bool useUnknownGameDialog) const {
// We run the file-based detector first and then add to the returned list
- ADGameDescList matched = AdvancedMetaEngine::detectGame(parent, allFiles, language, platform, extra);
+ ADGameDescList matched = AdvancedMetaEngine::detectGame(parent, allFiles, language, platform, extra, useUnknownGameDialog);
debug(3, "Starting disk image detection in dir '%s'", parent.getPath().c_str());
@@ -605,7 +605,7 @@ ADGameDescList AdlMetaEngine::detectGame(const Common::FSNode &parent, const Fil
// TODO: This could be improved to handle matched and unknown games together in a single directory
if (matched.empty()) {
if (!filesProps.empty() && gotAnyMatchesWithAllFiles) {
- reportUnknown(parent, filesProps, matchedGameIds);
+ reportUnknown(parent, filesProps, matchedGameIds, useUnknownGameDialog);
}
}
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 1cf18f0..dbe2cdf 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -150,7 +150,7 @@ bool cleanupPirated(ADGameDescList &matched) {
}
-GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
+GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist, bool useUnknownGameDialog) const {
ADGameDescList matches;
GameList detectedGames;
FileMap allFiles;
@@ -162,7 +162,7 @@ GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth));
// Run the detector on this
- matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "");
+ matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "", useUnknownGameDialog);
if (matches.empty()) {
// Use fallback detector if there were no matches by other means
@@ -327,7 +327,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
return Common::kNoError;
}
-void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds) const {
+void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds, bool useUnknownGameDialog) const {
const char *reportCommon = "The game in '%s' seems to be an unknown %s engine game "
"variant.\n\nPlease report the following data to the ScummVM "
"team at %s along with the name of the game you tried to add and "
@@ -373,7 +373,7 @@ void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFileP
g_system->logMessage(LogMessageType::kInfo, reportLog.c_str());
// Check if the GUI is running, show the UnknownGameDialog and print the translated unknown game information
- if (GUI::GuiManager::hasInstance() && g_gui.isActive()) {
+ if (GUI::GuiManager::hasInstance() && g_gui.isActive() && useUnknownGameDialog == true) {
UnknownGameDialog dialog(report, reportTranslated, bugtrackerAffectedEngine);
dialog.runModal();
}
@@ -449,7 +449,7 @@ bool AdvancedMetaEngine::getFileProperties(const Common::FSNode &parent, const F
return true;
}
-ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const {
+ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, bool useUnknownGameDialog) const {
ADFilePropertiesMap filesProps;
const ADGameFileDescription *fileDesc;
@@ -574,7 +574,7 @@ ADGameDescList AdvancedMetaEngine::detectGame(const Common::FSNode &parent, cons
// We didn't find a match
if (matched.empty()) {
if (!filesProps.empty() && gotAnyMatchesWithAllFiles) {
- reportUnknown(parent, filesProps, matchedGameIds);
+ reportUnknown(parent, filesProps, matchedGameIds, useUnknownGameDialog);
}
// Filename based fallback
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 7bd7de3..d7e85f8 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -278,7 +278,7 @@ public:
virtual GameDescriptor findGame(const char *gameId) const;
- virtual GameList detectGames(const Common::FSList &fslist) const;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
@@ -313,7 +313,7 @@ protected:
* @param extra restrict results to specified extra string (only if kADFlagUseExtraAsHint is set)
* @return list of ADGameDescription pointers corresponding to matched games
*/
- virtual ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
+ virtual ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, bool useUnknownGameDialog = false) const;
/**
* Iterates over all ADFileBasedFallback records inside fileBasedFallback.
@@ -333,7 +333,7 @@ protected:
* Log and print a report that we found an unknown game variant, together with the file
* names, sizes and MD5 sums.
*/
- void reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds = ADGameIdList()) const;
+ void reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds = ADGameIdList(), bool useUnknownGameDialog = false) const;
// TODO
void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;
diff --git a/engines/metaengine.h b/engines/metaengine.h
index b3aaa96..68f4b36 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -79,7 +79,7 @@ public:
* (possibly empty) list of games supported by the engine which it was able
* to detect amongst the given files.
*/
- virtual GameList detectGames(const Common::FSList &fslist) const = 0;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const = 0;
/**
* Tries to instantiate an engine instance based on the settings of
@@ -269,7 +269,7 @@ class EngineManager : public Common::Singleton<EngineManager> {
public:
GameDescriptor findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin = NULL) const;
GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL) const;
- GameList detectGames(const Common::FSList &fslist) const;
+ GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
const PluginList &getPlugins() const;
};
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 0aa993a..37302e3 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -961,7 +961,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual GameList getSupportedGames() const;
virtual GameDescriptor findGame(const char *gameid) const;
- virtual GameList detectGames(const Common::FSList &fslist) const;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
@@ -1026,7 +1026,7 @@ static Common::String generatePreferredTarget(const DetectorResult &x) {
return res;
}
-GameList ScummMetaEngine::detectGames(const Common::FSList &fslist) const {
+GameList ScummMetaEngine::detectGames(const Common::FSList &fslist, bool /*useUnknownGameDialog*/) const {
GameList detectedGames;
Common::List<DetectorResult> results;
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index b5425f9..a74b63f 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -79,7 +79,7 @@ public:
virtual GameList getSupportedGames() const;
virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
virtual GameDescriptor findGame(const char *gameid) const;
- virtual GameList detectGames(const Common::FSList &fslist) const;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
virtual Common::Error createInstance(OSystem *syst, Engine **engine) const;
@@ -141,7 +141,7 @@ GameDescriptor SkyMetaEngine::findGame(const char *gameid) const {
return GameDescriptor();
}
-GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const {
+GameList SkyMetaEngine::detectGames(const Common::FSList &fslist, bool /*useUnknownGameDialog*/) const {
GameList detectedGames;
bool hasSkyDsk = false;
bool hasSkyDnr = false;
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 0b81690..ddfc4b8 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -89,7 +89,7 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual GameList getSupportedGames() const;
virtual GameDescriptor findGame(const char *gameid) const;
- virtual GameList detectGames(const Common::FSList &fslist) const;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
@@ -175,7 +175,7 @@ void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool r
}
}
-GameList SwordMetaEngine::detectGames(const Common::FSList &fslist) const {
+GameList SwordMetaEngine::detectGames(const Common::FSList &fslist, bool /*useUnknownGameDialog*/) const {
int i, j;
GameList detectedGames;
bool filesFound[NUM_FILES_TO_CHECK];
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index a2761eb..10ddda7 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -95,7 +95,7 @@ public:
virtual GameList getSupportedGames() const;
virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
virtual GameDescriptor findGame(const char *gameid) const;
- virtual GameList detectGames(const Common::FSList &fslist) const;
+ virtual GameList detectGames(const Common::FSList &fslist, bool useUnknownGameDialog = false) const;
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
@@ -223,7 +223,7 @@ GameList detectGamesImpl(const Common::FSList &fslist, bool recursion = false) {
return detectedGames;
}
-GameList Sword2MetaEngine::detectGames(const Common::FSList &fslist) const {
+GameList Sword2MetaEngine::detectGames(const Common::FSList &fslist, bool /*useUnknownGameDialog*/) const {
return detectGamesImpl(fslist);
}
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 4fe1ae7..857d7d0 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -573,7 +573,7 @@ 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));
+ GameList candidates(EngineMan.detectGames(files, true));
int idx;
if (candidates.empty()) {
Commit: e3ffdb4ca1a5ec543626b996e905a3c3b74ae653
https://github.com/scummvm/scummvm/commit/e3ffdb4ca1a5ec543626b996e905a3c3b74ae653
Author: Lothar Serra Mari (serra at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
GUI: Disable the button for reporting a unknown game directly to the bugtracker for now
Changed paths:
engines/unknown-game-dialog.cpp
diff --git a/engines/unknown-game-dialog.cpp b/engines/unknown-game-dialog.cpp
index 5b124a7..33efdcc 100644
--- a/engines/unknown-game-dialog.cpp
+++ b/engines/unknown-game-dialog.cpp
@@ -48,11 +48,13 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
_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
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();
@@ -88,6 +90,14 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight, _("Copy to clipboard"), 0, kCopyToClipboard);
}
+#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;
@@ -98,6 +108,7 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
Common::replace(_bugtrackerGameData, "\n", "%0A");
}
}
+#endif
// Each line is represented by one static text item.
// TODO: Use a ScrollContainer widget instead of truncated text.
Commit: cf529f311f0be1332f6286b95741160e85651441
https://github.com/scummvm/scummvm/commit/cf529f311f0be1332f6286b95741160e85651441
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
ENGINES: Use ScrollContainerWidget in unknown game dialog
This should fix issues when the text to display in the dialog is too
big to fit on the screen.
Changed paths:
engines/unknown-game-dialog.cpp
engines/unknown-game-dialog.h
diff --git a/engines/unknown-game-dialog.cpp b/engines/unknown-game-dialog.cpp
index 33efdcc..91a593c 100644
--- a/engines/unknown-game-dialog.cpp
+++ b/engines/unknown-game-dialog.cpp
@@ -26,13 +26,15 @@
#include "gui/message.h"
#include "gui/ThemeEval.h"
#include "gui/widgets/popup.h"
+#include "gui/widgets/scrollcontainer.h"
#include "engines/unknown-game-dialog.h"
#include "backends/platform/sdl/sdl.h"
enum {
kCopyToClipboard = 'cpcl',
kOpenBugtrackerURL = 'ourl',
- kClose = 'clse'
+ kClose = 'clse',
+ kScrollContainerReflow = 'SCRf'
};
UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Common::String &reportTranslated, const Common::String &bugtrackerAffectedEngine)
@@ -63,11 +65,16 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
//Calculate the size the dialog needs
+ // 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, lines);
+ int maxlineWidth = g_gui.getFont().wordWrapText(_reportTranslated, screenW - 2 * 20 - 16 - scrollbarWidth, lines);
+
int lineCount = lines.size() + 1;
- _h = 3 * kLineHeight + lineCount * kLineHeight;
+ _h = MIN(screenH - 20, lineCount * kLineHeight + kLineHeight + buttonHeight + 24);
// Buttons
int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Close")) + 10);
@@ -79,7 +86,7 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
if (g_system->hasFeature(OSystem::kFeatureOpenUrl))
totalButtonWidth += 10 + openBugtrackerURLButtonWidth;
- _w = MAX(MAX(maxlineWidth, 0), totalButtonWidth) + 20;
+ _w = MAX(MAX(maxlineWidth, 0) + 16 + scrollbarWidth, totalButtonWidth) + 20;
int buttonPos = _w - closeButtonWidth - 10;
new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Close"), 0, kClose);
@@ -111,10 +118,14 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
#endif
// Each line is represented by one static text item.
- // TODO: Use a ScrollContainer widget instead of truncated text.
- uint y = 10;
- for (uint i = 0; i < lines.size(); i++) {
- new GUI::StaticTextWidget(this, 10, y, _w, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ // Use a ScrollContainer for the report in case we have a lot of lines.
+ int containerHeight = _h - kLineHeight - buttonHeight - 8;
+ GUI::ScrollContainerWidget *container = new GUI::ScrollContainerWidget(this, 8, 8, _w - 16, containerHeight, kScrollContainerReflow);
+ container->setTarget(this);
+ uint y = 8;
+ for (uint i = 0; i < lines.size() ; i++) {
+ GUI::StaticTextWidget *widget = new GUI::StaticTextWidget(container, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ _textWidgets.push_back(widget);
y += kLineHeight;
}
}
@@ -152,5 +163,9 @@ void UnknownGameDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
case kOpenBugtrackerURL:
g_system->openUrl(generateBugtrackerURL());
break;
+ case kScrollContainerReflow:
+ for (uint i = 0; i < _textWidgets.size() ; i++)
+ _textWidgets[i]->setVisible(true);
+ break;
}
}
diff --git a/engines/unknown-game-dialog.h b/engines/unknown-game-dialog.h
index 51adf27..a527339 100644
--- a/engines/unknown-game-dialog.h
+++ b/engines/unknown-game-dialog.h
@@ -21,6 +21,11 @@
*/
#include "gui/dialog.h"
+#include "common/array.h"
+
+namespace GUI {
+ class StaticTextWidget;
+}
class UnknownGameDialog : public GUI::Dialog {
public:
@@ -34,4 +39,6 @@ private:
Common::String _reportTranslated;
Common::String _bugtrackerGameData;
Common::String _bugtrackerAffectedEngine;
+
+ Common::Array<GUI::StaticTextWidget*> _textWidgets;
};
Commit: 8cb9eebd8a8f7cae2dbb68ad3398f444426929c1
https://github.com/scummvm/scummvm/commit/8cb9eebd8a8f7cae2dbb68ad3398f444426929c1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2018-04-29T21:47:10+01:00
Commit Message:
ENGINES: Improve update of the Unknown Game Dialog when the overlay size changes
Previously the dialog was not resized and was just recentered on the screen.
Now it is properly resized as well.
Changed paths:
engines/advancedDetector.cpp
engines/unknown-game-dialog.cpp
engines/unknown-game-dialog.h
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index dbe2cdf..0d01656 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -357,7 +357,6 @@ void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFileP
report += "\n\n";
reportTranslated += "\n\n";
- reportTranslated.wordWrap(65);
Common::String reportLog = report;
reportLog.wordWrap(80);
diff --git a/engines/unknown-game-dialog.cpp b/engines/unknown-game-dialog.cpp
index 91a593c..0314d2a 100644
--- a/engines/unknown-game-dialog.cpp
+++ b/engines/unknown-game-dialog.cpp
@@ -58,13 +58,64 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
}
#endif
- const int screenW = g_system->getOverlayWidth();
+ // For now place the buttons with a default place and size. They will be resized and moved when rebuild() is called.
+ _closeButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, _("Close"), 0, kClose);
+
+ //Check if we have clipboard functionality
+ if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ _copyToClipboardButton = new GUI::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 GUI::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 GUI::ScrollContainerWidget(this, 0, 0, 0, 0, kScrollContainerReflow);
+ _textContainer->setTarget(this);
+
+ rebuild();
+}
+
+void UnknownGameDialog::reflowLayout() {
+ rebuild();
+ GUI::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 buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
+ int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
- //Calculate the size the dialog needs
// 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.
@@ -76,66 +127,47 @@ UnknownGameDialog::UnknownGameDialog(const Common::String &reportData, const Com
_h = MIN(screenH - 20, lineCount * kLineHeight + kLineHeight + buttonHeight + 24);
- // Buttons
- int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Close")) + 10);
- int copyToClipboardButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Copy to clipboard")) + 10);
- int openBugtrackerURLButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_("Report game")) + 10);
- int totalButtonWidth = closeButtonWidth;
- if (g_system->hasFeature(OSystem::kFeatureClipboardSupport))
- totalButtonWidth += 10 + copyToClipboardButtonWidth;
- if (g_system->hasFeature(OSystem::kFeatureOpenUrl))
- totalButtonWidth += 10 + openBugtrackerURLButtonWidth;
+ 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;
- int buttonPos = _w - closeButtonWidth - 10;
- new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, _("Close"), 0, kClose);
+ // Center the dialog on the screen
+ _x = (g_system->getOverlayWidth() - _w) / 2;
+ _y = (g_system->getOverlayHeight() - _h) / 2;
- //Check if we have clipboard functionality
- if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) {
+ // 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;
- new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight, _("Copy to clipboard"), 0, kCopyToClipboard);
+ _copyToClipboardButton->resize(buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight);
}
-
-#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)) {
+ if (_openBugTrackerUrlButton) {
buttonPos -= openBugtrackerURLButtonWidth + 5;
- new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, openBugtrackerURLButtonWidth, buttonHeight, _("Report game"), 0, kOpenBugtrackerURL);
- //Formatting the reportData for bugtracker submission [replace line breaks]...
- _bugtrackerGameData = _reportData;
- while (_bugtrackerGameData.contains("\n")) {
- Common::replace(_bugtrackerGameData, "\n", "%0A");
- }
+ _openBugTrackerUrlButton->resize(buttonPos, _h - buttonHeight - 8, openBugtrackerURLButtonWidth, buttonHeight);
}
-#endif
- // Each line is represented by one static text item.
- // Use a ScrollContainer for the report in case we have a lot of lines.
- int containerHeight = _h - kLineHeight - buttonHeight - 8;
- GUI::ScrollContainerWidget *container = new GUI::ScrollContainerWidget(this, 8, 8, _w - 16, containerHeight, kScrollContainerReflow);
- container->setTarget(this);
+ 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++) {
- GUI::StaticTextWidget *widget = new GUI::StaticTextWidget(container, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft);
+ GUI::StaticTextWidget *widget = new GUI::StaticTextWidget(_textContainer, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft);
_textWidgets.push_back(widget);
y += kLineHeight;
}
}
-void UnknownGameDialog::reflowLayout() {
- _x = (g_system->getOverlayWidth() - _w) / 2;
- _y = (g_system->getOverlayHeight() - _h) / 2;
- GUI::Dialog::reflowLayout();
-}
-
Common::String UnknownGameDialog::generateBugtrackerURL() {
return Common::String::format((
"https://bugs.scummvm.org/newticket?"
diff --git a/engines/unknown-game-dialog.h b/engines/unknown-game-dialog.h
index a527339..4f0e9a4 100644
--- a/engines/unknown-game-dialog.h
+++ b/engines/unknown-game-dialog.h
@@ -25,6 +25,8 @@
namespace GUI {
class StaticTextWidget;
+ class ScrollContainerWidget;
+ class ButtonWidget;
}
class UnknownGameDialog : public GUI::Dialog {
@@ -34,11 +36,18 @@ public:
virtual Common::String generateBugtrackerURL();
virtual void reflowLayout();
+protected:
+ void rebuild();
+
private:
Common::String _reportData;
Common::String _reportTranslated;
Common::String _bugtrackerGameData;
Common::String _bugtrackerAffectedEngine;
+ GUI::ScrollContainerWidget *_textContainer;
Common::Array<GUI::StaticTextWidget*> _textWidgets;
+ GUI::ButtonWidget* _openBugTrackerUrlButton;
+ GUI::ButtonWidget* _copyToClipboardButton;
+ GUI::ButtonWidget* _closeButton;
};
More information about the Scummvm-git-logs
mailing list