Skip to content

Commit 3b9b36e

Browse files
committed
Download installer
1 parent ce3c680 commit 3b9b36e

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

source/add_install_dlg_derived.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,36 @@ void AddNewInstallDlg::PopulateWithFilter(const std::function<bool (const versio
137137
void AddNewInstallDlg::InstallSelected(wxCommandEvent&){
138138
// get the selected item
139139
auto item = versionsListCtrl->GetSelection();
140+
auto data = *(reinterpret_cast<version*>(versionsListCtrl->GetItemData(item)));
140141
if (item.IsOk()){
141-
auto& data = *(reinterpret_cast<version*>(versionsListCtrl->GetItemData(item)));
142-
143-
144-
// download the file
145-
#ifdef __APPLE__
146-
147-
#elif defined _WIN32
148-
149-
#elif __linux__
150-
151-
#else
152-
#error This platform is not supported.
153142

154-
#endif
143+
thread th([&]{
144+
// download the file
145+
string url = "https://download.unity3d.com/download_unity/" + data.hashcode +
146+
#ifdef __APPLE__
147+
"/UnityDownloadAssistant.dmg";
148+
#elif defined _WIN32
149+
150+
#elif __linux__
151+
152+
#else
153+
#error This platform is not supported.
154+
155+
#endif
156+
157+
auto r = cpr::Get(cpr::Url{url});
158+
159+
if (r.status_code != 200){
160+
// TODO: post that download failed
161+
throw runtime_error("Unable to download installer");
162+
}
163+
else{
164+
// write the file to temp location
165+
}
166+
});
167+
th.detach();
168+
169+
155170
}
156171
else{
157172
wxMessageBox("Select a version", "Error", wxOK | wxICON_ERROR);

0 commit comments

Comments
 (0)