mirror of
https://github.com/Team-Neptune/NSAInstaller.git
synced 2024-11-23 12:49:52 +00:00
Make instPage updating funcs belong to instPage.cpp
This commit is contained in:
parent
99ecebe007
commit
59a3897d87
@ -19,6 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include <vector>
|
||||
|
||||
namespace netInstStuff {
|
||||
void installTitleNet(std::vector<std::string> ourUrlList, int ourStorage, std::vector<std::string> urlListAltNames, std::string ourSource);
|
||||
|
@ -23,16 +23,6 @@ SOFTWARE.
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
namespace inst::ui {
|
||||
void setTopInstInfoText(std::string ourText);
|
||||
void setInstInfoText(std::string ourText);
|
||||
void setInstBarPerc(double ourPercent);
|
||||
void hideInstBar(bool hidden);
|
||||
void loadMainMenu();
|
||||
void loadInstallScreen();
|
||||
}
|
||||
|
||||
namespace nspInstStuff {
|
||||
std::string finishedMessage();
|
||||
void installNspFromFile(std::vector<std::filesystem::path> ourNspList, int whereToInstall);
|
||||
}
|
@ -13,6 +13,12 @@ namespace inst::ui {
|
||||
TextBlock::Ref installInfoText;
|
||||
pu::ui::elm::ProgressBar::Ref installBar;
|
||||
Image::Ref awooImage;
|
||||
static void setTopInstInfoText(std::string ourText);
|
||||
static void setInstInfoText(std::string ourText);
|
||||
static void setInstBarPerc(double ourPercent);
|
||||
static void loadMainMenu();
|
||||
static void loadInstallScreen();
|
||||
static std::string finishedMessage();
|
||||
private:
|
||||
Rectangle::Ref infoRect;
|
||||
Rectangle::Ref topRect;
|
||||
|
@ -28,8 +28,8 @@ SOFTWARE.
|
||||
#include "util/title_util.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "util/debug.h"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
@ -108,7 +108,7 @@ namespace tin::install::nsp
|
||||
size_t startSizeBuffered = 0;
|
||||
double speed = 0.0;
|
||||
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsHttpNsp)
|
||||
{
|
||||
u64 newTime = armGetSystemTick();
|
||||
@ -125,21 +125,21 @@ namespace tin::install::nsp
|
||||
|
||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
|
||||
inst::ui::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::setInstBarPerc((double)downloadProgress);
|
||||
inst::ui::instPage::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||
}
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpNsp)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
|
||||
inst::ui::setInstBarPerc((double)installProgress);
|
||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
thrd_join(curlThread, NULL);
|
||||
thrd_join(writeThread, NULL);
|
||||
|
@ -25,8 +25,8 @@ SOFTWARE.
|
||||
#include <threads.h>
|
||||
#include "data/buffered_placeholder_writer.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
@ -105,7 +105,7 @@ namespace tin::install::xci
|
||||
size_t startSizeBuffered = 0;
|
||||
double speed = 0.0;
|
||||
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsHttpXci)
|
||||
{
|
||||
u64 newTime = armGetSystemTick();
|
||||
@ -126,18 +126,18 @@ namespace tin::install::xci
|
||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::setInstBarPerc((double)downloadProgress);
|
||||
inst::ui::instPage::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||
}
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
@ -145,9 +145,9 @@ namespace tin::install::xci
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||
#endif
|
||||
inst::ui::setInstBarPerc((double)installProgress);
|
||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
thrd_join(curlThread, NULL);
|
||||
thrd_join(writeThread, NULL);
|
||||
|
10
source/install/sdmc_nsp.cpp
Normal file → Executable file
10
source/install/sdmc_nsp.cpp
Normal file → Executable file
@ -2,7 +2,7 @@
|
||||
#include "error.hpp"
|
||||
#include "debug.h"
|
||||
#include "nx/nca_writer.h"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace tin::install::nsp
|
||||
{
|
||||
@ -37,15 +37,15 @@ namespace tin::install::nsp
|
||||
|
||||
try
|
||||
{
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (fileOff < ncaSize)
|
||||
{
|
||||
progress = (float) fileOff / (float) ncaSize;
|
||||
|
||||
if (fileOff % (0x400000 * 3) == 0) {
|
||||
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
||||
inst::ui::setInstBarPerc((double)(progress * 100.0));
|
||||
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
|
||||
}
|
||||
|
||||
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;
|
||||
@ -55,7 +55,7 @@ namespace tin::install::nsp
|
||||
|
||||
fileOff += readSize;
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "error.hpp"
|
||||
#include "debug.h"
|
||||
#include "nx/nca_writer.h"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
@ -37,15 +37,15 @@ namespace tin::install::xci
|
||||
|
||||
try
|
||||
{
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (fileOff < ncaSize)
|
||||
{
|
||||
progress = (float) fileOff / (float) ncaSize;
|
||||
|
||||
if (fileOff % (0x400000 * 3) == 0) {
|
||||
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
||||
inst::ui::setInstBarPerc((double)(progress * 100.0));
|
||||
inst::ui::instPage::setInstBarPerc((double)(progress * 100.0));
|
||||
}
|
||||
|
||||
if (fileOff + readSize >= ncaSize) readSize = ncaSize - fileOff;
|
||||
@ -55,7 +55,7 @@ namespace tin::install::xci
|
||||
|
||||
fileOff += readSize;
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -32,9 +32,9 @@ SOFTWARE.
|
||||
#include "util/usb_util.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "util/debug.h"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "util/usb_comms_awoo.h"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
|
||||
namespace tin::install::nsp
|
||||
@ -132,7 +132,7 @@ namespace tin::install::nsp
|
||||
size_t startSizeBuffered = 0;
|
||||
double speed = 0.0;
|
||||
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsUsbNsp)
|
||||
{
|
||||
u64 newTime = armGetSystemTick();
|
||||
@ -153,18 +153,18 @@ namespace tin::install::nsp
|
||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::setInstBarPerc((double)downloadProgress);
|
||||
inst::ui::instPage::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||
}
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
@ -172,9 +172,9 @@ namespace tin::install::nsp
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||
#endif
|
||||
inst::ui::setInstBarPerc((double)installProgress);
|
||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
thrd_join(usbThread, NULL);
|
||||
thrd_join(writeThread, NULL);
|
||||
|
@ -32,9 +32,9 @@ SOFTWARE.
|
||||
#include "util/usb_util.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "util/debug.h"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "util/usb_comms_awoo.h"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace tin::install::xci
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace tin::install::xci
|
||||
size_t startSizeBuffered = 0;
|
||||
double speed = 0.0;
|
||||
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsBufferDataComplete() && !stopThreadsUsbXci)
|
||||
{
|
||||
u64 newTime = armGetSystemTick();
|
||||
@ -152,18 +152,18 @@ namespace tin::install::xci
|
||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::setInstBarPerc((double)downloadProgress);
|
||||
inst::ui::instPage::setInstInfoText("Downloading " + inst::util::formatUrlString(ncaFileName) + " at " + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||
}
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
|
||||
inst::ui::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Installing " + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
@ -171,9 +171,9 @@ namespace tin::install::xci
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||
#endif
|
||||
inst::ui::setInstBarPerc((double)installProgress);
|
||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||
}
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
|
||||
thrd_join(usbThread, NULL);
|
||||
thrd_join(writeThread, NULL);
|
||||
|
@ -27,22 +27,20 @@ SOFTWARE.
|
||||
#include <sstream>
|
||||
#include <curl/curl.h>
|
||||
#include <thread>
|
||||
|
||||
#include <switch.h>
|
||||
#include "util/network_util.hpp"
|
||||
#include "netInstall.hpp"
|
||||
#include "install/install_nsp.hpp"
|
||||
#include "install/http_nsp.hpp"
|
||||
#include "install/install_xci.hpp"
|
||||
#include "install/http_xci.hpp"
|
||||
#include "install/install.hpp"
|
||||
#include "util/error.hpp"
|
||||
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "netInstall.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/network_util.hpp"
|
||||
#include "util/config.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "util/curl.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
const unsigned int MAX_URL_SIZE = 1024;
|
||||
const unsigned int MAX_URLS = 256;
|
||||
@ -52,11 +50,6 @@ static int m_clientSocket = 0;
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
|
||||
void setNetInfoText(std::string ourText){
|
||||
mainApp->netinstPage->pageInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
}
|
||||
|
||||
namespace netInstStuff{
|
||||
@ -117,7 +110,7 @@ namespace netInstStuff{
|
||||
void installTitleNet(std::vector<std::string> ourUrlList, int ourStorage, std::vector<std::string> urlListAltNames, std::string ourSource)
|
||||
{
|
||||
inst::util::initInstallServices();
|
||||
inst::ui::loadInstallScreen();
|
||||
inst::ui::instPage::loadInstallScreen();
|
||||
bool nspInstalled = true;
|
||||
NcmStorageId m_destStorageId = NcmStorageId_SdCard;
|
||||
|
||||
@ -145,7 +138,7 @@ namespace netInstStuff{
|
||||
try {
|
||||
for (urlItr = 0; urlItr < ourUrlList.size(); urlItr++) {
|
||||
LOG_DEBUG("%s %s\n", "Install request from", ourUrlList[urlItr].c_str());
|
||||
inst::ui::setTopInstInfoText("Installing " + urlNames[urlItr] + ourSource);
|
||||
inst::ui::instPage::setTopInstInfoText("Installing " + urlNames[urlItr] + ourSource);
|
||||
std::unique_ptr<tin::install::Install> installTask;
|
||||
|
||||
if (inst::curl::downloadToBuffer(ourUrlList[urlItr], 0x100, 0x103) == "HEAD") {
|
||||
@ -157,8 +150,8 @@ namespace netInstStuff{
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s\n", "Preparing installation");
|
||||
inst::ui::setInstInfoText("Preparing installation...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Preparing installation...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
installTask->Prepare();
|
||||
installTask->Begin();
|
||||
}
|
||||
@ -167,8 +160,8 @@ namespace netInstStuff{
|
||||
LOG_DEBUG("Failed to install");
|
||||
LOG_DEBUG("%s", e.what());
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + urlNames[urlItr]);
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Failed to install " + urlNames[urlItr]);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + urlNames[urlItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
@ -187,16 +180,16 @@ namespace netInstStuff{
|
||||
tin::network::WaitSendNetworkData(m_clientSocket, &ack, sizeof(u8));
|
||||
|
||||
if(nspInstalled) {
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstInfoText("Install complete");
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + " installed!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
inst::ui::loadMainMenu();
|
||||
inst::ui::instPage::loadMainMenu();
|
||||
inst::util::deinitInstallServices();
|
||||
return;
|
||||
}
|
||||
@ -224,7 +217,8 @@ namespace netInstStuff{
|
||||
}
|
||||
|
||||
std::string ourIPAddress = inst::util::getIPAddress();
|
||||
inst::ui::setNetInfoText("Waiting for a connection... Your Switch's IP Address is: " + ourIPAddress);
|
||||
inst::ui::mainApp->netinstPage->pageInfoText->SetText("Waiting for a connection... Your Switch's IP Address is: " + ourIPAddress);
|
||||
inst::ui::mainApp->CallForRender();
|
||||
LOG_DEBUG("%s %s\n", "Switch IP is ", ourIPAddress.c_str());
|
||||
LOG_DEBUG("%s\n", "Waiting for network");
|
||||
LOG_DEBUG("%s\n", "B to cancel");
|
||||
|
@ -26,7 +26,7 @@ SOFTWARE.
|
||||
#include <ctime>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
|
||||
#include "sdInstall.hpp"
|
||||
#include "install/install_nsp.hpp"
|
||||
#include "install/install_xci.hpp"
|
||||
#include "install/sdmc_xci.hpp"
|
||||
@ -35,58 +35,21 @@ SOFTWARE.
|
||||
#include "util/file_util.hpp"
|
||||
#include "util/title_util.hpp"
|
||||
#include "util/error.hpp"
|
||||
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "util/config.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
|
||||
void setTopInstInfoText(std::string ourText){
|
||||
mainApp->instpage->pageInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void setInstInfoText(std::string ourText){
|
||||
mainApp->instpage->installInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void setInstBarPerc(double ourPercent){
|
||||
mainApp->instpage->installBar->SetVisible(true);
|
||||
mainApp->instpage->installBar->SetProgress(ourPercent);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void loadMainMenu(){
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
|
||||
void loadInstallScreen(){
|
||||
mainApp->instpage->pageInfoText->SetText("");
|
||||
mainApp->instpage->installInfoText->SetText("");
|
||||
mainApp->instpage->installBar->SetProgress(0);
|
||||
mainApp->instpage->installBar->SetVisible(false);
|
||||
mainApp->instpage->awooImage->SetVisible(!inst::config::gayMode);
|
||||
mainApp->LoadLayout(mainApp->instpage);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
}
|
||||
|
||||
namespace nspInstStuff {
|
||||
|
||||
std::string finishedMessage() {
|
||||
std::vector<std::string> finishMessages = {"Enjoy your \"legal backups\"!", "I'm sure after you give the game a try you'll have tons of fun actually buying it!", "You buy gamu right? Nintendo-san thanka-you for your purchase!", "Bypassing DRM is great, isn't it?", "You probably saved like six trees by not buying the game! All that plastic goes somewhere!", "Nintendo ninjas have been dispatched to your current location.", "And we didn't even have to shove a political ideology down your throat to get here!"};
|
||||
srand(time(NULL));
|
||||
return(finishMessages[rand() % finishMessages.size()]);
|
||||
}
|
||||
|
||||
void installNspFromFile(std::vector<std::filesystem::path> ourTitleList, int whereToInstall)
|
||||
{
|
||||
inst::util::initInstallServices();
|
||||
inst::ui::loadInstallScreen();
|
||||
inst::ui::instPage::loadInstallScreen();
|
||||
bool nspInstalled = true;
|
||||
NcmStorageId m_destStorageId = NcmStorageId_SdCard;
|
||||
std::vector<std::string> filesToBeRenamed = {};
|
||||
@ -105,7 +68,7 @@ namespace nspInstStuff {
|
||||
try
|
||||
{
|
||||
for (titleItr = 0; titleItr < ourTitleList.size(); titleItr++) {
|
||||
inst::ui::setTopInstInfoText("Installing " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 40, true) + " from SD card");
|
||||
inst::ui::instPage::setTopInstInfoText("Installing " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 40, true) + " from SD card");
|
||||
std::unique_ptr<tin::install::Install> installTask;
|
||||
|
||||
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
||||
@ -117,8 +80,8 @@ namespace nspInstStuff {
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s\n", "Preparing installation");
|
||||
inst::ui::setInstInfoText("Preparing installation...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Preparing installation...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
installTask->Prepare();
|
||||
installTask->Begin();
|
||||
}
|
||||
@ -128,8 +91,8 @@ namespace nspInstStuff {
|
||||
LOG_DEBUG("Failed to install");
|
||||
LOG_DEBUG("%s", e.what());
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true));
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
@ -150,8 +113,8 @@ namespace nspInstStuff {
|
||||
}
|
||||
|
||||
if(nspInstalled) {
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstInfoText("Install complete");
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourTitleList.size() > 1) {
|
||||
if (inst::config::deletePrompt) {
|
||||
@ -160,17 +123,17 @@ namespace nspInstStuff {
|
||||
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
|
||||
}
|
||||
}
|
||||
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
} else {
|
||||
if (inst::config::deletePrompt) {
|
||||
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + " installed! Delete it from the SD card?", "The original file isn't needed anymore after it's been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
|
||||
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + " installed!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
}
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
inst::ui::loadMainMenu();
|
||||
inst::ui::instPage::loadMainMenu();
|
||||
inst::util::deinitInstallServices();
|
||||
return;
|
||||
}
|
||||
|
@ -36,6 +36,42 @@ namespace inst::ui {
|
||||
if (inst::config::gayMode) this->awooImage->SetVisible(false);
|
||||
}
|
||||
|
||||
void instPage::setTopInstInfoText(std::string ourText){
|
||||
mainApp->instpage->pageInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::setInstInfoText(std::string ourText){
|
||||
mainApp->instpage->installInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::setInstBarPerc(double ourPercent){
|
||||
mainApp->instpage->installBar->SetVisible(true);
|
||||
mainApp->instpage->installBar->SetProgress(ourPercent);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::loadMainMenu(){
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
|
||||
void instPage::loadInstallScreen(){
|
||||
mainApp->instpage->pageInfoText->SetText("");
|
||||
mainApp->instpage->installInfoText->SetText("");
|
||||
mainApp->instpage->installBar->SetProgress(0);
|
||||
mainApp->instpage->installBar->SetVisible(false);
|
||||
mainApp->instpage->awooImage->SetVisible(!inst::config::gayMode);
|
||||
mainApp->LoadLayout(mainApp->instpage);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
std::string instPage::finishedMessage() {
|
||||
std::vector<std::string> finishMessages = {"Enjoy your \"legal backups\"!", "I'm sure after you give the game a try you'll have tons of fun actually buying it!", "You buy gamu right? Nintendo-san thanka-you for your purchase!", "Bypassing DRM is great, isn't it?", "You probably saved like six trees by not buying the game! All that plastic goes somewhere!", "Nintendo ninjas have been dispatched to your current location.", "And we didn't even have to shove a political ideology down your throat to get here!"};
|
||||
srand(time(NULL));
|
||||
return(finishMessages[rand() % finishMessages.size()]);
|
||||
}
|
||||
|
||||
void instPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "util/util.hpp"
|
||||
#include "util/config.hpp"
|
||||
#include "util/curl.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
@ -44,10 +44,10 @@ namespace inst::ui {
|
||||
|
||||
void optionsPage::askToUpdate(std::vector<std::string> updateInfo) {
|
||||
if (!mainApp->CreateShowDialog("Update available", "Awoo Installer " + updateInfo[0] + " is available now! Ready to update?", {"Update", "Cancel"}, false)) {
|
||||
inst::ui::loadInstallScreen();
|
||||
inst::ui::setTopInstInfoText("Updating to Awoo Installer " + updateInfo[0]);
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::setInstInfoText("Downloading Awoo Installer " + updateInfo[0]);
|
||||
inst::ui::instPage::loadInstallScreen();
|
||||
inst::ui::instPage::setTopInstInfoText("Updating to Awoo Installer " + updateInfo[0]);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Downloading Awoo Installer " + updateInfo[0]);
|
||||
try {
|
||||
romfsExit();
|
||||
std::string curName = inst::config::appDir + "/Awoo-Installer.nro";
|
||||
@ -88,7 +88,7 @@ namespace inst::ui {
|
||||
deletePromptOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
deletePromptOption->SetIcon(this->getMenuOptionIcon(inst::config::deletePrompt));
|
||||
this->menu->AddItem(deletePromptOption);
|
||||
auto autoUpdateOption = pu::ui::elm::MenuItem::New("Check for updates automatically");
|
||||
auto autoUpdateOption = pu::ui::elm::MenuItem::New("Check for updates to Awoo Installer automatically");
|
||||
autoUpdateOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
autoUpdateOption->SetIcon(this->getMenuOptionIcon(inst::config::autoUpdate));
|
||||
this->menu->AddItem(autoUpdateOption);
|
||||
@ -99,7 +99,7 @@ namespace inst::ui {
|
||||
auto sigPatchesUrlOption = pu::ui::elm::MenuItem::New("Signature patches source URL: " + inst::util::shortenString(inst::config::sigPatchesUrl, 42, false));
|
||||
sigPatchesUrlOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->menu->AddItem(sigPatchesUrlOption);
|
||||
auto updateOption = pu::ui::elm::MenuItem::New("Check for updates");
|
||||
auto updateOption = pu::ui::elm::MenuItem::New("Check for updates to Awoo Installer");
|
||||
updateOption->SetColor(COLOR("#FFFFFFFF"));
|
||||
this->menu->AddItem(updateOption);
|
||||
auto creditsOption = pu::ui::elm::MenuItem::New("Credits");
|
||||
|
@ -1,26 +1,42 @@
|
||||
/*
|
||||
Copyright (c) 2017-2018 Adubbz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "util/error.hpp"
|
||||
#include "usbInstall.hpp"
|
||||
#include "install/usb_nsp.hpp"
|
||||
#include "install/install_nsp.hpp"
|
||||
#include "install/usb_xci.hpp"
|
||||
#include "install/install_xci.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "util/usb_util.hpp"
|
||||
#include "util/util.hpp"
|
||||
#include "util/config.hpp"
|
||||
#include "ui/usbInstPage.hpp"
|
||||
|
||||
#include "install/usb_xci.hpp"
|
||||
#include "install/install_xci.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/MainApplication.hpp"
|
||||
#include "ui/usbInstPage.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
|
||||
void setUsbInfoText(std::string ourText){
|
||||
mainApp->usbinstPage->pageInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
}
|
||||
|
||||
namespace usbInstStuff {
|
||||
@ -63,7 +79,7 @@ namespace usbInstStuff {
|
||||
void installTitleUsb(std::vector<std::string> ourTitleList, int ourStorage)
|
||||
{
|
||||
inst::util::initInstallServices();
|
||||
inst::ui::loadInstallScreen();
|
||||
inst::ui::instPage::loadInstallScreen();
|
||||
bool nspInstalled = true;
|
||||
NcmStorageId m_destStorageId = NcmStorageId_SdCard;
|
||||
|
||||
@ -84,7 +100,7 @@ namespace usbInstStuff {
|
||||
|
||||
try {
|
||||
for (fileItr = 0; fileItr < ourTitleList.size(); fileItr++) {
|
||||
inst::ui::setTopInstInfoText("Installing " + fileNames[fileItr] + " over USB");
|
||||
inst::ui::instPage::setTopInstInfoText("Installing " + fileNames[fileItr] + " over USB");
|
||||
std::unique_ptr<tin::install::Install> installTask;
|
||||
|
||||
if (ourTitleList[fileItr].compare(ourTitleList[fileItr].size() - 3, 2, "xc") == 0) {
|
||||
@ -96,8 +112,8 @@ namespace usbInstStuff {
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s\n", "Preparing installation");
|
||||
inst::ui::setInstInfoText("Preparing installation...");
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Preparing installation...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
installTask->Prepare();
|
||||
|
||||
installTask->Begin();
|
||||
@ -107,8 +123,8 @@ namespace usbInstStuff {
|
||||
LOG_DEBUG("Failed to install");
|
||||
LOG_DEBUG("%s", e.what());
|
||||
fprintf(stdout, "%s", e.what());
|
||||
inst::ui::setInstInfoText("Failed to install " + fileNames[fileItr]);
|
||||
inst::ui::setInstBarPerc(0);
|
||||
inst::ui::instPage::setInstInfoText("Failed to install " + fileNames[fileItr]);
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav");
|
||||
inst::ui::mainApp->CreateShowDialog("Failed to install " + fileNames[fileItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
@ -123,16 +139,16 @@ namespace usbInstStuff {
|
||||
|
||||
if(nspInstalled) {
|
||||
tin::util::USBCmdManager::SendExitCmd();
|
||||
inst::ui::setInstInfoText("Install complete");
|
||||
inst::ui::setInstBarPerc(100);
|
||||
inst::ui::instPage::setInstInfoText("Install complete");
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav");
|
||||
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true);
|
||||
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + " installed!", inst::ui::instPage::finishedMessage(), {"OK"}, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
LOG_DEBUG("Done");
|
||||
inst::ui::loadMainMenu();
|
||||
inst::ui::instPage::loadMainMenu();
|
||||
inst::util::deinitInstallServices();
|
||||
return;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "util/curl.hpp"
|
||||
#include "util/config.hpp"
|
||||
#include "util/error.hpp"
|
||||
#include "sdInstall.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
static size_t writeDataFile(void *ptr, size_t size, size_t nmemb, void *stream) {
|
||||
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
@ -22,10 +22,10 @@ size_t writeDataBuffer(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
|
||||
if (ultotal) {
|
||||
int uploadProgress = (int)(((double)ulnow / (double)ultotal) * 100.0);
|
||||
inst::ui::setInstBarPerc(uploadProgress);
|
||||
inst::ui::instPage::setInstBarPerc(uploadProgress);
|
||||
} else if (dltotal) {
|
||||
int downloadProgress = (int)(((double)dlnow / (double)dltotal) * 100.0);
|
||||
inst::ui::setInstBarPerc(downloadProgress);
|
||||
inst::ui::instPage::setInstBarPerc(downloadProgress);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user