Browse Source

RemoteConsole: add Build Files

Yuxiao Mao 5 months ago
parent
commit
9382f669cc
4 changed files with 27 additions and 4 deletions
  1. 1 1
      hide/Ide.hx
  2. 9 0
      hide/view/RemoteConsoleView.hx
  3. 3 3
      hrt/impl/BuildTools.hx
  4. 14 0
      hrt/impl/RemoteConsole.hx

+ 1 - 1
hide/Ide.hx

@@ -1241,7 +1241,7 @@ class Ide extends hide.tools.IdeData {
 				setProgress('($percent%) $currentFile');
 			}, function(msg) {
 				error(msg);
-			}, function(count) {
+			}, function(count, errCount) {
 				setProgress();
 			});
 		});

+ 9 - 0
hide/view/RemoteConsoleView.hx

@@ -493,6 +493,15 @@ class RemoteConsoleCommandHeaps extends RemoteConsoleCommand {
 				onResult(r < 0 ? null : "sceneprof.json", "Scene prof");
 			});
 		}).element.appendTo(subcmd);
+		var subcmd = new Element('<div class="sub-command">
+			<h5>Res</h5>
+		</div>').appendTo(element);
+		var buildFilesBtn = new Element('<input type="button" value="Build Files"/>').appendTo(subcmd);
+		buildFilesBtn.on('click', function(e) {
+			panel.sendCommand("buildFiles", null, function(r) {
+				panel.log('Build files done, $r directory/files processed');
+			});
+		});
 	}
 	static var _ = RemoteConsoleView.registerCommandView("heaps", RemoteConsoleCommandHeaps);
 }

+ 3 - 3
hrt/impl/BuildTools.hx

@@ -14,7 +14,7 @@ class BuildTools {
 	/**
 		Build all files in `baseDir` directory (default: `res/`).
 	 */
-	public static function buildAllFiles( ?baseDir : String, ?onProgress : (percent:Float, currentFile:String) -> Void, ?onError : String -> Void, ?onDone : (count:Int) -> Void ) {
+	public static function buildAllFiles( ?baseDir : String, ?onProgress : (percent:Float, currentFile:String) -> Void, ?onError : String -> Void, ?onDone : (count:Int, errCount:Int) -> Void ) {
 		log("[INFO] Start building all files " + Date.now());
 		var baseDir = baseDir ?? "res/";
 		function getPath(path : String) {
@@ -26,7 +26,7 @@ class BuildTools {
 		var onError = onError ?? function(msg) {
 			log('[INFO] $msg');
 		};
-		var onDone = onDone ?? function(count) {
+		var onDone = onDone ?? function(count, errCount) {
 		};
 		var startTime = haxe.Timer.stamp();
 		var lastTime = startTime;
@@ -41,7 +41,7 @@ class BuildTools {
 					if( errors.length > 0 ) {
 						onError("Errors during Build Files:\n" + errors.join("\n"));
 					}
-					onDone(done);
+					onDone(done, errors.length);
 					return;
 				}
 				if( haxe.Timer.stamp() - lastTime > 0.1 ) {

+ 14 - 0
hrt/impl/RemoteConsole.hx

@@ -287,6 +287,10 @@ class RemoteConsoleConnection {
 		logError("[>] " + args);
 	}
 
+	function sendLog( msg : String ) {
+		sendCommand("log", msg);
+	}
+
 	function sendLogError( msg : String ) {
 		sendCommand("logError", msg);
 	}
@@ -574,5 +578,15 @@ class RemoteConsoleConnection {
 		#end
 	}
 
+	@cmd function buildFiles( onDone : Int -> Void ) {
+		sendLog("Build files begin");
+		BuildTools.buildAllFiles( null, null, null, function(count, errCount) {
+			if( errCount > 0 ) {
+				sendLogError('Build files has $errCount errors, please check game log for more details');
+			}
+			onDone(count);
+		});
+	}
+
 #end
 }