[Scummvm-git-logs] scummvm branch-2-6 -> 660e0fa921348f3236b12aa62265755f2d4073cf
lotharsm
noreply at scummvm.org
Sun Jul 10 14:50:54 UTC 2022
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:
1e3ee46f80 GUI: Add option to reset icons cache for grid view
660e0fa921 GUI: Fix calculating size of previously downloaded icons files
Commit: 1e3ee46f8046ec08cb00673c88e409aa6beaea03
https://github.com/scummvm/scummvm/commit/1e3ee46f8046ec08cb00673c88e409aa6beaea03
Author: Lothar Serra Mari (mail at serra.me)
Date: 2022-07-10T16:30:41+02:00
Commit Message:
GUI: Add option to reset icons cache for grid view
Changed paths:
gui/downloadiconsdialog.cpp
gui/downloadiconsdialog.h
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
gui/themes/default.inc
gui/themes/residualvm.zip
gui/themes/scummclassic.zip
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
gui/themes/scummmodern.zip
gui/themes/scummremastered.zip
diff --git a/gui/downloadiconsdialog.cpp b/gui/downloadiconsdialog.cpp
index b3d164a39d4..ec311e86e1a 100644
--- a/gui/downloadiconsdialog.cpp
+++ b/gui/downloadiconsdialog.cpp
@@ -42,7 +42,8 @@ namespace GUI {
enum {
kDownloadProceedCmd = 'Dlpr',
kListDownloadFinishedCmd = 'DlLE',
- kCleanupCmd = 'DlCL'
+ kCleanupCmd = 'DlCL',
+ kClearCacheCmd = 'DlCC'
};
struct DialogState {
@@ -186,6 +187,7 @@ DownloadIconsDialog::DownloadIconsDialog() :
_downloadSpeedLabel = new StaticTextWidget(this, "GlobalOptions_DownloadIconsDialog.DownloadSpeed", Common::U32String());
_cancelButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.MainButton", _("Cancel download"), Common::U32String(), kCleanupCmd);
_closeButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.CloseButton", _("Hide"), Common::U32String(), kCloseCmd);
+ _clearCacheButton = new ButtonWidget(this, "GlobalOptions_DownloadIconsDialog.ResetButton", _("Clear Cache"), Common::U32String(), kClearCacheCmd);
if (!g_state) {
g_state = new DialogState;
@@ -229,7 +231,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
_statusText->setLabel(_("Downloading icons list..."));
_cancelButton->setLabel(_("Cancel download"));
_cancelButton->setCmd(kCleanupCmd);
- _closeButton->setVisible(false);
+ _closeButton->setVisible(true);
g_state->totalSize = 0;
g_state->fileHash.clear();
@@ -239,7 +241,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
_statusText->setLabel(Common::U32String::format(_("Downloading icons list... %d entries"), g_state->fileHash.size()));
_cancelButton->setLabel(_("Cancel download"));
_cancelButton->setCmd(kCleanupCmd);
- _closeButton->setVisible(false);
+ _closeButton->setVisible(true);
break;
case kDownloadStateListCalculated: {
@@ -266,6 +268,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
_closeButton->setLabel(_("Hide"));
_closeButton->setCmd(kCloseCmd);
_closeButton->setEnabled(true);
+ _clearCacheButton->setEnabled(false);
break;
case kDownloadComplete: {
@@ -280,6 +283,7 @@ void DownloadIconsDialog::setState(IconProcessState state) {
_closeButton->setLabel(_("Close"));
_closeButton->setCmd(kCleanupCmd);
_closeButton->setEnabled(true);
+ _clearCacheButton->setEnabled(true);
break;
}
}
@@ -313,6 +317,10 @@ void DownloadIconsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
setState(kDownloadStateDownloading);
g_state->proceedDownload();
break;
+ case kClearCacheCmd:
+ _clearCacheButton->setEnabled(false);
+ clearCache();
+ break;
default:
Dialog::handleCommand(sender, cmd, data);
}
@@ -406,6 +414,7 @@ void DownloadIconsDialog::calculateList() {
if (g_state->totalSize == 0) {
Common::U32String error(_("No new icons packs available"));
+ _closeButton->setEnabled(false);
setError(error);
return;
}
@@ -413,5 +422,58 @@ void DownloadIconsDialog::calculateList() {
setState(kDownloadStateListCalculated);
}
+void DownloadIconsDialog::clearCache() {
+ Common::String sizeUnits;
+
+ Common::String iconsPath = ConfMan.get("iconspath");
+ if (iconsPath.empty()) {
+ Common::U32String str(_("ERROR: No icons path set"));
+ setError(str);
+ return;
+ }
+
+ Common::FSDirectory *iconDir = new Common::FSDirectory(iconsPath);
+
+ Common::ArchiveMemberList iconFiles;
+
+ iconDir->listMatchingMembers(iconFiles, "gui-icons*.dat");
+
+ for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
+ Common::String fname = (*ic)->getName();
+ Common::SeekableReadStream *str = (*ic)->createReadStream();
+ uint32 size = str->size();
+ delete str;
+
+ g_state->totalSize += size;
+ }
+
+ Common::String size = getHumanReadableBytes(g_state->totalSize, sizeUnits);
+
+ GUI::MessageDialog dialog(Common::U32String::format(_("You are about to remove %s %s of data, deleting all previously downloaded icon files. Do you want to proceed?"), size.c_str(), sizeUnits.c_str()), _("Proceed"), _("Cancel"));
+ if (dialog.runModal() == ::GUI::kMessageOK) {
+
+ // Build list of previously downloaded icon files
+ for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
+ Common::String fname = (*ic)->getName();
+ Common::FSNode fs(iconsPath + fname);
+ Common::WriteStream *str = fs.createWriteStream();
+
+ // Overwrite previously downloaded icon files with dummy data
+ str->writeByte(0);
+ str->finalize();
+ }
+ g_state->fileHash.clear();
+
+ // Reload (now empty) icons set
+ g_gui.initIconsSet();
+
+ // Fetch current icons list file and re-trigger downloads
+ g_state->downloadList();
+ calculateList();
+ _cancelButton->setVisible(true);
+ } else {
+ _clearCacheButton->setEnabled(true);
+ }
+}
} // End of namespace GUI
diff --git a/gui/downloadiconsdialog.h b/gui/downloadiconsdialog.h
index d03193fcd91..016c2e52326 100644
--- a/gui/downloadiconsdialog.h
+++ b/gui/downloadiconsdialog.h
@@ -54,6 +54,7 @@ class DownloadIconsDialog : public Dialog, public CommandSender {
SliderWidget *_progressBar;
ButtonWidget *_cancelButton;
ButtonWidget *_closeButton;
+ ButtonWidget *_clearCacheButton;
Common::String _localDirectory;
bool _close;
@@ -77,6 +78,7 @@ public:
private:
void calculateList();
+ void clearCache();
void setState(IconProcessState state);
};
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index a248caae5ab..08f99ff62c9 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -1064,6 +1064,9 @@
<widget name = 'CloseButton'
type = 'Button'
/>
+ <widget name = 'ResetButton'
+ type = 'Button'
+ />
</layout>
</layout>
</dialog>
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index 30ef493da46..1c529270645 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -1034,6 +1034,9 @@
<widget name = 'CloseButton'
type = 'Button'
/>
+ <widget name = 'ResetButton'
+ type = 'Button'
+ />
</layout>
</layout>
</dialog>
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 46c366d07a3..8f4197ba74f 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -2319,6 +2319,9 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<widget name='CloseButton' "
"type='Button' "
"/>"
+"<widget name='ResetButton' "
+"type='Button' "
+"/>"
"</layout>"
"</layout>"
"</dialog>"
@@ -4242,6 +4245,9 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<widget name='CloseButton' "
"type='Button' "
"/>"
+"<widget name='ResetButton' "
+"type='Button' "
+"/>"
"</layout>"
"</layout>"
"</dialog>"
diff --git a/gui/themes/residualvm.zip b/gui/themes/residualvm.zip
index 235ca3ebd03..ca395231576 100644
Binary files a/gui/themes/residualvm.zip and b/gui/themes/residualvm.zip differ
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 5b7b1a36847..64715b963bc 100644
Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index 1f00d4e764f..98929bf1d7f 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -935,6 +935,9 @@
<widget name = 'CloseButton'
type = 'Button'
/>
+ <widget name = 'ResetButton'
+ type = 'Button'
+ />
</layout>
</layout>
</dialog>
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index f019724b4c8..95609beea59 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -948,6 +948,9 @@
<widget name = 'CloseButton'
type = 'Button'
/>
+ <widget name = 'ResetButton'
+ type = 'Button'
+ />
</layout>
</layout>
</dialog>
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 25dc08628c0..322d77e415b 100644
Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip
index 182155d9b61..ca2df14d3d2 100644
Binary files a/gui/themes/scummremastered.zip and b/gui/themes/scummremastered.zip differ
Commit: 660e0fa921348f3236b12aa62265755f2d4073cf
https://github.com/scummvm/scummvm/commit/660e0fa921348f3236b12aa62265755f2d4073cf
Author: Lothar Serra Mari (mail at serra.me)
Date: 2022-07-10T16:30:46+02:00
Commit Message:
GUI: Fix calculating size of previously downloaded icons files
Changed paths:
gui/downloadiconsdialog.cpp
diff --git a/gui/downloadiconsdialog.cpp b/gui/downloadiconsdialog.cpp
index ec311e86e1a..96f595b9d06 100644
--- a/gui/downloadiconsdialog.cpp
+++ b/gui/downloadiconsdialog.cpp
@@ -423,8 +423,6 @@ void DownloadIconsDialog::calculateList() {
}
void DownloadIconsDialog::clearCache() {
- Common::String sizeUnits;
-
Common::String iconsPath = ConfMan.get("iconspath");
if (iconsPath.empty()) {
Common::U32String str(_("ERROR: No icons path set"));
@@ -437,6 +435,7 @@ void DownloadIconsDialog::clearCache() {
Common::ArchiveMemberList iconFiles;
iconDir->listMatchingMembers(iconFiles, "gui-icons*.dat");
+ int totalSize = 0;
for (auto ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
Common::String fname = (*ic)->getName();
@@ -444,10 +443,11 @@ void DownloadIconsDialog::clearCache() {
uint32 size = str->size();
delete str;
- g_state->totalSize += size;
+ totalSize += size;
}
- Common::String size = getHumanReadableBytes(g_state->totalSize, sizeUnits);
+ Common::String sizeUnits;
+ Common::String size = getHumanReadableBytes(totalSize, sizeUnits);
GUI::MessageDialog dialog(Common::U32String::format(_("You are about to remove %s %s of data, deleting all previously downloaded icon files. Do you want to proceed?"), size.c_str(), sizeUnits.c_str()), _("Proceed"), _("Cancel"));
if (dialog.runModal() == ::GUI::kMessageOK) {
More information about the Scummvm-git-logs
mailing list