Skip to content

Commit

Permalink
1.1.2 Release
Browse files Browse the repository at this point in the history
 - Lots Of Improvment Added
- Fixed Some Bugs
  • Loading branch information
amir1387aht committed Aug 6, 2024
1 parent a3f14c8 commit 0ab0e7e
Show file tree
Hide file tree
Showing 22 changed files with 273 additions and 69 deletions.
Binary file modified src/.vs/Unity Downloader/v17/.suo
Binary file not shown.
142 changes: 99 additions & 43 deletions src/Unity Downloader/AppDownloadForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public partial class AppDownloadForm : Form
{
private Form LastForm = new Form();

private UnityReleaseModule ParentModule;
private UnityReleaseModule CurrentModule;
private List<UnityReleaseModule> PendingSubModules = new List<UnityReleaseModule>();

private string CurrentFilePath = "";
private string ProgressFilePath = "";
Expand Down Expand Up @@ -43,6 +43,9 @@ public AppDownloadForm(Form lastForm, UnityReleaseModule module)
LastForm = lastForm;
CurrentModule = module;

if(CurrentModule.SubModules != null && CurrentModule.SubModules.Count != 0)
PendingSubModules = FindAllSubModules();

tempDownloadPath = Path.Combine(Path.GetTempPath(), "unity_downloader", MainForm.SelectedEditor);

if (!Directory.Exists(tempDownloadPath)) Directory.CreateDirectory(tempDownloadPath);
Expand Down Expand Up @@ -93,7 +96,7 @@ public AppDownloadForm(Form lastForm, UnityReleaseModule module)
TransferRateLabel.Text = "Transfer Rate : 0 MB/Sec";
TimeLeftLabel.Text = "Time Left : Calculating...";

ShowPendingText(CurrentModule.SubModules);
ShowPendingText();

InitializeProgressBars();

Expand All @@ -102,6 +105,38 @@ public AppDownloadForm(Form lastForm, UnityReleaseModule module)
StartDownload();
}

public List<UnityReleaseModule> FindAllSubModules()
{
var matchedSubModules = new List<UnityReleaseModule>();

var allModules = MainForm.AllReleaseModules;
var subModels = CurrentModule.SubModules;

foreach (var module in subModels)
{
AddSubModulesRecursively(allModules, matchedSubModules, module);
}

return matchedSubModules;
}

private void AddSubModulesRecursively(List<UnityReleaseModule> allModules, List<UnityReleaseModule> matchedSubModules, SubModule subModule)
{
var matchedModule = allModules.Find(m => m.Name == subModule.Name);
if (matchedModule != null)
{
matchedSubModules.Add(matchedModule);
}

if (subModule.SubModules != null && subModule.SubModules.Count > 0)
{
foreach (var nestedSubModule in subModule.SubModules)
{
AddSubModulesRecursively(allModules, matchedSubModules, nestedSubModule);
}
}
}

private void InitializeProgressBars()
{
for (int i = 0; i < progressBars.Length; i++)
Expand All @@ -126,6 +161,8 @@ public void UpdateProgressBar(int chunkIndex, int value)
}
}

private bool isInitialDownload = true;

private async void StartDownload()
{
try
Expand All @@ -142,7 +179,7 @@ private async void StartDownload()
LogsFilePath = Path.Combine(tempDownloadPath, $"Log.log");

// Show Download State
                AddLog($"-------------------- [{DateTime.Now}] New Download Starting. Name: {CurrentModule.Name}, Url: {CurrentModule.Url}, SubModels: {GetModelSubModels(CurrentModule.SubModules)} --------------------");
                AddLog($"-------------------- [{DateTime.Now}] New Download Starting. Name: {CurrentModule.Name}, Url: {CurrentModule.Url}, SubModels: {GetModelSubModels()} --------------------", false);

                // Show Logs Path
                AddLog($"Logs file can be found in \"{LogsFilePath}\"");
Expand All @@ -153,17 +190,27 @@ private async void StartDownload()
                // Check if a progress file exists
                if (File.Exists(ProgressFilePath))
{
                    // Prompt the user to continue from the saved progress
                    DialogResult result = MessageBox.Show(
// Prompt the user to continue from the saved progress
DialogResult result = isInitialDownload ? MessageBox.Show(
$"A save file was found for {CurrentModule.Name}. Do you want to continue from the saved file?",
"System Confirmation",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information
);

                    // Handle the user's choice
                    if (result == DialogResult.Yes)
await downloader.DownloadFileTaskAsync(DownloadProgress = LoadProgress(), CurrentModule.Url);
) : DialogResult.Yes;

// Handle the user's choice
if (result == DialogResult.Yes)
{
DownloadProgress = LoadProgress();

if (DownloadProgress.IsSaveComplete)
{
AddLog("Found an Exiting Completed Save. Skipping This Item.");
OnInstallComplete(null);
}
else
await downloader.DownloadFileTaskAsync(DownloadProgress, CurrentModule.Url);
}
else
await downloader.DownloadFileTaskAsync(CurrentModule.Url, CurrentFilePath);
}
Expand All @@ -181,7 +228,13 @@ private async void StartDownload()

private void ResetChunkProgressBars()
{
if (DownloadProgress == null || DownloadProgress.Chunks == null || DownloadProgress.Chunks.Length == 0) return;
if (DownloadProgress == null || DownloadProgress.Chunks == null || DownloadProgress.Chunks.Length == 0)
{
for (int i = 0; i < progressBars.Length; i++)
UpdateProgressBar(i, 0);

return;
}

for (int i = 0; i < progressBars.Length; i++)
UpdateProgressBar(i, DownloadProgress.Chunks[i].IsDownloadCompleted() ? 100 : 0);
Expand Down Expand Up @@ -267,36 +320,37 @@ private void OnDownloadFileCompleted(object sender, AsyncCompletedEventArgs e)

private void OnInstallComplete(Exception e)
{
ActionButton.Enabled = true;
CancelButton.Enabled = true;

if (e != null)
InvokeFunction(() =>
{
StatusLabel.Text = "An error was encountered during Installing";
AddLog($"An error was encountered during Installing, Error Message: {e.Message}, Source: {e.Source}, StackTrace:{e.StackTrace}");
MessageBox.Show($"An error was encountered during Installing, Error Message: {e.Message}, Source: {e.Source}, StackTrace:{e.StackTrace}", "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
SetActionButtonType(ActionButtonEnum.Retry);
return;
}
ActionButton.Enabled = true;
CancelButton.Enabled = true;

if ((CurrentModule.SubModules == null || CurrentModule.SubModules.Count == 0) && ParentModule == null)
{
MessageBox.Show("Installed Module Successfully!", "System Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
return;
}
if (e != null)
{
StatusLabel.Text = "An error was encountered during Installing";
AddLog($"An error was encountered during Installing, Error Message: {e.Message}, Source: {e.Source}, StackTrace:{e.StackTrace}");
MessageBox.Show($"An error was encountered during Installing, Error Message: {e.Message}, Source: {e.Source}, StackTrace:{e.StackTrace}", "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
SetActionButtonType(ActionButtonEnum.Retry);
return;
}

if (PendingSubModules.Count == 0)
{
MessageBox.Show("Installed Module Successfully!", "System Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
Close();
return;
}

            // Prepare for next model
            ref UnityReleaseModule NextModel = ref (ParentModule == null ? ref CurrentModule : ref ParentModule);
var ModuleToDownload = PendingSubModules.First();
PendingSubModules.Remove(ModuleToDownload);
CurrentModule = ModuleToDownload;

NextModel.SubModules.RemoveAt(0);
ShowPendingText();

ParentModule ??= CurrentModule;
string nextModelName = NextModel.SubModules[0].Name;
CurrentModule = MainForm.AllReleaseModules.Find(item => item.Name == nextModelName);
isInitialDownload = false;

ShowPendingText(ParentModule.SubModules);
StartDownload();
StartDownload();
});
}

private void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
Expand Down Expand Up @@ -359,19 +413,19 @@ private void OnDownloadStarted(object sender, DownloadStartedEventArgs e)
TransferRateLabel.Text = "Transfer Rate : 0 MB/Sec";
TimeLeftLabel.Text = "Time Left : Calculating...";
ResetChunkProgressBars();
ShowPendingText(CurrentModule.SubModules);
ShowPendingText();
});
}

private void ShowPendingText(List<SubModule> subModules) =>
PendingLabel.Text = GetModelSubModels(subModules);
private void ShowPendingText() =>
PendingLabel.Text = GetModelSubModels();

private string GetModelSubModels(List<SubModule> subModules)
private string GetModelSubModels()
{
string result = "Pending : -";

if (subModules != null && subModules.Count != 0)
result = "Pending : " + string.Join(", ", subModules.Select(x => x.Name));
if (PendingSubModules.Count != 0)
result = "Pending : " + string.Join(", ", PendingSubModules.Select(x => x.Name));

return result;
}
Expand Down Expand Up @@ -418,9 +472,11 @@ private void CancelButton_Click(object sender, EventArgs e)
Close();
}

private void AddLog(string text)
private void AddLog(string text, bool showInUI = true)
{
LogsList.Items.Add(text);
if(showInUI)
LogsList.Items.Add(text);

File.AppendAllText(LogsFilePath, $"[{DateTime.Now}] {text}\n");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Unity Downloader/Unity Downloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.1.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
2 changes: 1 addition & 1 deletion src/Unity Downloader/Unity Downloader.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<PublishUrlHistory>D:\Apps\UnityDownloader\|publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
Expand Down
12 changes: 1 addition & 11 deletions src/Unity Downloader/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,12 @@ public static bool RunProccess(string filePath, out string output)
{
ProcessStartInfo startInfo = new ProcessStartInfo(filePath)
{
UseShellExecute = true,
Verb = "runas" // Run as administrator
};

try
{
using (Process process = Process.Start(startInfo))
{
process.WaitForExit();

if (process.ExitCode != 0)
{
output = $"Running \"{filePath}\" encountered an error. Please try Run It Manually";
return false;
}
}
Process.Start(startInfo);
}
catch (Exception ex)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Unity Downloader/bin/Debug/Unity Downloader.application
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="Unity Downloader.application" version="1.0.0.4" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" xmlns="urn:schemas-microsoft-com:asm.v1" />
<assemblyIdentity name="Unity Downloader.application" version="1.1.2.3" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="Unity Downloader" asmv2:product="Unity Downloader" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" mapFileExtensions="true" />
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.8" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="Unity Downloader.exe.manifest" size="5440">
<assemblyIdentity name="Unity Downloader.exe" version="1.0.0.4" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
<assemblyIdentity name="Unity Downloader.exe" version="1.1.2.3" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>A3i0lQLwnbqgQQmMkFgwmMJxj9FF2JxVS/MZdMsBYHo=</dsig:DigestValue>
<dsig:DigestValue>vuCiz2yxyk9ngkbt+wwri5ovps+HSGfnwwzgmXUoKSs=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Expand Down
Binary file modified src/Unity Downloader/bin/Debug/Unity Downloader.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Unity Downloader/bin/Debug/Unity Downloader.exe.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<asmv1:assemblyIdentity name="Unity Downloader.exe" version="1.0.0.4" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
<asmv1:assemblyIdentity name="Unity Downloader.exe" version="1.1.2.3" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
<description asmv2:iconFile="unity_logo_icon_249311.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
<application />
<entryPoint>
Expand Down Expand Up @@ -67,14 +67,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="Unity Downloader.exe" size="433640">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="Unity Downloader.exe" size="434664">
<assemblyIdentity name="Unity Downloader" version="1.0.0.0" publicKeyToken="9DC1F4CA6583A488" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>WpF8hzZtnwuyB38dARuimh5wuRR2813h2hVBEtSYffY=</dsig:DigestValue>
<dsig:DigestValue>cr69N+B/dCBN2kdXc2LN41uFkeh/ZTCmhPw9O8kke9g=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Expand Down
Binary file modified src/Unity Downloader/bin/Debug/Unity Downloader.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file not shown.
Loading

0 comments on commit 0ab0e7e

Please sign in to comment.