im out of design ideas for the update screen

This commit is contained in:
Yoshman29
2022-12-17 15:31:43 +01:00
parent 8e90740ccf
commit 78216c2492
6 changed files with 38 additions and 9 deletions
+1 -1
View File
@@ -96,7 +96,7 @@
<!-- _________________________________ Engine Settings _______________________________ -->
<!-- Comment this out to disable updates !-->
<!-- <define name="UPDATE_CHECKING" /> -->
<define name="UPDATE_CHECKING" />
<!-- Comment this out to disable titlescreen.xml !-->
<haxedef name="TITLESCREEN_XML" />
+1 -1
View File
@@ -1 +1 @@
1516
1523
+1 -1
View File
@@ -178,7 +178,7 @@ class TitleState extends MusicBeatState
#if UPDATE_CHECKING
var report = funkin.updating.UpdateUtil.checkForUpdates();
if (report.newUpdate) {
FlxG.switchState(new funkin.updating.UpdateScreen(report));
FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report));
} else {
FlxG.switchState(new MainMenuState());
}
+8 -5
View File
@@ -47,8 +47,10 @@ class AsyncUpdater {
public function installFiles(files:Array<String>) {
progress.step = INSTALLING;
for(e in files) {
progress.files = files.length;
for(k=>e in files) {
var path = '$path$e';
progress.curFile = k+1;
trace('extracting file ${path}');
var reader = ZipUtils.openZip(path);
@@ -80,10 +82,10 @@ class AsyncUpdater {
progress.files = 1;
progress.step = DOWNLOADING_EXECUTABLE;
trace('starting exe download');
// doFile([exePath], [executableName], function() {
doFile([exePath], [executableName], function() {
trace('done, starting installation');
installFiles(fileNames);
// });
});
});
}
@@ -96,13 +98,14 @@ class AsyncUpdater {
var fn = fileNames.shift();
trace('downloading $f ($fn)');
progress.curFile++;
progress.bytesLoaded = 0;
progress.bytesTotal = 1;
downloadStream = new URLLoader();
downloadStream.dataFormat = BINARY;
downloadStream.addEventListener(ProgressEvent.PROGRESS, function(e) {
progress.bytesLoaded = e.bytesLoaded;
progress.bytesTotal = e.bytesTotal;
trace('${progress.bytesLoaded} / ${progress.bytesTotal}');
});
downloadStream.addEventListener(Event.COMPLETE, function(e) {
var fileOutput:FileOutput = File.write('$path$fn', true);
@@ -138,7 +141,7 @@ class UpdaterProgress {
public var files:Int = 0;
public var bytesLoaded:Float = 0;
public var bytesTotal:Float = 0;
public var curZipProgress:ZipProgress = null;
public var curZipProgress:ZipProgress = new ZipProgress();
public function new() {}
}
@@ -112,7 +112,7 @@ class UpdateAvailableScreen extends MusicBeatState {
public override function update(elapsed:Float) {
super.update(elapsed);
destY = FlxMath.bound(destY - (FlxG.mouse.wheel * 40), 0, Math.max(0, changeLogText.height - FlxG.height + versionCheckBG.height + 20 + optionsBG.height));
destY = FlxMath.bound(destY - (FlxG.mouse.wheel * 75), 0, Math.max(0, changeLogText.height - FlxG.height + versionCheckBG.height + 20 + optionsBG.height));
FlxG.camera.scroll.y = lerp(FlxG.camera.scroll.y, destY, 1/3);
if (controls.LEFT_P || controls.RIGHT_P) {
+26
View File
@@ -1,10 +1,14 @@
package funkin.updating;
import flixel.FlxG;
import flixel.ui.FlxBar;
import funkin.updating.UpdateUtil.UpdateCheckCallback;
class UpdateScreen extends MusicBeatState {
public var updater:AsyncUpdater;
public var progressBar:FlxBar;
public function new(check:UpdateCheckCallback) {
super(false);
updater = new AsyncUpdater(check.updates);
@@ -12,6 +16,28 @@ class UpdateScreen extends MusicBeatState {
public override function create() {
super.create();
progressBar = new FlxBar(0, FlxG.height - 150, LEFT_TO_RIGHT, FlxG.width, 150);
progressBar.createGradientBar([0xFF000000], [0xFF000000, 0xFF111111, 0xFF222222, 0xFF444444, 0xFF888888, -1], 1, 90);
progressBar.setRange(0, 4);
add(progressBar);
updater.execute();
}
public override function update(elapsed:Float) {
super.update(elapsed);
var prog = updater.progress;
switch(prog.step) {
case PREPARING:
progressBar.value = 0;
case DOWNLOADING_ASSETS:
progressBar.value = 1 + ((prog.curFile-1+(prog.bytesLoaded/prog.bytesTotal)) / prog.files);
case DOWNLOADING_EXECUTABLE:
progressBar.value = 2 + (prog.bytesLoaded/prog.bytesTotal);
case INSTALLING:
progressBar.value = 3 + ((prog.curFile-1+(prog.curZipProgress.curFile/prog.curZipProgress.fileCount))/prog.files);
}
}
}