luboslenco 1 سال پیش
والد
کامیت
a4710926af

+ 1 - 1
base/Sources/arm/Res.hx

@@ -49,7 +49,7 @@ class Res {
 	}
 	}
 
 
 	public static function embedFont(name: String, file: js.lib.ArrayBuffer) {
 	public static function embedFont(name: String, file: js.lib.ArrayBuffer) {
-		Data.cachedFonts.set(name, new kha.Font(file));
+		Data.cachedFonts.set(name, new Font(file));
 	}
 	}
 	#end
 	#end
 }
 }

+ 1 - 0
base/Sources/arm/io/ExportArm.hx

@@ -12,6 +12,7 @@ import iron.Scene;
 import iron.RenderPath;
 import iron.RenderPath;
 import iron.Vec4;
 import iron.Vec4;
 import iron.Lz4;
 import iron.Lz4;
+import iron.App;
 import arm.sys.Path;
 import arm.sys.Path;
 import arm.ProjectFormat;
 import arm.ProjectFormat;
 #if (is_paint || is_sculpt)
 #if (is_paint || is_sculpt)

+ 1 - 1
base/Sources/arm/io/ExportTexture.hx

@@ -143,7 +143,7 @@ class ExportTexture {
 		var textureSizeY = Config.getTextureResY();
 		var textureSizeY = Config.getTextureResY();
 		var formatQuality = Context.raw.formatQuality;
 		var formatQuality = Context.raw.formatQuality;
 		#if (krom_android || krom_ios)
 		#if (krom_android || krom_ios)
-		var f = kha.System.title;
+		var f = System.title;
 		#else
 		#else
 		var f = UIFiles.filename;
 		var f = UIFiles.filename;
 		#end
 		#end

+ 2 - 1
base/Sources/arm/io/ImportMesh.hx

@@ -5,6 +5,7 @@ import iron.SceneFormat;
 import iron.MeshData;
 import iron.MeshData;
 import iron.Data;
 import iron.Data;
 import iron.Scene;
 import iron.Scene;
+import iron.System;
 import arm.util.MeshUtil;
 import arm.util.MeshUtil;
 import arm.sys.Path;
 import arm.sys.Path;
 import arm.Viewport;
 import arm.Viewport;
@@ -60,7 +61,7 @@ class ImportMesh {
 		Project.meshAssets = [path];
 		Project.meshAssets = [path];
 
 
 		#if (krom_android || krom_ios)
 		#if (krom_android || krom_ios)
-		kha.System.title = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
+		System.title = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
 		#end
 		#end
 	}
 	}
 
 

+ 5 - 4
base/Sources/arm/ui/UIBox.hx

@@ -4,6 +4,7 @@ import zui.Zui;
 import iron.System;
 import iron.System;
 import iron.Input;
 import iron.Input;
 import iron.Tween;
 import iron.Tween;
+import iron.App;
 
 
 class UIBox {
 class UIBox {
 
 
@@ -161,14 +162,14 @@ class UIBox {
 	#if (krom_android || krom_ios)
 	#if (krom_android || krom_ios)
 	static function tweenIn() {
 	static function tweenIn() {
 		Tween.reset();
 		Tween.reset();
-		Tween.to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: Tween.Ease.ExpoOut});
+		Tween.to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: Ease.ExpoOut});
 		UIBox.hwnd.dragY = Std.int(System.height / 2);
 		UIBox.hwnd.dragY = Std.int(System.height / 2);
-		Tween.to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: Tween.Ease.ExpoOut, tick: function() { App.redrawUI(); }});
+		Tween.to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: Ease.ExpoOut, tick: function() { App.redrawUI(); }});
 	}
 	}
 
 
 	static function tweenOut() {
 	static function tweenOut() {
-		Tween.to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: Tween.Ease.ExpoIn, done: hideInternal});
-		Tween.to({target: UIBox.hwnd, props: { dragY: System.height / 2 }, duration: 0.2, ease: Tween.Ease.ExpoIn});
+		Tween.to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: Ease.ExpoIn, done: hideInternal});
+		Tween.to({target: UIBox.hwnd, props: { dragY: System.height / 2 }, duration: 0.2, ease: Ease.ExpoIn});
 	}
 	}
 	#end
 	#end
 
 

+ 37 - 39
misc/pad/Sources/Main.hx

@@ -1,11 +1,12 @@
 package;
 package;
 
 
-import haxe.io.Bytes;
+import js.lib.ArrayBuffer;
 import haxe.Json;
 import haxe.Json;
-import kha.Window;
-import kha.System;
 import zui.Zui;
 import zui.Zui;
-import iron.system.ArmPack;
+import iron.Data;
+import iron.System;
+import iron.ArmPack;
+import iron.Input;
 using StringTools;
 using StringTools;
 
 
 typedef TStorage = {
 typedef TStorage = {
@@ -33,7 +34,7 @@ class Main {
 	static var minimap_h = 0;
 	static var minimap_h = 0;
 	static var minimap_box_h = 0;
 	static var minimap_box_h = 0;
 	static var minimap_scrolling = false;
 	static var minimap_scrolling = false;
-	static var minimap: kha.Image = null;
+	static var minimap: Image = null;
 	static var window_header_h = 0;
 	static var window_header_h = 0;
 
 
 	public static function main() {
 	public static function main() {
@@ -62,25 +63,24 @@ class Main {
 		text_handle.text = storage.text;
 		text_handle.text = storage.text;
 		var ops: SystemOptions = {
 		var ops: SystemOptions = {
 			title: "ArmorPad",
 			title: "ArmorPad",
-			window: {
-				x: storage.window_x,
-				y: storage.window_y,
-				width: storage.window_w,
-				height: storage.window_h
-			},
-			framebuffer: {
-				samplesPerPixel: 1
-			}
+			x: storage.window_x,
+			y: storage.window_y,
+			width: storage.window_w,
+			height: storage.window_h,
+			features: FeatureResizable | FeatureMaximizable | FeatureMinimizable,
+			mode: WindowMode.Windowed,
+			frequency: 60,
+			vsync: true
 		};
 		};
 
 
 		System.start(ops, function() {
 		System.start(ops, function() {
-			kha.Assets.loadFontFromPath("data/font_mono.ttf", function(font: kha.Font) {
-				kha.Assets.loadBlobFromPath("data/themes/dark.json", function(blob_theme: kha.Blob) {
-					kha.Assets.loadBlobFromPath("data/text_coloring.json", function(blob_coloring: kha.Blob) {
+			Data.getFont("font_mono.ttf", function(font: Font) {
+				Data.getBlob("themes/dark.json", function(blob_theme: ArrayBuffer) {
+					Data.getBlob("text_coloring.json", function(blob_coloring: ArrayBuffer) {
 
 
-						var parsed = haxe.Json.parse(blob_theme.toString());
-						var theme = new zui.Zui.Theme();
-						for (key in Type.getInstanceFields(zui.Zui.Theme)) {
+						var parsed = Json.parse(System.bufferToString(blob_theme));
+						var theme = new Theme();
+						for (key in Type.getInstanceFields(Theme)) {
 							if (key == "theme_") continue;
 							if (key == "theme_") continue;
 							if (key.startsWith("set_")) continue;
 							if (key.startsWith("set_")) continue;
 							if (key.startsWith("get_")) key = key.substr(4);
 							if (key.startsWith("get_")) key = key.substr(4);
@@ -92,7 +92,7 @@ class Main {
 						Zui.onBorderHover = on_border_hover;
 						Zui.onBorderHover = on_border_hover;
 						Zui.onTextHover = on_text_hover;
 						Zui.onTextHover = on_text_hover;
 
 
-						var textColoring: TTextColoring = haxe.Json.parse(blob_coloring.toString());
+						var textColoring: TTextColoring = Json.parse(System.bufferToString(blob_coloring));
 						textColoring.default_color = Std.int(textColoring.default_color);
 						textColoring.default_color = Std.int(textColoring.default_color);
 						for (coloring in textColoring.colorings) coloring.color = Std.int(coloring.color);
 						for (coloring in textColoring.colorings) coloring.color = Std.int(coloring.color);
 						Zui.textAreaColoring = textColoring;
 						Zui.textAreaColoring = textColoring;
@@ -110,7 +110,7 @@ class Main {
 
 
 		Krom.setApplicationStateCallback(function() {}, function() {}, function() {}, function() {},
 		Krom.setApplicationStateCallback(function() {}, function() {}, function() {}, function() {},
 			function() { // Shutdown
 			function() { // Shutdown
-				Krom.fileSaveBytes(Krom.savePath() + "/config.json", haxe.io.Bytes.ofString(haxe.Json.stringify(storage)).getData());
+				Krom.fileSaveBytes(Krom.savePath() + "/config.json", System.stringToBuffer(Json.stringify(storage)));
 			}
 			}
 		);
 		);
 	}
 	}
@@ -134,12 +134,12 @@ class Main {
 				// Open file
 				// Open file
 				if (isFile) {
 				if (isFile) {
 					storage.file = abs;
 					storage.file = abs;
-					var bytes = Bytes.ofData(Krom.loadBlob(storage.file));
-					storage.text = f.endsWith(".arm") ? Json.stringify(ArmPack.decode(bytes), "    ") : bytes.toString();
+					var bytes = Krom.loadBlob(storage.file);
+					storage.text = f.endsWith(".arm") ? Json.stringify(ArmPack.decode(bytes), "    ") : System.bufferToString(bytes);
 					storage.text = StringTools.replace(storage.text, "\r", "");
 					storage.text = StringTools.replace(storage.text, "\r", "");
 					text_handle.text = storage.text;
 					text_handle.text = storage.text;
 					editor_handle.redraws = 1;
 					editor_handle.redraws = 1;
-					Krom.setWindowTitle(0, abs);
+					Krom.setWindowTitle(abs);
 				}
 				}
 				// Expand folder
 				// Expand folder
 				else {
 				else {
@@ -155,16 +155,14 @@ class Main {
 		}
 		}
 	}
 	}
 
 
-	static function render(framebuffer: kha.Framebuffer): Void {
-		var g = framebuffer.g2;
-
+	static function render(g2: Graphics2, g4: Graphics4): Void {
 		storage.window_w = System.width;
 		storage.window_w = System.width;
 		storage.window_h = System.height;
 		storage.window_h = System.height;
-		storage.window_x = Krom.windowX(0);
-		storage.window_y = Krom.windowY(0);
+		storage.window_x = Krom.windowX();
+		storage.window_y = Krom.windowY();
 		if (ui.inputDX != 0 || ui.inputDY != 0) Krom.setMouseCursor(0); // Arrow
 		if (ui.inputDX != 0 || ui.inputDY != 0) Krom.setMouseCursor(0); // Arrow
 
 
-		ui.begin(g);
+		ui.begin(g2);
 
 
 		if (ui.window(sidebar_handle, 0, 0, storage.sidebar_w, System.height, false)) {
 		if (ui.window(sidebar_handle, 0, 0, storage.sidebar_w, System.height, false)) {
 			var _BUTTON_TEXT_COL = ui.t.BUTTON_TEXT_COL;
 			var _BUTTON_TEXT_COL = ui.t.BUTTON_TEXT_COL;
@@ -197,7 +195,7 @@ class Main {
 					}
 					}
 
 
 					// Save
 					// Save
-					if (ui.isCtrlDown && ui.key == iron.system.Input.KeyCode.S) {
+					if (ui.isCtrlDown && ui.key == KeyCode.S) {
 						save_file();
 						save_file();
 					}
 					}
 
 
@@ -232,7 +230,7 @@ class Main {
 		}
 		}
 
 
 		// Build project
 		// Build project
-		if (ui.isCtrlDown && ui.key == iron.system.Input.KeyCode.B) {
+		if (ui.isCtrlDown && ui.key == KeyCode.B) {
 			save_file();
 			save_file();
 			build_project();
 			build_project();
 		}
 		}
@@ -244,9 +242,9 @@ class Main {
 		}
 		}
 
 
 		if (minimap != null) {
 		if (minimap != null) {
-			g.begin(false);
-			g.drawImage(minimap, minimap_x, minimap_y);
-			g.end();
+			g2.begin(false);
+			g2.drawImage(minimap, minimap_x, minimap_y);
+			g2.end();
 		}
 		}
 
 
 		if (editor_updated) {
 		if (editor_updated) {
@@ -263,8 +261,8 @@ class Main {
 		storage.text = StringTools.replace(storage.text, "    ", "\t");
 		storage.text = StringTools.replace(storage.text, "    ", "\t");
 		text_handle.text = storage.text;
 		text_handle.text = storage.text;
 		// Write bytes
 		// Write bytes
-		var bytes = storage.file.endsWith(".arm") ? ArmPack.encode(Json.parse(storage.text)) : Bytes.ofString(storage.text);
-		Krom.fileSaveBytes(storage.file, bytes.getData(), bytes.length);
+		var bytes = storage.file.endsWith(".arm") ? ArmPack.encode(Json.parse(storage.text)) : System.stringToBuffer(storage.text);
+		Krom.fileSaveBytes(storage.file, bytes, bytes.byteLength);
 		storage.modified = false;
 		storage.modified = false;
 	}
 	}
 
 
@@ -281,7 +279,7 @@ class Main {
 		if (minimap_h != System.height) {
 		if (minimap_h != System.height) {
 			minimap_h = System.height;
 			minimap_h = System.height;
 			if (minimap != null) minimap.unload();
 			if (minimap != null) minimap.unload();
-			minimap = kha.Image.createRenderTarget(minimap_w, minimap_h);
+			minimap = Image.createRenderTarget(minimap_w, minimap_h);
 		}
 		}
 
 
 		minimap.g2.begin(true, ui.t.SEPARATOR_COL);
 		minimap.g2.begin(true, ui.t.SEPARATOR_COL);