Skip to content

Commit

Permalink
Update Main.hx
Browse files Browse the repository at this point in the history
  • Loading branch information
VMan-2002 committed Jul 22, 2023
1 parent 0d2a796 commit 3e8fbb7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions sourceUpdater/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package;

import Reflect;
import Sys;
import flixel.math.FlxMath;
import haxe.Http;
import haxe.Json;
import haxe.Timer;
import lime.system.System;
import openfl.Lib;
import openfl.display.FPS;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.events.ProgressEvent;
Expand All @@ -30,8 +28,7 @@ typedef GamebananaFileResult = {
_bContainsExe:Bool
}

class Main extends Sprite
{
class Main extends Sprite {
#if (debug && !html5)
public static var debug:debugger.Local;
#end
Expand Down Expand Up @@ -230,6 +227,11 @@ class Main extends Sprite
FileSystem.createDirectory(getPath("mods"));
}
}

public function roundDecimal(n:Float):Float {
//So that we dont have to import FlxMath
return Math.floor(n * 10000) / 100;
}

function downloadFile(url:String, result:String, contentType:String, ?finishText:Null<String>) {
trace("Attempting download of "+url);
Expand Down Expand Up @@ -316,10 +318,10 @@ class Main extends Sprite
}
reader.addEventListener(ProgressEvent.PROGRESS, function(ev) {
downProg();
textThing.text = "Download progress: "+FlxMath.roundDecimal((ev.bytesLoaded / ev.bytesTotal) * 100, 2)+"%";
textThing.text = "Download progress: "+roundDecimal(ev.bytesLoaded / ev.bytesTotal)+"%";
stage.invalidate();
if (ev.bytesTotal > 0) {
trace("Download progress: "+FlxMath.roundDecimal((ev.bytesLoaded / ev.bytesTotal) * 100, 2)+"%");
trace("Download progress: "+roundDecimal(ev.bytesLoaded / ev.bytesTotal)+"%");
} else {
trace("Download progress");
}
Expand Down

0 comments on commit 3e8fbb7

Please sign in to comment.