Skip to content

Commit 0f9e15a

Browse files
committed
* update status bar while downloading / creating first launch stuff
* links to spreadsheets being used to retrieve the community data (either on readme or on the app or both)
1 parent f0bbcb2 commit 0f9e15a

File tree

3 files changed

+87
-56
lines changed

3 files changed

+87
-56
lines changed

.vs/N++Assistant/v16/.suo

-10 KB
Binary file not shown.

Form1.cs

Lines changed: 83 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Newtonsoft.Json;
1111
using Popcron.Sheets;
1212
using System.Globalization;
13+
using System.Threading;
1314

1415
namespace N__Assistant
1516
{
@@ -21,6 +22,8 @@ public partial class Form1 : Form
2122
private string screenshotsPath = @"\userdata\64929984\760\remote\230270\screenshots";
2223
private string savePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\N++Assistant";
2324

25+
static Thread MyLoadingThread = null;
26+
static Thread MyReadingTextThread = null;
2427
private BackgroundWorker bgwBackupNow = new BackgroundWorker();
2528

2629
// there is probably a better way to map this but fuck me if i know C# properly
@@ -84,6 +87,36 @@ public Form1()
8487
if (!Directory.Exists(savePath + @"\Palettes")) Directory.CreateDirectory(savePath + @"\Palettes");
8588
if (!Directory.Exists(savePath + @"\MapPacks")) Directory.CreateDirectory(savePath + @"\MapPacks");
8689

90+
MyLoadingThread = new Thread(new ThreadStart(DownloadStuff));
91+
MyLoadingThread.IsBackground = true;
92+
MyLoadingThread.Start();
93+
94+
// create palettes directory in steam game dir if it doesnt exist (it's needed to install the custom palettes)
95+
if (!Directory.Exists(steamGamePath + @"\NPP\Palettes")) Directory.CreateDirectory(steamGamePath + @"\NPP\Palettes");
96+
97+
//TODO: save user settings and reload the same on launch
98+
// set checkbox on profile backup default on
99+
checkedListBox1.SetItemChecked(0, true);
100+
// set checkbox on level editor backup default on
101+
checkedListBox1.SetItemChecked(2, true);
102+
103+
// initialize background worker for backup now button
104+
bgwBackupNow.DoWork += new DoWorkEventHandler(bgwBackupNow_DoWork);
105+
bgwBackupNow.ProgressChanged += new ProgressChangedEventHandler(bgwBackupNow_ProgressChanged);
106+
bgwBackupNow.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwBackupNow_RunWorkerCompleted);
107+
bgwBackupNow.WorkerReportsProgress = true;
108+
109+
tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting);
110+
111+
nppconfText.Text = File.ReadAllText(profilePath + @"\npp.conf");
112+
npplogText.Text = File.ReadAllText(profilePath + @"\NPPLog.txt");
113+
114+
loadProfile.Enabled = false;
115+
deleteProfile.Enabled = false;
116+
}
117+
118+
private void DownloadStuff()
119+
{
87120
// download default Metanet Palettes.zip pack to backup dir
88121
if (!Directory.Exists(savePath + @"\Palettes\Palettes"))
89122
{
@@ -96,6 +129,7 @@ public Form1()
96129
myWebClient.Dispose();
97130
ZipFile.ExtractToDirectory(filename, savePath + @"\Palettes");
98131
File.Delete(savePath + @"\Palettes\Palettes.zip");
132+
statusLabel.Text = "Done downloading Metanet allpalettes.zip";
99133
}
100134
catch (Exception exc)
101135
{
@@ -116,38 +150,59 @@ public Form1()
116150
Directory.CreateDirectory(savePath + @"\Maps\NPP_AllLevels");
117151
ZipFile.ExtractToDirectory(filename, savePath + @"\Maps\NPP_AllLevels");
118152
File.Delete(savePath + @"\Maps\NPP_AllLevels.zip");
153+
statusLabel.Text = "Done downloading NPP_AllLevels.zip";
119154
}
120155
catch (Exception exc)
121156
{
122157
MessageBox.Show("Couldn't download Metanet Palettes pack because: " + exc.Message);
123158
}
124159
}
125160

126-
// tooltip
127-
// this.metanetMapsList.MouseMove += new System.Windows.Forms.MouseEventHandler(this.metanetMapsList_MouseMove);
128-
129-
// create palettes directory in steam game dir if it doesnt exist (it's needed to install the custom palettes)
130-
if (!Directory.Exists(steamGamePath + @"\NPP\Palettes")) Directory.CreateDirectory(steamGamePath + @"\NPP\Palettes");
131-
132-
//TODO: save user settings and reload the same on launch
133-
// set checkbox on profile backup default on
134-
checkedListBox1.SetItemChecked(0, true);
135-
// set checkbox on level editor backup default on
136-
checkedListBox1.SetItemChecked(2, true);
161+
// list spreadsheet of new sound packs
162+
// https://docs.google.com/spreadsheets/d/18PshamVuDNyH396a7U3YDFQmCw18s4gIVZ_WrFODRd4/edit#gid=0
163+
if (spreadsheetSoundpacks.Items.Count == 0)
164+
{
165+
//spreadsheetSoundpacks.Items.Clear();
166+
PopulateListBoxWithSpreadsheetData(spreadsheetSoundpacks, 0, COMMUNITY_SOUNDPACKS, new APIKey().key, "Sound Packs");
167+
installSpreadsheetSoundpack.Enabled = false;
168+
statusLabel.Text = "Getting community sound packs spreadsheet data ...";
169+
}
137170

138-
// initialize background worker for backup now button
139-
bgwBackupNow.DoWork += new DoWorkEventHandler(bgwBackupNow_DoWork);
140-
bgwBackupNow.ProgressChanged += new ProgressChangedEventHandler(bgwBackupNow_ProgressChanged);
141-
bgwBackupNow.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwBackupNow_RunWorkerCompleted);
142-
bgwBackupNow.WorkerReportsProgress = true;
171+
// populate community palettes from spreadsheet link
172+
// https://docs.google.com/spreadsheets/d/1I2f87Qhfs6rxzZq5dQRDbLKYyaGLqTdCkLqfNfrw1Mk/edit#gid=0
173+
if (communityPalettesList.Items.Count == 0)
174+
{
175+
//communityPalettesList.Items.Clear();
176+
PopulateListBoxWithSpreadsheetData(communityPalettesList, 0, COMMUNITY_PALETTES, new APIKey().key, "Palettes");
177+
installCommunityPalette.Enabled = false;
178+
statusLabel.Text = "Getting community palettes spreadsheet data ...";
179+
}
143180

144-
tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting);
181+
// populate community map packs from spreadsheet link
182+
// https://docs.google.com/spreadsheets/d/1M9W3_jk3nULledALJNzRDRRpNhIofeTD2SF8ES6vCy8/edit#gid=0
183+
if (communityMapPacksList.Items.Count == 0)
184+
{
185+
//communityMapPacksList.Items.Clear();
186+
PopulateListBoxWithSpreadsheetData(communityMapPacksList, 0, COMMUNITY_MAPPACKS, new APIKey().key, "Map Packs");
187+
installCommunityMapPack.Enabled = false;
188+
statusLabel.Text = "Getting community map packs spreadsheet data ...";
189+
}
190+
}
145191

146-
nppconfText.Text = File.ReadAllText(profilePath + @"\npp.conf");
147-
npplogText.Text = File.ReadAllText(profilePath + @"\NPPLog.txt");
192+
private void ReadNPPTextLogs()
193+
{
194+
string nppconfText_Text = File.ReadAllText(profilePath + @"\npp.conf");
195+
string npplogText_Text = File.ReadAllText(profilePath + @"\NPPLog.txt");
148196

149-
loadProfile.Enabled = false;
150-
deleteProfile.Enabled = false;
197+
if (InvokeRequired)
198+
{
199+
this.Invoke(new MethodInvoker(delegate {
200+
nppconfText.Text = nppconfText_Text;
201+
npplogText.Text = npplogText_Text;
202+
statusLabel.Text = "Done loading NPP config and log files";
203+
}));
204+
return;
205+
}
151206
}
152207

153208
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
@@ -157,8 +212,11 @@ private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
157212
// switch to status / home tab
158213
if (current == tabStatus)
159214
{
160-
nppconfText.Text = File.ReadAllText(profilePath + @"\npp.conf");
161-
npplogText.Text = File.ReadAllText(profilePath + @"\NPPLog.txt");
215+
if (nppconfText.Text == "") {
216+
MyReadingTextThread = new Thread(new ThreadStart(ReadNPPTextLogs));
217+
MyReadingTextThread.IsBackground = true;
218+
MyReadingTextThread.Start();
219+
}
162220
}
163221

164222
// switch to profile tab
@@ -173,24 +231,15 @@ private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
173231
// switch to soundpacks tab
174232
if (current == tabSoundpacks)
175233
{
176-
177234
// list backups
178235
soundpackBackups.Items.Clear();
179236
PopulateListBoxWithFileType(soundpackBackups, savePath + @"\Sounds", "*.zip");
180237
installSoundpackButton.Enabled = false;
181238
deleteSoundpackBackupButton.Enabled = false;
182239

183-
// list spreadsheet of new sound packs
184-
// https://docs.google.com/spreadsheets/d/18PshamVuDNyH396a7U3YDFQmCw18s4gIVZ_WrFODRd4/edit#gid=0
185-
spreadsheetSoundpacks.Items.Clear();
186-
PopulateListBoxWithSpreadsheetData(spreadsheetSoundpacks, 0, COMMUNITY_SOUNDPACKS, new APIKey().key);
187-
installSpreadsheetSoundpack.Enabled = false;
188-
statusLabel.Text = "Getting community sound packs spreadsheet data ...";
189-
190240
// list preview
191241
previewSoundsList.Items.Clear();
192242
PopulateListBoxWithFileType(previewSoundsList, steamGamePath + @"\NPP\Sounds", "*.wav");
193-
194243
}
195244

196245
// switch to palettes tab
@@ -202,13 +251,6 @@ private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
202251
PopulateListBoxWithSubDirectories(metanetPalettesList, savePath + @"\Palettes\Palettes");
203252
installMetanetPalette.Enabled = false;
204253

205-
// populate community palettes from spreadsheet link
206-
// https://docs.google.com/spreadsheets/d/1I2f87Qhfs6rxzZq5dQRDbLKYyaGLqTdCkLqfNfrw1Mk/edit#gid=0
207-
communityPalettesList.Items.Clear();
208-
PopulateListBoxWithSpreadsheetData(communityPalettesList, 0, COMMUNITY_PALETTES, new APIKey().key);
209-
installCommunityPalette.Enabled = false;
210-
statusLabel.Text = "Getting community palettes spreadsheet data ...";
211-
212254
// list all palettes in local backup dir
213255
localBackupPalettesList.Items.Clear();
214256
PopulateListBoxWithFileType(localBackupPalettesList, savePath + @"\Palettes", "*.zip");
@@ -261,13 +303,6 @@ private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
261303

262304
if (current == tabMapPacks)
263305
{
264-
// populate community map packs from spreadsheet link
265-
// https://docs.google.com/spreadsheets/d/1I2f87Qhfs6rxzZq5dQRDbLKYyaGLqTdCkLqfNfrw1Mk/edit#gid=0
266-
communityMapPacksList.Items.Clear();
267-
PopulateListBoxWithSpreadsheetData(communityMapPacksList, 0, COMMUNITY_MAPPACKS, new APIKey().key);
268-
installCommunityMapPack.Enabled = false;
269-
statusLabel.Text = "Getting community map packs spreadsheet data ...";
270-
271306
// list local map packs backups
272307
localBackupsMapPacksList.Items.Clear();
273308
PopulateListBoxWithFileType(localBackupsMapPacksList, savePath + @"\MapPacks", "*.zip");
@@ -588,7 +623,7 @@ public override string SerializeObject(object data)
588623
}
589624
}
590625

591-
private async void PopulateListBoxWithSpreadsheetData(ListBox lsb, int sheetsId, string spreadsheetId, string key)
626+
private async void PopulateListBoxWithSpreadsheetData(ListBox lsb, int sheetsId, string spreadsheetId, string key, string sht)
592627
{
593628
// test url https://sheets.googleapis.com/v4/spreadsheets/spreadsheetid?key=key
594629

@@ -625,7 +660,7 @@ private async void PopulateListBoxWithSpreadsheetData(ListBox lsb, int sheetsId,
625660
sheetMapList.Add(new sheetMap(spreadsheetId, sheet));
626661
}
627662

628-
statusLabel.Text = "Done retrieving spreadsheet data";
663+
statusLabel.Text = "Done retrieving spreadsheet data " + sht;
629664

630665
}
631666
catch (System.Net.WebException webexc)

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Needs Visual Studio Community 2019 with C# .Net stuff installed to compile from
1616

1717
* list metanet palettes (auto download from discord link) and select which to install
1818

19-
* list community palettes (from google spreadsheet) and select which to install
19+
* list community palettes (from [google spreadsheet](https://docs.google.com/spreadsheets/d/1I2f87Qhfs6rxzZq5dQRDbLKYyaGLqTdCkLqfNfrw1Mk/edit#gid=0]) and select which to install
2020

2121
* list all palettes on backup and select one to install or delete
2222

2323
* display number of custom palettes installed (and warn of maximum when reached)
2424

2525
* list all soundpacks on backup and select one to install or delete
2626

27-
* list community soundpacks (from google spreadsheet) and select which to install
27+
* list community soundpacks (from [google spreadsheet](https://docs.google.com/spreadsheets/d/18PshamVuDNyH396a7U3YDFQmCw18s4gIVZ_WrFODRd4/edit#gid=0]) and select which to install
2828

2929
* list metanet maps and select one to put on your map levels editor folder (for practice / remixes)
3030

@@ -34,16 +34,12 @@ Needs Visual Studio Community 2019 with C# .Net stuff installed to compile from
3434

3535
* button to launch n++ from within N++ Assistant
3636

37-
* list community map packs (from google spreadsheet) and select which to install
37+
* list community map packs (from [google spreadsheet](https://docs.google.com/spreadsheets/d/1M9W3_jk3nULledALJNzRDRRpNhIofeTD2SF8ES6vCy8/edit#gid=0]) and select which to install
3838

3939
* list all map packs in backup and select one to install or delete (with optional same timestamp profile)
4040

4141
## Stuff it'll eventually do:
4242

43-
* update status bar while downloading / creating first launch stuff
44-
45-
* preload all spreadsheet data instead of getting it on tab change
46-
4743
* option to refresh lists (in case people are renaming things on folder)
4844

4945
* option to rename backups from within N++ Assistant
@@ -64,7 +60,7 @@ Needs Visual Studio Community 2019 with C# .Net stuff installed to compile from
6460

6561
* maps, rename solo to solo n++ (likewise co-op/race)
6662

67-
* links to spreadsheets being used to retrieve the community data (either on readme or on app or both)
63+
* note that mentions metanet maps don't show up ingame even if they are in the Palettes directory, unless you rename them, they are for palette creation reference only
6864

6965
## Known issues:
7066

0 commit comments

Comments
 (0)