Skip to content

Commit

Permalink
fixed image download for installer
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 15, 2021
1 parent 48f5ee3 commit 1574453
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
29 changes: 20 additions & 9 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,16 @@ private void Form1_Load(object sender, EventArgs e)
if (DateTime.Now.AddHours(-20) > Properties.Settings.Default.lastUpdateCheck)
{
bool displayModuleWindow = false;
bool selectDefaultImages = false;
if (!Properties.Settings.Default.AlreadyAskedToDownloadSpeciesImageFiles)
{
Properties.Settings.Default.AlreadyAskedToDownloadSpeciesImageFiles = true;

if (!Updater.Updater.IsProgramInstalled)
displayModuleWindow = true;
else selectDefaultImages = true;
}
CheckForUpdates(true, displayModuleWindow);
CheckForUpdates(true, displayModuleWindow, selectDefaultImages);
}

_filterListAllowed = true;
Expand Down Expand Up @@ -1048,7 +1050,8 @@ private void checkForUpdatedStatsToolStripMenuItem_Click(object sender, EventArg
CheckForUpdates();
}

private async void CheckForUpdates(bool silentCheck = false, bool displayModuleWindowAlways = false)
private async void CheckForUpdates(bool silentCheck = false, bool displayModuleWindowAlways = false,
bool selectDefaultImages = false)
{
bool? updaterRunning = await Updater.Updater.CheckForPortableUpdate(silentCheck, UnsavedChanges());
if (!updaterRunning.HasValue) return; // error
Expand Down Expand Up @@ -1096,8 +1099,8 @@ private async void CheckForUpdates(bool silentCheck = false, bool displayModuleW
"No new Version available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

if (!silentCheck || displayModuleWindowAlways)
DisplayUpdateModules(!displayModuleWindowAlways);
if (!silentCheck || displayModuleWindowAlways || selectDefaultImages)
DisplayUpdateModules(!displayModuleWindowAlways, selectDefaultImages);
}

/// <summary>
Expand Down Expand Up @@ -3495,12 +3498,15 @@ private void extraDataToolStripMenuItem_Click(object sender, EventArgs e)
DisplayUpdateModules();
}

private async void DisplayUpdateModules(bool onlyDisplayIfUpdatesAreAvailable = false)
private async void DisplayUpdateModules(bool onlyDisplayIfUpdatesAreAvailable = false, bool selectDefaultImages = false)
{
using (var modules = new Updater.UpdateModules())
{
if (onlyDisplayIfUpdatesAreAvailable && !modules.UpdateAvailable)
if (!modules.UpdateAvailable && onlyDisplayIfUpdatesAreAvailable)
{
if (selectDefaultImages) InitializeImages(true);
return;
}

modules.ShowDialog();
if (modules.DialogResult != DialogResult.OK)
Expand All @@ -3512,10 +3518,15 @@ private async void DisplayUpdateModules(bool onlyDisplayIfUpdatesAreAvailable =
MessageBox.Show(result, $"Data downloaded - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK,
MessageBoxIcon.Information);

Properties.Settings.Default.SpeciesImagesFolder = modules.GetSpeciesImagesFolder();
CreatureColored.InitializeSpeciesImageLocation();
InitializeImages();

void InitializeImages(bool useDefaultImages = false)
{
Properties.Settings.Default.SpeciesImagesFolder = modules.GetSpeciesImagesFolder(useDefaultImages);
CreatureColored.InitializeSpeciesImageLocation();

speciesSelector1.InitializeSpeciesImages(Values.V.species);
speciesSelector1.InitializeSpeciesImages(Values.V.species);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ARKBreedingStats/Updater/UpdateModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ internal async Task<string> DownloadRequestedModulesAsync()
return sb.ToString();
}

public string GetSpeciesImagesFolder()
public string GetSpeciesImagesFolder(bool useDefaultImages)
{
if (!(_checkboxesSelectModule?.Any() ?? false)) return null;

return _checkboxesSelectModule.Where(cb => cb.Checked).Select(cb => cb.Tag as AsbModule)
return _checkboxesSelectModule.Where(cb => useDefaultImages || cb.Checked).Select(cb => cb.Tag as AsbModule)
.FirstOrDefault(m => m?.Category == "Species Images")?.LocalPath;
}
}
Expand Down
6 changes: 3 additions & 3 deletions setup-debug.iss
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon
[Run]
Filename: "powershell.exe"; Parameters: "-nologo -noprofile -command ""& {{ Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('{tmp}\img.zip', '{localappdata}\{#AppName}\img\'); }"""; Flags: runminimized; StatusMsg: "{cm:InstallImages}"; Tasks: images
Filename: "powershell.exe"; Parameters: "-nologo -noprofile -command ""& {{ Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('{tmp}\speciesImages.zip', '{localappdata}\{#AppName}\images\speciesImages\'); }"""; Flags: runminimized; StatusMsg: "{cm:InstallImages}"; Tasks: images
Filename: "{app}\{#AppExeName}"; Flags: nowait postinstall skipifsilent unchecked; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"
[UninstallRun]
Filename: "taskkill"; Parameters: "/im ""{#AppExeName}"""; Flags: runhidden
[UninstallDelete]
Type: filesandordirs; Name: "{app}\img"
Type: filesandordirs; Name: "{app}\images"
[Code]
var
Expand Down Expand Up @@ -163,7 +163,7 @@ begin
end;
if (CurPageID = wpSelectTasks) then begin
if IsTaskSelected('images') then
idpAddFile('https://github.com/cadon/ARKStatsExtractor/raw/master/img.zip', ExpandConstant('{tmp}\img.zip'));
idpAddFile('https://github.com/cadon/ARKStatsExtractor/raw/master/speciesImages/speciesImages.zip', ExpandConstant('{tmp}\speciesImages.zip'));
idpDownloadAfter(wpReady);
end;
Result := True;
Expand Down
10 changes: 5 additions & 5 deletions setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ DotNetFrameworkFailed5100=Your computer does not meet the requirements of the .N
de.DotNetFrameworkFailed5100=Ihr Computer erfüllt nicht die Voraussetzungen für das .NET Framework.
DotNetFrameworkFailedOther=The .NET Framework installer exited with an unexpected status code "%1". Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this installation and fix the problem if it did not.
de.DotNetFrameworkFailedOther=Die .NET Framework Installation endete mit dem nicht erwarteten Statuscode "%1". Überprüfen Sie alle anderen vom Installationsprogramm angezeigten Meldungen, um festzustellen, ob die Installation erfolgreich abgeschlossen wurde, und falls nicht, brechen Sie die Installation ab und beheben Sie das Problem.
DownloadImages=Download images for some of the species (~13 MB).
de.DownloadImages=Bilder für einige der Dinos herunterladen (~13 MB).
DownloadImages=Download images for some of the species (~17 MB).
de.DownloadImages=Bilder für einige der Dinos herunterladen (~17 MB).
CreatureImages=Additional creature images
de.CreatureImages=Zusätzliche Dino-Bilder
InstallImages=Installing additionally creature images
Expand Down Expand Up @@ -105,14 +105,14 @@ Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon
[Run]
Filename: "powershell.exe"; Parameters: "-nologo -noprofile -command ""& {{ Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('{tmp}\img.zip', '{localappdata}\{#AppName}\img\'); }"""; Flags: runminimized; StatusMsg: "{cm:InstallImages}"; Tasks: images
Filename: "powershell.exe"; Parameters: "-nologo -noprofile -command ""& {{ Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('{tmp}\speciesImages.zip', '{localappdata}\{#AppName}\images\speciesImages\'); }"""; Flags: runminimized; StatusMsg: "{cm:InstallImages}"; Tasks: images
Filename: "{app}\{#AppExeName}"; Flags: nowait postinstall skipifsilent unchecked; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"
[UninstallRun]
Filename: "taskkill"; Parameters: "/im ""{#AppExeName}"""; Flags: runhidden
[UninstallDelete]
Type: filesandordirs; Name: "{app}\img"
Type: filesandordirs; Name: "{app}\images"
[Code]
var
Expand Down Expand Up @@ -163,7 +163,7 @@ begin
end;
if (CurPageID = wpSelectTasks) then begin
if IsTaskSelected('images') then
idpAddFile('https://github.com/cadon/ARKStatsExtractor/raw/master/img.zip', ExpandConstant('{tmp}\img.zip'));
idpAddFile('https://github.com/cadon/ARKStatsExtractor/raw/master/speciesImages/speciesImages.zip', ExpandConstant('{tmp}\speciesImages.zip'));
idpDownloadAfter(wpReady);
end;
Result := True;
Expand Down

0 comments on commit 1574453

Please sign in to comment.