[Scummvm-git-logs] scummvm master -> 1a5442bb2440d92d8f6a671153e1e1bd1aa0ca86
sev-
noreply at scummvm.org
Sun Apr 23 14:30:27 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
7c59a77aca COMMON: Added string splitter to StringTokenizer class
1a5442bb24 GUI: Merge multiline sentences into one string for easier translation
Commit: 7c59a77aca7740a7b8a3d1a54c7aef96d2ba6e9b
https://github.com/scummvm/scummvm/commit/7c59a77aca7740a7b8a3d1a54c7aef96d2ba6e9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-04-23T16:20:37+02:00
Commit Message:
COMMON: Added string splitter to StringTokenizer class
Changed paths:
common/tokenizer.cpp
common/tokenizer.h
diff --git a/common/tokenizer.cpp b/common/tokenizer.cpp
index f5ef77cc131..45effce118a 100644
--- a/common/tokenizer.cpp
+++ b/common/tokenizer.cpp
@@ -52,6 +52,15 @@ String StringTokenizer::nextToken() {
return String(_str.c_str() + _tokenBegin, _tokenEnd - _tokenBegin);
}
+StringArray StringTokenizer::split() {
+ StringArray res;
+
+ while (!empty())
+ res.push_back(nextToken());
+
+ return res;
+}
+
U32StringTokenizer::U32StringTokenizer(const U32String &str, const String &delimiters) : _str(str), _delimiters(delimiters) {
reset();
}
@@ -99,5 +108,14 @@ U32String U32StringTokenizer::nextToken() {
return U32String();
}
+U32StringArray U32StringTokenizer::split() {
+ U32StringArray res;
+
+ while (!empty())
+ res.push_back(nextToken());
+
+ return res;
+}
+
} // End of namespace Common
diff --git a/common/tokenizer.h b/common/tokenizer.h
index a7d8d5f342e..009b2edb9d8 100644
--- a/common/tokenizer.h
+++ b/common/tokenizer.h
@@ -23,8 +23,7 @@
#define COMMON_TOKENIZER_H
#include "common/scummsys.h"
-#include "common/str.h"
-#include "common/ustr.h"
+#include "common/str-array.h"
namespace Common {
@@ -55,6 +54,7 @@ public:
void reset(); ///< Resets the tokenizer to its initial state
bool empty() const; ///< Returns true if there are no more tokens left in the string, false otherwise
String nextToken(); ///< Returns the next token from the string (Or an empty string if there are no more tokens)
+ StringArray split(); ///< Returns StringArray with all tokens. Beware of the memory usage
private:
const String _str; ///< The string to be tokenized
@@ -82,6 +82,7 @@ public:
void reset(); ///< Resets the tokenizer to its initial state, i.e points boten token iterators to the beginning
bool empty() const; ///< Returns true if there are no more tokens left in the string, false otherwise
U32String nextToken(); ///< Returns the next token from the string (Or an empty string if there are no more tokens)
+ U32StringArray split(); ///< Returns StringArray with all tokens. Beware of the memory usage
private:
const U32String _str; ///< The unicode string to be tokenized
Commit: 1a5442bb2440d92d8f6a671153e1e1bd1aa0ca86
https://github.com/scummvm/scummvm/commit/1a5442bb2440d92d8f6a671153e1e1bd1aa0ca86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-04-23T16:29:49+02:00
Commit Message:
GUI: Merge multiline sentences into one string for easier translation
Changed paths:
gui/cloudconnectionwizard.cpp
diff --git a/gui/cloudconnectionwizard.cpp b/gui/cloudconnectionwizard.cpp
index 1fd991eaea8..bd66a656e0b 100644
--- a/gui/cloudconnectionwizard.cpp
+++ b/gui/cloudconnectionwizard.cpp
@@ -29,6 +29,7 @@
#include "common/formats/json.h"
#include "common/memstream.h"
+#include "common/tokenizer.h"
#include "common/translation.h"
#include "gui/message.h"
@@ -51,7 +52,7 @@ enum {
};
CloudConnectionWizard::CloudConnectionWizard() :
- Dialog("GlobalOptions_Cloud_ConnectionWizard"),
+ Dialog("GlobalOptions_Cloud_ConnectionWizard"),
_currentStep(Step::NONE), _switchToSuccess(false), _switchToFailure(false),
_connecting(false) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
@@ -202,8 +203,16 @@ void CloudConnectionWizard::showStepQuickMode1() {
showBackButton();
showNextButton();
- _label0 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep1.Line1", _("In this mode, Local Webserver must be running,"));
- _label1 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep1.Line2", _("so your browser could forward data to ScummVM"));
+ Common::U32StringTokenizer tok(_("In this mode, Local Webserver must be running,\n"
+ "so your browser could forward data to ScummVM"), "\n");
+
+ Common::U32StringArray labels = tok.split();
+
+ if (labels.size() < 2)
+ labels.push_back(Common::U32String());
+
+ _label0 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep1.Line1", labels[0]);
+ _label1 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep1.Line2", labels[1]);
_button0 = new ButtonWidget(_container, "ConnectionWizard_QuickModeStep1.RunServerButton", Common::U32String(), Common::U32String(), kCloudConnectionWizardRunServerButtonCmd);
_label2 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep1.ServerInfoLabel", Common::U32String());
@@ -254,8 +263,16 @@ void CloudConnectionWizard::showStepQuickMode2() {
_label0 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line1", _("Now, open this link in your browser:"));
_button0 = new ButtonWidget(_container, "ConnectionWizard_QuickModeStep2.OpenLinkButton", Common::U32String("https://cloud.scummvm.org/"), _("Open URL"), kCloudConnectionWizardOpenUrlStorageCmd);
- _label1 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line2", _("It will automatically pass the data to ScummVM,"));
- _label2 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line3", _("and warn you should there be any errors."));
+ Common::U32StringTokenizer tok(_("It will automatically pass the data to ScummVM,\n"
+ "and warn you should there be any errors."), "\n");
+
+ Common::U32StringArray labels = tok.split();
+
+ if (labels.size() < 2)
+ labels.push_back(Common::U32String());
+
+ _label1 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line2", labels[0]);
+ _label2 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line3", labels[1]);
_label3 = new StaticTextWidget(_container, "ConnectionWizard_QuickModeStep2.Line4", Common::U32String(), Common::U32String(), ThemeEngine::kFontStyleNormal);
#ifdef USE_SDL_NET
@@ -301,9 +318,21 @@ void CloudConnectionWizard::showStepManualMode1() {
_label0 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line1", _("Open this link in your browser:"));
_button0 = new ButtonWidget(_container, "ConnectionWizard_ManualModeStep1.OpenLinkButton", Common::U32String("https://cloud.scummvm.org/"), _("Open URL"), kCloudConnectionWizardOpenUrlStorageCmd);
- _label1 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line2", _("When it fails to pass JSON code to ScummVM,"));
- _label2 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line3", _("find it on Troubleshooting section of the page,"));
- _label3 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line4", _("and go to the next step here."));
+ Common::U32StringTokenizer tok(_("When it fails to pass JSON code to ScummVM,\n"
+ "find it on Troubleshooting section of the page,\n"
+ "and go to the next step here."), "\n");
+
+ Common::U32StringArray labels = tok.split();
+
+ if (labels.size() < 2)
+ labels.push_back(Common::U32String());
+
+ if (labels.size() < 3)
+ labels.push_back(Common::U32String());
+
+ _label1 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line2", labels[0]);
+ _label2 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line3", labels[1]);
+ _label3 = new StaticTextWidget(_container, "ConnectionWizard_ManualModeStep1.Line4", labels[2]);
}
void CloudConnectionWizard::hideStepManualMode1() {
@@ -502,7 +531,7 @@ void CloudConnectionWizard::manualModeConnect() {
return;
}
- // disable UI
+ // disable UI
if (_codeBox)
_codeBox->setEnabled(false);
if (_button0)
@@ -553,7 +582,7 @@ void CloudConnectionWizard::close() {
Dialog::close();
}
-void CloudConnectionWizard::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+void CloudConnectionWizard::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kCloudConnectionWizardQuickModeButtonCmd:
showStep(Step::QUICK_MODE_STEP_1);
@@ -634,7 +663,7 @@ void CloudConnectionWizard::handleCommand(CommandSender *sender, uint32 cmd, uin
}
break;
- default:
+ default:
Dialog::handleCommand(sender, cmd, data);
}
}
More information about the Scummvm-git-logs
mailing list