GUI: U32: Add u32 support to Editables and Dialogs

- Editable widgets
- Lists
- SaveLoad Dialogs
- Browser Dialogs
This commit is contained in:
aryanrawlani28 2020-06-11 21:25:05 +05:30 committed by Eugene Sandulenko
parent 4ea2b46ce8
commit 5f2af6b93e
30 changed files with 134 additions and 115 deletions

View File

@ -25,13 +25,15 @@
#include "common/array.h"
#include "common/str.h"
#include "common/ustr.h"
namespace Common {
/**
* An array of of strings.
*/
typedef Array<String> StringArray;
typedef Array<String> StringArray;
typedef Array<U32String> U32StringArray;
} // End of namespace Common

View File

@ -752,11 +752,11 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
int AgiEngine::scummVMSaveLoadDialog(bool isSave) {
GUI::SaveLoadChooser *dialog;
Common::String desc;
Common::U32String desc;
int slot;
if (isSave) {
dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
dialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Save game:")), Common::convertToU32String(("Save")), true);
slot = dialog->runModalWithCurrentTarget();
desc = dialog->getResultString();
@ -767,9 +767,9 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) {
}
if (desc.size() > 28)
desc = Common::String(desc.c_str(), 28);
desc = Common::U32String(desc.c_str(), 28);
} else {
dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
dialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Restore game:")), Common::convertToU32String(_("Restore")), false);
slot = dialog->runModalWithCurrentTarget();
}
@ -779,7 +779,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) {
return true;
if (isSave)
return doSave(slot, desc);
return doSave(slot, Common::convertFromU32String(desc));
else
return doLoad(slot, false);
}

View File

@ -99,8 +99,8 @@ MainMenuDialog::MainMenuDialog(Engine *engine)
new GUI::ButtonWidget(this, "GlobalMenu.Quit", Common::convertToU32String(_("~Q~uit")), 0, kQuitCmd);
_aboutDialog = new GUI::AboutDialog();
_loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
_saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
_loadDialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Load game:")), Common::convertToU32String(_("Load")), false);
_saveDialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Save game:")), Common::convertToU32String(_("Save")), true);
}
MainMenuDialog::~MainMenuDialog() {
@ -206,13 +206,13 @@ void MainMenuDialog::save() {
int slot = _saveDialog->runModalWithCurrentTarget();
if (slot >= 0) {
Common::String result(_saveDialog->getResultString());
Common::U32String result(_saveDialog->getResultString());
if (result.empty()) {
// If the user was lazy and entered no save name, come up with a default name.
result = _saveDialog->createDefaultSaveDescription(slot);
}
Common::Error status = _engine->saveGameState(slot, result);
Common::Error status = _engine->saveGameState(slot, Common::convertFromU32String(result));
if (status.getCode() != Common::kNoError) {
Common::String failMessage = Common::String::format(_("Failed to save game (%s)! "
"Please consult the README for basic information, and for "

View File

@ -762,7 +762,7 @@ bool Engine::loadGameDialog() {
return false;
}
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Load game:")), Common::convertToU32String(_("Load")), false);
int slotNum;
{
@ -791,14 +791,14 @@ bool Engine::saveGameDialog() {
return false;
}
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(Common::convertToU32String(_("Save game:")), Common::convertToU32String(_("Save")), true);
int slotNum;
{
PauseToken pt = pauseEngine();
slotNum = dialog->runModalWithCurrentTarget();
}
Common::String desc = dialog->getResultString();
Common::U32String desc = dialog->getResultString();
if (desc.empty())
desc = dialog->createDefaultSaveDescription(slotNum);
@ -807,7 +807,7 @@ bool Engine::saveGameDialog() {
if (slotNum < 0)
return false;
Common::Error saveError = saveGameState(slotNum, desc);
Common::Error saveError = saveGameState(slotNum, Common::convertFromU32String(desc));
if (saveError.getCode() != Common::kNoError) {
GUI::MessageDialog errorDialog(saveError.getDesc());
errorDialog.runModal();

View File

@ -49,7 +49,7 @@ enum {
* - others???
*/
BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)
BrowserDialog::BrowserDialog(Common::U32String &title, bool dirBrowser)
: Dialog("Browser") {
_title = title;
@ -59,10 +59,10 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser)
_showHidden = false;
// Headline - TODO: should be customizable during creation time
new StaticTextWidget(this, "Browser.Headline", Common::convertToU32String(title));
new StaticTextWidget(this, "Browser.Headline", title);
// Current path - TODO: handle long paths ?
_currentPath = new EditTextWidget(this, "Browser.Path", "", nullptr, 0, kPathEditedCmd);
_currentPath = new EditTextWidget(this, "Browser.Path", Common::convertToU32String(""), nullptr, 0, kPathEditedCmd);
// Add file list
_fileList = new ListWidget(this, "Browser.List");
@ -89,7 +89,7 @@ int BrowserDialog::runModal() {
Common::DialogManager *dialogManager = g_system->getDialogManager();
if (dialogManager) {
if (ConfMan.getBool("gui_browser_native", Common::ConfigManager::kApplicationDomain)) {
Common::DialogManager::DialogResult result = dialogManager->showFileBrowser(_title.c_str(), _choice, _isDirBrowser);
Common::DialogManager::DialogResult result = dialogManager->showFileBrowser(_title.encode().c_str(), _choice, _isDirBrowser);
if (result != Common::DialogManager::kDialogError) {
return result;
}
@ -119,7 +119,7 @@ void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
switch (cmd) {
//Search for typed-in directory
case kPathEditedCmd:
_node = Common::FSNode(_currentPath->getEditString());
_node = Common::FSNode(Common::convertFromU32String(_currentPath->getEditString()));
updateListing();
break;
//Search by text input
@ -201,7 +201,7 @@ void BrowserDialog::updateListing() {
Common::sort(_nodeContent.begin(), _nodeContent.end());
// Populate the ListWidget
ListWidget::StringArray list;
ListWidget::U32StringArray list;
ListWidget::ColorList colors;
for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
if (i->isDirectory())

View File

@ -36,7 +36,7 @@ class CommandSender;
class BrowserDialog : public Dialog {
public:
BrowserDialog(const char *title, bool dirBrowser);
BrowserDialog(Common::U32String &title, bool dirBrowser);
int runModal() override;
void open() override;
@ -53,9 +53,9 @@ protected:
bool _showHidden;
CheckboxWidget *_showHiddenWidget;
Common::FSNode _choice;
Common::String _title;
bool _isDirBrowser;
Common::FSNode _choice;
Common::U32String _title;
bool _isDirBrowser;
void updateListing();
};

View File

@ -48,7 +48,7 @@ ChooserDialog::ChooserDialog(const String &title, String dialogId)
_chooseButton->setEnabled(false);
}
void ChooserDialog::setList(const StringArray& list) {
void ChooserDialog::setList(const U32StringArray& list) {
_list->setList(list);
}

View File

@ -40,6 +40,9 @@ class ListWidget;
class ChooserDialog : public Dialog {
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
typedef Common::U32String U32String;
typedef Common::Array<Common::U32String> U32StringArray;
protected:
ListWidget *_list;
ButtonWidget *_chooseButton;
@ -47,7 +50,7 @@ protected:
public:
ChooserDialog(const String &title, String dialogId = "Browser");
void setList(const StringArray& list);
void setList(const U32StringArray& list);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
};

View File

@ -46,7 +46,7 @@ DownloadDialog::DownloadDialog(uint32 storageId, LauncherDialog *launcher) :
Dialog("GlobalOptions_Cloud_DownloadDialog"), _launcher(launcher), _close(false) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
_browser = new BrowserDialog(_("Select directory where to download game data"), true);
_browser = new BrowserDialog(Common::convertToU32String(_("Select directory where to download game data")), true);
_remoteBrowser = new RemoteBrowserDialog(_("Select directory with game data"));
_remoteDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.RemoteDirectory", Common::convertToU32String(_("From: ")));

View File

@ -438,7 +438,7 @@ void EditGameDialog::open() {
}
void EditGameDialog::apply() {
ConfMan.set("description", _descriptionWidget->getEditString(), _domain);
ConfMan.set("description", Common::convertFromU32String(_descriptionWidget->getEditString()), _domain);
Common::Language lang = (Common::Language)_langPopUp->getSelectedTag();
if (lang < 0)
@ -506,7 +506,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
break;
case kCmdChooseSoundFontCmd:
{
BrowserDialog browser(_("Select SoundFont"), false);
BrowserDialog browser(Common::convertToU32String(_("Select SoundFont")), false);
if (browser.runModal() > 0) {
// User made this choice...
@ -526,7 +526,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Change path for the game
case kCmdGameBrowser:
{
BrowserDialog browser(_("Select directory with game data"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory with game data")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -545,7 +545,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Change path for extra game data (eg, using sword cutscenes when playing via CD)
case kCmdExtraBrowser:
{
BrowserDialog browser(_("Select additional game directory"), true);
BrowserDialog browser(Common::convertToU32String(_("Select additional game directory")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -558,7 +558,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Change path for stored save game (perm and temp) data
case kCmdSaveBrowser:
{
BrowserDialog browser(_("Select directory for saved games"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for saved games")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -584,7 +584,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kOKCmd:
{
// Write back changes made to config object
String newDomain(_domainWidget->getEditString());
String newDomain(Common::convertFromU32String(_domainWidget->getEditString()));
if (newDomain != _domain) {
if (newDomain.empty()
|| newDomain.hasPrefix("_")

View File

@ -49,7 +49,7 @@ FileBrowserDialog::FileBrowserDialog(const char *title, const char *fileExtensio
new StaticTextWidget(this, "FileBrowser.Headline", title ? Common::convertToU32String(title) :
mode == kFBModeLoad ? Common::convertToU32String(_("Choose file for loading")) : Common::convertToU32String(_("Enter filename for saving")));
_fileName = new EditTextWidget(this, "FileBrowser.Filename", "");
_fileName = new EditTextWidget(this, "FileBrowser.Filename", Common::convertToU32String(""));
if (mode == kFBModeLoad)
_fileName->setEnabled(false);
@ -88,7 +88,7 @@ void FileBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32
close();
break;
case kListSelectionChangedCmd:
_fileName->setEditString(_fileList->getList().operator[](_fileList->getSelected()).c_str());
_fileName->setEditString(_fileList->getList().operator[](_fileList->getSelected()));
_fileName->markAsDirty();
break;
case kListItemActivatedCmd:
@ -107,7 +107,7 @@ void FileBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32
}
void FileBrowserDialog::normalieFileName() {
Common::String filename = _fileName->getEditString();
Common::String filename = Common::convertFromU32String(_fileName->getEditString());
if (filename.matchString(_fileMask, true))
return;
@ -122,7 +122,7 @@ bool FileBrowserDialog::isProceedSave() {
if (_mode == kFBModeLoad)
return true;
for (ListWidget::StringArray::const_iterator file = _fileList->getList().begin(); file != _fileList->getList().end(); ++file) {
for (ListWidget::U32StringArray::const_iterator file = _fileList->getList().begin(); file != _fileList->getList().end(); ++file) {
if (*file == _fileName->getEditString()) {
matched = true;
break;
@ -142,13 +142,13 @@ bool FileBrowserDialog::isProceedSave() {
void FileBrowserDialog::updateListing() {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
ListWidget::StringArray list;
ListWidget::U32StringArray list;
Common::StringArray filenames = saveFileMan->listSavefiles(_fileMask);
Common::sort(filenames.begin(), filenames.end());
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
list.push_back(file->c_str());
list.push_back(Common::U32String(*file));
}
_fileList->setList(list);

View File

@ -45,7 +45,7 @@ public:
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
const char *getResult() { return Dialog::getResult() ? _fileName->getEditString().c_str() : nullptr; }
const char *getResult() { return Dialog::getResult() ? _fileName->getEditString().encode().c_str() : nullptr; }
protected:
EditTextWidget *_fileName;

View File

@ -204,10 +204,10 @@ void LauncherDialog::build() {
updateButtons();
// Create file browser dialog
_browser = new BrowserDialog(_("Select directory with game data"), true);
_browser = new BrowserDialog(Common::convertToU32String(_("Select directory with game data")), true);
// Create Load dialog
_loadDialog = new SaveLoadChooser(_("Load game:"), _("Load"), false);
_loadDialog = new SaveLoadChooser(Common::convertToU32String(_("Load game:")), Common::convertToU32String(_("Load")), false);
}
void LauncherDialog::clean() {
@ -255,7 +255,7 @@ void LauncherDialog::close() {
}
void LauncherDialog::updateListing() {
StringArray l;
U32StringArray l;
ListWidget::ColorList colors;
ThemeEngine::FontColor color;
@ -293,7 +293,7 @@ void LauncherDialog::updateListing() {
// Insert the game into the launcher list
int pos = 0, size = l.size();
while (pos < size && (scumm_compareDictionary(description.c_str(), l[pos].c_str()) > 0))
while (pos < size && (scumm_compareDictionary(description.c_str(), l[pos].encode().c_str()) > 0))
pos++;
color = ThemeEngine::kFontColorNormal;
@ -323,7 +323,7 @@ void LauncherDialog::updateListing() {
// Update the filter settings, those are lost when "setList"
// is called.
_list->setFilter(_searchWidget->getEditString());
_list->setFilter(Common::convertFromU32String(_searchWidget->getEditString()));
}
void LauncherDialog::addGame() {
@ -562,7 +562,7 @@ bool LauncherDialog::doGameDetection(const Common::String &path) {
idx = 0;
} else {
// Display the candidates to the user and let her/him pick one
StringArray list;
U32StringArray list;
for (idx = 0; idx < (int)candidates.size(); idx++) {
Common::String description = candidates[idx].description;
@ -673,11 +673,11 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
break;
case kSearchCmd:
// Update the active search filter.
_list->setFilter(_searchWidget->getEditString());
_list->setFilter(Common::convertFromU32String(_searchWidget->getEditString()));
break;
case kSearchClearCmd:
// Reset the active search filter, thus showing all games again
_searchWidget->setEditString("");
_searchWidget->setEditString(Common::convertToU32String(""));
_list->setFilter("");
break;
default:

View File

@ -41,6 +41,9 @@ class SaveLoadChooser;
class LauncherDialog : public Dialog {
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
typedef Common::U32String U32String;
typedef Common::Array<Common::U32String> U32StringArray;
public:
LauncherDialog();
~LauncherDialog() override;

View File

@ -64,7 +64,7 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir)
_dirProgressText(nullptr),
_gameProgressText(nullptr) {
StringArray l;
U32StringArray l;
// The dir we start our scan at
_scanStack.push(startDir);

View File

@ -36,6 +36,7 @@ class StaticTextWidget;
class MassAddDialog : public Dialog {
typedef Common::Array<Common::String> StringArray;
typedef Common::Array<Common::U32String> U32StringArray;
public:
MassAddDialog(const Common::FSNode &startDir);

View File

@ -2123,7 +2123,7 @@ void GlobalOptionsDialog::addCloudControls(GuiObject *boss, const Common::String
_storageWizardCodeHint = new StaticTextWidget(boss, prefix + "StorageWizardCodeHint", Common::convertToU32String(_c("2. Get the code and enter it here:", "lowres")));
else
_storageWizardCodeHint = new StaticTextWidget(boss, prefix + "StorageWizardCodeHint", Common::convertToU32String(_("2. Get the code and enter it here:")));
_storageWizardCodeBox = new EditTextWidget(boss, prefix + "StorageWizardCodeBox", "", nullptr, 0, 0, ThemeEngine::kFontStyleConsole);
_storageWizardCodeBox = new EditTextWidget(boss, prefix + "StorageWizardCodeBox", Common::convertToU32String(""), nullptr, 0, 0, ThemeEngine::kFontStyleConsole);
_storageWizardPasteButton = new ButtonWidget(boss, prefix + "StorageWizardPasteButton", Common::convertToU32String(_("Paste")), _("Paste code from clipboard"), kPasteCodeStorageCmd);
_storageWizardConnectButton = new ButtonWidget(boss, prefix + "StorageWizardConnectButton", Common::convertToU32String(_("3. Connect")), _("Connect your cloud storage account"), kConnectStorageCmd);
_storageWizardConnectionStatusHint = new StaticTextWidget(boss, prefix + "StorageWizardConnectionStatusHint", Common::convertToU32String("..."));
@ -2394,7 +2394,7 @@ void GlobalOptionsDialog::close() {
void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kChooseSaveDirCmd: {
BrowserDialog browser(_("Select directory for saved games"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for saved games")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -2410,7 +2410,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
case kChooseThemeDirCmd: {
BrowserDialog browser(_("Select directory for GUI themes"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for GUI themes")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -2420,7 +2420,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
case kChooseExtraDirCmd: {
BrowserDialog browser(_("Select directory for extra files"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for extra files")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -2431,7 +2431,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
#ifdef DYNAMIC_MODULES
case kChoosePluginsDirCmd: {
BrowserDialog browser(_("Select directory for plugins"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for plugins")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -2444,7 +2444,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
#ifdef USE_CLOUD
#ifdef USE_SDL_NET
case kChooseRootDirCmd: {
BrowserDialog browser(_("Select directory for Files Manager /root/"), true);
BrowserDialog browser(Common::convertToU32String(_("Select directory for Files Manager /root/")), true);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode dir(browser.getResult());
@ -2480,7 +2480,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
#endif
#endif
case kChooseSoundFontCmd: {
BrowserDialog browser(_("Select SoundFont"), false);
BrowserDialog browser(Common::convertToU32String(_("Select SoundFont")), false);
if (browser.runModal() > 0) {
// User made his choice...
Common::FSNode file(browser.getResult());
@ -2513,7 +2513,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
case kPopUpItemSelectedCmd: {
if (_storageWizardCodeBox)
_storageWizardCodeBox->setEditString("");
_storageWizardCodeBox->setEditString(Common::convertToU32String(""));
// update container's scrollbar
reflowLayout();
break;
@ -2572,7 +2572,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
case kConnectStorageCmd: {
Common::String code = "";
Common::U32String code = "";
if (_storageWizardCodeBox)
code = _storageWizardCodeBox->getEditString();
if (code.size() == 0)
@ -2605,7 +2605,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
if (_storageWizardConnectionStatusHint)
_storageWizardConnectionStatusHint->setLabel(Common::convertToU32String(_("Connecting...")));
CloudMan.connectStorage(
_selectedStorageIndex, code,
_selectedStorageIndex, Common::convertFromU32String(code),
new Common::Callback<GlobalOptionsDialog, Networking::ErrorResponse>(this, &GlobalOptionsDialog::storageConnectionCallback)
);
_connectingStorage = true;
@ -2614,7 +2614,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
}
case kDisconnectStorageCmd: {
if (_storageWizardCodeBox)
_storageWizardCodeBox->setEditString("");
_storageWizardCodeBox->setEditString(Common::convertToU32String(""));
if (_selectedStorageIndex == CloudMan.getStorageIndex() && CloudMan.isWorking()) {
bool cancel = true;

View File

@ -1024,7 +1024,7 @@ void PredictiveDialog::loadAllDictionary(Dict &dict) {
void PredictiveDialog::pressEditText() {
Common::strlcpy(_predictiveResult, _prefix.c_str(), sizeof(_predictiveResult));
Common::strlcat(_predictiveResult, _currentWord.c_str(), sizeof(_predictiveResult));
_editText->setEditString(_predictiveResult);
_editText->setEditString(Common::convertToU32String(_predictiveResult));
//_editText->setCaretPos(_prefix.size() + _currentWord.size());
_editText->markAsDirty();
}

View File

@ -144,7 +144,7 @@ void RemoteBrowserDialog::updateListing() {
if (!_navigationLocked) {
// Populate the ListWidget
ListWidget::StringArray list;
ListWidget::U32StringArray list;
ListWidget::ColorList colors;
for (Common::Array<Cloud::StorageFile>::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
if (i->isDirectory()) {

View File

@ -371,7 +371,7 @@ enum {
kDelCmd = 'DEL '
};
SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode)
SaveLoadChooserSimple::SaveLoadChooserSimple(const U32String &title, const U32String &buttonLabel, bool saveMode)
: SaveLoadChooserDialog("SaveLoadChooser", saveMode), _list(nullptr), _chooseButton(nullptr), _deleteButton(nullptr), _gfxWidget(nullptr),
_container(nullptr) {
_backgroundType = ThemeEngine::kDialogBackgroundSpecial;
@ -391,7 +391,7 @@ SaveLoadChooserSimple::SaveLoadChooserSimple(const String &title, const String &
// Buttons
new ButtonWidget(this, "SaveLoadChooser.Cancel", Common::convertToU32String(_("Cancel")), nullptr, kCloseCmd);
_chooseButton = new ButtonWidget(this, "SaveLoadChooser.Choose", Common::U32String(buttonLabel), nullptr, kChooseCmd);
_chooseButton = new ButtonWidget(this, "SaveLoadChooser.Choose", buttonLabel, nullptr, kChooseCmd);
_chooseButton->setEnabled(false);
_deleteButton = new ButtonWidget(this, "SaveLoadChooser.Delete", Common::convertToU32String(_("Delete")), nullptr, kDelCmd);
@ -424,7 +424,7 @@ int SaveLoadChooserSimple::runIntern() {
return Dialog::runModal();
}
const Common::String &SaveLoadChooserSimple::getResultString() const {
const Common::U32String &SaveLoadChooserSimple::getResultString() const {
int selItem = _list->getSelected();
return (selItem >= 0) ? _list->getSelectedString() : _resultString;
}
@ -616,7 +616,7 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
if (_chooseButton->isEnabled() && _list->getSelectedString() == _("Untitled saved game") &&
_list->getSelectionColor() == ThemeEngine::kFontColorAlternate) {
_list->setEditString("");
_list->setEditString(Common::convertToU32String(""));
_list->setEditColor(ThemeEngine::kFontColorNormal);
}
}
@ -666,7 +666,7 @@ void SaveLoadChooserSimple::close() {
_metaEngine = nullptr;
_target.clear();
_saveList.clear();
_list->setList(StringArray());
_list->setList(U32StringArray());
SaveLoadChooserDialog::close();
}
@ -676,7 +676,7 @@ void SaveLoadChooserSimple::updateSaveList() {
int curSlot = 0;
int saveSlot = 0;
StringArray saveNames;
U32StringArray saveNames;
ListWidget::ColorList colors;
for (SaveStateList::const_iterator x = _saveList.begin(); x != _saveList.end(); ++x) {
// Handle gaps in the list of save games
@ -752,7 +752,7 @@ enum {
kNewSaveCmd = 'SAVE'
};
SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveMode)
SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::U32String &title, bool saveMode)
: SaveLoadChooserDialog("SaveLoadChooser", saveMode), _lines(0), _columns(0), _entriesPerPage(0),
_curPage(0), _newSaveContainer(nullptr), _nextFreeSaveSlot(0), _buttons() {
_backgroundType = ThemeEngine::kDialogBackgroundSpecial;
@ -772,7 +772,7 @@ SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveM
_prevButton->setEnabled(false);
// Page display
_pageDisplay = new StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String());
_pageDisplay = new StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::U32String());
_pageDisplay->setAlign(Graphics::kTextAlignEnd);
}
@ -784,7 +784,7 @@ SaveLoadChooserGrid::~SaveLoadChooserGrid() {
delete _pageDisplay;
}
const Common::String &SaveLoadChooserGrid::getResultString() const {
const Common::U32String &SaveLoadChooserGrid::getResultString() const {
return _resultString;
}
@ -1170,11 +1170,11 @@ SavenameDialog::SavenameDialog()
_targetSlot = 0;
}
void SavenameDialog::setDescription(const Common::String &desc) {
void SavenameDialog::setDescription(const Common::U32String &desc) {
_description->setEditString(desc);
}
const Common::String &SavenameDialog::getDescription() {
const Common::U32String &SavenameDialog::getDescription() {
return _description->getEditString();
}

View File

@ -92,7 +92,7 @@ public:
#endif // !DISABLE_SAVELOADCHOOSER_GRID
int run(const Common::String &target, const MetaEngine *metaEngine);
virtual const Common::String &getResultString() const = 0;
virtual const Common::U32String &getResultString() const = 0;
protected:
virtual int runIntern() = 0;
@ -133,12 +133,15 @@ protected:
class SaveLoadChooserSimple : public SaveLoadChooserDialog {
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
typedef Common::U32String U32String;
typedef Common::Array<Common::U32String> U32StringArray;
public:
SaveLoadChooserSimple(const String &title, const String &buttonLabel, bool saveMode);
SaveLoadChooserSimple(const U32String &title, const U32String &buttonLabel, bool saveMode);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
const Common::String &getResultString() const override;
const Common::U32String &getResultString() const override;
void reflowLayout() override;
@ -163,7 +166,7 @@ private:
StaticTextWidget *_playtime;
StaticTextWidget *_pageTitle;
String _resultString;
U32String _resultString;
void addThumbnailContainer();
void updateSelection(bool redraw);
@ -177,8 +180,8 @@ class SavenameDialog : public Dialog {
public:
SavenameDialog();
void setDescription(const Common::String &desc);
const Common::String &getDescription();
void setDescription(const Common::U32String &desc);
const Common::U32String &getDescription();
void setTargetSlot(int slot) { _targetSlot = slot; }
@ -193,10 +196,10 @@ private:
class SaveLoadChooserGrid : public SaveLoadChooserDialog {
public:
SaveLoadChooserGrid(const Common::String &title, bool saveMode);
SaveLoadChooserGrid(const Common::U32String &title, bool saveMode);
~SaveLoadChooserGrid() override;
const Common::String &getResultString() const override;
const Common::U32String &getResultString() const override;
void open() override;
@ -224,7 +227,7 @@ private:
ContainerWidget *_newSaveContainer;
int _nextFreeSaveSlot;
Common::String _resultString;
Common::U32String _resultString;
SavenameDialog _savenameDialog;
bool selectDescription();

View File

@ -30,7 +30,7 @@
namespace GUI {
SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode)
SaveLoadChooser::SaveLoadChooser(const U32String &title, const U32String &buttonLabel, bool saveMode)
: _impl(nullptr), _title(title), _buttonLabel(buttonLabel), _saveMode(saveMode) {
}
@ -63,7 +63,7 @@ void SaveLoadChooser::selectChooser(const MetaEngine &engine) {
#endif // !DISABLE_SAVELOADCHOOSER_GRID
}
Common::String SaveLoadChooser::createDefaultSaveDescription(const int slot) const {
Common::U32String SaveLoadChooser::createDefaultSaveDescription(const int slot) const {
#if defined(USE_SAVEGAME_TIMESTAMP)
TimeDate curTime;
g_system->getTimeAndDate(curTime);
@ -113,7 +113,7 @@ int SaveLoadChooser::runModalWithPluginAndTarget(const Plugin *plugin, const Str
return ret;
}
const Common::String &SaveLoadChooser::getResultString() const {
const Common::U32String &SaveLoadChooser::getResultString() const {
assert(_impl);
return _impl->getResultString();
}

View File

@ -32,16 +32,17 @@ class SaveLoadChooserDialog;
class SaveLoadChooser {
typedef Common::String String;
typedef Common::U32String U32String;
protected:
SaveLoadChooserDialog *_impl;
const String _title;
const String _buttonLabel;
const U32String _title;
const U32String _buttonLabel;
const bool _saveMode;
void selectChooser(const MetaEngine &engine);
public:
SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode);
SaveLoadChooser(const U32String &title, const U32String &buttonLabel, bool saveMode);
~SaveLoadChooser();
/**
@ -53,7 +54,7 @@ public:
int runModalWithCurrentTarget();
int runModalWithPluginAndTarget(const Plugin *plugin, const String &target);
const Common::String &getResultString() const;
const Common::U32String &getResultString() const;
/**
* Creates a default save description for the specified slot. Depending
@ -68,7 +69,7 @@ public:
* @param slot The slot number (must be >= 0).
* @return The slot description.
*/
Common::String createDefaultSaveDescription(const int slot) const;
Common::U32String createDefaultSaveDescription(const int slot) const;
};
} // End of namespace GUI

View File

@ -102,7 +102,7 @@ void ThemeBrowser::updateListing() {
const Common::String currentThemeId = g_gui.theme()->getThemeId();
int currentThemeIndex = 0, index = 0;
ListWidget::StringArray list;
ListWidget::U32StringArray list;
for (ThemeDescList::const_iterator i = _themes.begin(); i != _themes.end(); ++i, ++index) {
list.push_back(i->name);

View File

@ -69,7 +69,7 @@ void EditableWidget::reflowLayout() {
}
}
void EditableWidget::setEditString(const String &str) {
void EditableWidget::setEditString(const U32String &str) {
// TODO: We probably should filter the input string here,
// e.g. using tryInsertChar.
_editString = str;
@ -212,7 +212,7 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
case Common::KEYCODE_c:
if (state.flags & Common::KBD_CTRL) {
if (!getEditString().empty())
g_system->setTextInClipboard(getEditString());
g_system->setTextInClipboard(Common::convertFromU32String(getEditString()));
} else {
defaultKeyDownHandler(state, dirty, forcecaret, handled);
}

View File

@ -42,8 +42,9 @@ namespace GUI {
class EditableWidget : public Widget, public CommandSender {
public:
typedef Common::String String;
typedef Common::U32String U32String;
protected:
String _editString;
U32String _editString;
uint32 _cmd;
@ -69,8 +70,8 @@ public:
void init();
virtual void setEditString(const String &str);
virtual const String &getEditString() const { return _editString; }
virtual void setEditString(const U32String &str);
virtual const U32String &getEditString() const { return _editString; }
void handleTickle() override;
bool handleKeyDown(Common::KeyState state) override;

View File

@ -28,7 +28,7 @@
namespace GUI {
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, const char *tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font)
EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, const char *tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font)
: EditableWidget(boss, x, y - 1, w, h + 2, tooltip, cmd) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
_type = kEditTextWidget;
@ -40,7 +40,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, int x, int y, int w, int h, cons
_leftPadding = _rightPadding = 0;
}
EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String &text, const char *tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font)
EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const U32String &text, const char *tooltip, uint32 cmd, uint32 finishCmd, ThemeEngine::FontStyle font)
: EditableWidget(boss, name, tooltip, cmd) {
setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
_type = kEditTextWidget;
@ -52,7 +52,7 @@ EditTextWidget::EditTextWidget(GuiObject *boss, const String &name, const String
_leftPadding = _rightPadding = 0;
}
void EditTextWidget::setEditString(const String &str) {
void EditTextWidget::setEditString(const U32String &str) {
EditableWidget::setEditString(str);
_backupString = str;
}

View File

@ -33,17 +33,18 @@ namespace GUI {
class EditTextWidget : public EditableWidget {
protected:
typedef Common::String String;
typedef Common::U32String U32String;
String _backupString;
U32String _backupString;
int _leftPadding;
int _rightPadding;
public:
EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text, const char *tooltip = nullptr, uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal);
EditTextWidget(GuiObject *boss, const String &name, const String &text, const char *tooltp = nullptr, uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal);
EditTextWidget(GuiObject *boss, int x, int y, int w, int h, const U32String &text, const char *tooltip = nullptr, uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal);
EditTextWidget(GuiObject *boss, const String &name, const U32String &text, const char *tooltp = nullptr, uint32 cmd = 0, uint32 finishCmd = 0, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleNormal);
void setEditString(const String &str) override;
void setEditString(const U32String &str) override;
void handleMouseDown(int x, int y, int button, int clickCount) override;

View File

@ -165,7 +165,7 @@ ThemeEngine::FontColor ListWidget::getSelectionColor() const {
return _listColors[_listIndex[_selectedItem]];
}
void ListWidget::setList(const StringArray &list, const ColorList *colors) {
void ListWidget::setList(const U32StringArray &list, const ColorList *colors) {
if (_editMode && _caretVisible)
drawCaret(true);
@ -287,7 +287,7 @@ void ListWidget::handleMouseMoved(int x, int y, int button) {
if (item != -1) {
if(_lastRead != item) {
read(_dataList[item]);
read(Common::convertFromU32String(_dataList[item]));
_lastRead = item;
}
}
@ -350,8 +350,8 @@ bool ListWidget::handleKeyDown(Common::KeyState state) {
int newSelectedItem = 0;
int bestMatch = 0;
bool stop;
for (StringArray::const_iterator i = _list.begin(); i != _list.end(); ++i) {
const int match = matchingCharsIgnoringCase(i->c_str(), _quickSelectStr.c_str(), stop, _dictionarySelect);
for (U32StringArray::const_iterator i = _list.begin(); i != _list.end(); ++i) {
const int match = matchingCharsIgnoringCase(i->encode().c_str(), _quickSelectStr.c_str(), stop, _dictionarySelect);
if (match > bestMatch || stop) {
_selectedItem = newSelectedItem;
bestMatch = match;
@ -535,7 +535,7 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
void ListWidget::drawWidget() {
int i, pos, len = _list.size();
Common::String buffer;
Common::U32String buffer;
// Draw a thin frame around the list.
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h),
@ -758,8 +758,8 @@ void ListWidget::setFilter(const String &filter, bool redraw) {
_list.clear();
_listIndex.clear();
for (StringArray::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) {
tmp = *i;
for (U32StringArray::iterator i = _dataList.begin(); i != _dataList.end(); ++i, ++n) {
tmp = Common::convertFromU32String(*i);
tmp.toLowercase();
bool matches = true;
tok.reset();

View File

@ -51,10 +51,14 @@ class ListWidget : public EditableWidget {
public:
typedef Common::String String;
typedef Common::Array<Common::String> StringArray;
typedef Common::U32String U32String;
typedef Common::Array<Common::U32String> U32StringArray;
typedef Common::Array<ThemeEngine::FontColor> ColorList;
protected:
StringArray _list;
StringArray _dataList;
U32StringArray _list;
U32StringArray _dataList;
ColorList _listColors;
Common::Array<int> _listIndex;
bool _editable;
@ -94,15 +98,15 @@ public:
bool containsWidget(Widget *) const override;
Widget *findWidget(int x, int y) override;
void setList(const StringArray &list, const ColorList *colors = nullptr);
const StringArray &getList() const { return _dataList; }
void setList(const U32StringArray &list, const ColorList *colors = nullptr);
const U32StringArray &getList() const { return _dataList; }
void append(const String &s, ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal);
void setSelected(int item);
int getSelected() const { return (_filter.empty() || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
const String &getSelectedString() const { return _list[_selectedItem]; }
const U32String &getSelectedString() const { return _list[_selectedItem]; }
ThemeEngine::FontColor getSelectionColor() const;
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }