aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-04 13:00:26 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit73bb2e20afdd625998a1438adf29e5d9dbaa2929 (patch)
treebf4a0517e20bf037229d86e049a897164042e4a5 /gui
parent4aa8e23ea24e275f6b68fe6ed773ee2129d4de26 (diff)
downloadscummvm-rg350-73bb2e20afdd625998a1438adf29e5d9dbaa2929.tar.gz
scummvm-rg350-73bb2e20afdd625998a1438adf29e5d9dbaa2929.tar.bz2
scummvm-rg350-73bb2e20afdd625998a1438adf29e5d9dbaa2929.zip
GUI: Clean up in RemoteBrowser
Diffstat (limited to 'gui')
-rw-r--r--gui/downloaddialog.cpp2
-rw-r--r--gui/remotebrowser.cpp82
-rw-r--r--gui/remotebrowser.h5
3 files changed, 26 insertions, 63 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index e94b19634b..6e9410dd51 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -42,7 +42,7 @@ DownloadDialog::DownloadDialog(uint32 storageId):
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
_browser = new BrowserDialog(_("Select directory where to download game data"), true);
- _remoteBrowser = new RemoteBrowserDialog(_("Select directory with game data"), true);
+ _remoteBrowser = new RemoteBrowserDialog(_("Select directory with game data"));
_messageText = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.DialogDesc", _("Press the button to download a directory"));
_mainButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _("Start download"), 0, kDownloadDialogButtonCmd);
diff --git a/gui/remotebrowser.cpp b/gui/remotebrowser.cpp
index ffa24ecf7a..fac0b02e35 100644
--- a/gui/remotebrowser.cpp
+++ b/gui/remotebrowser.cpp
@@ -36,40 +36,20 @@ namespace GUI {
enum {
kChooseCmd = 'Chos',
- kGoUpCmd = 'GoUp',
- kHiddenCmd = 'Hidd'
+ kGoUpCmd = 'GoUp'
};
-/* We want to use this as a general directory selector at some point... possible uses
- * - to select the data dir for a game
- * - to select the place where save games are stored
- * - others???
- */
-
-RemoteBrowserDialog::RemoteBrowserDialog(const char *title, bool dirRemoteBrowser)
+RemoteBrowserDialog::RemoteBrowserDialog(const char *title)
: Dialog("Browser"), _navigationLocked(false), _updateList(false) {
+ _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
- _isDirRemoteBrowser = dirRemoteBrowser;
- _fileList = NULL;
- _currentPath = NULL;
-
- // Headline - TODO: should be customizable during creation time
new StaticTextWidget(this, "Browser.Headline", title);
-
- // Current path - TODO: handle long paths ?
_currentPath = new StaticTextWidget(this, "Browser.Path", "DUMMY");
- // Add file list
_fileList = new ListWidget(this, "Browser.List");
_fileList->setNumberingMode(kListNumberingOff);
_fileList->setEditable(false);
- _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
-
- // hide checkbox for the "show hidden files" state.
- //_showHiddenWidget = new CheckboxWidget(this, "Browser.Hidden", _("Show hidden files"), _("Show files marked with the hidden attribute"), kHiddenCmd);
-
- // Buttons
if (g_system->getOverlayWidth() > 320)
new ButtonWidget(this, "Browser.Up", _("Go up"), _("Go to previous directory level"), kGoUpCmd);
else
@@ -85,50 +65,32 @@ void RemoteBrowserDialog::open() {
void RemoteBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
- case kChooseCmd:
- if (_isDirRemoteBrowser) {
- // If nothing is selected in the list widget, choose the current dir.
- // Else, choose the dir that is selected.
- int selection = _fileList->getSelected();
- if (selection >= 0)
- _choice = _nodeContent[selection];
- else
- _choice = _node;
- setResult(1);
- close();
- } else {
- int selection = _fileList->getSelected();
- if (selection < 0)
- break;
- if (_nodeContent[selection].isDirectory()) {
- _node = _nodeContent[selection];
- updateListing();
- } else {
- _choice = _nodeContent[selection];
- setResult(1);
- close();
- }
- }
+ case kChooseCmd: {
+ // If nothing is selected in the list widget, choose the current dir.
+ // Else, choose the dir that is selected.
+ int selection = _fileList->getSelected();
+ if (selection >= 0)
+ _choice = _nodeContent[selection];
+ else
+ _choice = _node;
+ setResult(1);
+ close();
break;
+ }
case kGoUpCmd:
goUp();
break;
case kListItemActivatedCmd:
case kListItemDoubleClickedCmd:
- if (_nodeContent[data].isDirectory()) {
- _node = _nodeContent[data];
- listDirectory(_node);
- } else if (!_isDirRemoteBrowser) { //TODO: ????
- _choice = _nodeContent[data];
- setResult(1);
- close();
+ if (_nodeContent[data].isDirectory()) {
+ listDirectory(_nodeContent[data]);
}
break;
case kListSelectionChangedCmd:
- // We do not allow selecting directories in directory
- // RemoteBrowser mode, thus we will invalidate the selection
- // when the user selects an directory over here.
- if (data != (uint32)-1 && _isDirRemoteBrowser && !_nodeContent[data].isDirectory())
+ // We do not allow selecting directories,
+ // thus we will invalidate the selection
+ // when the user selects a directory over here.
+ if (data != (uint32)-1 && !_nodeContent[data].isDirectory())
_fileList->setSelected(-1);
break;
default:
@@ -202,19 +164,21 @@ void RemoteBrowserDialog::listDirectory(Cloud::StorageFile node) {
false
);
+ _backupNode = _node;
_node = node;
updateListing();
}
void RemoteBrowserDialog::directoryListedCallback(Cloud::Storage::ListDirectoryResponse response) {
_navigationLocked = false;
- //TODO: list files from response
_nodeContent = response.value;
_updateList = true;
}
void RemoteBrowserDialog::directoryListedErrorCallback(Networking::ErrorResponse error) {
_navigationLocked = false;
+ _node = _backupNode;
+ _updateList = true;
//TODO: show error message
}
diff --git a/gui/remotebrowser.h b/gui/remotebrowser.h
index 55be1198b5..ca1f9379cd 100644
--- a/gui/remotebrowser.h
+++ b/gui/remotebrowser.h
@@ -38,7 +38,7 @@ class CommandSender;
class RemoteBrowserDialog : public Dialog {
public:
- RemoteBrowserDialog(const char *title, bool dirRemoteBrowser);
+ RemoteBrowserDialog(const char *title);
virtual void open();
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
@@ -49,10 +49,9 @@ public:
protected:
ListWidget *_fileList;
StaticTextWidget *_currentPath;
- Cloud::StorageFile _node;
+ Cloud::StorageFile _node, _backupNode;
Common::Array<Cloud::StorageFile> _nodeContent;
Cloud::StorageFile _choice;
- bool _isDirRemoteBrowser;
bool _navigationLocked;
bool _updateList;