GUI: U32: Rename more temp code and fix issues
- Remove convertFromU32.. where necessary - Replace convertFromU32 to .encode() for better readability - Fix spacing issues in tabs - Fix spacing issues in popups - Fix weird font rendering in certain menus. - Fix dialog changing sizes by huge amount when changing languages - Some minor changes from String::format to U32String::Format
This commit is contained in:
parent
96912f4adb
commit
160a1320cc
9 changed files with 52 additions and 51 deletions
|
@ -64,16 +64,16 @@ void FilesAjaxPageHandler::handle(Client &client) {
|
|||
Common::String path = client.queryParameter("path");
|
||||
|
||||
//these occur twice:
|
||||
replace(response, "{create_directory_button}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Create directory")).c_str()));
|
||||
replace(response, "{create_directory_button}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Create directory")).c_str()));
|
||||
replace(response, "{upload_files_button}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Upload files")).c_str())); //tab
|
||||
replace(response, "{upload_file_button}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Upload files")).c_str())); //button in the tab
|
||||
replace(response, "{create_directory_desc}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Type new directory name:")).c_str()));
|
||||
replace(response, "{upload_file_desc}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Select a file to upload:")).c_str()));
|
||||
replace(response, "{or_upload_directory_desc}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Or select a directory (works in Chrome only):")).c_str()));
|
||||
replace(response, "{index_of}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Index of ")).c_str()));
|
||||
replace(response, "{loading}", HandlerUtils::toUtf8(("Loading...")));
|
||||
replace(response, "{error}", HandlerUtils::toUtf8(Common::convertFromU32String(_("Error occurred")).c_str()));
|
||||
replace(response, "{create_directory_button}", _("Create directory").encode());
|
||||
replace(response, "{create_directory_button}", _("Create directory").encode());
|
||||
replace(response, "{upload_files_button}", _("Upload files").encode()); //tab
|
||||
replace(response, "{upload_file_button}", _("Upload files").encode()); //button in the tab
|
||||
replace(response, "{create_directory_desc}", _("Type new directory name:").encode());
|
||||
replace(response, "{upload_file_desc}", _("Select a file to upload:").encode());
|
||||
replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):").encode());
|
||||
replace(response, "{index_of}", _("Index of ").encode());
|
||||
replace(response, "{loading}", ("Loading..."));
|
||||
replace(response, "{error}", _("Error occurred").encode());
|
||||
replace(response, "{start_path}", encodeDoubleQuotesAndSlashes(path));
|
||||
LocalWebserver::setClientGetHandler(client, response);
|
||||
}
|
||||
|
|
|
@ -220,15 +220,15 @@ void FilesPageHandler::handle(Client &client) {
|
|||
}
|
||||
|
||||
//these occur twice:
|
||||
replace(response, "{create_directory_button}", Common::convertFromU32String(_("Create directory")));
|
||||
replace(response, "{create_directory_button}", Common::convertFromU32String(_("Create directory")));
|
||||
replace(response, "{create_directory_button}", _("Create directory").encode());
|
||||
replace(response, "{create_directory_button}", _("Create directory").encode());
|
||||
replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
|
||||
replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
|
||||
replace(response, "{upload_files_button}", Common::convertFromU32String(_("Upload files"))); //tab
|
||||
replace(response, "{upload_file_button}", Common::convertFromU32String(_("Upload files"))); //button in the tab
|
||||
replace(response, "{create_directory_desc}", Common::convertFromU32String(_("Type new directory name:")));
|
||||
replace(response, "{upload_file_desc}", Common::convertFromU32String(_("Select a file to upload:")));
|
||||
replace(response, "{or_upload_directory_desc}", Common::convertFromU32String(_("Or select a directory (works in Chrome only):")));
|
||||
replace(response, "{upload_files_button}", _("Upload files").encode()); //tab
|
||||
replace(response, "{upload_file_button}", _("Upload files").encode()); //button in the tab
|
||||
replace(response, "{create_directory_desc}", _("Type new directory name:").encode());
|
||||
replace(response, "{upload_file_desc}", _("Select a file to upload:").encode());
|
||||
replace(response, "{or_upload_directory_desc}", _("Or select a directory (works in Chrome only):").encode());
|
||||
replace(response, "{index_of_directory}", Common::String::format("%s %s", Common::convertFromU32String(_("Index of")).c_str(), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))).c_str()));
|
||||
replace(response, "{content}", content);
|
||||
LocalWebserver::setClientGetHandler(client, response);
|
||||
|
|
|
@ -446,19 +446,19 @@ void EditGameDialog::apply() {
|
|||
else
|
||||
ConfMan.set("language", Common::getLanguageCode(lang), _domain);
|
||||
|
||||
String gamePath(Common::convertFromU32String(_gamePathWidget->getLabel()));
|
||||
U32String gamePath(_gamePathWidget->getLabel());
|
||||
if (!gamePath.empty())
|
||||
ConfMan.set("path", gamePath, _domain);
|
||||
ConfMan.set("path", gamePath.encode(), _domain);
|
||||
|
||||
String extraPath(Common::convertFromU32String(_extraPathWidget->getLabel()));
|
||||
if (!extraPath.empty() && (extraPath != Common::convertFromU32String(_c("None", "path"))))
|
||||
ConfMan.set("extrapath", extraPath, _domain);
|
||||
U32String extraPath(_extraPathWidget->getLabel());
|
||||
if (!extraPath.empty() && (extraPath != _c("None", "path")))
|
||||
ConfMan.set("extrapath", extraPath.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("extrapath", _domain);
|
||||
|
||||
String savePath(Common::convertFromU32String(_savePathWidget->getLabel()));
|
||||
if (!savePath.empty() && (savePath != Common::convertFromU32String(_("Default"))))
|
||||
ConfMan.set("savepath", savePath, _domain);
|
||||
U32String savePath(_savePathWidget->getLabel());
|
||||
if (!savePath.empty() && (savePath != _("Default")))
|
||||
ConfMan.set("savepath", savePath.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("savepath", _domain);
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ class SaveLoadChooser;
|
|||
|
||||
class EditGameDialog : public OptionsDialog {
|
||||
typedef Common::String String;
|
||||
typedef Common::U32String U32String;
|
||||
typedef Common::Array<Common::String> StringArray;
|
||||
public:
|
||||
EditGameDialog(const String &domain);
|
||||
|
|
|
@ -266,14 +266,14 @@ void MassAddDialog::handleTickle() {
|
|||
buf = _("Scan complete!");
|
||||
_dirProgressText->setLabel(buf);
|
||||
|
||||
buf = Common::String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games.")).c_str(), _games.size(), _oldGamesCount);
|
||||
buf = Common::U32String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games.")).c_str(), _games.size(), _oldGamesCount);
|
||||
_gameProgressText->setLabel(buf);
|
||||
|
||||
} else {
|
||||
buf = Common::String::format(Common::convertFromU32String(_("Scanned %d directories ...")).c_str(), _dirsScanned);
|
||||
buf = Common::U32String::format(Common::convertFromU32String(_("Scanned %d directories ...")).c_str(), _dirsScanned);
|
||||
_dirProgressText->setLabel(buf);
|
||||
|
||||
buf = Common::String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games ...")).c_str(), _games.size(), _oldGamesCount);
|
||||
buf = Common::U32String::format(Common::convertFromU32String(_("Discovered %d new games, ignored %d previously added games ...")).c_str(), _games.size(), _oldGamesCount);
|
||||
_gameProgressText->setLabel(buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -744,9 +744,9 @@ void OptionsDialog::apply() {
|
|||
ConfMan.setBool("multi_midi", _multiMidiCheckbox->getState(), _domain);
|
||||
ConfMan.setInt("midi_gain", _midiGainSlider->getValue(), _domain);
|
||||
|
||||
Common::String soundFont(Common::convertFromU32String(_soundFont->getLabel()));
|
||||
if (!soundFont.empty() && (soundFont != Common::convertFromU32String(_c("None", "soundfont"))))
|
||||
ConfMan.set("soundfont", soundFont, _domain);
|
||||
Common::U32String soundFont(_soundFont->getLabel());
|
||||
if (!soundFont.empty() && (soundFont != _c("None", "soundfont")))
|
||||
ConfMan.set("soundfont", soundFont.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("soundfont", _domain);
|
||||
} else {
|
||||
|
@ -1170,12 +1170,12 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin
|
|||
}
|
||||
|
||||
if (nHidden) {
|
||||
Common::String hiddenStr = Common::String::format(Common::convertFromU32String(_("%d hidden achievements remaining")).c_str(), nHidden);
|
||||
new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, Common::convertToU32String(hiddenStr.c_str()), Graphics::kTextAlignStart);
|
||||
Common::U32String hiddenStr = Common::U32String::format(Common::convertFromU32String(_("%d hidden achievements remaining")).c_str(), nHidden);
|
||||
new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, hiddenStr, Graphics::kTextAlignStart);
|
||||
}
|
||||
|
||||
if (nMax) {
|
||||
Common::U32String totalStr = Common::String::format(Common::convertFromU32String(_("Achievements unlocked: %d/%d")).c_str(), nAchieved, nMax);
|
||||
Common::U32String totalStr = Common::U32String::format(Common::convertFromU32String(_("Achievements unlocked: %d/%d")).c_str(), nAchieved, nMax);
|
||||
new StaticTextWidget(scrollContainer, lineHeight, lineHeight, width, yStep, totalStr, Graphics::kTextAlignStart);
|
||||
|
||||
SliderWidget *progressBar;
|
||||
|
@ -2148,7 +2148,7 @@ void GlobalOptionsDialog::addNetworkControls(GuiObject *boss, const Common::Stri
|
|||
uint32 port = Networking::LocalWebserver::getPort();
|
||||
|
||||
_serverPortDesc = new StaticTextWidget(boss, prefix + "ServerPortDesc", (_("Server's port:")), _("Port for server to use"));
|
||||
_serverPort = new EditTextWidget(boss, prefix + "ServerPortEditText", Common::String::format("%u", port), Common::U32String(""));
|
||||
_serverPort = new EditTextWidget(boss, prefix + "ServerPortEditText", Common::U32String::format("%u", port), Common::U32String(""));
|
||||
_serverPortClearButton = addClearButton(boss, prefix + "ServerPortClearButton", kServerPortClearCmd);
|
||||
|
||||
if (lowres) {
|
||||
|
@ -2200,21 +2200,21 @@ void GlobalOptionsDialog::apply() {
|
|||
|
||||
bool isRebuildNeeded = false;
|
||||
|
||||
Common::String savePath(Common::convertFromU32String(_savePath->getLabel()));
|
||||
if (!savePath.empty() && (savePath != Common::convertFromU32String(_("Default"))))
|
||||
ConfMan.set("savepath", savePath, _domain);
|
||||
Common::U32String savePath(_savePath->getLabel());
|
||||
if (!savePath.empty() && (savePath != (_("Default"))))
|
||||
ConfMan.set("savepath", savePath.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("savepath", _domain);
|
||||
|
||||
Common::String themePath(Common::convertFromU32String(_themePath->getLabel()));
|
||||
if (!themePath.empty() && (themePath != Common::convertFromU32String(_c("None", "path"))))
|
||||
ConfMan.set("themepath", themePath, _domain);
|
||||
Common::U32String themePath((_themePath->getLabel()));
|
||||
if (!themePath.empty() && (themePath != _c("None", "path")))
|
||||
ConfMan.set("themepath", themePath.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("themepath", _domain);
|
||||
|
||||
Common::String extraPath(Common::convertFromU32String(_extraPath->getLabel()));
|
||||
if (!extraPath.empty() && (extraPath != Common::convertFromU32String(_c("None", "path"))))
|
||||
ConfMan.set("extrapath", extraPath, _domain);
|
||||
Common::U32String extraPath(_extraPath->getLabel());
|
||||
if (!extraPath.empty() && (extraPath != _c("None", "path")))
|
||||
ConfMan.set("extrapath", extraPath.encode(), _domain);
|
||||
else
|
||||
ConfMan.removeKey("extrapath", _domain);
|
||||
|
||||
|
@ -2228,9 +2228,9 @@ void GlobalOptionsDialog::apply() {
|
|||
|
||||
#ifdef USE_CLOUD
|
||||
#ifdef USE_SDL_NET
|
||||
Common::String rootPath(Common::convertFromU32String(_rootPath->getLabel()));
|
||||
if (!rootPath.empty() && (rootPath != Common::convertFromU32String(_c("None", "path"))))
|
||||
ConfMan.set("rootpath", rootPath, "cloud");
|
||||
Common::U32String rootPath(_rootPath->getLabel());
|
||||
if (!rootPath.empty() && (rootPath != _c("None", "path")))
|
||||
ConfMan.set("rootpath", rootPath.encode(), "cloud");
|
||||
else
|
||||
ConfMan.removeKey("rootpath", "cloud");
|
||||
#endif
|
||||
|
|
|
@ -1182,7 +1182,7 @@ void SavenameDialog::open() {
|
|||
Dialog::open();
|
||||
setResult(-1);
|
||||
|
||||
_title->setLabel(Common::String::format(Common::convertFromU32String(_("Enter a description for slot %d:")).c_str(), _targetSlot));
|
||||
_title->setLabel(Common::U32String::format(Common::convertFromU32String(_("Enter a description for slot %d:")).c_str(), _targetSlot));
|
||||
}
|
||||
|
||||
void SavenameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
|
|
|
@ -84,7 +84,7 @@ void PopUpDialog::open() {
|
|||
_w = 0;
|
||||
|
||||
for (uint i = 0; i < _entries.size(); i++) {
|
||||
int width = g_gui.getStringWidth(Common::convertFromU32String(_entries[i]));
|
||||
int width = g_gui.getStringWidth(_entries[i]);
|
||||
|
||||
if (width > _w)
|
||||
_w = width;
|
||||
|
|
|
@ -120,7 +120,7 @@ int TabWidget::addTab(const U32String &title, const String &dialogName) {
|
|||
newTab.firstWidget = nullptr;
|
||||
|
||||
// Determine the new tab width
|
||||
int newWidth = g_gui.getStringWidth(Common::convertFromU32String(title)) + kTabTitleSpacing;
|
||||
int newWidth = g_gui.getStringWidth(title) + kTabTitleSpacing;
|
||||
if (newWidth < _minTabWidth)
|
||||
newWidth = _minTabWidth;
|
||||
newTab._tabWidth = newWidth;
|
||||
|
@ -350,7 +350,7 @@ void TabWidget::reflowLayout() {
|
|||
|
||||
for (uint i = 0; i < _tabs.size(); ++i) {
|
||||
// Determine the new tab width
|
||||
int newWidth = g_gui.getStringWidth(Common::convertFromU32String(_tabs[i].title)) + kTabTitleSpacing;
|
||||
int newWidth = g_gui.getStringWidth(_tabs[i].title) + kTabTitleSpacing;
|
||||
if (newWidth < _minTabWidth)
|
||||
newWidth = _minTabWidth;
|
||||
_tabs[i]._tabWidth = newWidth;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue