r5sdk/r5dev/sdklauncher/download_surface.cpp
Kawe Mazidjatari 41ebc431b2 Finish downloading of game and sdk files
Moved entire logic to dedicated wrappers.
2023-07-28 14:50:46 +02:00

116 lines
3.5 KiB
C++

#include "pch.h"
#include "download_surface.h"
CDownloadProgress::CDownloadProgress()
: Forms::Form(), m_bCanClose(false), m_bCanceled(false), m_bAutoClose(false)
{
this->InitializeComponent();
}
void CDownloadProgress::UpdateProgress(uint32_t Progress, bool Finished)
{
this->m_ProgressBar->SetValue(Progress);
if (Finished)
{
this->m_FinishButton->SetEnabled(true);
this->m_CancelButton->SetEnabled(false);
this->m_bCanClose = true;
this->SetText("Download Complete");
if (this->m_bCanceled || this->m_bAutoClose)
this->Close();
}
}
bool CDownloadProgress::IsCanceled()
{
return this->m_bCanceled;
}
void CDownloadProgress::SetCanCancel(bool bEnable)
{
m_CancelButton->SetEnabled(bEnable);
}
void CDownloadProgress::SetAutoClose(bool Value)
{
this->m_bAutoClose = Value;
}
void CDownloadProgress::SetExportLabel(const char* pNewLabel)
{
m_DownloadLabel->SetText(pNewLabel);
}
void CDownloadProgress::InitializeComponent()
{
this->SuspendLayout();
this->SetAutoScaleDimensions({ 6, 13 });
this->SetAutoScaleMode(Forms::AutoScaleMode::Font);
this->SetText("Downloading Files...");
this->SetClientSize({ 409, 119 });
this->SetFormBorderStyle(Forms::FormBorderStyle::FixedSingle);
this->SetStartPosition(Forms::FormStartPosition::CenterParent);
this->SetMinimizeBox(false);
this->SetMaximizeBox(false);
this->SetShowInTaskbar(false);
this->SetBackColor(Drawing::Color(47, 54, 61));
this->m_DownloadLabel = new UIX::UIXLabel();
this->m_DownloadLabel->SetSize({ 385, 17 });
this->m_DownloadLabel->SetLocation({ 12, 18 });
this->m_DownloadLabel->SetTabIndex(3);
this->m_DownloadLabel->SetText("Progress:");
this->m_DownloadLabel->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left | Forms::AnchorStyles::Right);
this->m_DownloadLabel->SetTextAlign(Drawing::ContentAlignment::TopLeft);
this->AddControl(this->m_DownloadLabel);
this->m_CancelButton = new UIX::UIXButton();
this->m_CancelButton->SetSize({ 87, 31 });
this->m_CancelButton->SetLocation({ 310, 76 });
this->m_CancelButton->SetTabIndex(2);
this->m_CancelButton->SetText("Cancel");
this->m_CancelButton->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Right);
this->m_CancelButton->Click += &OnCancelClick;
this->AddControl(this->m_CancelButton);
this->m_FinishButton = new UIX::UIXButton();
this->m_FinishButton->SetSize({ 87, 31 });
this->m_FinishButton->SetLocation({ 217, 76 });
this->m_FinishButton->SetTabIndex(1);
this->m_FinishButton->SetText("Ok");
this->m_FinishButton->SetEnabled(false);
this->m_FinishButton->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Right);
this->m_FinishButton->Click += &OnFinishClick;
this->AddControl(this->m_FinishButton);
this->m_ProgressBar = new UIX::UIXProgressBar();
this->m_ProgressBar->SetSize({ 385, 29 });
this->m_ProgressBar->SetLocation({ 12, 38 });
this->m_ProgressBar->SetTabIndex(0);
this->m_ProgressBar->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left | Forms::AnchorStyles::Right);
this->AddControl(this->m_ProgressBar);
this->ResumeLayout(false);
this->PerformLayout();
// END DESIGNER CODE
}
void CDownloadProgress::OnFinishClick(Forms::Control* Sender)
{
((Forms::Form*)Sender->FindForm())->Close();
}
void CDownloadProgress::OnCancelClick(Forms::Control* Sender)
{
((CDownloadProgress*)Sender->FindForm())->CancelProgress();
}
void CDownloadProgress::CancelProgress()
{
this->m_CancelButton->SetEnabled(false);
this->m_CancelButton->SetText("Canceling...");
this->m_bCanceled = true;
}