GUI: U32: Convert majority of code to use U32

This commit also includes some additional major changes.

- Return U32String from TransMan getTranslation()
- Change tooltips to be U32Strings
- Remove temporary code of convertToU32String
- U32 Support various dialogs (Browser, FileBrowser, Messages, Chooser, etc)
- U32 for music plugins
- U32 for OSD messages
- Add some helper functions to ustr.cpp
- Change default tooltips from nullptr & 0 -> ""
- Some runtime exceptions may occur when changing languages due to incorrect String::Format
This commit is contained in:
aryanrawlani28 2020-06-13 22:12:25 +05:30 committed by Eugene Sandulenko
parent aa33fc2354
commit f800ca4ada
91 changed files with 836 additions and 714 deletions

View file

@ -78,8 +78,8 @@ Common::String getDisplayPath(Common::String s) {
bool FilesPageHandler::listDirectory(Common::String path, Common::String &content, const Common::String &itemTemplate) {
if (path == "" || path == "/") {
if (ConfMan.hasKey("rootpath", "cloud"))
addItem(content, itemTemplate, IT_DIRECTORY, "/root/", HandlerUtils::toUtf8(_("File system root")));
addItem(content, itemTemplate, IT_DIRECTORY, "/saves/", HandlerUtils::toUtf8(_("Saved games")));
addItem(content, itemTemplate, IT_DIRECTORY, "/root/", Common::convertFromU32String(_("File system root")));
addItem(content, itemTemplate, IT_DIRECTORY, "/saves/", Common::convertFromU32String(_("Saved games")));
return true;
}
@ -116,7 +116,7 @@ bool FilesPageHandler::listDirectory(Common::String path, Common::String &conten
filePath = "/";
else
filePath = parentPath(prefixToAdd + filePath);
addItem(content, itemTemplate, IT_PARENT_DIRECTORY, filePath, HandlerUtils::toUtf8(_("Parent directory")));
addItem(content, itemTemplate, IT_PARENT_DIRECTORY, filePath, Common::convertFromU32String(_("Parent directory")));
}
// fill the content
@ -215,21 +215,21 @@ void FilesPageHandler::handle(Client &client) {
// show an error message if failed to list directory
if (!listDirectory(path, content, itemTemplate)) {
HandlerUtils::setFilesManagerErrorMessageHandler(client, HandlerUtils::toUtf8(_("ScummVM couldn't list the directory you specified.")));
HandlerUtils::setFilesManagerErrorMessageHandler(client, Common::convertFromU32String(_("ScummVM couldn't list the directory you specified.")).c_str());
return;
}
//these occur twice:
replace(response, "{create_directory_button}", HandlerUtils::toUtf8(_("Create directory")));
replace(response, "{create_directory_button}", HandlerUtils::toUtf8(_("Create directory")));
replace(response, "{create_directory_button}", Common::convertFromU32String(_("Create directory")));
replace(response, "{create_directory_button}", Common::convertFromU32String(_("Create directory")));
replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
replace(response, "{path}", encodeDoubleQuotes(client.queryParameter("path")));
replace(response, "{upload_files_button}", HandlerUtils::toUtf8(_("Upload files"))); //tab
replace(response, "{upload_file_button}", HandlerUtils::toUtf8(_("Upload files"))); //button in the tab
replace(response, "{create_directory_desc}", HandlerUtils::toUtf8(_("Type new directory name:")));
replace(response, "{upload_file_desc}", HandlerUtils::toUtf8(_("Select a file to upload:")));
replace(response, "{or_upload_directory_desc}", HandlerUtils::toUtf8(_("Or select a directory (works in Chrome only):")));
replace(response, "{index_of_directory}", Common::String::format("%s %s", HandlerUtils::toUtf8(_("Index of")).c_str(), encodeHtmlEntities(getDisplayPath(client.queryParameter("path"))).c_str()));
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, "{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);
}