6
6
#include " WebDownloader.h"
7
7
#include " Mod.h"
8
8
#include " ModManifest.h"
9
+ #include " Prompt.h"
9
10
#include < string>
10
11
#include < Windows.h>
12
+ #include < windows.h>
13
+ #include < Lmcons.h>
14
+ #include < msclr\marshal.h>
15
+ #define string System::String^
11
16
12
17
#pragma once
13
18
@@ -22,7 +27,6 @@ namespace InfernoModManager {
22
27
MainForm (void )
23
28
{
24
29
InitializeComponent ();
25
-
26
30
// double buffered renders all at once, therefore faster
27
31
System::Windows::Forms::DataGridView::typeid ->GetProperty (" DoubleBuffered" ,
28
32
System::Reflection::BindingFlags::Instance | System::Reflection::BindingFlags::NonPublic)
@@ -140,6 +144,8 @@ namespace InfernoModManager {
140
144
private: System::Windows::Forms::Label^ label19;
141
145
private: System::Windows::Forms::Label^ DownloadVersion;
142
146
private: System::Windows::Forms::ProgressBar^ DownloadProgressBar;
147
+ private: System::Windows::Forms::Label^ WelcomeBackUser;
148
+ private: System::Windows::Forms::Button^ AddRepo;
143
149
144
150
145
151
@@ -228,6 +234,7 @@ namespace InfernoModManager {
228
234
this ->ModTypeColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn ());
229
235
this ->ModInfoColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn ());
230
236
this ->ModVersion = (gcnew System::Windows::Forms::Label ());
237
+ this ->WelcomeBackUser = (gcnew System::Windows::Forms::Label ());
231
238
this ->DownloadsList = (gcnew System::Windows::Forms::DataGridView ());
232
239
this ->InstalledColumn = (gcnew System::Windows::Forms::DataGridViewCheckBoxColumn ());
233
240
this ->DownloadNameColumn = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn ());
@@ -245,14 +252,15 @@ namespace InfernoModManager {
245
252
this ->DownloadAuthor = (gcnew System::Windows::Forms::Label ());
246
253
this ->DownloadVersion = (gcnew System::Windows::Forms::Label ());
247
254
this ->DownloadDescription = (gcnew System::Windows::Forms::Label ());
255
+ this ->DownloadProgressBar = (gcnew System::Windows::Forms::ProgressBar ());
248
256
this ->CreditTab = (gcnew System::Windows::Forms::TabPage ());
249
257
this ->CreditsLayout = (gcnew System::Windows::Forms::TableLayoutPanel ());
250
258
this ->BaydockGithub = (gcnew System::Windows::Forms::Button ());
251
259
this ->KosmicGithub = (gcnew System::Windows::Forms::Button ());
252
260
this ->DiscordButton = (gcnew System::Windows::Forms::Button ());
253
261
this ->BTD6FolderDialog = (gcnew System::Windows::Forms::FolderBrowserDialog ());
254
262
this ->CheckBTD6Timer = (gcnew System::Windows::Forms::Timer (this ->components ));
255
- this ->DownloadProgressBar = (gcnew System::Windows::Forms::ProgressBar ());
263
+ this ->AddRepo = (gcnew System::Windows::Forms::Button ());
256
264
label1 = (gcnew System::Windows::Forms::Label ());
257
265
label2 = (gcnew System::Windows::Forms::Label ());
258
266
label3 = (gcnew System::Windows::Forms::Label ());
@@ -745,6 +753,7 @@ namespace InfernoModManager {
745
753
this ->ModManager ->Controls ->Add (label3, 1 , 9 );
746
754
this ->ModManager ->Controls ->Add (label17, 1 , 8 );
747
755
this ->ModManager ->Controls ->Add (this ->ModVersion , 2 , 8 );
756
+ this ->ModManager ->Controls ->Add (this ->WelcomeBackUser , 1 , 0 );
748
757
this ->ModManager ->Dock = System::Windows::Forms::DockStyle::Fill;
749
758
this ->ModManager ->Location = System::Drawing::Point (0 , 0 );
750
759
this ->ModManager ->Margin = System::Windows::Forms::Padding (2 );
@@ -904,6 +913,15 @@ namespace InfernoModManager {
904
913
this ->ModVersion ->TabIndex = 33 ;
905
914
this ->ModVersion ->Text = L" Mod Version" ;
906
915
//
916
+ // WelcomeBackUser
917
+ //
918
+ this ->WelcomeBackUser ->AutoSize = true ;
919
+ this ->WelcomeBackUser ->Location = System::Drawing::Point (657 , 0 );
920
+ this ->WelcomeBackUser ->Name = L" WelcomeBackUser" ;
921
+ this ->WelcomeBackUser ->Size = System::Drawing::Size (0 , 13 );
922
+ this ->WelcomeBackUser ->TabIndex = 34 ;
923
+ this ->WelcomeBackUser ->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
924
+ //
907
925
// DownloadsList
908
926
//
909
927
this ->DownloadsList ->AllowUserToAddRows = false ;
@@ -1031,6 +1049,7 @@ namespace InfernoModManager {
1031
1049
this ->DownloadManager ->Controls ->Add (this ->DownloadDescription , 1 , 10 );
1032
1050
this ->DownloadManager ->Controls ->Add (label10, 1 , 11 );
1033
1051
this ->DownloadManager ->Controls ->Add (this ->DownloadProgressBar , 2 , 0 );
1052
+ this ->DownloadManager ->Controls ->Add (this ->AddRepo , 1 , 0 );
1034
1053
this ->DownloadManager ->Dock = System::Windows::Forms::DockStyle::Fill;
1035
1054
this ->DownloadManager ->Location = System::Drawing::Point (0 , 0 );
1036
1055
this ->DownloadManager ->Margin = System::Windows::Forms::Padding (2 );
@@ -1137,6 +1156,13 @@ namespace InfernoModManager {
1137
1156
this ->DownloadDescription ->TabIndex = 28 ;
1138
1157
this ->DownloadDescription ->Text = L" Download Description" ;
1139
1158
//
1159
+ // DownloadProgressBar
1160
+ //
1161
+ this ->DownloadProgressBar ->Location = System::Drawing::Point (819 , 3 );
1162
+ this ->DownloadProgressBar ->Name = L" DownloadProgressBar" ;
1163
+ this ->DownloadProgressBar ->Size = System::Drawing::Size (158 , 23 );
1164
+ this ->DownloadProgressBar ->TabIndex = 31 ;
1165
+ //
1140
1166
// CreditTab
1141
1167
//
1142
1168
this ->CreditTab ->BackColor = System::Drawing::SystemColors::Window;
@@ -1240,12 +1266,15 @@ namespace InfernoModManager {
1240
1266
this ->CheckBTD6Timer ->Interval = 1000 ;
1241
1267
this ->CheckBTD6Timer ->Tick += gcnew System::EventHandler (this , &MainForm::CheckBTD6Open);
1242
1268
//
1243
- // DownloadProgressBar
1269
+ // AddRepo
1244
1270
//
1245
- this ->DownloadProgressBar ->Location = System::Drawing::Point (819 , 3 );
1246
- this ->DownloadProgressBar ->Name = L" DownloadProgressBar" ;
1247
- this ->DownloadProgressBar ->Size = System::Drawing::Size (158 , 23 );
1248
- this ->DownloadProgressBar ->TabIndex = 31 ;
1271
+ this ->AddRepo ->Location = System::Drawing::Point (656 , 3 );
1272
+ this ->AddRepo ->Name = L" AddRepo" ;
1273
+ this ->AddRepo ->Size = System::Drawing::Size (83 , 23 );
1274
+ this ->AddRepo ->TabIndex = 32 ;
1275
+ this ->AddRepo ->Text = L" Add Repo" ;
1276
+ this ->AddRepo ->UseVisualStyleBackColor = true ;
1277
+ this ->AddRepo ->Click += gcnew System::EventHandler (this , &MainForm::AddRepo_Click);
1249
1278
//
1250
1279
// MainForm
1251
1280
//
@@ -1486,19 +1515,26 @@ namespace InfernoModManager {
1486
1515
}
1487
1516
1488
1517
private: System::Void UpdateModStats (InfernoModManager::Mod^ mod) {
1489
- try {
1490
- System::Net::HttpWebRequest^ request = (System::Net::HttpWebRequest^)System::Net::HttpWebRequest::Create (mod->PNGLoc );
1491
- request->AllowWriteStreamBuffering = true ;
1492
- request->Timeout = 30000 ;
1518
+ if (!mod->PNGLoc ->ToLower ()->Equals (" nothingyet" ) && !mod->PNGLoc ->Equals (" " )) {
1519
+ try {
1520
+ System::Net::HttpWebRequest^ request = (System::Net::HttpWebRequest^)System::Net::HttpWebRequest::Create (mod->PNGLoc );
1521
+ request->AllowWriteStreamBuffering = true ;
1522
+ request->Timeout = 30000 ;
1493
1523
1494
- System::Net::WebResponse^ webResponse = request->GetResponse ();
1524
+ System::Net::WebResponse^ webResponse = request->GetResponse ();
1495
1525
1496
- System::IO::Stream^ stream = webResponse->GetResponseStream ();
1526
+ System::IO::Stream^ stream = webResponse->GetResponseStream ();
1497
1527
1498
- ModImage->Image = System::Drawing::Image::FromStream (stream);
1499
- delete stream;
1528
+ ModImage->Image = System::Drawing::Image::FromStream (stream);
1529
+ delete stream;
1530
+ }
1531
+ catch (System::Exception^)
1532
+ {
1533
+ System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager (MainForm::typeid ));
1534
+ ModImage->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject (L" ModImage.ErrorImage" )));
1535
+ }
1500
1536
}
1501
- catch (System::Exception^)
1537
+ else
1502
1538
{
1503
1539
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager (MainForm::typeid ));
1504
1540
ModImage->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject (L" ModImage.ErrorImage" )));
@@ -1518,19 +1554,26 @@ namespace InfernoModManager {
1518
1554
}
1519
1555
1520
1556
private: System::Void UpdateDownloadStats (InfernoModManager::Mod^ mod) {
1521
- try {
1522
- System::Net::HttpWebRequest^ request = (System::Net::HttpWebRequest^)System::Net::HttpWebRequest::Create (mod->PNGLoc );
1523
- request->AllowWriteStreamBuffering = true ;
1524
- request->Timeout = 30000 ;
1557
+ if (!mod->PNGLoc ->ToLower ()->Equals (" nothingyet" ) && !mod->PNGLoc ->Equals (" " )) {
1558
+ try {
1559
+ System::Net::HttpWebRequest^ request = (System::Net::HttpWebRequest^)System::Net::HttpWebRequest::Create (mod->PNGLoc );
1560
+ request->AllowWriteStreamBuffering = true ;
1561
+ request->Timeout = 30000 ;
1525
1562
1526
- System::Net::WebResponse^ webResponse = request->GetResponse ();
1563
+ System::Net::WebResponse^ webResponse = request->GetResponse ();
1527
1564
1528
- System::IO::Stream^ stream = webResponse->GetResponseStream ();
1565
+ System::IO::Stream^ stream = webResponse->GetResponseStream ();
1529
1566
1530
- DownloadImage->Image = System::Drawing::Image::FromStream (stream);
1531
- delete stream;
1567
+ DownloadImage->Image = System::Drawing::Image::FromStream (stream);
1568
+ delete stream;
1569
+ }
1570
+ catch (System::Exception^)
1571
+ {
1572
+ System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager (MainForm::typeid ));
1573
+ DownloadImage->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject (L" DownloadImage.ErrorImage" )));
1574
+ }
1532
1575
}
1533
- catch (System::Exception^)
1576
+ else
1534
1577
{
1535
1578
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager (MainForm::typeid ));
1536
1579
DownloadImage->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject (L" DownloadImage.ErrorImage" )));
@@ -1562,5 +1605,35 @@ namespace InfernoModManager {
1562
1605
private: System::String^ GetDisabledDir() {
1563
1606
return btd6Install + " \\ Mods\\ Disabled" ;
1564
1607
}
1565
- };
1608
+
1609
+ private: System::Void AddRepo_Click (System::Object^ sender, System::EventArgs^ e) {
1610
+ string s = Prompt::ShowDialog (" Yes" , " Enter URL for repo." );
1611
+ bool shouldWarn = false ;
1612
+ if (!s->Equals (" " ))
1613
+ {
1614
+ try {
1615
+ System::Net::HttpWebRequest^ request = (System::Net::HttpWebRequest^)System::Net::HttpWebRequest::Create (s);
1616
+ request->Timeout = 30000 ;
1617
+
1618
+ System::Net::WebResponse^ webResponse = request->GetResponse ();
1619
+ }
1620
+ catch (System::Exception^) {
1621
+ shouldWarn = true ;
1622
+ }
1623
+ }
1624
+ else
1625
+ shouldWarn = true ;
1626
+
1627
+ if (shouldWarn) {
1628
+ System::Windows::Forms::MessageBox::Show (" Download completed!" );
1629
+ return ;
1630
+ }
1631
+
1632
+ System::Collections::Generic::List<string>^ list = Newtonsoft::Json::JsonConvert::DeserializeObject<System::Collections::Generic::List<string>^>(System::IO::File::ReadAllText (" repos.json" ));
1633
+ list->Add (s);
1634
+ InfernoModManager::WebDownloader::Repos = list;
1635
+ System::IO::File::WriteAllText (" repos.json" , Newtonsoft::Json::JsonConvert::SerializeObject (InfernoModManager::WebDownloader::Repos));
1636
+ PopulateDownloadsList ();
1637
+ }
1638
+ };
1566
1639
}
0 commit comments