A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: Add WebExporter and improve JS callback registration
esenginee2da444192cb
diff --git a/CMakeLists.txt b/CMakeLists.txtindex a6737d8bf..9b0e1534d 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -17,6 +17,19 @@ option(ES_BUILD_MODULAR "Build modular WASM (Web only, dynamic linking)" OFF)option(ES_FEATURE_SDF_FONT "Enable SDF font rendering (requires FreeType)" OFF)option(ES_FEATURE_BITMAP_FONT "Enable bitmap font rendering (lightweight)" OFF)+# Auto-configure font features based on build target+if(ES_BUILD_WEB OR ES_BUILD_WXGAME)+ # Web/Mini-game: Force disable SDF font to reduce package size+ set(ES_FEATURE_SDF_FONT OFF CACHE BOOL "" FORCE)+ message(STATUS "Web build: SDF font disabled, using SystemFont")+elseif(ES_BUILD_EDITOR)+ # Editor: Enable SDF font by default for better quality+ if(NOT DEFINED CACHE{ES_FEATURE_SDF_FONT} OR NOT ES_FEATURE_SDF_FONT)+ set(ES_FEATURE_SDF_FONT ON CACHE BOOL "" FORCE)+ message(STATUS "Editor build: SDF font enabled")+ endif()+endif()+# Include custom CMake moduleslist(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")include(ESEngineConfig)diff --git a/assets/.esengine/assets.db b/assets/.esengine/assets.dbindex d01a8c13b..a99d83377 100644--- a/assets/.esengine/assets.db+++ b/assets/.esengine/assets.db@@ -2,172 +2,181 @@"version": "1.0","assets": [{- "guid": "2402078f-7772-c860-8bce-dfdb1fc37788",- "path": "F:\\microes\\assets\\audio\\bgm_main.mp3",- "name": "bgm_main.mp3",- "type": 3,+ "guid": "a9993ed8-9802-fb1c-f5e4-15864011fa2c",+ "path": "F:\\microes\\assets\\textures\\test.png",+ "name": "test.png",+ "type": 2,+ "fileSize": 6,+ "lastModified": 1769488062,+ "isDirectory": false+ },+ {+ "guid": "458ea613-0ce1-0325-3f9c-9f6937eafacf",+ "path": "assets\\prefabs\\Player.prefab",+ "name": "Player.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "fb6e1999-a210-5293-9dc9-f648e6e8fc1f",- "path": "assets\\shaders\\sprite.glsl",- "name": "sprite.glsl",- "type": 5,+ "guid": "6837963f-192a-0bcb-80e2-1cb45a8e35e7",+ "path": "assets\\scripts\\PlayerController.js",+ "name": "PlayerController.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "539c3218-76fb-bed8-1442-3c43ae5be464",- "path": "F:\\microes\\assets\\textures\\tileset.png",- "name": "tileset.png",+ "guid": "0f5a7d56-b021-7cfe-9ffd-b6deba57b565",+ "path": "assets\\textures\\ui_panel.png",+ "name": "ui_panel.png","type": 2,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{- "guid": "99c227eb-f8d3-d0e8-843b-ceb126687e8b",- "path": "F:\\microes\\assets\\audio",- "name": "audio",+ "guid": "0926ee8f-8eef-58fa-8d75-0ac49a8bf2b1",+ "path": "F:\\microes\\assets\\scenes",+ "name": "scenes","type": 1,"fileSize": 0,"lastModified": 1769503002,"isDirectory": true},{- "guid": "1c90475d-0d57-c627-f004-15d52bee4319",- "path": "F:\\microes\\assets\\shaders\\water.glsl",- "name": "water.glsl",- "type": 5,+ "guid": "bbbdbf23-cecf-5053-0ebe-f3daf5b9e103",+ "path": "assets\\prefabs\\Explosion.prefab",+ "name": "Explosion.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "86ed9e0d-442c-a047-9b51-09011c881685",- "path": "assets\\audio",- "name": "audio",+ "guid": "ab8960b7-4b05-8029-7577-571c44b9c394",+ "path": "F:\\microes\\assets\\fonts",+ "name": "fonts","type": 1,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769653161,"isDirectory": true},{- "guid": "0dd456da-eb9c-cdac-c429-b918b2f78b00",- "path": "F:\\microes\\assets\\shaders\\particle.glsl",- "name": "particle.glsl",- "type": 5,+ "guid": "83dd6048-d8fa-b62a-47d1-6f17771c459f",+ "path": "F:\\microes\\assets\\scripts",+ "name": "scripts",+ "type": 1,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": false+ "isDirectory": true},{- "guid": "73405f12-7a43-8434-140c-748f9448be34",- "path": "F:\\microes\\assets\\shaders\\axis.esshader",- "name": "axis.esshader",- "type": 0,- "fileSize": 392,- "lastModified": 1769701535,- "isDirectory": false+ "guid": "f543cca8-b481-a8be-8507-770c03c75eab",+ "path": "assets\\scenes",+ "name": "scenes",+ "type": 1,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": true},{- "guid": "c771ea16-ad7f-3333-df52-9426cff8a384",- "path": "assets\\textures\\ui_button.png",- "name": "ui_button.png",- "type": 2,+ "guid": "44626f54-604d-ae12-0f2e-2087f068acbf",+ "path": "F:\\microes\\assets\\prefabs\\Enemy.prefab",+ "name": "Enemy.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "a19bf5bf-7a78-8cbd-00c8-8f38cf141628",- "path": "F:\\microes\\assets\\fonts\\msyh.ttc",- "name": "msyh.ttc",+ "guid": "a638dc81-b60d-567f-6820-13f4e9998407",+ "path": "assets\\.esengine\\assets.db",+ "name": "assets.db","type": 0,- "fileSize": 19704352,- "lastModified": 1769511857,+ "fileSize": 2186,+ "lastModified": 1769502460,"isDirectory": false},{- "guid": "ca89cb26-11ee-a95a-940a-4d952d33b936",- "path": "F:\\microes\\assets\\scenes\\MainMenu.scene",- "name": "MainMenu.scene",- "type": 6,+ "guid": "cf70754c-26ba-346d-c01d-ff9fc29a6e9e",+ "path": "assets\\.esengine",+ "name": ".esengine",+ "type": 1,"fileSize": 0,- "lastModified": 1769503002,- "isDirectory": false+ "lastModified": 1769495857,+ "isDirectory": true},{- "guid": "602e5d05-e6b5-3cbe-a3a4-857b4290f255",- "path": "assets\\scripts\\CameraFollow.js",- "name": "CameraFollow.js",- "type": 4,+ "guid": "e19fb621-dd86-3c0c-6b10-142a848c6a14",+ "path": "assets\\audio\\sfx_jump.wav",+ "name": "sfx_jump.wav",+ "type": 3,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "44aa95ad-d460-37e0-041f-c6a4449f8b17",- "path": "assets\\textures\\test.png",- "name": "test.png",- "type": 2,- "fileSize": 6,- "lastModified": 1769488063,+ "guid": "e11483d8-2203-6eff-1b7e-0932b819f1c9",+ "path": "assets\\audio\\sfx_attack.wav",+ "name": "sfx_attack.wav",+ "type": 3,+ "fileSize": 0,+ "lastModified": 1769503001,"isDirectory": false},{- "guid": "b9c53311-d99a-e00b-9ba2-358e123efa4e",- "path": "assets\\scripts\\GameManager.js",- "name": "GameManager.js",- "type": 4,+ "guid": "0e48ebc1-25c8-2588-29aa-fb40564e2355",+ "path": "assets\\scenes\\MainMenu.scene",+ "name": "MainMenu.scene",+ "type": 6,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "4f4e6a0b-08fb-1c62-5a27-830f643cacff",- "path": "F:\\microes\\assets\\prefabs",- "name": "prefabs",- "type": 1,+ "guid": "6650f3d3-a906-b4a9-1873-b75759499bf8",+ "path": "F:\\microes\\assets\\audio\\sfx_jump.wav",+ "name": "sfx_jump.wav",+ "type": 3,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": true+ "isDirectory": false},{- "guid": "f543cca8-b481-a8be-8507-770c03c75eab",- "path": "assets\\scenes",- "name": "scenes",- "type": 1,+ "guid": "0dd456da-eb9c-cdac-c429-b918b2f78b00",+ "path": "F:\\microes\\assets\\shaders\\particle.glsl",+ "name": "particle.glsl",+ "type": 5,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": true+ "isDirectory": false},{- "guid": "06d02285-6f13-7665-e142-87cc08b9f6b8",- "path": "assets\\fonts\\lucide.ttf",- "name": "lucide.ttf",- "type": 8,- "fileSize": 793848,- "lastModified": 1769501796,- "isDirectory": false+ "guid": "86ed9e0d-442c-a047-9b51-09011c881685",+ "path": "assets\\audio",+ "name": "audio",+ "type": 1,+ "fileSize": 0,+ "lastModified": 1769503001,+ "isDirectory": true},{- "guid": "7fe2a865-bb30-1847-62e3-d289b5616a3a",- "path": "F:\\microes\\assets\\scenes\\BossRoom.scene",- "name": "BossRoom.scene",- "type": 6,+ "guid": "602e5d05-e6b5-3cbe-a3a4-857b4290f255",+ "path": "assets\\scripts\\CameraFollow.js",+ "name": "CameraFollow.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "d0e72f1c-981f-5995-dade-848b8b18813e",- "path": "assets\\textures\\background.png",- "name": "background.png",- "type": 2,+ "guid": "ca89cb26-11ee-a95a-940a-4d952d33b936",+ "path": "F:\\microes\\assets\\scenes\\MainMenu.scene",+ "name": "MainMenu.scene",+ "type": 6,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false@@ -182,157 +191,130 @@"isDirectory": true},{- "guid": "e0220f45-6261-175f-883b-ba80783788f2",- "path": "assets\\textures",- "name": "textures",- "type": 1,+ "guid": "d0e72f1c-981f-5995-dade-848b8b18813e",+ "path": "assets\\textures\\background.png",+ "name": "background.png",+ "type": 2,"fileSize": 0,- "lastModified": 1769503001,- "isDirectory": true+ "lastModified": 1769503002,+ "isDirectory": false},{- "guid": "9db35f84-665c-e687-86b1-cc78a3934216",- "path": "assets\\test.txt",- "name": "test.txt",+ "guid": "a19bf5bf-7a78-8cbd-00c8-8f38cf141628",+ "path": "F:\\microes\\assets\\fonts\\msyh.ttc",+ "name": "msyh.ttc","type": 0,- "fileSize": 5,- "lastModified": 1769488062,+ "fileSize": 19704352,+ "lastModified": 1769511857,"isDirectory": false},{- "guid": "02f457d5-e200-7f62-6850-7612ed829a63",- "path": "assets\\scenes\\BossRoom.scene",- "name": "BossRoom.scene",- "type": 6,+ "guid": "c771ea16-ad7f-3333-df52-9426cff8a384",+ "path": "assets\\textures\\ui_button.png",+ "name": "ui_button.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "b162bd84-eee3-1b79-807c-c64d2c64cb2b",- "path": "F:\\microes\\assets\\scripts\\PlayerController.js",- "name": "PlayerController.js",- "type": 4,+ "guid": "7d86b8df-60d3-330a-ae99-ae597a929a9b",+ "path": "assets\\textures\\player.png",+ "name": "player.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "38633421-fb34-4766-58e7-b4ba7c8b5ee3",- "path": "assets\\audio\\sfx_explosion.wav",- "name": "sfx_explosion.wav",- "type": 3,+ "guid": "ca417dff-fe94-4361-ec9b-16504f048514",+ "path": "F:\\microes\\assets\\prefabs\\Bullet.prefab",+ "name": "Bullet.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "d44064b6-5cd8-29c4-8dc3-e6f0b71c6ad1",- "path": "F:\\microes\\assets\\textures\\ui_panel.png",- "name": "ui_panel.png",- "type": 2,+ "guid": "2402078f-7772-c860-8bce-dfdb1fc37788",+ "path": "F:\\microes\\assets\\audio\\bgm_main.mp3",+ "name": "bgm_main.mp3",+ "type": 3,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "6650f3d3-a906-b4a9-1873-b75759499bf8",- "path": "F:\\microes\\assets\\audio\\sfx_jump.wav",- "name": "sfx_jump.wav",- "type": 3,+ "guid": "99c227eb-f8d3-d0e8-843b-ceb126687e8b",+ "path": "F:\\microes\\assets\\audio",+ "name": "audio",+ "type": 1,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": false+ "isDirectory": true},{- "guid": "3cc64ba4-5416-2768-7eff-dbba531179c4",- "path": "assets\\textures\\particle.png",- "name": "particle.png",- "type": 2,+ "guid": "1c90475d-0d57-c627-f004-15d52bee4319",+ "path": "F:\\microes\\assets\\shaders\\water.glsl",+ "name": "water.glsl",+ "type": 5,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "02f1f294-5a7f-d28b-7095-a04518207f9c",- "path": "F:\\microes\\assets\\scripts\\GameManager.js",- "name": "GameManager.js",- "type": 4,+ "guid": "ce69c963-c0ea-0fb2-c96c-bf1afc0e0802",+ "path": "assets\\shaders\\postprocess.glsl",+ "name": "postprocess.glsl",+ "type": 5,"fileSize": 0,- "lastModified": 1769503001,- "isDirectory": false- },- {- "guid": "3750f28c-b12f-4245-2036-9c552be15aea",- "path": "F:\\microes\\assets\\fonts\\lucide.ttf",- "name": "lucide.ttf",- "type": 8,- "fileSize": 793848,- "lastModified": 1769501795,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "7d86b8df-60d3-330a-ae99-ae597a929a9b",- "path": "assets\\textures\\player.png",- "name": "player.png",- "type": 2,+ "guid": "08964537-6809-2c47-8997-7bbf1c75029f",+ "path": "assets\\scripts",+ "name": "scripts",+ "type": 1,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": false+ "isDirectory": true},{- "guid": "ca417dff-fe94-4361-ec9b-16504f048514",- "path": "F:\\microes\\assets\\prefabs\\Bullet.prefab",- "name": "Bullet.prefab",- "type": 7,+ "guid": "8af759e0-a053-8e8c-1e34-48843f734d2f",+ "path": "assets\\textures\\enemy.png",+ "name": "enemy.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "a638dc81-b60d-567f-6820-13f4e9998407",- "path": "assets\\.esengine\\assets.db",- "name": "assets.db",- "type": 0,- "fileSize": 2186,- "lastModified": 1769502460,- "isDirectory": false- },- {- "guid": "cf70754c-26ba-346d-c01d-ff9fc29a6e9e",- "path": "assets\\.esengine",- "name": ".esengine",- "type": 1,- "fileSize": 0,- "lastModified": 1769495857,- "isDirectory": true- },- {- "guid": "e19fb621-dd86-3c0c-6b10-142a848c6a14",- "path": "assets\\audio\\sfx_jump.wav",- "name": "sfx_jump.wav",- "type": 3,+ "guid": "ed1cf9a5-9d96-50d7-e385-82c605f70a63",+ "path": "F:\\microes\\assets\\prefabs\\Explosion.prefab",+ "name": "Explosion.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "83dd6048-d8fa-b62a-47d1-6f17771c459f",- "path": "F:\\microes\\assets\\scripts",- "name": "scripts",+ "guid": "e0220f45-6261-175f-883b-ba80783788f2",+ "path": "assets\\textures",+ "name": "textures","type": 1,"fileSize": 0,"lastModified": 1769503001,"isDirectory": true},{- "guid": "08719359-3487-beb2-0d62-f54a2a8634c4",- "path": "assets\\shaders",- "name": "shaders",- "type": 1,+ "guid": "57c85655-8b7d-e5b6-d5a6-80eb2b0b49d3",+ "path": "assets\\scripts\\Inventory.js",+ "name": "Inventory.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": true+ "isDirectory": false},{"guid": "bca66dcd-f892-9c43-f176-62ac939c4de4",@@ -340,16 +322,7 @@"name": "sfx_attack.wav","type": 3,"fileSize": 0,- "lastModified": 1769503002,- "isDirectory": false- },- {- "guid": "57c85655-8b7d-e5b6-d5a6-80eb2b0b49d3",- "path": "assets\\scripts\\Inventory.js",- "name": "Inventory.js",- "type": 4,- "fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{@@ -376,48 +349,84 @@"name": "assets.db","type": 0,"fileSize": 24088,- "lastModified": 1769737335,+ "lastModified": 1769823748,"isDirectory": false},{- "guid": "49fa3441-7d74-bf79-c116-717b849b78ce",- "path": "F:\\microes\\assets\\prefabs\\Player.prefab",- "name": "Player.prefab",- "type": 7,+ "guid": "08719359-3487-beb2-0d62-f54a2a8634c4",+ "path": "assets\\shaders",+ "name": "shaders",+ "type": 1,"fileSize": 0,"lastModified": 1769503002,+ "isDirectory": true+ },+ {+ "guid": "ce792685-9959-2c9f-d909-597cab98305a",+ "path": "F:\\microes\\assets\\fonts\\lucide_new.ttf",+ "name": "lucide_new.ttf",+ "type": 8,+ "fileSize": 793848,+ "lastModified": 1769653162,"isDirectory": false},{- "guid": "d3d9a556-8861-fbc2-504a-151ef73f41de",- "path": "F:\\microes\\assets\\textures\\player.png",- "name": "player.png",+ "guid": "d44064b6-5cd8-29c4-8dc3-e6f0b71c6ad1",+ "path": "F:\\microes\\assets\\textures\\ui_panel.png",+ "name": "ui_panel.png","type": 2,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "f29a2ee0-016a-f018-436a-9c11731f251a",- "path": "F:\\microes\\assets\\scripts\\Inventory.js",- "name": "Inventory.js",- "type": 4,+ "guid": "02f457d5-e200-7f62-6850-7612ed829a63",+ "path": "assets\\scenes\\BossRoom.scene",+ "name": "BossRoom.scene",+ "type": 6,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "458ea613-0ce1-0325-3f9c-9f6937eafacf",- "path": "assets\\prefabs\\Player.prefab",- "name": "Player.prefab",- "type": 7,+ "guid": "b162bd84-eee3-1b79-807c-c64d2c64cb2b",+ "path": "F:\\microes\\assets\\scripts\\PlayerController.js",+ "name": "PlayerController.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "a9993ed8-9802-fb1c-f5e4-15864011fa2c",- "path": "F:\\microes\\assets\\textures\\test.png",+ "guid": "38633421-fb34-4766-58e7-b4ba7c8b5ee3",+ "path": "assets\\audio\\sfx_explosion.wav",+ "name": "sfx_explosion.wav",+ "type": 3,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": false+ },+ {+ "guid": "539c3218-76fb-bed8-1442-3c43ae5be464",+ "path": "F:\\microes\\assets\\textures\\tileset.png",+ "name": "tileset.png",+ "type": 2,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": false+ },+ {+ "guid": "fb6e1999-a210-5293-9dc9-f648e6e8fc1f",+ "path": "assets\\shaders\\sprite.glsl",+ "name": "sprite.glsl",+ "type": 5,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": false+ },+ {+ "guid": "44aa95ad-d460-37e0-041f-c6a4449f8b17",+ "path": "assets\\textures\\test.png","name": "test.png","type": 2,"fileSize": 6,@@ -425,30 +434,48 @@"isDirectory": false},{- "guid": "6837963f-192a-0bcb-80e2-1cb45a8e35e7",- "path": "assets\\scripts\\PlayerController.js",- "name": "PlayerController.js",+ "guid": "b9c53311-d99a-e00b-9ba2-358e123efa4e",+ "path": "assets\\scripts\\GameManager.js",+ "name": "GameManager.js","type": 4,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "44626f54-604d-ae12-0f2e-2087f068acbf",- "path": "F:\\microes\\assets\\prefabs\\Enemy.prefab",- "name": "Enemy.prefab",- "type": 7,+ "guid": "4f4e6a0b-08fb-1c62-5a27-830f643cacff",+ "path": "F:\\microes\\assets\\prefabs",+ "name": "prefabs",+ "type": 1,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": true+ },+ {+ "guid": "3cc64ba4-5416-2768-7eff-dbba531179c4",+ "path": "assets\\textures\\particle.png",+ "name": "particle.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "ce69c963-c0ea-0fb2-c96c-bf1afc0e0802",- "path": "assets\\shaders\\postprocess.glsl",- "name": "postprocess.glsl",+ "guid": "02f1f294-5a7f-d28b-7095-a04518207f9c",+ "path": "F:\\microes\\assets\\scripts\\GameManager.js",+ "name": "GameManager.js",+ "type": 4,+ "fileSize": 0,+ "lastModified": 1769503001,+ "isDirectory": false+ },+ {+ "guid": "e704f3d4-170b-fecb-d4f9-4534e5056d78",+ "path": "assets\\shaders\\particle.glsl",+ "name": "particle.glsl","type": 5,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{@@ -461,120 +488,156 @@"isDirectory": true},{- "guid": "e704f3d4-170b-fecb-d4f9-4534e5056d78",- "path": "assets\\shaders\\particle.glsl",- "name": "particle.glsl",- "type": 5,+ "guid": "986b148c-b4ea-cf89-2e04-37dc26624976",+ "path": "F:\\microes\\assets\\textures\\particle.png",+ "name": "particle.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "9d69bbdf-276b-8f14-cc66-10e8dfcdb283",- "path": "F:\\microes\\assets\\scripts\\CameraFollow.js",- "name": "CameraFollow.js",- "type": 4,+ "guid": "234c30b6-359c-51c1-a526-a970984ad90a",+ "path": "F:\\microes\\assets\\textures\\enemy.png",+ "name": "enemy.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "cc395f8f-d6f9-a23d-db3b-7253b437aa8a",- "path": "F:\\microes\\assets\\.esengine",- "name": ".esengine",- "type": 1,+ "guid": "4b48ff38-aeb0-7a1b-38ec-03ad938736e9",+ "path": "F:\\microes\\assets\\shaders\\sprite.glsl",+ "name": "sprite.glsl",+ "type": 5,"fileSize": 0,- "lastModified": 1769670136,- "isDirectory": true+ "lastModified": 1769503002,+ "isDirectory": false},{- "guid": "f23cff38-7fcd-d864-b487-6ca733c33582",- "path": "F:\\microes\\assets\\scripts\\EnemyAI.js",- "name": "EnemyAI.js",+ "guid": "a424334b-4399-6ab1-440c-7da10d865e15",+ "path": "assets\\scripts\\UIManager.js",+ "name": "UIManager.js","type": 4,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{- "guid": "88f4512c-08fc-7521-0720-aa75e35defbc",- "path": "assets\\audio\\bgm_main.mp3",- "name": "bgm_main.mp3",+ "guid": "32dd883f-81c7-59a9-8229-5920e8152da1",+ "path": "assets\\prefabs",+ "name": "prefabs",+ "type": 1,+ "fileSize": 0,+ "lastModified": 1769503001,+ "isDirectory": true+ },+ {+ "guid": "53cf7de5-ae26-2632-e022-e9108f6bbc2c",+ "path": "F:\\microes\\assets\\audio\\sfx_coin.wav",+ "name": "sfx_coin.wav","type": 3,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "9d4aa6d5-4f32-3634-e6fa-2c79467a2a9c",- "path": "F:\\microes\\assets\\shaders",- "name": "shaders",+ "guid": "e1d87090-38ce-2d60-5bdd-1f928fdaf88a",+ "path": "assets\\scenes\\Level1.scene",+ "name": "Level1.scene",+ "type": 6,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": false+ },+ {+ "guid": "ff5ba3b5-d524-f202-72ae-a40add555353",+ "path": "assets\\scenes\\Level2.scene",+ "name": "Level2.scene",+ "type": 6,+ "fileSize": 0,+ "lastModified": 1769503002,+ "isDirectory": false+ },+ {+ "guid": "9db35f84-665c-e687-86b1-cc78a3934216",+ "path": "assets\\test.txt",+ "name": "test.txt",+ "type": 0,+ "fileSize": 5,+ "lastModified": 1769488062,+ "isDirectory": false+ },+ {+ "guid": "cc395f8f-d6f9-a23d-db3b-7253b437aa8a",+ "path": "F:\\microes\\assets\\.esengine",+ "name": ".esengine","type": 1,"fileSize": 0,- "lastModified": 1769703321,+ "lastModified": 1769753978,"isDirectory": true},{- "guid": "6f4b1d08-8b77-b7eb-629d-c2ea4efba441",- "path": "F:\\microes\\assets\\prefabs\\Coin.prefab",- "name": "Coin.prefab",- "type": 7,+ "guid": "f23cff38-7fcd-d864-b487-6ca733c33582",+ "path": "F:\\microes\\assets\\scripts\\EnemyAI.js",+ "name": "EnemyAI.js",+ "type": 4,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "90db01ce-eadb-5131-35ee-a55e9f60bb4d",- "path": "assets\\shaders\\water.glsl",- "name": "water.glsl",+ "guid": "a6dd418b-dd75-0249-f26e-bb1b4cc294c8",+ "path": "F:\\microes\\assets\\shaders\\postprocess.glsl",+ "name": "postprocess.glsl","type": 5,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "6e88b347-db2d-b526-87c6-301569094b15",- "path": "F:\\microes\\assets\\audio\\sfx_explosion.wav",- "name": "sfx_explosion.wav",- "type": 3,- "fileSize": 0,- "lastModified": 1769503002,+ "guid": "835ed25e-a75f-3a42-0953-d9af26b1cc87",+ "path": "F:\\microes\\assets\\test.txt",+ "name": "test.txt",+ "type": 0,+ "fileSize": 5,+ "lastModified": 1769488063,"isDirectory": false},{- "guid": "b55ead52-b974-950b-26a3-a227e2ac41e9",- "path": "assets\\audio\\sfx_coin.wav",- "name": "sfx_coin.wav",- "type": 3,- "fileSize": 0,- "lastModified": 1769503002,+ "guid": "06d02285-6f13-7665-e142-87cc08b9f6b8",+ "path": "assets\\fonts\\lucide.ttf",+ "name": "lucide.ttf",+ "type": 8,+ "fileSize": 793848,+ "lastModified": 1769501796,"isDirectory": false},{- "guid": "c6113f63-03d0-811d-550a-8f26f331233d",- "path": "assets\\textures\\tileset.png",- "name": "tileset.png",- "type": 2,+ "guid": "d6dbbbb3-87ce-a096-8027-f7b9d7129e6f",+ "path": "assets\\scripts\\EnemyAI.js",+ "name": "EnemyAI.js",+ "type": 4,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{- "guid": "53cf7de5-ae26-2632-e022-e9108f6bbc2c",- "path": "F:\\microes\\assets\\audio\\sfx_coin.wav",- "name": "sfx_coin.wav",- "type": 3,+ "guid": "8283ad01-d8a2-48ae-c4e7-c1f8f0de7955",+ "path": "F:\\microes\\assets\\scripts\\UIManager.js",+ "name": "UIManager.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "e1d87090-38ce-2d60-5bdd-1f928fdaf88a",- "path": "assets\\scenes\\Level1.scene",- "name": "Level1.scene",- "type": 6,+ "guid": "04f5ced8-9d11-fa20-d612-06f12e563341",+ "path": "assets\\prefabs\\Coin.prefab",+ "name": "Coin.prefab",+ "type": 7,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{@@ -586,13 +649,22 @@"lastModified": 1769503002,"isDirectory": false},+ {+ "guid": "3750f28c-b12f-4245-2036-9c552be15aea",+ "path": "F:\\microes\\assets\\fonts\\lucide.ttf",+ "name": "lucide.ttf",+ "type": 8,+ "fileSize": 793848,+ "lastModified": 1769501796,+ "isDirectory": false+ },{"guid": "30c0a678-ec31-5c3c-f60c-2b982d208861","path": "F:\\microes\\assets\\textures\\background.png","name": "background.png","type": 2,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{@@ -601,58 +673,58 @@"name": "skybox.png","type": 2,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "ce792685-9959-2c9f-d909-597cab98305a",- "path": "F:\\microes\\assets\\fonts\\lucide_new.ttf",- "name": "lucide_new.ttf",- "type": 8,- "fileSize": 793848,- "lastModified": 1769653162,+ "guid": "6f4b1d08-8b77-b7eb-629d-c2ea4efba441",+ "path": "F:\\microes\\assets\\prefabs\\Coin.prefab",+ "name": "Coin.prefab",+ "type": 7,+ "fileSize": 0,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "e11483d8-2203-6eff-1b7e-0932b819f1c9",- "path": "assets\\audio\\sfx_attack.wav",- "name": "sfx_attack.wav",+ "guid": "88f4512c-08fc-7521-0720-aa75e35defbc",+ "path": "assets\\audio\\bgm_main.mp3",+ "name": "bgm_main.mp3","type": 3,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "0e48ebc1-25c8-2588-29aa-fb40564e2355",- "path": "assets\\scenes\\MainMenu.scene",- "name": "MainMenu.scene",- "type": 6,+ "guid": "9d4aa6d5-4f32-3634-e6fa-2c79467a2a9c",+ "path": "F:\\microes\\assets\\shaders",+ "name": "shaders",+ "type": 1,"fileSize": 0,- "lastModified": 1769503002,- "isDirectory": false+ "lastModified": 1769703321,+ "isDirectory": true},{- "guid": "d6dbbbb3-87ce-a096-8027-f7b9d7129e6f",- "path": "assets\\scripts\\EnemyAI.js",- "name": "EnemyAI.js",- "type": 4,+ "guid": "abf642da-9512-d0bd-e306-e1bce616320c",+ "path": "F:\\microes\\assets\\scenes\\Level2.scene",+ "name": "Level2.scene",+ "type": 6,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "04f5ced8-9d11-fa20-d612-06f12e563341",- "path": "assets\\prefabs\\Coin.prefab",- "name": "Coin.prefab",- "type": 7,+ "guid": "7fe2a865-bb30-1847-62e3-d289b5616a3a",+ "path": "F:\\microes\\assets\\scenes\\BossRoom.scene",+ "name": "BossRoom.scene",+ "type": 6,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{- "guid": "8283ad01-d8a2-48ae-c4e7-c1f8f0de7955",- "path": "F:\\microes\\assets\\scripts\\UIManager.js",- "name": "UIManager.js",+ "guid": "9d69bbdf-276b-8f14-cc66-10e8dfcdb283",+ "path": "F:\\microes\\assets\\scripts\\CameraFollow.js",+ "name": "CameraFollow.js","type": 4,"fileSize": 0,"lastModified": 1769503001,@@ -664,7 +736,7 @@"name": "bgm_battle.mp3","type": 3,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false},{@@ -673,7 +745,7 @@"name": "ui_button.png","type": 2,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{@@ -686,109 +758,73 @@"isDirectory": false},{- "guid": "ed1cf9a5-9d96-50d7-e385-82c605f70a63",- "path": "F:\\microes\\assets\\prefabs\\Explosion.prefab",- "name": "Explosion.prefab",- "type": 7,- "fileSize": 0,- "lastModified": 1769503002,+ "guid": "73405f12-7a43-8434-140c-748f9448be34",+ "path": "F:\\microes\\assets\\shaders\\axis.esshader",+ "name": "axis.esshader",+ "type": 0,+ "fileSize": 392,+ "lastModified": 1769701535,"isDirectory": false},{- "guid": "8af759e0-a053-8e8c-1e34-48843f734d2f",- "path": "assets\\textures\\enemy.png",- "name": "enemy.png",- "type": 2,+ "guid": "6e88b347-db2d-b526-87c6-301569094b15",+ "path": "F:\\microes\\assets\\audio\\sfx_explosion.wav",+ "name": "sfx_explosion.wav",+ "type": 3,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "08964537-6809-2c47-8997-7bbf1c75029f",- "path": "assets\\scripts",- "name": "scripts",- "type": 1,+ "guid": "c6113f63-03d0-811d-550a-8f26f331233d",+ "path": "assets\\textures\\tileset.png",+ "name": "tileset.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503002,- "isDirectory": true+ "isDirectory": false},{- "guid": "ff5ba3b5-d524-f202-72ae-a40add555353",- "path": "assets\\scenes\\Level2.scene",- "name": "Level2.scene",- "type": 6,+ "guid": "90db01ce-eadb-5131-35ee-a55e9f60bb4d",+ "path": "assets\\shaders\\water.glsl",+ "name": "water.glsl",+ "type": 5,"fileSize": 0,- "lastModified": 1769503002,+ "lastModified": 1769503001,"isDirectory": false},{- "guid": "bbbdbf23-cecf-5053-0ebe-f3daf5b9e103",- "path": "assets\\prefabs\\Explosion.prefab",- "name": "Explosion.prefab",- "type": 7,+ "guid": "b55ead52-b974-950b-26a3-a227e2ac41e9",+ "path": "assets\\audio\\sfx_coin.wav",+ "name": "sfx_coin.wav",+ "type": 3,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false},{- "guid": "0f5a7d56-b021-7cfe-9ffd-b6deba57b565",- "path": "assets\\textures\\ui_panel.png",- "name": "ui_panel.png",- "type": 2,+ "guid": "49fa3441-7d74-bf79-c116-717b849b78ce",+ "path": "F:\\microes\\assets\\prefabs\\Player.prefab",+ "name": "Player.prefab",+ "type": 7,"fileSize": 0,"lastModified": 1769503001,"isDirectory": false},{- "guid": "0926ee8f-8eef-58fa-8d75-0ac49a8bf2b1",- "path": "F:\\microes\\assets\\scenes",- "name": "scenes",- "type": 1,+ "guid": "d3d9a556-8861-fbc2-504a-151ef73f41de",+ "path": "F:\\microes\\assets\\textures\\player.png",+ "name": "player.png",+ "type": 2,"fileSize": 0,"lastModified": 1769503001,- "isDirectory": true- },- {- "guid": "ab8960b7-4b05-8029-7577-571c44b9c394",- "path": "F:\\microes\\assets\\fonts",- "name": "fonts",- "type": 1,- "fileSize": 0,- "lastModified": 1769653160,- "isDirectory": true- },- {- "guid": "a6dd418b-dd75-0249-f26e-bb1b4cc294c8",- "path": "F:\\microes\\assets\\shaders\\postprocess.glsl",- "name": "postprocess.glsl",- "type": 5,- "fileSize": 0,- "lastModified": 1769503002,- "isDirectory": false- },- {- "guid": "835ed25e-a75f-3a42-0953-d9af26b1cc87",- "path": "F:\\microes\\assets\\test.txt",- "name": "test.txt",- "type": 0,- "fileSize": 5,- "lastModified": 1769488062,- "isDirectory": false- },- {- "guid": "abf642da-9512-d0bd-e306-e1bce616320c",- "path": "F:\\microes\\assets\\scenes\\Level2.scene",- "name": "Level2.scene",- "type": 6,- "fileSize": 0,- "lastModified": 1769503002,"isDirectory": false},{- "guid": "090ed68c-0dbe-382c-e163-5ad3bc22abad",- "path": "F:\\microes\\assets\\scenes\\Level1.scene",- "name": "Level1.scene",- "type": 6,+ "guid": "f29a2ee0-016a-f018-436a-9c11731f251a",+ "path": "F:\\microes\\assets\\scripts\\Inventory.js",+ "name": "Inventory.js",+ "type": 4,"fileSize": 0,"lastModified": 1769503002,"isDirectory": false@@ -803,48 +839,12 @@"isDirectory": false},{- "guid": "a424334b-4399-6ab1-440c-7da10d865e15",- "path": "assets\\scripts\\UIManager.js",- "name": "UIManager.js",- "type": 4,- "fileSize": 0,- "lastModified": 1769503001,- "isDirectory": false- },- {- "guid": "32dd883f-81c7-59a9-8229-5920e8152da1",- "path": "assets\\prefabs",- "name": "prefabs",- "type": 1,- "fileSize": 0,- "lastModified": 1769503001,- "isDirectory": true- },- {- "guid": "4b48ff38-aeb0-7a1b-38ec-03ad938736e9",- "path": "F:\\microes\\assets\\shaders\\sprite.glsl",- "name": "sprite.glsl",- "type": 5,- "fileSize": 0,- "lastModified": 1769503001,- "isDirectory": false- },- {- "guid": "986b148c-b4ea-cf89-2e04-37dc26624976",- "path": "F:\\microes\\assets\\textures\\particle.png",- "name": "particle.png",- "type": 2,- "fileSize": 0,- "lastModified": 1769503001,- "isDirectory": false- },- {- "guid": "234c30b6-359c-51c1-a526-a970984ad90a",- "path": "F:\\microes\\assets\\textures\\enemy.png",- "name": "enemy.png",- "type": 2,+ "guid": "090ed68c-0dbe-382c-e163-5ad3bc22abad",+ "path": "F:\\microes\\assets\\scenes\\Level1.scene",+ "name": "Level1.scene",+ "type": 6,"fileSize": 0,- "lastModified": 1769503001,+ "lastModified": 1769503002,"isDirectory": false}]diff --git a/bindings/App.ts b/bindings/App.tsindex 27d8b2d39..e0589f6e1 100644--- a/bindings/App.ts+++ b/bindings/App.ts@@ -394,10 +394,6 @@ export interface AppConfig {// App// =============================================================================-interface ModuleWithCallback extends ESEngineModule {- _esRunJSSystems?: (schedule: number, dt: number) => void;-}-type SystemEntry = SystemFn | System;export class App {@@ -411,11 +407,13 @@ export class App {this.module_ = module;if (config) {- const cppConfig = new module.AppConfig();- if (config.title) cppConfig.title = config.title;- if (config.width) cppConfig.width = config.width;- if (config.height) cppConfig.height = config.height;- if (config.vsync !== undefined) cppConfig.vsync = config.vsync;+ // Pass config as plain object - embind value_object accepts JS objects+ const cppConfig = {+ title: config.title ?? 'ESEngine',+ width: config.width ?? 800,+ height: config.height ?? 600,+ vsync: config.vsync ?? true+ };this.cppApp_ = module.createAppWithConfig(cppConfig);} else {this.cppApp_ = module.createApp();@@ -425,9 +423,9 @@ export class App {this.systems_.set(i as Schedule, []);}- (module as ModuleWithCallback)._esRunJSSystems = (schedule: number) => {+ module.setJSSystemsCallback((schedule: number) => {this.runSystems(schedule as Schedule);- };+ });}addSystem(schedule: Schedule, system: SystemFn | System): this {diff --git a/bindings/AssetLoader.ts b/bindings/AssetLoader.tsnew file mode 100644index 000000000..d671a438f--- /dev/null+++ b/bindings/AssetLoader.ts@@ -0,0 +1,187 @@+/**+ * @file AssetLoader.ts+ * @brief Web platform asset loading utilities+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the MIT License.+ */++import type { ESEngineModule, ResourceManager, TextureHandle, ShaderHandle } from './esengine';+import { TextureFormat } from './esengine';++export interface TextureData {+ width: number;+ height: number;+ pixels: Uint8Array;+ format: 'RGBA8' | 'RGB8';+}++export interface ShaderData {+ vertexSource: string;+ fragmentSource: string;+}++export class AssetLoader {+ private module_: ESEngineModule;+ private resourceManager_: ResourceManager;+ private textureCache_ = new Map<string, TextureHandle>();+ private shaderCache_ = new Map<string, ShaderHandle>();++ constructor(module: ESEngineModule, resourceManager: ResourceManager) {+ this.module_ = module;+ this.resourceManager_ = resourceManager;+ }++ async loadAndCreateTexture(url: string): Promise<TextureHandle> {+ const cached = this.textureCache_.get(url);+ if (cached !== undefined) {+ return cached;+ }++ const data = await this.loadTexture(url);+ const handle = this.createTextureFromData(data);+ this.textureCache_.set(url, handle);+ return handle;+ }++ async loadAndCreateShader(url: string): Promise<ShaderHandle> {+ const cached = this.shaderCache_.get(url);+ if (cached !== undefined) {+ return cached;+ }++ const data = await this.loadShader(url);+ const handle = this.resourceManager_.createShader(data.vertexSource, data.fragmentSource);+ this.shaderCache_.set(url, handle);+ return handle;+ }++ createTextureFromData(data: TextureData): TextureHandle {+ const ptr = this.module_._malloc(data.pixels.length);+ this.module_.HEAPU8.set(data.pixels, ptr);++ const format = data.format === 'RGBA8' ? TextureFormat.RGBA8 : TextureFormat.RGB8;+ const handle = this.resourceManager_.createTexture(+ data.width, data.height, ptr, data.pixels.length, format+ );++ this.module_._free(ptr);+ return handle;+ }++ async loadTexture(url: string): Promise<TextureData> {+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch texture: ${url}`);+ }++ const blob = await response.blob();+ const bitmap = await createImageBitmap(blob, { premultiplyAlpha: 'none' });++ const canvas = document.createElement('canvas');+ canvas.width = bitmap.width;+ canvas.height = bitmap.height;++ const ctx = canvas.getContext('2d')!;+ ctx.drawImage(bitmap, 0, 0);++ const imageData = ctx.getImageData(0, 0, bitmap.width, bitmap.height);++ return {+ width: bitmap.width,+ height: bitmap.height,+ pixels: new Uint8Array(imageData.data.buffer),+ format: 'RGBA8'+ };+ }++ async loadShader(url: string): Promise<ShaderData> {+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch shader: ${url}`);+ }++ const source = await response.text();+ return this.parseESShader(source);+ }++ async loadText(url: string): Promise<string> {+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch: ${url}`);+ }+ return response.text();+ }++ async loadBinary(url: string): Promise<ArrayBuffer> {+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch: ${url}`);+ }+ return response.arrayBuffer();+ }++ async loadJson<T = unknown>(url: string): Promise<T> {+ const response = await fetch(url);+ if (!response.ok) {+ throw new Error(`Failed to fetch: ${url}`);+ }+ return response.json();+ }++ private parseESShader(source: string): ShaderData {+ let vertexSource = '';+ let fragmentSource = '';+ let sharedCode = '';+ let version = '';++ const lines = source.split('\n');+ let state: 'global' | 'vertex' | 'fragment' = 'global';+ let currentSection: string[] = [];++ for (const line of lines) {+ const trimmed = line.trim();++ if (trimmed.startsWith('#pragma')) {+ const parts = trimmed.substring(7).trim().split(/\s+/);+ const directive = parts[0];++ if (directive === 'version') {+ version = parts[1] || '';+ } else if (directive === 'vertex') {+ state = 'vertex';+ currentSection = [];+ } else if (directive === 'fragment') {+ state = 'fragment';+ currentSection = [];+ } else if (directive === 'end') {+ if (state === 'vertex') {+ vertexSource = currentSection.join('\n');+ } else if (state === 'fragment') {+ fragmentSource = currentSection.join('\n');+ }+ state = 'global';+ }+ continue;+ }++ if (state === 'global') {+ if (trimmed && !trimmed.startsWith('//')) {+ sharedCode += line + '\n';+ }+ } else {+ currentSection.push(line);+ }+ }++ const versionLine = version ? `#version ${version}\n` : '';++ return {+ vertexSource: versionLine + sharedCode + vertexSource,+ fragmentSource: versionLine + sharedCode + fragmentSource+ };+ }+}diff --git a/bindings/esengine.d.ts b/bindings/esengine.d.tsindex 99ff3f5f7..7fbd25bc7 100644--- a/bindings/esengine.d.ts+++ b/bindings/esengine.d.ts@@ -256,7 +256,7 @@ export interface ESEngineModule {_malloc(size: number): number;_free(ptr: number): void;- _esRunJSSystems?: (schedule: number, dt: number) => void;+ setJSSystemsCallback(callback: (schedule: number, dt: number) => void): void;[key: string]: unknown;}diff --git a/bindings/example.ts b/bindings/example.tsindex dff857cd3..e5b4b2012 100644--- a/bindings/example.ts+++ b/bindings/example.ts@@ -52,10 +52,6 @@ class RenderSystem extends UpdateSystem {}}-// =============================================================================-// Main-// =============================================================================-async function main(): Promise<void> {const module = await createModule();diff --git a/bindings/package.json b/bindings/package.jsonnew file mode 100644index 000000000..998429da2--- /dev/null+++ b/bindings/package.json@@ -0,0 +1,30 @@+{+ "name": "esengine",+ "version": "0.1.0",+ "description": "ESEngine TypeScript SDK and type definitions",+ "main": "App.ts",+ "types": "App.ts",+ "type": "module",+ "exports": {+ ".": {+ "types": "./App.ts",+ "default": "./App.ts"+ },+ "./wasm": {+ "types": "./esengine.d.ts"+ }+ },+ "files": [+ "esengine.d.ts",+ "App.ts",+ "AssetLoader.ts",+ "platform/"+ ],+ "keywords": ["esengine", "game-engine", "webassembly", "ecs"],+ "author": "ESEngine Team",+ "license": "MIT",+ "repository": {+ "type": "git",+ "url": "https://github.com/esengine/esengine.git"+ }+}diff --git a/build-modular/CPackConfig.cmake b/build-modular/CPackConfig.cmakeindex 13296022e..d469c0162 100644--- a/build-modular/CPackConfig.cmake+++ b/build-modular/CPackConfig.cmake@@ -22,14 +22,14 @@ set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")-set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericDescription.txt")+set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericDescription.txt")set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "ESEngine built using CMake")set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "ON")set(CPACK_GENERATOR "TGZ")set(CPACK_INNOSETUP_ARCHITECTURE "x86")set(CPACK_INSTALL_CMAKE_PROJECTS "F:/microes/build-modular;ESEngine;ALL;/")set(CPACK_INSTALL_PREFIX "F:/emsdk/upstream/emscripten/cache/sysroot")-set(CPACK_MODULE_PATH "F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/microes/cmake;F:/microes/third_party/freetype/builds/cmake")+set(CPACK_MODULE_PATH "F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/microes/cmake;F:/microes/third_party/freetype/builds/cmake")set(CPACK_NSIS_DISPLAY_NAME "ESEngine 2.13.3")set(CPACK_NSIS_INSTALLER_ICON_CODE "")set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")@@ -54,8 +54,8 @@ set(CPACK_PACKAGE_VERSION_MINOR "13")set(CPACK_PACKAGE_VERSION_PATCH "3")set(CPACK_READELF_EXECUTABLE "C:/msys64/mingw64/bin/readelf.exe")set(CPACK_RESOURCE_FILE_LICENSE "F:/microes/third_party/freetype/LICENSE.TXT")-set(CPACK_RESOURCE_FILE_README "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericDescription.txt")-set(CPACK_RESOURCE_FILE_WELCOME "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericWelcome.txt")+set(CPACK_RESOURCE_FILE_README "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericDescription.txt")+set(CPACK_RESOURCE_FILE_WELCOME "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericWelcome.txt")set(CPACK_SET_DESTDIR "OFF")set(CPACK_SOURCE_GENERATOR "TBZ2;TGZ;TXZ;TZ")set(CPACK_SOURCE_OUTPUT_CONFIG_FILE "F:/microes/build-modular/CPackSourceConfig.cmake")diff --git a/build-modular/CPackSourceConfig.cmake b/build-modular/CPackSourceConfig.cmakeindex dce52ae91..299fa1c6c 100644--- a/build-modular/CPackSourceConfig.cmake+++ b/build-modular/CPackSourceConfig.cmake@@ -22,7 +22,7 @@ set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")-set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericDescription.txt")+set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericDescription.txt")set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "ESEngine built using CMake")set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "ON")set(CPACK_GENERATOR "TBZ2;TGZ;TXZ;TZ")@@ -31,7 +31,7 @@ set(CPACK_INNOSETUP_ARCHITECTURE "x86")set(CPACK_INSTALLED_DIRECTORIES "F:/microes;/")set(CPACK_INSTALL_CMAKE_PROJECTS "")set(CPACK_INSTALL_PREFIX "F:/emsdk/upstream/emscripten/cache/sysroot")-set(CPACK_MODULE_PATH "F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/microes/cmake;F:/microes/third_party/freetype/builds/cmake")+set(CPACK_MODULE_PATH "F:/emsdk/upstream/emscripten/cmake/Modules;F:/emsdk/upstream/emscripten/cmake/Modules;F:/microes/cmake;F:/microes/third_party/freetype/builds/cmake")set(CPACK_NSIS_DISPLAY_NAME "ESEngine 2.13.3")set(CPACK_NSIS_INSTALLER_ICON_CODE "")set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")@@ -56,8 +56,8 @@ set(CPACK_PACKAGE_VERSION_MINOR "13")set(CPACK_PACKAGE_VERSION_PATCH "3")set(CPACK_READELF_EXECUTABLE "C:/msys64/mingw64/bin/readelf.exe")set(CPACK_RESOURCE_FILE_LICENSE "F:/microes/third_party/freetype/LICENSE.TXT")-set(CPACK_RESOURCE_FILE_README "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericDescription.txt")-set(CPACK_RESOURCE_FILE_WELCOME "C:/Program Files/CMake/share/cmake-4.2/Templates/CPack.GenericWelcome.txt")+set(CPACK_RESOURCE_FILE_README "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericDescription.txt")+set(CPACK_RESOURCE_FILE_WELCOME "C:/msys64/mingw64/share/cmake/Templates/CPack.GenericWelcome.txt")set(CPACK_RPM_PACKAGE_SOURCES "ON")set(CPACK_SET_DESTDIR "OFF")set(CPACK_SOURCE_GENERATOR "TBZ2;TGZ;TXZ;TZ")diff --git a/cmake/Emscripten.cmake b/cmake/Emscripten.cmakeindex 865116071..fdc91dc72 100644--- a/cmake/Emscripten.cmake+++ b/cmake/Emscripten.cmake@@ -165,6 +165,24 @@ set(ES_EMSCRIPTEN_SDK_LINK_FLAGS--closure=1)+# Single-file SDK link flags (WASM inlined as Base64, for playable ads)+set(ES_EMSCRIPTEN_SINGLE_FILE_FLAGS+ --bind+ -sWASM=1+ -sSINGLE_FILE=1+ -sUSE_WEBGL2=1+ -sFULL_ES3=1+ -sALLOW_MEMORY_GROWTH=1+ -sNO_EXIT_RUNTIME=1+ -sMODULARIZE=1+ "-sEXPORT_NAME='ESEngineModule'"+ "-sEXPORTED_FUNCTIONS=['_malloc','_free','_es_sdk_init','_es_sdk_version']"+ "-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap','HEAPF32','HEAPU8','HEAPU32']"+ -O3+ -flto+ --closure=1+)+function(es_apply_sdk_settings TARGET_NAME)if(ES_BUILD_WEB OR ES_BUILD_WXGAME)target_compile_options(${TARGET_NAME} PRIVATE ${ES_EMSCRIPTEN_COMPILE_FLAGS})@@ -177,6 +195,18 @@ function(es_apply_sdk_settings TARGET_NAME)endif()endfunction()+function(es_apply_single_file_settings TARGET_NAME)+ if(ES_BUILD_WEB OR ES_BUILD_WXGAME)+ target_compile_options(${TARGET_NAME} PRIVATE ${ES_EMSCRIPTEN_COMPILE_FLAGS} -flto)++ string(REPLACE ";" " " LINK_FLAGS_STR "${ES_EMSCRIPTEN_SINGLE_FILE_FLAGS}")+ set_target_properties(${TARGET_NAME} PROPERTIES+ SUFFIX ".js"+ LINK_FLAGS "${LINK_FLAGS_STR}"+ )+ endif()+endfunction()+message(STATUS "Emscripten configuration loaded")if(ES_BUILD_MODULAR)message(STATUS "Modular build enabled: MAIN_MODULE + SIDE_MODULE architecture")diff --git a/cmake/ModularBuild.cmake b/cmake/ModularBuild.cmakeindex f5104ee9c..1b50b3959 100644--- a/cmake/ModularBuild.cmake+++ b/cmake/ModularBuild.cmake@@ -5,10 +5,13 @@# This file configures the modular WASM build using Emscripten's dynamic linking.## Module Structure:-# - esengine_core (MAIN_MODULE): Core engine, renderer, ECS, platform-# - es_ui (SIDE_MODULE): UI system, widgets, docking-# - es_font_sdf (SIDE_MODULE): SDF font rendering (requires FreeType)-# - es_font_bitmap (SIDE_MODULE): Bitmap font rendering (lightweight)+# - es_core (SIDE_MODULE): Platform, Application, Log, Input+# - es_ecs (SIDE_MODULE): ECS system (header-only, minimal cpp)+# - es_renderer (SIDE_MODULE): Shader, Texture, Buffer, RenderPipeline+# - es_resource (SIDE_MODULE): ResourceManager, Loaders+# - es_ui_core (SIDE_MODULE): UIContext, Widget base, Layout, SystemFont+# - es_ui_widgets (SIDE_MODULE): Button, Label, ScrollView, etc.+# - es_ui_docking (SIDE_MODULE): Editor-only docking system## Usage:# emcmake cmake -B build-modular -DES_BUILD_WEB=ON -DES_BUILD_MODULAR=ON@@ -27,30 +30,86 @@ message(STATUS "")message(STATUS "=== ESEngine Modular Build Configuration ===")message(STATUS "")+# Common include directories for all modules+set(ES_COMMON_INCLUDES+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>+)++# Common compile definitions+set(ES_COMMON_DEFINITIONS ES_PLATFORM_WEB ES_BUILD_MODULAR)+# =============================================================================-# Core Module Sources (MAIN_MODULE)+# es_core - Platform Core Module# =============================================================================set(ES_CORE_SOURCESsrc/esengine/core/Application.cppsrc/esengine/core/Engine.cppsrc/esengine/core/Log.cpp- src/esengine/resource/ResourceManager.cpp+ src/esengine/platform/input/Input.cpp+ src/esengine/platform/PathResolver.cpp+ src/esengine/platform/web/WebPlatform.cpp+ src/esengine/platform/web/WebFileSystem.cpp+)++add_library(es_core SHARED ${ES_CORE_SOURCES})+target_include_directories(es_core PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_core PRIVATE glm)+target_compile_definitions(es_core PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_core)++set_target_properties(es_core PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"+)++# =============================================================================+# es_renderer - Rendering Module+# =============================================================================++set(ES_RENDERER_SOURCESsrc/esengine/renderer/RenderContext.cppsrc/esengine/renderer/Renderer.cppsrc/esengine/renderer/Shader.cppsrc/esengine/renderer/Buffer.cppsrc/esengine/renderer/Texture.cppsrc/esengine/renderer/Framebuffer.cpp- src/esengine/renderer/stb_image_impl.cpp- src/esengine/platform/input/Input.cpp- src/esengine/platform/PathResolver.cpp- src/esengine/platform/web/WebPlatform.cpp- src/esengine/platform/web/WebFileSystem.cpp+ src/esengine/renderer/RenderPipeline.cpp+)++add_library(es_renderer SHARED ${ES_RENDERER_SOURCES})+target_include_directories(es_renderer PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_renderer PRIVATE glm)+target_compile_definitions(es_renderer PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_renderer)++set_target_properties(es_renderer PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"+)++# =============================================================================+# es_resource - Resource Management Module+# =============================================================================++set(ES_RESOURCE_SOURCES+ src/esengine/resource/ResourceManager.cpp+ src/esengine/resource/ShaderParser.cpp+ src/esengine/resource/loaders/ShaderLoader.cpp+)++add_library(es_resource SHARED ${ES_RESOURCE_SOURCES})+target_include_directories(es_resource PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_resource PRIVATE glm)+target_compile_definitions(es_resource PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_resource)++set_target_properties(es_resource PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# UI Core Module Sources (SIDE_MODULE) - Base UI system+# es_ui_core - UI Core Module (includes SystemFont)# =============================================================================set(ES_UI_CORE_SOURCES@@ -60,160 +119,159 @@ set(ES_UI_CORE_SOURCESsrc/esengine/ui/layout/WrapLayout.cppsrc/esengine/ui/widgets/Widget.cppsrc/esengine/ui/widgets/Panel.cpp+ src/esengine/ui/font/SystemFont.cpp+ src/esengine/ui/text/TextMeasureHelper.cpp+)++add_library(es_ui_core SHARED ${ES_UI_CORE_SOURCES})+target_include_directories(es_ui_core PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_ui_core PRIVATE glm)+target_compile_definitions(es_ui_core PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_ui_core)++set_target_properties(es_ui_core PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# UI Widgets Module Sources (SIDE_MODULE) - Common widgets+# es_ui_widgets - UI Widgets Module# =============================================================================set(ES_UI_WIDGETS_SOURCESsrc/esengine/ui/widgets/Label.cppsrc/esengine/ui/widgets/Button.cpp- src/esengine/ui/widgets/ScrollView.cpp- src/esengine/ui/widgets/TreeView.cpp- src/esengine/ui/widgets/TextField.cppsrc/esengine/ui/widgets/Checkbox.cppsrc/esengine/ui/widgets/Slider.cpp+ src/esengine/ui/widgets/ClickablePanel.cpp)-# =============================================================================-# UI Docking Module Sources (SIDE_MODULE) - Editor docking system-# =============================================================================+add_library(es_ui_widgets SHARED ${ES_UI_WIDGETS_SOURCES})+target_include_directories(es_ui_widgets PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_ui_widgets PRIVATE glm)+target_compile_definitions(es_ui_widgets PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_ui_widgets)-set(ES_UI_DOCKING_SOURCES- src/esengine/ui/docking/DockNode.cpp- src/esengine/ui/docking/DockPanel.cpp- src/esengine/ui/docking/DockTabBar.cpp- src/esengine/ui/docking/DockZone.cpp- src/esengine/ui/docking/DockArea.cpp- src/esengine/ui/docking/DockLayoutSerializer.cpp+set_target_properties(es_ui_widgets PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# Font Module Sources (SIDE_MODULE)+# es_scrollview# =============================================================================-set(ES_FONT_SDF_SOURCES- src/esengine/ui/font/SDFFont.cpp-)--set(ES_FONT_BITMAP_SOURCES- src/esengine/ui/font/BitmapFont.cpp-)+add_library(es_scrollview SHARED src/esengine/ui/widgets/ScrollView.cpp)+target_include_directories(es_scrollview PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_scrollview PRIVATE glm)+target_compile_definitions(es_scrollview PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_scrollview)+set_target_properties(es_scrollview PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# Create Core Library (Static for linking)+# es_textfield# =============================================================================-add_library(esengine_core_lib STATIC ${ES_CORE_SOURCES})--target_include_directories(esengine_core_lib- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>-)--target_link_libraries(esengine_core_lib PUBLIC glm)-target_compile_definitions(esengine_core_lib PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR)+add_library(es_textfield SHARED src/esengine/ui/widgets/TextField.cpp)+target_include_directories(es_textfield PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_textfield PRIVATE glm)+target_compile_definitions(es_textfield PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_textfield)+set_target_properties(es_textfield PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# Create UI Core Side Module+# es_dropdown# =============================================================================-add_library(es_ui_core SHARED ${ES_UI_CORE_SOURCES})--target_include_directories(es_ui_core- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>-)--target_link_libraries(es_ui_core PRIVATE glm)-target_compile_definitions(es_ui_core PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR)--es_apply_side_module_settings(es_ui_core)+add_library(es_dropdown SHARED src/esengine/ui/widgets/Dropdown.cpp)+target_include_directories(es_dropdown PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_dropdown PRIVATE glm)+target_compile_definitions(es_dropdown PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_dropdown)+set_target_properties(es_dropdown PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# Create UI Widgets Side Module+# es_treeview# =============================================================================-add_library(es_ui_widgets SHARED ${ES_UI_WIDGETS_SOURCES})--target_include_directories(es_ui_widgets- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>-)+add_library(es_treeview SHARED src/esengine/ui/widgets/TreeView.cpp)+target_include_directories(es_treeview PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_treeview PRIVATE glm)+target_compile_definitions(es_treeview PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_treeview)+set_target_properties(es_treeview PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")-target_link_libraries(es_ui_widgets PRIVATE glm)-target_compile_definitions(es_ui_widgets PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR)+# =============================================================================+# es_contextmenu+# =============================================================================-es_apply_side_module_settings(es_ui_widgets)+add_library(es_contextmenu SHARED src/esengine/ui/widgets/ContextMenu.cpp)+target_include_directories(es_contextmenu PUBLIC ${ES_COMMON_INCLUDES})+target_link_libraries(es_contextmenu PRIVATE glm)+target_compile_definitions(es_contextmenu PUBLIC ${ES_COMMON_DEFINITIONS})+es_apply_side_module_settings(es_contextmenu)+set_target_properties(es_contextmenu PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules")# =============================================================================-# Create UI Docking Side Module (Editor only)+# es_ui_docking - UI Docking Module (Editor only)# =============================================================================-add_library(es_ui_docking SHARED ${ES_UI_DOCKING_SOURCES})--target_include_directories(es_ui_docking- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>+set(ES_UI_DOCKING_SOURCES+ src/esengine/ui/docking/DockNode.cpp+ src/esengine/ui/docking/DockPanel.cpp+ src/esengine/ui/docking/DockTabBar.cpp+ src/esengine/ui/docking/DockZone.cpp+ src/esengine/ui/docking/DockArea.cpp+ src/esengine/ui/docking/DockLayoutSerializer.cpp)+add_library(es_ui_docking SHARED ${ES_UI_DOCKING_SOURCES})+target_include_directories(es_ui_docking PUBLIC ${ES_COMMON_INCLUDES})target_link_libraries(es_ui_docking PRIVATE glm)-target_compile_definitions(es_ui_docking PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR)-+target_compile_definitions(es_ui_docking PUBLIC ${ES_COMMON_DEFINITIONS})es_apply_side_module_settings(es_ui_docking)+set_target_properties(es_ui_docking PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"+)+# =============================================================================-# Create Font SDF Side Module (if enabled)+# Optional Font Modules# =============================================================================if(ES_FEATURE_SDF_FONT)- add_library(es_font_sdf SHARED ${ES_FONT_SDF_SOURCES})-- target_include_directories(es_font_sdf- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>- ${CMAKE_SOURCE_DIR}/third_party/freetype/include+ set(ES_FONT_SDF_SOURCES+ src/esengine/ui/font/SDFFont.cpp+ src/esengine/ui/font/MSDFFont.cpp)- target_link_libraries(es_font_sdf PRIVATE glm freetype)- target_compile_definitions(es_font_sdf PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR ES_FEATURE_SDF_FONT=1)-+ add_library(es_font_sdf SHARED ${ES_FONT_SDF_SOURCES})+ target_include_directories(es_font_sdf PUBLIC+ ${ES_COMMON_INCLUDES}+ ${CMAKE_SOURCE_DIR}/third_party/freetype/include+ ${CMAKE_SOURCE_DIR}/third_party/msdfgen+ )+ target_link_libraries(es_font_sdf PRIVATE glm freetype msdfgen-core msdfgen-ext)+ target_compile_definitions(es_font_sdf PUBLIC ${ES_COMMON_DEFINITIONS} ES_FEATURE_SDF_FONT=1)es_apply_side_module_settings(es_font_sdf)- message(STATUS " - es_font_sdf: ENABLED (SDF font with FreeType)")-endif()+ set_target_properties(es_font_sdf PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"+ )-# =============================================================================-# Create Font Bitmap Side Module (if enabled)-# =============================================================================+ message(STATUS " - es_font_sdf: ENABLED")+endif()if(ES_FEATURE_BITMAP_FONT)- add_library(es_font_bitmap SHARED ${ES_FONT_BITMAP_SOURCES})-- target_include_directories(es_font_bitmap- PUBLIC- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>- )-+ add_library(es_font_bitmap SHARED src/esengine/ui/font/BitmapFont.cpp)+ target_include_directories(es_font_bitmap PUBLIC ${ES_COMMON_INCLUDES})target_link_libraries(es_font_bitmap PRIVATE glm)- target_compile_definitions(es_font_bitmap PUBLIC ES_PLATFORM_WEB ES_BUILD_MODULAR ES_FEATURE_BITMAP_FONT=1)-+ target_compile_definitions(es_font_bitmap PUBLIC ${ES_COMMON_DEFINITIONS} ES_FEATURE_BITMAP_FONT=1)es_apply_side_module_settings(es_font_bitmap)- message(STATUS " - es_font_bitmap: ENABLED (lightweight bitmap font)")+ set_target_properties(es_font_bitmap PROPERTIES+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"+ )++ message(STATUS " - es_font_bitmap: ENABLED")endif()# =============================================================================@@ -221,15 +279,13 @@ endif()# =============================================================================message(STATUS "")-message(STATUS "Modular build targets:")-message(STATUS " - esengine_core_lib: Core engine (static library)")-message(STATUS " - es_ui_core: UI core (side module)")-message(STATUS " - es_ui_widgets: UI widgets (side module)")-message(STATUS " - es_ui_docking: UI docking - editor only (side module)")-if(ES_FEATURE_SDF_FONT)- message(STATUS " - es_font_sdf: SDF font (side module)")-endif()-if(ES_FEATURE_BITMAP_FONT)- message(STATUS " - es_font_bitmap: Bitmap font (side module)")-endif()+message(STATUS "Modular build targets (output: build-modular/modules/):")+message(STATUS " Core:")+message(STATUS " - es_core, es_renderer, es_resource")+message(STATUS " UI:")+message(STATUS " - es_ui_core, es_ui_widgets")+message(STATUS " - es_scrollview, es_textfield, es_dropdown")+message(STATUS " - es_treeview, es_contextmenu")+message(STATUS " Editor:")+message(STATUS " - es_ui_docking")message(STATUS "")diff --git a/src/esengine/app/App.cpp b/src/esengine/app/App.cppindex d9df982fe..32d45e517 100644--- a/src/esengine/app/App.cpp+++ b/src/esengine/app/App.cpp@@ -16,6 +16,7 @@#ifdef ES_PLATFORM_WEB#include <emscripten.h>#include <emscripten/html5.h>+#include <emscripten/val.h>#endifnamespace esengine {@@ -183,14 +184,17 @@ void App::runSystems(Schedule schedule) {}#ifdef ES_PLATFORM_WEB-EM_JS(void, es_call_js_systems, (int schedule, float dt), {- if (Module._esRunJSSystems) {- Module._esRunJSSystems(schedule, dt);- }-});+void* App::jsSystemsCallback_ = nullptr;++void App::setJSSystemsCallback(void* callback) {+ jsSystemsCallback_ = callback;+}void App::runJSSystems(Schedule schedule, f32 dt) {- es_call_js_systems(static_cast<int>(schedule), dt);+ if (jsSystemsCallback_) {+ auto& callback = *static_cast<emscripten::val*>(jsSystemsCallback_);+ callback(static_cast<int>(schedule), dt);+ }}#endifdiff --git a/src/esengine/app/App.hpp b/src/esengine/app/App.hppindex 2f129c9d4..ef2c57cc8 100644--- a/src/esengine/app/App.hpp+++ b/src/esengine/app/App.hpp@@ -128,6 +128,8 @@ public:#ifdef ES_PLATFORM_WEBvoid runJSSystems(Schedule schedule, f32 dt);+ static void setJSSystemsCallback(void* callback);+ static void* jsSystemsCallback_;#endifprivate:diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 27fb6af6b..8a0d877c8 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -353,6 +353,12 @@ EMSCRIPTEN_BINDINGS(esengine_app) {function("getApp", optional_override([]() -> App* {return &App::get();}), allow_raw_pointers());++ function("setJSSystemsCallback", optional_override([](emscripten::val callback) {+ static emscripten::val storedCallback = emscripten::val::undefined();+ storedCallback = callback;+ App::setJSSystemsCallback(&storedCallback);+ }));}// =============================================================================diff --git a/src/esengine/editor/AssetDatabase.cpp b/src/esengine/editor/AssetDatabase.cppindex e3778c623..a1052b1f8 100644--- a/src/esengine/editor/AssetDatabase.cpp+++ b/src/esengine/editor/AssetDatabase.cpp@@ -132,6 +132,12 @@ void AssetDatabase::scanDirectory(const std::string& directory, bool recursive)for (const auto& entryPath : entries) {bool isDir = FileSystem::directoryExists(entryPath);+ std::string name = getFileName(entryPath);++ // Skip excluded directories+ if (isDir && isExcludedDirectory(name)) {+ continue;+ }auto existingIt = pathToGUID_.find(entryPath);if (existingIt != pathToGUID_.end()) {@@ -148,7 +154,7 @@ void AssetDatabase::scanDirectory(const std::string& directory, bool recursive)AssetMetadata metadata;metadata.guid = generateGUID();metadata.path = entryPath;- metadata.name = getFileName(entryPath);+ metadata.name = name;metadata.extension = getFileExtension(entryPath);metadata.isDirectory = isDir;metadata.type = isDir ? AssetType::Folder : detectAssetType(entryPath);@@ -169,6 +175,15 @@ void AssetDatabase::scanDirectory(const std::string& directory, bool recursive)}}+bool AssetDatabase::isExcludedDirectory(const std::string& name) const {+ for (const auto& excluded : excludedDirs_) {+ if (name == excluded) {+ return true;+ }+ }+ return false;+}+// =============================================================================// Query Methods// =============================================================================diff --git a/src/esengine/editor/AssetDatabase.hpp b/src/esengine/editor/AssetDatabase.hppindex 63f08dcf3..508361a41 100644--- a/src/esengine/editor/AssetDatabase.hpp+++ b/src/esengine/editor/AssetDatabase.hpp@@ -73,6 +73,7 @@ public:private:void scanDirectory(const std::string& directory, bool recursive);+ bool isExcludedDirectory(const std::string& name) const;std::string generateGUID() const;std::string getDatabasePath() const;AssetType detectAssetType(const std::string& path) const;@@ -80,6 +81,7 @@ private:std::string projectPath_;std::unordered_map<std::string, AssetMetadata> assetsByGUID_;std::unordered_map<std::string, std::string> pathToGUID_;+ std::vector<std::string> excludedDirs_ = {"node_modules", "build", ".esengine", ".git", ".vscode", ".idea"};std::function<void(const AssetMetadata&)> onAssetAdded_;std::function<void(const std::string&)> onAssetRemoved_;diff --git a/src/esengine/editor/CMakeLists.txt b/src/esengine/editor/CMakeLists.txtindex 8d5131be2..6a31489f6 100644--- a/src/esengine/editor/CMakeLists.txt+++ b/src/esengine/editor/CMakeLists.txt@@ -46,6 +46,10 @@ set(EDITOR_SOURCESwidgets/EditorRootContainer.cppwidgets/EditorToolbar.cppwidgets/SceneToolbar.cpp++ # Preview+ preview/WebPreviewServer.cpp+ preview/WebExporter.cpp)set(EDITOR_HEADERS@@ -107,6 +111,10 @@ set(EDITOR_HEADERSwidgets/EditorRootContainer.hppwidgets/EditorToolbar.hppwidgets/SceneToolbar.hpp++ # Preview+ preview/WebPreviewServer.hpp+ preview/WebExporter.hpp)# Create editor executablediff --git a/src/esengine/editor/EditorApplication.cpp b/src/esengine/editor/EditorApplication.cppindex d39218441..812948d04 100644--- a/src/esengine/editor/EditorApplication.cpp+++ b/src/esengine/editor/EditorApplication.cpp@@ -38,6 +38,9 @@#include "widgets/EditorRootContainer.hpp"#include "widgets/EditorToolbar.hpp"#include "../platform/FileDialog.hpp"+#include "preview/WebExporter.hpp"++#include <filesystem>namespace esengine {namespace editor {@@ -72,51 +75,66 @@ void EditorApplication::onInit() {uiContext_->setViewport(getWidth(), getHeight());uiContext_->setDevicePixelRatio(getPlatform().getDevicePixelRatio());- const char* fontPaths[] = {+ bool fontLoaded = false;++#if ES_FEATURE_SDF_FONT+ // Try system fonts for MSDF rendering+ const char* msdfFontPaths[] = {+ "C:/Windows/Fonts/msyh.ttc", // Microsoft YaHei (Chinese)+ "C:/Windows/Fonts/segoeui.ttf", // Segoe UI+ "C:/Windows/Fonts/arial.ttf", // Arial+ nullptr+ };++ for (const char** fontPath = msdfFontPaths; *fontPath != nullptr; ++fontPath) {+ if (uiContext_->loadMSDFFont("default", *fontPath, 32.0f)) {+ ES_LOG_INFO("Loaded MSDF font: {}", *fontPath);+ fontLoaded = true;+ break;+ }+ }++ std::string iconFontPath = PathResolver::editorPath("assets/fonts/lucide.ttf");+ if (!uiContext_->loadMSDFFont("icons", iconFontPath, 32.0f)) {+ ES_LOG_WARN("Icon MSDF font not loaded from '{}', icons will not render", iconFontPath);+ }+#else+ const char* fontFamilies[] = {#ifdef ES_PLATFORM_WINDOWS- "C:/Windows/Fonts/msyh.ttc",- "C:/Windows/Fonts/msyhl.ttc",- "C:/Windows/Fonts/simhei.ttf",- "C:/Windows/Fonts/segoeui.ttf",- "C:/Windows/Fonts/arial.ttf",+ "Microsoft YaHei",+ "SimHei",+ "Segoe UI",+ "Arial",#elif defined(ES_PLATFORM_MACOS)- "/System/Library/Fonts/PingFang.ttc",- "/System/Library/Fonts/Hiragino Sans GB.ttc",- "/System/Library/Fonts/SFNS.ttf",+ "PingFang SC",+ "Hiragino Sans GB",+ "SF Pro",#else- "/usr/share/fonts/truetype/noto/NotoSansCJK-Regular.ttc",- "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",- "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",+ "Noto Sans CJK SC",+ "DejaVu Sans",+ "sans-serif",#endifnullptr};- bool fontLoaded = false;- for (const char** path = fontPaths; *path != nullptr; ++path) {- if (uiContext_->loadMSDFFont("default", *path, 32.0f, 4.0f)) {- ES_LOG_INFO("Loaded MSDF font: {}", *path);+ for (const char** family = fontFamilies; *family != nullptr; ++family) {+ if (uiContext_->createSystemFont("default", *family, 14.0f)) {+ ES_LOG_INFO("Created system font: {}", *family);fontLoaded = true;break;}}- if (!fontLoaded) {- std::string fallbackFont = PathResolver::editorPath("assets/fonts/default.ttf");- if (uiContext_->loadMSDFFont("default", fallbackFont, 32.0f, 4.0f)) {- ES_LOG_INFO("Loaded MSDF font: {}", fallbackFont);- fontLoaded = true;- }+ std::string iconFontPath = PathResolver::editorPath("assets/fonts/lucide.ttf");+ if (!uiContext_->createSystemFontFromFile("icons", iconFontPath, 16.0f)) {+ ES_LOG_WARN("Icon font not loaded from '{}', icons will not render", iconFontPath);}+#endifif (!fontLoaded) {ES_LOG_WARN("No font loaded, text will not render");}- std::string iconFontPath = PathResolver::editorPath("assets/fonts/lucide.ttf");- if (!uiContext_->loadMSDFFont("icons", iconFontPath, 32.0f, 4.0f)) {- ES_LOG_WARN("Icon font not loaded, icons will not render");- }-// Wire up scroll events to UI systemgetPlatform().setScrollCallback([this](f32 deltaX, f32 deltaY, f32 x, f32 y) {if (uiContext_) {@@ -422,6 +440,40 @@ void EditorApplication::setupEditorLayout() {ES_LOG_INFO("Play mode stopped");}));+ eventConnections_.add(sink(toolbar->onWebPreview).connect([this, toolbar]() {+ if (toolbar->isWebPreviewRunning()) {+ toolbar->stopWebPreview();+ ES_LOG_INFO("Web preview stopped");+ } else {+ std::string webBuildDir = projectManager_->getWebBuildPath();+ std::string sdkPath = findWebSDKPath();++ if (sdkPath.empty()) {+ ES_LOG_ERROR("Web SDK not found. Please set ESENGINE_WEB_SDK environment variable.");+ return;+ }++ ES_LOG_INFO("Building and exporting project for web preview...");++ std::string projectPath = projectManager_->getCurrentProject().rootDirectory;+ bool success = WebExporter::exportProject(+ projectPath,+ sdkPath,+ webBuildDir,+ [](const std::string& status, f32 progress) {+ ES_LOG_INFO("[{:.0f}%] {}", progress * 100.0f, status);+ }+ );++ if (!success) {+ ES_LOG_ERROR("Failed to export web build");+ return;+ }++ toolbar->startWebPreview(webBuildDir);+ }+ }));+uiContext_->setRoot(std::move(editorRoot));ES_LOG_INFO("Editor layout initialized with StatusBar and Drawer system");@@ -646,5 +698,42 @@ void EditorApplication::dockAssetBrowser() {ES_LOG_INFO("AssetBrowser docked successfully");}+std::string EditorApplication::findWebSDKPath() {+ namespace fs = std::filesystem;++ // 1. Check environment variable+ if (const char* envPath = std::getenv("ESENGINE_WEB_SDK")) {+ if (fs::exists(envPath) && fs::exists(fs::path(envPath) / "esengine.wasm")) {+ ES_LOG_DEBUG("Found Web SDK via ESENGINE_WEB_SDK: {}", envPath);+ return envPath;+ }+ }++ // 2. Check relative to editor root (for development)+ std::string editorDir = PathResolver::editorPath("");+ std::vector<std::string> searchPaths = {+ editorDir + "/build-web/sdk", // F:\microes\build-web\sdk+ editorDir + "/../build-web/sdk", // One level up+ editorDir + "/../../build-web/sdk", // Two levels up (if running from bin/)+ editorDir + "/sdk/web",+ editorDir + "/web-sdk"+ };++ for (const auto& path : searchPaths) {+ fs::path sdkPath = fs::weakly_canonical(path);+ if (fs::exists(sdkPath) && fs::exists(sdkPath / "esengine.wasm")) {+ ES_LOG_DEBUG("Found Web SDK at: {}", sdkPath.string());+ return sdkPath.string();+ }+ }++ ES_LOG_WARN("Web SDK not found. Searched paths:");+ for (const auto& path : searchPaths) {+ ES_LOG_WARN(" - {}", path);+ }++ return "";+}+} // namespace editor} // namespace esenginediff --git a/src/esengine/editor/EditorApplication.hpp b/src/esengine/editor/EditorApplication.hppindex 73bb04aa9..02d17fe69 100644--- a/src/esengine/editor/EditorApplication.hpp+++ b/src/esengine/editor/EditorApplication.hpp@@ -257,6 +257,12 @@ private:*/void dockAssetBrowser();+ /**+ * @brief Find the web SDK path+ * @return Path to web SDK directory, or empty string if not found+ */+ std::string findWebSDKPath();+// =========================================================================// Constants// =========================================================================diff --git a/src/esengine/editor/panels/InspectorPanel.cpp b/src/esengine/editor/panels/InspectorPanel.cppindex d50e030c0..83ccdfde9 100644--- a/src/esengine/editor/panels/InspectorPanel.cpp+++ b/src/esengine/editor/panels/InspectorPanel.cpp@@ -24,9 +24,7 @@#include "../../ui/widgets/ClickablePanel.hpp"#include "../../ui/rendering/UIBatchRenderer.hpp"-#if ES_FEATURE_SDF_FONT-#include "../../ui/font/MSDFFont.hpp"-#endif+#include "../../ui/font/SystemFont.hpp"namespace esengine::editor {diff --git a/src/esengine/editor/preview/WebExporter.cpp b/src/esengine/editor/preview/WebExporter.cppnew file mode 100644index 000000000..e7313e963--- /dev/null+++ b/src/esengine/editor/preview/WebExporter.cpp@@ -0,0 +1,361 @@+/**+ * @file WebExporter.cpp+ * @brief Web build exporter implementation+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the MIT License.+ */++#include "WebExporter.hpp"+#include "../../core/Log.hpp"++#include <cstdlib>+#include <filesystem>+#include <fstream>+#include <sstream>++namespace fs = std::filesystem;++namespace esengine::editor {++bool WebExporter::exportProject(+ const std::string& projectPath,+ const std::string& sdkPath,+ const std::string& outputPath,+ ProgressCallback callback+) {+ ES_LOG_INFO("Exporting project to web: {}", outputPath);++ if (callback) callback("Creating output directory...", 0.0f);++ try {+ fs::create_directories(outputPath);+ } catch (const std::exception& e) {+ ES_LOG_ERROR("Failed to create output directory: {}", e.what());+ return false;+ }++ if (callback) callback("Checking dependencies...", 0.05f);+ if (!ensureDependencies(projectPath, callback)) {+ return false;+ }++ if (callback) callback("Compiling TypeScript...", 0.15f);+ if (!compileTypeScript(projectPath, callback)) {+ return false;+ }++ if (callback) callback("Copying SDK files...", 0.35f);+ if (!copySDKFiles(sdkPath, outputPath, callback)) {+ return false;+ }++ if (callback) callback("Copying assets...", 0.5f);+ if (!copyAssets(projectPath, outputPath, callback)) {+ return false;+ }++ if (callback) callback("Copying user scripts...", 0.7f);+ if (!copyUserScripts(projectPath, outputPath, callback)) {+ return false;+ }++ if (callback) callback("Generating index.html...", 0.9f);+ std::string projectName = fs::path(projectPath).filename().string();+ if (!generateIndexHtml(outputPath, projectName)) {+ return false;+ }++ if (callback) callback("Export complete!", 1.0f);+ ES_LOG_INFO("Web export completed successfully");+ return true;+}++bool WebExporter::ensureDependencies(const std::string& projectPath, ProgressCallback& callback) {+ fs::path nodeModules = fs::path(projectPath) / "node_modules";+ fs::path packageJson = fs::path(projectPath) / "package.json";+ fs::path packageLock = fs::path(projectPath) / "package-lock.json";++ // Check if package.json exists+ if (!fs::exists(packageJson)) {+ ES_LOG_ERROR("No package.json found in project. Please create project files first.");+ return false;+ }++ bool needsInstall = false;++ // Check if node_modules/esengine exists+ fs::path esengineModule = nodeModules / "esengine";+ if (!fs::exists(esengineModule)) {+ needsInstall = true;+ } else {+ // Check if package.json is newer than package-lock.json (SDK path may have changed)+ if (fs::exists(packageLock)) {+ auto pkgTime = fs::last_write_time(packageJson);+ auto lockTime = fs::last_write_time(packageLock);+ if (pkgTime > lockTime) {+ ES_LOG_INFO("package.json updated, reinstalling dependencies...");+ needsInstall = true;+ }+ }+ }++ if (!needsInstall) {+ ES_LOG_DEBUG("Dependencies already installed");+ return true;+ }++ // Install dependencies+ ES_LOG_INFO("Installing dependencies (npm install)...");+ if (callback) callback("Installing npm dependencies...", 0.08f);++#ifdef _WIN32+ std::string cmd = "cd /d \"" + projectPath + "\" && npm install";+#else+ std::string cmd = "cd \"" + projectPath + "\" && npm install";+#endif++ int result = std::system(cmd.c_str());++ if (result != 0) {+ ES_LOG_ERROR("npm install failed (exit code: {}). Please run 'npm install' manually in the project directory.", result);+ return false;+ }++ ES_LOG_INFO("Dependencies installed successfully");+ return true;+}++bool WebExporter::compileTypeScript(const std::string& projectPath, ProgressCallback& callback) {+ fs::path srcDir = fs::path(projectPath) / "src";+ fs::path buildDir = fs::path(projectPath) / "build" / "js";+ fs::path mainTs = srcDir / "main.ts";+ fs::path mainJs = buildDir / "main.js";++ // Check if source exists+ if (!fs::exists(mainTs)) {+ ES_LOG_ERROR("No src/main.ts found in project");+ return false;+ }++ // Create build directory if needed+ if (!fs::exists(buildDir)) {+ fs::create_directories(buildDir);+ }++ // Check if already compiled and up to date+ if (fs::exists(mainJs)) {+ auto srcTime = fs::last_write_time(mainTs);+ auto jsTime = fs::last_write_time(mainJs);+ if (jsTime >= srcTime) {+ ES_LOG_DEBUG("TypeScript already compiled and up to date");+ return true;+ }+ }++ // Run esbuild to bundle and compile+ ES_LOG_INFO("Bundling TypeScript with esbuild...");++#ifdef _WIN32+ std::string cmd = "cd /d \"" + projectPath + "\" && npm run build";+#else+ std::string cmd = "cd \"" + projectPath + "\" && npm run build";+#endif++ int result = std::system(cmd.c_str());++ if (result != 0) {+ ES_LOG_ERROR("Build failed (exit code: {})", result);+ return false;+ }++ if (!fs::exists(mainJs)) {+ ES_LOG_ERROR("Build did not produce build/js/main.js");+ return false;+ }++ ES_LOG_INFO("Build completed successfully");+ return true;+}++bool WebExporter::copyUserScripts(const std::string& projectPath, const std::string& outputPath, ProgressCallback& callback) {+ fs::path srcScripts = fs::path(projectPath) / "build" / "js";+ fs::path dstScripts = fs::path(outputPath) / "scripts";++ if (!fs::exists(srcScripts)) {+ ES_LOG_ERROR("Compiled scripts not found at {}", srcScripts.string());+ return false;+ }++ try {+ if (fs::exists(dstScripts)) {+ fs::remove_all(dstScripts);+ }+ fs::copy(srcScripts, dstScripts, fs::copy_options::recursive | fs::copy_options::overwrite_existing);+ ES_LOG_DEBUG("Copied user scripts to {}", dstScripts.string());+ } catch (const std::exception& e) {+ ES_LOG_ERROR("Failed to copy user scripts: {}", e.what());+ return false;+ }++ return true;+}++bool WebExporter::copySDKFiles(const std::string& sdkPath, const std::string& outputPath, ProgressCallback& callback) {+ const char* sdkFiles[] = {+ "esengine.js",+ "esengine.wasm",+ "esengine.d.ts"+ };++ for (const char* file : sdkFiles) {+ fs::path src = fs::path(sdkPath) / file;+ fs::path dst = fs::path(outputPath) / file;++ if (!fs::exists(src)) {+ if (std::string(file) == "esengine.d.ts") {+ continue;+ }+ ES_LOG_ERROR("SDK file not found: {}", src.string());+ return false;+ }++ try {+ fs::copy_file(src, dst, fs::copy_options::overwrite_existing);+ ES_LOG_DEBUG("Copied: {}", file);+ } catch (const std::exception& e) {+ ES_LOG_ERROR("Failed to copy {}: {}", file, e.what());+ return false;+ }+ }++ return true;+}++bool WebExporter::copyAssets(const std::string& projectPath, const std::string& outputPath, ProgressCallback& callback) {+ fs::path srcAssets = fs::path(projectPath) / "assets";+ fs::path dstAssets = fs::path(outputPath) / "assets";++ if (!fs::exists(srcAssets)) {+ ES_LOG_WARN("No assets directory found in project");+ return true;+ }++ try {+ if (fs::exists(dstAssets)) {+ fs::remove_all(dstAssets);+ }+ fs::copy(srcAssets, dstAssets, fs::copy_options::recursive | fs::copy_options::overwrite_existing);+ ES_LOG_DEBUG("Copied assets directory");+ } catch (const std::exception& e) {+ ES_LOG_ERROR("Failed to copy assets: {}", e.what());+ return false;+ }++ return true;+}++bool WebExporter::generateIndexHtml(const std::string& outputPath, const std::string& projectName) {+ std::ostringstream html;+ html << R"(<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">+ <title>)" << projectName << R"(</title>+ <style>+ * { margin: 0; padding: 0; box-sizing: border-box; }+ html, body {+ width: 100%;+ height: 100%;+ overflow: hidden;+ background-color: #1a1a1a;+ }+ #canvas {+ display: block;+ width: 100%;+ height: 100%;+ touch-action: none;+ }+ #loading {+ position: absolute;+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+ color: #fff;+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;+ font-size: 16px;+ text-align: center;+ }+ #loading.hidden { display: none; }+ .spinner {+ width: 40px;+ height: 40px;+ margin: 0 auto 16px;+ border: 3px solid #333;+ border-top-color: #3b82f6;+ border-radius: 50%;+ animation: spin 1s linear infinite;+ }+ @keyframes spin { to { transform: rotate(360deg); } }+ </style>+</head>+<body>+ <div id="loading">+ <div class="spinner"></div>+ <div>Loading...</div>+ </div>+ <canvas id="canvas"></canvas>++ <script type="module">+ import ESEngineModule from './esengine.js';+ import { main } from './scripts/main.js';++ function resizeCanvas() {+ const canvas = document.getElementById('canvas');+ const dpr = window.devicePixelRatio || 1;+ canvas.width = window.innerWidth * dpr;+ canvas.height = window.innerHeight * dpr;+ }+ window.addEventListener('resize', resizeCanvas);+ resizeCanvas();++ ESEngineModule({+ canvas: document.getElementById('canvas'),+ print: (text) => console.log(text),+ printErr: (text) => console.error(text)+ }).then((Module) => {+ console.log('ESEngine loaded');+ document.getElementById('loading').classList.add('hidden');+ main(Module);+ }).catch((err) => {+ if (err === 'unwind' || (err.message && err.message.includes('unwind'))) {+ console.log('App running');+ return;+ }+ console.error('Failed:', err);+ document.getElementById('loading').innerHTML = '<div style="color:#f87171">Error: ' + err.message + '</div>';+ });+ </script>+</body>+</html>+)";++ fs::path indexPath = fs::path(outputPath) / "index.html";+ std::ofstream file(indexPath);+ if (!file) {+ ES_LOG_ERROR("Failed to create index.html");+ return false;+ }++ file << html.str();+ file.close();++ ES_LOG_DEBUG("Generated index.html");+ return true;+}++} // namespace esengine::editordiff --git a/src/esengine/editor/preview/WebExporter.hpp b/src/esengine/editor/preview/WebExporter.hppnew file mode 100644index 000000000..ea1a3d223--- /dev/null+++ b/src/esengine/editor/preview/WebExporter.hpp@@ -0,0 +1,50 @@+/**+ * @file WebExporter.hpp+ * @brief Web build exporter for game projects+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the MIT License.+ */+#pragma once++#include "../../core/Types.hpp"+#include <string>+#include <functional>++namespace esengine::editor {++/**+ * @brief Exports game project to web-ready format+ */+class WebExporter {+public:+ using ProgressCallback = std::function<void(const std::string& status, f32 progress)>;++ /**+ * @brief Export project to web format+ * @param projectPath Root directory of the game project+ * @param sdkPath Path to the prebuilt web SDK (build-web/sdk)+ * @param outputPath Output directory (usually project/build/web)+ * @param callback Optional progress callback+ * @return true if export succeeded+ */+ static bool exportProject(+ const std::string& projectPath,+ const std::string& sdkPath,+ const std::string& outputPath,+ ProgressCallback callback = nullptr+ );++private:+ static bool ensureDependencies(const std::string& projectPath, ProgressCallback& callback);+ static bool compileTypeScript(const std::string& projectPath, ProgressCallback& callback);+ static bool copySDKFiles(const std::string& sdkPath, const std::string& outputPath, ProgressCallback& callback);+ static bool copyAssets(const std::string& projectPath, const std::string& outputPath, ProgressCallback& callback);+ static bool copyUserScripts(const std::string& projectPath, const std::string& outputPath, ProgressCallback& callback);+ static bool generateIndexHtml(const std::string& outputPath, const std::string& projectName);+};++} // namespace esengine::editordiff --git a/src/esengine/editor/project/ProjectManager.cpp b/src/esengine/editor/project/ProjectManager.cppindex abf899798..e1d7d0877 100644--- a/src/esengine/editor/project/ProjectManager.cpp+++ b/src/esengine/editor/project/ProjectManager.cpp@@ -18,6 +18,7 @@#include "../../platform/PathResolver.hpp"#include "../../core/Log.hpp"+#include <algorithm>#include <chrono>namespace esengine::editor {@@ -142,6 +143,8 @@ Result<bool> ProjectManager::openProject(const std::string& projectFilePath) {fireProjectOpenedEvent();+ checkAndSyncDependencies();+ES_LOG_INFO("ProjectManager: Project '{}' opened successfully", current_project_.name);return Result<bool>::ok(true);@@ -206,6 +209,17 @@ void ProjectManager::updateSettings(const ProjectSettings& settings) {fireProjectSettingsChangedEvent();}+// =============================================================================+// Build Paths+// =============================================================================++std::string ProjectManager::getWebBuildPath() const {+ if (!has_open_project_) {+ return "";+ }+ return current_project_.rootDirectory + "/build/web";+}+// =============================================================================// Recent Projects// =============================================================================@@ -224,20 +238,138 @@ const RecentProjectsManager& ProjectManager::getRecentProjects() const {void ProjectManager::createDirectoryStructure(const std::string& rootDir) {const std::vector<std::string> directories = {- "/assets",+ "/src", // User source code+ "/assets", // Resources only"/assets/scenes",- "/assets/scripts","/assets/textures","/assets/audio","/assets/fonts","/assets/prefabs","/assets/shaders",- "/.esengine"+ "/build", // Build output (should be gitignored)+ "/.esengine" // Editor cache (should be gitignored)};for (const auto& dir : directories) {FileSystem::createDirectory(rootDir + dir);}++ createProjectFiles(rootDir);+ createGitignore(rootDir);+}++void ProjectManager::createProjectFiles(const std::string& rootDir) {+ std::string sdkDir = PathResolver::editorPath("bindings");+ // Convert backslashes to forward slashes for JSON/npm compatibility+ std::replace(sdkDir.begin(), sdkDir.end(), '\\', '/');++ // Generate package.json in project root+ std::string packageJson = R"({+ "name": ")" + current_project_.name + R"(",+ "version": "1.0.0",+ "type": "module",+ "scripts": {+ "build": "npx esbuild src/main.ts --bundle --format=esm --outfile=build/js/main.js --sourcemap",+ "dev": "npx esbuild src/main.ts --bundle --format=esm --outfile=build/js/main.js --sourcemap --watch",+ "typecheck": "npx tsc --noEmit"+ },+ "dependencies": {+ "esengine": "file:)" + sdkDir + R"("+ },+ "devDependencies": {+ "esbuild": "^0.20.0",+ "typescript": "^5.0.0"+ }+}+)";+ FileSystem::writeTextFile(rootDir + "/package.json", packageJson);+ ES_LOG_DEBUG("Created package.json");++ // Generate tsconfig.json in project root (for type checking and IDE support)+ std::string tsconfig = R"({+ "compilerOptions": {+ "target": "ES2020",+ "module": "ESNext",+ "lib": ["ES2020", "DOM"],+ "moduleResolution": "node",+ "strict": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "noEmit": true+ },+ "include": ["src/**/*.ts"],+ "exclude": ["node_modules", "build"]+}+)";+ FileSystem::writeTextFile(rootDir + "/tsconfig.json", tsconfig);+ ES_LOG_DEBUG("Created tsconfig.json");++ // Create main.ts in src/ directory+ std::string mainScript = R"(/**+ * @file main.ts+ * @brief Game entry point+ */++import { App, StartupSystem, LocalTransform, Sprite } from 'esengine';++class SetupSystem extends StartupSystem {+ onStart(): void {+ // Create a simple sprite entity+ this.world_.spawn()+ .with(LocalTransform, {+ position: { x: 400, y: 300, z: 0 }+ })+ .with(Sprite, {+ color: { x: 1, y: 1, z: 1, w: 1 },+ size: { x: 64, y: 64 }+ });++ console.log('Game started!');+ }+}++/**+ * Game entry point - called by the engine after WASM is loaded+ */+export function main(module: any): void {+ const app = new App(module, {+ title: ')" + current_project_.name + R"(',+ width: 800,+ height: 600+ });++ app.addStartupSystem(new SetupSystem());+ app.run();+}+)";+ FileSystem::writeTextFile(rootDir + "/src/main.ts", mainScript);+ ES_LOG_DEBUG("Created src/main.ts");+}++void ProjectManager::createGitignore(const std::string& rootDir) {+ std::string gitignore = R"(# Dependencies+node_modules/++# Build output+build/+dist/++# Editor cache+.esengine/++# IDE+.vscode/+.idea/+*.swp+*.swo++# OS+.DS_Store+Thumbs.db+)";+ FileSystem::writeTextFile(rootDir + "/.gitignore", gitignore);+ ES_LOG_DEBUG("Created .gitignore");}void ProjectManager::updatePathResolver(const std::string& rootDir) {@@ -246,8 +378,7 @@ void ProjectManager::updatePathResolver(const std::string& rootDir) {}void ProjectManager::initializeAssetDatabase(const std::string& rootDir) {- std::string assetsPath = rootDir + "/assets";- asset_database_.setProjectPath(assetsPath);+ asset_database_.setProjectPath(rootDir);asset_database_.scan();}@@ -280,4 +411,55 @@ u64 ProjectManager::getCurrentTimestamp() {std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count());}+void ProjectManager::checkAndSyncDependencies() {+ std::string rootDir = current_project_.rootDirectory;+ std::string packageJsonPath = rootDir + "/package.json";+ std::string nodeModulesPath = rootDir + "/node_modules";+ std::string esengineModulePath = nodeModulesPath + "/esengine";++ // Check if package.json exists+ if (!FileSystem::fileExists(packageJsonPath)) {+ ES_LOG_INFO("No package.json found, creating project files...");+ createProjectFiles(rootDir);+ return;+ }++ // Check if node_modules/esengine exists+ if (!FileSystem::directoryExists(esengineModulePath)) {+ ES_LOG_WARN("Dependencies not installed. Please run 'npm install' in {}", rootDir);+ }++ // Update package.json with current SDK path (in case engine location changed)+ std::string sdkDir = PathResolver::editorPath("bindings");+ // Convert backslashes to forward slashes for JSON/npm compatibility+ std::replace(sdkDir.begin(), sdkDir.end(), '\\', '/');+ std::string currentPackageJson = FileSystem::readTextFile(packageJsonPath);++ // Check if SDK path needs updating+ if (currentPackageJson.find(sdkDir) == std::string::npos) {+ ES_LOG_INFO("Updating package.json with current SDK path...");++ std::string packageJson = R"({+ "name": ")" + current_project_.name + R"(",+ "version": "1.0.0",+ "type": "module",+ "scripts": {+ "build": "npx esbuild src/main.ts --bundle --format=esm --outfile=build/js/main.js --sourcemap",+ "dev": "npx esbuild src/main.ts --bundle --format=esm --outfile=build/js/main.js --sourcemap --watch",+ "typecheck": "npx tsc --noEmit"+ },+ "dependencies": {+ "esengine": "file:)" + sdkDir + R"("+ },+ "devDependencies": {+ "esbuild": "^0.20.0",+ "typescript": "^5.0.0"+ }+}+)";+ FileSystem::writeTextFile(packageJsonPath, packageJson);+ ES_LOG_INFO("package.json updated. Please run 'npm install' to update dependencies.");+ }+}+} // namespace esengine::editordiff --git a/src/esengine/editor/project/ProjectManager.hpp b/src/esengine/editor/project/ProjectManager.hppindex 5857fb138..6781766ff 100644--- a/src/esengine/editor/project/ProjectManager.hpp+++ b/src/esengine/editor/project/ProjectManager.hpp@@ -66,6 +66,12 @@ public:void saveProjectSettings();void updateSettings(const ProjectSettings& settings);+ // =========================================================================+ // Build Paths+ // =========================================================================++ [[nodiscard]] std::string getWebBuildPath() const;+// =========================================================================// Recent Projects// =========================================================================@@ -75,6 +81,9 @@ public:private:void createDirectoryStructure(const std::string& rootDir);+ void createProjectFiles(const std::string& rootDir);+ void createGitignore(const std::string& rootDir);+ void checkAndSyncDependencies();void updatePathResolver(const std::string& rootDir);void initializeAssetDatabase(const std::string& rootDir);void fireProjectOpenedEvent();diff --git a/src/esengine/editor/widgets/EditorToolbar.cpp b/src/esengine/editor/widgets/EditorToolbar.cppindex 03a012299..e8fe94763 100644--- a/src/esengine/editor/widgets/EditorToolbar.cpp+++ b/src/esengine/editor/widgets/EditorToolbar.cpp@@ -61,7 +61,6 @@ void EditorToolbar::startWebPreview(const std::string& directory) {}if (previewServer_.start(directory)) {WebPreviewServer::openInBrowser(previewServer_.getUrl());- onWebPreview.publish();}}diff --git a/src/esengine/editor/widgets/EditorToolbar.hpp b/src/esengine/editor/widgets/EditorToolbar.hppindex a877398a8..f27dea008 100644--- a/src/esengine/editor/widgets/EditorToolbar.hpp+++ b/src/esengine/editor/widgets/EditorToolbar.hpp@@ -16,6 +16,7 @@#include "../../ui/widgets/Widget.hpp"#include "../../events/Signal.hpp"+#include "../preview/WebPreviewServer.hpp"namespace esengine::editor {@@ -56,6 +57,11 @@ public:Signal<void()> onPlay;Signal<void()> onPause;Signal<void()> onStop;+ Signal<void()> onWebPreview;++ void startWebPreview(const std::string& directory);+ void stopWebPreview();+ bool isWebPreviewRunning() const { return previewServer_.isRunning(); }glm::vec2 measure(f32 availableWidth, f32 availableHeight) override;void render(ui::UIBatchRenderer& renderer) override;@@ -75,6 +81,9 @@ private:ButtonState playButton_;ButtonState pauseButton_;ButtonState stopButton_;+ ButtonState webPreviewButton_;++ WebPreviewServer previewServer_;};} // namespace esengine::editordiff --git a/src/esengine/renderer/Texture.cpp b/src/esengine/renderer/Texture.cppindex 962ee58ae..cbce81dad 100644--- a/src/esengine/renderer/Texture.cpp+++ b/src/esengine/renderer/Texture.cpp@@ -15,7 +15,10 @@#include "OpenGLHeaders.hpp"#include <span>++#ifndef ES_PLATFORM_WEB#include <stb_image.h>+#endifnamespace esengine {@@ -130,9 +133,9 @@ Unique<Texture> Texture::createRaw(u32 width, u32 height, const void* data, Textreturn texture;}+#ifndef ES_PLATFORM_WEBUnique<Texture> Texture::createFromFile(const std::string& path) {- // Load image using stb_image- stbi_set_flip_vertically_on_load(true); // OpenGL expects bottom-to-top+ stbi_set_flip_vertically_on_load(true);int width, height, channels;unsigned char* data = stbi_load(path.c_str(), &width, &height, &channels, 0);@@ -142,7 +145,6 @@ Unique<Texture> Texture::createFromFile(const std::string& path) {return nullptr;}- // Determine format based on channelsTextureFormat format = TextureFormat::RGBA8;if (channels == 3) {format = TextureFormat::RGB8;@@ -152,7 +154,6 @@ Unique<Texture> Texture::createFromFile(const std::string& path) {ES_LOG_WARN("Unsupported texture format ({} channels), converting to RGBA", channels);stbi_image_free(data);- // Reload with forced RGBAdata = stbi_load(path.c_str(), &width, &height, &channels, 4);if (!data) {ES_LOG_ERROR("Failed to convert texture to RGBA: {}", path);@@ -161,10 +162,7 @@ Unique<Texture> Texture::createFromFile(const std::string& path) {format = TextureFormat::RGBA8;}- // Create texture from loaded dataauto texture = createRaw(static_cast<u32>(width), static_cast<u32>(height), data, format);-- // Free image datastbi_image_free(data);if (texture) {@@ -173,6 +171,7 @@ Unique<Texture> Texture::createFromFile(const std::string& path) {return texture;}+#endifbool Texture::initialize(const TextureSpecification& spec) {width_ = spec.width;diff --git a/src/esengine/renderer/Texture.hpp b/src/esengine/renderer/Texture.hppindex b5da5012a..4a5cd2a52 100644--- a/src/esengine/renderer/Texture.hpp+++ b/src/esengine/renderer/Texture.hpp@@ -176,7 +176,9 @@ public:** @note Supported formats depend on the image loading implementation.*/+#ifndef ES_PLATFORM_WEBstatic Unique<Texture> createFromFile(const std::string& path);+#endif// =========================================================================// Operationsdiff --git a/src/esengine/resource/ResourceManager.cpp b/src/esengine/resource/ResourceManager.cppindex dfa45ae42..110da4251 100644--- a/src/esengine/resource/ResourceManager.cpp+++ b/src/esengine/resource/ResourceManager.cpp@@ -165,7 +165,6 @@ TextureHandle ResourceManager::createTexture(u32 width, u32 height, ConstSpan<u8}TextureHandle ResourceManager::loadTexture(const std::string& path) {- // Check cacheauto cached = textures_.findByPath(path);if (cached.isValid()) {textures_.addRef(cached);@@ -173,7 +172,11 @@ TextureHandle ResourceManager::loadTexture(const std::string& path) {return cached;}- // Load from file+#ifdef ES_PLATFORM_WEB+ ES_LOG_ERROR("loadTexture from file not supported on Web, use createTexture with pixel data");+ stats_.cacheMisses++;+ return TextureHandle();+#elseauto texture = Texture::createFromFile(path);if (!texture) {stats_.cacheMisses++;@@ -182,6 +185,7 @@ TextureHandle ResourceManager::loadTexture(const std::string& path) {stats_.cacheMisses++;return textures_.add(std::move(texture), path);+#endif}Texture* ResourceManager::getTexture(TextureHandle handle) {diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex e354c3607..bf2a02a9c 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -14,7 +14,6 @@#include <sstream>#include <algorithm>-#include <regex>namespace esengine::resource {@@ -244,14 +243,26 @@ void ShaderParser::parseDirective(const std::string& line,ShaderProperty ShaderParser::parsePropertyAnnotation(const std::string& line) {ShaderProperty prop;- std::regex uniformRegex(R"(uniform\s+(\w+)\s+(\w+)\s*;)");- std::smatch match;- if (!std::regex_search(line, match, uniformRegex)) {+ usize uniformPos = line.find("uniform");+ if (uniformPos == std::string::npos) {return prop;}- std::string glslType = match[1].str();- prop.name = match[2].str();+ std::string afterUniform = trim(line.substr(uniformPos + 7));+ usize spacePos = afterUniform.find_first_of(" \t");+ if (spacePos == std::string::npos) {+ return prop;+ }++ std::string glslType = afterUniform.substr(0, spacePos);+ std::string rest = trim(afterUniform.substr(spacePos));++ usize semicolonPos = rest.find(';');+ if (semicolonPos == std::string::npos) {+ return prop;+ }++ prop.name = trim(rest.substr(0, semicolonPos));if (glslType == "float") {prop.type = ShaderPropertyType::Float;@@ -269,29 +280,52 @@ ShaderProperty ShaderParser::parsePropertyAnnotation(const std::string& line) {prop.type = ShaderPropertyType::Unknown;}- std::regex annotationRegex(R"(@property\s*\(([^)]*)\))");- if (std::regex_search(line, match, annotationRegex)) {- std::string params = match[1].str();-- std::regex typeRegex(R"(type\s*=\s*(\w+))");- if (std::regex_search(params, match, typeRegex)) {- prop.type = stringToPropertyType(match[1].str());- }+ usize propStart = line.find("@property");+ if (propStart != std::string::npos) {+ usize parenStart = line.find('(', propStart);+ usize parenEnd = line.find(')', parenStart);+ if (parenStart != std::string::npos && parenEnd != std::string::npos) {+ std::string params = line.substr(parenStart + 1, parenEnd - parenStart - 1);++ usize typePos = params.find("type");+ if (typePos != std::string::npos) {+ usize eqPos = params.find('=', typePos);+ if (eqPos != std::string::npos) {+ usize valStart = params.find_first_not_of(" \t", eqPos + 1);+ usize valEnd = params.find_first_of(" \t,)", valStart);+ if (valStart != std::string::npos) {+ std::string typeVal = params.substr(valStart, valEnd - valStart);+ prop.type = stringToPropertyType(typeVal);+ }+ }+ }- std::regex defaultRegex(R"(default\s*=\s*([^,)]+))");- if (std::regex_search(params, match, defaultRegex)) {- prop.defaultValue = trim(match[1].str());- }+ usize defaultPos = params.find("default");+ if (defaultPos != std::string::npos) {+ usize eqPos = params.find('=', defaultPos);+ if (eqPos != std::string::npos) {+ usize valStart = params.find_first_not_of(" \t", eqPos + 1);+ usize valEnd = params.find_first_of(",)", valStart);+ if (valStart != std::string::npos) {+ prop.defaultValue = trim(params.substr(valStart, valEnd - valStart));+ }+ }+ }- std::regex nameRegex(R"regex(name\s*=\s*"([^"]+)")regex");- if (std::regex_search(params, match, nameRegex)) {- prop.displayName = match[1].str();+ usize namePos = params.find("name");+ if (namePos != std::string::npos) {+ usize quoteStart = params.find('"', namePos);+ usize quoteEnd = params.find('"', quoteStart + 1);+ if (quoteStart != std::string::npos && quoteEnd != std::string::npos) {+ prop.displayName = params.substr(quoteStart + 1, quoteEnd - quoteStart - 1);+ }+ }}}if (prop.displayName.empty()) {prop.displayName = prop.name;- if (prop.displayName.substr(0, 2) == "u_") {+ if (prop.displayName.size() > 2 && prop.displayName.substr(0, 2) == "u_") {prop.displayName = prop.displayName.substr(2);}if (!prop.displayName.empty()) {diff --git a/src/esengine/ui/UIContext.cpp b/src/esengine/ui/UIContext.cppindex 9f5cf39ae..90573cf0b 100644--- a/src/esengine/ui/UIContext.cpp+++ b/src/esengine/ui/UIContext.cpp@@ -26,6 +26,8 @@#include "font/BitmapFont.hpp"#endif+#include "font/SystemFont.hpp"+#include <glm/gtc/matrix_transform.hpp>#include <algorithm>@@ -72,6 +74,7 @@ void UIContext::shutdown() {#if ES_FEATURE_BITMAP_FONTbitmapFonts_.clear();#endif+ systemFonts_.clear();theme_.reset();if (renderer_) {@@ -219,6 +222,60 @@ BitmapFont* UIContext::getDefaultBitmapFont() {}#endif // ES_FEATURE_BITMAP_FONT+// =============================================================================+// System Font+// =============================================================================++SystemFont* UIContext::createSystemFont(const std::string& name, const std::string& fontFamily,+ f32 fontSize) {+ auto font = SystemFont::create(fontFamily, fontSize);+ if (!font) {+ ES_LOG_ERROR("Failed to create system font: {}", fontFamily);+ return nullptr;+ }++ font->preloadASCII();++ SystemFont* ptr = font.get();+ systemFonts_[name] = std::move(font);++ ES_LOG_INFO("Created system font '{}' with family '{}'", name, fontFamily);+ return ptr;+}++SystemFont* UIContext::createSystemFontFromFile(const std::string& name, const std::string& filePath,+ f32 fontSize) {+ auto font = SystemFont::createFromFile(filePath, fontSize);+ if (!font) {+ ES_LOG_ERROR("Failed to create font from file: {}", filePath);+ return nullptr;+ }++ font->preloadASCII();++ SystemFont* ptr = font.get();+ systemFonts_[name] = std::move(font);++ ES_LOG_INFO("Created font '{}' from file '{}'", name, filePath);+ return ptr;+}++SystemFont* UIContext::getSystemFont(const std::string& name) {+ auto it = systemFonts_.find(name);+ if (it != systemFonts_.end()) {+ return it->second.get();+ }+ return nullptr;+}++SystemFont* UIContext::getDefaultSystemFont() {+ return getSystemFont(defaultFontName_);+}++SystemFont* UIContext::getIconSystemFont() {+ return getSystemFont("icons");+}+// =============================================================================// Update and Render// =============================================================================diff --git a/src/esengine/ui/UIContext.hpp b/src/esengine/ui/UIContext.hppindex 27e00da16..1468d79f4 100644--- a/src/esengine/ui/UIContext.hpp+++ b/src/esengine/ui/UIContext.hpp@@ -43,6 +43,7 @@ class MSDFFont;class BitmapFont;#endif+class SystemFont;class UIBatchRenderer;class Widget;@@ -184,6 +185,30 @@ public:BitmapFont* getDefaultBitmapFont();#endif+ /**+ * @brief Creates a system font using OS native APIs+ * @param name Font identifier name+ * @param fontFamily System font family (e.g. "Microsoft YaHei", "Arial")+ * @param fontSize Font size in pixels+ * @return Pointer to created font or nullptr on failure+ */+ SystemFont* createSystemFont(const std::string& name, const std::string& fontFamily,+ f32 fontSize = 32.0f);++ /**+ * @brief Creates a font from a TTF file+ * @param name Font identifier name+ * @param filePath Path to TTF font file+ * @param fontSize Font size in pixels+ * @return Pointer to created font or nullptr on failure+ */+ SystemFont* createSystemFontFromFile(const std::string& name, const std::string& filePath,+ f32 fontSize = 32.0f);++ SystemFont* getSystemFont(const std::string& name);+ SystemFont* getDefaultSystemFont();+ SystemFont* getIconSystemFont();+void setDefaultFontName(const std::string& name) { defaultFontName_ = name; }// =========================================================================@@ -399,6 +424,8 @@ private:std::unordered_map<std::string, Unique<BitmapFont>> bitmapFonts_;#endif+ std::unordered_map<std::string, Unique<SystemFont>> systemFonts_;+std::string defaultFontName_ = "default";u32 viewportWidth_ = 0;diff --git a/src/esengine/ui/docking/DockTabBar.cpp b/src/esengine/ui/docking/DockTabBar.cppindex 170d68e7e..63fdb64b3 100644--- a/src/esengine/ui/docking/DockTabBar.cpp+++ b/src/esengine/ui/docking/DockTabBar.cpp@@ -24,6 +24,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+#include <cmath>namespace esengine::ui {@@ -188,6 +190,13 @@ void DockTabBar::renderTab(UIBatchRenderer& renderer, const DockTabInfo& tab, ustheme.typography.fontSizeSmall, textColor,HAlign::Left, VAlign::Center);}+#else+ SystemFont* font = ctx->getDefaultSystemFont();+ if (font) {+ renderer.drawTextInBounds(tab.title, textBounds, *font,+ theme.typography.fontSizeSmall, textColor,+ HAlign::Left, VAlign::Center);+ }#endifif (tab.closable) {diff --git a/src/esengine/ui/font/SystemFont.cpp b/src/esengine/ui/font/SystemFont.cppindex 7784061a2..0f19c3696 100644--- a/src/esengine/ui/font/SystemFont.cpp+++ b/src/esengine/ui/font/SystemFont.cpp@@ -12,6 +12,8 @@#include "SystemFont.hpp"#include "../../core/Log.hpp"+#include <algorithm>+#ifdef ES_PLATFORM_WINDOWS#define WIN32_LEAN_AND_MEAN#define NOMINMAX@@ -21,6 +23,29 @@#ifdef ES_PLATFORM_WEB#include <emscripten.h>#include <emscripten/html5.h>++EM_JS(void, es_systemfont_init, (const char* fontFamily, int fontSize), {+ if (!Module._systemFontCanvases) Module._systemFontCanvases = {};+ var id = Object.keys(Module._systemFontCanvases).length;+ var canvas = document.createElement('canvas');+ canvas.width = 256;+ canvas.height = 256;+ var ctx = canvas.getContext('2d');+ ctx.font = fontSize + 'px ' + UTF8ToString(fontFamily);+ ctx.textBaseline = 'top';+ ctx.fillStyle = 'white';+ Module._systemFontCanvases[id] = { canvas: canvas, ctx: ctx };+});++EM_JS(double, es_systemfont_measure_char, (int codepoint), {+ var canvasData = Module._systemFontCanvases[0];+ if (!canvasData) return 0;+ var ctx = canvasData.ctx;+ var char = String.fromCodePoint(codepoint);+ var metrics = ctx.measureText(char);+ return metrics.width;+});+#endif#ifndef ES_PLATFORM_WEB@@ -41,6 +66,7 @@ struct SystemFont::PlatformData {void* bitmapBits = nullptr;i32 bitmapWidth = 256;i32 bitmapHeight = 256;+ std::string fontFilePath;};#elif defined(ES_PLATFORM_WEB)struct SystemFont::PlatformData {@@ -60,6 +86,9 @@ SystemFont::~SystemFont() {if (platformData_->hFont) DeleteObject(platformData_->hFont);if (platformData_->hBitmap) DeleteObject(platformData_->hBitmap);if (platformData_->hdc) DeleteDC(platformData_->hdc);+ if (!platformData_->fontFilePath.empty()) {+ RemoveFontResourceExA(platformData_->fontFilePath.c_str(), FR_PRIVATE, nullptr);+ }}#endif@@ -127,6 +156,38 @@ Unique<SystemFont> SystemFont::create(const std::string& fontFamily, f32 fontSizreturn font;}+Unique<SystemFont> SystemFont::createFromFile(const std::string& filePath, f32 fontSize) {+#ifdef ES_PLATFORM_WINDOWS+ int result = AddFontResourceExA(filePath.c_str(), FR_PRIVATE, nullptr);+ if (result == 0) {+ ES_LOG_ERROR("SystemFont: Failed to load font file '{}'", filePath);+ return nullptr;+ }++ std::string fontName;+ size_t lastSlash = filePath.find_last_of("/\\");+ size_t lastDot = filePath.find_last_of('.');+ if (lastSlash != std::string::npos) {+ fontName = filePath.substr(lastSlash + 1, lastDot - lastSlash - 1);+ } else {+ fontName = filePath.substr(0, lastDot);+ }++ auto font = Unique<SystemFont>(new SystemFont());+ if (!font->init(fontName, fontSize)) {+ RemoveFontResourceExA(filePath.c_str(), FR_PRIVATE, nullptr);+ return nullptr;+ }++ font->platformData_->fontFilePath = filePath;+ ES_LOG_INFO("SystemFont: Loaded font from file '{}' as '{}'", filePath, fontName);+ return font;+#else+ ES_LOG_WARN("SystemFont::createFromFile not supported on this platform");+ return nullptr;+#endif+}+bool SystemFont::init(const std::string& fontFamily, f32 fontSize) {fontFamily_ = fontFamily;fontSize_ = fontSize;@@ -188,37 +249,19 @@ bool SystemFont::init(const std::string& fontFamily, f32 fontSize) {SetTextColor(platformData_->hdc, RGB(255, 255, 255));#elif defined(ES_PLATFORM_WEB)- EM_ASM({- if (!Module._systemFontCanvases) Module._systemFontCanvases = {};- var id = Object.keys(Module._systemFontCanvases).length;- var canvas = document.createElement('canvas');- canvas.width = 256;- canvas.height = 256;- var ctx = canvas.getContext('2d');- ctx.font = $1 + 'px ' + UTF8ToString($0);- ctx.textBaseline = 'top';- ctx.fillStyle = 'white';- Module._systemFontCanvases[id] = { canvas: canvas, ctx: ctx };-- var metrics = ctx.measureText('M');- Module._systemFontMetrics = {- ascent: metrics.actualBoundingBoxAscent || $1 * 0.8,- descent: metrics.actualBoundingBoxDescent || $1 * 0.2- };- }, fontFamily.c_str(), static_cast<int>(fontSize));-+ es_systemfont_init(fontFamily.c_str(), static_cast<int>(fontSize));ascent_ = fontSize * 0.8f;descent_ = fontSize * 0.2f;lineHeight_ = fontSize * 1.2f;#endif- atlasData_.resize(static_cast<size_t>(atlasWidth_) * atlasHeight_, 0);+ atlasData_.resize(static_cast<size_t>(atlasWidth_) * atlasHeight_ * 4, 0);#ifndef ES_PLATFORM_WEBglGenTextures(1, &atlasTextureId_);glBindTexture(GL_TEXTURE_2D, atlasTextureId_);- glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, atlasWidth_, atlasHeight_, 0,- GL_RED, GL_UNSIGNED_BYTE, atlasData_.data());+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, atlasWidth_, atlasHeight_, 0,+ GL_RGBA, GL_UNSIGNED_BYTE, atlasData_.data());glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);@@ -285,8 +328,15 @@ GlyphInfo* SystemFont::renderGlyph(u32 codepoint) {for (i32 y = 0; y < glyphHeight; ++y) {for (i32 x = 0; x < glyphWidth; ++x) {i32 srcIdx = (y * platformData_->bitmapWidth + x) * 4;- i32 dstIdx = (atlasY + y) * atlasWidth_ + (atlasX + x);- atlasData_[dstIdx] = src[srcIdx];+ i32 dstIdx = ((atlasY + y) * atlasWidth_ + (atlasX + x)) * 4;+ u8 r = src[srcIdx + 2];+ u8 g = src[srcIdx + 1];+ u8 b = src[srcIdx + 0];+ u8 a = std::max({r, g, b});+ atlasData_[dstIdx + 0] = 255;+ atlasData_[dstIdx + 1] = 255;+ atlasData_[dstIdx + 2] = 255;+ atlasData_[dstIdx + 3] = a;}}@@ -319,26 +369,13 @@ GlyphInfo* SystemFont::renderGlyph(u32 codepoint) {}}- f32 advance = EM_ASM_DOUBLE({- var canvasData = Module._systemFontCanvases[0];- if (!canvasData) return $4;-- var ctx = canvasData.ctx;- var canvas = canvasData.canvas;-- ctx.clearRect(0, 0, canvas.width, canvas.height);- var char = String.fromCodePoint($0);- ctx.fillText(char, 1, 1);-- var metrics = ctx.measureText(char);- return metrics.width;- }, codepoint, atlasX, atlasY, glyphWidth, fontSize_);+ f32 advance = static_cast<f32>(es_systemfont_measure_char(static_cast<int>(codepoint)));glyph.width = static_cast<f32>(glyphWidth);glyph.height = static_cast<f32>(glyphHeight);glyph.bearingX = 0;glyph.bearingY = ascent_;- glyph.advance = static_cast<f32>(advance);+ glyph.advance = advance;glyph.u0 = static_cast<f32>(atlasX) / atlasWidth_;glyph.v0 = static_cast<f32>(atlasY) / atlasHeight_;glyph.u1 = static_cast<f32>(atlasX + glyphWidth) / atlasWidth_;@@ -352,7 +389,7 @@ GlyphInfo* SystemFont::renderGlyph(u32 codepoint) {#ifndef ES_PLATFORM_WEBglBindTexture(GL_TEXTURE_2D, atlasTextureId_);glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, atlasWidth_, atlasHeight_,- GL_RED, GL_UNSIGNED_BYTE, atlasData_.data());+ GL_RGBA, GL_UNSIGNED_BYTE, atlasData_.data());#endifreturn &glyphs_[codepoint];diff --git a/src/esengine/ui/font/SystemFont.hpp b/src/esengine/ui/font/SystemFont.hppindex 9327fe0ed..3cd26bdb3 100644--- a/src/esengine/ui/font/SystemFont.hpp+++ b/src/esengine/ui/font/SystemFont.hpp@@ -40,6 +40,14 @@ public:*/static Unique<SystemFont> create(const std::string& fontFamily, f32 fontSize = 32.0f);+ /**+ * @brief Create a font from TTF file+ * @param filePath Path to TTF font file+ * @param fontSize Base font size in pixels+ * @return Font instance or nullptr on failure+ */+ static Unique<SystemFont> createFromFile(const std::string& filePath, f32 fontSize = 32.0f);+// =========================================================================// IFont Interface// =========================================================================diff --git a/src/esengine/ui/rendering/UIBatchRenderer.cpp b/src/esengine/ui/rendering/UIBatchRenderer.cppindex 2426047a6..00a91e17f 100644--- a/src/esengine/ui/rendering/UIBatchRenderer.cpp+++ b/src/esengine/ui/rendering/UIBatchRenderer.cpp@@ -149,8 +149,12 @@ static const char* UI_FRAGMENT_SHADER = R"(vec4 color;+ // SystemFont rendering: borderThickness < -200.0 indicates SystemFont mode+ if (v_borderThickness < -200.0) {+ color = vec4(v_color.rgb, texColor.a * v_color.a);+ }// MSDF text rendering: borderThickness < -100.0 indicates MSDF mode- if (v_borderThickness < -100.0) {+ else if (v_borderThickness < -100.0) {float screenPxRange = -v_borderThickness - 100.0 - 1.0;float sd = median(texColor.r, texColor.g, texColor.b);float edgeWidth = 0.5 / max(screenPxRange, 1.0);@@ -261,8 +265,12 @@ static const char* UI_FRAGMENT_SHADER = R"(vec4 texColor = texture(u_textures[v_texIndex], v_texCoord);vec4 color;+ // SystemFont rendering: borderThickness < -200.0 indicates SystemFont mode+ if (v_borderThickness < -200.0) {+ color = vec4(v_color.rgb, texColor.a * v_color.a);+ }// MSDF text rendering: borderThickness < -100.0 indicates MSDF mode- if (v_borderThickness < -100.0) {+ else if (v_borderThickness < -100.0) {float screenPxRange = -v_borderThickness - 100.0 - 1.0;float sd = median(texColor.r, texColor.g, texColor.b);float edgeWidth = 0.5 / max(screenPxRange, 1.0);@@ -1243,7 +1251,7 @@ void UIBatchRenderer::drawText(const std::string& text, const glm::vec2& positiov.cornerRadii = {0, 0, 0, 0};v.rectSize = rectSize;v.texIndex = texIdx;- v.borderThickness = 0.0f;+ v.borderThickness = -300.0f; // SystemFont mode markerdata_->vertices.push_back(v);}diff --git a/src/esengine/ui/text/TextMeasureHelper.cpp b/src/esengine/ui/text/TextMeasureHelper.cppindex 36bc8ae91..08dcee39e 100644--- a/src/esengine/ui/text/TextMeasureHelper.cpp+++ b/src/esengine/ui/text/TextMeasureHelper.cpp@@ -20,6 +20,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -91,6 +93,19 @@ glm::vec2 TextMeasureHelper::measureText(UIContext* ctx, const std::string& textif (font) {return font->measureText(text, fontSize);}+#else+ bool isIcon = useIconFont || (fontName.empty() && isIconText(text));+ SystemFont* font = nullptr;+ if (!fontName.empty()) {+ font = ctx->getSystemFont(fontName);+ } else if (isIcon) {+ font = ctx->getIconSystemFont();+ } else {+ font = ctx->getDefaultSystemFont();+ }+ if (font) {+ return font->measureText(text, fontSize);+ }#endifreturn {0.0f, 0.0f};diff --git a/src/esengine/ui/widgets/Button.cpp b/src/esengine/ui/widgets/Button.cppindex 5efb29d65..1d16e44b2 100644--- a/src/esengine/ui/widgets/Button.cpp+++ b/src/esengine/ui/widgets/Button.cpp@@ -21,6 +21,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -95,6 +97,19 @@ glm::vec2 Button::measure(f32 availableWidth, f32 availableHeight) {cachedTextSize_ = font->measureText(text_, fontSize_);textSizeDirty_ = false;}+#else+ SystemFont* font = nullptr;+ if (!fontName_.empty()) {+ font = ctx->getSystemFont(fontName_);+ } else if (isIcon) {+ font = ctx->getSystemFont("icons");+ } else {+ font = ctx->getDefaultSystemFont();+ }+ if (font) {+ cachedTextSize_ = font->measureText(text_, fontSize_);+ textSizeDirty_ = false;+ }#endif}@@ -209,6 +224,19 @@ void Button::render(UIBatchRenderer& renderer) {renderer.drawTextInBounds(text_, textBounds, *font, fontSize_, textColor,textAlign_, VAlign::Center);}+#else+ SystemFont* font = nullptr;+ if (!fontName_.empty()) {+ font = ctx->getSystemFont(fontName_);+ } else if (isIcon) {+ font = ctx->getSystemFont("icons");+ } else {+ font = ctx->getDefaultSystemFont();+ }+ if (font) {+ renderer.drawTextInBounds(text_, textBounds, *font, fontSize_, textColor,+ textAlign_, VAlign::Center);+ }#endif}}diff --git a/src/esengine/ui/widgets/Checkbox.cpp b/src/esengine/ui/widgets/Checkbox.cppindex 4ca102bce..7a95944d0 100644--- a/src/esengine/ui/widgets/Checkbox.cpp+++ b/src/esengine/ui/widgets/Checkbox.cpp@@ -22,6 +22,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -97,6 +99,11 @@ glm::vec2 Checkbox::measure(f32 availableWidth, f32 availableHeight) {if (font) {labelWidth = font->measureText(label_, fontSize).x;}+#else+ SystemFont* font = getContext()->getDefaultSystemFont();+ if (font) {+ labelWidth = font->measureText(label_, fontSize).x;+ }#endifwidth += LABEL_SPACING + labelWidth;@@ -195,6 +202,11 @@ void Checkbox::render(UIBatchRenderer& renderer) {renderer.drawText(label_, glm::vec2(labelX, labelY),*getContext()->getDefaultBitmapFont(), fontSize, textColor);}+#else+ if (getContext() && getContext()->getDefaultSystemFont()) {+ renderer.drawText(label_, glm::vec2(labelX, labelY),+ *getContext()->getDefaultSystemFont(), fontSize, textColor);+ }#endif}}diff --git a/src/esengine/ui/widgets/ContextMenu.cpp b/src/esengine/ui/widgets/ContextMenu.cppindex a1821323a..658e85336 100644--- a/src/esengine/ui/widgets/ContextMenu.cpp+++ b/src/esengine/ui/widgets/ContextMenu.cpp@@ -19,6 +19,8 @@#include "../font/MSDFFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -87,6 +89,20 @@ glm::vec2 ContextMenu::measure(f32 availableWidth, f32 availableHeight) {for (const auto& item : items_) {if (item.separator) continue;+ f32 textWidth = font->measureText(item.label, 13.0f).x;+ f32 shortcutWidth = item.shortcut.empty() ? 0.0f+ : font->measureText(item.shortcut, 12.0f).x + 32.0f;+ f32 itemWidth = PADDING_X * 2 + ICON_SIZE + 8.0f + textWidth + shortcutWidth + 8.0f;+ width = glm::max(width, itemWidth);+ }+ }+#else+ UIContext* ctx = getContext();+ SystemFont* font = ctx ? ctx->getDefaultSystemFont() : nullptr;+ if (font) {+ for (const auto& item : items_) {+ if (item.separator) continue;+f32 textWidth = font->measureText(item.label, 13.0f).x;f32 shortcutWidth = item.shortcut.empty() ? 0.0f: font->measureText(item.shortcut, 12.0f).x + 32.0f;@@ -143,6 +159,55 @@ void ContextMenu::render(UIBatchRenderer& renderer) {f32 itemY = y + PADDING_Y;+ for (usize i = 0; i < items_.size(); ++i) {+ const MenuItem& item = items_[i];++ if (item.separator) {+ f32 sepY = itemY + SEPARATOR_HEIGHT * 0.5f;+ Rect sepLine{x + 8.0f, sepY, size.x - 16.0f, 1.0f};+ renderer.drawRect(sepLine, separatorColor);+ itemY += SEPARATOR_HEIGHT;+ continue;+ }++ Rect itemBounds{x + 4.0f, itemY, size.x - 8.0f, ITEM_HEIGHT};++ bool isHovered = (static_cast<i32>(i) == hoveredIndex_) && item.enabled;+ if (isHovered) {+ renderer.drawRoundedRect(itemBounds, hoverBg, CornerRadii::all(3.0f));+ }++ glm::vec4 color = item.enabled ? textColor : disabledColor;++ f32 iconX = x + PADDING_X;+ if (iconFont && !item.icon.empty()) {+ Rect iconBounds{iconX, itemY + (ITEM_HEIGHT - ICON_SIZE) * 0.5f,+ ICON_SIZE, ICON_SIZE};+ renderer.drawTextInBounds(item.icon, iconBounds, *iconFont, 14.0f, color,+ HAlign::Center, VAlign::Center);+ }++ f32 textX = iconX + ICON_SIZE + 8.0f;+ f32 textY = itemY + (ITEM_HEIGHT - 13.0f) * 0.5f;+ renderer.drawText(item.label, {textX, textY}, *textFont, 13.0f, color);++ if (!item.shortcut.empty()) {+ f32 shortcutWidth = textFont->measureText(item.shortcut, 12.0f).x;+ f32 shortcutX = x + size.x - PADDING_X - shortcutWidth;+ f32 shortcutY = itemY + (ITEM_HEIGHT - 12.0f) * 0.5f;+ renderer.drawText(item.shortcut, {shortcutX, shortcutY}, *textFont, 12.0f, shortcutColor);+ }++ itemY += ITEM_HEIGHT;+ }+#else+ SystemFont* textFont = ctx->getDefaultSystemFont();+ SystemFont* iconFont = ctx->getIconSystemFont();++ if (!textFont) return;++ f32 itemY = y + PADDING_Y;+for (usize i = 0; i < items_.size(); ++i) {const MenuItem& item = items_[i];diff --git a/src/esengine/ui/widgets/Dropdown.cpp b/src/esengine/ui/widgets/Dropdown.cppindex eba04211c..3a1730d69 100644--- a/src/esengine/ui/widgets/Dropdown.cpp+++ b/src/esengine/ui/widgets/Dropdown.cpp@@ -22,6 +22,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -122,6 +124,14 @@ glm::vec2 Dropdown::measure(f32 availableWidth, f32 availableHeight) {maxTextWidth = glm::max(maxTextWidth, textWidth);}}+#else+ SystemFont* font = ctx->getDefaultSystemFont();+ if (font) {+ for (const auto& item : items_) {+ f32 textWidth = font->measureText(item.label, fontSize_).x;+ maxTextWidth = glm::max(maxTextWidth, textWidth);+ }+ }#endiff32 contentWidth = PADDING_X * 2 + maxTextWidth + ARROW_WIDTH;@@ -190,6 +200,26 @@ void Dropdown::render(UIBatchRenderer& renderer) {f32 textY = bounds.y + (bounds.height - fontSize_) * 0.5f;renderer.drawText(displayText, {textX, textY}, *textFont, fontSize_, textColor);}+#else+ SystemFont* textFont = ctx->getDefaultSystemFont();+ SystemFont* iconFont = ctx->getIconSystemFont();++ if (textFont) {+ const DropdownItem* selected = getSelectedItem();+ std::string displayText = selected ? selected->label : "";++ f32 textX = bounds.x + PADDING_X;+ f32 textY = bounds.y + (bounds.height - fontSize_) * 0.5f;+ renderer.drawText(displayText, {textX, textY}, *textFont, fontSize_, textColor);+ }++ if (iconFont) {+ f32 arrowX = bounds.x + bounds.width - ARROW_WIDTH;+ Rect arrowBounds{arrowX, bounds.y, ARROW_WIDTH, bounds.height};+ std::string arrowIcon = isOpen_ ? icons::ChevronUp : icons::ChevronDown;+ renderer.drawTextInBounds(arrowIcon, arrowBounds, *iconFont, 12.0f, arrowColor,+ HAlign::Center, VAlign::Center);+ }#endifif (isOpen_) {@@ -246,6 +276,30 @@ void Dropdown::render(UIBatchRenderer& renderer) {itemY += ITEM_HEIGHT;}}+#else+ if (textFont) {+ f32 itemY = popupBounds.y + PADDING_Y;++ for (i32 i = 0; i < static_cast<i32>(items_.size()); ++i) {+ const DropdownItem& item = items_[i];+ Rect itemBounds{popupBounds.x + 4.0f, itemY, popupBounds.width - 8.0f, ITEM_HEIGHT};++ bool isHovered = (i == hoveredIndex_) && item.enabled;+ bool isSelected = (i == selectedIndex_);++ if (isHovered || isSelected) {+ glm::vec4 highlightColor = isHovered ? hoverBgColor : glm::vec4{0.25f, 0.25f, 0.25f, 1.0f};+ renderer.drawRoundedRect(itemBounds, highlightColor, CornerRadii::all(2.0f));+ }++ glm::vec4 itemTextColor = item.enabled ? textColor : glm::vec4{0.5f, 0.5f, 0.5f, 1.0f};+ f32 textX = popupBounds.x + PADDING_X;+ f32 textY = itemY + (ITEM_HEIGHT - fontSize_) * 0.5f;+ renderer.drawText(item.label, {textX, textY}, *textFont, fontSize_, itemTextColor);++ itemY += ITEM_HEIGHT;+ }+ }#endif}}diff --git a/src/esengine/ui/widgets/Label.cpp b/src/esengine/ui/widgets/Label.cppindex be044a1ca..e4d796e9a 100644--- a/src/esengine/ui/widgets/Label.cpp+++ b/src/esengine/ui/widgets/Label.cpp@@ -21,6 +21,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+namespace esengine::ui {// =============================================================================@@ -80,6 +82,18 @@ glm::vec2 Label::measure(f32 availableWidth, f32 availableHeight) {cachedTextSize_ = font->measureText(text_, fontSize_);textSizeDirty_ = false;}+#else+ SystemFont* font = nullptr;+ if (useIconFont_) {+ font = getContext()->getIconSystemFont();+ } else {+ font = fontName_.empty() ? getContext()->getDefaultSystemFont()+ : getContext()->getSystemFont(fontName_);+ }+ if (font) {+ cachedTextSize_ = font->measureText(text_, fontSize_);+ textSizeDirty_ = false;+ }#endif}@@ -128,6 +142,16 @@ void Label::render(UIBatchRenderer& renderer) {if (font) {renderer.drawTextInBounds(text_, contentBounds, *font, fontSize_, textColor, hAlign_, vAlign_);}+#else+ SystemFont* font = nullptr;+ if (useIconFont_) {+ font = ctx->getIconSystemFont();+ } else {+ font = fontName_.empty() ? ctx->getDefaultSystemFont() : ctx->getSystemFont(fontName_);+ }+ if (font) {+ renderer.drawTextInBounds(text_, contentBounds, *font, fontSize_, textColor, hAlign_, vAlign_);+ }#endifif (clipContent_) {diff --git a/src/esengine/ui/widgets/TextField.cpp b/src/esengine/ui/widgets/TextField.cppindex 00f7ad9b6..7bd4a3b15 100644--- a/src/esengine/ui/widgets/TextField.cpp+++ b/src/esengine/ui/widgets/TextField.cpp@@ -23,6 +23,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+#include <algorithm>namespace esengine::ui {@@ -153,6 +155,12 @@ void TextField::render(UIBatchRenderer& renderer) {f32 scale = fontSize / font->getFontSize();lineHeight = font->getLineHeight() * scale;}+#elif !ES_FEATURE_BITMAP_FONT+ if (getContext() && getContext()->getDefaultSystemFont()) {+ SystemFont* font = getContext()->getDefaultSystemFont();+ f32 scale = fontSize / font->getFontSize();+ lineHeight = font->getLineHeight() * scale;+ }#endiff32 textY = bounds.y + (bounds.height - lineHeight) * 0.5f;@@ -178,6 +186,11 @@ void TextField::render(UIBatchRenderer& renderer) {renderer.drawText(placeholder_, glm::vec2(textX, textY),*getContext()->getDefaultBitmapFont(), fontSize, placeholderColor);}+#else+ if (getContext() && getContext()->getDefaultSystemFont()) {+ renderer.drawText(placeholder_, glm::vec2(textX, textY),+ *getContext()->getDefaultSystemFont(), fontSize, placeholderColor);+ }#endif} else if (!text_.empty()) {if (hasSelection()) {@@ -211,6 +224,11 @@ void TextField::render(UIBatchRenderer& renderer) {renderer.drawText(text_, glm::vec2(textX, textY),*getContext()->getDefaultBitmapFont(), fontSize, textColor);}+#else+ if (getContext() && getContext()->getDefaultSystemFont()) {+ renderer.drawText(text_, glm::vec2(textX, textY),+ *getContext()->getDefaultSystemFont(), fontSize, textColor);+ }#endif}@@ -569,6 +587,11 @@ usize TextField::getCharIndexAtX(f32 x) const {if (font) {charWidth = font->getCharWidth(static_cast<u32>(text_[i]), fontSize);}+#else+ SystemFont* font = getContext()->getDefaultSystemFont();+ if (font) {+ charWidth = font->getCharWidth(static_cast<u32>(text_[i]), fontSize);+ }#endifif (relativeX < currentX + charWidth * 0.5f) {@@ -606,6 +629,15 @@ f32 TextField::getXForCharIndex(usize index) const {}return currentX;}+#else+ SystemFont* font = getContext()->getDefaultSystemFont();+ if (font) {+ f32 currentX = 0.0f;+ for (usize i = 0; i < index && i < text_.size(); ++i) {+ currentX += font->getCharWidth(static_cast<u32>(text_[i]), fontSize);+ }+ return currentX;+ }#endiff32 charWidth = fontSize * 0.6f;diff --git a/src/esengine/ui/widgets/TreeView.cpp b/src/esengine/ui/widgets/TreeView.cppindex 927c2d30f..a0370c516 100644--- a/src/esengine/ui/widgets/TreeView.cpp+++ b/src/esengine/ui/widgets/TreeView.cpp@@ -24,6 +24,8 @@#include "../font/BitmapFont.hpp"#endif+#include "../font/SystemFont.hpp"+#include <algorithm>namespace esengine::ui {@@ -391,6 +393,64 @@ void TreeView::renderNode(UIBatchRenderer& renderer, const TreeNode& node, f32 yrenderer.drawText(node.label, glm::vec2(x, textY), *getContext()->getDefaultBitmapFont(),FONT_SIZE, textColor);}+#else+ SystemFont* iconFont = getContext() ? getContext()->getIconSystemFont() : nullptr;+ SystemFont* textFont = getContext() ? getContext()->getDefaultSystemFont() : nullptr;++ f32 x = bounds.x + padding.left + ROW_PADDING_X;++ if (showVisibilityColumn_) {+ if (iconFont) {+ Rect eyeBounds{x, y + (rowHeight_ - ICON_SIZE) * 0.5f, ICON_SIZE, ICON_SIZE};+ const char* eyeIcon = node.visible ? icons::Eye : icons::EyeOff;+ glm::vec4 eyeColor = node.visible ? visibleIconColor : hiddenIconColor;+ renderer.drawTextInBounds(eyeIcon, eyeBounds, *iconFont, 12.0f, eyeColor,+ HAlign::Center, VAlign::Center);+ }+ x += VISIBILITY_COLUMN_WIDTH;+ }++ x += static_cast<f32>(node.depth) * indentSize_;++ bool hasChild = hasChildren(node);+ Rect arrowBounds{x, y + (rowHeight_ - ARROW_SIZE) * 0.5f, ARROW_SIZE, ARROW_SIZE};++ if (iconFont && hasChild) {+ const char* arrowIcon = node.expanded ? icons::ChevronDown : icons::ChevronRight;+ renderer.drawTextInBounds(arrowIcon, arrowBounds, *iconFont, 12.0f, arrowColor,+ HAlign::Center, VAlign::Center);+ }+ x += ARROW_SIZE + 2.0f;++ if (iconFont) {+ Rect iconBounds{x, y + (rowHeight_ - ICON_SIZE) * 0.5f, ICON_SIZE, ICON_SIZE};++ if (!node.icon.empty()) {+ renderer.drawTextInBounds(node.icon, iconBounds, *iconFont, 14.0f, entityIconColor,+ HAlign::Center, VAlign::Center);+ } else {+ const char* folderIcon = hasChild && node.expanded ? icons::FolderOpen : icons::Folder;+ renderer.drawTextInBounds(folderIcon, iconBounds, *iconFont, 14.0f, folderColor,+ HAlign::Center, VAlign::Center);+ }+ }+ x += ICON_SIZE + 6.0f;++ f32 typeColumnSpace = showTypeColumn_ ? TYPE_COLUMN_WIDTH : 0.0f;+ f32 labelMaxWidth = bounds.x + bounds.width - padding.right - typeColumnSpace - x;+ f32 textY = y + (rowHeight_ - FONT_SIZE) * 0.5f;++ if (textFont && labelMaxWidth > 0) {+ Rect labelClipRect{x, y, labelMaxWidth, rowHeight_};+ renderer.pushClipRect(labelClipRect);+ renderer.drawText(node.label, glm::vec2(x, textY), *textFont, FONT_SIZE, textColor);+ renderer.popClipRect();+ }++ if (showTypeColumn_ && textFont && !node.type.empty()) {+ f32 typeX = bounds.x + bounds.width - padding.right - TYPE_COLUMN_WIDTH;+ renderer.drawText(node.type, glm::vec2(typeX, textY), *textFont, 11.0f, dimTextColor);+ }#endif}