mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-19 02:36:27 +01:00
DolphinWX: Don't store compression progress in member variables
Just some extra cleanup.
This commit is contained in:
parent
6a75212e7a
commit
8cad70238c
@ -53,9 +53,19 @@
|
|||||||
#include "DolphinWX/Main.h"
|
#include "DolphinWX/Main.h"
|
||||||
#include "DolphinWX/WxUtils.h"
|
#include "DolphinWX/WxUtils.h"
|
||||||
|
|
||||||
size_t CGameListCtrl::m_currentItem = 0;
|
struct CompressionProgress final
|
||||||
size_t CGameListCtrl::m_numberItem = 0;
|
{
|
||||||
std::string CGameListCtrl::m_currentFilename;
|
public:
|
||||||
|
CompressionProgress(int items_done_, int items_total_, const std::string& current_filename_, wxProgressDialog* dialog_)
|
||||||
|
: items_done(items_done_), items_total(items_total_), current_filename(current_filename_), dialog(dialog_)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
int items_done;
|
||||||
|
int items_total;
|
||||||
|
std::string current_filename;
|
||||||
|
wxProgressDialog* dialog;
|
||||||
|
};
|
||||||
|
|
||||||
static bool sorted = false;
|
static bool sorted = false;
|
||||||
|
|
||||||
static int CompareGameListItems(const GameListItem* iso1, const GameListItem* iso2,
|
static int CompareGameListItems(const GameListItem* iso1, const GameListItem* iso2,
|
||||||
@ -1067,12 +1077,14 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event))
|
|||||||
|
|
||||||
bool CGameListCtrl::MultiCompressCB(const std::string& text, float percent, void* arg)
|
bool CGameListCtrl::MultiCompressCB(const std::string& text, float percent, void* arg)
|
||||||
{
|
{
|
||||||
percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
|
CompressionProgress* progress = static_cast<CompressionProgress*>(arg);
|
||||||
wxString textString(StrToWxStr(StringFromFormat("%s (%i/%i) - %s",
|
|
||||||
m_currentFilename.c_str(), (int)m_currentItem + 1,
|
|
||||||
(int)m_numberItem, text.c_str())));
|
|
||||||
|
|
||||||
return ((wxProgressDialog*)arg)->Update((int)(percent * 1000), textString);
|
float total_percent = ((float)progress->items_done + percent) / (float)progress->items_total;
|
||||||
|
wxString text_string(StrToWxStr(StringFromFormat("%s (%i/%i) - %s",
|
||||||
|
progress->current_filename.c_str(), progress->items_done + 1,
|
||||||
|
progress->items_total, text.c_str())));
|
||||||
|
|
||||||
|
return progress->dialog->Update(total_percent * progress->dialog->GetRange(), text_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::OnMultiCompressISO(wxCommandEvent& /*event*/)
|
void CGameListCtrl::OnMultiCompressISO(wxCommandEvent& /*event*/)
|
||||||
@ -1118,7 +1130,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
|
|||||||
wxProgressDialog progressDialog(
|
wxProgressDialog progressDialog(
|
||||||
_compress ? _("Compressing ISO") : _("Decompressing ISO"),
|
_compress ? _("Compressing ISO") : _("Decompressing ISO"),
|
||||||
_("Working..."),
|
_("Working..."),
|
||||||
1000,
|
1000, // Arbitrary number that's larger than the dialog's width in pixels
|
||||||
this,
|
this,
|
||||||
wxPD_APP_MODAL |
|
wxPD_APP_MODAL |
|
||||||
wxPD_CAN_ABORT |
|
wxPD_CAN_ABORT |
|
||||||
@ -1126,9 +1138,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
|
|||||||
wxPD_SMOOTH
|
wxPD_SMOOTH
|
||||||
);
|
);
|
||||||
|
|
||||||
// These two variables are used when the progress dialog is updated
|
CompressionProgress progress(0, GetSelectedItemCount(), "", &progressDialog);
|
||||||
m_currentItem = 0;
|
|
||||||
m_numberItem = GetSelectedItemCount();
|
|
||||||
|
|
||||||
for (const GameListItem* iso : selected_items)
|
for (const GameListItem* iso : selected_items)
|
||||||
{
|
{
|
||||||
@ -1139,10 +1149,9 @@ void CGameListCtrl::CompressSelection(bool _compress)
|
|||||||
|
|
||||||
if (!iso->IsCompressed() && _compress)
|
if (!iso->IsCompressed() && _compress)
|
||||||
{
|
{
|
||||||
std::string FileName, FileExt;
|
std::string FileName;
|
||||||
SplitPath(iso->GetFileName(), nullptr, &FileName, &FileExt);
|
SplitPath(iso->GetFileName(), nullptr, &FileName, nullptr);
|
||||||
// Update the file name in the progress dialog
|
progress.current_filename = FileName;
|
||||||
m_currentFilename = FileName;
|
|
||||||
FileName.append(".gcz");
|
FileName.append(".gcz");
|
||||||
|
|
||||||
std::string OutputFileName;
|
std::string OutputFileName;
|
||||||
@ -1161,14 +1170,13 @@ void CGameListCtrl::CompressSelection(bool _compress)
|
|||||||
all_good &= DiscIO::CompressFileToBlob(iso->GetFileName(),
|
all_good &= DiscIO::CompressFileToBlob(iso->GetFileName(),
|
||||||
OutputFileName,
|
OutputFileName,
|
||||||
(iso->GetPlatform() == DiscIO::IVolume::WII_DISC) ? 1 : 0,
|
(iso->GetPlatform() == DiscIO::IVolume::WII_DISC) ? 1 : 0,
|
||||||
16384, &MultiCompressCB, &progressDialog);
|
16384, &MultiCompressCB, &progress);
|
||||||
}
|
}
|
||||||
else if (iso->IsCompressed() && !_compress)
|
else if (iso->IsCompressed() && !_compress)
|
||||||
{
|
{
|
||||||
std::string FileName, FileExt;
|
std::string FileName;
|
||||||
SplitPath(iso->GetFileName(), nullptr, &FileName, &FileExt);
|
SplitPath(iso->GetFileName(), nullptr, &FileName, nullptr);
|
||||||
// Update the file name in the progress dialog
|
progress.current_filename = FileName;
|
||||||
m_currentFilename = FileName;
|
|
||||||
if (iso->GetPlatform() == DiscIO::IVolume::WII_DISC)
|
if (iso->GetPlatform() == DiscIO::IVolume::WII_DISC)
|
||||||
FileName.append(".iso");
|
FileName.append(".iso");
|
||||||
else
|
else
|
||||||
@ -1188,11 +1196,10 @@ void CGameListCtrl::CompressSelection(bool _compress)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
all_good &= DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
|
all_good &= DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
|
||||||
OutputFileName.c_str(), &MultiCompressCB, &progressDialog);
|
OutputFileName.c_str(), &MultiCompressCB, &progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the progress in the progress dialog
|
progress.items_done++;
|
||||||
m_currentItem++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,9 +109,6 @@ private:
|
|||||||
void HideColumn(int column);
|
void HideColumn(int column);
|
||||||
void UnselectAll();
|
void UnselectAll();
|
||||||
|
|
||||||
static size_t m_currentItem;
|
|
||||||
static std::string m_currentFilename;
|
|
||||||
static size_t m_numberItem;
|
|
||||||
static bool CompressCB(const std::string& text, float percent, void* arg);
|
static bool CompressCB(const std::string& text, float percent, void* arg);
|
||||||
static bool MultiCompressCB(const std::string& text, float percent, void* arg);
|
static bool MultiCompressCB(const std::string& text, float percent, void* arg);
|
||||||
static bool WiiCompressWarning();
|
static bool WiiCompressWarning();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user