Skip to content

Commit

Permalink
Add option to redownload games that are already installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
LiEnby committed Jul 16, 2023
1 parent a73166a commit 6a2adf3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
20 changes: 15 additions & 5 deletions src/gameview.cpp
Expand Up @@ -257,18 +257,28 @@ void GameView::refresh()
_comppack_versions = pkgi_get_comppack_versions(_item->titleid);
}


void GameView::do_download() {
pkgi_start_download(*_downloader, *_item);
_item->presence = PresenceUnknown;
}

void GameView::start_download_package()
{
if (_item->presence == PresenceInstalled)
{
LOGF("[{}] {} - already installed", _item->titleid, _item->name);
pkgi_dialog_error("Already installed");
pkgi_dialog_question(
fmt::format(
"{} is already installed."
"Would you like to redownload it?",
_item->name)
.c_str(),
{{"Redownload.", [this] { this->do_download(); }},
{"Dont Redownload.", [] {} }});
return;
}

pkgi_start_download(*_downloader, *_item);

_item->presence = PresenceUnknown;
this->do_download();
}

void GameView::cancel_download_package()
Expand Down
1 change: 1 addition & 0 deletions src/gameview.hpp
Expand Up @@ -58,6 +58,7 @@ class GameView

std::string get_min_system_version();
void printDiagnostic();
void do_download();
void start_download_package();
void cancel_download_package();
void start_download_comppack(bool patch);
Expand Down
2 changes: 1 addition & 1 deletion src/log.hpp
Expand Up @@ -7,7 +7,7 @@
#define LOG(msg, ...) \
do \
{ \
pkgi_log(msg, ##__VA_ARGS__); \
pkgi_log(msg, ##__VA_ARGS__); \
} while (0)
#define LOGF(msg, ...) \
do \
Expand Down
19 changes: 15 additions & 4 deletions src/pkgi.cpp
Expand Up @@ -289,17 +289,28 @@ bool pkgi_theme_is_installed(std::string contentid)
return installed_themes.find(contentid) != installed_themes.end();
}

void do_download(Downloader& downloader, DbItem* item) {
pkgi_start_download(downloader, *item);
item->presence = PresenceUnknown;
}

void pkgi_install_package(Downloader& downloader, DbItem* item)
{
if (item->presence == PresenceInstalled)
{
LOGF("[{}] {} - already installed", item->content, item->name);
pkgi_dialog_error("Already installed");
pkgi_dialog_question(
fmt::format(
"{} is already installed."
"Would you like to redownload it?",
item->name)
.c_str(),
{{"Redownload.", [&downloader, item] { do_download(downloader, item); }},
{"Dont Redownload.", [] {} }});
return;
}

pkgi_start_download(downloader, *item);
item->presence = PresenceUnknown;

do_download(downloader, item);
}

void pkgi_friendly_size(char* text, uint32_t textlen, int64_t size)
Expand Down

0 comments on commit 6a2adf3

Please sign in to comment.