Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 61af9c7

Browse files
authored
Merge pull request #115 from beat-saber-modding-group/classic
Beat Mods fork (Classic Edition)
2 parents a99619c + 8f35c28 commit 61af9c7

24 files changed

+3647
-228
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
6+
[*.cs]
7+
indent_style = space
8+
indent_size = 4
9+
insert_final_newline = true

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33

4+
# Ignore NuGet packages
5+
**/packages/*
6+
!**/packages/repositories.config
7+
48
# User-specific files
59
*.suo
610
*.user

BeatSaberModManager/BeatSaberModManager.csproj

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>WinExe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>BeatSaberModManager</RootNamespace>
11-
<AssemblyName>BeatSaberModManager</AssemblyName>
11+
<AssemblyName>BeatSaberModManagerClassic</AssemblyName>
1212
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
@@ -42,13 +42,17 @@
4242
<PropertyGroup>
4343
<ApplicationIcon>saber.ico</ApplicationIcon>
4444
</PropertyGroup>
45+
<PropertyGroup>
46+
<StartupObject />
47+
</PropertyGroup>
4548
<ItemGroup>
4649
<Reference Include="Microsoft.CSharp" />
4750
<Reference Include="Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
4851
<EmbedInteropTypes>True</EmbedInteropTypes>
4952
</Reference>
5053
<Reference Include="System" />
5154
<Reference Include="System.ComponentModel.Composition" />
55+
<Reference Include="System.Configuration" />
5256
<Reference Include="System.Data" />
5357
<Reference Include="System.Deployment" />
5458
<Reference Include="System.Drawing" />
@@ -61,6 +65,7 @@
6165
<Compile Include="Core\GroupSorter.cs" />
6266
<Compile Include="Core\Helper.cs" />
6367
<Compile Include="Core\InstallerLogic.cs" />
68+
<Compile Include="Core\OneClickInstaller.cs" />
6469
<Compile Include="Core\PathLogic.cs" />
6570
<Compile Include="Core\RemoteLogic.cs" />
6671
<Compile Include="Core\UpdateLogic.cs" />
@@ -179,7 +184,6 @@
179184
<Compile Include="Dependencies\ICSharpCode.SharpZipLib\Zip\ZipNameTransform.cs" />
180185
<Compile Include="Dependencies\ICSharpCode.SharpZipLib\Zip\ZipOutputStream.cs" />
181186
<Compile Include="Dependencies\ICSharpCode.SharpZipLib\Zip\ZipStrings.cs" />
182-
<Compile Include="Dependencies\RegHelper.cs" />
183187
<Compile Include="Dependencies\SemVer\Comparator.cs" />
184188
<Compile Include="Dependencies\SemVer\ComparatorSet.cs" />
185189
<Compile Include="Dependencies\SemVer\Desugarer.cs" />
@@ -189,6 +193,12 @@
189193
<Compile Include="Dependencies\SemVer\Tuple.cs" />
190194
<Compile Include="Dependencies\SemVer\Version.cs" />
191195
<Compile Include="Dependencies\SimpleJson.cs" />
196+
<Compile Include="Forms\FormAnnouncement.cs">
197+
<SubType>Form</SubType>
198+
</Compile>
199+
<Compile Include="Forms\FormAnnouncement.Designer.cs">
200+
<DependentUpon>FormAnnouncement.cs</DependentUpon>
201+
</Compile>
192202
<Compile Include="Forms\FormDetailViewer.cs">
193203
<SubType>Form</SubType>
194204
</Compile>
@@ -210,11 +220,15 @@
210220
<Compile Include="Program.cs" />
211221
<Compile Include="Properties\AssemblyInfo.cs" />
212222
<Compile Include="Dependencies\SteamFinder.cs" />
223+
<EmbeddedResource Include="Forms\FormAnnouncement.resx">
224+
<DependentUpon>FormAnnouncement.cs</DependentUpon>
225+
</EmbeddedResource>
213226
<EmbeddedResource Include="Forms\FormDetailViewer.resx">
214227
<DependentUpon>FormDetailViewer.cs</DependentUpon>
215228
</EmbeddedResource>
216229
<EmbeddedResource Include="Forms\FormMain.resx">
217230
<DependentUpon>FormMain.cs</DependentUpon>
231+
<SubType>Designer</SubType>
218232
</EmbeddedResource>
219233
<EmbeddedResource Include="Forms\FormPlatformSelect.resx">
220234
<DependentUpon>FormPlatformSelect.cs</DependentUpon>

BeatSaberModManager/Core/Helper.cs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,56 @@ namespace BeatSaberModManager.Core
1212
public static class Helper
1313
{
1414

15+
private static void CreateHttpErrorLog(WebException ex)
16+
{
17+
string response = ex.Response != null ? new StreamReader(ex.Response.GetResponseStream()).ReadToEnd().ToString() : "none";
18+
string[] text =
19+
{
20+
"################################################################",
21+
"This is an automatic error log",
22+
$"generated by BeatSaberModManager {Assembly.GetEntryAssembly().GetName().Version}",
23+
$"on {DateTime.Now:s}",
24+
"################################################################",
25+
"Message :",
26+
ex.Message,
27+
"----------------------------------------------------------------",
28+
"Stack trace :",
29+
ex.StackTrace,
30+
"----------------------------------------------------------------",
31+
"Status :",
32+
ex.Status.ToString(),
33+
"----------------------------------------------------------------",
34+
"Complete error :",
35+
ex.ToString(),
36+
"----------------------------------------------------------------",
37+
"Complete response :",
38+
response,
39+
"----------------------------------------------------------------"
40+
};
41+
string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"BeatSaberModManager_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log");
42+
43+
System.IO.File.WriteAllLines(filePath, text);
44+
}
1545
public static string Get(string URL) {
1646

17-
try {
18-
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
47+
try
48+
{
49+
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(URL);
1950
request.Method = "GET";
2051
request.KeepAlive = true;
2152
request.ContentType = "application/x-www-form-urlencoded";
2253
request.UserAgent = $"BeatSaberModManager/{Assembly.GetEntryAssembly().GetName().Version}";
23-
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
24-
using (StreamReader requestReader = new StreamReader(response.GetResponseStream())) {
54+
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
55+
using (StreamReader requestReader = new StreamReader(response.GetResponseStream()))
56+
{
2557
return requestReader.ReadToEnd();
2658
}
2759
}
28-
catch (Exception ex) {
29-
Console.WriteLine(ex.Message);
30-
MessageBox.Show("Failed to get version info! Please check your internet connection!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
60+
catch (WebException ex) {
61+
MessageBox.Show($"Error trying to access: {URL}\n\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
62+
#if DEBUG
63+
CreateHttpErrorLog(ex);
64+
#endif
3165
Environment.Exit(0);
3266
return null;
3367
}

BeatSaberModManager/Core/InstallerLogic.cs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.IO;
56

67
namespace BeatSaberModManager.Core
78
{
@@ -32,22 +33,47 @@ public void Run()
3233
try
3334
{
3435
StatusUpdate("Starting install sequence...");
36+
37+
ReleaseInfo bsipa = null;
38+
if ((bsipa = releases.Find(release => release.name.ToLower() == "bsipa")) != null)
39+
{
40+
StatusUpdate($"Downloading...{bsipa.title}");
41+
byte[] file = Helper.GetFile(bsipa.downloadLink);
42+
StatusUpdate($"Unzipping...{bsipa.title}");
43+
Helper.UnzipFile(file, installDirectory);
44+
StatusUpdate($"Unzipped! {bsipa.title}");
45+
46+
releases.Remove(bsipa); // don't want to double down
47+
}
48+
49+
var toInstall = Path.Combine(installDirectory, "IPA", "Pending");
50+
Directory.CreateDirectory(toInstall);
51+
3552
foreach (ReleaseInfo release in releases)
3653
{
3754
if (release.install)
3855
{
39-
StatusUpdate(string.Format("Downloading...{0}", release.title));
56+
StatusUpdate($"Downloading...{release.title}");
4057
byte[] file = Helper.GetFile(release.downloadLink);
41-
StatusUpdate(string.Format("Unzipping...{0}", release.title));
42-
Helper.UnzipFile(file, installDirectory);
43-
StatusUpdate(string.Format("Unzipped! {0}", release.title));
58+
StatusUpdate($"Unzipping...{release.title}");
59+
Helper.UnzipFile(file, toInstall);
60+
StatusUpdate($"Unzipped! {release.title}");
4461
}
4562
}
46-
Process.Start(installDirectory + @"\IPA.exe", Quoted(installDirectory + @"\Beat Saber.exe"));
63+
64+
// Only ever going to be downloading BSIPA
65+
Process.Start(new ProcessStartInfo
66+
{
67+
FileName = Path.Combine(installDirectory, "IPA.exe"),
68+
WorkingDirectory = installDirectory,
69+
Arguments = "-n"
70+
}).WaitForExit();
71+
4772
StatusUpdate("Install complete!");
4873
} catch (Exception ex)
4974
{
5075
StatusUpdate("Install failed! " + ex.ToString());
76+
Console.WriteLine("Install failed! " + ex.ToString());
5177
}
5278

5379
}

0 commit comments

Comments
 (0)