From ae098603bb9ce1e7fa8a1f0cc7799b0cb0e40533 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:00:25 +0200 Subject: [PATCH] Overall launcher cleanup and improvements Use clean_sdk.bat to clean the SDK install. --- r5dev/sdklauncher/advanced_surface.cpp | 4 +-- r5dev/sdklauncher/base_surface.cpp | 46 ++++++++++++++------------ r5dev/sdklauncher/base_surface.h | 1 + r5dev/sdklauncher/sdklauncher_const.h | 2 +- r5dev/sdklauncher/sdkupdater.cpp | 16 +++------ 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/r5dev/sdklauncher/advanced_surface.cpp b/r5dev/sdklauncher/advanced_surface.cpp index dcb06a1a..abfb3705 100644 --- a/r5dev/sdklauncher/advanced_surface.cpp +++ b/r5dev/sdklauncher/advanced_surface.cpp @@ -704,7 +704,7 @@ void CAdvancedSurface::CleanSDK(Forms::Control* pSender) pSurface->m_LogList.push_back(LogList_t(spdlog::level::info, "Running cleaner for SDK installation\n")); pSurface->m_ConsoleListView->SetVirtualListSize(static_cast(pSurface->m_LogList.size())); - std::system("platform\\clean_sdk.bat"); + std::system("bin\\clean_sdk.bat"); } //----------------------------------------------------------------------------- @@ -717,7 +717,7 @@ void CAdvancedSurface::UpdateSDK(Forms::Control* pSender) pSurface->m_LogList.push_back(LogList_t(spdlog::level::info, "Running updater for SDK installation\n")); pSurface->m_ConsoleListView->SetVirtualListSize(static_cast(pSurface->m_LogList.size())); - std::system("platform\\update_sdk.bat"); + std::system("bin\\update_sdk.bat"); } //----------------------------------------------------------------------------- diff --git a/r5dev/sdklauncher/base_surface.cpp b/r5dev/sdklauncher/base_surface.cpp index 5fd4cdeb..c82f4f80 100644 --- a/r5dev/sdklauncher/base_surface.cpp +++ b/r5dev/sdklauncher/base_surface.cpp @@ -61,12 +61,12 @@ CBaseSurface::CBaseSurface() this->m_RepairButton->SetSize({ 168, 70 }); this->m_RepairButton->SetLocation({ 10, 90 }); this->m_RepairButton->SetTabIndex(9); - this->m_RepairButton->SetEnabled(/*m_bIsInstalled*/ false); - this->m_RepairButton->SetText(XorStr("Repair Apex")); + this->m_RepairButton->SetEnabled(/*m_bIsInstalled*/ true); + this->m_RepairButton->SetText(XorStr("Advanced Options")); this->m_RepairButton->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Left); // TODO: should hash every file against a downloaded manifest instead and // start repairing what mismatches. - this->m_RepairButton->Click += &OnInstallClick; + this->m_RepairButton->Click += &OnAdvancedClick; m_BaseGroup->AddControl(this->m_RepairButton); this->m_DonateButton = new UIX::UIXButton(); @@ -92,9 +92,9 @@ CBaseSurface::CBaseSurface() this->m_AdvancedButton->SetLocation({ 188, 116 }); this->m_AdvancedButton->SetTabIndex(9); this->m_AdvancedButton->SetEnabled(m_bIsInstalled); - this->m_AdvancedButton->SetText(XorStr("Advanced Options")); + this->m_AdvancedButton->SetText(XorStr("Follow on YouTube")); this->m_AdvancedButton->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Left); - this->m_AdvancedButton->Click += &OnAdvancedClick; + this->m_AdvancedButton->Click += &OnYouTubeClick; m_BaseGroup->AddControl(this->m_AdvancedButton); m_ExperimentalBuildsCheckbox = new UIX::UIXCheckBox(); @@ -104,13 +104,10 @@ CBaseSurface::CBaseSurface() this->m_ExperimentalBuildsCheckbox->SetText(XorStr("Check for playtest/event updates")); this->m_ExperimentalBuildsCheckbox->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - // TODO: remove this when its made public!!! - m_ExperimentalBuildsCheckbox->SetChecked(true); - m_BaseGroup->AddControl(this->m_ExperimentalBuildsCheckbox); // TODO: Use a toggle item instead; remove this field. - m_bPartialInstall = false; + m_bPartialInstall = true; m_bUpdateViewToggled = false; Threading::Thread([this] { @@ -216,20 +213,20 @@ void CBaseSurface::OnInstallClick(Forms::Control* Sender) } - //CBaseSurface* pSurf = (CBaseSurface*)Sender; - //const bool bPartial = pSurf->m_bPartialInstall; + CBaseSurface* pSurf = (CBaseSurface*)Sender; + const bool bPartial = pSurf->m_bPartialInstall; - //const int minRequiredSpace = bPartial ? MIN_REQUIRED_DISK_SPACE : MIN_REQUIRED_DISK_SPACE_OPT; - //int currentDiskSpace; + const int minRequiredSpace = bPartial ? MIN_REQUIRED_DISK_SPACE : MIN_REQUIRED_DISK_SPACE_OPT; + int currentDiskSpace; - //if (!SDKLauncher_CheckDiskSpace(minRequiredSpace, ¤tDiskSpace)) - //{ - // Forms::MessageBox::Show(Format("There is not enough space available on the disk to install R5Reloaded;" - // " you need at least %iGB, you currently have %iGB\n", minRequiredSpace, currentDiskSpace).c_str(), - // "Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error); + if (!SDKLauncher_CheckDiskSpace(minRequiredSpace, ¤tDiskSpace)) + { + Forms::MessageBox::Show(Format("There is not enough space available on the disk to install R5Reloaded;" + " you need at least %iGB, you currently have %iGB\n", minRequiredSpace, currentDiskSpace).c_str(), + "Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error); - // return; - //} + return; + } auto downloadSurface = std::make_unique(); CProgressPanel* pProgress = downloadSurface.get(); @@ -240,7 +237,7 @@ void CBaseSurface::OnInstallClick(Forms::Control* Sender) if (!SDKLauncher_CreateDepotDirectories()) { - Forms::MessageBox::Show(Format("Failed to create depot directories: Error code = %08x\n", GetLastError()).c_str(), + Forms::MessageBox::Show(Format("Failed to create intermediate directory: Error code = %08x\n", GetLastError()).c_str(), "Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error); return; @@ -277,10 +274,15 @@ void CBaseSurface::OnAdvancedClick(Forms::Control* Sender) void CBaseSurface::OnSupportClick(Forms::Control* /*Sender*/) { - ShellExecute(0, 0, XorStr("https://www.paypal.com/donate/?hosted_button_id=S28DHC2TF6UV4"), 0, 0, SW_SHOW); + ShellExecute(0, 0, XorStr("https://ko-fi.com/amos0"), 0, 0, SW_SHOW); } void CBaseSurface::OnJoinClick(Forms::Control* /*Sender*/) { ShellExecute(0, 0, XorStr("https://discord.com/invite/jqMkUdXrBr"), 0, 0, SW_SHOW); } + +void CBaseSurface::OnYouTubeClick(Forms::Control* /*Sender*/) +{ + ShellExecute(0, 0, XorStr("https://www.youtube.com/@AmosMods"), 0, 0, SW_SHOW); +} diff --git a/r5dev/sdklauncher/base_surface.h b/r5dev/sdklauncher/base_surface.h index b3a4c3d0..504c9bcc 100644 --- a/r5dev/sdklauncher/base_surface.h +++ b/r5dev/sdklauncher/base_surface.h @@ -20,6 +20,7 @@ protected: static void OnSupportClick(Forms::Control* Sender); static void OnJoinClick(Forms::Control* Sender); + static void OnYouTubeClick(Forms::Control* Sender); private: void Frame(); diff --git a/r5dev/sdklauncher/sdklauncher_const.h b/r5dev/sdklauncher/sdklauncher_const.h index 232ea9a8..67d6f07f 100644 --- a/r5dev/sdklauncher/sdklauncher_const.h +++ b/r5dev/sdklauncher/sdklauncher_const.h @@ -13,7 +13,7 @@ // Gigabytes. // TODO: obtain these from the repo... -#define MIN_REQUIRED_DISK_SPACE 20 +#define MIN_REQUIRED_DISK_SPACE 35 #define MIN_REQUIRED_DISK_SPACE_OPT 55 // Optional textures #define QUERY_TIMEOUT 15 diff --git a/r5dev/sdklauncher/sdkupdater.cpp b/r5dev/sdklauncher/sdkupdater.cpp index b6a3f9bf..673d0518 100644 --- a/r5dev/sdklauncher/sdkupdater.cpp +++ b/r5dev/sdklauncher/sdkupdater.cpp @@ -24,18 +24,12 @@ DWORD ErrorAndExit(const char* pSymbol) } //---------------------------------------------------------------------------- -// TODO: this code is from the SDK launcher, make it shared! +// Purpose: clears all intermediate and deprecated files //---------------------------------------------------------------------------- -bool ClearDepotDirectories() +bool ClearIntermediateFiles() { - // Clear all depot files. - if (!RemoveDirectoryA(RESTART_DEPOT_DOWNLOAD_DIR) || - !RemoveDirectoryA(DEFAULT_DEPOT_DOWNLOAD_DIR)) - { - return false; - } - - return true; + const bool bret = std::system("bin\\clean_sdk.bat") != NULL; + return bret; } //----------------------------------------------------------------------------- @@ -188,7 +182,7 @@ int main(int argc, char** argv) const char* destPath = (argc > 2) ? argv[2] : currentPath; MoveFiles(argv[1], destPath); - if (!ClearDepotDirectories()) + if (!ClearIntermediateFiles()) { printf("Failed to remove intermediate files!\n"); }