luboslenco 1 年之前
父节点
当前提交
705045dfd4
共有 100 个文件被更改,包括 7201 次插入7201 次删除
  1. 19 19
      armorforge/Sources/TabObjects.ts
  2. 22 22
      armorpaint/Sources/ImportFolder.ts
  3. 36 36
      armorpaint/Sources/MakeBake.ts
  4. 4 4
      armorpaint/Sources/MakeBlur.ts
  5. 5 5
      armorpaint/Sources/MakeBrush.ts
  6. 2 2
      armorpaint/Sources/MakeClone.ts
  7. 3 3
      armorpaint/Sources/MakeColorIdPicker.ts
  8. 4 4
      armorpaint/Sources/MakeDiscard.ts
  9. 112 112
      armorpaint/Sources/MakeMaterial.ts
  10. 68 68
      armorpaint/Sources/MakeMesh.ts
  11. 13 13
      armorpaint/Sources/MakeMeshPreview.ts
  12. 2 2
      armorpaint/Sources/MakeNodePreview.ts
  13. 86 86
      armorpaint/Sources/MakePaint.ts
  14. 2 2
      armorpaint/Sources/MakeParticle.ts
  15. 7 7
      armorpaint/Sources/MakeTexcoord.ts
  16. 2 2
      armorpaint/Sources/NodesBrush.ts
  17. 251 251
      armorpaint/Sources/RenderPathPaint.ts
  18. 16 16
      armorpaint/Sources/RenderPathPreview.ts
  19. 6 6
      armorpaint/Sources/SlotBrush.ts
  20. 1 1
      armorpaint/Sources/SlotFont.ts
  21. 140 140
      armorpaint/Sources/SlotLayer.ts
  22. 20 20
      armorpaint/Sources/SlotMaterial.ts
  23. 278 278
      armorpaint/Sources/TabLayers.ts
  24. 48 48
      armorpaint/Sources/nodes/BrushOutputNode.ts
  25. 18 18
      armorpaint/Sources/nodes/InputNode.ts
  26. 67 67
      armorsculpt/Sources/TabLayers.ts
  27. 74 75
      base/Sources/Args.ts
  28. 324 324
      base/Sources/Base.ts
  29. 149 149
      base/Sources/BoxExport.ts
  30. 192 192
      base/Sources/BoxPreferences.ts
  31. 65 65
      base/Sources/BoxProjects.ts
  32. 59 59
      base/Sources/Camera.ts
  33. 86 97
      base/Sources/Config.ts
  34. 2 2
      base/Sources/ConfigFormat.ts
  35. 32 32
      base/Sources/Console.ts
  36. 165 165
      base/Sources/Context.ts
  37. 255 254
      base/Sources/ContextFormat.ts
  38. 239 239
      base/Sources/Enums.ts
  39. 109 109
      base/Sources/ExportArm.ts
  40. 2 2
      base/Sources/ExportGpl.ts
  41. 4 4
      base/Sources/ExportMesh.ts
  42. 89 89
      base/Sources/ExportObj.ts
  43. 161 162
      base/Sources/ExportTexture.ts
  44. 44 44
      base/Sources/File.ts
  45. 61 61
      base/Sources/Geom.ts
  46. 132 122
      base/Sources/Gizmo.ts
  47. 240 238
      base/Sources/History.ts
  48. 150 150
      base/Sources/ImportArm.ts
  49. 23 23
      base/Sources/ImportAsset.ts
  50. 46 46
      base/Sources/ImportBlendMaterial.ts
  51. 148 139
      base/Sources/ImportBlendMesh.ts
  52. 56 56
      base/Sources/ImportEnvmap.ts
  53. 8 8
      base/Sources/ImportFont.ts
  54. 8 8
      base/Sources/ImportGpl.ts
  55. 5 5
      base/Sources/ImportKeymap.ts
  56. 80 80
      base/Sources/ImportMesh.ts
  57. 46 46
      base/Sources/ImportObj.ts
  58. 4 4
      base/Sources/ImportPlugin.ts
  59. 16 16
      base/Sources/ImportTexture.ts
  60. 6 6
      base/Sources/ImportTheme.ts
  61. 69 69
      base/Sources/LineDraw.ts
  62. 6 6
      base/Sources/LogicNode.ts
  63. 12 8
      base/Sources/MakeVoxel.ts
  64. 83 83
      base/Sources/NodeShader.ts
  65. 9 9
      base/Sources/NodeShaderContext.ts
  66. 68 68
      base/Sources/NodesMaterial.ts
  67. 8 8
      base/Sources/Operator.ts
  68. 130 130
      base/Sources/ParserBlend.ts
  69. 37 37
      base/Sources/ParserExr.ts
  70. 40 41
      base/Sources/ParserLogic.ts
  71. 258 255
      base/Sources/ParserMaterial.ts
  72. 63 63
      base/Sources/Path.ts
  73. 163 169
      base/Sources/PhysicsBody.ts
  74. 67 67
      base/Sources/PhysicsWorld.ts
  75. 8 8
      base/Sources/Plugin.ts
  76. 198 198
      base/Sources/Project.ts
  77. 54 54
      base/Sources/ProjectFormat.ts
  78. 153 153
      base/Sources/RenderPathBase.ts
  79. 38 38
      base/Sources/RenderPathDeferred.ts
  80. 5 5
      base/Sources/RenderPathForward.ts
  81. 75 78
      base/Sources/RenderPathRaytrace.ts
  82. 67 67
      base/Sources/RenderPathRaytraceBake.ts
  83. 16 16
      base/Sources/Res.ts
  84. 21 21
      base/Sources/ShaderFunctions.ts
  85. 53 53
      base/Sources/TabBrowser.ts
  86. 46 46
      base/Sources/TabBrushes.ts
  87. 12 12
      base/Sources/TabConsole.ts
  88. 38 39
      base/Sources/TabFonts.ts
  89. 4 4
      base/Sources/TabHistory.ts
  90. 121 124
      base/Sources/TabMaterials.ts
  91. 51 51
      base/Sources/TabMeshes.ts
  92. 2 2
      base/Sources/TabPlugins.ts
  93. 16 16
      base/Sources/TabScript.ts
  94. 78 80
      base/Sources/TabSwatches.ts
  95. 81 81
      base/Sources/TabTextures.ts
  96. 33 33
      base/Sources/Translator.ts
  97. 319 319
      base/Sources/UIBase.ts
  98. 69 69
      base/Sources/UIBox.ts
  99. 102 102
      base/Sources/UIFiles.ts
  100. 216 216
      base/Sources/UIHeader.ts

+ 19 - 19
armorforge/Sources/TabObjects.ts

@@ -14,8 +14,8 @@ class TabObjects {
 			zui_begin_sticky();
 			zui_row([1 / 4]);
 			if (zui_button("Import")) {
-				Project.importMesh(false, () => {
-					object_set_parent(Project.paintObjects.pop().base, null);
+				Project.import_mesh(false, () => {
+					object_set_parent(Project.paint_objects.pop().base, null);
 				});
 			}
 			zui_end_sticky();
@@ -40,7 +40,7 @@ class TabObjects {
 					}
 
 					// Highlight selected line
-					if (currentObject == Context.raw.selectedObject) {
+					if (currentObject == Context.raw.selected_object) {
 						g2_set_color(0xff205d9c);
 						g2_fill_rect(0, ui._y, ui._window_w, zui_ELEMENT_H(ui));
 						g2_set_color(0xffffffff);
@@ -68,12 +68,12 @@ class TabObjects {
 					ui._y -= zui_ELEMENT_OFFSET(ui);
 
 					if (ui.is_released) {
-						Context.raw.selectedObject = currentObject;
+						Context.raw.selected_object = currentObject;
 					}
 
 					if (ui.is_hovered && ui.input_released_r) {
 						UIMenu.draw((ui: zui_t) => {
-							if (UIMenu.menuButton(ui, "Assign Material")) {
+							if (UIMenu.menu_button(ui, "Assign Material")) {
 								TabObjects.materialId++;
 
 								for (let sh of _scene_raw.shader_datas) {
@@ -98,7 +98,7 @@ class TabObjects {
 								let md: material_data_t = data_get_material("Scene", "TempMaterial" + TabObjects.materialId);
 								let mo: mesh_object_t = currentObject.ext;
 								mo.materials = [md];
-								MakeMaterial.parseMeshPreviewMaterial(md);
+								MakeMaterial.parse_mesh_preview_material(md);
 							}
 						}, 1);
 					}
@@ -127,12 +127,12 @@ class TabObjects {
 			if (zui_panel(zui_handle("tabobjects_2", {selected: true}), 'Properties')) {
 				// ui.indent();
 
-				if (Context.raw.selectedObject != null) {
+				if (Context.raw.selected_object != null) {
 					let h = zui_handle("tabobjects_3");
-					h.selected = Context.raw.selectedObject.visible;
-					Context.raw.selectedObject.visible = zui_check(h, "Visible");
+					h.selected = Context.raw.selected_object.visible;
+					Context.raw.selected_object.visible = zui_check(h, "Visible");
 
-					let t = Context.raw.selectedObject.transform;
+					let t = Context.raw.selected_object.transform;
 					let localPos = t.loc;
 					let worldPos = vec4_create(transform_world_x(t), transform_world_y(t), transform_world_z(t), 1.0);
 					let scale = t.scale;
@@ -178,10 +178,10 @@ class TabObjects {
 					f = parseFloat(zui_text_input(h, "Z"));
 					if (h.changed) { changed = true; rot.z = f; }
 
-					if (changed && Context.raw.selectedObject.name != "Scene") {
+					if (changed && Context.raw.selected_object.name != "Scene") {
 						vec4_mult(rot, 3.141592 / 180);
-						quat_from_euler(Context.raw.selectedObject.transform.rot, rot.x, rot.y, rot.z);
-						transform_build_matrix(Context.raw.selectedObject.transform);
+						quat_from_euler(Context.raw.selected_object.transform.rot, rot.x, rot.y, rot.z);
+						transform_build_matrix(Context.raw.selected_object.transform);
 						// ///if arm_physics
 						// if (rb != null) rb.syncTransform();
 						// ///end
@@ -223,20 +223,20 @@ class TabObjects {
 					f = parseFloat(zui_text_input(h, "Z"));
 					if (h.changed) dim.z = f;
 
-					Context.raw.selectedObject.transform.dirty = true;
+					Context.raw.selected_object.transform.dirty = true;
 
-					if (Context.raw.selectedObject.name == "Scene") {
+					if (Context.raw.selected_object.name == "Scene") {
 						let p = scene_world;
 						p.strength = zui_slider(zui_handle("tabobjects_16", {value: p.strength}), "Environment", 0.0, 5.0, true);
 					}
-					else if (Context.raw.selectedObject.ext_type == "light_object_t") {
-						let light = Context.raw.selectedObject.ext;
+					else if (Context.raw.selected_object.ext_type == "light_object_t") {
+						let light = Context.raw.selected_object.ext;
 						let lightHandle = zui_handle("tabobjects_17");
 						lightHandle.value = light.data.strength / 10;
 						light.data.strength = zui_slider(lightHandle, "Strength", 0.0, 5.0, true) * 10;
 					}
-					else if (Context.raw.selectedObject.ext_type == "camera_object_t") {
-						let cam = Context.raw.selectedObject.ext;
+					else if (Context.raw.selected_object.ext_type == "camera_object_t") {
+						let cam = Context.raw.selected_object.ext;
 						let fovHandle = zui_handle("tabobjects_18");
 						fovHandle.value = Math.floor(cam.data.fov * 100) / 100;
 						cam.data.fov = zui_slider(fovHandle, "FoV", 0.3, 2.0, true);

+ 22 - 22
armorpaint/Sources/ImportFolder.ts

@@ -2,7 +2,7 @@
 class ImportFolder {
 
 	static run = (path: string) => {
-		let files = File.readDirectory(path);
+		let files = File.read_directory(path);
 		let mapbase = "";
 		let mapopac = "";
 		let mapnor = "";
@@ -14,37 +14,37 @@ class ImportFolder {
 		let foundTexture = false;
 		// Import maps
 		for (let f of files) {
-			if (!Path.isTexture(f)) continue;
+			if (!Path.is_texture(f)) continue;
 
 			// TODO: handle -albedo
 
 			let base = f.substr(0, f.lastIndexOf(".")).toLowerCase();
 			let valid = false;
-			if (mapbase == "" && Path.isBaseColorTex(base)) {
+			if (mapbase == "" && Path.is_base_color_tex(base)) {
 				mapbase = f;
 				valid = true;
 			}
-			if (mapopac == "" && Path.isOpacityTex(base)) {
+			if (mapopac == "" && Path.is_opacity_tex(base)) {
 				mapopac = f;
 				valid = true;
 			}
-			if (mapnor == "" && Path.isNormalMapTex(base)) {
+			if (mapnor == "" && Path.is_normal_map_tex(base)) {
 				mapnor = f;
 				valid = true;
 			}
-			if (mapocc == "" && Path.isOcclusionTex(base)) {
+			if (mapocc == "" && Path.is_occlusion_tex(base)) {
 				mapocc = f;
 				valid = true;
 			}
-			if (maprough == "" && Path.isRoughnessTex(base)) {
+			if (maprough == "" && Path.is_roughness_tex(base)) {
 				maprough = f;
 				valid = true;
 			}
-			if (mapmet == "" && Path.isMetallicTex(base)) {
+			if (mapmet == "" && Path.is_metallic_tex(base)) {
 				mapmet = f;
 				valid = true;
 			}
-			if (mapheight == "" && Path.isDisplacementTex(base)) {
+			if (mapheight == "" && Path.is_displacement_tex(base)) {
 				mapheight = f;
 				valid = true;
 			}
@@ -86,43 +86,43 @@ class ImportFolder {
 		let startY = 100;
 		let nodeH = 164;
 		if (mapbase != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapbase, startY + nodeH * pos, nout.id, 0);
+			ImportFolder.place_image_node(nodes, canvas, mapbase, startY + nodeH * pos, nout.id, 0);
 			pos++;
 		}
 		if (mapopac != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapopac, startY + nodeH * pos, nout.id, 1);
+			ImportFolder.place_image_node(nodes, canvas, mapopac, startY + nodeH * pos, nout.id, 1);
 			pos++;
 		}
 		if (mapocc != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapocc, startY + nodeH * pos, nout.id, 2);
+			ImportFolder.place_image_node(nodes, canvas, mapocc, startY + nodeH * pos, nout.id, 2);
 			pos++;
 		}
 		if (maprough != "") {
-			ImportFolder.placeImageNode(nodes, canvas, maprough, startY + nodeH * pos, nout.id, 3);
+			ImportFolder.place_image_node(nodes, canvas, maprough, startY + nodeH * pos, nout.id, 3);
 			pos++;
 		}
 		if (mapmet != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapmet, startY + nodeH * pos, nout.id, 4);
+			ImportFolder.place_image_node(nodes, canvas, mapmet, startY + nodeH * pos, nout.id, 4);
 			pos++;
 		}
 		if (mapnor != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapnor, startY + nodeH * pos, nout.id, 5);
+			ImportFolder.place_image_node(nodes, canvas, mapnor, startY + nodeH * pos, nout.id, 5);
 			pos++;
 		}
 		if (mapheight != "") {
-			ImportFolder.placeImageNode(nodes, canvas, mapheight, startY + nodeH * pos, nout.id, 7);
+			ImportFolder.place_image_node(nodes, canvas, mapheight, startY + nodeH * pos, nout.id, 7);
 			pos++;
 		}
 
-		MakeMaterial.parsePaintMaterial();
-		UtilRender.makeMaterialPreview();
+		MakeMaterial.parse_paint_material();
+		UtilRender.make_material_preview();
 		UIBase.hwnds[1].redraws = 2;
-		History.newMaterial();
+		History.new_material();
 	}
 
-	static placeImageNode = (nodes: zui_nodes_t, canvas: zui_node_canvas_t, asset: string, ny: i32, to_id: i32, to_socket: i32) => {
-		let n = NodesMaterial.createNode("TEX_IMAGE");
-		n.buttons[0].default_value = Base.getAssetIndex(asset);
+	static place_image_node = (nodes: zui_nodes_t, canvas: zui_node_canvas_t, asset: string, ny: i32, to_id: i32, to_socket: i32) => {
+		let n = NodesMaterial.create_node("TEX_IMAGE");
+		n.buttons[0].default_value = Base.get_asset_index(asset);
 		n.x = 72;
 		n.y = ny;
 		let l: zui_node_link_t = { id: zui_get_link_id(canvas.links), from_id: n.id, from_socket: 0, to_id: to_id, to_socket: to_socket };

+ 36 - 36
armorpaint/Sources/MakeBake.ts

@@ -2,13 +2,13 @@
 class MakeBake {
 
 	static run = (con: NodeShaderContextRaw, vert: NodeShaderRaw, frag: NodeShaderRaw) => {
-		if (Context.raw.bakeType == BakeType.BakeAO) { // Voxel
+		if (Context.raw.bake_type == bake_type_t.AO) { // Voxel
 			///if arm_voxels
 			// Apply normal channel
 			frag.wposition = true;
 			frag.n = true;
-			frag.vVec = true;
-			NodeShader.add_function(frag, ShaderFunctions.str_cotangentFrame);
+			frag.vvec = true;
+			NodeShader.add_function(frag, ShaderFunctions.str_cotangent_frame);
 			///if krom_direct3d11
 			NodeShader.write(frag, 'mat3 TBN = cotangentFrame(n, vVec, texCoord);');
 			///else
@@ -18,28 +18,28 @@ class MakeBake {
 			NodeShader.write(frag, 'n.y = -n.y;');
 			NodeShader.write(frag, 'n = normalize(mul(n, TBN));');
 
-			NodeShader.write(frag, MakeMaterial.voxelgiHalfExtents());
+			NodeShader.write(frag, MakeMaterial.voxelgi_half_extents());
 			NodeShader.write(frag, 'vec3 voxpos = wposition / voxelgiHalfExtents;');
 			NodeShader.add_uniform(frag, 'sampler3D voxels');
-			NodeShader.add_function(frag, ShaderFunctions.str_traceAO);
+			NodeShader.add_function(frag, ShaderFunctions.str_trace_ao);
 			frag.n = true;
-			let strength = Context.raw.bakeAoStrength;
-			let radius = Context.raw.bakeAoRadius;
-			let offset = Context.raw.bakeAoOffset;
+			let strength = Context.raw.bake_ao_strength;
+			let radius = Context.raw.bake_ao_radius;
+			let offset = Context.raw.bake_ao_offset;
 			NodeShader.write(frag, `float ao = traceAO(voxpos, n, ${radius}, ${offset}) * ${strength};`);
-			if (Context.raw.bakeAxis != BakeAxis.BakeXYZ) {
-				let axis = MakeBake.axisString(Context.raw.bakeAxis);
+			if (Context.raw.bake_axis != bake_axis_t.XYZ) {
+				let axis = MakeBake.axis_string(Context.raw.bake_axis);
 				NodeShader.write(frag, `ao *= dot(n, ${axis});`);
 			}
 			NodeShader.write(frag, 'ao = 1.0 - ao;');
 			NodeShader.write(frag, 'fragColor[0] = vec4(ao, ao, ao, 1.0);');
 			///end
 		}
-		else if (Context.raw.bakeType == BakeType.BakeCurvature) {
+		else if (Context.raw.bake_type == bake_type_t.CURVATURE) {
 			let pass = ParserMaterial.bake_passthrough;
-			let strength = pass ? ParserMaterial.bake_passthrough_strength : Context.raw.bakeCurvStrength + "";
-			let radius = pass ? ParserMaterial.bake_passthrough_radius : Context.raw.bakeCurvRadius + "";
-			let offset = pass ? ParserMaterial.bake_passthrough_offset : Context.raw.bakeCurvOffset + "";
+			let strength = pass ? ParserMaterial.bake_passthrough_strength : Context.raw.bake_curv_strength + "";
+			let radius = pass ? ParserMaterial.bake_passthrough_radius : Context.raw.bake_curv_radius + "";
+			let offset = pass ? ParserMaterial.bake_passthrough_offset : Context.raw.bake_curv_offset + "";
 			strength = `float(${strength})`;
 			radius = `float(${radius})`;
 			offset = `float(${offset})`;
@@ -48,36 +48,36 @@ class MakeBake {
 			NodeShader.write(frag, 'vec3 dy = dFdy(n);');
 			NodeShader.write(frag, 'float curvature = max(dot(dx, dx), dot(dy, dy));');
 			NodeShader.write(frag, 'curvature = clamp(pow(curvature, (1.0 / ' + radius + ') * 0.25) * ' + strength + ' * 2.0 + ' + offset + ' / 10.0, 0.0, 1.0);');
-			if (Context.raw.bakeAxis != BakeAxis.BakeXYZ) {
-				let axis = MakeBake.axisString(Context.raw.bakeAxis);
+			if (Context.raw.bake_axis != bake_axis_t.XYZ) {
+				let axis = MakeBake.axis_string(Context.raw.bake_axis);
 				NodeShader.write(frag, `curvature *= dot(n, ${axis});`);
 			}
 			NodeShader.write(frag, 'fragColor[0] = vec4(curvature, curvature, curvature, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeNormal) { // Tangent
+		else if (Context.raw.bake_type == bake_type_t.NORMAL) { // Tangent
 			frag.n = true;
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_undo', '_texpaint_undo'); // Baked high-poly normals
 			NodeShader.write(frag, 'vec3 n0 = textureLod(texpaint_undo, texCoord, 0.0).rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);');
-			NodeShader.add_function(frag, ShaderFunctions.str_cotangentFrame);
+			NodeShader.add_function(frag, ShaderFunctions.str_cotangent_frame);
 			NodeShader.write(frag, 'mat3 invTBN = transpose(cotangentFrame(n, n, texCoord));');
 			NodeShader.write(frag, 'vec3 res = normalize(mul(n0, invTBN)) * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5);');
 			NodeShader.write(frag, 'fragColor[0] = vec4(res, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeNormalObject) {
+		else if (Context.raw.bake_type == bake_type_t.NORMAL_OBJECT) {
 			frag.n = true;
 			NodeShader.write(frag, 'fragColor[0] = vec4(n * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);');
-			if (Context.raw.bakeUpAxis == BakeUpAxis.BakeUpY) {
+			if (Context.raw.bake_up_axis == bake_up_axis_t.Y) {
 				NodeShader.write(frag, 'fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);');
 			}
 		}
-		else if (Context.raw.bakeType == BakeType.BakeHeight) {
+		else if (Context.raw.bake_type == bake_type_t.HEIGHT) {
 			frag.wposition = true;
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_undo', '_texpaint_undo'); // Baked high-poly positions
 			NodeShader.write(frag, 'vec3 wpos0 = textureLod(texpaint_undo, texCoord, 0.0).rgb * vec3(2.0, 2.0, 2.0) - vec3(1.0, 1.0, 1.0);');
 			NodeShader.write(frag, 'float res = distance(wpos0, wposition) * 10.0;');
 			NodeShader.write(frag, 'fragColor[0] = vec4(res, res, res, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeDerivative) {
+		else if (Context.raw.bake_type == bake_type_t.DERIVATIVE) {
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_undo', '_texpaint_undo'); // Baked height
 			NodeShader.write(frag, 'vec2 texDx = dFdx(texCoord);');
 			NodeShader.write(frag, 'vec2 texDy = dFdy(texCoord);');
@@ -86,17 +86,17 @@ class MakeBake {
 			NodeShader.write(frag, 'float h2 = textureLod(texpaint_undo, texCoord + texDy, 0.0).r * 100;');
 			NodeShader.write(frag, 'fragColor[0] = vec4((h1 - h0) * 0.5 + 0.5, (h2 - h0) * 0.5 + 0.5, 0.0, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakePosition) {
+		else if (Context.raw.bake_type == bake_type_t.POSITION) {
 			frag.wposition = true;
 			NodeShader.write(frag, 'fragColor[0] = vec4(wposition * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);');
-			if (Context.raw.bakeUpAxis == BakeUpAxis.BakeUpY) {
+			if (Context.raw.bake_up_axis == bake_up_axis_t.Y) {
 				NodeShader.write(frag, 'fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);');
 			}
 		}
-		else if (Context.raw.bakeType == BakeType.BakeTexCoord) {
+		else if (Context.raw.bake_type == bake_type_t.TEXCOORD) {
 			NodeShader.write(frag, 'fragColor[0] = vec4(texCoord.xy, 0.0, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeMaterialID) {
+		else if (Context.raw.bake_type == bake_type_t.MATERIALID) {
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_nor_undo', '_texpaint_nor_undo');
 			NodeShader.write(frag, 'float sample_matid = textureLod(texpaint_nor_undo, texCoord, 0.0).a + 1.0 / 255.0;');
 			NodeShader.write(frag, 'float matid_r = fract(sin(dot(vec2(sample_matid, sample_matid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);');
@@ -104,7 +104,7 @@ class MakeBake {
 			NodeShader.write(frag, 'float matid_b = fract(sin(dot(vec2(sample_matid, sample_matid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);');
 			NodeShader.write(frag, 'fragColor[0] = vec4(matid_r, matid_g, matid_b, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeObjectID) {
+		else if (Context.raw.bake_type == bake_type_t.OBJECTID) {
 			NodeShader.add_uniform(frag, 'float objectId', '_objectId');
 			NodeShader.write(frag, 'float obid = objectId + 1.0 / 255.0;');
 			NodeShader.write(frag, 'float id_r = fract(sin(dot(vec2(obid, obid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);');
@@ -112,7 +112,7 @@ class MakeBake {
 			NodeShader.write(frag, 'float id_b = fract(sin(dot(vec2(obid, obid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);');
 			NodeShader.write(frag, 'fragColor[0] = vec4(id_r, id_g, id_b, 1.0);');
 		}
-		else if (Context.raw.bakeType == BakeType.BakeVertexColor) {
+		else if (Context.raw.bake_type == bake_type_t.VERTEX_COLOR) {
 			if (con.allow_vcols) {
 				NodeShaderContext.add_elem(con, "col", "short4norm");
 				NodeShader.write(frag, 'fragColor[0] = vec4(vcolor.r, vcolor.g, vcolor.b, 1.0);');
@@ -123,7 +123,7 @@ class MakeBake {
 		}
 	}
 
-	static positionAndNormal = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
+	static position_normal = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 		NodeShader.add_out(vert, 'vec3 position');
 		NodeShader.add_out(vert, 'vec3 normal');
 		NodeShader.add_uniform(vert, 'mat4 W', '_world_matrix');
@@ -136,7 +136,7 @@ class MakeBake {
 		NodeShader.write(frag, 'fragColor[1] = vec4(normal, 1.0);');
 	}
 
-	static setColorWrites = (con_paint: NodeShaderContextRaw) => {
+	static set_color_writes = (con_paint: NodeShaderContextRaw) => {
 		// Bake into base color, disable other slots
 		con_paint.data.color_writes_red[1] = false;
 		con_paint.data.color_writes_green[1] = false;
@@ -148,12 +148,12 @@ class MakeBake {
 		con_paint.data.color_writes_alpha[2] = false;
 	}
 
-	static axisString = (i: i32): string => {
-		return i == BakeAxis.BakeX  ? "vec3(1,0,0)"  :
-			   i == BakeAxis.BakeY  ? "vec3(0,1,0)"  :
-			   i == BakeAxis.BakeZ  ? "vec3(0,0,1)"  :
-			   i == BakeAxis.BakeMX ? "vec3(-1,0,0)" :
-			   i == BakeAxis.BakeMY ? "vec3(0,-1,0)" :
+	static axis_string = (i: i32): string => {
+		return i == bake_axis_t.X  ? "vec3(1,0,0)"  :
+			   i == bake_axis_t.Y  ? "vec3(0,1,0)"  :
+			   i == bake_axis_t.Z  ? "vec3(0,0,1)"  :
+			   i == bake_axis_t.MX ? "vec3(-1,0,0)" :
+			   i == bake_axis_t.MY ? "vec3(0,-1,0)" :
 							 		  "vec3(0,0,-1)";
 	}
 }

+ 4 - 4
armorpaint/Sources/MakeBlur.ts

@@ -15,23 +15,23 @@ class MakeBlur {
 		NodeShader.write(frag, 'vec3 nortan = vec3(0.0, 0.0, 0.0);');
 		NodeShader.write(frag, 'float height = 0.0;');
 		NodeShader.write(frag, 'float mat_opacity = 1.0;');
-		let isMask = SlotLayer.isMask(Context.raw.layer);
+		let isMask = SlotLayer.is_mask(Context.raw.layer);
 		if (isMask) {
 			NodeShader.write(frag, 'float opacity = 1.0;');
 		}
 		else {
 			NodeShader.write(frag, 'float opacity = 0.0;');
 		}
-		if (Context.raw.material.paintEmis) {
+		if (Context.raw.material.paint_emis) {
 			NodeShader.write(frag, 'float emis = 0.0;');
 		}
-		if (Context.raw.material.paintSubs) {
+		if (Context.raw.material.paint_subs) {
 			NodeShader.write(frag, 'float subs = 0.0;');
 		}
 
 		NodeShader.add_uniform(frag, 'vec2 texpaintSize', '_texpaintSize');
 		NodeShader.write(frag, 'float blur_step = 1.0 / texpaintSize.x;');
-		if (Context.raw.tool == WorkspaceTool.ToolSmudge) {
+		if (Context.raw.tool == workspace_tool_t.SMUDGE) {
 			///if (krom_direct3d11 || krom_direct3d12 || krom_metal)
 			NodeShader.write(frag, 'const float blur_weight[7] = {1.0 / 28.0, 2.0 / 28.0, 3.0 / 28.0, 4.0 / 28.0, 5.0 / 28.0, 6.0 / 28.0, 7.0 / 28.0};');
 			///else

+ 5 - 5
armorpaint/Sources/MakeBrush.ts

@@ -5,10 +5,10 @@ class MakeBrush {
 
 		NodeShader.write(frag, 'float dist = 0.0;');
 
-		if (Context.raw.tool == WorkspaceTool.ToolParticle) return;
+		if (Context.raw.tool == workspace_tool_t.PARTICLE) return;
 
 		let fillLayer = Context.raw.layer.fill_layer != null;
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		if (decal && !fillLayer) NodeShader.write(frag, 'if (decalMask.z > 0.0) {');
 
 		if (Config.raw.brush_3d) {
@@ -25,7 +25,7 @@ class MakeBrush {
 			frag.wposition = true;
 
 			if (Config.raw.brush_angle_reject || Context.raw.xray) {
-				NodeShader.add_function(frag, ShaderFunctions.str_octahedronWrap);
+				NodeShader.add_function(frag, ShaderFunctions.str_octahedron_wrap);
 				NodeShader.add_uniform(frag, 'sampler2D gbuffer0');
 				///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 				NodeShader.write(frag, 'vec2 g0 = textureLod(gbuffer0, inp.xy, 0.0).rg;');
@@ -41,7 +41,7 @@ class MakeBrush {
 				if (Config.raw.brush_angle_reject && !Context.raw.xray) {
 					NodeShader.write(frag, 'if (planeDist < -0.01) discard;');
 					frag.n = true;
-					let angle = Context.raw.brushAngleRejectDot;
+					let angle = Context.raw.brush_angle_reject_dot;
 					NodeShader.write(frag, `if (dot(wn, n) < ${angle}) discard;`);
 				}
 			}
@@ -62,7 +62,7 @@ class MakeBrush {
 			}
 			NodeShader.write(frag, 'vec3 ba = winplast.xyz - winp.xyz;');
 
-			if (Context.raw.brushLazyRadius > 0 && Context.raw.brushLazyStep > 0) {
+			if (Context.raw.brush_lazy_radius > 0 && Context.raw.brush_lazy_step > 0) {
 				// Sphere
 				NodeShader.write(frag, 'dist = distance(wposition, winp.xyz);');
 			}

+ 2 - 2
armorpaint/Sources/MakeClone.ts

@@ -25,10 +25,10 @@ class MakeClone {
 		NodeShader.write(frag, `float height = ${height};`);
 		NodeShader.write(frag, `float mat_opacity = ${opac};`);
 		NodeShader.write(frag, 'float opacity = mat_opacity * brushOpacity;');
-		if (Context.raw.material.paintEmis) {
+		if (Context.raw.material.paint_emis) {
 			NodeShader.write(frag, 'float emis = 0.0;');
 		}
-		if (Context.raw.material.paintSubs) {
+		if (Context.raw.material.paint_subs) {
 			NodeShader.write(frag, 'float subs = 0.0;');
 		}
 	}

+ 3 - 3
armorpaint/Sources/MakeColorIdPicker.ts

@@ -15,14 +15,14 @@ class MakeColorIdPicker {
 		NodeShader.write(frag, 'vec2 texCoordInp = texelFetch(gbuffer2, ivec2(inp.x * gbufferSize.x, (1.0 - inp.y) * gbufferSize.y), 0).ba;');
 		///end
 
-		if (Context.raw.tool == WorkspaceTool.ToolColorId) {
+		if (Context.raw.tool == workspace_tool_t.COLORID) {
 			NodeShader.add_out(frag, 'vec4 fragColor');
 			NodeShader.add_uniform(frag, 'sampler2D texcolorid', '_texcolorid');
 			NodeShader.write(frag, 'vec3 idcol = textureLod(texcolorid, texCoordInp, 0.0).rgb;');
 			NodeShader.write(frag, 'fragColor = vec4(idcol, 1.0);');
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) {
-			if (Context.raw.pickPosNorTex) {
+		else if (Context.raw.tool == workspace_tool_t.PICKER || Context.raw.tool == workspace_tool_t.MATERIAL) {
+			if (Context.raw.pick_pos_nor_tex) {
 				NodeShader.add_out(frag, 'vec4 fragColor[2]');
 				NodeShader.add_uniform(frag, 'sampler2D gbufferD');
 				NodeShader.add_uniform(frag, 'mat4 invVP', '_inv_view_proj_matrix');

+ 4 - 4
armorpaint/Sources/MakeDiscard.ts

@@ -1,7 +1,7 @@
 
 class MakeDiscard {
 
-	static colorId = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
+	static color_id = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 		NodeShader.add_uniform(frag, 'sampler2D texpaint_colorid'); // 1x1 picker
 		NodeShader.add_uniform(frag, 'sampler2D texcolorid', '_texcolorid'); // color map
 		NodeShader.write(frag, 'vec3 colorid_c1 = texelFetch(texpaint_colorid, ivec2(0, 0), 0).rgb;');
@@ -32,19 +32,19 @@ class MakeDiscard {
 		///end
 	}
 
-	static uvIsland = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
+	static uv_island = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 		NodeShader.add_uniform(frag, 'sampler2D texuvislandmap', '_texuvislandmap');
 		NodeShader.write(frag, 'if (textureLod(texuvislandmap, texCoordPick, 0).r == 0.0) discard;');
 	}
 
-	static materialId = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
+	static material_id = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 		frag.wvpposition = true;
 		NodeShader.write(frag, 'vec2 picker_sample_tc = vec2(wvpposition.x / wvpposition.w, wvpposition.y / wvpposition.w) * 0.5 + 0.5;');
 		///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 		NodeShader.write(frag, 'picker_sample_tc.y = 1.0 - picker_sample_tc.y;');
 		///end
 		NodeShader.add_uniform(frag, 'sampler2D texpaint_nor_undo', '_texpaint_nor_undo');
-		let matid = Context.raw.materialIdPicked / 255;
+		let matid = Context.raw.materialid_picked / 255;
 		NodeShader.write(frag, `if (${matid} != textureLod(texpaint_nor_undo, picker_sample_tc, 0.0).a) discard;`);
 	}
 }

+ 112 - 112
armorpaint/Sources/MakeMaterial.ts

@@ -8,32 +8,32 @@ class MakeMaterial {
 	static emisUsed = false;
 	static subsUsed = false;
 
-	static getMOut = (): bool => {
-		for (let n of UINodes.getCanvasMaterial().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
+	static get_mout = (): bool => {
+		for (let n of UINodes.get_canvas_material().nodes) if (n.type == "OUTPUT_MATERIAL_PBR") return true;
 		return false;
 	}
 
-	static parseMeshMaterial = () => {
+	static parse_mesh_material = () => {
 		let m = Project.materials[0].data;
 
 		for (let c of m._.shader._.contexts) {
 			if (c.name == "mesh") {
 				array_remove(m._.shader.contexts, c);
 				array_remove(m._.shader._.contexts, c);
-				MakeMaterial.deleteContext(c);
+				MakeMaterial.delete_context(c);
 				break;
 			}
 		}
 
-		if (MakeMesh.layerPassCount > 1) {
+		if (MakeMesh.layer_pass_count > 1) {
 			let i = 0;
 			while (i < m._.shader._.contexts.length) {
 				let c = m._.shader._.contexts[i];
-				for (let j = 1; j < MakeMesh.layerPassCount; ++j) {
+				for (let j = 1; j < MakeMesh.layer_pass_count; ++j) {
 					if (c.name == "mesh" + j) {
 						array_remove(m._.shader.contexts, c);
 						array_remove(m._.shader._.contexts, c);
-						MakeMaterial.deleteContext(c);
+						MakeMaterial.delete_context(c);
 						i--;
 						break;
 					}
@@ -44,7 +44,7 @@ class MakeMaterial {
 			i = 0;
 			while (i < m._.contexts.length) {
 				let c = m._.contexts[i];
-				for (let j = 1; j < MakeMesh.layerPassCount; ++j) {
+				for (let j = 1; j < MakeMesh.layer_pass_count; ++j) {
 					if (c.name == "mesh" + j) {
 						array_remove(m.contexts, c);
 						array_remove(m._.contexts, c);
@@ -59,25 +59,25 @@ class MakeMaterial {
 		let con = MakeMesh.run({ name: "Material", canvas: null });
 		let scon: shader_context_t = shader_context_create(con.data);
 		scon._.override_context = {};
-		if (con.frag.sharedSamplers.length > 0) {
-			let sampler = con.frag.sharedSamplers[0];
+		if (con.frag.shared_samplers.length > 0) {
+			let sampler = con.frag.shared_samplers[0];
 			scon._.override_context.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
 		}
-		if (!Context.raw.textureFilter) {
+		if (!Context.raw.texture_filter) {
 			scon._.override_context.filter = "point";
 		}
 		m._.shader.contexts.push(scon);
 		m._.shader._.contexts.push(scon);
 
-		for (let i = 1; i < MakeMesh.layerPassCount; ++i) {
+		for (let i = 1; i < MakeMesh.layer_pass_count; ++i) {
 			let con = MakeMesh.run({ name: "Material", canvas: null }, i);
 			let scon: shader_context_t = shader_context_create(con.data);
 			scon._.override_context = {};
-			if (con.frag.sharedSamplers.length > 0) {
-				let sampler = con.frag.sharedSamplers[0];
+			if (con.frag.shared_samplers.length > 0) {
+				let sampler = con.frag.shared_samplers[0];
 				scon._.override_context.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
 			}
-			if (!Context.raw.textureFilter) {
+			if (!Context.raw.texture_filter) {
 				scon._.override_context.filter = "point";
 			}
 			m._.shader.contexts.push(scon);
@@ -92,7 +92,7 @@ class MakeMaterial {
 		Context.raw.ddirty = 2;
 
 		///if arm_voxels
-		MakeMaterial.makeVoxel(m);
+		MakeMaterial.make_voxel(m);
 		///end
 
 		///if (krom_direct3d12 || krom_vulkan || krom_metal)
@@ -100,8 +100,8 @@ class MakeMaterial {
 		///end
 	}
 
-	static parseParticleMaterial = () => {
-		let m = Context.raw.particleMaterial;
+	static parse_particle_material = () => {
+		let m = Context.raw.particle_material;
 		let sc: shader_context_t = null;
 		for (let c of m._.shader._.contexts) {
 			if (c.name == "mesh") {
@@ -114,14 +114,14 @@ class MakeMaterial {
 			array_remove(m._.shader._.contexts, sc);
 		}
 		let con = MakeParticle.run({ name: "MaterialParticle", canvas: null });
-		if (sc != null) MakeMaterial.deleteContext(sc);
+		if (sc != null) MakeMaterial.delete_context(sc);
 		sc = shader_context_create(con.data);
 		m._.shader.contexts.push(sc);
 		m._.shader._.contexts.push(sc);
 	}
 
-	static parseMeshPreviewMaterial = (md: material_data_t = null) => {
-		if (!MakeMaterial.getMOut()) return;
+	static parse_mesh_preview_material = (md: material_data_t = null) => {
+		if (!MakeMaterial.get_mout()) return;
 
 		let m = md == null ? Project.materials[0].data : md;
 		let scon: shader_context_t = null;
@@ -137,7 +137,7 @@ class MakeMaterial {
 
 		let mcon: material_context_t = { name: "mesh", bind_textures: [] };
 
-		let sd: TMaterial = { name: "Material", canvas: null };
+		let sd: material_t = { name: "Material", canvas: null };
 		let con = MakeMeshPreview.run(sd, mcon);
 
 		for (let i = 0; i < m._.contexts.length; ++i) {
@@ -147,7 +147,7 @@ class MakeMaterial {
 			}
 		}
 
-		if (scon != null) MakeMaterial.deleteContext(scon);
+		if (scon != null) MakeMaterial.delete_context(scon);
 
 		let compileError = false;
 		let _scon: shader_context_t = shader_context_create(con.data);
@@ -160,7 +160,7 @@ class MakeMaterial {
 	}
 
 	///if arm_voxels
-	static makeVoxel = (m: material_data_t) => {
+	static make_voxel = (m: material_data_t) => {
 		let rebuild = MakeMaterial.heightUsed;
 		if (Config.raw.rp_gi != false && rebuild) {
 			let scon: shader_context_t = null;
@@ -175,13 +175,13 @@ class MakeMaterial {
 	}
 	///end
 
-	static parsePaintMaterial = (bakePreviews = true) => {
-		if (!MakeMaterial.getMOut()) return;
+	static parse_paint_material = (bakePreviews = true) => {
+		if (!MakeMaterial.get_mout()) return;
 
 		if (bakePreviews) {
 			let current = _g2_current;
 			if (current != null) g2_end();
-			MakeMaterial.bakeNodePreviews();
+			MakeMaterial.bake_node_previews();
 			if (current != null) g2_begin(current);
 		}
 
@@ -192,7 +192,7 @@ class MakeMaterial {
 			if (c.name == "paint") {
 				array_remove(m._.shader.contexts, c);
 				array_remove(m._.shader._.contexts, c);
-				if (c != MakeMaterial.defaultScon) MakeMaterial.deleteContext(c);
+				if (c != MakeMaterial.defaultScon) MakeMaterial.delete_context(c);
 				break;
 			}
 		}
@@ -204,7 +204,7 @@ class MakeMaterial {
 			}
 		}
 
-		let sdata: TMaterial = { name: "Material", canvas: UINodes.getCanvasMaterial() };
+		let sdata: material_t = { name: "Material", canvas: UINodes.get_canvas_material() };
 		let tmcon: material_context_t = { name: "paint", bind_textures: [] };
 		let con = MakePaint.run(sdata, tmcon);
 
@@ -227,27 +227,27 @@ class MakeMaterial {
 		if (MakeMaterial.defaultMcon == null) MakeMaterial.defaultMcon = mcon;
 	}
 
-	static bakeNodePreviews = () => {
-		Context.raw.nodePreviewsUsed = [];
-		if (Context.raw.nodePreviews == null) Context.raw.nodePreviews = new Map();
-		MakeMaterial.traverseNodes(UINodes.getCanvasMaterial().nodes, null, []);
-		for (let key of Context.raw.nodePreviews.keys()) {
-			if (Context.raw.nodePreviewsUsed.indexOf(key) == -1) {
-				let image = Context.raw.nodePreviews.get(key);
-				Base.notifyOnNextFrame(function() { image_unload(image); });
-				Context.raw.nodePreviews.delete(key);
+	static bake_node_previews = () => {
+		Context.raw.node_previews_used = [];
+		if (Context.raw.node_previews == null) Context.raw.node_previews = new Map();
+		MakeMaterial.traverse_nodes(UINodes.get_canvas_material().nodes, null, []);
+		for (let key of Context.raw.node_previews.keys()) {
+			if (Context.raw.node_previews_used.indexOf(key) == -1) {
+				let image = Context.raw.node_previews.get(key);
+				Base.notify_on_next_frame(function() { image_unload(image); });
+				Context.raw.node_previews.delete(key);
 			}
 		}
 	}
 
-	static traverseNodes = (nodes: zui_node_t[], group: zui_node_canvas_t, parents: zui_node_t[]) => {
+	static traverse_nodes = (nodes: zui_node_t[], group: zui_node_canvas_t, parents: zui_node_t[]) => {
 		for (let node of nodes) {
-			MakeMaterial.bakeNodePreview(node, group, parents);
+			MakeMaterial.bake_node_preview(node, group, parents);
 			if (node.type == "GROUP") {
-				for (let g of Project.materialGroups) {
+				for (let g of Project.material_groups) {
 					if (g.canvas.name == node.name) {
 						parents.push(node);
-						MakeMaterial.traverseNodes(g.canvas.nodes, g.canvas, parents);
+						MakeMaterial.traverse_nodes(g.canvas.nodes, g.canvas, parents);
 						parents.pop();
 						break;
 					}
@@ -256,49 +256,49 @@ class MakeMaterial {
 		}
 	}
 
-	static bakeNodePreview = (node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]) => {
+	static bake_node_preview = (node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]) => {
 		if (node.type == "BLUR") {
 			let id = ParserMaterial.node_name(node, parents);
-			let image = Context.raw.nodePreviews.get(id);
-			Context.raw.nodePreviewsUsed.push(id);
-			let resX = Math.floor(Config.getTextureResX() / 4);
-			let resY = Math.floor(Config.getTextureResY() / 4);
+			let image = Context.raw.node_previews.get(id);
+			Context.raw.node_previews_used.push(id);
+			let resX = Math.floor(Config.get_texture_res_x() / 4);
+			let resY = Math.floor(Config.get_texture_res_y() / 4);
 			if (image == null || image.width != resX || image.height != resY) {
 				if (image != null) image_unload(image);
 				image = image_create_render_target(resX, resY);
-				Context.raw.nodePreviews.set(id, image);
+				Context.raw.node_previews.set(id, image);
 			}
 
 			ParserMaterial.blur_passthrough = true;
-			UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
+			UtilRender.make_node_preview(UINodes.get_canvas_material(), node, image, group, parents);
 			ParserMaterial.blur_passthrough = false;
 		}
 		else if (node.type == "DIRECT_WARP") {
 			let id = ParserMaterial.node_name(node, parents);
-			let image = Context.raw.nodePreviews.get(id);
-			Context.raw.nodePreviewsUsed.push(id);
-			let resX = Math.floor(Config.getTextureResX());
-			let resY = Math.floor(Config.getTextureResY());
+			let image = Context.raw.node_previews.get(id);
+			Context.raw.node_previews_used.push(id);
+			let resX = Math.floor(Config.get_texture_res_x());
+			let resY = Math.floor(Config.get_texture_res_y());
 			if (image == null || image.width != resX || image.height != resY) {
 				if (image != null) image_unload(image);
 				image = image_create_render_target(resX, resY);
-				Context.raw.nodePreviews.set(id, image);
+				Context.raw.node_previews.set(id, image);
 			}
 
 			ParserMaterial.warp_passthrough = true;
-			UtilRender.makeNodePreview(UINodes.getCanvasMaterial(), node, image, group, parents);
+			UtilRender.make_node_preview(UINodes.get_canvas_material(), node, image, group, parents);
 			ParserMaterial.warp_passthrough = false;
 		}
 		else if (node.type == "BAKE_CURVATURE") {
 			let id = ParserMaterial.node_name(node, parents);
-			let image = Context.raw.nodePreviews.get(id);
-			Context.raw.nodePreviewsUsed.push(id);
-			let resX = Math.floor(Config.getTextureResX());
-			let resY = Math.floor(Config.getTextureResY());
+			let image = Context.raw.node_previews.get(id);
+			Context.raw.node_previews_used.push(id);
+			let resX = Math.floor(Config.get_texture_res_x());
+			let resY = Math.floor(Config.get_texture_res_y());
 			if (image == null || image.width != resX || image.height != resY) {
 				if (image != null) image_unload(image);
 				image = image_create_render_target(resX, resY, tex_format_t.R8);
-				Context.raw.nodePreviews.set(id, image);
+				Context.raw.node_previews.set(id, image);
 			}
 
 			if (RenderPathPaint.liveLayer == null) {
@@ -307,31 +307,31 @@ class MakeMaterial {
 
 			let _space = UIHeader.worktab.position;
 			let _tool = Context.raw.tool;
-			let _bakeType = Context.raw.bakeType;
-			UIHeader.worktab.position = SpaceType.Space3D;
-			Context.raw.tool = WorkspaceTool.ToolBake;
-			Context.raw.bakeType = BakeType.BakeCurvature;
+			let _bakeType = Context.raw.bake_type;
+			UIHeader.worktab.position = space_type_t.SPACE3D;
+			Context.raw.tool = workspace_tool_t.BAKE;
+			Context.raw.bake_type = bake_type_t.CURVATURE;
 
 			ParserMaterial.bake_passthrough = true;
 			ParserMaterial.start_node = node;
 			ParserMaterial.start_group = group;
 			ParserMaterial.start_parents = parents;
-			MakeMaterial.parsePaintMaterial(false);
+			MakeMaterial.parse_paint_material(false);
 			ParserMaterial.bake_passthrough = false;
 			ParserMaterial.start_node = null;
 			ParserMaterial.start_group = null;
 			ParserMaterial.start_parents = null;
 			Context.raw.pdirty = 1;
-			RenderPathPaint.useLiveLayer(true);
-			RenderPathPaint.commandsPaint(false);
+			RenderPathPaint.use_live_layer(true);
+			RenderPathPaint.commands_paint(false);
 			RenderPathPaint.dilate(true, false);
-			RenderPathPaint.useLiveLayer(false);
+			RenderPathPaint.use_live_layer(false);
 			Context.raw.pdirty = 0;
 
 			UIHeader.worktab.position = _space;
 			Context.raw.tool = _tool;
-			Context.raw.bakeType = _bakeType;
-			MakeMaterial.parsePaintMaterial(false);
+			Context.raw.bake_type = _bakeType;
+			MakeMaterial.parse_paint_material(false);
 
 			let rts = render_path_render_targets;
 			let texpaint_live = rts.get("texpaint_live");
@@ -342,9 +342,9 @@ class MakeMaterial {
 		}
 	}
 
-	static parseNodePreviewMaterial = (node: zui_node_t, group: zui_node_canvas_t = null, parents: zui_node_t[] = null): { scon: shader_context_t, mcon: material_context_t } => {
+	static parse_node_preview_material = (node: zui_node_t, group: zui_node_canvas_t = null, parents: zui_node_t[] = null): { scon: shader_context_t, mcon: material_context_t } => {
 		if (node.outputs.length == 0) return null;
-		let sdata: TMaterial = { name: "Material", canvas: UINodes.getCanvasMaterial() };
+		let sdata: material_t = { name: "Material", canvas: UINodes.get_canvas_material() };
 		let mcon_raw: material_context_t = { name: "mesh", bind_textures: [] };
 		let con = MakeNodePreview.run(sdata, mcon_raw, node, group, parents);
 		let compileError = false;
@@ -357,66 +357,66 @@ class MakeMaterial {
 		return { scon: scon, mcon: mcon };
 	}
 
-	static parseBrush = () => {
+	static parse_brush = () => {
 		ParserLogic.parse(Context.raw.brush.canvas);
 	}
 
-	static blendMode = (frag: NodeShaderRaw, blending: i32, cola: string, colb: string, opac: string): string => {
-		if (blending == BlendType.BlendMix) {
+	static blend_mode = (frag: NodeShaderRaw, blending: i32, cola: string, colb: string, opac: string): string => {
+		if (blending == blend_type_t.MIX) {
 			return `mix(${cola}, ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendDarken) {
+		else if (blending == blend_type_t.DARKEN) {
 			return `mix(${cola}, min(${cola}, ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendMultiply) {
+		else if (blending == blend_type_t.MULTIPLY) {
 			return `mix(${cola}, ${cola} * ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendBurn) {
+		else if (blending == blend_type_t.BURN) {
 			return `mix(${cola}, vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - ${cola}) / ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendLighten) {
+		else if (blending == blend_type_t.LIGHTEN) {
 			return `max(${cola}, ${colb} * ${opac})`;
 		}
-		else if (blending == BlendType.BlendScreen) {
+		else if (blending == blend_type_t.SCREEN) {
 			return `(vec3(1.0, 1.0, 1.0) - (vec3(1.0 - ${opac}, 1.0 - ${opac}, 1.0 - ${opac}) + ${opac} * (vec3(1.0, 1.0, 1.0) - ${colb})) * (vec3(1.0, 1.0, 1.0) - ${cola}))`;
 		}
-		else if (blending == BlendType.BlendDodge) {
+		else if (blending == blend_type_t.DODGE) {
 			return `mix(${cola}, ${cola} / (vec3(1.0, 1.0, 1.0) - ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendAdd) {
+		else if (blending == blend_type_t.ADD) {
 			return `mix(${cola}, ${cola} + ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendOverlay) {
+		else if (blending == blend_type_t.OVERLAY) {
 			return `mix(${cola}, vec3(
 				${cola}.r < 0.5 ? 2.0 * ${cola}.r * ${colb}.r : 1.0 - 2.0 * (1.0 - ${cola}.r) * (1.0 - ${colb}.r),
 				${cola}.g < 0.5 ? 2.0 * ${cola}.g * ${colb}.g : 1.0 - 2.0 * (1.0 - ${cola}.g) * (1.0 - ${colb}.g),
 				${cola}.b < 0.5 ? 2.0 * ${cola}.b * ${colb}.b : 1.0 - 2.0 * (1.0 - ${cola}.b) * (1.0 - ${colb}.b)
 			), ${opac})`;
 		}
-		else if (blending == BlendType.BlendSoftLight) {
+		else if (blending == blend_type_t.SOFT_LIGHT) {
 			return `((1.0 - ${opac}) * ${cola} + ${opac} * ((vec3(1.0, 1.0, 1.0) - ${cola}) * ${colb} * ${cola} + ${cola} * (vec3(1.0, 1.0, 1.0) - (vec3(1.0, 1.0, 1.0) - ${colb}) * (vec3(1.0, 1.0, 1.0) - ${cola}))))`;
 		}
-		else if (blending == BlendType.BlendLinearLight) {
+		else if (blending == blend_type_t.LINEAR_LIGHT) {
 			return `(${cola} + ${opac} * (vec3(2.0, 2.0, 2.0) * (${colb} - vec3(0.5, 0.5, 0.5))))`;
 		}
-		else if (blending == BlendType.BlendDifference) {
+		else if (blending == blend_type_t.DIFFERENCE) {
 			return `mix(${cola}, abs(${cola} - ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendSubtract) {
+		else if (blending == blend_type_t.SUBTRACT) {
 			return `mix(${cola}, ${cola} - ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendDivide) {
+		else if (blending == blend_type_t.DIVIDE) {
 			return `vec3(1.0 - ${opac}, 1.0 - ${opac}, 1.0 - ${opac}) * ${cola} + vec3(${opac}, ${opac}, ${opac}) * ${cola} / ${colb}`;
 		}
-		else if (blending == BlendType.BlendHue) {
+		else if (blending == blend_type_t.HUE) {
 			NodeShader.add_function(frag, ShaderFunctions.str_hue_sat);
 			return `mix(${cola}, hsv_to_rgb(vec3(rgb_to_hsv(${colb}).r, rgb_to_hsv(${cola}).g, rgb_to_hsv(${cola}).b)), ${opac})`;
 		}
-		else if (blending == BlendType.BlendSaturation) {
+		else if (blending == blend_type_t.SATURATION) {
 			NodeShader.add_function(frag, ShaderFunctions.str_hue_sat);
 			return `mix(${cola}, hsv_to_rgb(vec3(rgb_to_hsv(${cola}).r, rgb_to_hsv(${colb}).g, rgb_to_hsv(${cola}).b)), ${opac})`;
 		}
-		else if (blending == BlendType.BlendColor) {
+		else if (blending == blend_type_t.COLOR) {
 			NodeShader.add_function(frag, ShaderFunctions.str_hue_sat);
 			return `mix(${cola}, hsv_to_rgb(vec3(rgb_to_hsv(${colb}).r, rgb_to_hsv(${colb}).g, rgb_to_hsv(${cola}).b)), ${opac})`;
 		}
@@ -426,47 +426,47 @@ class MakeMaterial {
 		}
 	}
 
-	static blendModeMask = (frag: NodeShaderRaw, blending: i32, cola: string, colb: string, opac: string): string => {
-		if (blending == BlendType.BlendMix) {
+	static blend_mode_mask = (frag: NodeShaderRaw, blending: i32, cola: string, colb: string, opac: string): string => {
+		if (blending == blend_type_t.MIX) {
 			return `mix(${cola}, ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendDarken) {
+		else if (blending == blend_type_t.DARKEN) {
 			return `mix(${cola}, min(${cola}, ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendMultiply) {
+		else if (blending == blend_type_t.MULTIPLY) {
 			return `mix(${cola}, ${cola} * ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendBurn) {
+		else if (blending == blend_type_t.BURN) {
 			return `mix(${cola}, 1.0 - (1.0 - ${cola}) / ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendLighten) {
+		else if (blending == blend_type_t.LIGHTEN) {
 			return `max(${cola}, ${colb} * ${opac})`;
 		}
-		else if (blending == BlendType.BlendScreen) {
+		else if (blending == blend_type_t.SCREEN) {
 			return `(1.0 - ((1.0 - ${opac}) + ${opac} * (1.0 - ${colb})) * (1.0 - ${cola}))`;
 		}
-		else if (blending == BlendType.BlendDodge) {
+		else if (blending == blend_type_t.DODGE) {
 			return `mix(${cola}, ${cola} / (1.0 - ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendAdd) {
+		else if (blending == blend_type_t.ADD) {
 			return `mix(${cola}, ${cola} + ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendOverlay) {
+		else if (blending == blend_type_t.OVERLAY) {
 			return `mix(${cola}, ${cola} < 0.5 ? 2.0 * ${cola} * ${colb} : 1.0 - 2.0 * (1.0 - ${cola}) * (1.0 - ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendSoftLight) {
+		else if (blending == blend_type_t.SOFT_LIGHT) {
 			return `((1.0 - ${opac}) * ${cola} + ${opac} * ((1.0 - ${cola}) * ${colb} * ${cola} + ${cola} * (1.0 - (1.0 - ${colb}) * (1.0 - ${cola}))))`;
 		}
-		else if (blending == BlendType.BlendLinearLight) {
+		else if (blending == blend_type_t.LINEAR_LIGHT) {
 			return `(${cola} + ${opac} * (2.0 * (${colb} - 0.5)))`;
 		}
-		else if (blending == BlendType.BlendDifference) {
+		else if (blending == blend_type_t.DIFFERENCE) {
 			return `mix(${cola}, abs(${cola} - ${colb}), ${opac})`;
 		}
-		else if (blending == BlendType.BlendSubtract) {
+		else if (blending == blend_type_t.SUBTRACT) {
 			return `mix(${cola}, ${cola} - ${colb}, ${opac})`;
 		}
-		else if (blending == BlendType.BlendDivide) {
+		else if (blending == blend_type_t.DIVIDE) {
 			return `(1.0 - ${opac}) * ${cola} + ${opac} * ${cola} / ${colb}`;
 		}
 		else { // BlendHue, BlendSaturation, BlendColor, BlendValue
@@ -474,18 +474,18 @@ class MakeMaterial {
 		}
 	}
 
-	static getDisplaceStrength = (): f32 => {
-		let sc = Context.mainObject().base.transform.scale.x;
+	static get_displace_strength = (): f32 => {
+		let sc = Context.main_object().base.transform.scale.x;
 		return Config.raw.displace_strength * 0.02 * sc;
 	}
 
-	static voxelgiHalfExtents = (): string => {
-		let ext = Context.raw.vxaoExt;
+	static voxelgi_half_extents = (): string => {
+		let ext = Context.raw.vxao_ext;
 		return `const vec3 voxelgiHalfExtents = vec3(${ext}, ${ext}, ${ext});`;
 	}
 
-	static deleteContext = (c: shader_context_t) => {
-		Base.notifyOnNextFrame(() => { // Ensure pipeline is no longer in use
+	static delete_context = (c: shader_context_t) => {
+		Base.notify_on_next_frame(() => { // Ensure pipeline is no longer in use
 			shader_context_delete(c);
 		});
 	}

+ 68 - 68
armorpaint/Sources/MakeMesh.ts

@@ -1,15 +1,15 @@
 
 class MakeMesh {
 
-	static layerPassCount = 1;
+	static layer_pass_count = 1;
 
-	static run = (data: TMaterial, layerPass = 0): NodeShaderContextRaw => {
+	static run = (data: material_t, layerPass = 0): NodeShaderContextRaw => {
 		let context_id = layerPass == 0 ? "mesh" : "mesh" + layerPass;
 		let con_mesh = NodeShaderContext.create(data, {
 			name: context_id,
 			depth_write: layerPass == 0 ? true : false,
 			compare_mode: layerPass == 0 ? "less" : "equal",
-			cull_mode: (Context.raw.cullBackfaces || layerPass > 0) ? "clockwise" : "none",
+			cull_mode: (Context.raw.cull_backfaces || layerPass > 0) ? "clockwise" : "none",
 			vertex_elements: [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}],
 			color_attachments: ["RGBA64", "RGBA64", "RGBA64"],
 			depth_attachment: "DEPTH32"
@@ -27,22 +27,22 @@ class MakeMesh {
 		vert.wposition = true;
 
 		let textureCount = 0;
-		let displaceStrength = MakeMaterial.getDisplaceStrength();
+		let displaceStrength = MakeMaterial.get_displace_strength();
 		if (MakeMaterial.heightUsed && displaceStrength > 0.0) {
 			vert.n = true;
 			NodeShader.write(vert, 'float height = 0.0;');
 			let numLayers = 0;
 			for (let l of Project.layers) {
-				if (!SlotLayer.isVisible(l) || !l.paintHeight || !SlotLayer.isLayer(l)) continue;
+				if (!SlotLayer.is_visible(l) || !l.paintHeight || !SlotLayer.is_layer(l)) continue;
 				if (numLayers > 16) break;
 				numLayers++;
 				textureCount++;
 				NodeShader.add_uniform(vert, 'sampler2D texpaint_pack_vert' + l.id, '_texpaint_pack_vert' + l.id);
 				NodeShader.write(vert, 'height += textureLod(texpaint_pack_vert' + l.id + ', tex, 0.0).a;');
-				let masks = SlotLayer.getMasks(l);
+				let masks = SlotLayer.get_masks(l);
 				if (masks != null) {
 					for (let m of masks) {
-						if (!SlotLayer.isVisible(m)) continue;
+						if (!SlotLayer.is_visible(m)) continue;
 						textureCount++;
 						NodeShader.add_uniform(vert, 'sampler2D texpaint_vert' + m.id, '_texpaint_vert' + m.id);
 						NodeShader.write(vert, 'height *= textureLod(texpaint_vert' + m.id + ', tex, 0.0).r;');
@@ -64,9 +64,9 @@ class MakeMesh {
 
 		NodeShader.add_out(frag, 'vec4 fragColor[3]');
 		frag.n = true;
-		NodeShader.add_function(frag, ShaderFunctions.str_packFloatInt16);
+		NodeShader.add_function(frag, ShaderFunctions.str_pack_float_int16);
 
-		if (Context.raw.tool == WorkspaceTool.ToolColorId) {
+		if (Context.raw.tool == workspace_tool_t.COLORID) {
 			textureCount++;
 			NodeShader.add_uniform(frag, 'sampler2D texcolorid', '_texcolorid');
 			NodeShader.write(frag, 'fragColor[0] = vec4(n.xy, 1.0, packFloatInt16(0.0, uint(0)));');
@@ -74,8 +74,8 @@ class MakeMesh {
 			NodeShader.write(frag, 'fragColor[1] = vec4(idcol.rgb, 1.0);'); // occ
 		}
 		else {
-			NodeShader.add_function(frag, ShaderFunctions.str_octahedronWrap);
-			NodeShader.add_function(frag, ShaderFunctions.str_cotangentFrame);
+			NodeShader.add_function(frag, ShaderFunctions.str_octahedron_wrap);
+			NodeShader.add_function(frag, ShaderFunctions.str_cotangent_frame);
 			if (layerPass > 0) {
 				NodeShader.add_uniform(frag, 'sampler2D gbuffer0');
 				NodeShader.add_uniform(frag, 'sampler2D gbuffer1');
@@ -118,20 +118,20 @@ class MakeMesh {
 				NodeShader.write(frag, 'float height3 = 0.0;');
 			}
 
-			if (Context.raw.drawWireframe) {
+			if (Context.raw.draw_wireframe) {
 				textureCount++;
 				NodeShader.add_uniform(frag, 'sampler2D texuvmap', '_texuvmap');
 			}
 
-			if (Context.raw.viewportMode == ViewportMode.ViewMask && SlotLayer.getMasks(Context.raw.layer) != null) {
-				for (let m of SlotLayer.getMasks(Context.raw.layer)) {
-					if (!SlotLayer.isVisible(m)) continue;
+			if (Context.raw.viewport_mode == viewport_mode_t.MASK && SlotLayer.get_masks(Context.raw.layer) != null) {
+				for (let m of SlotLayer.get_masks(Context.raw.layer)) {
+					if (!SlotLayer.is_visible(m)) continue;
 					textureCount++;
 					NodeShader.add_uniform(frag, 'sampler2D texpaint_view_mask' + m.id, '_texpaint' + Project.layers.indexOf(m));
 				}
 			}
 
-			if (Context.raw.viewportMode == ViewportMode.ViewLit && Context.raw.renderMode == RenderMode.RenderForward) {
+			if (Context.raw.viewport_mode == viewport_mode_t.LIT && Context.raw.render_mode == render_mode_t.FORWARD) {
 				textureCount += 4;
 				NodeShader.add_uniform(frag, 'sampler2D senvmapBrdf', "$brdf.k");
 				NodeShader.add_uniform(frag, 'sampler2D senvmapRadiance', '_envmap_radiance');
@@ -140,34 +140,34 @@ class MakeMesh {
 			}
 
 			// Get layers for this pass
-			MakeMesh.layerPassCount = 1;
+			MakeMesh.layer_pass_count = 1;
 			let layers: SlotLayerRaw[] = [];
 			let startCount = textureCount;
-			let isMaterialTool = Context.raw.tool == WorkspaceTool.ToolMaterial;
+			let isMaterialTool = Context.raw.tool == workspace_tool_t.MATERIAL;
 			for (let l of Project.layers) {
 				if (isMaterialTool && l != Context.raw.layer) continue;
-				if (!SlotLayer.isLayer(l) || !SlotLayer.isVisible(l)) continue;
+				if (!SlotLayer.is_layer(l) || !SlotLayer.is_visible(l)) continue;
 
 				let count = 3;
-				let masks = SlotLayer.getMasks(l);
+				let masks = SlotLayer.get_masks(l);
 				if (masks != null) count += masks.length;
 				textureCount += count;
-				if (textureCount >= MakeMesh.getMaxTextures()) {
+				if (textureCount >= MakeMesh.get_max_textures()) {
 					textureCount = startCount + count + 3; // gbuffer0_copy, gbuffer1_copy, gbuffer2_copy
-					MakeMesh.layerPassCount++;
+					MakeMesh.layer_pass_count++;
 				}
-				if (layerPass == MakeMesh.layerPassCount - 1) {
+				if (layerPass == MakeMesh.layer_pass_count - 1) {
 					layers.push(l);
 				}
 			}
 
-			let lastPass = layerPass == MakeMesh.layerPassCount - 1;
+			let lastPass = layerPass == MakeMesh.layer_pass_count - 1;
 
 			for (let l of layers) {
-				if (SlotLayer.getObjectMask(l) > 0) {
+				if (SlotLayer.get_object_mask(l) > 0) {
 					NodeShader.add_uniform(frag, 'int uid', '_uid');
-					if (SlotLayer.getObjectMask(l) > Project.paintObjects.length) { // Atlas
-						let visibles = Project.getAtlasObjects(SlotLayer.getObjectMask(l));
+					if (SlotLayer.get_object_mask(l) > Project.paint_objects.length) { // Atlas
+						let visibles = Project.get_atlas_objects(SlotLayer.get_object_mask(l));
 						NodeShader.write(frag, 'if (');
 						for (let i = 0; i < visibles.length; ++i) {
 							if (i > 0) NodeShader.write(frag, ' || ');
@@ -176,7 +176,7 @@ class MakeMesh {
 						NodeShader.write(frag, ') {');
 					}
 					else { // Object mask
-						let uid = Project.paintObjects[SlotLayer.getObjectMask(l) - 1].base.uid;
+						let uid = Project.paint_objects[SlotLayer.get_object_mask(l) - 1].base.uid;
 						NodeShader.write(frag, `if (${uid} == uid) {`);
 					}
 				}
@@ -190,11 +190,11 @@ class MakeMesh {
 				// }
 				// ///end
 
-				let masks = SlotLayer.getMasks(l);
+				let masks = SlotLayer.get_masks(l);
 				if (masks != null) {
 					let hasVisible = false;
 					for (let m of masks) {
-						if (SlotLayer.isVisible(m)) {
+						if (SlotLayer.is_visible(m)) {
 							hasVisible = true;
 							break;
 						}
@@ -203,19 +203,19 @@ class MakeMesh {
 						let texpaint_mask = 'texpaint_mask' + l.id;
 						NodeShader.write(frag, `float ${texpaint_mask} = 0.0;`);
 						for (let m of masks) {
-							if (!SlotLayer.isVisible(m)) continue;
+							if (!SlotLayer.is_visible(m)) continue;
 							NodeShader.add_shared_sampler(frag, 'sampler2D texpaint' + m.id);
 							NodeShader.write(frag, '{'); // Group mask is sampled across multiple layers
 							NodeShader.write(frag, 'float texpaint_mask_sample' + m.id + ' = textureLodShared(texpaint' + m.id + ', texCoord, 0.0).r;');
-							NodeShader.write(frag, `${texpaint_mask} = ` + MakeMaterial.blendModeMask(frag, m.blending, `${texpaint_mask}`, 'texpaint_mask_sample' + m.id, 'float(' + SlotLayer.getOpacity(m) + ')') + ';');
+							NodeShader.write(frag, `${texpaint_mask} = ` + MakeMaterial.blend_mode_mask(frag, m.blending, `${texpaint_mask}`, 'texpaint_mask_sample' + m.id, 'float(' + SlotLayer.get_opacity(m) + ')') + ';');
 							NodeShader.write(frag, '}');
 						}
 						NodeShader.write(frag, `texpaint_opac *= clamp(${texpaint_mask}, 0.0, 1.0);`);
 					}
 				}
 
-				if (SlotLayer.getOpacity(l) < 1) {
-					NodeShader.write(frag, `texpaint_opac *= ${SlotLayer.getOpacity(l)};`);
+				if (SlotLayer.get_opacity(l) < 1) {
+					NodeShader.write(frag, `texpaint_opac *= ${SlotLayer.get_opacity(l)};`);
 				}
 
 				if (l.paintBase) {
@@ -223,7 +223,7 @@ class MakeMesh {
 						NodeShader.write(frag, 'basecol = texpaint_sample.rgb * texpaint_opac;');
 					}
 					else {
-						NodeShader.write(frag, 'basecol = ' + MakeMaterial.blendMode(frag, l.blending, 'basecol', 'texpaint_sample.rgb', 'texpaint_opac') + ';');
+						NodeShader.write(frag, 'basecol = ' + MakeMaterial.blend_mode(frag, l.blending, 'basecol', 'texpaint_sample.rgb', 'texpaint_opac') + ';');
 					}
 				}
 
@@ -277,12 +277,12 @@ class MakeMesh {
 					}
 				}
 
-				if (SlotLayer.getObjectMask(l) > 0) {
+				if (SlotLayer.get_object_mask(l) > 0) {
 					NodeShader.write(frag, '}');
 				}
 			}
 
-			if (lastPass && Context.raw.drawTexels) {
+			if (lastPass && Context.raw.draw_texels) {
 				NodeShader.add_uniform(frag, 'vec2 texpaintSize', '_texpaintSize');
 				NodeShader.write(frag, 'vec2 texel0 = texCoord * texpaintSize * 0.01;');
 				NodeShader.write(frag, 'vec2 texel1 = texCoord * texpaintSize * 0.1;');
@@ -292,7 +292,7 @@ class MakeMesh {
 				NodeShader.write(frag, 'basecol *= max(float(mod(int(texel2.x), 2.0) == mod(int(texel2.y), 2.0)), 0.9);');
 			}
 
-			if (lastPass && Context.raw.drawWireframe) {
+			if (lastPass && Context.raw.draw_wireframe) {
 				NodeShader.write(frag, 'basecol *= 1.0 - textureLod(texuvmap, texCoord, 0.0).r;');
 			}
 
@@ -320,7 +320,7 @@ class MakeMesh {
 				return con_mesh;
 			}
 
-			frag.vVec = true;
+			frag.vvec = true;
 			///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 			NodeShader.write(frag, 'mat3 TBN = cotangentFrame(n, vVec, texCoord);');
 			///else
@@ -330,31 +330,31 @@ class MakeMesh {
 			NodeShader.write(frag, 'n.y = -n.y;');
 			NodeShader.write(frag, 'n = normalize(mul(n, TBN));');
 
-			if (Context.raw.viewportMode == ViewportMode.ViewLit || Context.raw.viewportMode == ViewportMode.ViewPathTrace) {
+			if (Context.raw.viewport_mode == viewport_mode_t.LIT || Context.raw.viewport_mode == viewport_mode_t.PATH_TRACE) {
 				NodeShader.write(frag, 'basecol = pow(basecol, vec3(2.2, 2.2, 2.2));');
 
-				if (Context.raw.viewportShader != null) {
-					let color = Context.raw.viewportShader(frag);
+				if (Context.raw.viewport_shader != null) {
+					let color = Context.raw.viewport_shader(frag);
 					NodeShader.write(frag, `fragColor[1] = vec4(${color}, 1.0);`);
 				}
-				else if (Context.raw.renderMode == RenderMode.RenderForward && Context.raw.viewportMode != ViewportMode.ViewPathTrace) {
+				else if (Context.raw.render_mode == render_mode_t.FORWARD && Context.raw.viewport_mode != viewport_mode_t.PATH_TRACE) {
 					frag.wposition = true;
 					NodeShader.write(frag, 'vec3 albedo = mix(basecol, vec3(0.0, 0.0, 0.0), metallic);');
 					NodeShader.write(frag, 'vec3 f0 = mix(vec3(0.04, 0.04, 0.04), basecol, metallic);');
-					frag.vVec = true;
+					frag.vvec = true;
 					NodeShader.write(frag, 'float dotNV = max(0.0, dot(n, vVec));');
 					NodeShader.write(frag, 'vec2 envBRDF = texelFetch(senvmapBrdf, ivec2(vec2(roughness, 1.0 - dotNV) * 256.0), 0).xy;');
 					NodeShader.add_uniform(frag, 'int envmapNumMipmaps', '_envmap_num_mipmaps');
 					NodeShader.add_uniform(frag, 'vec4 envmapData', '_envmapData'); // angle, sin(angle), cos(angle), strength
 					NodeShader.write(frag, 'vec3 wreflect = reflect(-vVec, n);');
 					NodeShader.write(frag, 'float envlod = roughness * float(envmapNumMipmaps);');
-					NodeShader.add_function(frag, ShaderFunctions.str_envMapEquirect);
+					NodeShader.add_function(frag, ShaderFunctions.str_envmap_equirect);
 					NodeShader.write(frag, 'vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(wreflect, envmapData.x), envlod).rgb;');
 					NodeShader.add_uniform(frag, 'vec3 lightArea0', '_light_area0');
 					NodeShader.add_uniform(frag, 'vec3 lightArea1', '_light_area1');
 					NodeShader.add_uniform(frag, 'vec3 lightArea2', '_light_area2');
 					NodeShader.add_uniform(frag, 'vec3 lightArea3', '_light_area3');
-					NodeShader.add_function(frag, ShaderFunctions.str_ltcEvaluate);
+					NodeShader.add_function(frag, ShaderFunctions.str_ltc_evaluate);
 					NodeShader.add_uniform(frag, 'vec3 lightPos', '_point_pos');
 					NodeShader.add_uniform(frag, 'vec3 lightColor', '_point_color');
 					// NodeShader.write(frag, 'float dotNL = max(dot(n, normalize(lightPos - wposition)), 0.0);');
@@ -376,7 +376,7 @@ class MakeMesh {
 					NodeShader.write(frag, 'direct *= lightColor * (1.0 / (ldist * ldist));');
 
 					NodeShader.add_uniform(frag, 'vec4 shirr[7]', '_envmap_irradiance');
-					NodeShader.add_function(frag, ShaderFunctions.str_shIrradiance);
+					NodeShader.add_function(frag, ShaderFunctions.str_sh_irradiance);
 					NodeShader.write(frag, 'vec3 indirect = albedo * (shIrradiance(vec3(n.x * envmapData.z - n.y * envmapData.y, n.x * envmapData.y + n.y * envmapData.z, n.z), shirr) / 3.14159265);');
 					NodeShader.write(frag, 'indirect += prefilteredColor * (f0 * envBRDF.x + envBRDF.y) * 1.5;');
 					NodeShader.write(frag, 'indirect *= envmapData.w * occlusion;');
@@ -387,43 +387,43 @@ class MakeMesh {
 					NodeShader.write(frag, 'fragColor[1] = vec4(basecol, occlusion);');
 				}
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewBaseColor && Context.raw.layer.paintBase) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.BASE_COLOR && Context.raw.layer.paintBase) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(basecol, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewNormalMap && Context.raw.layer.paintNor) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.NORMAL_MAP && Context.raw.layer.paintNor) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(ntex.rgb, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewOcclusion && Context.raw.layer.paintOcc) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.OCCLUSION && Context.raw.layer.paintOcc) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(occlusion, occlusion, occlusion), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewRoughness && Context.raw.layer.paintRough) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.ROUGHNESS && Context.raw.layer.paintRough) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(roughness, roughness, roughness), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewMetallic && Context.raw.layer.paintMet) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.METALLIC && Context.raw.layer.paintMet) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(metallic, metallic, metallic), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewOpacity && Context.raw.layer.paintOpac) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.OPACITY && Context.raw.layer.paintOpac) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(texpaint_sample.a, texpaint_sample.a, texpaint_sample.a), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewHeight && Context.raw.layer.paintHeight) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.HEIGHT && Context.raw.layer.paintHeight) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(height, height, height), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewEmission) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.EMISSION) {
 				NodeShader.write(frag, 'float emis = int(matid * 255.0) % 3 == 1 ? 1.0 : 0.0;');
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(emis, emis, emis), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewSubsurface) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.SUBSURFACE) {
 				NodeShader.write(frag, 'float subs = int(matid * 255.0) % 3 == 2 ? 1.0 : 0.0;');
 				NodeShader.write(frag, 'fragColor[1] = vec4(vec3(subs, subs, subs), 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewTexCoord) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.TEXCOORD) {
 				NodeShader.write(frag, 'fragColor[1] = vec4(texCoord, 0.0, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewObjectNormal) {
-				frag.nAttr = true;
+			else if (Context.raw.viewport_mode == viewport_mode_t.OBJECT_NORMAL) {
+				frag.nattr = true;
 				NodeShader.write(frag, 'fragColor[1] = vec4(nAttr, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewMaterialID) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.MATERIAL_ID) {
 				NodeShader.add_shared_sampler(frag, 'sampler2D texpaint_nor' + Context.raw.layer.id);
 				NodeShader.add_uniform(frag, 'vec2 texpaintSize', '_texpaintSize');
 				NodeShader.write(frag, 'float sample_matid = texelFetch(texpaint_nor' + Context.raw.layer.id + ', ivec2(texCoord * texpaintSize), 0).a + 1.0 / 255.0;');
@@ -432,7 +432,7 @@ class MakeMesh {
 				NodeShader.write(frag, 'float matid_b = fract(sin(dot(vec2(sample_matid, sample_matid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);');
 				NodeShader.write(frag, 'fragColor[1] = vec4(matid_r, matid_g, matid_b, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewObjectID) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.OBJECT_ID) {
 				NodeShader.add_uniform(frag, 'float objectId', '_objectId');
 				NodeShader.write(frag, 'float obid = objectId + 1.0 / 255.0;');
 				NodeShader.write(frag, 'float id_r = fract(sin(dot(vec2(obid, obid * 20.0), vec2(12.9898, 78.233))) * 43758.5453);');
@@ -440,16 +440,16 @@ class MakeMesh {
 				NodeShader.write(frag, 'float id_b = fract(sin(dot(vec2(obid, obid * 40.0), vec2(12.9898, 78.233))) * 43758.5453);');
 				NodeShader.write(frag, 'fragColor[1] = vec4(id_r, id_g, id_b, 1.0);');
 			}
-			else if (Context.raw.viewportMode == ViewportMode.ViewMask && (SlotLayer.getMasks(Context.raw.layer) != null || SlotLayer.isMask(Context.raw.layer))) {
-				if (SlotLayer.isMask(Context.raw.layer)) {
+			else if (Context.raw.viewport_mode == viewport_mode_t.MASK && (SlotLayer.get_masks(Context.raw.layer) != null || SlotLayer.is_mask(Context.raw.layer))) {
+				if (SlotLayer.is_mask(Context.raw.layer)) {
 					NodeShader.write(frag, 'float mask_view = textureLodShared(texpaint' + Context.raw.layer.id + ', texCoord, 0.0).r;');
 				}
 				else {
 					NodeShader.write(frag, 'float mask_view = 0.0;');
-					for (let m of SlotLayer.getMasks(Context.raw.layer)) {
-						if (!SlotLayer.isVisible(m)) continue;
+					for (let m of SlotLayer.get_masks(Context.raw.layer)) {
+						if (!SlotLayer.is_visible(m)) continue;
 						NodeShader.write(frag, 'float mask_sample' + m.id + ' = textureLodShared(texpaint_view_mask' + m.id + ', texCoord, 0.0).r;');
-						NodeShader.write(frag, 'mask_view = ' + MakeMaterial.blendModeMask(frag, m.blending, 'mask_view', 'mask_sample' + m.id, 'float(' + SlotLayer.getOpacity(m) + ')') + ';');
+						NodeShader.write(frag, 'mask_view = ' + MakeMaterial.blend_mode_mask(frag, m.blending, 'mask_view', 'mask_sample' + m.id, 'float(' + SlotLayer.get_opacity(m) + ')') + ';');
 					}
 				}
 				NodeShader.write(frag, 'fragColor[1] = vec4(mask_view, mask_view, mask_view, 1.0);');
@@ -458,7 +458,7 @@ class MakeMesh {
 				NodeShader.write(frag, 'fragColor[1] = vec4(1.0, 0.0, 1.0, 1.0);'); // Pink
 			}
 
-			if (Context.raw.viewportMode != ViewportMode.ViewLit && Context.raw.viewportMode != ViewportMode.ViewPathTrace) {
+			if (Context.raw.viewport_mode != viewport_mode_t.LIT && Context.raw.viewport_mode != viewport_mode_t.PATH_TRACE) {
 				NodeShader.write(frag, 'fragColor[1].rgb = pow(fragColor[1].rgb, vec3(2.2, 2.2, 2.2));');
 			}
 
@@ -478,7 +478,7 @@ class MakeMesh {
 		return con_mesh;
 	}
 
-	static getMaxTextures = (): i32 => {
+	static get_max_textures = (): i32 => {
 		///if krom_direct3d11
 		return 128 - 66;
 		///else

+ 13 - 13
armorpaint/Sources/MakeMeshPreview.ts

@@ -1,9 +1,9 @@
 
 class MakeMeshPreview {
 
-	static opacityDiscardDecal = 0.05;
+	static opacity_discard_decal: f32 = 0.05;
 
-	static run = (data: TMaterial, matcon: material_context_t): NodeShaderContextRaw => {
+	static run = (data: material_t, matcon: material_context_t): NodeShaderContextRaw => {
 		let context_id = "mesh";
 		let con_mesh = NodeShaderContext.create(data, {
 			name: context_id,
@@ -21,12 +21,12 @@ class MakeMeshPreview {
 		let pos = "pos";
 
 		///if arm_skin
-		let skin = mesh_data_get_vertex_array(Context.raw.paintObject.data, "bone") != null;
+		let skin = mesh_data_get_vertex_array(Context.raw.paint_object.data, "bone") != null;
 		if (skin) {
 			pos = "spos";
 			NodeShaderContext.add_elem(con_mesh, "bone", 'short4norm');
 			NodeShaderContext.add_elem(con_mesh, "weight", 'short4norm');
-			NodeShader.add_function(vert, ShaderFunctions.str_getSkinningDualQuat);
+			NodeShader.add_function(vert, ShaderFunctions.str_get_skinning_dual_quat);
 			NodeShader.add_uniform(vert, 'vec4 skinBones[128 * 2]', '_skin_bones');
 			NodeShader.add_uniform(vert, 'float posUnpack', '_pos_unpack');
 			NodeShader.write_attrib(vert, 'vec4 skinA;');
@@ -43,16 +43,16 @@ class MakeMeshPreview {
 		NodeShader.add_uniform(vert, 'mat4 WVP', '_world_view_proj_matrix');
 		NodeShader.write_attrib(vert, `gl_Position = mul(vec4(${pos}.xyz, 1.0), WVP);`);
 
-		let brushScale = (Context.raw.brushScale * Context.raw.brushNodesScale) + "";
+		let brushScale = (Context.raw.brush_scale * Context.raw.brush_nodes_scale) + "";
 		NodeShader.add_out(vert, 'vec2 texCoord');
 		NodeShader.write_attrib(vert, `texCoord = tex * float(${brushScale});`);
 
-		let decal = Context.raw.decalPreview;
+		let decal = Context.raw.decal_preview;
 		ParserMaterial.sample_keep_aspect = decal;
 		ParserMaterial.sample_uv_scale = brushScale;
 		ParserMaterial.parse_height = MakeMaterial.heightUsed;
 		ParserMaterial.parse_height_as_channel = true;
-		let sout = ParserMaterial.parse(UINodes.getCanvasMaterial(), con_mesh, vert, frag, matcon);
+		let sout = ParserMaterial.parse(UINodes.get_canvas_material(), con_mesh, vert, frag, matcon);
 		ParserMaterial.parse_height = false;
 		ParserMaterial.parse_height_as_channel = false;
 		ParserMaterial.sample_keep_aspect = false;
@@ -82,22 +82,22 @@ class MakeMeshPreview {
 		// }
 
 		if (decal) {
-			if (Context.raw.tool == WorkspaceTool.ToolText) {
+			if (Context.raw.tool == workspace_tool_t.TEXT) {
 				NodeShader.add_uniform(frag, 'sampler2D textexttool', '_textexttool');
 				NodeShader.write(frag, `opacity *= textureLod(textexttool, texCoord / float(${brushScale}), 0.0).r;`);
 			}
 		}
 		if (decal) {
-			let opac = MakeMeshPreview.opacityDiscardDecal;
+			let opac = MakeMeshPreview.opacity_discard_decal;
 			NodeShader.write(frag, `if (opacity < ${opac}) discard;`);
 		}
 
 		NodeShader.add_out(frag, 'vec4 fragColor[3]');
 		frag.n = true;
 
-		NodeShader.add_function(frag, ShaderFunctions.str_packFloatInt16);
-		NodeShader.add_function(frag, ShaderFunctions.str_cotangentFrame);
-		NodeShader.add_function(frag, ShaderFunctions.str_octahedronWrap);
+		NodeShader.add_function(frag, ShaderFunctions.str_pack_float_int16);
+		NodeShader.add_function(frag, ShaderFunctions.str_cotangent_frame);
+		NodeShader.add_function(frag, ShaderFunctions.str_octahedron_wrap);
 
 		if (MakeMaterial.heightUsed) {
 			NodeShader.write(frag, 'if (height > 0.0) {');
@@ -117,7 +117,7 @@ class MakeMeshPreview {
 			// TODO
 		}
 		else {
-			frag.vVec = true;
+			frag.vvec = true;
 			///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 			NodeShader.write(frag, 'mat3 TBN = cotangentFrame(n, vVec, texCoord);');
 			///else

+ 2 - 2
armorpaint/Sources/MakeNodePreview.ts

@@ -1,7 +1,7 @@
 
 class MakeNodePreview {
 
-	static run = (data: TMaterial, matcon: material_context_t, node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]): NodeShaderContextRaw => {
+	static run = (data: material_t, matcon: material_context_t, node: zui_node_t, group: zui_node_canvas_t, parents: zui_node_t[]): NodeShaderContextRaw => {
 		let context_id = "mesh";
 		let con_mesh = NodeShaderContext.create(data, {
 			name: context_id,
@@ -36,7 +36,7 @@ class MakeNodePreview {
 		let links = ParserMaterial.links;
 		let nodes = Context.raw.material.nodes;
 
-		let link: zui_node_link_t = { id: zui_get_link_id(links), from_id: node.id, from_socket: Context.raw.nodePreviewSocket, to_id: -1, to_socket: -1 };
+		let link: zui_node_link_t = { id: zui_get_link_id(links), from_id: node.id, from_socket: Context.raw.node_preview_socket, to_id: -1, to_socket: -1 };
 		links.push(link);
 
 		ParserMaterial.con = con_mesh;

+ 86 - 86
armorpaint/Sources/MakePaint.ts

@@ -3,15 +3,15 @@
 
 class MakePaint {
 
-	static get isRaytracedBake(): bool {
+	static get is_raytraced_bake(): bool {
 		///if (krom_direct3d12 || krom_vulkan || krom_metal)
-		return Context.raw.bakeType == BakeType.BakeInit;
+		return Context.raw.bake_type == bake_type_t.INIT;
 		///else
 		return false;
 		///end
 	}
 
-	static run = (data: TMaterial, matcon: material_context_t): NodeShaderContextRaw => {
+	static run = (data: material_t, matcon: material_context_t): NodeShaderContextRaw => {
 		let context_id = "paint";
 
 		let con_paint = NodeShaderContext.create(data, {
@@ -22,10 +22,10 @@ class MakePaint {
 			cull_mode: "none",
 			vertex_elements: [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}],
 			color_attachments:
-				Context.raw.tool == WorkspaceTool.ToolColorId ? ["RGBA32"] :
-				(Context.raw.tool == WorkspaceTool.ToolPicker && Context.raw.pickPosNorTex) ? ["RGBA128", "RGBA128"] :
-				(Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) ? ["RGBA32", "RGBA32", "RGBA32", "RGBA32"] :
-				(Context.raw.tool == WorkspaceTool.ToolBake && MakePaint.isRaytracedBake) ? ["RGBA64", "RGBA64"] :
+				Context.raw.tool == workspace_tool_t.COLORID ? ["RGBA32"] :
+				(Context.raw.tool == workspace_tool_t.PICKER && Context.raw.pick_pos_nor_tex) ? ["RGBA128", "RGBA128"] :
+				(Context.raw.tool == workspace_tool_t.PICKER || Context.raw.tool == workspace_tool_t.MATERIAL) ? ["RGBA32", "RGBA32", "RGBA32", "RGBA32"] :
+				(Context.raw.tool == workspace_tool_t.BAKE && MakePaint.is_raytraced_bake) ? ["RGBA64", "RGBA64"] :
 					["RGBA32", "RGBA32", "RGBA32", "R8"]
 		});
 
@@ -33,16 +33,16 @@ class MakePaint {
 		con_paint.data.color_writes_green = [true, true, true, true];
 		con_paint.data.color_writes_blue = [true, true, true, true];
 		con_paint.data.color_writes_alpha = [true, true, true, true];
-		con_paint.allow_vcols = mesh_data_get_vertex_array(Context.raw.paintObject.data, 'col') != null;
+		con_paint.allow_vcols = mesh_data_get_vertex_array(Context.raw.paint_object.data, 'col') != null;
 
 		let vert = NodeShaderContext.make_vert(con_paint);
 		let frag = NodeShaderContext.make_frag(con_paint);
 		frag.ins = vert.outs;
 
 		///if (krom_direct3d12 || krom_vulkan || krom_metal)
-		if (Context.raw.tool == WorkspaceTool.ToolBake && Context.raw.bakeType == BakeType.BakeInit) {
+		if (Context.raw.tool == workspace_tool_t.BAKE && Context.raw.bake_type == bake_type_t.INIT) {
 			// Init raytraced bake
-			MakeBake.positionAndNormal(vert, frag);
+			MakeBake.position_normal(vert, frag);
 			con_paint.data.shader_from_source = true;
 			con_paint.data.vertex_shader = NodeShader.get(vert);
 			con_paint.data.fragment_shader = NodeShader.get(frag);
@@ -50,11 +50,11 @@ class MakePaint {
 		}
 		///end
 
-		if (Context.raw.tool == WorkspaceTool.ToolBake) {
-			MakeBake.setColorWrites(con_paint);
+		if (Context.raw.tool == workspace_tool_t.BAKE) {
+			MakeBake.set_color_writes(con_paint);
 		}
 
-		if (Context.raw.tool == WorkspaceTool.ToolColorId || Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) {
+		if (Context.raw.tool == workspace_tool_t.COLORID || Context.raw.tool == workspace_tool_t.PICKER || Context.raw.tool == workspace_tool_t.MATERIAL) {
 			MakeColorIdPicker.run(vert, frag);
 			con_paint.data.shader_from_source = true;
 			con_paint.data.vertex_shader = NodeShader.get(vert);
@@ -62,9 +62,9 @@ class MakePaint {
 			return con_paint;
 		}
 
-		let faceFill = Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.fillTypeHandle.position == FillType.FillFace;
-		let uvIslandFill = Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.fillTypeHandle.position == FillType.FillUVIsland;
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		let faceFill = Context.raw.tool == workspace_tool_t.FILL && Context.raw.fill_type_handle.position == fill_type_t.FACE;
+		let uvIslandFill = Context.raw.tool == workspace_tool_t.FILL && Context.raw.fill_type_handle.position == fill_type_t.UV_ISLAND;
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 
 		///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 		NodeShader.write(vert, 'vec2 tpos = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);');
@@ -74,7 +74,7 @@ class MakePaint {
 
 		NodeShader.write(vert, 'gl_Position = vec4(tpos, 0.0, 1.0);');
 
-		let decalLayer = Context.raw.layer.fill_layer != null && Context.raw.layer.uvType == UVType.UVProject;
+		let decalLayer = Context.raw.layer.fill_layer != null && Context.raw.layer.uvType == uv_type_t.PROJECT;
 		if (decalLayer) {
 			NodeShader.add_uniform(vert, 'mat4 WVP', '_decalLayerMatrix');
 		}
@@ -89,8 +89,8 @@ class MakePaint {
 		NodeShader.write_attrib(frag, 'sp.y = 1.0 - sp.y;');
 		NodeShader.write_attrib(frag, 'sp.z -= 0.0001;'); // small bias
 
-		let uvType = Context.raw.layer.fill_layer != null ? Context.raw.layer.uvType : Context.raw.brushPaint;
-		if (uvType == UVType.UVProject) frag.ndcpos = true;
+		let uvType = Context.raw.layer.fill_layer != null ? Context.raw.layer.uvType : Context.raw.brush_paint;
+		if (uvType == uv_type_t.PROJECT) frag.ndcpos = true;
 
 		NodeShader.add_uniform(frag, 'vec4 inp', '_inputBrush');
 		NodeShader.add_uniform(frag, 'vec4 inplast', '_inputBrushLast');
@@ -107,21 +107,21 @@ class MakePaint {
 		NodeShader.add_uniform(frag, 'float brushOpacity', '_brushOpacity');
 		NodeShader.add_uniform(frag, 'float brushHardness', '_brushHardness');
 
-		if (Context.raw.tool == WorkspaceTool.ToolBrush  ||
-			Context.raw.tool == WorkspaceTool.ToolEraser ||
-			Context.raw.tool == WorkspaceTool.ToolClone  ||
-			Context.raw.tool == WorkspaceTool.ToolBlur   ||
-			Context.raw.tool == WorkspaceTool.ToolSmudge   ||
-			Context.raw.tool == WorkspaceTool.ToolParticle ||
+		if (Context.raw.tool == workspace_tool_t.BRUSH  ||
+			Context.raw.tool == workspace_tool_t.ERASER ||
+			Context.raw.tool == workspace_tool_t.CLONE  ||
+			Context.raw.tool == workspace_tool_t.BLUR   ||
+			Context.raw.tool == workspace_tool_t.SMUDGE   ||
+			Context.raw.tool == workspace_tool_t.PARTICLE ||
 			decal) {
 
 			let depthReject = !Context.raw.xray;
 			if (Config.raw.brush_3d && !Config.raw.brush_depth_reject) depthReject = false;
 
 			// TODO: sp.z needs to take height channel into account
-			let particle = Context.raw.tool == WorkspaceTool.ToolParticle;
+			let particle = Context.raw.tool == workspace_tool_t.PARTICLE;
 			if (Config.raw.brush_3d && !decal && !particle) {
-				if (MakeMaterial.heightUsed || Context.raw.symX || Context.raw.symY || Context.raw.symZ) depthReject = false;
+				if (MakeMaterial.heightUsed || Context.raw.sym_x || Context.raw.sym_y || Context.raw.sym_z) depthReject = false;
 			}
 
 			if (depthReject) {
@@ -136,9 +136,9 @@ class MakePaint {
 		}
 		else { // Fill, Bake
 			NodeShader.write(frag, 'float dist = 0.0;');
-			let angleFill = Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.fillTypeHandle.position == FillType.FillAngle;
+			let angleFill = Context.raw.tool == workspace_tool_t.FILL && Context.raw.fill_type_handle.position == fill_type_t.ANGLE;
 			if (angleFill) {
-				NodeShader.add_function(frag, ShaderFunctions.str_octahedronWrap);
+				NodeShader.add_function(frag, ShaderFunctions.str_octahedron_wrap);
 				NodeShader.add_uniform(frag, 'sampler2D gbuffer0');
 				NodeShader.write(frag, 'vec2 g0 = textureLod(gbuffer0, inp.xy, 0.0).rg;');
 				NodeShader.write(frag, 'vec3 wn;');
@@ -146,10 +146,10 @@ class MakePaint {
 				NodeShader.write(frag, 'wn.xy = wn.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);');
 				NodeShader.write(frag, 'wn = normalize(wn);');
 				frag.n = true;
-				let angle = Context.raw.brushAngleRejectDot;
+				let angle = Context.raw.brush_angle_reject_dot;
 				NodeShader.write(frag, `if (dot(wn, n) < ${angle}) discard;`);
 			}
-			let stencilFill = Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.brushStencilImage != null;
+			let stencilFill = Context.raw.tool == workspace_tool_t.FILL && Context.raw.brush_stencil_image != null;
 			if (stencilFill) {
 				///if (krom_direct3d11 || krom_direct3d12 || krom_metal || krom_vulkan)
 				NodeShader.write(frag, 'if (sp.z > textureLod(gbufferD, sp.xy, 0.0).r + 0.0005) discard;');
@@ -159,34 +159,34 @@ class MakePaint {
 			}
 		}
 
-		if (Context.raw.colorIdPicked || faceFill || uvIslandFill) {
+		if (Context.raw.colorid_picked || faceFill || uvIslandFill) {
 			NodeShader.add_out(vert, 'vec2 texCoordPick');
 			NodeShader.write(vert, 'texCoordPick = tex;');
-			if (Context.raw.colorIdPicked) {
-				MakeDiscard.colorId(vert, frag);
+			if (Context.raw.colorid_picked) {
+				MakeDiscard.color_id(vert, frag);
 			}
 			if (faceFill) {
 				MakeDiscard.face(vert, frag);
 			}
 			else if (uvIslandFill) {
-				MakeDiscard.uvIsland(vert, frag);
+				MakeDiscard.uv_island(vert, frag);
 			}
 		}
 
-		if (Context.raw.pickerMaskHandle.position == PickerMask.MaskMaterial) {
-			MakeDiscard.materialId(vert, frag);
+		if (Context.raw.picker_mask_handle.position == picker_mask_t.MATERIAL) {
+			MakeDiscard.material_id(vert, frag);
 		}
 
 		MakeTexcoord.run(vert, frag);
 
-		if (Context.raw.tool == WorkspaceTool.ToolClone || Context.raw.tool == WorkspaceTool.ToolBlur || Context.raw.tool == WorkspaceTool.ToolSmudge) {
+		if (Context.raw.tool == workspace_tool_t.CLONE || Context.raw.tool == workspace_tool_t.BLUR || Context.raw.tool == workspace_tool_t.SMUDGE) {
 			NodeShader.add_uniform(frag, 'sampler2D gbuffer2');
 			NodeShader.add_uniform(frag, 'vec2 gbufferSize', '_gbufferSize');
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_undo', '_texpaint_undo');
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_nor_undo', '_texpaint_nor_undo');
 			NodeShader.add_uniform(frag, 'sampler2D texpaint_pack_undo', '_texpaint_pack_undo');
 
-			if (Context.raw.tool == WorkspaceTool.ToolClone) {
+			if (Context.raw.tool == workspace_tool_t.CLONE) {
 				MakeClone.run(vert, frag);
 			}
 			else { // Blur, Smudge
@@ -194,15 +194,15 @@ class MakePaint {
 			}
 		}
 		else {
-			ParserMaterial.parse_emission = Context.raw.material.paintEmis;
-			ParserMaterial.parse_subsurface = Context.raw.material.paintSubs;
-			ParserMaterial.parse_height = Context.raw.material.paintHeight;
+			ParserMaterial.parse_emission = Context.raw.material.paint_emis;
+			ParserMaterial.parse_subsurface = Context.raw.material.paint_subs;
+			ParserMaterial.parse_height = Context.raw.material.paint_height;
 			ParserMaterial.parse_height_as_channel = true;
-			let uvType = Context.raw.layer.fill_layer != null ? Context.raw.layer.uvType : Context.raw.brushPaint;
-			ParserMaterial.triplanar = uvType == UVType.UVTriplanar && !decal;
+			let uvType = Context.raw.layer.fill_layer != null ? Context.raw.layer.uvType : Context.raw.brush_paint;
+			ParserMaterial.triplanar = uvType == uv_type_t.TRIPLANAR && !decal;
 			ParserMaterial.sample_keep_aspect = decal;
 			ParserMaterial.sample_uv_scale = 'brushScale';
-			let sout = ParserMaterial.parse(UINodes.getCanvasMaterial(), con_paint, vert, frag, matcon);
+			let sout = ParserMaterial.parse(UINodes.get_canvas_material(), con_paint, vert, frag, matcon);
 			ParserMaterial.parse_emission = false;
 			ParserMaterial.parse_subsurface = false;
 			ParserMaterial.parse_height_as_channel = false;
@@ -227,10 +227,10 @@ class MakePaint {
 			if (Context.raw.layer.fill_layer == null) {
 				NodeShader.write(frag, 'opacity *= brushOpacity;');
 			}
-			if (Context.raw.material.paintEmis) {
+			if (Context.raw.material.paint_emis) {
 				NodeShader.write(frag, `float emis = ${emis};`);
 			}
-			if (Context.raw.material.paintSubs) {
+			if (Context.raw.material.paint_subs) {
 				NodeShader.write(frag, `float subs = ${subs};`);
 			}
 			if (parseFloat(height) != 0.0 && !MakeMaterial.heightUsed) {
@@ -242,29 +242,29 @@ class MakePaint {
 			if (parseFloat(subs) != 0.0) MakeMaterial.subsUsed = true;
 		}
 
-		if (Context.raw.brushMaskImage != null && Context.raw.tool == WorkspaceTool.ToolDecal) {
+		if (Context.raw.brush_mask_image != null && Context.raw.tool == workspace_tool_t.DECAL) {
 			NodeShader.add_uniform(frag, 'sampler2D texbrushmask', '_texbrushmask');
 			NodeShader.write(frag, 'vec4 mask_sample = textureLod(texbrushmask, uvsp, 0.0);');
-			if (Context.raw.brushMaskImageIsAlpha) {
+			if (Context.raw.brush_mask_image_is_alpha) {
 				NodeShader.write(frag, 'opacity *= mask_sample.a;');
 			}
 			else {
 				NodeShader.write(frag, 'opacity *= mask_sample.r * mask_sample.a;');
 			}
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolText) {
+		else if (Context.raw.tool == workspace_tool_t.TEXT) {
 			NodeShader.add_uniform(frag, 'sampler2D textexttool', '_textexttool');
 			NodeShader.write(frag, 'opacity *= textureLod(textexttool, uvsp, 0.0).r;');
 		}
 
-		if (Context.raw.brushStencilImage != null && (
-			Context.raw.tool == WorkspaceTool.ToolBrush  ||
-			Context.raw.tool == WorkspaceTool.ToolEraser ||
-			Context.raw.tool == WorkspaceTool.ToolFill ||
-			Context.raw.tool == WorkspaceTool.ToolClone  ||
-			Context.raw.tool == WorkspaceTool.ToolBlur   ||
-			Context.raw.tool == WorkspaceTool.ToolSmudge   ||
-			Context.raw.tool == WorkspaceTool.ToolParticle ||
+		if (Context.raw.brush_stencil_image != null && (
+			Context.raw.tool == workspace_tool_t.BRUSH  ||
+			Context.raw.tool == workspace_tool_t.ERASER ||
+			Context.raw.tool == workspace_tool_t.FILL ||
+			Context.raw.tool == workspace_tool_t.CLONE  ||
+			Context.raw.tool == workspace_tool_t.BLUR   ||
+			Context.raw.tool == workspace_tool_t.SMUDGE   ||
+			Context.raw.tool == workspace_tool_t.PARTICLE ||
 			decal)) {
 			NodeShader.add_uniform(frag, 'sampler2D texbrushstencil', '_texbrushstencil');
 			NodeShader.add_uniform(frag, 'vec4 stencilTransform', '_stencilTransform');
@@ -278,7 +278,7 @@ class MakePaint {
 			NodeShader.write(frag, 'stencil_uv.x *= stencil_ratio;');
 			NodeShader.write(frag, 'if (stencil_uv.x < 0 || stencil_uv.x > 1 || stencil_uv.y < 0 || stencil_uv.y > 1) discard;');
 			NodeShader.write(frag, 'vec4 texbrushstencil_sample = textureLod(texbrushstencil, stencil_uv, 0.0);');
-			if (Context.raw.brushStencilImageIsAlpha) {
+			if (Context.raw.brush_stencil_image_is_alpha) {
 				NodeShader.write(frag, 'opacity *= texbrushstencil_sample.a;');
 			}
 			else {
@@ -286,18 +286,18 @@ class MakePaint {
 			}
 		}
 
-		if (Context.raw.brushMaskImage != null && (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolEraser)) {
+		if (Context.raw.brush_mask_image != null && (Context.raw.tool == workspace_tool_t.BRUSH || Context.raw.tool == workspace_tool_t.ERASER)) {
 			NodeShader.add_uniform(frag, 'sampler2D texbrushmask', '_texbrushmask');
 			NodeShader.write(frag, 'vec2 binp_mask = inp.xy * 2.0 - 1.0;');
 			NodeShader.write(frag, 'binp_mask.x *= aspectRatio;');
 			NodeShader.write(frag, 'binp_mask = binp_mask * 0.5 + 0.5;');
 			NodeShader.write(frag, 'vec2 pa_mask = bsp.xy - binp_mask.xy;');
-			if (Context.raw.brushDirectional) {
+			if (Context.raw.brush_directional) {
 				NodeShader.add_uniform(frag, 'vec3 brushDirection', '_brushDirection');
 				NodeShader.write(frag, 'if (brushDirection.z == 0.0) discard;');
 				NodeShader.write(frag, 'pa_mask = vec2(pa_mask.x * brushDirection.x - pa_mask.y * brushDirection.y, pa_mask.x * brushDirection.y + pa_mask.y * brushDirection.x);');
 			}
-			let angle = Context.raw.brushAngle + Context.raw.brushNodesAngle;
+			let angle = Context.raw.brush_angle + Context.raw.brush_nodes_angle;
 			if (angle != 0.0) {
 				NodeShader.add_uniform(frag, 'vec2 brushAngle', '_brushAngle');
 				NodeShader.write(frag, 'pa_mask.xy = vec2(pa_mask.x * brushAngle.x - pa_mask.y * brushAngle.y, pa_mask.x * brushAngle.y + pa_mask.y * brushAngle.x);');
@@ -309,7 +309,7 @@ class MakePaint {
 			}
 			NodeShader.write(frag, 'pa_mask = pa_mask.xy * 0.5 + 0.5;');
 			NodeShader.write(frag, 'vec4 mask_sample = textureLod(texbrushmask, pa_mask, 0.0);');
-			if (Context.raw.brushMaskImageIsAlpha) {
+			if (Context.raw.brush_mask_image_is_alpha) {
 				NodeShader.write(frag, 'opacity *= mask_sample.a;');
 			}
 			else {
@@ -319,7 +319,7 @@ class MakePaint {
 
 		NodeShader.write(frag, 'if (opacity == 0.0) discard;');
 
-		if (Context.raw.tool == WorkspaceTool.ToolParticle) { // Particle mask
+		if (Context.raw.tool == workspace_tool_t.PARTICLE) { // Particle mask
 			MakeParticle.mask(vert, frag);
 		}
 		else { // Brush cursor mask
@@ -341,30 +341,30 @@ class MakePaint {
 		NodeShader.write(frag, 'vec4 sample_undo = textureLod(texpaint_undo, sample_tc, 0.0);');
 
 		let matid = Context.raw.material.id / 255;
-		if (Context.raw.pickerMaskHandle.position == PickerMask.MaskMaterial) {
-			matid = Context.raw.materialIdPicked / 255; // Keep existing material id in place when mask is set
+		if (Context.raw.picker_mask_handle.position == picker_mask_t.MATERIAL) {
+			matid = Context.raw.materialid_picked / 255; // Keep existing material id in place when mask is set
 		}
 		let matidString = ParserMaterial.vec1(matid * 3.0);
 		NodeShader.write(frag, `float matid = ${matidString};`);
 
 		// matid % 3 == 0 - normal, 1 - emission, 2 - subsurface
-		if (Context.raw.material.paintEmis) {
+		if (Context.raw.material.paint_emis) {
 			NodeShader.write(frag, 'if (emis > 0.0) {');
 			NodeShader.write(frag, '	matid += 1.0 / 255.0;');
 			NodeShader.write(frag, '	if (str == 0.0) discard;');
 			NodeShader.write(frag, '}');
 		}
-		else if (Context.raw.material.paintSubs) {
+		else if (Context.raw.material.paint_subs) {
 			NodeShader.write(frag, 'if (subs > 0.0) {');
 			NodeShader.write(frag, '    matid += 2.0 / 255.0;');
 			NodeShader.write(frag, '	if (str == 0.0) discard;');
 			NodeShader.write(frag, '}');
 		}
 
-		let isMask = SlotLayer.isMask(Context.raw.layer);
+		let isMask = SlotLayer.is_mask(Context.raw.layer);
 		let layered = Context.raw.layer != Project.layers[0];
 		if (layered && !isMask) {
-			if (Context.raw.tool == WorkspaceTool.ToolEraser) {
+			if (Context.raw.tool == workspace_tool_t.ERASER) {
 				NodeShader.write(frag, 'fragColor[0] = vec4(mix(sample_undo.rgb, vec3(0.0, 0.0, 0.0), str), sample_undo.a - str);');
 				NodeShader.write(frag, 'nortan = vec3(0.5, 0.5, 1.0);');
 				NodeShader.write(frag, 'occlusion = 1.0;');
@@ -372,21 +372,21 @@ class MakePaint {
 				NodeShader.write(frag, 'metallic = 0.0;');
 				NodeShader.write(frag, 'matid = 0.0;');
 			}
-			else if (Context.raw.tool == WorkspaceTool.ToolParticle || decal || Context.raw.brushMaskImage != null) {
-				NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blendMode(frag, Context.raw.brushBlending, 'sample_undo.rgb', 'basecol', 'str') + ', max(str, sample_undo.a));');
+			else if (Context.raw.tool == workspace_tool_t.PARTICLE || decal || Context.raw.brush_mask_image != null) {
+				NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blend_mode(frag, Context.raw.brush_blending, 'sample_undo.rgb', 'basecol', 'str') + ', max(str, sample_undo.a));');
 			}
 			else {
 				if (Context.raw.layer.fill_layer != null) {
-					NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blendMode(frag, Context.raw.brushBlending, 'sample_undo.rgb', 'basecol', 'opacity') + ', mat_opacity);');
+					NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blend_mode(frag, Context.raw.brush_blending, 'sample_undo.rgb', 'basecol', 'opacity') + ', mat_opacity);');
 				}
 				else {
-					NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blendMode(frag, Context.raw.brushBlending, 'sample_undo.rgb', 'basecol', 'opacity') + ', max(str, sample_undo.a));');
+					NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blend_mode(frag, Context.raw.brush_blending, 'sample_undo.rgb', 'basecol', 'opacity') + ', max(str, sample_undo.a));');
 				}
 			}
 			NodeShader.write(frag, 'fragColor[1] = vec4(nortan, matid);');
 
 			let height = "0.0";
-			if (Context.raw.material.paintHeight && MakeMaterial.heightUsed) {
+			if (Context.raw.material.paint_height && MakeMaterial.heightUsed) {
 				height = "height";
 			}
 
@@ -400,7 +400,7 @@ class MakePaint {
 			}
 		}
 		else {
-			if (Context.raw.tool == WorkspaceTool.ToolEraser) {
+			if (Context.raw.tool == workspace_tool_t.ERASER) {
 				NodeShader.write(frag, 'fragColor[0] = vec4(mix(sample_undo.rgb, vec3(0.0, 0.0, 0.0), str), sample_undo.a - str);');
 				NodeShader.write(frag, 'fragColor[1] = vec4(0.5, 0.5, 1.0, 0.0);');
 				NodeShader.write(frag, 'fragColor[2] = vec4(1.0, 0.0, 0.0, 0.0);');
@@ -410,9 +410,9 @@ class MakePaint {
 				NodeShader.add_uniform(frag, 'sampler2D texpaint_pack_undo', '_texpaint_pack_undo');
 				NodeShader.write(frag, 'vec4 sample_nor_undo = textureLod(texpaint_nor_undo, sample_tc, 0.0);');
 				NodeShader.write(frag, 'vec4 sample_pack_undo = textureLod(texpaint_pack_undo, sample_tc, 0.0);');
-				NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blendMode(frag, Context.raw.brushBlending, 'sample_undo.rgb', 'basecol', 'str') + ', max(str, sample_undo.a));');
+				NodeShader.write(frag, 'fragColor[0] = vec4(' + MakeMaterial.blend_mode(frag, Context.raw.brush_blending, 'sample_undo.rgb', 'basecol', 'str') + ', max(str, sample_undo.a));');
 				NodeShader.write(frag, 'fragColor[1] = vec4(mix(sample_nor_undo.rgb, nortan, str), matid);');
-				if (Context.raw.material.paintHeight && MakeMaterial.heightUsed) {
+				if (Context.raw.material.paint_height && MakeMaterial.heightUsed) {
 					NodeShader.write(frag, 'fragColor[2] = mix(sample_pack_undo, vec4(occlusion, roughness, metallic, height), str);');
 				}
 				else {
@@ -422,29 +422,29 @@ class MakePaint {
 		}
 		NodeShader.write(frag, 'fragColor[3] = vec4(str, 0.0, 0.0, 1.0);');
 
-		if (!Context.raw.material.paintBase) {
+		if (!Context.raw.material.paint_base) {
 			con_paint.data.color_writes_red[0] = false;
 			con_paint.data.color_writes_green[0] = false;
 			con_paint.data.color_writes_blue[0] = false;
 		}
-		if (!Context.raw.material.paintOpac) {
+		if (!Context.raw.material.paint_opac) {
 			con_paint.data.color_writes_alpha[0] = false;
 		}
-		if (!Context.raw.material.paintNor) {
+		if (!Context.raw.material.paint_nor) {
 			con_paint.data.color_writes_red[1] = false;
 			con_paint.data.color_writes_green[1] = false;
 			con_paint.data.color_writes_blue[1] = false;
 		}
-		if (!Context.raw.material.paintOcc) {
+		if (!Context.raw.material.paint_occ) {
 			con_paint.data.color_writes_red[2] = false;
 		}
-		if (!Context.raw.material.paintRough) {
+		if (!Context.raw.material.paint_rough) {
 			con_paint.data.color_writes_green[2] = false;
 		}
-		if (!Context.raw.material.paintMet) {
+		if (!Context.raw.material.paint_met) {
 			con_paint.data.color_writes_blue[2] = false;
 		}
-		if (!Context.raw.material.paintHeight) {
+		if (!Context.raw.material.paint_height) {
 			con_paint.data.color_writes_alpha[2] = false;
 		}
 
@@ -465,7 +465,7 @@ class MakePaint {
 			con_paint.data.color_writes_alpha[2] = false;
 		}
 
-		if (Context.raw.tool == WorkspaceTool.ToolBake) {
+		if (Context.raw.tool == workspace_tool_t.BAKE) {
 			MakeBake.run(con_paint, vert, frag);
 		}
 

+ 2 - 2
armorpaint/Sources/MakeParticle.ts

@@ -1,7 +1,7 @@
 
 class MakeParticle {
 
-	static run = (data: TMaterial): NodeShaderContextRaw => {
+	static run = (data: material_t): NodeShaderContextRaw => {
 		let context_id = "mesh";
 		let con_part = NodeShaderContext.create(data, {
 			name: context_id,
@@ -87,7 +87,7 @@ class MakeParticle {
 
 	static mask = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 		///if arm_physics
-		if (Context.raw.particlePhysics) {
+		if (Context.raw.particle_physics) {
 			NodeShader.add_out(vert, 'vec4 wpos');
 			NodeShader.add_uniform(vert, 'mat4 W', '_world_matrix');
 			NodeShader.write_attrib(vert, 'wpos = mul(vec4(pos.xyz, 1.0), W);');

+ 7 - 7
armorpaint/Sources/MakeTexcoord.ts

@@ -4,12 +4,12 @@ class MakeTexcoord {
 	static run = (vert: NodeShaderRaw, frag: NodeShaderRaw) => {
 
 		let fillLayer = Context.raw.layer.fill_layer != null;
-		let uvType = fillLayer ? Context.raw.layer.uvType : Context.raw.brushPaint;
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
-		let angle = Context.raw.brushAngle + Context.raw.brushNodesAngle;
+		let uvType = fillLayer ? Context.raw.layer.uvType : Context.raw.brush_paint;
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
+		let angle = Context.raw.brush_angle + Context.raw.brush_nodes_angle;
 		let uvAngle = fillLayer ? Context.raw.layer.angle : angle;
 
-		if (uvType == UVType.UVProject || decal) { // TexCoords - project
+		if (uvType == uv_type_t.PROJECT || decal) { // TexCoords - project
 			NodeShader.add_uniform(frag, 'float brushScale', '_brushScale');
 			NodeShader.write_attrib(frag, 'vec2 uvsp = sp.xy;');
 
@@ -23,7 +23,7 @@ class MakeTexcoord {
 
 				frag.n = true;
 				NodeShader.add_uniform(frag, 'vec3 decalLayerNor', '_decalLayerNor');
-				let dotAngle = Context.raw.brushAngleRejectDot;
+				let dotAngle = Context.raw.brush_angle_reject_dot;
 				NodeShader.write(frag, `if (abs(dot(n, decalLayerNor) - 1.0) > ${dotAngle}) discard;`);
 
 				frag.wposition = true;
@@ -37,7 +37,7 @@ class MakeTexcoord {
 				NodeShader.write_attrib(frag, 'uvsp.x *= aspectRatio;');
 				NodeShader.write_attrib(frag, 'uvsp *= 0.21 / (decalMask.w * 0.9);'); // Decal radius
 
-				if (Context.raw.brushDirectional) {
+				if (Context.raw.brush_directional) {
 					NodeShader.add_uniform(frag, 'vec3 brushDirection', '_brushDirection');
 					NodeShader.write_attrib(frag, 'if (brushDirection.z == 0.0) discard;');
 					NodeShader.write_attrib(frag, 'uvsp = vec2(uvsp.x * brushDirection.x - uvsp.y * brushDirection.y, uvsp.x * brushDirection.y + uvsp.y * brushDirection.x);');
@@ -66,7 +66,7 @@ class MakeTexcoord {
 
 			NodeShader.write_attrib(frag, 'vec2 texCoord = uvsp * brushScale;');
 		}
-		else if (uvType == UVType.UVMap) { // TexCoords - uvmap
+		else if (uvType == uv_type_t.UVMAP) { // TexCoords - uvmap
 			NodeShader.add_uniform(vert, 'float brushScale', '_brushScale');
 			NodeShader.add_out(vert, 'vec2 texCoord');
 			NodeShader.write(vert, 'texCoord = tex * brushScale;');

+ 2 - 2
armorpaint/Sources/NodesBrush.ts

@@ -26,13 +26,13 @@ class NodesBrush {
 		]
 	];
 
-	static createNode = (nodeType: string): zui_node_t => {
+	static create_node = (nodeType: string): zui_node_t => {
 		for (let c of NodesBrush.list) {
 			for (let n of c) {
 				if (n.type == nodeType) {
 					let canvas = Context.raw.brush.canvas;
 					let nodes = Context.raw.brush.nodes;
-					let node = UINodes.makeNode(n, nodes, canvas);
+					let node = UINodes.make_node(n, nodes, canvas);
 					canvas.nodes.push(node);
 					return node;
 				}

+ 251 - 251
armorpaint/Sources/RenderPathPaint.ts

@@ -27,16 +27,16 @@ class RenderPathPaint {
 		{
 			let t = render_target_create();
 			t.name = "texpaint_blend0";
-			t.width = Config.getTextureResX();
-			t.height = Config.getTextureResY();
+			t.width = Config.get_texture_res_x();
+			t.height = Config.get_texture_res_y();
 			t.format = "R8";
 			render_path_create_render_target(t);
 		}
 		{
 			let t = render_target_create();
 			t.name = "texpaint_blend1";
-			t.width = Config.getTextureResX();
-			t.height = Config.getTextureResY();
+			t.width = Config.get_texture_res_x();
+			t.height = Config.get_texture_res_y();
 			t.format = "R8";
 			render_path_create_render_target(t);
 		}
@@ -104,16 +104,16 @@ class RenderPathPaint {
 		///end
 	}
 
-	static commandsPaint = (dilation = true) => {
+	static commands_paint = (dilation = true) => {
 		let tid = Context.raw.layer.id;
 
 		if (Context.raw.pdirty > 0) {
 			///if arm_physics
-			let particlePhysics = Context.raw.particlePhysics;
+			let particlePhysics = Context.raw.particle_physics;
 			///else
 			let particlePhysics = false;
 			///end
-			if (Context.raw.tool == WorkspaceTool.ToolParticle && !particlePhysics) {
+			if (Context.raw.tool == workspace_tool_t.PARTICLE && !particlePhysics) {
 				render_path_set_target("texparticle");
 				render_path_clear_target(0x00000000);
 				render_path_bind_target("_main", "gbufferD");
@@ -134,15 +134,15 @@ class RenderPathPaint {
 			}
 
 			///if is_paint
-			if (Context.raw.tool == WorkspaceTool.ToolColorId) {
+			if (Context.raw.tool == workspace_tool_t.COLORID) {
 				render_path_set_target("texpaint_colorid");
 				render_path_clear_target(0xff000000);
 				render_path_bind_target("gbuffer2", "gbuffer2");
 				render_path_draw_meshes("paint");
-				UIHeader.headerHandle.redraws = 2;
+				UIHeader.header_handle.redraws = 2;
 			}
-			else if (Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) {
-				if (Context.raw.pickPosNorTex) {
+			else if (Context.raw.tool == workspace_tool_t.PICKER || Context.raw.tool == workspace_tool_t.MATERIAL) {
+				if (Context.raw.pick_pos_nor_tex) {
 					if (Context.raw.paint2d) {
 						render_path_set_target("gbuffer0", ["gbuffer1", "gbuffer2"]);
 						render_path_draw_meshes("mesh");
@@ -155,27 +155,27 @@ class RenderPathPaint {
 					let texpaint_posnortex_picker1 = render_path_render_targets.get("texpaint_posnortex_picker1")._image;
 					let a = new DataView(image_get_pixels(texpaint_posnortex_picker0));
 					let b = new DataView(image_get_pixels(texpaint_posnortex_picker1));
-					Context.raw.posXPicked = a.getFloat32(0, true);
-					Context.raw.posYPicked = a.getFloat32(4, true);
-					Context.raw.posZPicked = a.getFloat32(8, true);
-					Context.raw.uvxPicked = a.getFloat32(12, true);
-					Context.raw.norXPicked = b.getFloat32(0, true);
-					Context.raw.norYPicked = b.getFloat32(4, true);
-					Context.raw.norZPicked = b.getFloat32(8, true);
-					Context.raw.uvyPicked = b.getFloat32(12, true);
+					Context.raw.posx_picked = a.getFloat32(0, true);
+					Context.raw.posy_picked = a.getFloat32(4, true);
+					Context.raw.posz_picked = a.getFloat32(8, true);
+					Context.raw.uvx_picked = a.getFloat32(12, true);
+					Context.raw.norx_picked = b.getFloat32(0, true);
+					Context.raw.nory_picked = b.getFloat32(4, true);
+					Context.raw.norz_picked = b.getFloat32(8, true);
+					Context.raw.uvy_picked = b.getFloat32(12, true);
 				}
 				else {
 					render_path_set_target("texpaint_picker", ["texpaint_nor_picker", "texpaint_pack_picker", "texpaint_uv_picker"]);
 					render_path_bind_target("gbuffer2", "gbuffer2");
 					tid = Context.raw.layer.id;
-					let useLiveLayer = Context.raw.tool == WorkspaceTool.ToolMaterial;
-					if (useLiveLayer) RenderPathPaint.useLiveLayer(true);
+					let useLiveLayer = Context.raw.tool == workspace_tool_t.MATERIAL;
+					if (useLiveLayer) RenderPathPaint.use_live_layer(true);
 					render_path_bind_target("texpaint" + tid, "texpaint");
 					render_path_bind_target("texpaint_nor" + tid, "texpaint_nor");
 					render_path_bind_target("texpaint_pack" + tid, "texpaint_pack");
 					render_path_draw_meshes("paint");
-					if (useLiveLayer) RenderPathPaint.useLiveLayer(false);
-					UIHeader.headerHandle.redraws = 2;
+					if (useLiveLayer) RenderPathPaint.use_live_layer(false);
+					UIHeader.header_handle.redraws = 2;
 					UIBase.hwnds[2].redraws = 2;
 
 					let texpaint_picker = render_path_render_targets.get("texpaint_picker")._image;
@@ -187,8 +187,8 @@ class RenderPathPaint {
 					let c = new DataView(image_get_pixels(texpaint_pack_picker));
 					let d = new DataView(image_get_pixels(texpaint_uv_picker));
 
-					if (Context.raw.colorPickerCallback != null) {
-						Context.raw.colorPickerCallback(Context.raw.pickedColor);
+					if (Context.raw.color_picker_callback != null) {
+						Context.raw.color_picker_callback(Context.raw.picked_color);
 					}
 
 					// Picked surface values
@@ -202,27 +202,27 @@ class RenderPathPaint {
 					let i2 = 2;
 					///end
 					let i3 = 3;
-					Context.raw.pickedColor.base = color_set_rb(Context.raw.pickedColor.base, a.getUint8(i0));
-					Context.raw.pickedColor.base = color_set_gb(Context.raw.pickedColor.base, a.getUint8(i1));
-					Context.raw.pickedColor.base = color_set_bb(Context.raw.pickedColor.base, a.getUint8(i2));
-					Context.raw.pickedColor.normal = color_set_rb(Context.raw.pickedColor.normal, b.getUint8(i0));
-					Context.raw.pickedColor.normal = color_set_gb(Context.raw.pickedColor.normal, b.getUint8(i1));
-					Context.raw.pickedColor.normal = color_set_bb(Context.raw.pickedColor.normal, b.getUint8(i2));
-					Context.raw.pickedColor.occlusion = c.getUint8(i0) / 255;
-					Context.raw.pickedColor.roughness = c.getUint8(i1) / 255;
-					Context.raw.pickedColor.metallic = c.getUint8(i2) / 255;
-					Context.raw.pickedColor.height = c.getUint8(i3) / 255;
-					Context.raw.pickedColor.opacity = a.getUint8(i3) / 255;
-					Context.raw.uvxPicked = d.getUint8(i0) / 255;
-					Context.raw.uvyPicked = d.getUint8(i1) / 255;
+					Context.raw.picked_color.base = color_set_rb(Context.raw.picked_color.base, a.getUint8(i0));
+					Context.raw.picked_color.base = color_set_gb(Context.raw.picked_color.base, a.getUint8(i1));
+					Context.raw.picked_color.base = color_set_bb(Context.raw.picked_color.base, a.getUint8(i2));
+					Context.raw.picked_color.normal = color_set_rb(Context.raw.picked_color.normal, b.getUint8(i0));
+					Context.raw.picked_color.normal = color_set_gb(Context.raw.picked_color.normal, b.getUint8(i1));
+					Context.raw.picked_color.normal = color_set_bb(Context.raw.picked_color.normal, b.getUint8(i2));
+					Context.raw.picked_color.occlusion = c.getUint8(i0) / 255;
+					Context.raw.picked_color.roughness = c.getUint8(i1) / 255;
+					Context.raw.picked_color.metallic = c.getUint8(i2) / 255;
+					Context.raw.picked_color.height = c.getUint8(i3) / 255;
+					Context.raw.picked_color.opacity = a.getUint8(i3) / 255;
+					Context.raw.uvx_picked = d.getUint8(i0) / 255;
+					Context.raw.uvy_picked = d.getUint8(i1) / 255;
 					// Pick material
-					if (Context.raw.pickerSelectMaterial && Context.raw.colorPickerCallback == null) {
+					if (Context.raw.picker_select_material && Context.raw.color_picker_callback == null) {
 						// matid % 3 == 0 - normal, 1 - emission, 2 - subsurface
 						let matid = Math.floor((b.getUint8(3) - (b.getUint8(3) % 3)) / 3);
 						for (let m of Project.materials) {
 							if (m.id == matid) {
-								Context.setMaterial(m);
-								Context.raw.materialIdPicked = matid;
+								Context.set_material(m);
+								Context.raw.materialid_picked = matid;
 								break;
 							}
 						}
@@ -231,12 +231,12 @@ class RenderPathPaint {
 			}
 			else {
 				///if arm_voxels
-				if (Context.raw.tool == WorkspaceTool.ToolBake && Context.raw.bakeType == BakeType.BakeAO) {
+				if (Context.raw.tool == workspace_tool_t.BAKE && Context.raw.bake_type == bake_type_t.AO) {
 					if (RenderPathPaint.initVoxels) {
 						RenderPathPaint.initVoxels = false;
 						let _rp_gi = Config.raw.rp_gi;
 						Config.raw.rp_gi = true;
-						RenderPathBase.initVoxels();
+						RenderPathBase.init_voxels();
 						Config.raw.rp_gi = _rp_gi;
 					}
 					render_path_clear_image("voxels", 0x00000000);
@@ -249,7 +249,7 @@ class RenderPathPaint {
 				///end
 
 				let texpaint = "texpaint" + tid;
-				if (Context.raw.tool == WorkspaceTool.ToolBake && Context.raw.brushTime == time_delta()) {
+				if (Context.raw.tool == workspace_tool_t.BAKE && Context.raw.brush_time == time_delta()) {
 					// Clear to black on bake start
 					render_path_set_target(texpaint);
 					render_path_clear_target(0xff000000);
@@ -258,11 +258,11 @@ class RenderPathPaint {
 				render_path_set_target("texpaint_blend1");
 				render_path_bind_target("texpaint_blend0", "tex");
 				render_path_draw_shader("shader_datas/copy_pass/copyR8_pass");
-				let isMask = SlotLayer.isMask(Context.raw.layer);
+				let isMask = SlotLayer.is_mask(Context.raw.layer);
 				if (isMask) {
 					let ptid = Context.raw.layer.parent.id;
-					if (SlotLayer.isGroup(Context.raw.layer.parent)) { // Group mask
-						for (let c of SlotLayer.getChildren(Context.raw.layer.parent)) {
+					if (SlotLayer.is_group(Context.raw.layer.parent)) { // Group mask
+						for (let c of SlotLayer.get_children(Context.raw.layer.parent)) {
 							ptid = c.id;
 							break;
 						}
@@ -278,35 +278,35 @@ class RenderPathPaint {
 				}
 				render_path_bind_target("texpaint_blend1", "paintmask");
 				///if arm_voxels
-				if (Context.raw.tool == WorkspaceTool.ToolBake && Context.raw.bakeType == BakeType.BakeAO) {
+				if (Context.raw.tool == workspace_tool_t.BAKE && Context.raw.bake_type == bake_type_t.AO) {
 					render_path_bind_target("voxels", "voxels");
 				}
 				///end
-				if (Context.raw.colorIdPicked) {
+				if (Context.raw.colorid_picked) {
 					render_path_bind_target("texpaint_colorid", "texpaint_colorid");
 				}
 
 				// Read texcoords from gbuffer
-				let readTC = (Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.fillTypeHandle.position == FillType.FillFace) ||
-							  Context.raw.tool == WorkspaceTool.ToolClone ||
-							  Context.raw.tool == WorkspaceTool.ToolBlur ||
-							  Context.raw.tool == WorkspaceTool.ToolSmudge;
+				let readTC = (Context.raw.tool == workspace_tool_t.FILL && Context.raw.fill_type_handle.position == fill_type_t.FACE) ||
+							  Context.raw.tool == workspace_tool_t.CLONE ||
+							  Context.raw.tool == workspace_tool_t.BLUR ||
+							  Context.raw.tool == workspace_tool_t.SMUDGE;
 				if (readTC) {
 					render_path_bind_target("gbuffer2", "gbuffer2");
 				}
 
 				render_path_draw_meshes("paint");
 
-				if (Context.raw.tool == WorkspaceTool.ToolBake && Context.raw.bakeType == BakeType.BakeCurvature && Context.raw.bakeCurvSmooth > 0) {
+				if (Context.raw.tool == workspace_tool_t.BAKE && Context.raw.bake_type == bake_type_t.CURVATURE && Context.raw.bake_curv_smooth > 0) {
 					if (render_path_render_targets.get("texpaint_blur") == null) {
 						let t = render_target_create();
 						t.name = "texpaint_blur";
-						t.width = Math.floor(Config.getTextureResX() * 0.95);
-						t.height = Math.floor(Config.getTextureResY() * 0.95);
+						t.width = Math.floor(Config.get_texture_res_x() * 0.95);
+						t.height = Math.floor(Config.get_texture_res_y() * 0.95);
 						t.format = "RGBA32";
 						render_path_create_render_target(t);
 					}
-					let blurs = Math.round(Context.raw.bakeCurvSmooth);
+					let blurs = Math.round(Context.raw.bake_curv_smooth);
 					for (let i = 0; i < blurs; ++i) {
 						render_path_set_target("texpaint_blur");
 						render_path_bind_target(texpaint, "tex");
@@ -317,7 +317,7 @@ class RenderPathPaint {
 					}
 				}
 
-				if (dilation && Config.raw.dilate == DilateType.DilateInstant) {
+				if (dilation && Config.raw.dilate == dilate_type_t.INSTANT) {
 					RenderPathPaint.dilate(true, false);
 				}
 			}
@@ -336,10 +336,10 @@ class RenderPathPaint {
 			render_path_bind_target("texpaint_blend1", "paintmask");
 
 			// Read texcoords from gbuffer
-			let readTC = (Context.raw.tool == WorkspaceTool.ToolFill && Context.raw.fillTypeHandle.position == FillType.FillFace) ||
-						  Context.raw.tool == WorkspaceTool.ToolClone ||
-						  Context.raw.tool == WorkspaceTool.ToolBlur ||
-						  Context.raw.tool == WorkspaceTool.ToolSmudge;
+			let readTC = (Context.raw.tool == workspace_tool_t.FILL && Context.raw.fill_type_handle.position == fill_type_t.FACE) ||
+						  Context.raw.tool == workspace_tool_t.CLONE ||
+						  Context.raw.tool == workspace_tool_t.BLUR ||
+						  Context.raw.tool == workspace_tool_t.SMUDGE;
 			if (readTC) {
 				render_path_bind_target("gbuffer2", "gbuffer2");
 			}
@@ -347,14 +347,14 @@ class RenderPathPaint {
 
 			let materialContexts: material_context_t[] = [];
 			let shaderContexts: shader_context_t[] = [];
-			let mats = Project.paintObjects[0].materials;
-			mesh_object_get_contexts(Project.paintObjects[0], "paint", mats, materialContexts, shaderContexts);
+			let mats = Project.paint_objects[0].materials;
+			mesh_object_get_contexts(Project.paint_objects[0], "paint", mats, materialContexts, shaderContexts);
 
 			let cc_context = shaderContexts[0];
 			if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data();
 			g4_set_pipeline(cc_context._.pipe_state);
 			uniforms_set_context_consts(cc_context,_render_path_bind_params);
-			uniforms_set_obj_consts(cc_context, Project.paintObjects[0].base);
+			uniforms_set_obj_consts(cc_context, Project.paint_objects[0].base);
 			uniforms_set_material_consts(cc_context, materialContexts[0]);
 			g4_set_vertex_buffer(const_data_screen_aligned_vb);
 			g4_set_index_buffer(const_data_screen_aligned_ib);
@@ -364,9 +364,9 @@ class RenderPathPaint {
 		}
 	}
 
-	static useLiveLayer = (use: bool) => {
+	static use_live_layer = (use: bool) => {
 		let tid = Context.raw.layer.id;
-		let hid = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
+		let hid = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
 		if (use) {
 			RenderPathPaint._texpaint = render_path_render_targets.get("texpaint" + tid);
 			RenderPathPaint._texpaint_undo = render_path_render_targets.get("texpaint_undo" + hid);
@@ -376,7 +376,7 @@ class RenderPathPaint {
 			RenderPathPaint._texpaint_pack = render_path_render_targets.get("texpaint_pack" + tid);
 			render_path_render_targets.set("texpaint_undo" + hid,render_path_render_targets.get("texpaint" + tid));
 			render_path_render_targets.set("texpaint" + tid,render_path_render_targets.get("texpaint_live"));
-			if (SlotLayer.isLayer(Context.raw.layer)) {
+			if (SlotLayer.is_layer(Context.raw.layer)) {
 				render_path_render_targets.set("texpaint_nor_undo" + hid,render_path_render_targets.get("texpaint_nor" + tid));
 				render_path_render_targets.set("texpaint_pack_undo" + hid,render_path_render_targets.get("texpaint_pack" + tid));
 				render_path_render_targets.set("texpaint_nor" + tid,render_path_render_targets.get("texpaint_nor_live"));
@@ -386,7 +386,7 @@ class RenderPathPaint {
 		else {
 			render_path_render_targets.set("texpaint" + tid, RenderPathPaint._texpaint);
 			render_path_render_targets.set("texpaint_undo" + hid, RenderPathPaint._texpaint_undo);
-			if (SlotLayer.isLayer(Context.raw.layer)) {
+			if (SlotLayer.is_layer(Context.raw.layer)) {
 				render_path_render_targets.set("texpaint_nor_undo" + hid, RenderPathPaint._texpaint_nor_undo);
 				render_path_render_targets.set("texpaint_pack_undo" + hid, RenderPathPaint._texpaint_pack_undo);
 				render_path_render_targets.set("texpaint_nor" + tid, RenderPathPaint._texpaint_nor);
@@ -396,15 +396,15 @@ class RenderPathPaint {
 		RenderPathPaint.liveLayerLocked = use;
 	}
 
-	static commandsLiveBrush = () => {
+	static commands_live_brush = () => {
 		let tool = Context.raw.tool;
-		if (tool != WorkspaceTool.ToolBrush &&
-			tool != WorkspaceTool.ToolEraser &&
-			tool != WorkspaceTool.ToolClone &&
-			tool != WorkspaceTool.ToolDecal &&
-			tool != WorkspaceTool.ToolText &&
-			tool != WorkspaceTool.ToolBlur &&
-			tool != WorkspaceTool.ToolSmudge) {
+		if (tool != workspace_tool_t.BRUSH &&
+			tool != workspace_tool_t.ERASER &&
+			tool != workspace_tool_t.CLONE &&
+			tool != workspace_tool_t.DECAL &&
+			tool != workspace_tool_t.TEXT &&
+			tool != workspace_tool_t.BLUR &&
+			tool != workspace_tool_t.SMUDGE) {
 				return;
 		}
 
@@ -415,7 +415,7 @@ class RenderPathPaint {
 		}
 
 		let tid = Context.raw.layer.id;
-		if (SlotLayer.isMask(Context.raw.layer)) {
+		if (SlotLayer.is_mask(Context.raw.layer)) {
 			render_path_set_target("texpaint_live");
 			render_path_bind_target("texpaint" + tid, "tex");
 			render_path_draw_shader("shader_datas/copy_pass/copy_pass");
@@ -428,96 +428,96 @@ class RenderPathPaint {
 			render_path_draw_shader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
 		}
 
-		RenderPathPaint.useLiveLayer(true);
+		RenderPathPaint.use_live_layer(true);
 
 		RenderPathPaint.liveLayerDrawn = 2;
 
 		UIView2D.hwnd.redraws = 2;
-		let _x = Context.raw.paintVec.x;
-		let _y = Context.raw.paintVec.y;
-		if (Context.raw.brushLocked) {
-			Context.raw.paintVec.x = (Context.raw.lockStartedX - app_x()) / app_w();
-			Context.raw.paintVec.y = (Context.raw.lockStartedY - app_y()) / app_h();
-		}
-		let _lastX = Context.raw.lastPaintVecX;
-		let _lastY = Context.raw.lastPaintVecY;
+		let _x = Context.raw.paint_vec.x;
+		let _y = Context.raw.paint_vec.y;
+		if (Context.raw.brush_locked) {
+			Context.raw.paint_vec.x = (Context.raw.lock_started_x - app_x()) / app_w();
+			Context.raw.paint_vec.y = (Context.raw.lock_started_y - app_y()) / app_h();
+		}
+		let _lastX = Context.raw.last_paint_vec_x;
+		let _lastY = Context.raw.last_paint_vec_y;
 		let _pdirty = Context.raw.pdirty;
-		Context.raw.lastPaintVecX = Context.raw.paintVec.x;
-		Context.raw.lastPaintVecY = Context.raw.paintVec.y;
+		Context.raw.last_paint_vec_x = Context.raw.paint_vec.x;
+		Context.raw.last_paint_vec_y = Context.raw.paint_vec.y;
 		if (Operator.shortcut(Config.keymap.brush_ruler)) {
-			Context.raw.lastPaintVecX = Context.raw.lastPaintX;
-			Context.raw.lastPaintVecY = Context.raw.lastPaintY;
+			Context.raw.last_paint_vec_x = Context.raw.last_paint_x;
+			Context.raw.last_paint_vec_y = Context.raw.last_paint_y;
 		}
 		Context.raw.pdirty = 2;
 
-		RenderPathPaint.commandsSymmetry();
-		RenderPathPaint.commandsPaint();
+		RenderPathPaint.commands_symmetry();
+		RenderPathPaint.commands_paint();
 
-		RenderPathPaint.useLiveLayer(false);
+		RenderPathPaint.use_live_layer(false);
 
-		Context.raw.paintVec.x = _x;
-		Context.raw.paintVec.y = _y;
-		Context.raw.lastPaintVecX = _lastX;
-		Context.raw.lastPaintVecY = _lastY;
+		Context.raw.paint_vec.x = _x;
+		Context.raw.paint_vec.y = _y;
+		Context.raw.last_paint_vec_x = _lastX;
+		Context.raw.last_paint_vec_y = _lastY;
 		Context.raw.pdirty = _pdirty;
-		Context.raw.brushBlendDirty = true;
+		Context.raw.brush_blend_dirty = true;
 	}
 
-	static commandsCursor = () => {
+	static commands_cursor = () => {
 		if (!Config.raw.brush_3d) return;
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown);
 		let tool = Context.raw.tool;
-		if (tool != WorkspaceTool.ToolBrush &&
-			tool != WorkspaceTool.ToolEraser &&
-			tool != WorkspaceTool.ToolClone &&
-			tool != WorkspaceTool.ToolBlur &&
-			tool != WorkspaceTool.ToolSmudge &&
-			tool != WorkspaceTool.ToolParticle &&
+		if (tool != workspace_tool_t.BRUSH &&
+			tool != workspace_tool_t.ERASER &&
+			tool != workspace_tool_t.CLONE &&
+			tool != workspace_tool_t.BLUR &&
+			tool != workspace_tool_t.SMUDGE &&
+			tool != workspace_tool_t.PARTICLE &&
 			!decalMask) {
 				return;
 		}
 
 		let fillLayer = Context.raw.layer.fill_layer != null;
-		let groupLayer = SlotLayer.isGroup(Context.raw.layer);
-		if (!Base.uiEnabled || Base.isDragging || fillLayer || groupLayer) {
+		let groupLayer = SlotLayer.is_group(Context.raw.layer);
+		if (!Base.ui_enabled || Base.is_dragging || fillLayer || groupLayer) {
 			return;
 		}
 
-		let mx = Context.raw.paintVec.x;
-		let my = 1.0 - Context.raw.paintVec.y;
-		if (Context.raw.brushLocked) {
-			mx = (Context.raw.lockStartedX - app_x()) / app_w();
-			my = 1.0 - (Context.raw.lockStartedY - app_y()) / app_h();
+		let mx = Context.raw.paint_vec.x;
+		let my = 1.0 - Context.raw.paint_vec.y;
+		if (Context.raw.brush_locked) {
+			mx = (Context.raw.lock_started_x - app_x()) / app_w();
+			my = 1.0 - (Context.raw.lock_started_y - app_y()) / app_h();
 		}
-		let radius = decalMask ? Context.raw.brushDecalMaskRadius : Context.raw.brushRadius;
-		RenderPathPaint.drawCursor(mx, my, Context.raw.brushNodesRadius * radius / 3.4);
+		let radius = decalMask ? Context.raw.brush_decal_mask_radius : Context.raw.brush_radius;
+		RenderPathPaint.draw_cursor(mx, my, Context.raw.brush_nodes_radius * radius / 3.4);
 	}
 
-	static drawCursor = (mx: f32, my: f32, radius: f32, tintR = 1.0, tintG = 1.0, tintB = 1.0) => {
+	static draw_cursor = (mx: f32, my: f32, radius: f32, tintR = 1.0, tintG = 1.0, tintB = 1.0) => {
 		let plane: mesh_object_t = scene_get_child(".Plane").ext;
 		let geom = plane.data;
 
-		if (Base.pipeCursor == null) Base.makeCursorPipe();
+		if (Base.pipe_cursor == null) Base.make_cursor_pipe();
 
 		render_path_set_target("");
-		g4_set_pipeline(Base.pipeCursor);
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		g4_set_pipeline(Base.pipe_cursor);
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown);
-		let img = (decal && !decalMask) ? Context.raw.decalImage : Res.get("cursor.k");
-		g4_set_tex(Base.cursorTex, img);
+		let img = (decal && !decalMask) ? Context.raw.decal_image : Res.get("cursor.k");
+		g4_set_tex(Base.cursor_tex, img);
 		let gbuffer0 = render_path_render_targets.get("gbuffer0")._image;
-		g4_set_tex_depth(Base.cursorGbufferD, gbuffer0);
-		g4_set_float2(Base.cursorMouse, mx, my);
-		g4_set_float2(Base.cursorTexStep, 1 / gbuffer0.width, 1 / gbuffer0.height);
-		g4_set_float(Base.cursorRadius, radius);
+		g4_set_tex_depth(Base.cursor_gbufferd, gbuffer0);
+		g4_set_float2(Base.cursor_mouse, mx, my);
+		g4_set_float2(Base.cursor_tex_step, 1 / gbuffer0.width, 1 / gbuffer0.height);
+		g4_set_float(Base.cursor_radius, radius);
 		let right = vec4_normalize(camera_object_right_world(scene_camera));
-		g4_set_float3(Base.cursorCameraRight, right.x, right.y, right.z);
-		g4_set_float3(Base.cursorTint, tintR, tintG, tintB);
-		g4_set_mat(Base.cursorVP, scene_camera.vp);
+		g4_set_float3(Base.cursor_camera_right, right.x, right.y, right.z);
+		g4_set_float3(Base.cursor_tint, tintR, tintG, tintB);
+		g4_set_mat(Base.cursor_vp, scene_camera.vp);
 		let helpMat = mat4_identity();
 		mat4_get_inv(helpMat, scene_camera.vp);
-		g4_set_mat(Base.cursorInvVP, helpMat);
+		g4_set_mat(Base.cursor_inv_vp, helpMat);
 		///if (krom_metal || krom_vulkan)
 		g4_set_vertex_buffer(mesh_data_get(geom, [{name: "tex", data: "short2norm"}]));
 		///else
@@ -530,74 +530,74 @@ class RenderPathPaint {
 		render_path_end();
 	}
 
-	static commandsSymmetry = () => {
-		if (Context.raw.symX || Context.raw.symY || Context.raw.symZ) {
+	static commands_symmetry = () => {
+		if (Context.raw.sym_x || Context.raw.sym_y || Context.raw.sym_z) {
 			Context.raw.ddirty = 2;
-			let t = Context.raw.paintObject.base.transform;
+			let t = Context.raw.paint_object.base.transform;
 			let sx = t.scale.x;
 			let sy = t.scale.y;
 			let sz = t.scale.z;
-			if (Context.raw.symX) {
+			if (Context.raw.sym_x) {
 				vec4_set(t.scale, -sx, sy, sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symY) {
+			if (Context.raw.sym_y) {
 				vec4_set(t.scale, sx, -sy, sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symZ) {
+			if (Context.raw.sym_z) {
 				vec4_set(t.scale, sx, sy, -sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symX && Context.raw.symY) {
+			if (Context.raw.sym_x && Context.raw.sym_y) {
 				vec4_set(t.scale, -sx, -sy, sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symX && Context.raw.symZ) {
+			if (Context.raw.sym_x && Context.raw.sym_z) {
 				vec4_set(t.scale, -sx, sy, -sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symY && Context.raw.symZ) {
+			if (Context.raw.sym_y && Context.raw.sym_z) {
 				vec4_set(t.scale, sx, -sy, -sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
-			if (Context.raw.symX && Context.raw.symY && Context.raw.symZ) {
+			if (Context.raw.sym_x && Context.raw.sym_y && Context.raw.sym_z) {
 				vec4_set(t.scale, -sx, -sy, -sz);
 				transform_build_matrix(t);
-				RenderPathPaint.commandsPaint(false);
+				RenderPathPaint.commands_paint(false);
 			}
 			vec4_set(t.scale, sx, sy, sz);
 			transform_build_matrix(t);
 		}
 	}
 
-	static paintEnabled = (): bool => {
+	static paint_enabled = (): bool => {
 		///if is_paint
-		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != WorkspaceTool.ToolPicker && Context.raw.tool != WorkspaceTool.ToolMaterial && Context.raw.tool != WorkspaceTool.ToolColorId;
+		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != workspace_tool_t.PICKER && Context.raw.tool != workspace_tool_t.MATERIAL && Context.raw.tool != workspace_tool_t.COLORID;
 		///end
 
 		///if is_sculpt
-		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != WorkspaceTool.ToolPicker && Context.raw.tool != WorkspaceTool.ToolMaterial;
+		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != workspace_tool_t.PICKER && Context.raw.tool != workspace_tool_t.MATERIAL;
 		///end
 
-		let groupLayer = SlotLayer.isGroup(Context.raw.layer);
-		return !fillLayer && !groupLayer && !Context.raw.foregroundEvent;
+		let groupLayer = SlotLayer.is_group(Context.raw.layer);
+		return !fillLayer && !groupLayer && !Context.raw.foreground_event;
 	}
 
-	static liveBrushDirty = () => {
+	static live_brush_dirty = () => {
 		let mx = RenderPathPaint.lastX;
 		let my = RenderPathPaint.lastY;
 		RenderPathPaint.lastX = mouse_view_x();
 		RenderPathPaint.lastY = mouse_view_y();
 		if (Config.raw.brush_live && Context.raw.pdirty <= 0) {
-			let moved = (mx != RenderPathPaint.lastX || my != RenderPathPaint.lastY) && (Context.inViewport() || Context.in2dView());
-			if (moved || Context.raw.brushLocked) {
+			let moved = (mx != RenderPathPaint.lastX || my != RenderPathPaint.lastY) && (Context.in_viewport() || Context.in_2d_view());
+			if (moved || Context.raw.brush_locked) {
 				Context.raw.rdirty = 2;
 			}
 		}
@@ -607,18 +607,18 @@ class RenderPathPaint {
 
 		///if is_paint
 		if (!RenderPathPaint.dilated) {
-			RenderPathPaint.dilate(Config.raw.dilate == DilateType.DilateDelayed, true);
+			RenderPathPaint.dilate(Config.raw.dilate == dilate_type_t.DELAYED, true);
 			RenderPathPaint.dilated = true;
 		}
 		///end
 
-		if (!RenderPathPaint.paintEnabled()) return;
+		if (!RenderPathPaint.paint_enabled()) return;
 
 		///if is_paint
-		RenderPathPaint.pushUndoLast = History.pushUndo;
+		RenderPathPaint.pushUndoLast = History.push_undo;
 		///end
 
-		if (History.pushUndo && History.undoLayers != null) {
+		if (History.push_undo && History.undo_layers != null) {
 			History.paint();
 
 			///if is_sculpt
@@ -633,136 +633,136 @@ class RenderPathPaint {
 		}
 
 		///if is_sculpt
-		if (History.pushUndo2 && History.undoLayers != null) {
+		if (History.push_undo2 && History.undo_layers != null) {
 			History.paint();
 		}
 		///end
 
 		if (Context.raw.paint2d) {
-			RenderPathPaint.setPlaneMesh();
+			RenderPathPaint.set_plane_mesh();
 		}
 
 		if (RenderPathPaint.liveLayerDrawn > 0) RenderPathPaint.liveLayerDrawn--;
 
-		if (Config.raw.brush_live && Context.raw.pdirty <= 0 && Context.raw.ddirty <= 0 && Context.raw.brushTime == 0) {
+		if (Config.raw.brush_live && Context.raw.pdirty <= 0 && Context.raw.ddirty <= 0 && Context.raw.brush_time == 0) {
 			// Depth is unchanged, draw before gbuffer gets updated
-			RenderPathPaint.commandsLiveBrush();
+			RenderPathPaint.commands_live_brush();
 		}
 	}
 
 	static end = () => {
-		RenderPathPaint.commandsCursor();
+		RenderPathPaint.commands_cursor();
 		Context.raw.ddirty--;
 		Context.raw.rdirty--;
 
-		if (!RenderPathPaint.paintEnabled()) return;
+		if (!RenderPathPaint.paint_enabled()) return;
 		Context.raw.pdirty--;
 	}
 
 	static draw = () => {
-		if (!RenderPathPaint.paintEnabled()) return;
+		if (!RenderPathPaint.paint_enabled()) return;
 
 		///if (!krom_ios) // No hover on iPad, decals are painted by pen release
-		if (Config.raw.brush_live && Context.raw.pdirty <= 0 && Context.raw.ddirty > 0 && Context.raw.brushTime == 0) {
+		if (Config.raw.brush_live && Context.raw.pdirty <= 0 && Context.raw.ddirty > 0 && Context.raw.brush_time == 0) {
 			// gbuffer has been updated now but brush will lag 1 frame
-			RenderPathPaint.commandsLiveBrush();
+			RenderPathPaint.commands_live_brush();
 		}
 		///end
 
-		if (History.undoLayers != null) {
-			RenderPathPaint.commandsSymmetry();
+		if (History.undo_layers != null) {
+			RenderPathPaint.commands_symmetry();
 
 			if (Context.raw.pdirty > 0) RenderPathPaint.dilated = false;
 
 			///if is_paint
-			if (Context.raw.tool == WorkspaceTool.ToolBake) {
+			if (Context.raw.tool == workspace_tool_t.BAKE) {
 
 				///if (krom_direct3d12 || krom_vulkan || krom_metal)
-				let isRaytracedBake = (Context.raw.bakeType == BakeType.BakeAO  ||
-					Context.raw.bakeType == BakeType.BakeLightmap ||
-					Context.raw.bakeType == BakeType.BakeBentNormal ||
-					Context.raw.bakeType == BakeType.BakeThickness);
+				let isRaytracedBake = (Context.raw.bake_type == bake_type_t.AO  ||
+					Context.raw.bake_type == bake_type_t.LIGHTMAP ||
+					Context.raw.bake_type == bake_type_t.BENT_NORMAL ||
+					Context.raw.bake_type == bake_type_t.THICKNESS);
 				///end
 
-				if (Context.raw.bakeType == BakeType.BakeNormal || Context.raw.bakeType == BakeType.BakeHeight || Context.raw.bakeType == BakeType.BakeDerivative) {
+				if (Context.raw.bake_type == bake_type_t.NORMAL || Context.raw.bake_type == bake_type_t.HEIGHT || Context.raw.bake_type == bake_type_t.DERIVATIVE) {
 					if (!RenderPathPaint.baking && Context.raw.pdirty > 0) {
 						RenderPathPaint.baking = true;
-						let _bakeType = Context.raw.bakeType;
-						Context.raw.bakeType = Context.raw.bakeType == BakeType.BakeNormal ? BakeType.BakeNormalObject : BakeType.BakePosition; // Bake high poly data
-						MakeMaterial.parsePaintMaterial();
-						let _paintObject = Context.raw.paintObject;
-						let highPoly = Project.paintObjects[Context.raw.bakeHighPoly];
+						let _bakeType = Context.raw.bake_type;
+						Context.raw.bake_type = Context.raw.bake_type == bake_type_t.NORMAL ? bake_type_t.NORMAL_OBJECT : bake_type_t.POSITION; // Bake high poly data
+						MakeMaterial.parse_paint_material();
+						let _paintObject = Context.raw.paint_object;
+						let highPoly = Project.paint_objects[Context.raw.bake_high_poly];
 						let _visible = highPoly.base.visible;
 						highPoly.base.visible = true;
-						Context.selectPaintObject(highPoly);
-						RenderPathPaint.commandsPaint();
+						Context.select_paint_object(highPoly);
+						RenderPathPaint.commands_paint();
 						highPoly.base.visible = _visible;
 						if (RenderPathPaint.pushUndoLast) History.paint();
-						Context.selectPaintObject(_paintObject);
+						Context.select_paint_object(_paintObject);
 
 						let _renderFinal = () => {
-							Context.raw.bakeType = _bakeType;
-							MakeMaterial.parsePaintMaterial();
+							Context.raw.bake_type = _bakeType;
+							MakeMaterial.parse_paint_material();
 							Context.raw.pdirty = 1;
-							RenderPathPaint.commandsPaint();
+							RenderPathPaint.commands_paint();
 							Context.raw.pdirty = 0;
 							RenderPathPaint.baking = false;
 						}
 						let _renderDeriv = () => {
-							Context.raw.bakeType = BakeType.BakeHeight;
-							MakeMaterial.parsePaintMaterial();
+							Context.raw.bake_type = bake_type_t.HEIGHT;
+							MakeMaterial.parse_paint_material();
 							Context.raw.pdirty = 1;
-							RenderPathPaint.commandsPaint();
+							RenderPathPaint.commands_paint();
 							Context.raw.pdirty = 0;
 							if (RenderPathPaint.pushUndoLast) History.paint();
 							app_notify_on_init(_renderFinal);
 						}
-						let bakeType = Context.raw.bakeType as BakeType;
-						app_notify_on_init(bakeType == BakeType.BakeDerivative ? _renderDeriv : _renderFinal);
+						let bakeType = Context.raw.bake_type as bake_type_t;
+						app_notify_on_init(bakeType == bake_type_t.DERIVATIVE ? _renderDeriv : _renderFinal);
 					}
 				}
-				else if (Context.raw.bakeType == BakeType.BakeObjectID) {
-					let _layerFilter = Context.raw.layerFilter;
-					let _paintObject = Context.raw.paintObject;
-					let isMerged = Context.raw.mergedObject != null;
-					let _visible = isMerged && Context.raw.mergedObject.base.visible;
-					Context.raw.layerFilter = 1;
-					if (isMerged) Context.raw.mergedObject.base.visible = false;
-
-					for (let p of Project.paintObjects) {
-						Context.selectPaintObject(p);
-						RenderPathPaint.commandsPaint();
+				else if (Context.raw.bake_type == bake_type_t.OBJECTID) {
+					let _layerFilter = Context.raw.layer_filter;
+					let _paintObject = Context.raw.paint_object;
+					let isMerged = Context.raw.merged_object != null;
+					let _visible = isMerged && Context.raw.merged_object.base.visible;
+					Context.raw.layer_filter = 1;
+					if (isMerged) Context.raw.merged_object.base.visible = false;
+
+					for (let p of Project.paint_objects) {
+						Context.select_paint_object(p);
+						RenderPathPaint.commands_paint();
 					}
 
-					Context.raw.layerFilter = _layerFilter;
-					Context.selectPaintObject(_paintObject);
-					if (isMerged) Context.raw.mergedObject.base.visible = _visible;
+					Context.raw.layer_filter = _layerFilter;
+					Context.select_paint_object(_paintObject);
+					if (isMerged) Context.raw.merged_object.base.visible = _visible;
 				}
 				///if (krom_direct3d12 || krom_vulkan || krom_metal)
 				else if (isRaytracedBake) {
-					let dirty = RenderPathRaytraceBake.commands(MakeMaterial.parsePaintMaterial);
-					if (dirty) UIHeader.headerHandle.redraws = 2;
-					if (Config.raw.dilate == DilateType.DilateInstant) { // && Context.raw.pdirty == 1
+					let dirty = RenderPathRaytraceBake.commands(MakeMaterial.parse_paint_material);
+					if (dirty) UIHeader.header_handle.redraws = 2;
+					if (Config.raw.dilate == dilate_type_t.INSTANT) { // && Context.raw.pdirty == 1
 						RenderPathPaint.dilate(true, false);
 					}
 				}
 				///end
 				else {
-					RenderPathPaint.commandsPaint();
+					RenderPathPaint.commands_paint();
 				}
 			}
 			else { // Paint
-				RenderPathPaint.commandsPaint();
+				RenderPathPaint.commands_paint();
 			}
 			///end
 
 			///if is_sculpt
-			RenderPathPaint.commandsPaint();
+			RenderPathPaint.commands_paint();
 			///end
 		}
 
-		if (Context.raw.brushBlendDirty) {
-			Context.raw.brushBlendDirty = false;
+		if (Context.raw.brush_blend_dirty) {
+			Context.raw.brush_blend_dirty = false;
 			///if krom_metal
 			render_path_set_target("texpaint_blend0");
 			render_path_clear_target(0x00000000);
@@ -775,37 +775,37 @@ class RenderPathPaint {
 		}
 
 		if (Context.raw.paint2d) {
-			RenderPathPaint.restorePlaneMesh();
+			RenderPathPaint.restore_plane_mesh();
 		}
 	}
 
-	static setPlaneMesh = () => {
-		Context.raw.paint2dView = true;
-		RenderPathPaint.painto = Context.raw.paintObject;
+	static set_plane_mesh = () => {
+		Context.raw.paint2d_view = true;
+		RenderPathPaint.painto = Context.raw.paint_object;
 		RenderPathPaint.visibles = [];
-		for (let p of Project.paintObjects) {
+		for (let p of Project.paint_objects) {
 			RenderPathPaint.visibles.push(p.base.visible);
 			p.base.visible = false;
 		}
-		if (Context.raw.mergedObject != null) {
-			RenderPathPaint.mergedObjectVisible = Context.raw.mergedObject.base.visible;
-			Context.raw.mergedObject.base.visible = false;
+		if (Context.raw.merged_object != null) {
+			RenderPathPaint.mergedObjectVisible = Context.raw.merged_object.base.visible;
+			Context.raw.merged_object.base.visible = false;
 		}
 
 		let cam = scene_camera;
-		mat4_set_from(Context.raw.savedCamera, cam.base.transform.local);
+		mat4_set_from(Context.raw.saved_camera, cam.base.transform.local);
 		RenderPathPaint.savedFov = cam.data.fov;
-		Viewport.updateCameraType(CameraType.CameraPerspective);
+		Viewport.update_camera_type(camera_type_t.PERSPECTIVE);
 		let m = mat4_identity();
 		mat4_translate(m, 0, 0, 0.5);
 		transform_set_matrix(cam.base.transform, m);
-		cam.data.fov = Base.defaultFov;
+		cam.data.fov = Base.default_fov;
 		camera_object_build_proj(cam);
 		camera_object_build_mat(cam);
 
-		let tw = 0.95 * UIView2D.panScale;
-		let tx = UIView2D.panX / UIView2D.ww;
-		let ty = UIView2D.panY / app_h();
+		let tw = 0.95 * UIView2D.pan_scale;
+		let tx = UIView2D.pan_x / UIView2D.ww;
+		let ty = UIView2D.pan_y / app_h();
 		mat4_set_identity(m);
 		mat4_scale(m, vec4_create(tw, tw, 1));
 		mat4_set_loc(m, vec4_create(tx, ty, 0));
@@ -813,7 +813,7 @@ class RenderPathPaint {
 		mat4_get_inv(m2, scene_camera.vp);
 		mat4_mult_mat(m, m2);
 
-		let tiled = UIView2D.tiledShow;
+		let tiled = UIView2D.tiled_show;
 		if (tiled && scene_get_child(".PlaneTiled") == null) {
 			// 3x3 planes
 			let posa = [32767,0,-32767,0,10922,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,10922,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,32767,0,-32767,0,10922,0,10922,0,10922,0,-10922,0,32767,0,-10922,0,10922,0,32767,0,10922,0,10922,0,32767,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,10922,0,-32767,0,-10922,0,32767,0,-10922,0,10922,0,10922,0,10922,0,-10922,0,-10922,0,-32767,0,-32767,0,-10922,0,-32767,0,-32767,0,10922,0,-32767,0,-10922,0,-10922,0,-10922,0,-32767,0,32767,0,-32767,0,32767,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,10922,0,-10922,0,10922,0,-10922,0,10922,0,-10922,0,32767,0,-32767,0,32767,0,10922,0,10922,0,10922,0,32767,0,-10922,0,32767,0,32767,0,10922,0,32767,0,32767,0,10922,0,32767,0,-10922,0,-10922,0,-10922,0,10922,0,-32767,0,10922,0,32767,0,-10922,0,32767,0,10922,0,10922,0,10922,0,-10922,0,-32767,0,-10922,0,-10922,0,-32767,0,-10922,0,10922,0,-32767,0,10922,0,-10922,0,-10922,0,-10922,0];
@@ -841,42 +841,42 @@ class RenderPathPaint {
 
 		RenderPathPaint.planeo = scene_get_child(tiled ? ".PlaneTiled" : ".Plane").ext;
 		RenderPathPaint.planeo.base.visible = true;
-		Context.raw.paintObject = RenderPathPaint.planeo;
+		Context.raw.paint_object = RenderPathPaint.planeo;
 
 		let v = vec4_create();
 		let sx = vec4_len(vec4_set(v, m.m[0], m.m[1], m.m[2]));
 		quat_from_euler(RenderPathPaint.planeo.base.transform.rot, -Math.PI / 2, 0, 0);
 		vec4_set(RenderPathPaint.planeo.base.transform.scale, sx, 1.0, sx);
-		RenderPathPaint.planeo.base.transform.scale.z *= Config.getTextureResY() / Config.getTextureResX();
+		RenderPathPaint.planeo.base.transform.scale.z *= Config.get_texture_res_y() / Config.get_texture_res_x();
 		vec4_set(RenderPathPaint.planeo.base.transform.loc, m.m[12], -m.m[13], 0.0);
 		transform_build_matrix(RenderPathPaint.planeo.base.transform);
 	}
 
-	static restorePlaneMesh = () => {
-		Context.raw.paint2dView = false;
+	static restore_plane_mesh = () => {
+		Context.raw.paint2d_view = false;
 		RenderPathPaint.planeo.base.visible = false;
 		vec4_set(RenderPathPaint.planeo.base.transform.loc, 0.0, 0.0, 0.0);
-		for (let i = 0; i < Project.paintObjects.length; ++i) {
-			Project.paintObjects[i].base.visible = RenderPathPaint.visibles[i];
+		for (let i = 0; i < Project.paint_objects.length; ++i) {
+			Project.paint_objects[i].base.visible = RenderPathPaint.visibles[i];
 		}
-		if (Context.raw.mergedObject != null) {
-			Context.raw.mergedObject.base.visible = RenderPathPaint.mergedObjectVisible;
+		if (Context.raw.merged_object != null) {
+			Context.raw.merged_object.base.visible = RenderPathPaint.mergedObjectVisible;
 		}
-		Context.raw.paintObject = RenderPathPaint.painto;
-		transform_set_matrix(scene_camera.base.transform, Context.raw.savedCamera);
+		Context.raw.paint_object = RenderPathPaint.painto;
+		transform_set_matrix(scene_camera.base.transform, Context.raw.saved_camera);
 		scene_camera.data.fov = RenderPathPaint.savedFov;
-		Viewport.updateCameraType(Context.raw.cameraType);
+		Viewport.update_camera_type(Context.raw.camera_type);
 		camera_object_build_proj(scene_camera);
 		camera_object_build_mat(scene_camera);
 
-		RenderPathBase.drawGbuffer();
+		RenderPathBase.draw_gbuffer();
 	}
 
-	static bindLayers = () => {
+	static bind_layers = () => {
 		///if is_paint
 		let isLive = Config.raw.brush_live && RenderPathPaint.liveLayerDrawn > 0;
-		let isMaterialTool = Context.raw.tool == WorkspaceTool.ToolMaterial;
-		if (isLive || isMaterialTool) RenderPathPaint.useLiveLayer(true);
+		let isMaterialTool = Context.raw.tool == workspace_tool_t.MATERIAL;
+		if (isLive || isMaterialTool) RenderPathPaint.use_live_layer(true);
 		///end
 
 		for (let i = 0; i < Project.layers.length; ++i) {
@@ -884,7 +884,7 @@ class RenderPathPaint {
 			render_path_bind_target("texpaint" + l.id, "texpaint" + l.id);
 
 			///if is_paint
-			if (SlotLayer.isLayer(l)) {
+			if (SlotLayer.is_layer(l)) {
 				render_path_bind_target("texpaint_nor" + l.id, "texpaint_nor" + l.id);
 				render_path_bind_target("texpaint_pack" + l.id, "texpaint_pack" + l.id);
 			}
@@ -892,19 +892,19 @@ class RenderPathPaint {
 		}
 	}
 
-	static unbindLayers = () => {
+	static unbind_layers = () => {
 		///if is_paint
 		let isLive = Config.raw.brush_live && RenderPathPaint.liveLayerDrawn > 0;
-		let isMaterialTool = Context.raw.tool == WorkspaceTool.ToolMaterial;
-		if (isLive || isMaterialTool) RenderPathPaint.useLiveLayer(false);
+		let isMaterialTool = Context.raw.tool == workspace_tool_t.MATERIAL;
+		if (isLive || isMaterialTool) RenderPathPaint.use_live_layer(false);
 		///end
 	}
 
 	static dilate = (base: bool, nor_pack: bool) => {
 		///if is_paint
 		if (Config.raw.dilate_radius > 0 && !Context.raw.paint2d) {
-			UtilUV.cacheDilateMap();
-			Base.makeTempImg();
+			UtilUV.cache_dilate_map();
+			Base.make_temp_img();
 			let tid = Context.raw.layer.id;
 			if (base) {
 				let texpaint = "texpaint";
@@ -915,7 +915,7 @@ class RenderPathPaint {
 				render_path_bind_target("temptex0", "tex");
 				render_path_draw_shader("shader_datas/dilate_pass/dilate_pass");
 			}
-			if (nor_pack && !SlotLayer.isMask(Context.raw.layer)) {
+			if (nor_pack && !SlotLayer.is_mask(Context.raw.layer)) {
 				render_path_set_target("temptex0");
 				render_path_bind_target("texpaint_nor" + tid, "tex");
 				render_path_draw_shader("shader_datas/copy_pass/copy_pass");

+ 16 - 16
armorpaint/Sources/RenderPathPreview.ts

@@ -25,10 +25,10 @@ class RenderPathPreview {
 		{
 			let t = render_target_create();
 			t.name = "mtex";
-			t.width = Math.floor(UtilRender.materialPreviewSize * 2.0);
-			t.height = Math.floor(UtilRender.materialPreviewSize * 2.0);
+			t.width = Math.floor(UtilRender.material_preview_size * 2.0);
+			t.height = Math.floor(UtilRender.material_preview_size * 2.0);
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			///if krom_opengl
 			t.depth_buffer = "mmain";
 			///end
@@ -38,10 +38,10 @@ class RenderPathPreview {
 		{
 			let t = render_target_create();
 			t.name = "mgbuffer0";
-			t.width = Math.floor(UtilRender.materialPreviewSize * 2.0);
-			t.height = Math.floor(UtilRender.materialPreviewSize * 2.0);
+			t.width = Math.floor(UtilRender.material_preview_size * 2.0);
+			t.height = Math.floor(UtilRender.material_preview_size * 2.0);
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			t.depth_buffer = "mmain";
 			render_path_create_render_target(t);
 		}
@@ -49,25 +49,25 @@ class RenderPathPreview {
 		{
 			let t = render_target_create();
 			t.name = "mgbuffer1";
-			t.width = Math.floor(UtilRender.materialPreviewSize * 2.0);
-			t.height = Math.floor(UtilRender.materialPreviewSize * 2.0);
+			t.width = Math.floor(UtilRender.material_preview_size * 2.0);
+			t.height = Math.floor(UtilRender.material_preview_size * 2.0);
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 
 		{
 			let t = render_target_create();
 			t.name = "mgbuffer2";
-			t.width = Math.floor(UtilRender.materialPreviewSize * 2.0);
-			t.height = Math.floor(UtilRender.materialPreviewSize * 2.0);
+			t.width = Math.floor(UtilRender.material_preview_size * 2.0);
+			t.height = Math.floor(UtilRender.material_preview_size * 2.0);
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 	}
 
-	static commandsPreview = () => {
+	static commands_preview = () => {
 		render_path_set_target("mgbuffer2");
 		render_path_clear_target(0xff000000);
 
@@ -100,7 +100,7 @@ class RenderPathPreview {
 		let framebuffer = "texpreview";
 		let selectedMat = Context.raw.material;
 		render_path_render_targets.get("texpreview")._image = selectedMat.image;
-		render_path_render_targets.get("texpreview_icon")._image = selectedMat.imageIcon;
+		render_path_render_targets.get("texpreview_icon")._image = selectedMat.image_icon;
 
 		render_path_set_target(framebuffer);
 		render_path_bind_target("mtex", "tex");
@@ -111,7 +111,7 @@ class RenderPathPreview {
 		render_path_draw_shader("shader_datas/supersample_resolve/supersample_resolve");
 	}
 
-	static commandsDecal = () => {
+	static commands_decal = () => {
 		render_path_set_target("gbuffer2");
 		render_path_clear_target(0xff000000);
 
@@ -142,7 +142,7 @@ class RenderPathPreview {
 		///end
 
 		let framebuffer = "texpreview";
-		render_path_render_targets.get("texpreview")._image = Context.raw.decalImage;
+		render_path_render_targets.get("texpreview")._image = Context.raw.decal_image;
 
 		render_path_set_target(framebuffer);
 

+ 6 - 6
armorpaint/Sources/SlotBrush.ts

@@ -3,24 +3,24 @@ class SlotBrushRaw {
 	nodes = zui_nodes_create();
 	canvas: zui_node_canvas_t;
 	image: image_t = null; // 200px
-	imageIcon: image_t = null; // 50px
-	previewReady = false;
+	image_icon: image_t = null; // 50px
+	preview_ready = false;
 	id = 0;
 }
 
 class SlotBrush {
-	static defaultCanvas: ArrayBuffer = null;
+	static default_canvas: ArrayBuffer = null;
 
 	static create(c: zui_node_canvas_t = null): SlotBrushRaw {
 		let raw = new SlotBrushRaw();
 		for (let brush of Project.brushes) if (brush.id >= raw.id) raw.id = brush.id + 1;
 
 		if (c == null) {
-			if (SlotBrush.defaultCanvas == null) { // Synchronous
+			if (SlotBrush.default_canvas == null) { // Synchronous
 				let b: ArrayBuffer = data_get_blob("default_brush.arm")
-				SlotBrush.defaultCanvas = b;
+				SlotBrush.default_canvas = b;
 			}
-			raw.canvas = armpack_decode(SlotBrush.defaultCanvas);
+			raw.canvas = armpack_decode(SlotBrush.default_canvas);
 			raw.canvas.name = "Brush " + (raw.id + 1);
 		}
 		else {

+ 1 - 1
armorpaint/Sources/SlotFont.ts

@@ -1,7 +1,7 @@
 
 class SlotFontRaw {
 	image: image_t = null; // 200px
-	previewReady = false;
+	preview_ready = false;
 	id = 0;
 	font: g2_font_t;
 	name: string;

+ 140 - 140
armorpaint/Sources/SlotLayer.ts

@@ -16,11 +16,11 @@ class SlotLayerRaw {
 	maskOpacity = 1.0; // Opacity mask
 	fill_layer: SlotMaterialRaw = null;
 	show_panel = true;
-	blending = BlendType.BlendMix;
+	blending = blend_type_t.MIX;
 	objectMask = 0;
 	scale = 1.0;
 	angle = 0.0;
-	uvType = UVType.UVMap;
+	uvType = uv_type_t.UVMAP;
 	paintBase = true;
 	paintOpac = true;
 	paintOcc = true;
@@ -37,7 +37,7 @@ class SlotLayerRaw {
 
 class SlotLayer {
 
-	static create(ext = "", type = LayerSlotType.SlotLayer, parent: SlotLayerRaw = null): SlotLayerRaw {
+	static create(ext = "", type = layer_slot_type_t.LAYER, parent: SlotLayerRaw = null): SlotLayerRaw {
 		let raw = new SlotLayerRaw();
 		if (ext == "") {
 			raw.id = 0;
@@ -47,14 +47,14 @@ class SlotLayer {
 		raw.ext = ext;
 		raw.parent = parent;
 
-		if (type == LayerSlotType.SlotGroup) {
+		if (type == layer_slot_type_t.GROUP) {
 			raw.name = "Group " + (raw.id + 1);
 		}
-		else if (type == LayerSlotType.SlotLayer) {
+		else if (type == layer_slot_type_t.LAYER) {
 			raw.name = "Layer " + (raw.id + 1);
 			///if is_paint
-			let format = Base.bitsHandle.position == TextureBits.Bits8  ? "RGBA32" :
-						 Base.bitsHandle.position == TextureBits.Bits16 ? "RGBA64" :
+			let format = Base.bits_handle.position == texture_bits_t.BITS8  ? "RGBA32" :
+						 Base.bits_handle.position == texture_bits_t.BITS16 ? "RGBA64" :
 						 									  			  "RGBA128";
 			///end
 
@@ -65,8 +65,8 @@ class SlotLayer {
 			{
 				let t = render_target_create();
 				t.name = "texpaint" + ext;
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = format;
 				raw.texpaint = render_path_create_render_target(t)._image;
 			}
@@ -75,21 +75,21 @@ class SlotLayer {
 			{
 				let t = render_target_create();
 				t.name = "texpaint_nor" + ext;
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = format;
 				raw.texpaint_nor = render_path_create_render_target(t)._image;
 			}
 			{
 				let t = render_target_create();
 				t.name = "texpaint_pack" + ext;
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = format;
 				raw.texpaint_pack = render_path_create_render_target(t)._image;
 			}
 
-			raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, tex_format_t.RGBA32);
+			raw.texpaint_preview = image_create_render_target(UtilRender.layer_preview_size, UtilRender.layer_preview_size, tex_format_t.RGBA32);
 			///end
 		}
 
@@ -97,18 +97,18 @@ class SlotLayer {
 		else { // Mask
 			raw.name = "Mask " + (raw.id + 1);
 			let format = "RGBA32"; // Full bits for undo support, R8 is used
-			raw.blending = BlendType.BlendAdd;
+			raw.blending = blend_type_t.ADD;
 
 			{
 				let t = render_target_create();
 				t.name = "texpaint" + ext;
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = format;
 				raw.texpaint = render_path_create_render_target(t)._image;
 			}
 
-			raw.texpaint_preview = image_create_render_target(UtilRender.layerPreviewSize, UtilRender.layerPreviewSize, tex_format_t.RGBA32);
+			raw.texpaint_preview = image_create_render_target(UtilRender.layer_preview_size, UtilRender.layer_preview_size, tex_format_t.RGBA32);
 		}
 		///end
 
@@ -118,14 +118,14 @@ class SlotLayer {
 	static delete = (raw: SlotLayerRaw) => {
 		SlotLayer.unload(raw);
 
-		if (SlotLayer.isLayer(raw)) {
-			let masks = SlotLayer.getMasks(raw, false); // Prevents deleting group masks
+		if (SlotLayer.is_layer(raw)) {
+			let masks = SlotLayer.get_masks(raw, false); // Prevents deleting group masks
 			if (masks != null) for (let m of masks) SlotLayer.delete(m);
 		}
-		else if (SlotLayer.isGroup(raw)) {
-			let children = SlotLayer.getChildren(raw);
+		else if (SlotLayer.is_group(raw)) {
+			let children = SlotLayer.get_children(raw);
 			if (children != null) for (let c of children) SlotLayer.delete(c);
-			let masks = SlotLayer.getMasks(raw);
+			let masks = SlotLayer.get_masks(raw);
 			if (masks != null) for (let m of masks) SlotLayer.delete(m);
 		}
 
@@ -133,14 +133,14 @@ class SlotLayer {
 		array_remove(Project.layers, raw);
 		// Undo can remove base layer and then restore it from undo layers
 		if (Project.layers.length > 0) {
-			Context.setLayer(Project.layers[lpos > 0 ? lpos - 1 : 0]);
+			Context.set_layer(Project.layers[lpos > 0 ? lpos - 1 : 0]);
 		}
 
 		// Do not remove empty groups if the last layer is deleted as this prevents redo from working properly
 	}
 
 	static unload = (raw: SlotLayerRaw) => {
-		if (SlotLayer.isGroup(raw)) return;
+		if (SlotLayer.is_group(raw)) return;
 
 		let _texpaint = raw.texpaint;
 		///if is_paint
@@ -157,11 +157,11 @@ class SlotLayer {
 			image_unload(_texpaint_preview);
 			///end
 		}
-		Base.notifyOnNextFrame(_next);
+		Base.notify_on_next_frame(_next);
 
 		render_path_render_targets.delete("texpaint" + raw.ext);
 		///if is_paint
-		if (SlotLayer.isLayer(raw)) {
+		if (SlotLayer.is_layer(raw)) {
 			render_path_render_targets.delete("texpaint_nor" + raw.ext);
 			render_path_render_targets.delete("texpaint_pack" + raw.ext);
 		}
@@ -169,7 +169,7 @@ class SlotLayer {
 	}
 
 	static swap = (raw: SlotLayerRaw, other: SlotLayerRaw) => {
-		if ((SlotLayer.isLayer(raw) || SlotLayer.isMask(raw)) && (SlotLayer.isLayer(other) || SlotLayer.isMask(other))) {
+		if ((SlotLayer.is_layer(raw) || SlotLayer.is_mask(raw)) && (SlotLayer.is_layer(other) || SlotLayer.is_mask(other))) {
 			render_path_render_targets.get("texpaint" + raw.ext)._image = other.texpaint;
 			render_path_render_targets.get("texpaint" + other.ext)._image = raw.texpaint;
 			let _texpaint = raw.texpaint;
@@ -184,7 +184,7 @@ class SlotLayer {
 		}
 
 		///if is_paint
-		if (SlotLayer.isLayer(raw) && SlotLayer.isLayer(other)) {
+		if (SlotLayer.is_layer(raw) && SlotLayer.is_layer(other)) {
 			render_path_render_targets.get("texpaint_nor" + raw.ext)._image = other.texpaint_nor;
 			render_path_render_targets.get("texpaint_pack" + raw.ext)._image = other.texpaint_pack;
 			render_path_render_targets.get("texpaint_nor" + other.ext)._image = raw.texpaint_nor;
@@ -199,7 +199,7 @@ class SlotLayer {
 		///end
 	}
 
-	static clear = (raw: SlotLayerRaw, baseColor = 0x00000000, baseImage: image_t = null, occlusion = 1.0, roughness = Base.defaultRough, metallic = 0.0) => {
+	static clear = (raw: SlotLayerRaw, baseColor = 0x00000000, baseImage: image_t = null, occlusion = 1.0, roughness = Base.default_rough, metallic = 0.0) => {
 		g4_begin(raw.texpaint);
 		g4_clear(baseColor); // Base
 		g4_end();
@@ -210,7 +210,7 @@ class SlotLayer {
 		}
 
 		///if is_paint
-		if (SlotLayer.isLayer(raw)) {
+		if (SlotLayer.is_layer(raw)) {
 			g4_begin(raw.texpaint_nor);
 			g4_clear(color_from_floats(0.5, 0.5, 1.0, 0.0)); // Nor
 			g4_end();
@@ -220,15 +220,15 @@ class SlotLayer {
 		}
 		///end
 
-		Context.raw.layerPreviewDirty = true;
+		Context.raw.layer_preview_dirty = true;
 		Context.raw.ddirty = 3;
 	}
 
-	static invertMask = (raw: SlotLayerRaw) => {
-		if (Base.pipeInvert8 == null) Base.makePipe();
+	static invert_mask = (raw: SlotLayerRaw) => {
+		if (Base.pipe_invert8 == null) Base.make_pipe();
 		let inverted = image_create_render_target(raw.texpaint.width, raw.texpaint.height, tex_format_t.RGBA32);
 		g2_begin(inverted);
-		g2_set_pipeline(Base.pipeInvert8);
+		g2_set_pipeline(Base.pipe_invert8);
 		g2_draw_image(raw.texpaint, 0, 0);
 		g2_set_pipeline(null);
 		g2_end();
@@ -236,23 +236,23 @@ class SlotLayer {
 		let _next = () => {
 			image_unload(_texpaint);
 		}
-		Base.notifyOnNextFrame(_next);
+		Base.notify_on_next_frame(_next);
 		raw.texpaint = render_path_render_targets.get("texpaint" + raw.id)._image = inverted;
-		Context.raw.layerPreviewDirty = true;
+		Context.raw.layer_preview_dirty = true;
 		Context.raw.ddirty = 3;
 	}
 
-	static applyMask = (raw: SlotLayerRaw) => {
+	static apply_mask = (raw: SlotLayerRaw) => {
 		if (raw.parent.fill_layer != null) {
-			SlotLayer.toPaintLayer(raw.parent);
+			SlotLayer.to_paint_layer(raw.parent);
 		}
-		if (SlotLayer.isGroup(raw.parent)) {
-			for (let c of SlotLayer.getChildren(raw.parent)) {
-				Base.applyMask(c, raw);
+		if (SlotLayer.is_group(raw.parent)) {
+			for (let c of SlotLayer.get_children(raw.parent)) {
+				Base.apply_mask(c, raw);
 			}
 		}
 		else {
-			Base.applyMask(raw.parent, raw);
+			Base.apply_mask(raw.parent, raw);
 		}
 		SlotLayer.delete(raw);
 	}
@@ -260,32 +260,32 @@ class SlotLayer {
 	static duplicate = (raw: SlotLayerRaw): SlotLayerRaw => {
 		let layers = Project.layers;
 		let i = layers.indexOf(raw) + 1;
-		let l = SlotLayer.create("", SlotLayer.isLayer(raw) ? LayerSlotType.SlotLayer : SlotLayer.isMask(raw) ? LayerSlotType.SlotMask : LayerSlotType.SlotGroup, raw.parent);
+		let l = SlotLayer.create("", SlotLayer.is_layer(raw) ? layer_slot_type_t.LAYER : SlotLayer.is_mask(raw) ? layer_slot_type_t.MASK : layer_slot_type_t.GROUP, raw.parent);
 		layers.splice(i, 0, l);
 
-		if (Base.pipeMerge == null) Base.makePipe();
-		if (SlotLayer.isLayer(raw)) {
+		if (Base.pipe_merge == null) Base.make_pipe();
+		if (SlotLayer.is_layer(raw)) {
 			g2_begin(l.texpaint);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_image(raw.texpaint, 0, 0);
 			g2_set_pipeline(null);
 			g2_end();
 			///if is_paint
 			g2_begin(l.texpaint_nor);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_image(raw.texpaint_nor, 0, 0);
 			g2_set_pipeline(null);
 			g2_end();
 			g2_begin(l.texpaint_pack);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_image(raw.texpaint_pack, 0, 0);
 			g2_set_pipeline(null);
 			g2_end();
 			///end
 		}
-		else if (SlotLayer.isMask(raw)) {
+		else if (SlotLayer.is_mask(raw)) {
 			g2_begin(l.texpaint);
-			g2_set_pipeline(Base.pipeCopy8);
+			g2_set_pipeline(Base.pipe_copy8);
 			g2_draw_image(raw.texpaint, 0, 0);
 			g2_set_pipeline(null);
 			g2_end();
@@ -294,7 +294,7 @@ class SlotLayer {
 		///if is_paint
 		g2_begin(l.texpaint_preview);
 		g2_clear(0x00000000);
-		g2_set_pipeline(Base.pipeCopy);
+		g2_set_pipeline(Base.pipe_copy);
 		g2_draw_scaled_image(raw.texpaint_preview, 0, 0, raw.texpaint_preview.width, raw.texpaint_preview.height);
 		g2_set_pipeline(null);
 		g2_end();
@@ -323,16 +323,16 @@ class SlotLayer {
 		return l;
 	}
 
-	static resizeAndSetBits = (raw: SlotLayerRaw) => {
-		let resX = Config.getTextureResX();
-		let resY = Config.getTextureResY();
+	static resize_and_set_bits = (raw: SlotLayerRaw) => {
+		let resX = Config.get_texture_res_x();
+		let resY = Config.get_texture_res_y();
 		let rts = render_path_render_targets;
-		if (Base.pipeMerge == null) Base.makePipe();
+		if (Base.pipe_merge == null) Base.make_pipe();
 
-		if (SlotLayer.isLayer(raw)) {
+		if (SlotLayer.is_layer(raw)) {
 			///if is_paint
-			let format = Base.bitsHandle.position == TextureBits.Bits8  ? tex_format_t.RGBA32 :
-						 Base.bitsHandle.position == TextureBits.Bits16 ? tex_format_t.RGBA64 :
+			let format = Base.bits_handle.position == texture_bits_t.BITS8  ? tex_format_t.RGBA32 :
+						 Base.bits_handle.position == texture_bits_t.BITS16 ? tex_format_t.RGBA64 :
 						 									  			  tex_format_t.RGBA128;
 			///end
 
@@ -343,7 +343,7 @@ class SlotLayer {
 			let _texpaint = raw.texpaint;
 			raw.texpaint = image_create_render_target(resX, resY, format);
 			g2_begin(raw.texpaint);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_scaled_image(_texpaint, 0, 0, resX, resY);
 			g2_set_pipeline(null);
 			g2_end();
@@ -355,13 +355,13 @@ class SlotLayer {
 			raw.texpaint_pack = image_create_render_target(resX, resY, format);
 
 			g2_begin(raw.texpaint_nor);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_scaled_image(_texpaint_nor, 0, 0, resX, resY);
 			g2_set_pipeline(null);
 			g2_end();
 
 			g2_begin(raw.texpaint_pack);
-			g2_set_pipeline(Base.pipeCopy);
+			g2_set_pipeline(Base.pipe_copy);
 			g2_draw_scaled_image(_texpaint_pack, 0, 0, resX, resY);
 			g2_set_pipeline(null);
 			g2_end();
@@ -374,7 +374,7 @@ class SlotLayer {
 				image_unload(_texpaint_pack);
 				///end
 			}
-			Base.notifyOnNextFrame(_next);
+			Base.notify_on_next_frame(_next);
 
 			rts.get("texpaint" + raw.ext)._image = raw.texpaint;
 			///if is_paint
@@ -382,12 +382,12 @@ class SlotLayer {
 			rts.get("texpaint_pack" + raw.ext)._image = raw.texpaint_pack;
 			///end
 		}
-		else if (SlotLayer.isMask(raw)) {
+		else if (SlotLayer.is_mask(raw)) {
 			let _texpaint = raw.texpaint;
 			raw.texpaint = image_create_render_target(resX, resY, tex_format_t.RGBA32);
 
 			g2_begin(raw.texpaint);
-			g2_set_pipeline(Base.pipeCopy8);
+			g2_set_pipeline(Base.pipe_copy8);
 			g2_draw_scaled_image(_texpaint, 0, 0, resX, resY);
 			g2_set_pipeline(null);
 			g2_end();
@@ -395,40 +395,40 @@ class SlotLayer {
 			let _next = () => {
 				image_unload(_texpaint);
 			}
-			Base.notifyOnNextFrame(_next);
+			Base.notify_on_next_frame(_next);
 
 			rts.get("texpaint" + raw.ext)._image = raw.texpaint;
 		}
 	}
 
-	static toFillLayer = (raw: SlotLayerRaw) => {
-		Context.setLayer(raw);
+	static to_fill_layer = (raw: SlotLayerRaw) => {
+		Context.set_layer(raw);
 		raw.fill_layer = Context.raw.material;
-		Base.updateFillLayer();
+		Base.update_fill_layer();
 		let _next = () => {
-			MakeMaterial.parsePaintMaterial();
-			Context.raw.layerPreviewDirty = true;
-			UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+			MakeMaterial.parse_paint_material();
+			Context.raw.layer_preview_dirty = true;
+			UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
 		}
-		Base.notifyOnNextFrame(_next);
+		Base.notify_on_next_frame(_next);
 	}
 
-	static toPaintLayer = (raw: SlotLayerRaw) => {
-		Context.setLayer(raw);
+	static to_paint_layer = (raw: SlotLayerRaw) => {
+		Context.set_layer(raw);
 		raw.fill_layer = null;
-		MakeMaterial.parsePaintMaterial();
-		Context.raw.layerPreviewDirty = true;
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+		MakeMaterial.parse_paint_material();
+		Context.raw.layer_preview_dirty = true;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
 	}
 
-	static isVisible = (raw: SlotLayerRaw): bool => {
+	static is_visible = (raw: SlotLayerRaw): bool => {
 		return raw.visible && (raw.parent == null || raw.parent.visible);
 	}
 
-	static getChildren = (raw: SlotLayerRaw): SlotLayerRaw[] => {
+	static get_children = (raw: SlotLayerRaw): SlotLayerRaw[] => {
 		let children: SlotLayerRaw[] = null; // Child layers of a group
 		for (let l of Project.layers) {
-			if (l.parent == raw && SlotLayer.isLayer(l)) {
+			if (l.parent == raw && SlotLayer.is_layer(l)) {
 				if (children == null) children = [];
 				children.push(l);
 			}
@@ -436,7 +436,7 @@ class SlotLayer {
 		return children;
 	}
 
-	static getRecursiveChildren = (raw: SlotLayerRaw): SlotLayerRaw[] => {
+	static get_recursive_children = (raw: SlotLayerRaw): SlotLayerRaw[] => {
 		let children: SlotLayerRaw[] = null;
 		for (let l of Project.layers) {
 			if (l.parent == raw) { // Child layers and group masks
@@ -451,22 +451,22 @@ class SlotLayer {
 		return children;
 	}
 
-	static getMasks = (raw: SlotLayerRaw, includeGroupMasks = true): SlotLayerRaw[] => {
-		if (SlotLayer.isMask(raw)) return null;
+	static get_masks = (raw: SlotLayerRaw, includeGroupMasks = true): SlotLayerRaw[] => {
+		if (SlotLayer.is_mask(raw)) return null;
 
 		let children: SlotLayerRaw[] = null;
 		// Child masks of a layer
 		for (let l of Project.layers) {
-			if (l.parent == raw && SlotLayer.isMask(l)) {
+			if (l.parent == raw && SlotLayer.is_mask(l)) {
 				if (children == null) children = [];
 				children.push(l);
 			}
 		}
 		// Child masks of a parent group
 		if (includeGroupMasks) {
-			if (raw.parent != null && SlotLayer.isGroup(raw.parent)) {
+			if (raw.parent != null && SlotLayer.is_group(raw.parent)) {
 				for (let l of Project.layers) {
-					if (l.parent == raw.parent && SlotLayer.isMask(l)) {
+					if (l.parent == raw.parent && SlotLayer.is_mask(l)) {
 						if (children == null) children = [];
 						children.push(l);
 					}
@@ -476,17 +476,17 @@ class SlotLayer {
 		return children;
 	}
 
-	static hasMasks = (raw: SlotLayerRaw, includeGroupMasks = true): bool => {
+	static has_masks = (raw: SlotLayerRaw, includeGroupMasks = true): bool => {
 		// Layer mask
 		for (let l of Project.layers) {
-			if (l.parent == raw && SlotLayer.isMask(l)) {
+			if (l.parent == raw && SlotLayer.is_mask(l)) {
 				return true;
 			}
 		}
 		// Group mask
-		if (includeGroupMasks && raw.parent != null && SlotLayer.isGroup(raw.parent)) {
+		if (includeGroupMasks && raw.parent != null && SlotLayer.is_group(raw.parent)) {
 			for (let l of Project.layers) {
-				if (l.parent == raw.parent && SlotLayer.isMask(l)) {
+				if (l.parent == raw.parent && SlotLayer.is_mask(l)) {
 					return true;
 				}
 			}
@@ -494,17 +494,17 @@ class SlotLayer {
 		return false;
 	}
 
-	static getOpacity = (raw: SlotLayerRaw): f32 => {
+	static get_opacity = (raw: SlotLayerRaw): f32 => {
 		let f = raw.maskOpacity;
-		if (SlotLayer.isLayer(raw) && raw.parent != null) f *= raw.parent.maskOpacity;
+		if (SlotLayer.is_layer(raw) && raw.parent != null) f *= raw.parent.maskOpacity;
 		return f;
 	}
 
-	static getObjectMask = (raw: SlotLayerRaw): i32 => {
-		return SlotLayer.isMask(raw) ? raw.parent.objectMask : raw.objectMask;
+	static get_object_mask = (raw: SlotLayerRaw): i32 => {
+		return SlotLayer.is_mask(raw) ? raw.parent.objectMask : raw.objectMask;
 	}
 
-	static isLayer = (raw: SlotLayerRaw): bool => {
+	static is_layer = (raw: SlotLayerRaw): bool => {
 		///if is_paint
 		return raw.texpaint != null && raw.texpaint_nor != null;
 		///end
@@ -513,19 +513,19 @@ class SlotLayer {
 		///end
 	}
 
-	static isGroup = (raw: SlotLayerRaw): bool => {
+	static is_group = (raw: SlotLayerRaw): bool => {
 		return raw.texpaint == null;
 	}
 
-	static getContainingGroup = (raw: SlotLayerRaw): SlotLayerRaw => {
-		if (raw.parent != null && SlotLayer.isGroup(raw.parent))
+	static get_containing_group = (raw: SlotLayerRaw): SlotLayerRaw => {
+		if (raw.parent != null && SlotLayer.is_group(raw.parent))
 			return raw.parent;
-		else if (raw.parent != null && raw.parent.parent != null && SlotLayer.isGroup(raw.parent.parent))
+		else if (raw.parent != null && raw.parent.parent != null && SlotLayer.is_group(raw.parent.parent))
 			return raw.parent.parent;
 		else return null;
 	}
 
-	static isMask = (raw: SlotLayerRaw): bool => {
+	static is_mask = (raw: SlotLayerRaw): bool => {
 		///if is_paint
 		return raw.texpaint != null && raw.texpaint_nor == null;
 		///end
@@ -534,29 +534,29 @@ class SlotLayer {
 		///end
 	}
 
-	static isGroupMask = (raw: SlotLayerRaw): bool => {
+	static is_group_mask = (raw: SlotLayerRaw): bool => {
 		///if is_paint
-		return raw.texpaint != null && raw.texpaint_nor == null && SlotLayer.isGroup(raw.parent);
+		return raw.texpaint != null && raw.texpaint_nor == null && SlotLayer.is_group(raw.parent);
 		///end
 		///if is_sculpt
 		return false;
 		///end
 	}
 
-	static isLayerMask = (raw: SlotLayerRaw): bool => {
+	static is_layer_mask = (raw: SlotLayerRaw): bool => {
 		///if is_paint
-		return raw.texpaint != null && raw.texpaint_nor == null && SlotLayer.isLayer(raw.parent);
+		return raw.texpaint != null && raw.texpaint_nor == null && SlotLayer.is_layer(raw.parent);
 		///end
 		///if is_sculpt
 		return false;
 		///end
 	}
 
-	static isInGroup = (raw: SlotLayerRaw): bool => {
-		return raw.parent != null && (SlotLayer.isGroup(raw.parent) || (raw.parent.parent != null && SlotLayer.isGroup(raw.parent.parent)));
+	static is_in_group = (raw: SlotLayerRaw): bool => {
+		return raw.parent != null && (SlotLayer.is_group(raw.parent) || (raw.parent.parent != null && SlotLayer.is_group(raw.parent.parent)));
 	}
 
-	static canMove = (raw: SlotLayerRaw, to: i32): bool => {
+	static can_move = (raw: SlotLayerRaw, to: i32): bool => {
 		let oldIndex = Project.layers.indexOf(raw);
 
 		let delta = to - oldIndex; // If delta > 0 the layer is moved up, otherwise down
@@ -569,7 +569,7 @@ class SlotLayer {
 
 		// Group or layer is collapsed so we check below and update the upper layer.
 		if (newUpperLayer != null && !newUpperLayer.show_panel) {
-			let children = SlotLayer.getRecursiveChildren(newUpperLayer);
+			let children = SlotLayer.get_recursive_children(newUpperLayer);
 			to -= children != null ? children.length : 0;
 			delta = to - oldIndex;
 			newUpperLayer = delta > 0 ? (to < Project.layers.length - 1 ? Project.layers[to + 1] : null) : Project.layers[to];
@@ -577,34 +577,34 @@ class SlotLayer {
 
 		let newLowerLayer = delta > 0 ? Project.layers[to] : (to > 0 ? Project.layers[to - 1] : null);
 
-		if (SlotLayer.isMask(raw)) {
+		if (SlotLayer.is_mask(raw)) {
 			// Masks can not be on top.
 			if (newUpperLayer == null) return false;
 			// Masks should not be placed below a collapsed group. This condition can be savely removed.
-			if (SlotLayer.isInGroup(newUpperLayer) && !SlotLayer.getContainingGroup(newUpperLayer).show_panel) return false;
+			if (SlotLayer.is_in_group(newUpperLayer) && !SlotLayer.get_containing_group(newUpperLayer).show_panel) return false;
 			// Masks should not be placed below a collapsed layer. This condition can be savely removed.
-			if (SlotLayer.isMask(newUpperLayer) && !newUpperLayer.parent.show_panel) return false;
+			if (SlotLayer.is_mask(newUpperLayer) && !newUpperLayer.parent.show_panel) return false;
 		}
 
-		if (SlotLayer.isLayer(raw)) {
+		if (SlotLayer.is_layer(raw)) {
 			// Layers can not be moved directly below its own mask(s).
-			if (newUpperLayer != null && SlotLayer.isMask(newUpperLayer) && newUpperLayer.parent == raw) return false;
+			if (newUpperLayer != null && SlotLayer.is_mask(newUpperLayer) && newUpperLayer.parent == raw) return false;
 			// Layers can not be placed above a mask as the mask would be reparented.
-			if (newLowerLayer != null && SlotLayer.isMask(newLowerLayer)) return false;
+			if (newLowerLayer != null && SlotLayer.is_mask(newLowerLayer)) return false;
 		}
 
 		// Currently groups can not be nested. Thus valid positions for groups are:
-		if (SlotLayer.isGroup(raw)) {
+		if (SlotLayer.is_group(raw)) {
 			// At the top.
 			if (newUpperLayer == null) return true;
 			// NOT below its own children.
-			if (SlotLayer.getContainingGroup(newUpperLayer) == raw) return false;
+			if (SlotLayer.get_containing_group(newUpperLayer) == raw) return false;
 			// At the bottom.
 			if (newLowerLayer == null) return true;
 			// Above a group.
-			if (SlotLayer.isGroup(newLowerLayer)) return true;
+			if (SlotLayer.is_group(newLowerLayer)) return true;
 			// Above a non-grouped layer.
-			if (SlotLayer.isLayer(newLowerLayer) && !SlotLayer.isInGroup(newLowerLayer)) return true;
+			if (SlotLayer.is_layer(newLowerLayer) && !SlotLayer.is_in_group(newLowerLayer)) return true;
 			else return false;
 		}
 
@@ -612,48 +612,48 @@ class SlotLayer {
 	}
 
 	static move = (raw: SlotLayerRaw, to: i32) => {
-		if (!SlotLayer.canMove(raw, to)) {
+		if (!SlotLayer.can_move(raw, to)) {
 			return;
 		}
 
-		let pointers = TabLayers.initLayerMap();
+		let pointers = TabLayers.init_layer_map();
 		let oldIndex = Project.layers.indexOf(raw);
 		let delta = to - oldIndex;
 		let newUpperLayer = delta > 0 ? (to < Project.layers.length - 1 ? Project.layers[to + 1] : null) : Project.layers[to];
 
 		// Group or layer is collapsed so we check below and update the upper layer.
 		if (newUpperLayer != null && !newUpperLayer.show_panel) {
-			let children = SlotLayer.getRecursiveChildren(newUpperLayer);
+			let children = SlotLayer.get_recursive_children(newUpperLayer);
 			to -= children != null ? children.length : 0;
 			delta = to - oldIndex;
 			newUpperLayer = delta > 0 ? (to < Project.layers.length - 1 ? Project.layers[to + 1] : null) : Project.layers[to];
 		}
 
-		Context.setLayer(raw);
-		History.orderLayers(to);
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+		Context.set_layer(raw);
+		History.order_layers(to);
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
 
 		array_remove(Project.layers, raw);
 		Project.layers.splice(to, 0, raw);
 
-		if (SlotLayer.isLayer(raw)) {
+		if (SlotLayer.is_layer(raw)) {
 			let oldParent = raw.parent;
 
 			if (newUpperLayer == null)
 				raw.parent = null; // Placed on top.
-			else if (SlotLayer.isInGroup(newUpperLayer) && !SlotLayer.getContainingGroup(newUpperLayer).show_panel)
+			else if (SlotLayer.is_in_group(newUpperLayer) && !SlotLayer.get_containing_group(newUpperLayer).show_panel)
 				raw.parent = null; // Placed below a collapsed group.
-			else if (SlotLayer.isLayer(newUpperLayer))
+			else if (SlotLayer.is_layer(newUpperLayer))
 				raw.parent = newUpperLayer.parent; // Placed below a layer, use the same parent.
-			else if (SlotLayer.isGroup(newUpperLayer))
+			else if (SlotLayer.is_group(newUpperLayer))
 				raw.parent = newUpperLayer; // Placed as top layer in a group.
-			else if (SlotLayer.isGroupMask(newUpperLayer))
+			else if (SlotLayer.is_group_mask(newUpperLayer))
 				raw.parent = newUpperLayer.parent; // Placed in a group below the lowest group mask.
-			else if (SlotLayer.isLayerMask(newUpperLayer))
-				raw.parent = SlotLayer.getContainingGroup(newUpperLayer); // Either the group the mask belongs to or null.
+			else if (SlotLayer.is_layer_mask(newUpperLayer))
+				raw.parent = SlotLayer.get_containing_group(newUpperLayer); // Either the group the mask belongs to or null.
 
 			// Layers can have masks as children. These have to be moved, too.
-			let layerMasks = SlotLayer.getMasks(raw, false);
+			let layerMasks = SlotLayer.get_masks(raw, false);
 			if (layerMasks != null) {
 				for (let idx = 0; idx < layerMasks.length; ++idx) {
 					let mask = layerMasks[idx];
@@ -664,19 +664,19 @@ class SlotLayer {
 			}
 
 			// The layer is the last layer in the group, remove it. Notice that this might remove group masks.
-			if (oldParent != null && SlotLayer.getChildren(oldParent) == null)
+			if (oldParent != null && SlotLayer.get_children(oldParent) == null)
 				SlotLayer.delete(oldParent);
 		}
-		else if (SlotLayer.isMask(raw)) {
+		else if (SlotLayer.is_mask(raw)) {
 			// Precondition newUpperLayer != null, ensured in canMove.
-			if (SlotLayer.isLayer(newUpperLayer) || SlotLayer.isGroup(newUpperLayer))
+			if (SlotLayer.is_layer(newUpperLayer) || SlotLayer.is_group(newUpperLayer))
 				raw.parent = newUpperLayer;
-			else if (SlotLayer.isMask(newUpperLayer)) { // Group mask or layer mask.
+			else if (SlotLayer.is_mask(newUpperLayer)) { // Group mask or layer mask.
 				raw.parent = newUpperLayer.parent;
 			}
 		}
-		else if (SlotLayer.isGroup(raw)) {
-			let children = SlotLayer.getRecursiveChildren(raw);
+		else if (SlotLayer.is_group(raw)) {
+			let children = SlotLayer.get_recursive_children(raw);
 			if (children != null) {
 				for (let idx = 0; idx < children.length; ++idx) {
 					let child = children[idx];
@@ -687,6 +687,6 @@ class SlotLayer {
 			}
 		}
 
-		for (let m of Project.materials) TabLayers.remapLayerPointers(m.canvas.nodes, TabLayers.fillLayerMap(pointers));
+		for (let m of Project.materials) TabLayers.remap_layer_pointers(m.canvas.nodes, TabLayers.fill_layer_map(pointers));
 	}
 }

+ 20 - 20
armorpaint/Sources/SlotMaterial.ts

@@ -3,41 +3,41 @@ class SlotMaterialRaw {
 	nodes = zui_nodes_create();
 	canvas: zui_node_canvas_t;
 	image: image_t = null;
-	imageIcon: image_t = null;
-	previewReady = false;
+	image_icon: image_t = null;
+	preview_ready = false;
 	data: material_data_t;
 	id = 0;
 
-	paintBase = true;
-	paintOpac = true;
-	paintOcc = true;
-	paintRough = true;
-	paintMet = true;
-	paintNor = true;
-	paintHeight = true;
-	paintEmis = true;
-	paintSubs = true;
+	paint_base = true;
+	paint_opac = true;
+	paint_occ = true;
+	paint_rough = true;
+	paint_met = true;
+	paint_nor = true;
+	paint_height = true;
+	paint_emis = true;
+	paint_subs = true;
 }
 
 class SlotMaterial {
-	static defaultCanvas: ArrayBuffer = null;
+	static default_canvas: ArrayBuffer = null;
 
 	static create(m: material_data_t = null, c: zui_node_canvas_t = null): SlotMaterialRaw {
 		let raw = new SlotMaterialRaw();
 		for (let mat of Project.materials) if (mat.id >= raw.id) raw.id = mat.id + 1;
 		raw.data = m;
 
-		let w = UtilRender.materialPreviewSize;
+		let w = UtilRender.material_preview_size;
 		let wIcon = 50;
 		raw.image = image_create_render_target(w, w);
-		raw.imageIcon = image_create_render_target(wIcon, wIcon);
+		raw.image_icon = image_create_render_target(wIcon, wIcon);
 
 		if (c == null) {
-			if (SlotMaterial.defaultCanvas == null) { // Synchronous
+			if (SlotMaterial.default_canvas == null) { // Synchronous
 				let b: ArrayBuffer = data_get_blob("default_material.arm");
-				SlotMaterial.defaultCanvas = b;
+				SlotMaterial.default_canvas = b;
 			}
-			raw.canvas = armpack_decode(SlotMaterial.defaultCanvas);
+			raw.canvas = armpack_decode(SlotMaterial.default_canvas);
 			raw.canvas.name = "Material " + (raw.id + 1);
 		}
 		else {
@@ -54,9 +54,9 @@ class SlotMaterial {
 	static unload = (raw: SlotMaterialRaw) => {
 		let _next = () => {
 			image_unload(raw.image);
-			image_unload(raw.imageIcon);
+			image_unload(raw.image_icon);
 		}
-		Base.notifyOnNextFrame(_next);
+		Base.notify_on_next_frame(_next);
 	}
 
 	static delete = (raw: SlotMaterialRaw) => {
@@ -64,7 +64,7 @@ class SlotMaterial {
 		let mpos = Project.materials.indexOf(raw);
 		array_remove(Project.materials, this);
 		if (Project.materials.length > 0) {
-			Context.setMaterial(Project.materials[mpos > 0 ? mpos - 1 : 0]);
+			Context.set_material(Project.materials[mpos > 0 ? mpos - 1 : 0]);
 		}
 	}
 }

文件差异内容过多而无法显示
+ 278 - 278
armorpaint/Sources/TabLayers.ts


+ 48 - 48
armorpaint/Sources/nodes/BrushOutputNode.ts

@@ -5,13 +5,13 @@ class BrushOutputNode extends LogicNode {
 
 	constructor() {
 		super();
-		Context.raw.runBrush = this.run;
-		Context.raw.parseBrushInputs = this.parseInputs;
+		Context.raw.run_brush = this.run;
+		Context.raw.parse_brush_inputs = this.parse_inputs;
 	}
 
-	parseInputs = () => {
-		let lastMask = Context.raw.brushMaskImage;
-		let lastStencil = Context.raw.brushStencilImage;
+	parse_inputs = () => {
+		let lastMask = Context.raw.brush_mask_image;
+		let lastStencil = Context.raw.brush_stencil_image;
 
 		let input0: any;
 		let input1: any;
@@ -33,47 +33,47 @@ class BrushOutputNode extends LogicNode {
 			return;
 		}
 
-		Context.raw.paintVec = input0;
-		Context.raw.brushNodesRadius = input1;
-		Context.raw.brushNodesScale = input2;
-		Context.raw.brushNodesAngle = input3;
+		Context.raw.paint_vec = input0;
+		Context.raw.brush_nodes_radius = input1;
+		Context.raw.brush_nodes_scale = input2;
+		Context.raw.brush_nodes_angle = input3;
 
 		let opac: any = input4; // Float or texture name
 		if (opac == null) opac = 1.0;
 		if (typeof opac == "string") {
-			Context.raw.brushMaskImageIsAlpha = opac.endsWith(".a");
+			Context.raw.brush_mask_image_is_alpha = opac.endsWith(".a");
 			opac = opac.substr(0, opac.lastIndexOf("."));
-			Context.raw.brushNodesOpacity = 1.0;
-			let index = Project.assetNames.indexOf(opac);
+			Context.raw.brush_nodes_opacity = 1.0;
+			let index = Project.asset_names.indexOf(opac);
 			let asset = Project.assets[index];
-			Context.raw.brushMaskImage = Project.getImage(asset);
+			Context.raw.brush_mask_image = Project.get_image(asset);
 		}
 		else {
-			Context.raw.brushNodesOpacity = opac;
-			Context.raw.brushMaskImage = null;
+			Context.raw.brush_nodes_opacity = opac;
+			Context.raw.brush_mask_image = null;
 		}
 
-		Context.raw.brushNodesHardness = input5;
+		Context.raw.brush_nodes_hardness = input5;
 
 		let stencil: any = input6; // Float or texture name
 		if (stencil == null) stencil = 1.0;
 		if (typeof stencil == "string") {
-			Context.raw.brushStencilImageIsAlpha = stencil.endsWith(".a");
+			Context.raw.brush_stencil_image_is_alpha = stencil.endsWith(".a");
 			stencil = stencil.substr(0, stencil.lastIndexOf("."));
-			let index = Project.assetNames.indexOf(stencil);
+			let index = Project.asset_names.indexOf(stencil);
 			let asset = Project.assets[index];
-			Context.raw.brushStencilImage = Project.getImage(asset);
+			Context.raw.brush_stencil_image = Project.get_image(asset);
 		}
 		else {
-			Context.raw.brushStencilImage = null;
+			Context.raw.brush_stencil_image = null;
 		}
 
-		if (lastMask != Context.raw.brushMaskImage ||
-			lastStencil != Context.raw.brushStencilImage) {
-			MakeMaterial.parsePaintMaterial();
+		if (lastMask != Context.raw.brush_mask_image ||
+			lastStencil != Context.raw.brush_stencil_image) {
+			MakeMaterial.parse_paint_material();
 		}
 
-		Context.raw.brushDirectional = this.Directional;
+		Context.raw.brush_directional = this.Directional;
 	}
 
 	run = (from: i32) => {
@@ -81,60 +81,60 @@ class BrushOutputNode extends LogicNode {
 		let right = 1.0;
 		if (Context.raw.paint2d) {
 			left = 1.0;
-			right = (Context.raw.splitView ? 2.0 : 1.0) + UIView2D.ww / Base.w();
+			right = (Context.raw.split_view ? 2.0 : 1.0) + UIView2D.ww / Base.w();
 		}
 
 		// First time init
-		if (Context.raw.lastPaintX < 0 || Context.raw.lastPaintY < 0) {
-			Context.raw.lastPaintVecX = Context.raw.paintVec.x;
-			Context.raw.lastPaintVecY = Context.raw.paintVec.y;
+		if (Context.raw.last_paint_x < 0 || Context.raw.last_paint_y < 0) {
+			Context.raw.last_paint_vec_x = Context.raw.paint_vec.x;
+			Context.raw.last_paint_vec_y = Context.raw.paint_vec.y;
 		}
 
 		// Do not paint over fill layer
-		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != WorkspaceTool.ToolPicker && Context.raw.tool != WorkspaceTool.ToolMaterial && Context.raw.tool != WorkspaceTool.ToolColorId;
+		let fillLayer = Context.raw.layer.fill_layer != null && Context.raw.tool != workspace_tool_t.PICKER && Context.raw.tool != workspace_tool_t.MATERIAL && Context.raw.tool != workspace_tool_t.COLORID;
 
 		// Do not paint over groups
-		let groupLayer = SlotLayer.isGroup(Context.raw.layer);
+		let groupLayer = SlotLayer.is_group(Context.raw.layer);
 
 		// Paint bounds
-		if (Context.raw.paintVec.x > left &&
-			Context.raw.paintVec.x < right &&
-			Context.raw.paintVec.y > 0 &&
-			Context.raw.paintVec.y < 1 &&
+		if (Context.raw.paint_vec.x > left &&
+			Context.raw.paint_vec.x < right &&
+			Context.raw.paint_vec.y > 0 &&
+			Context.raw.paint_vec.y < 1 &&
 			!fillLayer &&
 			!groupLayer &&
-			(SlotLayer.isVisible(Context.raw.layer) || Context.raw.paint2d) &&
+			(SlotLayer.is_visible(Context.raw.layer) || Context.raw.paint2d) &&
 			!UIBase.ui.is_hovered &&
-			!Base.isDragging &&
-			!Base.isResizing &&
-			!Base.isScrolling() &&
-			!Base.isComboSelected()) {
+			!Base.is_dragging &&
+			!Base.is_resizing &&
+			!Base.is_scrolling() &&
+			!Base.is_combo_selected()) {
 
 			// Set color pick
 			let down = mouse_down() || pen_down();
-			if (down && Context.raw.tool == WorkspaceTool.ToolColorId && Project.assets.length > 0) {
-				Context.raw.colorIdPicked = true;
-				UIToolbar.toolbarHandle.redraws = 1;
+			if (down && Context.raw.tool == workspace_tool_t.COLORID && Project.assets.length > 0) {
+				Context.raw.colorid_picked = true;
+				UIToolbar.toolbar_handle.redraws = 1;
 			}
 
 			// Prevent painting the same spot
-			let sameSpot = Context.raw.paintVec.x == Context.raw.lastPaintX && Context.raw.paintVec.y == Context.raw.lastPaintY;
-			let lazy = Context.raw.tool == WorkspaceTool.ToolBrush && Context.raw.brushLazyRadius > 0;
+			let sameSpot = Context.raw.paint_vec.x == Context.raw.last_paint_x && Context.raw.paint_vec.y == Context.raw.last_paint_y;
+			let lazy = Context.raw.tool == workspace_tool_t.BRUSH && Context.raw.brush_lazy_radius > 0;
 			if (down && (sameSpot || lazy)) {
 				Context.raw.painted++;
 			}
 			else {
 				Context.raw.painted = 0;
 			}
-			Context.raw.lastPaintX = Context.raw.paintVec.x;
-			Context.raw.lastPaintY = Context.raw.paintVec.y;
+			Context.raw.last_paint_x = Context.raw.paint_vec.x;
+			Context.raw.last_paint_y = Context.raw.paint_vec.y;
 
-			if (Context.raw.tool == WorkspaceTool.ToolParticle) {
+			if (Context.raw.tool == workspace_tool_t.PARTICLE) {
 				Context.raw.painted = 0; // Always paint particles
 			}
 
 			if (Context.raw.painted == 0) {
-				this.parseInputs();
+				this.parse_inputs();
 			}
 
 			if (Context.raw.painted <= 1) {

+ 18 - 18
armorpaint/Sources/nodes/InputNode.ts

@@ -25,14 +25,14 @@ class InputNode extends LogicNode {
 	}
 
 	update = () => {
-		if (Context.raw.splitView) {
-			Context.raw.viewIndex = mouse_view_x() > Base.w() / 2 ? 1 : 0;
+		if (Context.raw.split_view) {
+			Context.raw.view_index = mouse_view_x() > Base.w() / 2 ? 1 : 0;
 		}
 
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		let decal = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown);
 
-		let lazyPaint = Context.raw.brushLazyRadius > 0 &&
+		let lazyPaint = Context.raw.brush_lazy_radius > 0 &&
 			(Operator.shortcut(Config.keymap.action_paint, ShortcutType.ShortcutDown) ||
 			 Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown) ||
 			 decalMask);
@@ -58,17 +58,17 @@ class InputNode extends LogicNode {
 			if (InputNode.lockY) paintY = InputNode.startY;
 		}
 
-		if (Context.raw.brushLazyRadius > 0) {
-			Context.raw.brushLazyX = paintX;
-			Context.raw.brushLazyY = paintY;
+		if (Context.raw.brush_lazy_radius > 0) {
+			Context.raw.brush_lazy_x = paintX;
+			Context.raw.brush_lazy_y = paintY;
 		}
 		if (!lazyPaint) {
 			InputNode.coords.x = paintX;
 			InputNode.coords.y = paintY;
 		}
 
-		if (Context.raw.splitView) {
-			Context.raw.viewIndex = -1;
+		if (Context.raw.split_view) {
+			Context.raw.view_index = -1;
 		}
 
 		if (InputNode.lockBegin) {
@@ -89,16 +89,16 @@ class InputNode extends LogicNode {
 			InputNode.lockX = InputNode.lockY = InputNode.lockBegin = false;
 		}
 
-		if (Context.raw.brushLazyRadius > 0) {
-			let v1 = vec4_create(Context.raw.brushLazyX * app_w(), Context.raw.brushLazyY * app_h(), 0.0);
+		if (Context.raw.brush_lazy_radius > 0) {
+			let v1 = vec4_create(Context.raw.brush_lazy_x * app_w(), Context.raw.brush_lazy_y * app_h(), 0.0);
 			let v2 = vec4_create(InputNode.coords.x * app_w(), InputNode.coords.y * app_h(), 0.0);
 			let d = vec4_dist(v1, v2);
-			let r = Context.raw.brushLazyRadius * 85;
+			let r = Context.raw.brush_lazy_radius * 85;
 			if (d > r) {
 				let v3 = vec4_create();
 				vec4_sub_vecs(v3, v2, v1);
 				vec4_normalize(v3, );
-				vec4_mult(v3, 1.0 - Context.raw.brushLazyStep);
+				vec4_mult(v3, 1.0 - Context.raw.brush_lazy_step);
 				vec4_mult(v3, r);
 				vec4_add_vecs(v2, v1, v3);
 				InputNode.coords.x = v2.x / app_w();
@@ -106,18 +106,18 @@ class InputNode extends LogicNode {
 				// Parse brush inputs once on next draw
 				Context.raw.painted = -1;
 			}
-			Context.raw.lastPaintX = -1;
-			Context.raw.lastPaintY = -1;
+			Context.raw.last_paint_x = -1;
+			Context.raw.last_paint_y = -1;
 		}
 
-		Context.raw.parseBrushInputs();
+		Context.raw.parse_brush_inputs();
 	}
 
 	override get = (from: i32, done: (a: any)=>void) => {
 		this.inputs[0].get((value) => {
-			Context.raw.brushLazyRadius = value;
+			Context.raw.brush_lazy_radius = value;
 			this.inputs[1].get((value) => {
-				Context.raw.brushLazyStep = value;
+				Context.raw.brush_lazy_step = value;
 				done(InputNode.coords);
 			});
 		});

+ 67 - 67
armorsculpt/Sources/TabLayers.ts

@@ -6,8 +6,8 @@ class TabLayers {
 	static showContextMenu = false;
 
 	static draw = (htab: zui_handle_t) => {
-		let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW;
-		mini ? TabLayers.drawMini(htab) : TabLayers.drawFull(htab);
+		let mini = Config.raw.layout[layout_size_t.SIDEBAR_W] <= UIBase.sidebar_mini_w;
+		mini ? TabLayers.draw_mini(htab) : TabLayers.draw_full(htab);
 	}
 
 	static drawMini = (htab: zui_handle_t) => {
@@ -15,19 +15,19 @@ class TabLayers {
 		zui_set_hovered_tab_name(tr("Layers"));
 
 		let _ELEMENT_H = ui.t.ELEMENT_H;
-		ui.t.ELEMENT_H = Math.floor(UIBase.sidebarMiniW / 2 / zui_SCALE(ui));
+		ui.t.ELEMENT_H = Math.floor(UIBase.sidebar_mini_w / 2 / zui_SCALE(ui));
 
 		zui_begin_sticky();
 		zui_separator(5);
 
-		TabLayers.comboFilter();
-		TabLayers.buttonNew("+");
+		TabLayers.combo_filter();
+		TabLayers.button_new("+");
 
 		zui_end_sticky();
 		ui._y += 2;
 
-		TabLayers.highlightOddLines();
-		TabLayers.drawSlots(true);
+		TabLayers.highlight_odd_lines();
+		TabLayers.draw_slots(true);
 
 		ui.t.ELEMENT_H = _ELEMENT_H;
 	}
@@ -38,14 +38,14 @@ class TabLayers {
 			zui_begin_sticky();
 			zui_row([1 / 4, 3 / 4]);
 
-			TabLayers.buttonNew(tr("New"));
-			TabLayers.comboFilter();
+			TabLayers.button_new(tr("New"));
+			TabLayers.combo_filter();
 
 			zui_end_sticky();
 			ui._y += 2;
 
-			TabLayers.highlightOddLines();
-			TabLayers.drawSlots(false);
+			TabLayers.highlight_odd_lines();
+			TabLayers.draw_slots(false);
 		}
 	}
 
@@ -54,7 +54,7 @@ class TabLayers {
 			if (i >= Project.layers.length) break; // Layer was deleted
 			let j = Project.layers.length - 1 - i;
 			let l = Project.layers[j];
-			TabLayers.drawLayerSlot(l, j, mini);
+			TabLayers.draw_layer_slot(l, j, mini);
 		}
 	}
 
@@ -74,9 +74,9 @@ class TabLayers {
 		if (zui_button(text)) {
 			UIMenu.draw((ui: zui_t) => {
 				let l = Context.raw.layer;
-				if (UIMenu.menuButton(ui, tr("Paint Layer"))) {
-					Base.newLayer();
-					History.newLayer();
+				if (UIMenu.menu_button(ui, tr("Paint Layer"))) {
+					Base.new_layer();
+					History.new_layer();
 				}
 			}, 1);
 		}
@@ -86,8 +86,8 @@ class TabLayers {
 		let ui = UIBase.ui;
 		let ar = [tr("All")];
 		let filterHandle = zui_handle("tablayers_0");
-		filterHandle.position = Context.raw.layerFilter;
-		Context.raw.layerFilter = zui_combo(filterHandle, ar, tr("Filter"), false, zui_align_t.LEFT);
+		filterHandle.position = Context.raw.layer_filter;
+		Context.raw.layer_filter = zui_combo(filterHandle, ar, tr("Filter"), false, zui_align_t.LEFT);
 	}
 
 	static remapLayerPointers = (nodes: zui_node_t[], pointerMap: Map<i32, i32>) => {
@@ -114,18 +114,18 @@ class TabLayers {
 	}
 
 	static setDragLayer = (layer: SlotLayerRaw, offX: f32, offY: f32) => {
-		Base.dragOffX = offX;
-		Base.dragOffY = offY;
-		Base.dragLayer = layer;
-		Context.raw.dragDestination = Project.layers.indexOf(layer);
+		Base.drag_off_x = offX;
+		Base.drag_off_y = offY;
+		Base.drag_layer = layer;
+		Context.raw.drag_dest = Project.layers.indexOf(layer);
 	}
 
 	static drawLayerSlot = (l: SlotLayerRaw, i: i32, mini: bool) => {
 		let ui = UIBase.ui;
 
-		if (Context.raw.layerFilter > 0 &&
-			SlotLayer.getObjectMask(l) > 0 &&
-			SlotLayer.getObjectMask(l) != Context.raw.layerFilter) {
+		if (Context.raw.layer_filter > 0 &&
+			SlotLayer.get_object_mask(l) > 0 &&
+			SlotLayer.get_object_mask(l) != Context.raw.layer_filter) {
 			return;
 		}
 
@@ -141,47 +141,47 @@ class TabLayers {
 
 		// Highlight drag destination
 		let absy = ui._window_y + ui._y;
-		if (Base.isDragging && Base.dragLayer != null && Context.inLayers()) {
+		if (Base.is_dragging && Base.drag_layer != null && Context.in_layers()) {
 			if (mouse_y > absy + step && mouse_y < absy + step * 3) {
-				let down = Project.layers.indexOf(Base.dragLayer) >= i;
-				Context.raw.dragDestination = down ? i : i - 1;
+				let down = Project.layers.indexOf(Base.drag_layer) >= i;
+				Context.raw.drag_dest = down ? i : i - 1;
 
 				let ls = Project.layers;
-				let dest = Context.raw.dragDestination;
+				let dest = Context.raw.drag_dest;
 				let toGroup = down ? dest > 0 && ls[dest - 1].parent != null && ls[dest - 1].parent.show_panel : dest < ls.length && ls[dest].parent != null && ls[dest].parent.show_panel;
-				let nestedGroup = SlotLayer.isGroup(Base.dragLayer) && toGroup;
+				let nestedGroup = SlotLayer.is_group(Base.drag_layer) && toGroup;
 				if (!nestedGroup) {
-					if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) {
+					if (SlotLayer.can_move(Context.raw.layer, Context.raw.drag_dest)) {
 						zui_fill(checkw, step * 2, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL);
 					}
 				}
 			}
 			else if (i == Project.layers.length - 1 && mouse_y < absy + step) {
-				Context.raw.dragDestination = Project.layers.length - 1;
-				if (SlotLayer.canMove(Context.raw.layer, Context.raw.dragDestination)) {
+				Context.raw.drag_dest = Project.layers.length - 1;
+				if (SlotLayer.can_move(Context.raw.layer, Context.raw.drag_dest)) {
 					zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL);
 				}
 			}
 		}
-		if (Base.isDragging && (Base.dragMaterial != null || Base.dragSwatch != null) && Context.inLayers()) {
+		if (Base.is_dragging && (Base.drag_material != null || Base.drag_swatch != null) && Context.in_layers()) {
 			if (mouse_y > absy + step && mouse_y < absy + step * 3) {
-				Context.raw.dragDestination = i;
-				if (TabLayers.canDropNewLayer(i))
+				Context.raw.drag_dest = i;
+				if (TabLayers.can_drop_new_layer(i))
 					zui_fill(checkw, 2 * step, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL);
 			}
 			else if (i == Project.layers.length - 1 && mouse_y < absy + step) {
-				Context.raw.dragDestination = Project.layers.length;
-				if (TabLayers.canDropNewLayer(Project.layers.length))
+				Context.raw.drag_dest = Project.layers.length;
+				if (TabLayers.can_drop_new_layer(Project.layers.length))
 					zui_fill(checkw, 0, (ui._window_w / zui_SCALE(ui) - 2) - checkw, 2 * zui_SCALE(ui), ui.t.HIGHLIGHT_COL);
 			}
 		}
 
-		mini ? TabLayers.drawLayerSlotMini(l, i) : TabLayers.drawLayerSlotFull(l, i);
+		mini ? TabLayers.draw_layer_slot_mini(l, i) : TabLayers.draw_layer_slot_full(l, i);
 
-		TabLayers.drawLayerHighlight(l, mini);
+		TabLayers.draw_layer_highlight(l, mini);
 
-		if (TabLayers.showContextMenu) {
-			TabLayers.drawLayerContextMenu(l, mini);
+		if (TabLayers.show_context_menu) {
+			TabLayers.draw_layer_context_menu(l, mini);
 		}
 	}
 
@@ -203,7 +203,7 @@ class TabLayers {
 
 		let step = ui.t.ELEMENT_H;
 
-		let hasPanel = SlotLayer.isGroup(l) || (SlotLayer.isLayer(l) && SlotLayer.getMasks(l, false) != null);
+		let hasPanel = SlotLayer.is_group(l) || (SlotLayer.is_layer(l) && SlotLayer.get_masks(l, false) != null);
 		if (hasPanel) {
 			zui_row([8 / 100, 52 / 100, 30 / 100, 10 / 100]);
 		}
@@ -223,7 +223,7 @@ class TabLayers {
 		if (parentHidden) col -= 0x99000000;
 
 		if (zui_image(icons, col, -1.0, r.x, r.y, r.w, r.h) == zui_state_t.RELEASED) {
-			TabLayers.layerToggleVisible(l);
+			TabLayers.layer_toggle_visible(l);
 		}
 		ui._x -= 2;
 		ui._y -= 3;
@@ -234,37 +234,37 @@ class TabLayers {
 
 		// Draw layer name
 		ui._y += center;
-		if (TabLayers.layerNameEdit == l.id) {
-			TabLayers.layerNameHandle.text = l.name;
-			l.name = zui_text_input(TabLayers.layerNameHandle);
-			if (ui.text_selected_handle_ptr != TabLayers.layerNameHandle.ptr) TabLayers.layerNameEdit = -1;
+		if (TabLayers.layer_name_edit == l.id) {
+			TabLayers.layer_name_handle.text = l.name;
+			l.name = zui_text_input(TabLayers.layer_name_handle);
+			if (ui.text_selected_handle_ptr != TabLayers.layer_name_handle.ptr) TabLayers.layer_name_edit = -1;
 		}
 		else {
 			if (ui.enabled && ui.input_enabled && ui.combo_selected_handle_ptr == 0 &&
 				ui.input_x > ui._window_x + ui._x && ui.input_x < ui._window_x + ui._window_w &&
 				ui.input_y > ui._window_y + ui._y - center && ui.input_y < ui._window_y + ui._y - center + (step * zui_SCALE(ui)) * 2) {
 				if (ui.input_started) {
-					Context.setLayer(l);
-					TabLayers.setDragLayer(Context.raw.layer, -(mouse_x - uix - ui._window_x - 3), -(mouse_y - uiy - ui._window_y + 1));
+					Context.set_layer(l);
+					TabLayers.set_drag_layer(Context.raw.layer, -(mouse_x - uix - ui._window_x - 3), -(mouse_y - uiy - ui._window_y + 1));
 				}
 				else if (ui.input_released) {
-					if (time_time() - Context.raw.selectTime > 0.2) {
-						Context.raw.selectTime = time_time();
+					if (time_time() - Context.raw.select_time > 0.2) {
+						Context.raw.select_time = time_time();
 					}
 				}
 				else if (ui.input_released_r) {
-					Context.setLayer(l);
-					TabLayers.showContextMenu = true;
+					Context.set_layer(l);
+					TabLayers.show_context_menu = true;
 				}
 			}
 
 			let state = zui_text(l.name);
 			if (state == zui_state_t.RELEASED) {
-				let td = time_time() - Context.raw.selectTime;
+				let td = time_time() - Context.raw.select_time;
 				if (td < 0.2 && td > 0.0) {
-					TabLayers.layerNameEdit = l.id;
-					TabLayers.layerNameHandle.text = l.name;
-					zui_start_text_edit(TabLayers.layerNameHandle);
+					TabLayers.layer_name_edit = l.id;
+					TabLayers.layer_name_handle.text = l.name;
+					zui_start_text_edit(TabLayers.layer_name_handle);
 				}
 			}
 
@@ -285,18 +285,18 @@ class TabLayers {
 			if (l.parent.parent != null) ui._x -= 10 * zui_SCALE(ui);
 		}
 
-		if (SlotLayer.isGroup(l)) {
+		if (SlotLayer.is_group(l)) {
 			zui_end_element();
 		}
 		else {
-			if (SlotLayer.isMask(l)) {
+			if (SlotLayer.is_mask(l)) {
 				ui._y += center;
 			}
 
 			// comboBlending(ui, l);
 			zui_end_element();
 
-			if (SlotLayer.isMask(l)) {
+			if (SlotLayer.is_mask(l)) {
 				ui._y -= center;
 			}
 		}
@@ -309,7 +309,7 @@ class TabLayers {
 			ui._y -= center;
 		}
 
-		if (SlotLayer.isGroup(l) || SlotLayer.isMask(l)) {
+		if (SlotLayer.is_group(l) || SlotLayer.is_mask(l)) {
 			ui._y -= zui_ELEMENT_OFFSET(ui);
 			zui_end_element();
 		}
@@ -326,7 +326,7 @@ class TabLayers {
 			}
 
 			ui._y -= center;
-			TabLayers.comboObject(ui, l);
+			TabLayers.combo_object(ui, l);
 			ui._y += center;
 
 			zui_end_element();
@@ -346,7 +346,7 @@ class TabLayers {
 	static layerToggleVisible = (l: SlotLayerRaw) => {
 		l.visible = !l.visible;
 		UIView2D.hwnd.redraws = 2;
-		MakeMaterial.parseMeshMaterial();
+		MakeMaterial.parse_mesh_material();
 	}
 
 	static drawLayerHighlight = (l: SlotLayerRaw, mini: bool) => {
@@ -372,11 +372,11 @@ class TabLayers {
 		// Lowest layer
 		if (index == 0) return false;
 		// Lowest layer that has masks
-		if (SlotLayer.isLayer(l) && SlotLayer.isMask(Project.layers[0]) && Project.layers[0].parent == l) return false;
+		if (SlotLayer.is_layer(l) && SlotLayer.is_mask(Project.layers[0]) && Project.layers[0].parent == l) return false;
 		// The lowest toplevel layer is a group
-		if (SlotLayer.isGroup(l) && SlotLayer.isInGroup(Project.layers[0]) && SlotLayer.getContainingGroup(Project.layers[0]) == l) return false;
+		if (SlotLayer.is_group(l) && SlotLayer.is_in_group(Project.layers[0]) && SlotLayer.get_containing_group(Project.layers[0]) == l) return false;
 		// Masks must be merged down to masks
-		if (SlotLayer.isMask(l) && !SlotLayer.isMask(Project.layers[index - 1])) return false;
+		if (SlotLayer.is_mask(l) && !SlotLayer.is_mask(Project.layers[index - 1])) return false;
 		return true;
 	}
 
@@ -385,7 +385,7 @@ class TabLayers {
 	}
 
 	static canDropNewLayer = (position: i32) => {
-		if (position > 0 && position < Project.layers.length && SlotLayer.isMask(Project.layers[position - 1])) {
+		if (position > 0 && position < Project.layers.length && SlotLayer.is_mask(Project.layers[position - 1])) {
 			// 1. The layer to insert is inserted in the middle
 			// 2. The layer below is a mask, i.e. the layer would have to be a (group) mask, too.
 			return false;

+ 74 - 75
base/Sources/Args.ts

@@ -1,76 +1,75 @@
 
 class Args {
 
-	static useArgs = false;
-	static assetPath = "";
-	static background = false;
+	static use_args: bool = false;
+	static asset_path: string = "";
+	static background: bool = false;
 	///if (is_paint || is_lab)
-	static exportTextures = false;
-	static exportTexturesType = "";
-	static exportTexturesPreset = "";
-	static exportTexturesPath = "";
+	static export_textures: bool = false;
+	static export_textures_type: string = "";
+	static export_textures_preset: string = "";
+	static export_textures_path: string = "";
 	///end
 	///if (is_paint || is_sculpt)
-	static reimportMesh = false;
-	static exportMesh = false;
-	static exportMeshPath = "";
+	static reimport_mesh: bool = false;
+	static export_mesh: bool = false;
+	static export_mesh_path: string = "";
 	///end
 	///if is_paint
-	static exportMaterial = false;
-	static exportMaterialPath = "";
+	static export_material: bool = false;
+	static export_material_path: string = "";
 	///end
 
-	static parse = () => {
+	static parse() {
 		if (krom_get_arg_count() > 1) {
-			Args.useArgs = true;
+			Args.use_args = true;
 
-			let i = 0;
+			let i: i32 = 0;
 			while (i < krom_get_arg_count()) {
 				// Process each arg
-				let currentArg = krom_get_arg(i);
+				let current_arg: string = krom_get_arg(i);
 
-				if (Path.isProject(currentArg)) {
-					Project.filepath = currentArg;
+				if (Path.is_project(current_arg)) {
+					Project.filepath = current_arg;
 				}
-				else if (currentArg == "--b" || currentArg == "--background") {
+				else if (current_arg == "--b" || current_arg == "--background") {
 					Args.background = true;
 				}
 
 				///if (is_paint || is_lab)
-				else if (Path.isTexture(currentArg)) {
-					Args.assetPath = currentArg;
+				else if (Path.is_texture(current_arg)) {
+					Args.asset_path = current_arg;
 				}
-				else if (currentArg == "--export-textures" && (i + 3) <= krom_get_arg_count()) {
-					Args.exportTextures = true;
+				else if (current_arg == "--export-textures" && (i + 3) <= krom_get_arg_count()) {
+					Args.export_textures = true;
 					++i;
-					Args.exportTexturesType = krom_get_arg(i);
+					Args.export_textures_type = krom_get_arg(i);
 					++i;
-					Args.exportTexturesPreset = krom_get_arg(i);
+					Args.export_textures_preset = krom_get_arg(i);
 					++i;
-					Args.exportTexturesPath = krom_get_arg(i);
+					Args.export_textures_path = krom_get_arg(i);
 				}
 				///end
 
 				///if (is_paint || is_sculpt)
-				else if (currentArg == "--reload-mesh") {
-					Args.reimportMesh = true;
+				else if (current_arg == "--reload-mesh") {
+					Args.reimport_mesh = true;
 				}
-				else if (currentArg == "--export-mesh" && (i + 1) <= krom_get_arg_count()) {
-					Args.exportMesh = true;
+				else if (current_arg == "--export-mesh" && (i + 1) <= krom_get_arg_count()) {
+					Args.export_mesh = true;
 					++i;
-					Args.exportMeshPath = krom_get_arg(i);
+					Args.export_mesh_path = krom_get_arg(i);
 				}
-				else if (Path.isMesh(currentArg) ||
-						(i > 1 && !currentArg.startsWith("-") && Path.isFolder(currentArg))) {
-					Args.assetPath = currentArg;
+				else if (Path.is_mesh(current_arg) || (i > 1 && !current_arg.startsWith("-") && Path.is_folder(current_arg))) {
+					Args.asset_path = current_arg;
 				}
 				///end
 
 				///if is_paint
-				else if (currentArg == "--export-material" && (i + 1) <= krom_get_arg_count()) {
-					Args.exportMaterial = true;
+				else if (current_arg == "--export-material" && (i + 1) <= krom_get_arg_count()) {
+					Args.export_material = true;
 					++i;
-					Args.exportMaterialPath = krom_get_arg(i);
+					Args.export_material_path = krom_get_arg(i);
 				}
 				///end
 
@@ -79,69 +78,69 @@ class Args {
 		}
 	}
 
-	static run = () => {
-		if (Args.useArgs) {
+	static run() {
+		if (Args.use_args) {
 			app_notify_on_init(() => {
 				if (Project.filepath != "") {
-					ImportArm.runProject(Project.filepath);
+					ImportArm.run_project(Project.filepath);
 				}
-				else if (Args.assetPath != "") {
-					ImportAsset.run(Args.assetPath, -1, -1, false);
+				else if (Args.asset_path != "") {
+					ImportAsset.run(Args.asset_path, -1, -1, false);
 					///if is_paint
-					if (Path.isTexture(Args.assetPath)) {
-						UIBase.show2DView(View2DType.View2DAsset);
+					if (Path.is_texture(Args.asset_path)) {
+						UIBase.show_2d_view(view_2d_type_t.ASSET);
 					}
 					///end
 				}
 				///if (is_paint || is_sculpt)
-				else if (Args.reimportMesh) {
-					Project.reimportMesh();
+				else if (Args.reimport_mesh) {
+					Project.reimport_mesh();
 				}
 				///end
 
 				///if (is_paint || is_lab)
-				if (Args.exportTextures) {
-					if (Args.exportTexturesType == "png" ||
-						Args.exportTexturesType == "jpg" ||
-						Args.exportTexturesType == "exr16" ||
-						Args.exportTexturesType == "exr32") {
-						if (Path.isFolder(Args.exportTexturesPath)) {
+				if (Args.export_textures) {
+					if (Args.export_textures_type == "png" ||
+						Args.export_textures_type == "jpg" ||
+						Args.export_textures_type == "exr16" ||
+						Args.export_textures_type == "exr32") {
+						if (Path.is_folder(Args.export_textures_path)) {
 							// Applying the correct format type from args
-							if (Args.exportTexturesType == "png") {
+							if (Args.export_textures_type == "png") {
 								///if is_paint
-								Base.bitsHandle.position = TextureBits.Bits8;
+								Base.bits_handle.position = texture_bits_t.BITS8;
 								///end
-								Context.raw.formatType = TextureLdrFormat.FormatPng;
+								Context.raw.format_type = texture_ldr_format_t.PNG;
 							}
-							else if (Args.exportTexturesType == "jpg") {
+							else if (Args.export_textures_type == "jpg") {
 								///if is_paint
-								Base.bitsHandle.position = TextureBits.Bits8;
+								Base.bits_handle.position = texture_bits_t.BITS8;
 								///end
-								Context.raw.formatType = TextureLdrFormat.FormatJpg;
+								Context.raw.format_type = texture_ldr_format_t.JPG;
 							}
-							else if (Args.exportTexturesType == "exr16") {
+							else if (Args.export_textures_type == "exr16") {
 								///if is_paint
-								Base.bitsHandle.position = TextureBits.Bits16;
+								Base.bits_handle.position = texture_bits_t.BITS16;
 								///end
 							}
-							else if (Args.exportTexturesType == "exr32") {
+							else if (Args.export_textures_type == "exr32") {
 								///if is_paint
-								Base.bitsHandle.position = TextureBits.Bits32;
+								Base.bits_handle.position = texture_bits_t.BITS32;
 								///end
 							}
 
 							///if is_paint
-							Context.raw.layersExport = ExportMode.ExportVisible;
+							Context.raw.layers_export = export_mode_t.VISIBLE;
 							///end
 
 							// Get export preset and apply the correct one from args
-							BoxExport.files = File.readDirectory(Path.data() + Path.sep + "export_presets");
-							for (let i = 0; i < BoxExport.files.length; ++i) {
+							BoxExport.files = File.read_directory(Path.data() + Path.sep + "export_presets");
+							for (let i: i32 = 0; i < BoxExport.files.length; ++i) {
 								BoxExport.files[i] = BoxExport.files[i].substr(0, BoxExport.files[i].length - 5); // Strip .json
 							}
 
-							let file = "export_presets/" + BoxExport.files[0] + ".json";
-							for (let f of BoxExport.files) if (f == Args.exportTexturesPreset) {
+							let file: string = "export_presets/" + BoxExport.files[0] + ".json";
+							for (let f of BoxExport.files) if (f == Args.export_textures_preset) {
 								file = "export_presets/" + BoxExport.files[BoxExport.files.indexOf(f)] + ".json";
 							}
 
@@ -151,7 +150,7 @@ class Args {
 
 							// Export queue
 							app_notify_on_init(() => {
-								ExportTexture.run(Args.exportTexturesPath);
+								ExportTexture.run(Args.export_textures_path);
 							});
 						}
 						else {
@@ -165,11 +164,11 @@ class Args {
 				///end
 
 				///if (is_paint || is_sculpt)
-				else if (Args.exportMesh) {
-					if (Path.isFolder(Args.exportMeshPath)) {
-						let f = UIFiles.filename;
+				else if (Args.export_mesh) {
+					if (Path.is_folder(Args.export_mesh_path)) {
+						let f: string = UIFiles.filename;
 						if (f == "") f = tr("untitled");
-						ExportMesh.run(Args.exportMeshPath + Path.sep + f, null, false);
+						ExportMesh.run(Args.export_mesh_path + Path.sep + f, null, false);
 					}
 					else {
 						krom_log(tr("Invalid export directory"));
@@ -178,9 +177,9 @@ class Args {
 				///end
 
 				///if is_paint
-				else if (Args.exportMaterial) {
-					Context.raw.writeIconOnExport = true;
-					ExportArm.runMaterial(Args.exportMaterialPath);
+				else if (Args.export_material) {
+					Context.raw.write_icon_on_export = true;
+					ExportArm.run_material(Args.export_material_path);
 				}
 				///end
 

文件差异内容过多而无法显示
+ 324 - 324
base/Sources/Base.ts


+ 149 - 149
base/Sources/BoxExport.ts

@@ -1,37 +1,37 @@
 
 class BoxExport {
 
-	static htab = zui_handle_create();
+	static htab: zui_handle_t = zui_handle_create();
 	static files: string[] = null;
-	static exportMeshHandle = zui_handle_create();
+	static export_mesh_handle: zui_handle_t = zui_handle_create();
 
 	///if (is_paint || is_lab)
-	static hpreset = zui_handle_create();
-	static preset: TExportPreset = null;
-	static channels = ["base_r", "base_g", "base_b", "height", "metal", "nor_r", "nor_g", "nor_g_directx", "nor_b", "occ", "opac", "rough", "smooth", "emis", "subs", "0.0", "1.0"];
-	static colorSpaces = ["linear", "srgb"];
+	static hpreset: zui_handle_t = zui_handle_create();
+	static preset: export_preset_t = null;
+	static channels: string[] = ["base_r", "base_g", "base_b", "height", "metal", "nor_r", "nor_g", "nor_g_directx", "nor_b", "occ", "opac", "rough", "smooth", "emis", "subs", "0.0", "1.0"];
+	static color_spaces: string[] = ["linear", "srgb"];
 	///end
 
 	///if (is_paint || is_lab)
-	static showTextures = () => {
-		UIBox.showCustom((ui: zui_t) => {
+	static show_textures = () => {
+		UIBox.show_custom((ui: zui_t) => {
 
 			if (BoxExport.files == null) {
-				BoxExport.fetchPresets();
+				BoxExport.fetch_presets();
 				BoxExport.hpreset.position = BoxExport.files.indexOf("generic");
 			}
 			if (BoxExport.preset == null) {
-				BoxExport.parsePreset();
+				BoxExport.parse_preset();
 				BoxExport.hpreset.children = null;
 			}
 
-			BoxExport.tabExportTextures(ui, tr("Export Textures"));
-			BoxExport.tabPresets(ui);
+			BoxExport.tab_export_textures(ui, tr("Export Textures"));
+			BoxExport.tab_presets(ui);
 
 			///if is_paint
-			BoxExport.tabAtlases(ui);
+			BoxExport.tab_atlases(ui);
 			///if (krom_android || krom_ios)
-			BoxExport.tabExportMesh(ui, BoxExport.htab);
+			BoxExport.tab_export_mesh(ui, BoxExport.htab);
 			///end
 			///end
 
@@ -40,91 +40,91 @@ class BoxExport {
 	///end
 
 	///if is_paint
-	static showBakeMaterial = () => {
-		UIBox.showCustom((ui: zui_t) => {
+	static show_bake_material = () => {
+		UIBox.show_custom((ui: zui_t) => {
 
 			if (BoxExport.files == null) {
-				BoxExport.fetchPresets();
+				BoxExport.fetch_presets();
 				BoxExport.hpreset.position = BoxExport.files.indexOf("generic");
 			}
 			if (BoxExport.preset == null) {
-				BoxExport.parsePreset();
+				BoxExport.parse_preset();
 				BoxExport.hpreset.children = null;
 			}
 
-			BoxExport.tabExportTextures(ui, tr("Bake to Textures"), true);
-			BoxExport.tabPresets(ui);
+			BoxExport.tab_export_textures(ui, tr("Bake to Textures"), true);
+			BoxExport.tab_presets(ui);
 
 		}, 540, 310);
 	}
 	///end
 
 	///if (is_paint || is_lab)
-	static tabExportTextures = (ui: zui_t, title: string, bakeMaterial = false) => {
-		let tabVertical = Config.raw.touch_ui;
+	static tab_export_textures = (ui: zui_t, title: string, bakeMaterial: bool = false) => {
+		let tabVertical: bool = Config.raw.touch_ui;
 		if (zui_tab(BoxExport.htab, title, tabVertical)) {
 
 			zui_row([0.5, 0.5]);
 
 			///if is_paint
 			///if (krom_android || krom_ios)
-			zui_combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K"], tr("Resolution"), true);
+			zui_combo(Base.res_handle, ["128", "256", "512", "1K", "2K", "4K"], tr("Resolution"), true);
 			///else
-			zui_combo(Base.resHandle, ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"], tr("Resolution"), true);
+			zui_combo(Base.res_handle, ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"], tr("Resolution"), true);
 			///end
 			///end
 
 			///if is_lab
 			///if (krom_android || krom_ios)
-			zui_combo(Base.resHandle, ["2K", "4K"], tr("Resolution"), true);
+			zui_combo(Base.res_handle, ["2K", "4K"], tr("Resolution"), true);
 			///else
-			zui_combo(Base.resHandle, ["2K", "4K", "8K", "16K"], tr("Resolution"), true);
+			zui_combo(Base.res_handle, ["2K", "4K", "8K", "16K"], tr("Resolution"), true);
 			///end
 			///end
 
-			if (Base.resHandle.changed) {
-				Base.onLayersResized();
+			if (Base.res_handle.changed) {
+				Base.on_layers_resized();
 			}
 
 			///if (is_lab || krom_android || krom_ios)
-			zui_combo(Base.bitsHandle, ["8bit"], tr("Color"), true);
+			zui_combo(Base.bits_handle, ["8bit"], tr("Color"), true);
 			///else
-			zui_combo(Base.bitsHandle, ["8bit", "16bit", "32bit"], tr("Color"), true);
+			zui_combo(Base.bits_handle, ["8bit", "16bit", "32bit"], tr("Color"), true);
 			///end
 
 			///if is_paint
-			if (Base.bitsHandle.changed) {
-				app_notify_on_init(Base.setLayerBits);
+			if (Base.bits_handle.changed) {
+				app_notify_on_init(Base.set_layer_bits);
 			}
 			///end
 
 			zui_row([0.5, 0.5]);
-			if (Base.bitsHandle.position == TextureBits.Bits8) {
-				Context.raw.formatType = zui_combo(zui_handle("boxexport_0", { position: Context.raw.formatType }), ["png", "jpg"], tr("Format"), true);
+			if (Base.bits_handle.position == texture_bits_t.BITS8) {
+				Context.raw.format_type = zui_combo(zui_handle("boxexport_0", { position: Context.raw.format_type }), ["png", "jpg"], tr("Format"), true);
 			}
 			else {
-				Context.raw.formatType = zui_combo(zui_handle("boxexport_1", { position: Context.raw.formatType }), ["exr"], tr("Format"), true);
+				Context.raw.format_type = zui_combo(zui_handle("boxexport_1", { position: Context.raw.format_type }), ["exr"], tr("Format"), true);
 			}
 
-			ui.enabled = Context.raw.formatType == TextureLdrFormat.FormatJpg && Base.bitsHandle.position == TextureBits.Bits8;
-			Context.raw.formatQuality = zui_slider(zui_handle("boxexport_2", { value: Context.raw.formatQuality }), tr("Quality"), 0.0, 100.0, true, 1);
+			ui.enabled = Context.raw.format_type == texture_ldr_format_t.JPG && Base.bits_handle.position == texture_bits_t.BITS8;
+			Context.raw.format_quality = zui_slider(zui_handle("boxexport_2", { value: Context.raw.format_quality }), tr("Quality"), 0.0, 100.0, true, 1);
 			ui.enabled = true;
 
 			///if is_paint
 			zui_row([0.5, 0.5]);
 			ui.enabled = !bakeMaterial;
-			let layersExportHandle = zui_handle("boxexport_3");
-			layersExportHandle.position = Context.raw.layersExport;
-			Context.raw.layersExport = zui_combo(layersExportHandle, [tr("Visible"), tr("Selected"), tr("Per Object"), tr("Per Udim Tile")], tr("Layers"), true);
+			let layersExportHandle: zui_handle_t = zui_handle("boxexport_3");
+			layersExportHandle.position = Context.raw.layers_export;
+			Context.raw.layers_export = zui_combo(layersExportHandle, [tr("Visible"), tr("Selected"), tr("Per Object"), tr("Per Udim Tile")], tr("Layers"), true);
 			ui.enabled = true;
 			///end
 
 			zui_combo(BoxExport.hpreset, BoxExport.files, tr("Preset"), true);
 			if (BoxExport.hpreset.changed) BoxExport.preset = null;
 
-			let layersDestinationHandle = zui_handle("boxexport_4");
-			layersDestinationHandle.position = Context.raw.layersDestination;
-			Context.raw.layersDestination = zui_combo(layersDestinationHandle, [tr("Disk"), tr("Packed")], tr("Destination"), true);
+			let layersDestinationHandle: zui_handle_t = zui_handle("boxexport_4");
+			layersDestinationHandle.position = Context.raw.layers_destination;
+			Context.raw.layers_destination = zui_combo(layersDestinationHandle, [tr("Disk"), tr("Packed")], tr("Destination"), true);
 
 			zui_end_element();
 
@@ -134,37 +134,37 @@ class BoxExport {
 			}
 			if (zui_button(tr("Export"))) {
 				UIBox.hide();
-				if (Context.raw.layersDestination == ExportDestination.DestinationPacked) {
-					Context.raw.textureExportPath = "/";
+				if (Context.raw.layers_destination == export_destination_t.PACKED) {
+					Context.raw.texture_export_path = "/";
 					let _init = () => {
 						///if is_paint
-						ExportTexture.run(Context.raw.textureExportPath, bakeMaterial);
+						ExportTexture.run(Context.raw.texture_export_path, bakeMaterial);
 						///end
 						///if is_lab
-						ExportTexture.run(Context.raw.textureExportPath);
+						ExportTexture.run(Context.raw.texture_export_path);
 						///end
 					}
 					app_notify_on_init(_init);
 				}
 				else {
-					let filters = Base.bitsHandle.position != TextureBits.Bits8 ? "exr" : Context.raw.formatType == TextureLdrFormat.FormatPng ? "png" : "jpg";
+					let filters = Base.bits_handle.position != texture_bits_t.BITS8 ? "exr" : Context.raw.format_type == texture_ldr_format_t.PNG ? "png" : "jpg";
 					UIFiles.show(filters, true, false, (path: string) => {
-						Context.raw.textureExportPath = path;
+						Context.raw.texture_export_path = path;
 						let doExport = () => {
 							let _init = () => {
 								///if is_paint
-								ExportTexture.run(Context.raw.textureExportPath, bakeMaterial);
+								ExportTexture.run(Context.raw.texture_export_path, bakeMaterial);
 								///end
 								///if is_lab
-								ExportTexture.run(Context.raw.textureExportPath);
+								ExportTexture.run(Context.raw.texture_export_path);
 								///end
 							}
 							app_notify_on_init(_init);
 						}
 						///if (krom_android || krom_ios)
-						Base.notifyOnNextFrame(() => {
+						Base.notify_on_next_frame(() => {
 							Console.toast(tr("Exporting textures"));
-							Base.notifyOnNextFrame(doExport);
+							Base.notify_on_next_frame(doExport);
 						});
 						///else
 						doExport();
@@ -176,8 +176,8 @@ class BoxExport {
 		}
 	}
 
-	static tabPresets = (ui: zui_t) => {
-		let tabVertical = Config.raw.touch_ui;
+	static tab_presets = (ui: zui_t) => {
+		let tabVertical: bool = Config.raw.touch_ui;
 		if (zui_tab(BoxExport.htab, tr("Presets"), tabVertical)) {
 			zui_row([3 / 5, 1 / 5, 1 / 5]);
 
@@ -185,19 +185,19 @@ class BoxExport {
 			if (BoxExport.hpreset.changed) BoxExport.preset = null;
 
 			if (zui_button(tr("New"))) {
-				UIBox.showCustom((ui: zui_t) => {
-					let tabVertical = Config.raw.touch_ui;
+				UIBox.show_custom((ui: zui_t) => {
+					let tabVertical: bool = Config.raw.touch_ui;
 					if (zui_tab(zui_handle("boxexport_5"), tr("New Preset"), tabVertical)) {
 						zui_row([0.5, 0.5]);
-						let presetName = zui_text_input(zui_handle("boxexport_6", { text: "new_preset" }), tr("Name"));
+						let presetName: string = zui_text_input(zui_handle("boxexport_6", { text: "new_preset" }), tr("Name"));
 						if (zui_button(tr("OK")) || ui.is_return_down) {
-							BoxExport.newPreset(presetName);
-							BoxExport.fetchPresets();
+							BoxExport.new_preset(presetName);
+							BoxExport.fetch_presets();
 							BoxExport.preset = null;
 							BoxExport.hpreset.position = BoxExport.files.indexOf(presetName);
 							UIBox.hide();
 							BoxExport.htab.position = 1; // Presets
-							BoxExport.showTextures();
+							BoxExport.show_textures();
 						}
 					}
 				});
@@ -207,10 +207,10 @@ class BoxExport {
 				UIFiles.show("json", false, false, (path: string) => {
 					path = path.toLowerCase();
 					if (path.endsWith(".json")) {
-						let filename = path.substr(path.lastIndexOf(Path.sep) + 1);
-						let dstPath = Path.data() + Path.sep + "export_presets" + Path.sep + filename;
+						let filename: string = path.substr(path.lastIndexOf(Path.sep) + 1);
+						let dstPath: string = Path.data() + Path.sep + "export_presets" + Path.sep + filename;
 						File.copy(path, dstPath); // Copy to presets folder
-						BoxExport.fetchPresets();
+						BoxExport.fetch_presets();
 						BoxExport.preset = null;
 						BoxExport.hpreset.position = BoxExport.files.indexOf(filename.substr(0, filename.length - 5)); // Strip .json
 						Console.info(tr("Preset imported:") + " " + filename);
@@ -220,7 +220,7 @@ class BoxExport {
 			}
 
 			if (BoxExport.preset == null) {
-				BoxExport.parsePreset();
+				BoxExport.parse_preset();
 				BoxExport.hpreset.children = null;
 			}
 
@@ -234,29 +234,29 @@ class BoxExport {
 			zui_text(tr("A"));
 			zui_text(tr("Color Space"));
 			ui.changed = false;
-			for (let i = 0; i < BoxExport.preset.textures.length; ++i) {
-				let t = BoxExport.preset.textures[i];
+			for (let i: i32 = 0; i < BoxExport.preset.textures.length; ++i) {
+				let t: export_preset_texture_t = BoxExport.preset.textures[i];
 				zui_row([1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6, 1 / 6]);
-				let htex = zui_nest(BoxExport.hpreset, i);
+				let htex: zui_handle_t = zui_nest(BoxExport.hpreset, i);
 				htex.text = t.name;
 				t.name = zui_text_input(htex);
 
 				if (ui.is_hovered && ui.input_released_r) {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Delete"))) {
+						if (UIMenu.menu_button(ui, tr("Delete"))) {
 							array_remove(BoxExport.preset.textures, t);
-							BoxExport.savePreset();
+							BoxExport.save_preset();
 						}
 					}, 1);
 				}
 
-				let hr = zui_nest(htex, 0);
+				let hr: zui_handle_t = zui_nest(htex, 0);
 				hr.position = BoxExport.channels.indexOf(t.channels[0]);
-				let hg = zui_nest(htex, 1);
+				let hg: zui_handle_t = zui_nest(htex, 1);
 				hg.position = BoxExport.channels.indexOf(t.channels[1]);
-				let hb = zui_nest(htex, 2);
+				let hb: zui_handle_t = zui_nest(htex, 2);
 				hb.position = BoxExport.channels.indexOf(t.channels[2]);
-				let ha = zui_nest(htex, 3);
+				let ha: zui_handle_t = zui_nest(htex, 3);
 				ha.position = BoxExport.channels.indexOf(t.channels[3]);
 
 				zui_combo(hr, BoxExport.channels, tr("R"));
@@ -268,74 +268,74 @@ class BoxExport {
 				zui_combo(ha, BoxExport.channels, tr("A"));
 				if (ha.changed) t.channels[3] = BoxExport.channels[ha.position];
 
-				let hspace = zui_nest(htex, 4);
-				hspace.position = BoxExport.colorSpaces.indexOf(t.color_space);
-				zui_combo(hspace, BoxExport.colorSpaces, tr("Color Space"));
-				if (hspace.changed) t.color_space = BoxExport.colorSpaces[hspace.position];
+				let hspace: zui_handle_t = zui_nest(htex, 4);
+				hspace.position = BoxExport.color_spaces.indexOf(t.color_space);
+				zui_combo(hspace, BoxExport.color_spaces, tr("Color Space"));
+				if (hspace.changed) t.color_space = BoxExport.color_spaces[hspace.position];
 			}
 
 			if (ui.changed) {
-				BoxExport.savePreset();
+				BoxExport.save_preset();
 			}
 
 			zui_row([1 / 8]);
 			if (zui_button(tr("Add"))) {
 				BoxExport.preset.textures.push({ name: "base", channels: ["base_r", "base_g", "base_b", "1.0"], color_space: "linear" });
 				BoxExport.hpreset.children = null;
-				BoxExport.savePreset();
+				BoxExport.save_preset();
 			}
 		}
 	}
 	///end
 
 	///if is_paint
-	static tabAtlases = (ui: zui_t) => {
-		let tabVertical = Config.raw.touch_ui;
+	static tab_atlases = (ui: zui_t) => {
+		let tabVertical: bool = Config.raw.touch_ui;
 		if (zui_tab(BoxExport.htab, tr("Atlases"), tabVertical)) {
-			if (Project.atlasObjects == null || Project.atlasObjects.length != Project.paintObjects.length) {
-				Project.atlasObjects = [];
-				Project.atlasNames = [];
-				for (let i = 0; i < Project.paintObjects.length; ++i) {
-					Project.atlasObjects.push(0);
-					Project.atlasNames.push(tr("Atlas") + " " + (i + 1));
+			if (Project.atlas_objects == null || Project.atlas_objects.length != Project.paint_objects.length) {
+				Project.atlas_objects = [];
+				Project.atlas_names = [];
+				for (let i: i32 = 0; i < Project.paint_objects.length; ++i) {
+					Project.atlas_objects.push(0);
+					Project.atlas_names.push(tr("Atlas") + " " + (i + 1));
 				}
 			}
-			for (let i = 0; i < Project.paintObjects.length; ++i) {
+			for (let i: i32 = 0; i < Project.paint_objects.length; ++i) {
 				zui_row([1 / 2, 1 / 2]);
-				zui_text(Project.paintObjects[i].base.name);
-				let hatlas = zui_nest(zui_handle("boxexport_7"), i);
-				hatlas.position = Project.atlasObjects[i];
-				Project.atlasObjects[i] = zui_combo(hatlas, Project.atlasNames, tr("Atlas"));
+				zui_text(Project.paint_objects[i].base.name);
+				let hatlas: zui_handle_t = zui_nest(zui_handle("boxexport_7"), i);
+				hatlas.position = Project.atlas_objects[i];
+				Project.atlas_objects[i] = zui_combo(hatlas, Project.atlas_names, tr("Atlas"));
 			}
 		}
 	}
 	///end
 
-	static showMesh = () => {
-		BoxExport.exportMeshHandle.position = Context.raw.exportMeshIndex;
-		UIBox.showCustom((ui: zui_t) => {
-			let htab = zui_handle("boxexport_8");
-			BoxExport.tabExportMesh(ui, htab);
+	static show_mesh = () => {
+		BoxExport.export_mesh_handle.position = Context.raw.export_mesh_index;
+		UIBox.show_custom((ui: zui_t) => {
+			let htab: zui_handle_t = zui_handle("boxexport_8");
+			BoxExport.tab_export_mesh(ui, htab);
 		});
 	}
 
-	static tabExportMesh = (ui: zui_t, htab: zui_handle_t) => {
-		let tabVertical = Config.raw.touch_ui;
+	static tab_export_mesh = (ui: zui_t, htab: zui_handle_t) => {
+		let tabVertical: bool = Config.raw.touch_ui;
 		if (zui_tab(htab, tr("Export Mesh"), tabVertical)) {
 
 			zui_row([1 / 2, 1 / 2]);
 
-			Context.raw.exportMeshFormat = zui_combo(zui_handle("boxexport_9", { position: Context.raw.exportMeshFormat }), ["obj", "arm"], tr("Format"), true);
+			Context.raw.export_mesh_format = zui_combo(zui_handle("boxexport_9", { position: Context.raw.export_mesh_format }), ["obj", "arm"], tr("Format"), true);
 
-			let ar = [tr("All")];
-			for (let p of Project.paintObjects) ar.push(p.base.name);
-			zui_combo(BoxExport.exportMeshHandle, ar, tr("Meshes"), true);
+			let ar: string[] = [tr("All")];
+			for (let p of Project.paint_objects) ar.push(p.base.name);
+			zui_combo(BoxExport.export_mesh_handle, ar, tr("Meshes"), true);
 
-			let applyDisplacement = zui_check(zui_handle("boxexport_10"), tr("Apply Displacement"));
+			let applyDisplacement: bool = zui_check(zui_handle("boxexport_10"), tr("Apply Displacement"));
 
-			let tris = 0;
-			let pos = BoxExport.exportMeshHandle.position;
-			let paintObjects = pos == 0 ? Project.paintObjects : [Project.paintObjects[pos - 1]];
+			let tris: i32 = 0;
+			let pos: i32 = BoxExport.export_mesh_handle.position;
+			let paintObjects: mesh_object_t[] = pos == 0 ? Project.paint_objects : [Project.paint_objects[pos - 1]];
 			for (let po of paintObjects) {
 				for (let inda of po.data.index_arrays) {
 					tris += Math.floor(inda.values.length / 3);
@@ -349,20 +349,20 @@ class BoxExport {
 			}
 			if (zui_button(tr("Export"))) {
 				UIBox.hide();
-				UIFiles.show(Context.raw.exportMeshFormat == MeshFormat.FormatObj ? "obj" : "arm", true, false, (path: string) => {
+				UIFiles.show(Context.raw.export_mesh_format == mesh_format_t.OBJ ? "obj" : "arm", true, false, (path: string) => {
 					///if (krom_android || krom_ios)
-					let f = sys_title();
+					let f: string = sys_title();
 					///else
-					let f = UIFiles.filename;
+					let f: string = UIFiles.filename;
 					///end
 					if (f == "") f = tr("untitled");
 					let doExport = () => {
-						ExportMesh.run(path + Path.sep + f, BoxExport.exportMeshHandle.position == 0 ? null : [Project.paintObjects[BoxExport.exportMeshHandle.position - 1]], applyDisplacement);
+						ExportMesh.run(path + Path.sep + f, BoxExport.export_mesh_handle.position == 0 ? null : [Project.paint_objects[BoxExport.export_mesh_handle.position - 1]], applyDisplacement);
 					}
 					///if (krom_android || krom_ios)
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						Console.toast(tr("Exporting mesh"));
-						Base.notifyOnNextFrame(doExport);
+						Base.notify_on_next_frame(doExport);
 					});
 					///else
 					doExport();
@@ -373,17 +373,17 @@ class BoxExport {
 	}
 
 	///if (is_paint || is_sculpt)
-	static showMaterial = () => {
-		UIBox.showCustom((ui: zui_t) => {
-			let htab = zui_handle("boxexport_11");
-			let tabVertical = Config.raw.touch_ui;
+	static show_material = () => {
+		UIBox.show_custom((ui: zui_t) => {
+			let htab: zui_handle_t = zui_handle("boxexport_11");
+			let tabVertical: bool = Config.raw.touch_ui;
 			if (zui_tab(htab, tr("Export Material"), tabVertical)) {
-				let h1 = zui_handle("boxexport_12");
-				let h2 = zui_handle("boxexport_13");
-				h1.selected = Context.raw.packAssetsOnExport;
-				h2.selected = Context.raw.writeIconOnExport;
-				Context.raw.packAssetsOnExport = zui_check(h1, tr("Pack Assets"));
-				Context.raw.writeIconOnExport = zui_check(h2, tr("Export Icon"));
+				let h1: zui_handle_t = zui_handle("boxexport_12");
+				let h2: zui_handle_t = zui_handle("boxexport_13");
+				h1.selected = Context.raw.pack_assets_on_export;
+				h2.selected = Context.raw.write_icon_on_export;
+				Context.raw.pack_assets_on_export = zui_check(h1, tr("Pack Assets"));
+				Context.raw.write_icon_on_export = zui_check(h2, tr("Export Icon"));
 				zui_row([0.5, 0.5]);
 				if (zui_button(tr("Cancel"))) {
 					UIBox.hide();
@@ -391,10 +391,10 @@ class BoxExport {
 				if (zui_button(tr("Export"))) {
 					UIBox.hide();
 					UIFiles.show("arm", true, false, (path: string) => {
-						let f = UIFiles.filename;
+						let f: string = UIFiles.filename;
 						if (f == "") f = tr("untitled");
 						app_notify_on_init(() => {
-							ExportArm.runMaterial(path + Path.sep + f);
+							ExportArm.run_material(path + Path.sep + f);
 						});
 					});
 				}
@@ -402,17 +402,17 @@ class BoxExport {
 		});
 	}
 
-	static showBrush = () => {
-		UIBox.showCustom((ui: zui_t) => {
-			let htab = zui_handle("boxexport_14");
-			let tabVertical = Config.raw.touch_ui;
+	static show_brush = () => {
+		UIBox.show_custom((ui: zui_t) => {
+			let htab: zui_handle_t = zui_handle("boxexport_14");
+			let tabVertical: bool = Config.raw.touch_ui;
 			if (zui_tab(htab, tr("Export Brush"), tabVertical)) {
-				let h1 = zui_handle("boxexport_15");
-				let h2 = zui_handle("boxexport_16");
-				h1.selected = Context.raw.packAssetsOnExport;
-				h2.selected = Context.raw.writeIconOnExport;
-				Context.raw.packAssetsOnExport = zui_check(h1, tr("Pack Assets"));
-				Context.raw.writeIconOnExport = zui_check(h2, tr("Export Icon"));
+				let h1: zui_handle_t = zui_handle("boxexport_15");
+				let h2: zui_handle_t = zui_handle("boxexport_16");
+				h1.selected = Context.raw.pack_assets_on_export;
+				h2.selected = Context.raw.write_icon_on_export;
+				Context.raw.pack_assets_on_export = zui_check(h1, tr("Pack Assets"));
+				Context.raw.write_icon_on_export = zui_check(h2, tr("Export Icon"));
 				zui_row([0.5, 0.5]);
 				if (zui_button(tr("Cancel"))) {
 					UIBox.hide();
@@ -420,10 +420,10 @@ class BoxExport {
 				if (zui_button(tr("Export"))) {
 					UIBox.hide();
 					UIFiles.show("arm", true, false, (path: string) => {
-						let f = UIFiles.filename;
+						let f: string = UIFiles.filename;
 						if (f == "") f = tr("untitled");
 						app_notify_on_init(() => {
-							ExportArm.runBrush(path + Path.sep + f);
+							ExportArm.run_brush(path + Path.sep + f);
 						});
 					});
 				}
@@ -433,22 +433,22 @@ class BoxExport {
 	///end
 
 	///if (is_paint || is_lab)
-	static fetchPresets = () => {
-		BoxExport.files = File.readDirectory(Path.data() + Path.sep + "export_presets");
-		for (let i = 0; i < BoxExport.files.length; ++i) {
+	static fetch_presets = () => {
+		BoxExport.files = File.read_directory(Path.data() + Path.sep + "export_presets");
+		for (let i: i32 = 0; i < BoxExport.files.length; ++i) {
 			BoxExport.files[i] = BoxExport.files[i].substr(0, BoxExport.files[i].length - 5); // Strip .json
 		}
 	}
 
-	static parsePreset = () => {
-		let file = "export_presets/" + BoxExport.files[BoxExport.hpreset.position] + ".json";
+	static parse_preset = () => {
+		let file: string = "export_presets/" + BoxExport.files[BoxExport.hpreset.position] + ".json";
 		let blob: ArrayBuffer = data_get_blob(file);
 		BoxExport.preset = JSON.parse(sys_buffer_to_string(blob));
 		data_delete_blob("export_presets/" + file);
 	}
 
-	static newPreset = (name: string) => {
-		let template =
+	static new_preset = (name: string) => {
+		let template: string =
 `{
 	"textures": [
 		{ "name": "base", "channels": ["base_r", "base_g", "base_b", "1.0"], "color_space": "linear" }
@@ -456,14 +456,14 @@ class BoxExport {
 }
 `;
 		if (!name.endsWith(".json")) name += ".json";
-		let path = Path.data() + Path.sep + "export_presets" + Path.sep + name;
+		let path: string = Path.data() + Path.sep + "export_presets" + Path.sep + name;
 		krom_file_save_bytes(path, sys_string_to_buffer(template));
 	}
 
-	static savePreset = () => {
-		let name = BoxExport.files[BoxExport.hpreset.position];
+	static save_preset = () => {
+		let name: string = BoxExport.files[BoxExport.hpreset.position];
 		if (name == "generic") return; // generic is const
-		let path = Path.data() + Path.sep + "export_presets" + Path.sep + name + ".json";
+		let path: string = Path.data() + Path.sep + "export_presets" + Path.sep + name + ".json";
 		krom_file_save_bytes(path, sys_string_to_buffer(JSON.stringify(BoxExport.preset)));
 	}
 	///end

+ 192 - 192
base/Sources/BoxPreferences.ts

@@ -1,44 +1,44 @@
 
 class BoxPreferences {
 
-	static htab = zui_handle_create();
-	static filesPlugin: string[] = null;
-	static filesKeymap: string[] = null;
-	static themeHandle: zui_handle_t;
-	static presetHandle: zui_handle_t;
+	static htab : zui_handle_t= zui_handle_create();
+	static files_plugin: string[] = null;
+	static files_keymap: string[] = null;
+	static theme_handle: zui_handle_t;
+	static preset_handle: zui_handle_t;
 	static locales: string[] = null;
 	static themes: string[] = null;
-	static worldColor = 0xff080808;
+	static world_color: i32 = 0xff080808;
 
 	static show = () => {
 
-		UIBox.showCustom((ui: zui_t) => {
+		UIBox.show_custom((ui: zui_t) => {
 			if (zui_tab(BoxPreferences.htab, tr("Interface"), true)) {
 
 				if (BoxPreferences.locales == null) {
-					BoxPreferences.locales = Translator.getSupportedLocales();
+					BoxPreferences.locales = Translator.get_supported_locales();
 				}
 
-				let localeHandle = zui_handle("boxpreferences_0", { position: BoxPreferences.locales.indexOf(Config.raw.locale) });
+				let localeHandle: zui_handle_t = zui_handle("boxpreferences_0", { position: BoxPreferences.locales.indexOf(Config.raw.locale) });
 				zui_combo(localeHandle, BoxPreferences.locales, tr("Language"), true);
 				if (localeHandle.changed) {
-					let localeCode = BoxPreferences.locales[localeHandle.position];
+					let localeCode: string = BoxPreferences.locales[localeHandle.position];
 					Config.raw.locale = localeCode;
-					Translator.loadTranslations(localeCode);
-					UIBase.tagUIRedraw();
+					Translator.load_translations(localeCode);
+					UIBase.tag_ui_redraw();
 				}
 
-				let hscale = zui_handle("boxpreferences_1", { value: Config.raw.window_scale });
+				let hscale: zui_handle_t = zui_handle("boxpreferences_1", { value: Config.raw.window_scale });
 				zui_slider(hscale, tr("UI Scale"), 1.0, 4.0, true, 10);
-				if (Context.raw.hscaleWasChanged && !ui.input_down) {
-					Context.raw.hscaleWasChanged = false;
+				if (Context.raw.hscale_was_changed && !ui.input_down) {
+					Context.raw.hscale_was_changed = false;
 					if (hscale.value == null || isNaN(hscale.value)) hscale.value = 1.0;
 					Config.raw.window_scale = hscale.value;
-					BoxPreferences.setScale();
+					BoxPreferences.set_scale();
 				}
-				if (hscale.changed) Context.raw.hscaleWasChanged = true;
+				if (hscale.changed) Context.raw.hscale_was_changed = true;
 
-				let hspeed = zui_handle("boxpreferences_2", { value: Config.raw.camera_zoom_speed });
+				let hspeed: zui_handle_t = zui_handle("boxpreferences_2", { value: Config.raw.camera_zoom_speed });
 				Config.raw.camera_zoom_speed = zui_slider(hspeed, tr("Camera Zoom Speed"), 0.1, 4.0, true);
 
 				hspeed = zui_handle("boxpreferences_3", { value: Config.raw.camera_rotation_speed });
@@ -47,7 +47,7 @@ class BoxPreferences {
 				hspeed = zui_handle("boxpreferences_4", { value: Config.raw.camera_pan_speed });
 				Config.raw.camera_pan_speed = zui_slider(hspeed, tr("Camera Pan Speed"), 0.1, 4.0, true);
 
-				let zoomDirectionHandle = zui_handle("boxpreferences_5", { position: Config.raw.zoom_direction });
+				let zoomDirectionHandle: zui_handle_t = zui_handle("boxpreferences_5", { position: Config.raw.zoom_direction });
 				zui_combo(zoomDirectionHandle, [tr("Vertical"), tr("Vertical Inverted"), tr("Horizontal"), tr("Horizontal Inverted"), tr("Vertical and Horizontal"), tr("Vertical and Horizontal Inverted")], tr("Direction to Zoom"), true);
 				if (zoomDirectionHandle.changed) {
 					Config.raw.zoom_direction = zoomDirectionHandle.position;
@@ -61,7 +61,7 @@ class BoxPreferences {
 				ui.changed = false;
 				Config.raw.show_asset_names = zui_check(zui_handle("boxpreferences_8", { selected: Config.raw.show_asset_names }), tr("Show Asset Names"));
 				if (ui.changed) {
-					UIBase.tagUIRedraw();
+					UIBase.tag_ui_redraw();
 				}
 
 				///if !(krom_android || krom_ios)
@@ -71,43 +71,43 @@ class BoxPreferences {
 					zui_set_touch_scroll(Config.raw.touch_ui);
 					zui_set_touch_hold(Config.raw.touch_ui);
 					zui_set_touch_tooltip(Config.raw.touch_ui);
-					Config.loadTheme(Config.raw.theme);
-					BoxPreferences.setScale();
-					UIBase.tagUIRedraw();
+					Config.load_theme(Config.raw.theme);
+					BoxPreferences.set_scale();
+					UIBase.tag_ui_redraw();
 				}
 				///end
 
 				Config.raw.splash_screen = zui_check(zui_handle("boxpreferences_10", { selected: Config.raw.splash_screen }), tr("Splash Screen"));
 
 				// Zui.text("Node Editor");
-				// let gridSnap = Zui.check(Zui.handle("boxpreferences_11", { selected: false }), "Grid Snap");
+				// let gridSnap: bool = Zui.check(Zui.handle("boxpreferences_11", { selected: false }), "Grid Snap");
 
 				zui_end_element();
 				zui_row([0.5, 0.5]);
 				if (zui_button(tr("Restore")) && !UIMenu.show) {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Confirm"))) {
+						if (UIMenu.menu_button(ui, tr("Confirm"))) {
 							app_notify_on_init(() => {
-								ui.t.ELEMENT_H = Base.defaultElementH;
+								ui.t.ELEMENT_H = Base.default_element_h;
 								Config.restore();
-								BoxPreferences.setScale();
-								if (BoxPreferences.filesPlugin != null) for (let f of BoxPreferences.filesPlugin) Plugin.stop(f);
-								BoxPreferences.filesPlugin = null;
-								BoxPreferences.filesKeymap = null;
-								MakeMaterial.parseMeshMaterial();
-								MakeMaterial.parsePaintMaterial();
+								BoxPreferences.set_scale();
+								if (BoxPreferences.files_plugin != null) for (let f of BoxPreferences.files_plugin) Plugin.stop(f);
+								BoxPreferences.files_plugin = null;
+								BoxPreferences.files_keymap = null;
+								MakeMaterial.parse_mesh_material();
+								MakeMaterial.parse_paint_material();
 							});
 						}
-						if (UIMenu.menuButton(ui, tr("Import..."))) {
+						if (UIMenu.menu_button(ui, tr("Import..."))) {
 							UIFiles.show("json", false, false, (path: string) => {
 								let b: ArrayBuffer = data_get_blob(path);
-								let raw = JSON.parse(sys_buffer_to_string(b));
+								let raw: config_t = JSON.parse(sys_buffer_to_string(b));
 								app_notify_on_init(() => {
-									ui.t.ELEMENT_H = Base.defaultElementH;
-									Config.importFrom(raw);
-									BoxPreferences.setScale();
-									MakeMaterial.parseMeshMaterial();
-									MakeMaterial.parsePaintMaterial();
+									ui.t.ELEMENT_H = Base.default_element_h;
+									Config.import_from(raw);
+									BoxPreferences.set_scale();
+									MakeMaterial.parse_mesh_material();
+									MakeMaterial.parse_paint_material();
 								});
 							});
 						}
@@ -115,8 +115,8 @@ class BoxPreferences {
 				}
 				if (zui_button(tr("Reset Layout")) && !UIMenu.show) {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Confirm"))) {
-							Base.initLayout();
+						if (UIMenu.menu_button(ui, tr("Confirm"))) {
+							Base.init_layout();
 							Config.save();
 						}
 					}, 1);
@@ -126,32 +126,32 @@ class BoxPreferences {
 			if (zui_tab(BoxPreferences.htab, tr("Theme"), true)) {
 
 				if (BoxPreferences.themes == null) {
-					BoxPreferences.fetchThemes();
+					BoxPreferences.fetch_themes();
 				}
-				BoxPreferences.themeHandle = zui_handle("boxpreferences_12", { position: BoxPreferences.getThemeIndex() });
+				BoxPreferences.theme_handle = zui_handle("boxpreferences_12", { position: BoxPreferences.get_theme_index() });
 
 				zui_begin_sticky();
 				zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]);
 
-				zui_combo(BoxPreferences.themeHandle, BoxPreferences.themes, tr("Theme"));
-				if (BoxPreferences.themeHandle.changed) {
-					Config.raw.theme = BoxPreferences.themes[BoxPreferences.themeHandle.position] + ".json";
-					Config.loadTheme(Config.raw.theme);
+				zui_combo(BoxPreferences.theme_handle, BoxPreferences.themes, tr("Theme"));
+				if (BoxPreferences.theme_handle.changed) {
+					Config.raw.theme = BoxPreferences.themes[BoxPreferences.theme_handle.position] + ".json";
+					Config.load_theme(Config.raw.theme);
 				}
 
 				if (zui_button(tr("New"))) {
-					UIBox.showCustom((ui: zui_t) => {
+					UIBox.show_custom((ui: zui_t) => {
 						if (zui_tab(zui_handle("boxpreferences_13"), tr("New Theme"))) {
 							zui_row([0.5, 0.5]);
-							let themeName = zui_text_input(zui_handle("boxpreferences_14", { text: "new_theme" }), tr("Name"));
+							let themeName: string = zui_text_input(zui_handle("boxpreferences_14", { text: "new_theme" }), tr("Name"));
 							if (zui_button(tr("OK")) || ui.is_return_down) {
-								let template = JSON.stringify(Base.theme);
+								let template: string = JSON.stringify(Base.theme);
 								if (!themeName.endsWith(".json")) themeName += ".json";
-								let path = Path.data() + Path.sep + "themes" + Path.sep + themeName;
+								let path: string = Path.data() + Path.sep + "themes" + Path.sep + themeName;
 								krom_file_save_bytes(path, sys_string_to_buffer(template));
-								BoxPreferences.fetchThemes(); // Refresh file list
+								BoxPreferences.fetch_themes(); // Refresh file list
 								Config.raw.theme = themeName;
-								BoxPreferences.themeHandle.position = BoxPreferences.getThemeIndex();
+								BoxPreferences.theme_handle.position = BoxPreferences.get_theme_index();
 								UIBox.hide();
 								BoxPreferences.htab.position = 1; // Themes
 								BoxPreferences.show();
@@ -176,38 +176,38 @@ class BoxPreferences {
 
 				zui_end_sticky();
 
-				let i = 0;
+				let i: i32 = 0;
 				let theme: any = Base.theme;
-				let hlist = zui_handle("boxpreferences_15");
+				let hlist: zui_handle_t = zui_handle("boxpreferences_15");
 
 				// Viewport color
-				let h = zui_nest(hlist, i++, { color: BoxPreferences.worldColor });
+				let h: zui_handle_t = zui_nest(hlist, i++, { color: BoxPreferences.world_color });
 				zui_row([1 / 8, 7 / 8]);
 				zui_text("", 0, h.color);
 				if (ui.is_hovered && ui.input_released) {
 					UIMenu.draw((ui) => {
 						ui.changed = false;
 						zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true);
-						if (ui.changed) UIMenu.keepOpen = true;
+						if (ui.changed) UIMenu.keep_open = true;
 					}, 11);
 				}
-				let val = h.color;
+				let val: i32 = h.color;
 				if (val < 0) val += 4294967296;
 				h.text = val.toString(16);
 				zui_text_input(h, "VIEWPORT_COL");
 				h.color = parseInt(h.text, 16);
 
-				if (BoxPreferences.worldColor != h.color) {
-					BoxPreferences.worldColor = h.color;
-					let b = new Uint8Array(4);
-					b[0] = color_get_rb(BoxPreferences.worldColor);
-					b[1] = color_get_gb(BoxPreferences.worldColor);
-					b[2] = color_get_bb(BoxPreferences.worldColor);
+				if (BoxPreferences.world_color != h.color) {
+					BoxPreferences.world_color = h.color;
+					let b: Uint8Array = new Uint8Array(4);
+					b[0] = color_get_rb(BoxPreferences.world_color);
+					b[1] = color_get_gb(BoxPreferences.world_color);
+					b[2] = color_get_bb(BoxPreferences.world_color);
 					b[3] = 255;
-					Context.raw.emptyEnvmap = image_from_bytes(b.buffer, 1, 1);
+					Context.raw.empty_envmap = image_from_bytes(b.buffer, 1, 1);
 					Context.raw.ddirty = 2;
-					if (!Context.raw.showEnvmap) {
-						scene_world._.envmap = Context.raw.emptyEnvmap;
+					if (!Context.raw.show_envmap) {
+						scene_world._.envmap = Context.raw.empty_envmap;
 					}
 				}
 
@@ -215,10 +215,10 @@ class BoxPreferences {
 				for (let key of Object.getOwnPropertyNames(theme_t.prototype)) {
 					if (key == "constructor") continue;
 
-					let h = zui_nest(hlist, i++);
+					let h: zui_handle_t = zui_nest(hlist, i++);
 					let val: any = theme[key];
 
-					let isHex = key.endsWith("_COL");
+					let isHex: bool = key.endsWith("_COL");
 					if (isHex && val < 0) val += 4294967296;
 
 					if (isHex) {
@@ -228,9 +228,9 @@ class BoxPreferences {
 							h.color = theme[key];
 							UIMenu.draw((ui) => {
 								ui.changed = false;
-								let color = zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true);
+								let color: i32 = zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true);
 								theme[key] = color;
-								if (ui.changed) UIMenu.keepOpen = true;
+								if (ui.changed) UIMenu.keep_open = true;
 							}, 11);
 						}
 					}
@@ -239,24 +239,24 @@ class BoxPreferences {
 
 					if (typeof val == "boolean") {
 						h.selected = val;
-						let b = zui_check(h, key);
+						let b: bool = zui_check(h, key);
 						theme[key] = b;
 					}
 					else if (key == "LINK_STYLE") {
-						let styles = [tr("Straight"), tr("Curved")];
+						let styles: string[] = [tr("Straight"), tr("Curved")];
 						h.position = val;
-						let i = zui_combo(h, styles, key, true);
+						let i: i32 = zui_combo(h, styles, key, true);
 						theme[key] = i;
 					}
 					else {
 						h.text = isHex ? val.toString(16) : val.toString();
-						let res = zui_text_input(h, key);
+						zui_text_input(h, key);
 						if (isHex) theme[key] = parseInt(h.text, 16);
 						else theme[key] = parseInt(h.text);
 					}
 
 					if (ui.changed) {
-						for (let ui of Base.getUIs()) {
+						for (let ui of Base.get_uis()) {
 							ui.elements_baked = false;
 						}
 					}
@@ -264,22 +264,22 @@ class BoxPreferences {
 			}
 
 			if (zui_tab(BoxPreferences.htab, tr("Usage"), true)) {
-				Context.raw.undoHandle = zui_handle("boxpreferences_16", { value: Config.raw.undo_steps });
-				Config.raw.undo_steps = Math.floor(zui_slider(Context.raw.undoHandle, tr("Undo Steps"), 1, 64, false, 1));
+				Context.raw.undo_handle = zui_handle("boxpreferences_16", { value: Config.raw.undo_steps });
+				Config.raw.undo_steps = Math.floor(zui_slider(Context.raw.undo_handle, tr("Undo Steps"), 1, 64, false, 1));
 				if (Config.raw.undo_steps < 1) {
-					Config.raw.undo_steps = Math.floor(Context.raw.undoHandle.value = 1);
+					Config.raw.undo_steps = Math.floor(Context.raw.undo_handle.value = 1);
 				}
-				if (Context.raw.undoHandle.changed) {
-					let current = _g2_current;
+				if (Context.raw.undo_handle.changed) {
+					let current: image_t = _g2_current;
 					g2_end();
 
 					///if (is_paint || is_sculpt)
-					while (History.undoLayers.length < Config.raw.undo_steps) {
-						let l = SlotLayer.create("_undo" + History.undoLayers.length);
-						History.undoLayers.push(l);
+					while (History.undo_layers.length < Config.raw.undo_steps) {
+						let l: SlotLayerRaw = SlotLayer.create("_undo" + History.undo_layers.length);
+						History.undo_layers.push(l);
 					}
-					while (History.undoLayers.length > Config.raw.undo_steps) {
-						let l = History.undoLayers.pop();
+					while (History.undo_layers.length > Config.raw.undo_steps) {
+						let l: SlotLayerRaw = History.undo_layers.pop();
 						SlotLayer.unload(l);
 					}
 					///end
@@ -292,7 +292,7 @@ class BoxPreferences {
 				Config.raw.dilate_radius = Math.floor(zui_slider(zui_handle("boxpreferences_17", { value: Config.raw.dilate_radius }), tr("Dilate Radius"), 0.0, 16.0, true, 1));
 				if (ui.is_hovered) zui_tooltip(tr("Dilate painted textures to prevent seams"));
 
-				let dilateHandle = zui_handle("boxpreferences_18", { position: Config.raw.dilate });
+				let dilateHandle: zui_handle_t = zui_handle("boxpreferences_18", { position: Config.raw.dilate });
 				zui_combo(dilateHandle, [tr("Instant"), tr("Delayed")], tr("Dilate"), true);
 				if (dilateHandle.changed) {
 					Config.raw.dilate = dilateHandle.position;
@@ -300,20 +300,20 @@ class BoxPreferences {
 				///end
 
 				///if is_lab
-				let workspaceHandle = zui_handle("boxpreferences_19", { position: Config.raw.workspace });
+				let workspaceHandle: zui_handle_t = zui_handle("boxpreferences_19", { position: Config.raw.workspace });
 				zui_combo(workspaceHandle, [tr("3D View"), tr("2D View")], tr("Default Workspace"), true);
 				if (workspaceHandle.changed) {
 					Config.raw.workspace = workspaceHandle.position;
 				}
 				///end
 
-				let cameraControlsHandle = zui_handle("boxpreferences_20", { position: Config.raw.camera_controls });
+				let cameraControlsHandle: zui_handle_t = zui_handle("boxpreferences_20", { position: Config.raw.camera_controls });
 				zui_combo(cameraControlsHandle, [tr("Orbit"), tr("Rotate"), tr("Fly")], tr("Default Camera Controls"), true);
 				if (cameraControlsHandle.changed) {
 					Config.raw.camera_controls = cameraControlsHandle.position;
 				}
 
-				let layerResHandle = zui_handle("boxpreferences_21", { position: Config.raw.layer_res });
+				let layerResHandle: zui_handle_t = zui_handle("boxpreferences_21", { position: Config.raw.layer_res });
 
 				///if is_paint
 				///if (krom_android || krom_ios)
@@ -335,39 +335,39 @@ class BoxPreferences {
 					Config.raw.layer_res = layerResHandle.position;
 				}
 
-				let serverHandle = zui_handle("boxpreferences_22", { text: Config.raw.server });
+				let serverHandle: zui_handle_t = zui_handle("boxpreferences_22", { text: Config.raw.server });
 				Config.raw.server = zui_text_input(serverHandle, tr("Cloud Server"));
 
 				///if (is_paint || is_sculpt)
-				let materialLiveHandle = zui_handle("boxpreferences_23", {selected: Config.raw.material_live });
+				let materialLiveHandle: zui_handle_t = zui_handle("boxpreferences_23", {selected: Config.raw.material_live });
 				Config.raw.material_live = zui_check(materialLiveHandle, tr("Live Material Preview"));
 				if (ui.is_hovered) zui_tooltip(tr("Instantly update material preview on node change"));
 
-				let brushLiveHandle = zui_handle("boxpreferences_24", { selected: Config.raw.brush_live });
+				let brushLiveHandle: zui_handle_t = zui_handle("boxpreferences_24", { selected: Config.raw.brush_live });
 				Config.raw.brush_live = zui_check(brushLiveHandle, tr("Live Brush Preview"));
 				if (ui.is_hovered) zui_tooltip(tr("Draw live brush preview in viewport"));
 				if (brushLiveHandle.changed) Context.raw.ddirty = 2;
 
-				let brush3dHandle = zui_handle("boxpreferences_25", { selected: Config.raw.brush_3d });
+				let brush3dHandle: zui_handle_t = zui_handle("boxpreferences_25", { selected: Config.raw.brush_3d });
 				Config.raw.brush_3d = zui_check(brush3dHandle, tr("3D Cursor"));
-				if (brush3dHandle.changed) MakeMaterial.parsePaintMaterial();
+				if (brush3dHandle.changed) MakeMaterial.parse_paint_material();
 
 				ui.enabled = Config.raw.brush_3d;
-				let brushDepthRejectHandle = zui_handle("boxpreferences_26", { selected: Config.raw.brush_depth_reject });
+				let brushDepthRejectHandle: zui_handle_t = zui_handle("boxpreferences_26", { selected: Config.raw.brush_depth_reject });
 				Config.raw.brush_depth_reject = zui_check(brushDepthRejectHandle, tr("Depth Reject"));
-				if (brushDepthRejectHandle.changed) MakeMaterial.parsePaintMaterial();
+				if (brushDepthRejectHandle.changed) MakeMaterial.parse_paint_material();
 
 				zui_row([0.5, 0.5]);
 
-				let brushAngleRejectHandle = zui_handle("boxpreferences_27", { selected: Config.raw.brush_angle_reject });
+				let brushAngleRejectHandle: zui_handle_t = zui_handle("boxpreferences_27", { selected: Config.raw.brush_angle_reject });
 				Config.raw.brush_angle_reject = zui_check(brushAngleRejectHandle, tr("Angle Reject"));
-				if (brushAngleRejectHandle.changed) MakeMaterial.parsePaintMaterial();
+				if (brushAngleRejectHandle.changed) MakeMaterial.parse_paint_material();
 
 				if (!Config.raw.brush_angle_reject) ui.enabled = false;
-				let angleDotHandle = zui_handle("boxpreferences_28", { value: Context.raw.brushAngleRejectDot });
-				Context.raw.brushAngleRejectDot = zui_slider(angleDotHandle, tr("Angle"), 0.0, 1.0, true);
+				let angleDotHandle: zui_handle_t = zui_handle("boxpreferences_28", { value: Context.raw.brush_angle_reject_dot });
+				Context.raw.brush_angle_reject_dot = zui_slider(angleDotHandle, tr("Angle"), 0.0, 1.0, true);
 				if (angleDotHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+					MakeMaterial.parse_paint_material();
 				}
 				ui.enabled = true;
 				///end
@@ -378,7 +378,7 @@ class BoxPreferences {
 				///end
 			}
 
-			let penName;
+			let penName: string;
 			///if krom_ios
 			penName = tr("Pencil");
 			///else
@@ -399,10 +399,10 @@ class BoxPreferences {
 				zui_row([0.5]);
 				if (zui_button(tr("Help"))) {
 					///if (is_paint || is_sculpt)
-					File.loadUrl("https://github.com/armory3d/armorpaint_docs///pen");
+					File.load_url("https://github.com/armory3d/armorpaint_docs///pen");
 					///end
 					///if is_lab
-					File.loadUrl("https://github.com/armory3d/armorlab_docs///pen");
+					File.load_url("https://github.com/armory3d/armorlab_docs///pen");
 					///end
 				}
 			}
@@ -410,55 +410,55 @@ class BoxPreferences {
 			Context.raw.hssao = zui_handle("boxpreferences_35", { selected: Config.raw.rp_ssao });
 			Context.raw.hssr = zui_handle("boxpreferences_36", { selected: Config.raw.rp_ssr });
 			Context.raw.hbloom = zui_handle("boxpreferences_37", { selected: Config.raw.rp_bloom });
-			Context.raw.hsupersample = zui_handle("boxpreferences_38", { position: Config.getSuperSampleQuality(Config.raw.rp_supersample) });
+			Context.raw.hsupersample = zui_handle("boxpreferences_38", { position: Config.get_super_sample_quality(Config.raw.rp_supersample) });
 			Context.raw.hvxao = zui_handle("boxpreferences_39", { selected: Config.raw.rp_gi });
 			if (zui_tab(BoxPreferences.htab, tr("Viewport"), true)) {
 				///if (krom_direct3d12 || krom_vulkan || krom_metal)
 
-				let hpathtracemode = zui_handle("boxpreferences_40", { position: Context.raw.pathTraceMode });
-				Context.raw.pathTraceMode = zui_combo(hpathtracemode, [tr("Core"), tr("Full")], tr("Path Tracer"), true);
+				let hpathtracemode: zui_handle_t = zui_handle("boxpreferences_40", { position: Context.raw.pathtrace_mode });
+				Context.raw.pathtrace_mode = zui_combo(hpathtracemode, [tr("Core"), tr("Full")], tr("Path Tracer"), true);
 				if (hpathtracemode.changed) {
 					RenderPathRaytrace.ready = false;
 				}
 
 				///end
 
-				let hrendermode = zui_handle("boxpreferences_41", { position: Context.raw.renderMode });
-				Context.raw.renderMode = zui_combo(hrendermode, [tr("Full"), tr("Mobile")], tr("Renderer"), true);
+				let hrendermode: zui_handle_t = zui_handle("boxpreferences_41", { position: Context.raw.render_mode });
+				Context.raw.render_mode = zui_combo(hrendermode, [tr("Full"), tr("Mobile")], tr("Renderer"), true);
 				if (hrendermode.changed) {
-					Context.setRenderPath();
+					Context.set_render_path();
 				}
 
 				zui_combo(Context.raw.hsupersample, ["0.25x", "0.5x", "1.0x", "1.5x", "2.0x", "4.0x"], tr("Super Sample"), true);
-				if (Context.raw.hsupersample.changed) Config.applyConfig();
+				if (Context.raw.hsupersample.changed) Config.apply_config();
 
-				if (Context.raw.renderMode == RenderMode.RenderDeferred) {
+				if (Context.raw.render_mode == render_mode_t.DEFERRED) {
 					///if arm_voxels
 					zui_check(Context.raw.hvxao, tr("Voxel AO"));
 					if (ui.is_hovered) zui_tooltip(tr("Cone-traced AO and shadows"));
 					if (Context.raw.hvxao.changed) {
-						Config.applyConfig();
+						Config.apply_config();
 					}
 
 					ui.enabled = Context.raw.hvxao.selected;
-					let h = zui_handle("boxpreferences_42", { value: Context.raw.vxaoOffset });
-					Context.raw.vxaoOffset = zui_slider(h, tr("Cone Offset"), 1.0, 4.0, true);
+					let h: zui_handle_t = zui_handle("boxpreferences_42", { value: Context.raw.vxao_offset });
+					Context.raw.vxao_offset = zui_slider(h, tr("Cone Offset"), 1.0, 4.0, true);
 					if (h.changed) Context.raw.ddirty = 2;
-					h = zui_handle("boxpreferences_43", { value: Context.raw.vxaoAperture });
-					Context.raw.vxaoAperture = zui_slider(h, tr("Aperture"), 1.0, 4.0, true);
+					h = zui_handle("boxpreferences_43", { value: Context.raw.vxao_aperture });
+					Context.raw.vxao_aperture = zui_slider(h, tr("Aperture"), 1.0, 4.0, true);
 					if (h.changed) Context.raw.ddirty = 2;
 					ui.enabled = true;
 					///end
 
 					zui_check(Context.raw.hssao, tr("SSAO"));
-					if (Context.raw.hssao.changed) Config.applyConfig();
+					if (Context.raw.hssao.changed) Config.apply_config();
 					zui_check(Context.raw.hssr, tr("SSR"));
-					if (Context.raw.hssr.changed) Config.applyConfig();
+					if (Context.raw.hssr.changed) Config.apply_config();
 					zui_check(Context.raw.hbloom, tr("Bloom"));
-					if (Context.raw.hbloom.changed) Config.applyConfig();
+					if (Context.raw.hbloom.changed) Config.apply_config();
 				}
 
-				let h = zui_handle("boxpreferences_44", { value: Config.raw.rp_vignette });
+				let h: zui_handle_t = zui_handle("boxpreferences_44", { value: Config.raw.rp_vignette });
 				Config.raw.rp_vignette = zui_slider(h, tr("Vignette"), 0.0, 1.0, true);
 				if (h.changed) Context.raw.ddirty = 2;
 
@@ -466,14 +466,14 @@ class BoxPreferences {
 				Config.raw.rp_grain = zui_slider(h, tr("Noise Grain"), 0.0, 1.0, true);
 				if (h.changed) Context.raw.ddirty = 2;
 
-				// let h = Zui.handle("boxpreferences_46", { value: Context.raw.autoExposureStrength });
+				// let h: zui_handle_t = Zui.handle("boxpreferences_46", { value: Context.raw.autoExposureStrength });
 				// Context.raw.autoExposureStrength = Zui.slider(h, "Auto Exposure", 0.0, 2.0, true);
 				// if (h.changed) Context.raw.ddirty = 2;
 
-				let cam = scene_camera;
-				let camRaw = cam.data;
-				let near_handle = zui_handle("boxpreferences_47");
-				let far_handle = zui_handle("boxpreferences_48");
+				let cam: camera_object_t = scene_camera;
+				let camRaw: camera_data_t = cam.data;
+				let near_handle: zui_handle_t = zui_handle("boxpreferences_47");
+				let far_handle: zui_handle_t = zui_handle("boxpreferences_48");
 				near_handle.value = Math.floor(camRaw.near_plane * 1000) / 1000;
 				far_handle.value = Math.floor(camRaw.far_plane * 100) / 100;
 				camRaw.near_plane = zui_slider(near_handle, tr("Clip Start"), 0.001, 1.0, true);
@@ -482,43 +482,43 @@ class BoxPreferences {
 					camera_object_build_proj(cam);
 				}
 
-				let dispHandle = zui_handle("boxpreferences_49", { value: Config.raw.displace_strength });
+				let dispHandle: zui_handle_t = zui_handle("boxpreferences_49", { value: Config.raw.displace_strength });
 				Config.raw.displace_strength = zui_slider(dispHandle, tr("Displacement Strength"), 0.0, 10.0, true);
 				if (dispHandle.changed) {
 					Context.raw.ddirty = 2;
-					MakeMaterial.parseMeshMaterial();
+					MakeMaterial.parse_mesh_material();
 				}
 			}
 			if (zui_tab(BoxPreferences.htab, tr("Keymap"), true)) {
 
-				if (BoxPreferences.filesKeymap == null) {
-					BoxPreferences.fetchKeymaps();
+				if (BoxPreferences.files_keymap == null) {
+					BoxPreferences.fetch_keymaps();
 				}
 
 				zui_begin_sticky();
 				zui_row([1 / 4, 1 / 4, 1 / 4, 1 / 4]);
 
-				BoxPreferences.presetHandle = zui_handle("boxpreferences_50", { position: BoxPreferences.getPresetIndex() });
-				zui_combo(BoxPreferences.presetHandle, BoxPreferences.filesKeymap, tr("Preset"));
-				if (BoxPreferences.presetHandle.changed) {
-					Config.raw.keymap = BoxPreferences.filesKeymap[BoxPreferences.presetHandle.position] + ".json";
-					Config.applyConfig();
-					Config.loadKeymap();
+				BoxPreferences.preset_handle = zui_handle("boxpreferences_50", { position: BoxPreferences.get_preset_index() });
+				zui_combo(BoxPreferences.preset_handle, BoxPreferences.files_keymap, tr("Preset"));
+				if (BoxPreferences.preset_handle.changed) {
+					Config.raw.keymap = BoxPreferences.files_keymap[BoxPreferences.preset_handle.position] + ".json";
+					Config.apply_config();
+					Config.load_keymap();
 				}
 
 				if (zui_button(tr("New"))) {
-					UIBox.showCustom((ui: zui_t) => {
+					UIBox.show_custom((ui: zui_t) => {
 						if (zui_tab(zui_handle("boxpreferences_51"), tr("New Keymap"))) {
 							zui_row([0.5, 0.5]);
-							let keymapName = zui_text_input(zui_handle("boxpreferences_52", { text: "new_keymap" }), tr("Name"));
+							let keymapName: string = zui_text_input(zui_handle("boxpreferences_52", { text: "new_keymap" }), tr("Name"));
 							if (zui_button(tr("OK")) || ui.is_return_down) {
-								let template = JSON.stringify(Base.defaultKeymap);
+								let template: string = JSON.stringify(Base.default_keymap);
 								if (!keymapName.endsWith(".json")) keymapName += ".json";
-								let path = Path.data() + Path.sep + "keymap_presets" + Path.sep + keymapName;
+								let path: string = Path.data() + Path.sep + "keymap_presets" + Path.sep + keymapName;
 								krom_file_save_bytes(path, sys_string_to_buffer(template));
-								BoxPreferences.fetchKeymaps(); // Refresh file list
+								BoxPreferences.fetch_keymaps(); // Refresh file list
 								Config.raw.keymap = keymapName;
-								BoxPreferences.presetHandle.position = BoxPreferences.getPresetIndex();
+								BoxPreferences.preset_handle.position = BoxPreferences.get_preset_index();
 								UIBox.hide();
 								BoxPreferences.htab.position = 5; // Keymap
 								BoxPreferences.show();
@@ -535,7 +535,7 @@ class BoxPreferences {
 				if (zui_button(tr("Export"))) {
 					UIFiles.show("json", true, false, (dest: string) => {
 						if (!UIFiles.filename.endsWith(".json")) UIFiles.filename += ".json";
-						let path = Path.data() + Path.sep + "keymap_presets" + Path.sep + Config.raw.keymap;
+						let path: string = Path.data() + Path.sep + "keymap_presets" + Path.sep + Config.raw.keymap;
 						File.copy(path, dest + Path.sep + UIFiles.filename);
 					});
 				}
@@ -544,29 +544,29 @@ class BoxPreferences {
 
 				zui_separator(8, false);
 
-				let i = 0;
+				let i: i32 = 0;
 				ui.changed = false;
 				for (let key in Config.keymap) {
-					let h = zui_nest(zui_handle("boxpreferences_53"), i++);
+					let h: zui_handle_t = zui_nest(zui_handle("boxpreferences_53"), i++);
 					h.text = Config.keymap[key];
-					let text = zui_text_input(h, key, zui_align_t.LEFT);
+					let text: string = zui_text_input(h, key, zui_align_t.LEFT);
 					Config.keymap[key] = text;
 				}
 				if (ui.changed) {
-					Config.applyConfig();
-					Config.saveKeymap();
+					Config.apply_config();
+					Config.save_keymap();
 				}
 			}
 			if (zui_tab(BoxPreferences.htab, tr("Plugins"), true)) {
 				zui_begin_sticky();
 				zui_row([1 / 4, 1 / 4]);
 				if (zui_button(tr("New"))) {
-					UIBox.showCustom((ui: zui_t) => {
+					UIBox.show_custom((ui: zui_t) => {
 						if (zui_tab(zui_handle("boxpreferences_54"), tr("New Plugin"))) {
 							zui_row([0.5, 0.5]);
-							let pluginName = zui_text_input(zui_handle("boxpreferences_55", { text: "new_plugin" }), tr("Name"));
+							let pluginName: string = zui_text_input(zui_handle("boxpreferences_55", { text: "new_plugin" }), tr("Name"));
 							if (zui_button(tr("OK")) || ui.is_return_down) {
-								let template =
+								let template: string =
 `let plugin = Plugin.create();
 let h1 = new Handle();
 plugin.drawUI = (ui) { =>
@@ -578,9 +578,9 @@ plugin.drawUI = (ui) { =>
 }
 `;
 								if (!pluginName.endsWith(".js")) pluginName += ".js";
-								let path = Path.data() + Path.sep + "plugins" + Path.sep + pluginName;
+								let path: string = Path.data() + Path.sep + "plugins" + Path.sep + pluginName;
 								krom_file_save_bytes(path, sys_string_to_buffer(template));
-								BoxPreferences.filesPlugin = null; // Refresh file list
+								BoxPreferences.files_plugin = null; // Refresh file list
 								UIBox.hide();
 								BoxPreferences.htab.position = 6; // Plugins
 								BoxPreferences.show();
@@ -595,47 +595,47 @@ plugin.drawUI = (ui) { =>
 				}
 				zui_end_sticky();
 
-				if (BoxPreferences.filesPlugin == null) {
-					BoxPreferences.fetchPlugins();
+				if (BoxPreferences.files_plugin == null) {
+					BoxPreferences.fetch_plugins();
 				}
 
 				if (Config.raw.plugins == null) Config.raw.plugins = [];
-				let h = zui_handle("boxpreferences_56", { selected: false });
-				for (let f of BoxPreferences.filesPlugin) {
-					let isJs = f.endsWith(".js");
+				let h: zui_handle_t = zui_handle("boxpreferences_56", { selected: false });
+				for (let f of BoxPreferences.files_plugin) {
+					let isJs: bool = f.endsWith(".js");
 					if (!isJs) continue;
-					let enabled = Config.raw.plugins.indexOf(f) >= 0;
+					let enabled: bool = Config.raw.plugins.indexOf(f) >= 0;
 					h.selected = enabled;
-					let tag = isJs ? f.split(".")[0] : f;
+					let tag: string = isJs ? f.split(".")[0] : f;
 					zui_check(h, tag);
 					if (h.changed && h.selected != enabled) {
-						h.selected ? Config.enablePlugin(f) : Config.disablePlugin(f);
-						Base.redrawUI();
+						h.selected ? Config.enable_plugin(f) : Config.disable_plugin(f);
+						Base.redraw_ui();
 					}
 					if (ui.is_hovered && ui.input_released_r) {
 						UIMenu.draw((ui: zui_t) => {
-							let path = Path.data() + Path.sep + "plugins" + Path.sep + f;
-							if (UIMenu.menuButton(ui, tr("Edit in Text Editor"))) {
+							let path: string = Path.data() + Path.sep + "plugins" + Path.sep + f;
+							if (UIMenu.menu_button(ui, tr("Edit in Text Editor"))) {
 								File.start(path);
 							}
-							if (UIMenu.menuButton(ui, tr("Edit in Script Tab"))) {
+							if (UIMenu.menu_button(ui, tr("Edit in Script Tab"))) {
 								let blob: ArrayBuffer = data_get_blob("plugins/" + f);
 								TabScript.hscript.text = sys_buffer_to_string(blob);
 								data_delete_blob("plugins/" + f);
 								Console.info(tr("Script opened"));
 							}
-							if (UIMenu.menuButton(ui, tr("Export"))) {
+							if (UIMenu.menu_button(ui, tr("Export"))) {
 								UIFiles.show("js", true, false, (dest: string) => {
 									if (!UIFiles.filename.endsWith(".js")) UIFiles.filename += ".js";
 									File.copy(path, dest + Path.sep + UIFiles.filename);
 								});
 							}
-							if (UIMenu.menuButton(ui, tr("Delete"))) {
+							if (UIMenu.menu_button(ui, tr("Delete"))) {
 								if (Config.raw.plugins.indexOf(f) >= 0) {
 									array_remove(Config.raw.plugins, f);
 									Plugin.stop(f);
 								}
-								array_remove(BoxPreferences.filesPlugin, f);
+								array_remove(BoxPreferences.files_plugin, f);
 								File.delete(path);
 							}
 						}, 4);
@@ -646,47 +646,47 @@ plugin.drawUI = (ui) { =>
 		}, 620, Config.raw.touch_ui ? 480 : 420, () => { Config.save(); });
 	}
 
-	static fetchThemes = () => {
-		BoxPreferences.themes = File.readDirectory(Path.data() + Path.sep + "themes");
-		for (let i = 0; i < BoxPreferences.themes.length; ++i) BoxPreferences.themes[i] = BoxPreferences.themes[i].substr(0, BoxPreferences.themes[i].length - 5); // Strip .json
+	static fetch_themes = () => {
+		BoxPreferences.themes = File.read_directory(Path.data() + Path.sep + "themes");
+		for (let i: i32 = 0; i < BoxPreferences.themes.length; ++i) BoxPreferences.themes[i] = BoxPreferences.themes[i].substr(0, BoxPreferences.themes[i].length - 5); // Strip .json
 		BoxPreferences.themes.unshift("default");
 	}
 
-	static fetchKeymaps = () => {
-		BoxPreferences.filesKeymap = File.readDirectory(Path.data() + Path.sep + "keymap_presets");
-		for (let i = 0; i < BoxPreferences.filesKeymap.length; ++i) {
-			BoxPreferences.filesKeymap[i] = BoxPreferences.filesKeymap[i].substr(0, BoxPreferences.filesKeymap[i].length - 5); // Strip .json
+	static fetch_keymaps = () => {
+		BoxPreferences.files_keymap = File.read_directory(Path.data() + Path.sep + "keymap_presets");
+		for (let i: i32 = 0; i < BoxPreferences.files_keymap.length; ++i) {
+			BoxPreferences.files_keymap[i] = BoxPreferences.files_keymap[i].substr(0, BoxPreferences.files_keymap[i].length - 5); // Strip .json
 		}
-		BoxPreferences.filesKeymap.unshift("default");
+		BoxPreferences.files_keymap.unshift("default");
 	}
 
-	static fetchPlugins = () => {
-		BoxPreferences.filesPlugin = File.readDirectory(Path.data() + Path.sep + "plugins");
+	static fetch_plugins = () => {
+		BoxPreferences.files_plugin = File.read_directory(Path.data() + Path.sep + "plugins");
 	}
 
-	static getThemeIndex = (): i32 => {
+	static get_theme_index = (): i32 => {
 		return BoxPreferences.themes.indexOf(Config.raw.theme.substr(0, Config.raw.theme.length - 5)); // Strip .json
 	}
 
-	static getPresetIndex = (): i32 => {
-		return BoxPreferences.filesKeymap.indexOf(Config.raw.keymap.substr(0, Config.raw.keymap.length - 5)); // Strip .json
+	static get_preset_index = (): i32 => {
+		return BoxPreferences.files_keymap.indexOf(Config.raw.keymap.substr(0, Config.raw.keymap.length - 5)); // Strip .json
 	}
 
-	static setScale = () => {
-		let scale = Config.raw.window_scale;
+	static set_scale = () => {
+		let scale: f32 = Config.raw.window_scale;
 		zui_set_scale(UIBase.ui, scale);
-		UIHeader.headerh = Math.floor(UIHeader.defaultHeaderH * scale);
-		Config.raw.layout[LayoutSize.LayoutStatusH] = Math.floor(UIStatus.defaultStatusH * scale);
-		UIMenubar.menubarw = Math.floor(UIMenubar.defaultMenubarW * scale);
-		UIBase.setIconScale();
+		UIHeader.headerh = Math.floor(UIHeader.default_header_h * scale);
+		Config.raw.layout[layout_size_t.STATUS_H] = Math.floor(UIStatus.default_status_h * scale);
+		UIMenubar.menubarw = Math.floor(UIMenubar.default_menubar_w * scale);
+		UIBase.set_icon_scale();
 		zui_set_scale(UINodes.ui, scale);
 		zui_set_scale(UIView2D.ui, scale);
-		zui_set_scale(Base.uiBox, scale);
-		zui_set_scale(Base.uiMenu, scale);
+		zui_set_scale(Base.ui_box, scale);
+		zui_set_scale(Base.ui_menu, scale);
 		Base.resize();
 		///if (is_paint || is_sculpt)
-		Config.raw.layout[LayoutSize.LayoutSidebarW] = Math.floor(UIBase.defaultSidebarW * scale);
-		UIToolbar.toolbarw = Math.floor(UIToolbar.defaultToolbarW * scale);
+		Config.raw.layout[layout_size_t.SIDEBAR_W] = Math.floor(UIBase.default_sidebar_w * scale);
+		UIToolbar.toolbar_w = Math.floor(UIToolbar.default_toolbar_w * scale);
 		///end
 	}
 }

+ 65 - 65
base/Sources/BoxProjects.ts

@@ -1,56 +1,56 @@
 
 class BoxProjects {
 
-	static htab = zui_handle_create();
-	static hsearch = zui_handle_create();
-	static iconMap: Map<string, image_t> = null;
+	static htab: zui_handle_t = zui_handle_create();
+	static hsearch: zui_handle_t = zui_handle_create();
+	static icon_map: Map<string, image_t> = null;
 
 	static show = () => {
-		if (BoxProjects.iconMap != null) {
-			for (let handle of BoxProjects.iconMap.keys()) {
+		if (BoxProjects.icon_map != null) {
+			for (let handle of BoxProjects.icon_map.keys()) {
 				data_delete_image(handle);
 			}
-			BoxProjects.iconMap = null;
+			BoxProjects.icon_map = null;
 		}
 
-		let draggable;
+		let draggable: bool;
 		///if (krom_android || krom_ios)
 		draggable = false;
 		///else
 		draggable = true;
 		///end
 
-		UIBox.showCustom((ui: zui_t) => {
+		UIBox.show_custom((ui: zui_t) => {
 			///if (krom_android || krom_ios)
-			BoxProjects.alignToFullScreen();
+			BoxProjects.align_to_fullscreen();
 			///end
 
 			///if (krom_android || krom_ios)
-			BoxProjects.projectsTab(ui);
-			BoxProjects.getStartedTab(ui);
+			BoxProjects.projects_tab(ui);
+			BoxProjects.get_started_tab(ui);
 			///else
-			BoxProjects.recentProjectsTab(ui);
+			BoxProjects.recent_projects_tab(ui);
 			///end
 
 		}, 600, 400, null, draggable);
 	}
 
-	static projectsTab = (ui: zui_t) => {
+	static projects_tab = (ui: zui_t) => {
 		if (zui_tab(BoxProjects.htab, tr("Projects"), true)) {
 			zui_begin_sticky();
 
-			BoxProjects.drawBadge(ui);
+			BoxProjects.draw_badge(ui);
 
 			if (zui_button(tr("New"))) {
-				Project.projectNew();
-				Viewport.scaleToBounds();
+				Project.project_new();
+				Viewport.scale_to_bounds();
 				UIBox.hide();
 				// Pick unique name
-				let i = 0;
-				let j = 0;
-				let title = tr("untitled") + i;
+				let i: i32 = 0;
+				let j: i32 = 0;
+				let title: string = tr("untitled") + i;
 				while (j < Config.raw.recent_projects.length) {
-					let base = Config.raw.recent_projects[j];
+					let base: string = Config.raw.recent_projects[j];
 					base = base.substring(base.lastIndexOf(Path.sep) + 1, base.lastIndexOf("."));
 					j++;
 					if (title == base) {
@@ -64,83 +64,83 @@ class BoxProjects {
 			zui_end_sticky();
 			zui_separator(3, false);
 
-			let slotw = Math.floor(150 * zui_SCALE(ui));
-			let num = Math.floor(sys_width() / slotw);
-			let recent_projects = Config.raw.recent_projects;
-			let show_asset_names = true;
+			let slotw: i32 = Math.floor(150 * zui_SCALE(ui));
+			let num: i32 = Math.floor(sys_width() / slotw);
+			let recent_projects: string[] = Config.raw.recent_projects;
+			let show_asset_names: bool = true;
 
-			for (let row = 0; row < Math.ceil(recent_projects.length / num); ++row) {
+			for (let row: i32 = 0; row < Math.ceil(recent_projects.length / num); ++row) {
 				let mult = show_asset_names ? 2 : 1;
-				let ar = [];
-				for (let i = 0; i < num * mult; ++i) ar.push(1 / num);
+				let ar: f32[] = [];
+				for (let i: i32 = 0; i < num * mult; ++i) ar.push(1 / num);
 				zui_row(ar);
 
 				ui._x += 2;
-				let off = show_asset_names ? zui_ELEMENT_OFFSET(ui) * 16.0 : 6;
+				let off: f32 = show_asset_names ? zui_ELEMENT_OFFSET(ui) * 16.0 : 6;
 				if (row > 0) ui._y += off;
 
-				for (let j = 0; j < num; ++j) {
-					let imgw = Math.floor(128 * zui_SCALE(ui));
-					let i = j + row * num;
+				for (let j: i32 = 0; j < num; ++j) {
+					let imgw: i32 = Math.floor(128 * zui_SCALE(ui));
+					let i: i32 = j + row * num;
 					if (i >= recent_projects.length) {
 						zui_end_element(imgw);
 						if (show_asset_names) zui_end_element(0);
 						continue;
 					}
 
-					let path = recent_projects[i];
+					let path: string = recent_projects[i];
 
 					///if krom_ios
-					let documentDirectory = krom_save_dialog("", "");
+					let documentDirectory: string = krom_save_dialog("", "");
 					documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled'
 					path = documentDirectory + path;
 					///end
 
-					let iconPath = path.substr(0, path.length - 4) + "_icon.png";
-					if (BoxProjects.iconMap == null) BoxProjects.iconMap = new Map();
-					let icon = BoxProjects.iconMap.get(iconPath);
+					let iconPath: string = path.substr(0, path.length - 4) + "_icon.png";
+					if (BoxProjects.icon_map == null) BoxProjects.icon_map = new Map();
+					let icon: image_t = BoxProjects.icon_map.get(iconPath);
 					if (icon == null) {
 						let image: image_t = data_get_image(iconPath);
 						icon = image;
-						BoxProjects.iconMap.set(iconPath, icon);
+						BoxProjects.icon_map.set(iconPath, icon);
 					}
 
-					let uix = ui._x;
+					let uix: i32 = ui._x;
 					if (icon != null) {
 						zui_fill(0, 0, 128, 128, ui.t.SEPARATOR_COL);
 
-						let state = zui_image(icon, 0xffffffff, 128  * zui_SCALE(ui));
+						let state: i32 = zui_image(icon, 0xffffffff, 128  * zui_SCALE(ui));
 						if (state == zui_state_t.RELEASED) {
-							let _uix = ui._x;
+							let _uix: i32 = ui._x;
 							ui._x = uix;
 							zui_fill(0, 0, 128, 128, 0x66000000);
 							ui._x = _uix;
 							let doImport = () => {
 								app_notify_on_init(() => {
 									UIBox.hide();
-									ImportArm.runProject(path);
+									ImportArm.run_project(path);
 								});
 							}
 
 							///if (krom_android || krom_ios)
-							Base.notifyOnNextFrame(() => {
+							Base.notify_on_next_frame(() => {
 								Console.toast(tr("Opening project"));
-								Base.notifyOnNextFrame(doImport);
+								Base.notify_on_next_frame(doImport);
 							});
 							///else
 							doImport();
 							///end
 						}
 
-						let name = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
+						let name: string = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
 						if (ui.is_hovered && ui.input_released_r) {
 							UIMenu.draw((ui: zui_t) => {
 								// if (UIMenu.menuButton(ui, tr("Duplicate"))) {}
-								if (UIMenu.menuButton(ui, tr("Delete"))) {
+								if (UIMenu.menu_button(ui, tr("Delete"))) {
 									app_notify_on_init(() => {
 										File.delete(path);
 										File.delete(iconPath);
-										let dataPath = path.substr(0, path.length - 4);
+										let dataPath: string = path.substr(0, path.length - 4);
 										File.delete(dataPath);
 										recent_projects.splice(i, 1);
 									});
@@ -171,17 +171,17 @@ class BoxProjects {
 		}
 	}
 
-	static recentProjectsTab = (ui: zui_t) => {
+	static recent_projects_tab = (ui: zui_t) => {
 		if (zui_tab(BoxProjects.htab, tr("Recent"), true)) {
 
-			BoxProjects.drawBadge(ui);
+			BoxProjects.draw_badge(ui);
 
 			ui.enabled = Config.raw.recent_projects.length > 0;
 			BoxProjects.hsearch.text = zui_text_input(BoxProjects.hsearch, tr("Search"), zui_align_t.LEFT, true, true);
 			ui.enabled = true;
 
 			for (let path of Config.raw.recent_projects) {
-				let file = path;
+				let file: string = path;
 				///if krom_windows
 				file = string_replace_all(path, "/", "\\");
 				///else
@@ -192,10 +192,10 @@ class BoxProjects {
 				if (file.toLowerCase().indexOf(BoxProjects.hsearch.text.toLowerCase()) < 0) continue; // Search filter
 
 				if (zui_button(file, zui_align_t.LEFT) && File.exists(path)) {
-					let current = _g2_current;
+					let current: image_t = _g2_current;
 					if (current != null) g2_end();
 
-					ImportArm.runProject(path);
+					ImportArm.run_project(path);
 
 					if (current != null) g2_begin(current);
 					UIBox.hide();
@@ -211,38 +211,38 @@ class BoxProjects {
 			ui.enabled = true;
 
 			zui_end_element();
-			if (zui_button(tr("New Project..."), zui_align_t.LEFT)) Project.projectNewBox();
-			if (zui_button(tr("Open..."), zui_align_t.LEFT)) Project.projectOpen();
+			if (zui_button(tr("New Project..."), zui_align_t.LEFT)) Project.project_new_box();
+			if (zui_button(tr("Open..."), zui_align_t.LEFT)) Project.project_open();
 		}
 	}
 
-	static drawBadge = (ui: zui_t) => {
+	static draw_badge = (ui: zui_t) => {
 		let img: image_t = data_get_image("badge.k");
 		zui_image(img);
 		zui_end_element();
 	}
 
-	static getStartedTab = (ui: zui_t) => {
+	static get_started_tab = (ui: zui_t) => {
 		if (zui_tab(BoxProjects.htab, tr("Get Started"), true)) {
 			if (zui_button(tr("Manual"))) {
-				File.loadUrl(manifest_url + "/manual");
+				File.load_url(manifest_url + "/manual");
 			}
 			if (zui_button(tr("How To"))) {
-				File.loadUrl(manifest_url + "/howto");
+				File.load_url(manifest_url + "/howto");
 			}
 			if (zui_button(tr("What's New"))) {
-				File.loadUrl(manifest_url + "/notes");
+				File.load_url(manifest_url + "/notes");
 			}
 		}
 	}
 
-	static alignToFullScreen = () => {
-		UIBox.modalW = Math.floor(sys_width() / zui_SCALE(Base.uiBox));
-		UIBox.modalH = Math.floor(sys_height() / zui_SCALE(Base.uiBox));
-		let appw = sys_width();
-		let apph = sys_height();
-		let mw = appw;
-		let mh = apph;
+	static align_to_fullscreen = () => {
+		UIBox.modalw = Math.floor(sys_width() / zui_SCALE(Base.ui_box));
+		UIBox.modalh = Math.floor(sys_height() / zui_SCALE(Base.ui_box));
+		let appw: i32 = sys_width();
+		let apph: i32 = sys_height();
+		let mw: i32 = appw;
+		let mh: i32 = apph;
 		UIBox.hwnd.drag_x = Math.floor(-appw / 2 + mw / 2);
 		UIBox.hwnd.drag_y = Math.floor(-apph / 2 + mh / 2);
 	}

+ 59 - 59
base/Sources/Camera.ts

@@ -3,24 +3,24 @@ class Camera {
 
 	static origins: vec4_t[];
 	static views: mat4_t[];
-	static redraws = 0;
-	static dir = vec4_create();
-	static ease = 1.0;
-	static controlsDown = false;
+	static redraws: i32 = 0;
+	static dir: vec4_t = vec4_create();
+	static ease: f32 = 1.0;
+	static controls_down: bool = false;
 
 	constructor() {
 		Camera.reset();
 	}
 
 	static update = () => {
-		let camera = scene_camera;
+		let camera: camera_object_t = scene_camera;
 
 		if (mouse_view_x() < 0 ||
 			mouse_view_x() > app_w() ||
 			mouse_view_y() < 0 ||
 			mouse_view_y() > app_h()) {
 
-			if (Config.raw.wrap_mouse && Camera.controlsDown) {
+			if (Config.raw.wrap_mouse && Camera.controls_down) {
 				if (mouse_view_x() < 0) {
 					mouse_x = mouse_last_x = app_x() + app_w();
 					krom_set_mouse_position(Math.floor(mouse_x), Math.floor(mouse_y));
@@ -43,9 +43,9 @@ class Camera {
 			}
 		}
 
-		let modifKey = keyboard_down("alt") || keyboard_down("shift") || keyboard_down("control");
-		let modif = modifKey || Config.keymap.action_rotate == "middle";
-		let defaultKeymap = Config.raw.keymap == "default.json";
+		let modifKey: bool = keyboard_down("alt") || keyboard_down("shift") || keyboard_down("control");
+		let modif: bool = modifKey || Config.keymap.action_rotate == "middle";
+		let defaultKeymap: bool = Config.raw.keymap == "default.json";
 
 		if (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutStarted) ||
 			Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutStarted) ||
@@ -55,7 +55,7 @@ class Camera {
 			(mouse_started("right") && !modif) ||
 			(mouse_started("middle") && !modif) ||
 			(mouse_wheel_delta != 0 && !modifKey)) {
-			Camera.controlsDown = true;
+			Camera.controls_down = true;
 		}
 		else if (!Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) &&
 			!Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown) &&
@@ -65,17 +65,17 @@ class Camera {
 			!(mouse_down("right") && !modif) &&
 			!(mouse_down("middle") && !modif) &&
 			(mouse_wheel_delta == 0 && !modifKey)) {
-			Camera.controlsDown = false;
+			Camera.controls_down = false;
 		}
 
-		if (_input_occupied || !Base.uiEnabled || Base.isDragging || Base.isScrolling() || Base.isComboSelected() || !Camera.controlsDown) {
+		if (_input_occupied || !Base.ui_enabled || Base.is_dragging || Base.is_scrolling() || Base.is_combo_selected() || !Camera.controls_down) {
 			return;
 		}
 
-		let controls = Context.raw.cameraControls;
-		if (controls == CameraControls.ControlsOrbit && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) {
+		let controls: camera_controls_t = Context.raw.camera_controls;
+		if (controls == camera_controls_t.ORBIT && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) {
 			Camera.redraws = 2;
-			let dist = Camera.distance();
+			let dist: f32 = Camera.distance();
 			transform_move(camera.base.transform, camera_object_look_world(camera), dist);
 			transform_rotate(camera.base.transform, vec4_z_axis(), -mouse_movement_x / 100 * Config.raw.camera_rotation_speed);
 			transform_rotate(camera.base.transform, camera_object_right_world(camera), -mouse_movement_y / 100 * Config.raw.camera_rotation_speed);
@@ -84,12 +84,12 @@ class Camera {
 			}
 			transform_move(camera.base.transform, camera_object_look_world(camera), -dist);
 		}
-		else if (controls == CameraControls.ControlsRotate && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) {
+		else if (controls == camera_controls_t.ROTATE && (Operator.shortcut(Config.keymap.action_rotate, ShortcutType.ShortcutDown) || (mouse_down("right") && !modif && defaultKeymap))) {
 			Camera.redraws = 2;
-			let t = Context.mainObject().base.transform;
-			let up = vec4_normalize(transform_up(t));
+			let t: transform_t = Context.main_object().base.transform;
+			let up: vec4_t = vec4_normalize(transform_up(t));
 			transform_rotate(t, up, mouse_movement_x / 100 * Config.raw.camera_rotation_speed);
-			let right = vec4_normalize(camera_object_right_world(camera));
+			let right: vec4_t = vec4_normalize(camera_object_right_world(camera));
 			transform_rotate(t, right, mouse_movement_y / 100 * Config.raw.camera_rotation_speed);
 			transform_build_matrix(t);
 			if (transform_up(t).z < 0) {
@@ -97,31 +97,31 @@ class Camera {
 			}
 		}
 
-		if (controls == CameraControls.ControlsRotate || controls == CameraControls.ControlsOrbit) {
-			Camera.panAction(modif, defaultKeymap);
+		if (controls == camera_controls_t.ROTATE || controls == camera_controls_t.ORBIT) {
+			Camera.pan_action(modif, defaultKeymap);
 
 			if (Operator.shortcut(Config.keymap.action_zoom, ShortcutType.ShortcutDown)) {
 				Camera.redraws = 2;
-				let f = Camera.getZoomDelta() / 150;
-				f *= Camera.getCameraZoomSpeed();
+				let f: f32 = Camera.get_zoom_delta() / 150;
+				f *= Camera.get_camera_zoom_speed();
 				transform_move(camera.base.transform, camera_object_look(camera), f);
 			}
 
 			if (mouse_wheel_delta != 0 && !modifKey) {
 				Camera.redraws = 2;
-				let f = mouse_wheel_delta * (-0.1);
-				f *= Camera.getCameraZoomSpeed();
+				let f: f32 = mouse_wheel_delta * (-0.1);
+				f *= Camera.get_camera_zoom_speed();
 				transform_move(camera.base.transform, camera_object_look(camera), f);
 			}
 		}
-		else if (controls == CameraControls.ControlsFly && mouse_down("right")) {
-			let moveForward = keyboard_down("w") || keyboard_down("up") || mouse_wheel_delta < 0;
-			let moveBackward = keyboard_down("s") || keyboard_down("down") || mouse_wheel_delta > 0;
-			let strafeLeft = keyboard_down("a") || keyboard_down("left");
-			let strafeRight = keyboard_down("d") || keyboard_down("right");
-			let strafeUp = keyboard_down("e");
-			let strafeDown = keyboard_down("q");
-			let fast = keyboard_down("shift") ? 2.0 : (keyboard_down("alt") ? 0.5 : 1.0);
+		else if (controls == camera_controls_t.FLY && mouse_down("right")) {
+			let moveForward: bool = keyboard_down("w") || keyboard_down("up") || mouse_wheel_delta < 0;
+			let moveBackward: bool = keyboard_down("s") || keyboard_down("down") || mouse_wheel_delta > 0;
+			let strafeLeft: bool = keyboard_down("a") || keyboard_down("left");
+			let strafeRight: bool = keyboard_down("d") || keyboard_down("right");
+			let strafeUp: bool = keyboard_down("e");
+			let strafeDown: bool = keyboard_down("q");
+			let fast: f32 = keyboard_down("shift") ? 2.0 : (keyboard_down("alt") ? 0.5 : 1.0);
 			if (mouse_wheel_delta != 0) {
 				fast *= Math.abs(mouse_wheel_delta) * 4.0;
 			}
@@ -143,11 +143,11 @@ class Camera {
 			}
 
 
-			let d = time_delta() * fast * Camera.ease * 2.0 * ((moveForward || moveBackward) ? Config.raw.camera_zoom_speed : Config.raw.camera_pan_speed);
+			let d: f32 = time_delta() * fast * Camera.ease * 2.0 * ((moveForward || moveBackward) ? Config.raw.camera_zoom_speed : Config.raw.camera_pan_speed);
 			if (d > 0.0) {
 				transform_move(camera.base.transform, Camera.dir, d);
-				if (Context.raw.cameraType == CameraType.CameraOrthographic) {
-					Viewport.updateCameraType(Context.raw.cameraType);
+				if (Context.raw.camera_type == camera_type_t.ORTHOGRAPHIC) {
+					Viewport.update_camera_type(Context.raw.camera_type);
 				}
 			}
 
@@ -158,46 +158,46 @@ class Camera {
 
 		if (Operator.shortcut(Config.keymap.rotate_light, ShortcutType.ShortcutDown)) {
 			Camera.redraws = 2;
-			let light = scene_lights[0];
-			Context.raw.lightAngle = (Context.raw.lightAngle + ((mouse_movement_x / 100) % (2 * Math.PI) + 2 * Math.PI)) % (2 * Math.PI);
-			let m = mat4_rot_z(mouse_movement_x / 100);
+			let light: light_object_t = scene_lights[0];
+			Context.raw.light_angle = (Context.raw.light_angle + ((mouse_movement_x / 100) % (2 * Math.PI) + 2 * Math.PI)) % (2 * Math.PI);
+			let m: mat4_t = mat4_rot_z(mouse_movement_x / 100);
 			mat4_mult_mat(light.base.transform.local, m);
 			transform_decompose(light.base.transform);
 		}
 
 		if (Operator.shortcut(Config.keymap.rotate_envmap, ShortcutType.ShortcutDown)) {
 			Camera.redraws = 2;
-			Context.raw.envmapAngle -= mouse_movement_x / 100;
+			Context.raw.envmap_angle -= mouse_movement_x / 100;
 		}
 
 		if (Camera.redraws > 0) {
 			Camera.redraws--;
 			Context.raw.ddirty = 2;
 
-			if (Context.raw.cameraType == CameraType.CameraOrthographic) {
-				Viewport.updateCameraType(Context.raw.cameraType);
+			if (Context.raw.camera_type == camera_type_t.ORTHOGRAPHIC) {
+				Viewport.update_camera_type(Context.raw.camera_type);
 			}
 		}
 	}
 
 	static distance = (): f32 => {
-		let camera = scene_camera;
+		let camera: camera_object_t = scene_camera;
 		return vec4_dist(Camera.origins[Camera.index()], camera.base.transform.loc);
 	}
 
 	static index = (): i32 => {
-		return Context.raw.viewIndexLast > 0 ? 1 : 0;
+		return Context.raw.view_index_last > 0 ? 1 : 0;
 	}
 
-	static getCameraZoomSpeed = (): f32 => {
-		let sign = Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ||
-				   Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ||
-				   Config.raw.zoom_direction == ZoomDirection.ZoomVerticalAndHorizontalInverted ? -1 : 1;
+	static get_camera_zoom_speed = (): f32 => {
+		let sign: i32 = Config.raw.zoom_direction == zoom_direction_t.VERTICAL_INVERTED ||
+						Config.raw.zoom_direction == zoom_direction_t.HORIZONTAL_INVERTED ||
+				   		Config.raw.zoom_direction == zoom_direction_t.VERTICAL_HORIZONTAL_INVERTED ? -1 : 1;
 		return Config.raw.camera_zoom_speed * sign;
 	}
 
-	static reset = (viewIndex = -1) => {
-		let camera = scene_camera;
+	static reset = (viewIndex: i32 = -1) => {
+		let camera: camera_object_t = scene_camera;
 		if (viewIndex == -1) {
 			Camera.origins = [vec4_create(0, 0, 0), vec4_create(0, 0, 0)];
 			Camera.views = [mat4_clone(camera.base.transform.local), mat4_clone(camera.base.transform.local)];
@@ -208,12 +208,12 @@ class Camera {
 		}
 	}
 
-	static panAction = (modif: bool, defaultKeymap: bool) => {
-		let camera = scene_camera;
+	static pan_action = (modif: bool, defaultKeymap: bool) => {
+		let camera: camera_object_t = scene_camera;
 		if (Operator.shortcut(Config.keymap.action_pan, ShortcutType.ShortcutDown) || (mouse_down("middle") && !modif && defaultKeymap)) {
 			Camera.redraws = 2;
-			let look = vec4_mult(vec4_normalize(transform_look(camera.base.transform)), mouse_movement_y / 150 * Config.raw.camera_pan_speed);
-			let right = vec4_mult(vec4_normalize(transform_right(camera.base.transform)), -mouse_movement_x / 150 * Config.raw.camera_pan_speed);
+			let look: vec4_t = vec4_mult(vec4_normalize(transform_look(camera.base.transform)), mouse_movement_y / 150 * Config.raw.camera_pan_speed);
+			let right: vec4_t = vec4_mult(vec4_normalize(transform_right(camera.base.transform)), -mouse_movement_x / 150 * Config.raw.camera_pan_speed);
 			vec4_add(camera.base.transform.loc, look);
 			vec4_add(camera.base.transform.loc, right);
 			vec4_add(Camera.origins[Camera.index()], look);
@@ -222,11 +222,11 @@ class Camera {
 		}
 	}
 
-	static getZoomDelta = (): f32 => {
-		return Config.raw.zoom_direction == ZoomDirection.ZoomVertical ? -mouse_movement_y :
-			   Config.raw.zoom_direction == ZoomDirection.ZoomVerticalInverted ? -mouse_movement_y :
-			   Config.raw.zoom_direction == ZoomDirection.ZoomHorizontal ? mouse_movement_x :
-			   Config.raw.zoom_direction == ZoomDirection.ZoomHorizontalInverted ? mouse_movement_x :
+	static get_zoom_delta = (): f32 => {
+		return Config.raw.zoom_direction == zoom_direction_t.VERTICAL ? -mouse_movement_y :
+			   Config.raw.zoom_direction == zoom_direction_t.VERTICAL_INVERTED ? -mouse_movement_y :
+			   Config.raw.zoom_direction == zoom_direction_t.HORIZONTAL ? mouse_movement_x :
+			   Config.raw.zoom_direction == zoom_direction_t.HORIZONTAL_INVERTED ? mouse_movement_x :
 			   -(mouse_movement_y - mouse_movement_x);
 	}
 }

+ 86 - 97
base/Sources/Config.ts

@@ -1,17 +1,17 @@
 
 class Config {
 
-	static raw: TConfig = null;
+	static raw: config_t = null;
 	static keymap: any;
-	static configLoaded = false;
-	static buttonAlign = zui_align_t.LEFT;
-	static defaultButtonSpacing = "       ";
-	static buttonSpacing = Config.defaultButtonSpacing;
+	static config_loaded: bool = false;
+	static button_align: zui_align_t = zui_align_t.LEFT;
+	static default_button_spacing: string = "       ";
+	static button_spacing: string = Config.default_button_spacing;
 
 	static load = (done: ()=>void) => {
 		try {
-			let blob: ArrayBuffer = data_get_blob((Path.isProtected() ? krom_save_path() : "") + "config.json");
-			Config.configLoaded = true;
+			let blob: ArrayBuffer = data_get_blob((Path.is_protected() ? krom_save_path() : "") + "config.json");
+			Config.config_loaded = true;
 			Config.raw = JSON.parse(sys_buffer_to_string(blob));
 			done();
 		}
@@ -19,11 +19,12 @@ class Config {
 			///if krom_linux
 			try { // Protected directory
 				let blob: ArrayBuffer = data_get_blob(krom_save_path() + "config.json");
-				Config.configLoaded = true;
+				Config.config_loaded = true;
 				Config.raw = JSON.parse(sys_buffer_to_string(blob));
 				done();
 			}
 			catch (e: any) {
+				krom_log(e);
 				done();
 			}
 			///else
@@ -35,8 +36,8 @@ class Config {
 	static save = () => {
 		// Use system application data folder
 		// when running from protected path like "Program Files"
-		let path = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "config.json";
-		let buffer = sys_string_to_buffer(JSON.stringify(Config.raw));
+		let path: string = (Path.is_protected() ? krom_save_path() : Path.data() + Path.sep) + "config.json";
+		let buffer: buffer_t = sys_string_to_buffer(JSON.stringify(Config.raw));
 		krom_file_save_bytes(path, buffer);
 
 		///if krom_linux // Protected directory
@@ -45,7 +46,7 @@ class Config {
 	}
 
 	static init = () => {
-		if (!Config.configLoaded || Config.raw == null) {
+		if (!Config.config_loaded || Config.raw == null) {
 			Config.raw = {};
 			Config.raw.locale = "system";
 			Config.raw.window_mode = 0;
@@ -82,8 +83,8 @@ class Config {
 			Config.raw.rp_ssr = false;
 			Config.raw.rp_supersample = 1.0;
 			Config.raw.version = manifest_version;
-			Config.raw.sha = Config.getSha();
-			Base.initConfig();
+			Config.raw.sha = Config.get_sha();
+			Base.init_config();
 		}
 		else {
 			// Upgrade config format created by older ArmorPaint build
@@ -91,8 +92,8 @@ class Config {
 			// 	Config.raw.version = manifest_version;
 			// 	save();
 			// }
-			if (Config.raw.sha != Config.getSha()) {
-				Config.configLoaded = false;
+			if (Config.raw.sha != Config.get_sha()) {
+				Config.config_loaded = false;
 				Config.init();
 				return;
 			}
@@ -101,31 +102,31 @@ class Config {
 		zui_set_touch_scroll(Config.raw.touch_ui);
 		zui_set_touch_hold(Config.raw.touch_ui);
 		zui_set_touch_tooltip(Config.raw.touch_ui);
-		Base.resHandle.position = Config.raw.layer_res;
-		Config.loadKeymap();
+		Base.res_handle.position = Config.raw.layer_res;
+		Config.load_keymap();
 	}
 
-	static getSha = (): string => {
-		let sha = "";
+	static get_sha = (): string => {
+		let sha: string = "";
 		let blob: ArrayBuffer = data_get_blob("version.json");
 		sha = JSON.parse(sys_buffer_to_string(blob)).sha;
 		return sha;
 	}
 
-	static getDate = (): string => {
-		let date = "";
+	static get_date = (): string => {
+		let date: string = "";
 		let blob: ArrayBuffer = data_get_blob("version.json");
 		date = JSON.parse(sys_buffer_to_string(blob)).date;
 		return date;
 	}
 
-	static getOptions = (): kinc_sys_ops_t => {
-		let windowMode = Config.raw.window_mode == 0 ? window_mode_t.WINDOWED : window_mode_t.FULLSCREEN;
-		let windowFeatures = window_features_t.NONE;
+	static get_options = (): kinc_sys_ops_t => {
+		let windowMode: window_mode_t = Config.raw.window_mode == 0 ? window_mode_t.WINDOWED : window_mode_t.FULLSCREEN;
+		let windowFeatures: window_features_t = window_features_t.NONE;
 		if (Config.raw.window_resizable) windowFeatures |= window_features_t.RESIZABLE;
 		if (Config.raw.window_maximizable) windowFeatures |= window_features_t.MAXIMIZABLE;
 		if (Config.raw.window_minimizable) windowFeatures |= window_features_t.MINIMIZABLE;
-		let title = "untitled - " + manifest_title;
+		let title: string = "untitled - " + manifest_title;
 		return {
 			title: title,
 			width: Config.raw.window_w,
@@ -141,70 +142,70 @@ class Config {
 
 	static restore = () => {
 		zui_children = new Map(); // Reset ui handles
-		Config.configLoaded = false;
-		let _layout = Config.raw.layout;
+		Config.config_loaded = false;
+		let _layout: i32[] = Config.raw.layout;
 		Config.init();
 		Config.raw.layout = _layout;
-		Base.initLayout();
-		Translator.loadTranslations(Config.raw.locale);
-		Config.applyConfig();
-		Config.loadTheme(Config.raw.theme);
+		Base.init_layout();
+		Translator.load_translations(Config.raw.locale);
+		Config.apply_config();
+		Config.load_theme(Config.raw.theme);
 	}
 
-	static importFrom = (from: TConfig) => {
-		let _sha = Config.raw.sha;
-		let _version = Config.raw.version;
+	static import_from = (from: config_t) => {
+		let _sha: string = Config.raw.sha;
+		let _version: string = Config.raw.version;
 		Config.raw = from;
 		Config.raw.sha = _sha;
 		Config.raw.version = _version;
 		zui_children = new Map(); // Reset ui handles
-		Config.loadKeymap();
-		Base.initLayout();
-		Translator.loadTranslations(Config.raw.locale);
-		Config.applyConfig();
-		Config.loadTheme(Config.raw.theme);
+		Config.load_keymap();
+		Base.init_layout();
+		Translator.load_translations(Config.raw.locale);
+		Config.apply_config();
+		Config.load_theme(Config.raw.theme);
 	}
 
-	static applyConfig = () => {
+	static apply_config = () => {
 		Config.raw.rp_ssao = Context.raw.hssao.selected;
 		Config.raw.rp_ssr = Context.raw.hssr.selected;
 		Config.raw.rp_bloom = Context.raw.hbloom.selected;
 		Config.raw.rp_gi = Context.raw.hvxao.selected;
-		Config.raw.rp_supersample = Config.getSuperSampleSize(Context.raw.hsupersample.position);
+		Config.raw.rp_supersample = Config.get_super_sample_size(Context.raw.hsupersample.position);
 		Config.save();
 		Context.raw.ddirty = 2;
 
-		let current = _g2_current;
+		let current: image_t = _g2_current;
 		if (current != null) g2_end();
-		RenderPathBase.applyConfig();
+		RenderPathBase.apply_config();
 		if (current != null) g2_begin(current);
 	}
 
-	static loadKeymap = () => {
+	static load_keymap = () => {
 		if (Config.raw.keymap == "default.json") { // Built-in default
-			Config.keymap = Base.defaultKeymap;
+			Config.keymap = Base.default_keymap;
 		}
 		else {
 			let blob: ArrayBuffer = data_get_blob("keymap_presets/" + Config.raw.keymap);
 			Config.keymap = JSON.parse(sys_buffer_to_string(blob));
 			// Fill in undefined keys with defaults
-			for (let field in Base.defaultKeymap) {
+			for (let field in Base.default_keymap) {
 				if (!(field in Config.keymap)) {
-					let adefaultKeymap: any = Base.defaultKeymap;
+					let adefaultKeymap: any = Base.default_keymap;
 					Config.keymap[field] = adefaultKeymap[field];
 				}
 			}
 		}
 	}
 
-	static saveKeymap = () => {
+	static save_keymap = () => {
 		if (Config.raw.keymap == "default.json") return;
-		let path = data_path() + "keymap_presets/" + Config.raw.keymap;
-		let buffer = sys_string_to_buffer(JSON.stringify(Config.keymap));
+		let path: string = data_path() + "keymap_presets/" + Config.raw.keymap;
+		let buffer: buffer_t = sys_string_to_buffer(JSON.stringify(Config.keymap));
 		krom_file_save_bytes(path, buffer);
 	}
 
-	static getSuperSampleQuality = (f: f32): i32 => {
+	static get_super_sample_quality = (f: f32): i32 => {
 		return f == 0.25 ? 0 :
 			   f == 0.5 ? 1 :
 			   f == 1.0 ? 2 :
@@ -212,7 +213,7 @@ class Config {
 			   f == 2.0 ? 4 : 5;
 	}
 
-	static getSuperSampleSize = (i: i32): f32 => {
+	static get_super_sample_size = (i: i32): f32 => {
 		return i == 0 ? 0.25 :
 			   i == 1 ? 0.5 :
 			   i == 2 ? 1.0 :
@@ -220,56 +221,44 @@ class Config {
 			   i == 4 ? 2.0 : 4.0;
 	}
 
-	static getTextureRes = (): i32 => {
-		let res = Base.resHandle.position;
-		return res == TextureRes.Res128 ? 128 :
-			   res == TextureRes.Res256 ? 256 :
-			   res == TextureRes.Res512 ? 512 :
-			   res == TextureRes.Res1024 ? 1024 :
-			   res == TextureRes.Res2048 ? 2048 :
-			   res == TextureRes.Res4096 ? 4096 :
-			   res == TextureRes.Res8192 ? 8192 :
-			   res == TextureRes.Res16384 ? 16384 : 0;
+	static get_texture_res = (): i32 => {
+		let res: i32 = Base.res_handle.position;
+		return res == texture_res_t.RES128 ? 128 :
+			   res == texture_res_t.RES256 ? 256 :
+			   res == texture_res_t.RES512 ? 512 :
+			   res == texture_res_t.RES1024 ? 1024 :
+			   res == texture_res_t.RES2048 ? 2048 :
+			   res == texture_res_t.RES4096 ? 4096 :
+			   res == texture_res_t.RES8192 ? 8192 :
+			   res == texture_res_t.RES16384 ? 16384 : 0;
 	}
 
-	static getTextureResX = (): i32 => {
-		return Context.raw.projectAspectRatio == 2 ? Math.floor(Config.getTextureRes() / 2) : Config.getTextureRes();
+	static get_texture_res_x = (): i32 => {
+		return Context.raw.project_aspect_ratio == 2 ? Math.floor(Config.get_texture_res() / 2) : Config.get_texture_res();
 	}
 
-	static getTextureResY = (): i32 => {
-		return Context.raw.projectAspectRatio == 1 ? Math.floor(Config.getTextureRes() / 2) : Config.getTextureRes();
+	static get_texture_res_y = (): i32 => {
+		return Context.raw.project_aspect_ratio == 1 ? Math.floor(Config.get_texture_res() / 2) : Config.get_texture_res();
 	}
 
-	static getTextureResBias = (): f32 => {
-		let res = Base.resHandle.position;
-		return res == TextureRes.Res128 ? 16.0 :
-			   res == TextureRes.Res256 ? 8.0 :
-			   res == TextureRes.Res512 ? 4.0 :
-			   res == TextureRes.Res1024 ? 2.0 :
-			   res == TextureRes.Res2048 ? 1.5 :
-			   res == TextureRes.Res4096 ? 1.0 :
-			   res == TextureRes.Res8192 ? 0.5 :
-			   res == TextureRes.Res16384 ? 0.25 : 1.0;
+	static get_texture_res_pos = (i: i32): i32 => {
+		return i == 128 ? texture_res_t.RES128 :
+			   i == 256 ? texture_res_t.RES256 :
+			   i == 512 ? texture_res_t.RES512 :
+			   i == 1024 ? texture_res_t.RES1024 :
+			   i == 2048 ? texture_res_t.RES2048 :
+			   i == 4096 ? texture_res_t.RES4096 :
+			   i == 8192 ? texture_res_t.RES8192 :
+			   i == 16384 ? texture_res_t.RES16384 : 0;
 	}
 
-	static getTextureResPos = (i: i32): i32 => {
-		return i == 128 ? TextureRes.Res128 :
-			   i == 256 ? TextureRes.Res256 :
-			   i == 512 ? TextureRes.Res512 :
-			   i == 1024 ? TextureRes.Res1024 :
-			   i == 2048 ? TextureRes.Res2048 :
-			   i == 4096 ? TextureRes.Res4096 :
-			   i == 8192 ? TextureRes.Res8192 :
-			   i == 16384 ? TextureRes.Res16384 : 0;
-	}
-
-	static loadTheme = (theme: string, tagRedraw = true) => {
+	static load_theme = (theme: string, tagRedraw: bool = true) => {
 		if (theme == "default.json") { // Built-in default
 			Base.theme = zui_theme_create();
 		}
 		else {
 			let b: ArrayBuffer = data_get_blob("themes/" + theme);
-			let parsed = JSON.parse(sys_buffer_to_string(b));
+			let parsed: any = JSON.parse(sys_buffer_to_string(b));
 			Base.theme = zui_theme_create();
 			for (let key in Base.theme) {
 				if (key == "theme_") continue;
@@ -281,8 +270,8 @@ class Config {
 		}
 		Base.theme.FILL_WINDOW_BG = true;
 		if (tagRedraw) {
-			for (let ui of Base.getUIs()) ui.t = Base.theme;
-			UIBase.tagUIRedraw();
+			for (let ui of Base.get_uis()) ui.t = Base.theme;
+			UIBase.tag_ui_redraw();
 		}
 		if (Config.raw.touch_ui) {
 			// Enlarge elements
@@ -293,22 +282,22 @@ class Config {
 			Base.theme.ARROW_SIZE = 5 + 2;
 			Base.theme.CHECK_SIZE = 15 + 4;
 			Base.theme.CHECK_SELECT_SIZE = 8 + 2;
-			Config.buttonAlign = zui_align_t.LEFT;
-			Config.buttonSpacing = "";
+			Config.button_align = zui_align_t.LEFT;
+			Config.button_spacing = "";
 		}
 		else {
 			Base.theme.FULL_TABS = false;
-			Config.buttonAlign = zui_align_t.LEFT;
-			Config.buttonSpacing = Config.defaultButtonSpacing;
+			Config.button_align = zui_align_t.LEFT;
+			Config.button_spacing = Config.default_button_spacing;
 		}
 	}
 
-	static enablePlugin = (f: string) => {
+	static enable_plugin = (f: string) => {
 		Config.raw.plugins.push(f);
 		Plugin.start(f);
 	}
 
-	static disablePlugin = (f: string) => {
+	static disable_plugin = (f: string) => {
 		array_remove(Config.raw.plugins, f);
 		Plugin.stop(f);
 	}

+ 2 - 2
base/Sources/ConfigFormat.ts

@@ -1,5 +1,5 @@
 
-type TConfig = {
+type config_t = {
 	// The locale should be specified in ISO 639-1 format: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
 	// "system" is a special case that will use the system locale
 	locale?: string;
@@ -66,4 +66,4 @@ type TConfig = {
 	dilate_radius?: Null<i32>;
 
 	gpu_inference?: Null<bool>;
-}
+};

+ 32 - 32
base/Sources/Console.ts

@@ -1,18 +1,18 @@
 
 class Console {
 
-	static message = "";
-	static messageTimer = 0.0;
-	static messageColor = 0x00000000;
-	static lastTraces: string[] = [""];
-	static progressText: string = null;
+	static message: string = "";
+	static message_timer: f32 = 0.0;
+	static message_color: i32 = 0x00000000;
+	static last_traces: string[] = [""];
+	static progress_text: string = null;
 
-	static drawToast = (s: string) => {
+	static draw_toast = (s: string) => {
 		g2_set_color(0x55000000);
 		g2_fill_rect(0, 0, sys_width(), sys_height());
-		let scale = zui_SCALE(Base.getUIs()[0]);
-		let x = sys_width() / 2;
-		let y = sys_height() - 200 * scale;
+		let scale: f32 = zui_SCALE(Base.get_uis()[0]);
+		let x: f32 = sys_width() / 2;
+		let y: f32 = sys_height() - 200 * scale;
 		g2_fill_rect(x - 200 * scale, y, 400 * scale, 80 * scale);
 		g2_set_font(Base.font);
 		g2_set_font_size(Math.floor(22 * scale));
@@ -23,54 +23,54 @@ class Console {
 	static toast = (s: string) => {
 		// Show a popup message
 		let _render = () => {
-			Console.drawToast(s);
-			Base.notifyOnNextFrame(() => {
+			Console.draw_toast(s);
+			Base.notify_on_next_frame(() => {
 				app_remove_render_2d(_render);
 			});
 		}
 		app_notify_on_render_2d(_render);
-		Console.consoleTrace(s);
+		Console.console_trace(s);
 	}
 
-	static drawProgress = () => {
-		Console.drawToast(Console.progressText);
+	static draw_progress = () => {
+		Console.draw_toast(Console.progress_text);
 	}
 
 	static progress = (s: string) => {
 		// Keep popup message displayed until s == null
 		if (s == null) {
-			app_remove_render_2d(Console.drawProgress);
+			app_remove_render_2d(Console.draw_progress);
 		}
-		else if (Console.progressText == null) {
-			app_notify_on_render_2d(Console.drawProgress);
+		else if (Console.progress_text == null) {
+			app_notify_on_render_2d(Console.draw_progress);
 		}
-		if (s != null) Console.consoleTrace(s);
-		Console.progressText = s;
+		if (s != null) Console.console_trace(s);
+		Console.progress_text = s;
 	}
 
 	static info = (s: string) => {
-		Console.messageTimer = 5.0;
+		Console.message_timer = 5.0;
 		Console.message = s;
-		Console.messageColor = 0x00000000;
-		Base.redrawStatus();
-		Console.consoleTrace(s);
+		Console.message_color = 0x00000000;
+		Base.redraw_status();
+		Console.console_trace(s);
 	}
 
 	static error = (s: string) => {
-		Console.messageTimer = 8.0;
+		Console.message_timer = 8.0;
 		Console.message = s;
-		Console.messageColor = 0xffaa0000;
-		Base.redrawStatus();
-		Console.consoleTrace(s);
+		Console.message_color = 0xffaa0000;
+		Base.redraw_status();
+		Console.console_trace(s);
 	}
 
 	static log = (s: string) => {
-		Console.consoleTrace(s);
+		Console.console_trace(s);
 	}
 
-	static consoleTrace = (v: any) => {
-		Base.redrawConsole();
-		Console.lastTraces.unshift(String(v));
-		if (Console.lastTraces.length > 100) Console.lastTraces.pop();
+	static console_trace = (v: any) => {
+		Base.redraw_console();
+		Console.last_traces.unshift(String(v));
+		if (Console.last_traces.length > 100) Console.last_traces.pop();
 	}
 }

+ 165 - 165
base/Sources/Context.ts

@@ -4,134 +4,134 @@ class Context {
 
 	static raw: TContext = new TContext(); //{};
 
-	static useDeferred = (): bool => {
+	static use_deferred = (): bool => {
 		///if is_paint
-		return Context.raw.renderMode != RenderMode.RenderForward && (Context.raw.viewportMode == ViewportMode.ViewLit || Context.raw.viewportMode == ViewportMode.ViewPathTrace) && Context.raw.tool != WorkspaceTool.ToolColorId;
+		return Context.raw.render_mode != render_mode_t.FORWARD && (Context.raw.viewport_mode == viewport_mode_t.LIT || Context.raw.viewport_mode == viewport_mode_t.PATH_TRACE) && Context.raw.tool != workspace_tool_t.COLORID;
 		///end
 
 		///if (is_sculpt || is_lab)
-		return Context.raw.renderMode != RenderMode.RenderForward && (Context.raw.viewportMode == ViewportMode.ViewLit || Context.raw.viewportMode == ViewportMode.ViewPathTrace);
+		return Context.raw.render_mode != render_mode_t.FORWARD && (Context.raw.viewport_mode == viewport_mode_t.LIT || Context.raw.viewport_mode == viewport_mode_t.PATH_TRACE);
 		///end
 	}
 
 	///if (is_paint || is_sculpt)
-	static selectMaterial = (i: i32) => {
+	static select_material = (i: i32) => {
 		if (Project.materials.length <= i) return;
-		Context.setMaterial(Project.materials[i]);
+		Context.set_material(Project.materials[i]);
 	}
 
-	static setMaterial = (m: SlotMaterialRaw) => {
+	static set_material = (m: SlotMaterialRaw) => {
 		if (Project.materials.indexOf(m) == -1) return;
 		Context.raw.material = m;
-		MakeMaterial.parsePaintMaterial();
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
-		UIHeader.headerHandle.redraws = 2;
+		MakeMaterial.parse_paint_material();
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
+		UIHeader.header_handle.redraws = 2;
 		UINodes.hwnd.redraws = 2;
-		UINodes.groupStack = [];
+		UINodes.group_stack = [];
 
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+		let decal: bool = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		if (decal) {
 			let _next = () => {
-				UtilRender.makeDecalPreview();
+				UtilRender.make_decal_preview();
 			}
-			Base.notifyOnNextFrame(_next);
+			Base.notify_on_next_frame(_next);
 		}
 	}
 
-	static selectBrush = (i: i32) => {
+	static select_brush = (i: i32) => {
 		if (Project.brushes.length <= i) return;
-		Context.setBrush(Project.brushes[i]);
+		Context.set_brush(Project.brushes[i]);
 	}
 
-	static setBrush = (b: SlotBrushRaw) => {
+	static set_brush = (b: SlotBrushRaw) => {
 		if (Project.brushes.indexOf(b) == -1) return;
 		Context.raw.brush = b;
-		MakeMaterial.parseBrush();
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		MakeMaterial.parse_brush();
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		UINodes.hwnd.redraws = 2;
 	}
 
-	static selectFont = (i: i32) => {
+	static select_font = (i: i32) => {
 		if (Project.fonts.length <= i) return;
-		Context.setFont(Project.fonts[i]);
+		Context.set_font(Project.fonts[i]);
 	}
 
-	static setFont = (f: SlotFontRaw) => {
+	static set_font = (f: SlotFontRaw) => {
 		if (Project.fonts.indexOf(f) == -1) return;
 		Context.raw.font = f;
-		UtilRender.makeTextPreview();
-		UtilRender.makeDecalPreview();
-		UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+		UtilRender.make_text_preview();
+		UtilRender.make_decal_preview();
+		UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 		UIView2D.hwnd.redraws = 2;
 	}
 
-	static selectLayer = (i: i32) => {
+	static select_layer = (i: i32) => {
 		if (Project.layers.length <= i) return;
-		Context.setLayer(Project.layers[i]);
+		Context.set_layer(Project.layers[i]);
 	}
 
-	static setLayer = (l: SlotLayerRaw) => {
+	static set_layer = (l: SlotLayerRaw) => {
 		if (l == Context.raw.layer) return;
 		Context.raw.layer = l;
-		UIHeader.headerHandle.redraws = 2;
+		UIHeader.header_handle.redraws = 2;
 
-		let current = _g2_current;
+		let current: image_t = _g2_current;
 		if (current != null) g2_end();
 
-		Base.setObjectMask();
-		MakeMaterial.parseMeshMaterial();
-		MakeMaterial.parsePaintMaterial();
+		Base.set_object_mask();
+		MakeMaterial.parse_mesh_material();
+		MakeMaterial.parse_paint_material();
 
 		if (current != null) g2_begin(current);
 
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
 		UIView2D.hwnd.redraws = 2;
 	}
 	///end
 
-	static selectTool = (i: i32) => {
+	static select_tool = (i: i32) => {
 		Context.raw.tool = i;
-		MakeMaterial.parsePaintMaterial();
-		MakeMaterial.parseMeshMaterial();
+		MakeMaterial.parse_paint_material();
+		MakeMaterial.parse_mesh_material();
 		Context.raw.ddirty = 3;
-		let _viewportMode = Context.raw.viewportMode;
-		Context.raw.viewportMode = -1 as ViewportMode;
-		Context.setViewportMode(_viewportMode);
+		let _viewportMode: viewport_mode_t = Context.raw.viewport_mode;
+		Context.raw.viewport_mode = -1 as viewport_mode_t;
+		Context.set_viewport_mode(_viewportMode);
 
 		///if (is_paint || is_sculpt)
-		Context.initTool();
-		UIHeader.headerHandle.redraws = 2;
-		UIToolbar.toolbarHandle.redraws = 2;
+		Context.init_tool();
+		UIHeader.header_handle.redraws = 2;
+		UIToolbar.toolbar_handle.redraws = 2;
 		///end
 	}
 
 	///if (is_paint || is_sculpt)
-	static initTool = () => {
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+	static init_tool = () => {
+		let decal: bool = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 		if (decal) {
-			if (Context.raw.tool == WorkspaceTool.ToolText) {
-				UtilRender.makeTextPreview();
+			if (Context.raw.tool == workspace_tool_t.TEXT) {
+				UtilRender.make_text_preview();
 			}
-			UtilRender.makeDecalPreview();
+			UtilRender.make_decal_preview();
 		}
 
-		else if (Context.raw.tool == WorkspaceTool.ToolParticle) {
-			UtilParticle.initParticle();
-			MakeMaterial.parseParticleMaterial();
+		else if (Context.raw.tool == workspace_tool_t.PARTICLE) {
+			UtilParticle.init_particle();
+			MakeMaterial.parse_particle_material();
 		}
 
-		else if (Context.raw.tool == WorkspaceTool.ToolBake) {
+		else if (Context.raw.tool == workspace_tool_t.BAKE) {
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
 			// Bake in lit mode for now
-			if (Context.raw.viewportMode == ViewportMode.ViewPathTrace) {
-				Context.raw.viewportMode = ViewportMode.ViewLit;
+			if (Context.raw.viewport_mode == viewport_mode_t.PATH_TRACE) {
+				Context.raw.viewport_mode = viewport_mode_t.LIT;
 			}
 			///end
 		}
 
-		else if (Context.raw.tool == WorkspaceTool.ToolMaterial) {
-			Base.updateFillLayers();
-			Context.mainObject().skip_context = null;
+		else if (Context.raw.tool == workspace_tool_t.MATERIAL) {
+			Base.update_fill_layers();
+			Context.main_object().skip_context = null;
 		}
 
 		///if krom_ios
@@ -141,42 +141,42 @@ class Context {
 	}
 	///end
 
-	static selectPaintObject = (o: mesh_object_t) => {
+	static select_paint_object = (o: mesh_object_t) => {
 		///if (is_paint || is_sculpt)
-		UIHeader.headerHandle.redraws = 2;
-		for (let p of Project.paintObjects) p.skip_context = "paint";
-		Context.raw.paintObject = o;
+		UIHeader.header_handle.redraws = 2;
+		for (let p of Project.paint_objects) p.skip_context = "paint";
+		Context.raw.paint_object = o;
 
-		let mask = SlotLayer.getObjectMask(Context.raw.layer);
-		if (Context.layerFilterUsed()) mask = Context.raw.layerFilter;
+		let mask: i32 = SlotLayer.get_object_mask(Context.raw.layer);
+		if (Context.layer_filter_used()) mask = Context.raw.layer_filter;
 
-		if (Context.raw.mergedObject == null || mask > 0) {
-			Context.raw.paintObject.skip_context = "";
+		if (Context.raw.merged_object == null || mask > 0) {
+			Context.raw.paint_object.skip_context = "";
 		}
-		UtilUV.uvmapCached = false;
-		UtilUV.trianglemapCached = false;
-		UtilUV.dilatemapCached = false;
+		UtilUV.uvmap_cached = false;
+		UtilUV.trianglemap_cached = false;
+		UtilUV.dilatemap_cached = false;
 		///end
 
 		///if is_lab
-		Context.raw.paintObject = o;
+		Context.raw.paint_object = o;
 		///end
 	}
 
-	static mainObject = (): mesh_object_t => {
+	static main_object = (): mesh_object_t => {
 		///if (is_paint || is_sculpt)
-		for (let po of Project.paintObjects) if (po.base.children.length > 0) return po;
-		return Project.paintObjects[0];
+		for (let po of Project.paint_objects) if (po.base.children.length > 0) return po;
+		return Project.paint_objects[0];
 		///end
 
 		///if is_lab
-		return Project.paintObjects[0];
+		return Project.paint_objects[0];
 		///end
 	}
 
-	static layerFilterUsed = (): bool => {
+	static layer_filter_used = (): bool => {
 		///if (is_paint || is_sculpt)
-		return Context.raw.layerFilter > 0 && Context.raw.layerFilter <= Project.paintObjects.length;
+		return Context.raw.layer_filter > 0 && Context.raw.layer_filter <= Project.paint_objects.length;
 		///end
 
 		///if is_lab
@@ -184,9 +184,9 @@ class Context {
 		///end
 	}
 
-	static objectMaskUsed = (): bool => {
+	static object_mask_used = (): bool => {
 		///if (is_paint || is_sculpt)
-		return SlotLayer.getObjectMask(Context.raw.layer) > 0 && SlotLayer.getObjectMask(Context.raw.layer) <= Project.paintObjects.length;
+		return SlotLayer.get_object_mask(Context.raw.layer) > 0 && SlotLayer.get_object_mask(Context.raw.layer) <= Project.paint_objects.length;
 		///end
 
 		///if is_lab
@@ -194,127 +194,127 @@ class Context {
 		///end
 	}
 
-	static inViewport = (): bool => {
-		return Context.raw.paintVec.x < 1 && Context.raw.paintVec.x > 0 &&
-			   Context.raw.paintVec.y < 1 && Context.raw.paintVec.y > 0;
+	static in_viewport = (): bool => {
+		return Context.raw.paint_vec.x < 1 && Context.raw.paint_vec.x > 0 &&
+			   Context.raw.paint_vec.y < 1 && Context.raw.paint_vec.y > 0;
 	}
 
-	static inPaintArea = (): bool => {
+	static in_paint_area = (): bool => {
 		///if (is_paint || is_sculpt)
-		let right = app_w();
+		let right: i32 = app_w();
 		if (UIView2D.show) right += UIView2D.ww;
 		return mouse_view_x() > 0 && mouse_view_x() < right &&
 			   mouse_view_y() > 0 && mouse_view_y() < app_h();
 		///end
 
 		///if is_lab
-		return Context.inViewport();
+		return Context.in_viewport();
 		///end
 	}
 
-	static inLayers = (): bool => {
+	static in_layers = (): bool => {
 		return zui_get_hovered_tab_name() == tr("Layers");
 	}
 
-	static inMaterials = (): bool => {
+	static in_materials = (): bool => {
 		return zui_get_hovered_tab_name() == tr("Materials");
 	}
 
 	///if (is_paint || is_sculpt)
-	static in2dView = (type = View2DType.View2DLayer): bool => {
+	static in_2d_view = (type: view_2d_type_t = view_2d_type_t.LAYER): bool => {
 		return UIView2D.show && UIView2D.type == type &&
 			   mouse_x > UIView2D.wx && mouse_x < UIView2D.wx + UIView2D.ww &&
 			   mouse_y > UIView2D.wy && mouse_y < UIView2D.wy + UIView2D.wh;
 	}
 	///end
 
-	static inNodes = (): bool => {
+	static in_nodes = (): bool => {
 		return UINodes.show &&
 			   mouse_x > UINodes.wx && mouse_x < UINodes.wx + UINodes.ww &&
 			   mouse_y > UINodes.wy && mouse_y < UINodes.wy + UINodes.wh;
 	}
 
-	static inSwatches = (): bool => {
+	static in_swatches = (): bool => {
 		return zui_get_hovered_tab_name() == tr("Swatches");
 	}
 
-	static inBrowser = (): bool => {
+	static in_browser = (): bool => {
 		return zui_get_hovered_tab_name() == tr("Browser");
 	}
 
-	static getAreaType = (): AreaType => {
-		if (Context.inViewport()) return AreaType.AreaViewport;
-		if (Context.inNodes()) return AreaType.AreaNodes;
-		if (Context.inBrowser()) return AreaType.AreaBrowser;
+	static get_area_type = (): area_type_t => {
+		if (Context.in_viewport()) return area_type_t.VIEWPORT;
+		if (Context.in_nodes()) return area_type_t.NODES;
+		if (Context.in_browser()) return area_type_t.BROWSER;
 		///if (is_paint || is_sculpt)
-		if (Context.in2dView()) return AreaType.Area2DView;
-		if (Context.inLayers()) return AreaType.AreaLayers;
-		if (Context.inMaterials()) return AreaType.AreaMaterials;
+		if (Context.in_2d_view()) return area_type_t.VIEW2D;
+		if (Context.in_layers()) return area_type_t.LAYERS;
+		if (Context.in_materials()) return area_type_t.MATERIALS;
 		///end
-		return -1 as AreaType;
+		return -1 as area_type_t;
 	}
 
-	static setViewportMode = (mode: ViewportMode) => {
-		if (mode == Context.raw.viewportMode) return;
+	static set_viewport_mode = (mode: viewport_mode_t) => {
+		if (mode == Context.raw.viewport_mode) return;
 
-		Context.raw.viewportMode = mode;
-		if (Context.useDeferred()) {
+		Context.raw.viewport_mode = mode;
+		if (Context.use_deferred()) {
 			render_path_commands = RenderPathDeferred.commands;
 		}
 		else {
 			render_path_commands = RenderPathForward.commands;
 		}
-		let _workspace = UIHeader.worktab.position;
+		let _workspace: i32 = UIHeader.worktab.position;
 		UIHeader.worktab.position = 0;
-		MakeMaterial.parseMeshMaterial();
+		MakeMaterial.parse_mesh_material();
 		UIHeader.worktab.position = _workspace;
 	}
 
-	static loadEnvmap = () => {
-		if (!Context.raw.envmapLoaded) {
+	static load_envmap = () => {
+		if (!Context.raw.envmap_loaded) {
 			// TODO: Unable to share texture for both radiance and envmap - reload image
-			Context.raw.envmapLoaded = true;
+			Context.raw.envmap_loaded = true;
 			data_cached_images.delete("World_radiance.k");
 		}
 		world_data_load_envmap(scene_world, (_) => {});
-		if (Context.raw.savedEnvmap == null) Context.raw.savedEnvmap = scene_world._.envmap;
+		if (Context.raw.saved_envmap == null) Context.raw.saved_envmap = scene_world._.envmap;
 	}
 
-	static updateEnvmap = () => {
-		if (Context.raw.showEnvmap) {
-			scene_world._.envmap = Context.raw.showEnvmapBlur ? scene_world._.radiance_mipmaps[0] : Context.raw.savedEnvmap;
+	static update_envmap = () => {
+		if (Context.raw.show_envmap) {
+			scene_world._.envmap = Context.raw.show_envmap_blur ? scene_world._.radiance_mipmaps[0] : Context.raw.saved_envmap;
 		}
 		else {
-			scene_world._.envmap = Context.raw.emptyEnvmap;
+			scene_world._.envmap = Context.raw.empty_envmap;
 		}
 	}
 
-	static setViewportShader = (viewportShader: (ns: NodeShaderRaw)=>string) => {
-		Context.raw.viewportShader = viewportShader;
-		Context.setRenderPath();
+	static set_viewport_shader = (viewportShader: (ns: NodeShaderRaw)=>string) => {
+		Context.raw.viewport_shader = viewportShader;
+		Context.set_render_path();
 	}
 
-	static setRenderPath = () => {
-		if (Context.raw.renderMode == RenderMode.RenderForward || Context.raw.viewportShader != null) {
+	static set_render_path = () => {
+		if (Context.raw.render_mode == render_mode_t.FORWARD || Context.raw.viewport_shader != null) {
 			render_path_commands = RenderPathForward.commands;
 		}
 		else {
 			render_path_commands = RenderPathDeferred.commands;
 		}
 		app_notify_on_init(() => {
-			MakeMaterial.parseMeshMaterial();
+			MakeMaterial.parse_mesh_material();
 		});
 	}
 
-	static enableImportPlugin = (file: string): bool => {
+	static enable_import_plugin = (file: string): bool => {
 		// Return plugin name suitable for importing the specified file
-		if (BoxPreferences.filesPlugin == null) {
-			BoxPreferences.fetchPlugins();
+		if (BoxPreferences.files_plugin == null) {
+			BoxPreferences.fetch_plugins();
 		}
-		let ext = file.substr(file.lastIndexOf(".") + 1);
-		for (let f of BoxPreferences.filesPlugin) {
+		let ext: string = file.substr(file.lastIndexOf(".") + 1);
+		for (let f of BoxPreferences.files_plugin) {
 			if (f.startsWith("import_") && f.indexOf(ext) >= 0) {
-				Config.enablePlugin(f);
+				Config.enable_plugin(f);
 				Console.info(f + " " + tr("plugin enabled"));
 				return true;
 			}
@@ -322,51 +322,51 @@ class Context {
 		return false;
 	}
 
-	static setSwatch = (s: TSwatchColor) => {
+	static set_swatch = (s: swatch_color_t) => {
 		Context.raw.swatch = s;
 	}
 
 	///if is_lab
-	static runBrush = (from: i32) => {
-		let left = 0.0;
-		let right = 1.0;
+	static run_brush = (from: i32) => {
+		let left: f32 = 0.0;
+		let right: f32 = 1.0;
 
 		// First time init
-		if (Context.raw.lastPaintX < 0 || Context.raw.lastPaintY < 0) {
-			Context.raw.lastPaintVecX = Context.raw.paintVec.x;
-			Context.raw.lastPaintVecY = Context.raw.paintVec.y;
+		if (Context.raw.last_paint_x < 0 || Context.raw.last_paint_y < 0) {
+			Context.raw.last_paint_vec_x = Context.raw.paint_vec.x;
+			Context.raw.last_paint_vec_y = Context.raw.paint_vec.y;
 		}
 
-		let nodes = UINodes.getNodes();
-		let canvas = UINodes.getCanvas(true);
-		let inpaint = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
+		let nodes: zui_nodes_t = UINodes.get_nodes();
+		let canvas: zui_node_canvas_t = UINodes.get_canvas(true);
+		let inpaint: bool = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
 
 		// Paint bounds
 		if (inpaint &&
-			Context.raw.paintVec.x > left &&
-			Context.raw.paintVec.x < right &&
-			Context.raw.paintVec.y > 0 &&
-			Context.raw.paintVec.y < 1 &&
-			!Base.isDragging &&
-			!Base.isResizing &&
-			!Base.isScrolling() &&
-			!Base.isComboSelected()) {
+			Context.raw.paint_vec.x > left &&
+			Context.raw.paint_vec.x < right &&
+			Context.raw.paint_vec.y > 0 &&
+			Context.raw.paint_vec.y < 1 &&
+			!Base.is_dragging &&
+			!Base.is_resizing &&
+			!Base.is_scrolling() &&
+			!Base.is_combo_selected()) {
 
-			let down = mouse_down() || pen_down();
+			let down: bool = mouse_down() || pen_down();
 
 			// Prevent painting the same spot
-			let sameSpot = Context.raw.paintVec.x == Context.raw.lastPaintX && Context.raw.paintVec.y == Context.raw.lastPaintY;
+			let sameSpot: bool = Context.raw.paint_vec.x == Context.raw.last_paint_x && Context.raw.paint_vec.y == Context.raw.last_paint_y;
 			if (down && sameSpot) {
 				Context.raw.painted++;
 			}
 			else {
 				Context.raw.painted = 0;
 			}
-			Context.raw.lastPaintX = Context.raw.paintVec.x;
-			Context.raw.lastPaintY = Context.raw.paintVec.y;
+			Context.raw.last_paint_x = Context.raw.paint_vec.x;
+			Context.raw.last_paint_y = Context.raw.paint_vec.y;
 
 			if (Context.raw.painted == 0) {
-				Context.parseBrushInputs();
+				Context.parse_brush_inputs();
 			}
 
 			if (Context.raw.painted <= 1) {
@@ -376,21 +376,21 @@ class Context {
 		}
 	}
 
-	static parseBrushInputs = () => {
+	static parse_brush_inputs = () => {
 		if (!Context.raw.registered) {
 			Context.raw.registered = true;
 			app_notify_on_update(Context.update);
 		}
 
-		Context.raw.paintVec = Context.raw.coords;
+		Context.raw.paint_vec = Context.raw.coords;
 	}
 
 	static update = () => {
-		let paintX = mouse_view_x() / app_w();
-		let paintY = mouse_view_y() / app_h();
+		let paintX: f32 = mouse_view_x() / app_w();
+		let paintY: f32 = mouse_view_y() / app_h();
 		if (mouse_started()) {
-			Context.raw.startX = mouse_view_x() / app_w();
-			Context.raw.startY = mouse_view_y() / app_h();
+			Context.raw.start_x = mouse_view_x() / app_w();
+			Context.raw.start_y = mouse_view_y() / app_h();
 		}
 
 		if (pen_down()) {
@@ -398,37 +398,37 @@ class Context {
 			paintY = pen_view_y() / app_h();
 		}
 		if (pen_started()) {
-			Context.raw.startX = pen_view_x() / app_w();
-			Context.raw.startY = pen_view_y() / app_h();
+			Context.raw.start_x = pen_view_x() / app_w();
+			Context.raw.start_y = pen_view_y() / app_h();
 		}
 
 		if (Operator.shortcut(Config.keymap.brush_ruler + "+" + Config.keymap.action_paint, ShortcutType.ShortcutDown)) {
-			if (Context.raw.lockX) paintX = Context.raw.startX;
-			if (Context.raw.lockY) paintY = Context.raw.startY;
+			if (Context.raw.lock_x) paintX = Context.raw.start_x;
+			if (Context.raw.lock_y) paintY = Context.raw.start_y;
 		}
 
 		Context.raw.coords.x = paintX;
 		Context.raw.coords.y = paintY;
 
-		if (Context.raw.lockBegin) {
-			let dx = Math.abs(Context.raw.lockStartX - mouse_view_x());
-			let dy = Math.abs(Context.raw.lockStartY - mouse_view_y());
+		if (Context.raw.lock_begin) {
+			let dx: i32 = Math.abs(Context.raw.lock_start_x - mouse_view_x());
+			let dy: i32 = Math.abs(Context.raw.lock_start_y - mouse_view_y());
 			if (dx > 1 || dy > 1) {
-				Context.raw.lockBegin = false;
-				dx > dy ? Context.raw.lockY = true : Context.raw.lockX = true;
+				Context.raw.lock_begin = false;
+				dx > dy ? Context.raw.lock_y = true : Context.raw.lock_x = true;
 			}
 		}
 
 		if (keyboard_started(Config.keymap.brush_ruler)) {
-			Context.raw.lockStartX = mouse_view_x();
-			Context.raw.lockStartY = mouse_view_y();
-			Context.raw.lockBegin = true;
+			Context.raw.lock_start_x = mouse_view_x();
+			Context.raw.lock_start_y = mouse_view_y();
+			Context.raw.lock_begin = true;
 		}
 		else if (keyboard_released(Config.keymap.brush_ruler)) {
-			Context.raw.lockX = Context.raw.lockY = Context.raw.lockBegin = false;
+			Context.raw.lock_x = Context.raw.lock_y = Context.raw.lock_begin = false;
 		}
 
-		Context.parseBrushInputs();
+		Context.parse_brush_inputs();
 	}
 	///end
 }

+ 255 - 254
base/Sources/ContextFormat.ts

@@ -3,304 +3,305 @@
 
 // type TContext = {
 class TContext {
-	texture?: TAsset = null;
-	paintObject?: mesh_object_t;
-	mergedObject?: mesh_object_t = null; // For object mask
-	mergedObjectIsAtlas? = false; // Only objects referenced by atlas are merged
-
-	ddirty? = 0; // depth
-	pdirty? = 0; // paint
-	rdirty? = 0; // render
-	brushBlendDirty? = true;
-	nodePreviewSocket? = 0;
-
-	splitView? = false;
-	viewIndex? = -1;
-	viewIndexLast? = -1;
-
-	swatch?: TSwatchColor;
-	pickedColor?: TSwatchColor = Project.makeSwatch();
-	colorPickerCallback?: (sc: TSwatchColor)=>void = null;
-
-	defaultIrradiance?: Float32Array = null;
-	defaultRadiance?: image_t = null;
-	defaultRadianceMipmaps?: image_t[] = null;
-	savedEnvmap?: image_t = null;
-	emptyEnvmap?: image_t = null;
-	previewEnvmap?: image_t = null;
-	envmapLoaded? = false;
-	showEnvmap? = false;
-	showEnvmapHandle? = zui_handle_create({ selected: false });
-	showEnvmapBlur? = false;
-	showEnvmapBlurHandle? = zui_handle_create({ selected: false });
-	envmapAngle? = 0.0;
-	lightAngle? = 0.0;
-	cullBackfaces? = true;
-	textureFilter? = true;
-
-	formatType? = TextureLdrFormat.FormatPng;
-	formatQuality? = 100.0;
-	layersDestination? = ExportDestination.DestinationDisk;
-	splitBy? = SplitType.SplitObject;
-	parseTransform? = true;
-	parseVCols? = false;
-
-	selectTime? = 0.0;
+
+	texture?: asset_t = null;
+	paint_object?: mesh_object_t;
+	merged_object?: mesh_object_t = null; // For object mask
+	merged_object_is_atlas?: bool = false; // Only objects referenced by atlas are merged
+
+	ddirty?: i32 = 0; // depth
+	pdirty?: i32 = 0; // paint
+	rdirty?: i32 = 0; // render
+	brush_blend_dirty?: bool = true;
+	node_preview_socket?: i32 = 0;
+
+	split_view?: bool = false;
+	view_index?: i32 = -1;
+	view_index_last?: i32 = -1;
+
+	swatch?: swatch_color_t;
+	picked_color?: swatch_color_t = Project.make_swatch();
+	color_picker_callback?: (sc: swatch_color_t)=>void = null;
+
+	default_irradiance?: Float32Array = null;
+	default_radiance?: image_t = null;
+	default_radiance_mipmaps?: image_t[] = null;
+	saved_envmap?: image_t = null;
+	empty_envmap?: image_t = null;
+	preview_envmap?: image_t = null;
+	envmap_loaded?: bool = false;
+	show_envmap?: bool = false;
+	show_envmap_handle?: zui_handle_t = zui_handle_create({ selected: false });
+	show_envmap_blur?: bool = false;
+	show_envmap_blur_handle? = zui_handle_create({ selected: false });
+	envmap_angle?: f32 = 0.0;
+	light_angle?: f32 = 0.0;
+	cull_backfaces?: bool = true;
+	texture_filter?: bool = true;
+
+	format_type?: texture_ldr_format_t = texture_ldr_format_t.PNG;
+	format_quality?: f32 = 100.0;
+	layers_destination? = export_destination_t.DISK;
+	split_by?: split_type_t = split_type_t.OBJECT;
+	parse_transform?: bool = true;
+	parse_vcols?: bool = false;
+
+	select_time?: f32 = 0.0;
 	///if (krom_direct3d12 || krom_vulkan || krom_metal)
-	pathTraceMode? = PathTraceMode.TraceCore;
+	pathtrace_mode?: path_trace_mode_t = path_trace_mode_t.CORE;
 	///end
 	///if (krom_direct3d12 || krom_vulkan) // || krom_metal)
-	viewportMode? = ViewportMode.ViewPathTrace;
+	viewport_mode?: viewport_mode_t = viewport_mode_t.PATH_TRACE;
 	///else
-	viewportMode? = ViewportMode.ViewLit;
+	viewport_mode?: viewport_mode_t = viewport_mode_t.LIT;
 	///end
 	///if (krom_android || krom_ios)
-	renderMode? = RenderMode.RenderForward;
+	render_mode?: render_mode_t = render_mode_t.FORWARD;
 	///else
-	renderMode? = RenderMode.RenderDeferred;
+	render_mode?: render_mode_t = render_mode_t.DEFERRED;
 	///end
 
-	viewportShader?: (ns: NodeShaderRaw)=>string = null;
-	hscaleWasChanged? = false;
-	exportMeshFormat? = MeshFormat.FormatObj;
-	exportMeshIndex? = 0;
-	packAssetsOnExport? = true;
-
-	paintVec? = vec4_create();
-	lastPaintX? = -1.0;
-	lastPaintY? = -1.0;
-	foregroundEvent? = false;
-	painted? = 0;
-	brushTime? = 0.0;
-	cloneStartX? = -1.0;
-	cloneStartY? = -1.0;
-	cloneDeltaX? = 0.0;
-	cloneDeltaY? = 0.0;
-
-	showCompass? = true;
-	projectType? = ProjectModel.ModelRoundedCube;
-	projectAspectRatio? = 0; // 1:1, 2:1, 1:2
-	projectObjects?: mesh_object_t[];
-
-	lastPaintVecX? = -1.0;
-	lastPaintVecY? = -1.0;
-	prevPaintVecX? = -1.0;
-	prevPaintVecY? = -1.0;
-	frame? = 0;
-	paint2dView? = false;
-
-	lockStartedX? = -1.0;
-	lockStartedY? = -1.0;
-	brushLocked? = false;
-	brushCanLock? = false;
-	brushCanUnlock? = false;
-	cameraType? = CameraType.CameraPerspective;
-	camHandle? = zui_handle_create();
-	fovHandle?: zui_handle_t = null;
-	undoHandle?: zui_handle_t = null;
+	viewport_shader?: (ns: NodeShaderRaw)=>string = null;
+	hscale_was_changed?: bool = false;
+	export_mesh_format?: mesh_format_t = mesh_format_t.OBJ;
+	export_mesh_index?: i32 = 0;
+	pack_assets_on_export?: bool = true;
+
+	paint_vec?: vec4_t = vec4_create();
+	last_paint_x?: f32 = -1.0;
+	last_paint_y?: f32 = -1.0;
+	foreground_event?: bool = false;
+	painted?: i32 = 0;
+	brush_time?: f32 = 0.0;
+	clone_start_x?: f32 = -1.0;
+	clone_start_y?: f32 = -1.0;
+	clone_delta_x?: f32 = 0.0;
+	clone_delta_y?: f32 = 0.0;
+
+	show_compass?: bool = true;
+	project_type?: project_model_t = project_model_t.ROUNDED_CUBE;
+	project_aspect_ratio?: i32 = 0; // 1:1, 2:1, 1:2
+	project_objects?: mesh_object_t[];
+
+	last_paint_vec_x?: f32 = -1.0;
+	last_paint_vec_y?: f32 = -1.0;
+	prev_paint_vec_x?: f32 = -1.0;
+	prev_paint_vec_y?: f32 = -1.0;
+	frame?: i32 = 0;
+	paint2d_view?: bool = false;
+
+	lock_started_x?: f32 = -1.0;
+	lock_started_y?: f32 = -1.0;
+	brush_locked?: bool = false;
+	brush_can_lock?: bool = false;
+	brush_can_unlock?: bool = false;
+	camera_type?: camera_type_t = camera_type_t.PERSPECTIVE;
+	cam_handle?: zui_handle_t = zui_handle_create();
+	fov_handle?: zui_handle_t = null;
+	undo_handle?: zui_handle_t = null;
 	hssao?: zui_handle_t = null;
 	hssr?: zui_handle_t = null;
 	hbloom?: zui_handle_t = null;
 	hsupersample?: zui_handle_t = null;
 	hvxao?: zui_handle_t = null;
 	///if is_forge
-	vxaoExt? = 2.0;
+	vxao_ext?: f32 = 2.0;
 	///else
-	vxaoExt? = 1.0;
+	vxao_ext?: f32 = 1.0;
 	///end
-	vxaoOffset? = 1.5;
-	vxaoAperture? = 1.2;
-	textureExportPath? = "";
-	lastStatusPosition? = 0;
-	cameraControls? = CameraControls.ControlsOrbit;
-	penPaintingOnly? = false; // Reject painting with finger when using pen
+	vxao_offset?: f32 = 1.5;
+	vxao_aperture?: f32 = 1.2;
+	texture_export_path?: string = "";
+	last_status_position?: i32 = 0;
+	camera_controls?: camera_controls_t = camera_controls_t.ORBIT;
+	pen_painting_only?: bool = false; // Reject painting with finger when using pen
 
 	///if (is_paint || is_sculpt)
 	material?: SlotMaterialRaw;
 	layer?: SlotLayerRaw;
 	brush?: SlotBrushRaw;
 	font?: SlotFontRaw;
-	tool? = WorkspaceTool.ToolBrush;
-
-	layerPreviewDirty? = true;
-	layersPreviewDirty? = false;
-	nodePreviewDirty? = false;
-	nodePreview?: image_t = null;
-	nodePreviews?: Map<string, image_t> = null;
-	nodePreviewsUsed?: string[] = null;
-	nodePreviewName? = "";
-	maskPreviewRgba32?: image_t = null;
-	maskPreviewLast?: SlotLayerRaw = null;
-
-	colorIdPicked? = false;
-	materialPreview? = false; // Drawing material previews
-	savedCamera? = mat4_identity();
-
-	colorPickerPreviousTool? = WorkspaceTool.ToolBrush;
-	materialIdPicked? = 0;
-	uvxPicked? = 0.0;
-	uvyPicked? = 0.0;
-	pickerSelectMaterial? = true;
-	pickerMaskHandle? = zui_handle_create();
-	pickPosNorTex? = false;
-	posXPicked? = 0.0;
-	posYPicked? = 0.0;
-	posZPicked? = 0.0;
-	norXPicked? = 0.0;
-	norYPicked? = 0.0;
-	norZPicked? = 0.0;
-
-	drawWireframe? = false;
-	wireframeHandle? = zui_handle_create({ selected: false });
-	drawTexels? = false;
-	texelsHandle? = zui_handle_create({ selected: false });
-
-	colorIdHandle? = zui_handle_create();
-	layersExport? = ExportMode.ExportVisible;
-
-	decalImage?: image_t = null;
-	decalPreview? = false;
-	decalX? = 0.0;
-	decalY? = 0.0;
-
-	cacheDraws? = false;
-	writeIconOnExport? = false;
-
-	textToolImage?: image_t = null;
-	textToolText?: string;
-	particleMaterial?: material_data_t = null;
+	tool?: workspace_tool_t = workspace_tool_t.BRUSH;
+
+	layer_preview_dirty?: bool = true;
+	layers_preview_dirty?: bool = false;
+	node_preview_dirty?: bool = false;
+	node_preview?: image_t = null;
+	node_previews?: Map<string, image_t> = null;
+	node_previews_used?: string[] = null;
+	node_preview_name?: string = "";
+	mask_preview_rgba32?: image_t = null;
+	mask_preview_last?: SlotLayerRaw = null;
+
+	colorid_picked?: bool = false;
+	material_preview?: bool = false; // Drawing material previews
+	saved_camera?: mat4_t = mat4_identity();
+
+	color_picker_previous_tool? = workspace_tool_t.BRUSH;
+	materialid_picked?: i32 = 0;
+	uvx_picked?: f32 = 0.0;
+	uvy_picked?: f32 = 0.0;
+	picker_select_material?: bool = true;
+	picker_mask_handle?: zui_handle_t = zui_handle_create();
+	pick_pos_nor_tex?: bool = false;
+	posx_picked?: f32 = 0.0;
+	posy_picked?: f32 = 0.0;
+	posz_picked?: f32 = 0.0;
+	norx_picked?: f32 = 0.0;
+	nory_picked?: f32 = 0.0;
+	norz_picked?: f32 = 0.0;
+
+	draw_wireframe?: bool = false;
+	wireframe_handle?: zui_handle_t = zui_handle_create({ selected: false });
+	draw_texels?: bool = false;
+	texels_handle?: zui_handle_t = zui_handle_create({ selected: false });
+
+	colorid_handle?: zui_handle_t = zui_handle_create();
+	layers_export?: export_mode_t = export_mode_t.VISIBLE;
+
+	decal_image?: image_t = null;
+	decal_preview?: bool = false;
+	decal_x?: f32 = 0.0;
+	decal_y?: f32 = 0.0;
+
+	cache_draws?: bool = false;
+	write_icon_on_export?: bool = false;
+
+	text_tool_image?: image_t = null;
+	text_tool_text?: string;
+	particle_material?: material_data_t = null;
 	///if arm_physics
-	particlePhysics? = false;
-	particleHitX? = 0.0;
-	particleHitY? = 0.0;
-	particleHitZ? = 0.0;
-	lastParticleHitX? = 0.0;
-	lastParticleHitY? = 0.0;
-	lastParticleHitZ? = 0.0;
-	particleTimer?: tween_anim_t = null;
-	paintBody?: PhysicsBodyRaw = null;
+	particle_physics?: bool = false;
+	particle_hit_x?: f32 = 0.0;
+	particle_hit_y?: f32 = 0.0;
+	particle_hit_z?: f32 = 0.0;
+	last_particle_hit_x?: f32 = 0.0;
+	last_particle_hit_y?: f32 = 0.0;
+	last_particle_hit_z?: f32 = 0.0;
+	particle_timer?: tween_anim_t = null;
+	paint_body?: PhysicsBodyRaw = null;
 	///end
 
-	layerFilter? = 0;
-	runBrush?: (i: i32)=>void = null;
-	parseBrushInputs?: ()=>void = null;
+	layer_filter?: i32 = 0;
+	run_brush?: (i: i32)=>void = null;
+	parse_brush_inputs?: ()=>void = null;
 
 	gizmo?: object_t = null;
-	gizmoTranslateX?: object_t = null;
-	gizmoTranslateY?: object_t = null;
-	gizmoTranslateZ?: object_t = null;
-	gizmoScaleX?: object_t = null;
-	gizmoScaleY?: object_t = null;
-	gizmoScaleZ?: object_t = null;
-	gizmoRotateX?: object_t = null;
-	gizmoRotateY?: object_t = null;
-	gizmoRotateZ?: object_t = null;
-	gizmoStarted? = false;
-	gizmoOffset? = 0.0;
-	gizmoDrag? = 0.0;
-	gizmoDragLast? = 0.0;
-	translateX? = false;
-	translateY? = false;
-	translateZ? = false;
-	scaleX? = false;
-	scaleY? = false;
-	scaleZ? = false;
-	rotateX? = false;
-	rotateY? = false;
-	rotateZ? = false;
-
-	brushNodesRadius? = 1.0;
-	brushNodesOpacity? = 1.0;
-	brushMaskImage?: image_t = null;
-	brushMaskImageIsAlpha? = false;
-	brushStencilImage?: image_t = null;
-	brushStencilImageIsAlpha? = false;
-	brushStencilX? = 0.02;
-	brushStencilY? = 0.02;
-	brushStencilScale? = 0.9;
-	brushStencilScaling? = false;
-	brushStencilAngle? = 0.0;
-	brushStencilRotating? = false;
-	brushNodesScale? = 1.0;
-	brushNodesAngle? = 0.0;
-	brushNodesHardness? = 1.0;
-	brushDirectional? = false;
-
-	brushRadius? = 0.5;
-	brushRadiusHandle? = zui_handle_create({ value: 0.5 });
-	brushScaleX? = 1.0;
-	brushDecalMaskRadius? = 0.5;
-	brushDecalMaskRadiusHandle? = zui_handle_create({ value: 0.5 });
-	brushScaleXHandle? = zui_handle_create({ value: 1.0 });
-	brushBlending? = BlendType.BlendMix;
-	brushOpacity? = 1.0;
-	brushOpacityHandle? = zui_handle_create({ value: 1.0 });
-	brushScale? = 1.0;
-	brushAngle? = 0.0;
-	brushAngleHandle? = zui_handle_create({ value: 0.0 });
+	gizmo_translate_x?: object_t = null;
+	gizmo_translate_y?: object_t = null;
+	gizmo_translate_z?: object_t = null;
+	gizmo_scale_x?: object_t = null;
+	gizmo_scale_y?: object_t = null;
+	gizmo_scale_z?: object_t = null;
+	gizmo_rotate_x?: object_t = null;
+	gizmo_rotate_y?: object_t = null;
+	gizmo_rotate_z?: object_t = null;
+	gizmo_started?: bool = false;
+	gizmo_offset?: f32 = 0.0;
+	gizmo_drag?: f32 = 0.0;
+	gizmo_drag_last?: f32 = 0.0;
+	translate_x?: bool = false;
+	translate_y?: bool = false;
+	translate_z?: bool = false;
+	scale_x?: bool = false;
+	scale_y?: bool = false;
+	scale_z?: bool = false;
+	rotate_x?: bool = false;
+	rotate_y?: bool = false;
+	rotate_z?: bool = false;
+
+	brush_nodes_radius?: f32 = 1.0;
+	brush_nodes_opacity?: f32 = 1.0;
+	brush_mask_image?: image_t = null;
+	brush_mask_image_is_alpha?: bool = false;
+	brush_stencil_image?: image_t = null;
+	brush_stencil_image_is_alpha?: bool = false;
+	brush_stencil_x?: f32 = 0.02;
+	brush_stencil_y?: f32 = 0.02;
+	brush_stencil_scale?: f32 = 0.9;
+	brush_stencil_scaling?: bool = false;
+	brush_stencil_angle?: f32 = 0.0;
+	brush_stencil_rotating?: bool = false;
+	brush_nodes_scale?: f32 = 1.0;
+	brush_nodes_angle?: f32 = 0.0;
+	brush_nodes_hardness?: f32 = 1.0;
+	brush_directional?: bool = false;
+
+	brush_radius?: f32 = 0.5;
+	brush_radius_handle?: zui_handle_t = zui_handle_create({ value: 0.5 });
+	brush_scale_x?: f32 = 1.0;
+	brush_decal_mask_radius?: f32 = 0.5;
+	brush_decal_mask_radius_handle?: zui_handle_t = zui_handle_create({ value: 0.5 });
+	brush_scale_x_handle?: zui_handle_t = zui_handle_create({ value: 1.0 });
+	brush_blending?: blend_type_t = blend_type_t.MIX;
+	brush_opacity?: f32 = 1.0;
+	brush_opacity_handle?: zui_handle_t = zui_handle_create({ value: 1.0 });
+	brush_scale?: f32 = 1.0;
+	brush_angle?: f32 = 0.0;
+	brush_angle_handle?: zui_handle_t = zui_handle_create({ value: 0.0 });
 	///if is_paint
-	brushHardness? = 0.8;
+	brush_hardness?: f32 = 0.8;
 	///end
 	///if is_sculpt
-	brushHardness? = 0.05;
+	brush_hardness?: f32 = 0.05;
 	///end
-	brushLazyRadius? = 0.0;
-	brushLazyStep? = 0.0;
-	brushLazyX? = 0.0;
-	brushLazyY? = 0.0;
-	brushPaint? = UVType.UVMap;
-	brushAngleRejectDot? = 0.5;
-	bakeType? = BakeType.BakeAO;
-	bakeAxis? = BakeAxis.BakeXYZ;
-	bakeUpAxis? = BakeUpAxis.BakeUpZ;
-	bakeSamples? = 128;
-	bakeAoStrength? = 1.0;
-	bakeAoRadius? = 1.0;
-	bakeAoOffset? = 1.0;
-	bakeCurvStrength? = 1.0;
-	bakeCurvRadius? = 1.0;
-	bakeCurvOffset? = 0.0;
-	bakeCurvSmooth? = 1;
-	bakeHighPoly? = 0;
-
-	xray? = false;
-	symX? = false;
-	symY? = false;
-	symZ? = false;
-	fillTypeHandle? = zui_handle_create();
-
-	paint2d? = false;
-
-	lastHtab0Position? = 0;
-	maximizedSidebarWidth? = 0;
-	dragDestination? = 0;
+	brush_lazy_radius?: f32 = 0.0;
+	brush_lazy_step?: f32 = 0.0;
+	brush_lazy_x?: f32 = 0.0;
+	brush_lazy_y?: f32 = 0.0;
+	brush_paint?: uv_type_t = uv_type_t.UVMAP;
+	brush_angle_reject_dot?: f32 = 0.5;
+	bake_type?: bake_type_t = bake_type_t.AO;
+	bake_axis?: bake_axis_t = bake_axis_t.XYZ;
+	bake_up_axis?: bake_up_axis_t = bake_up_axis_t.Z;
+	bake_samples?: i32 = 128;
+	bake_ao_strength?: f32 = 1.0;
+	bake_ao_radius?: f32 = 1.0;
+	bake_ao_offset?: f32 = 1.0;
+	bake_curv_strength?: f32 = 1.0;
+	bake_curv_radius?: f32 = 1.0;
+	bake_curv_offset?: f32 = 0.0;
+	bake_curv_smooth?: i32 = 1;
+	bake_high_poly?: i32 = 0;
+
+	xray?: bool = false;
+	sym_x?: bool = false;
+	sym_y?: bool = false;
+	sym_z?: bool = false;
+	fill_type_handle?: zui_handle_t = zui_handle_create();
+
+	paint2d?: bool = false;
+
+	last_htab0_pos?: i32 = 0;
+	maximized_sidebar_width?: i32 = 0;
+	drag_dest?: i32 = 0;
 	///end
 
 	///if is_lab
 	material?: any; ////
 	layer?: any; ////
-	tool? = WorkspaceTool.ToolEraser;
+	tool?: workspace_tool_t = workspace_tool_t.ERASER;
 
-	colorPickerPreviousTool? = WorkspaceTool.ToolEraser;
+	color_picker_previous_tool?: workspace_tool_t = workspace_tool_t.ERASER;
 
-	brushRadius? = 0.25;
-	brushRadiusHandle? = zui_handle_create({ value: 0.25 });
-	brushScale? = 1.0;
+	brush_radius?: f32 = 0.25;
+	brush_radius_handle?: zui_handle_t = zui_handle_create({ value: 0.25 });
+	brush_scale?: f32 = 1.0;
 
-	coords? = vec4_create();
-	startX? = 0.0;
-	startY? = 0.0;
+	coords?: vec4_t = vec4_create();
+	start_x?: f32 = 0.0;
+	start_y?: f32 = 0.0;
 
 	// Brush ruler
-	lockBegin? = false;
-	lockX? = false;
-	lockY? = false;
-	lockStartX? = 0.0;
-	lockStartY? = 0.0;
-	registered? = false;
+	lock_begin?: bool = false;
+	lock_x?: bool = false;
+	lock_y?: bool = false;
+	lock_start_x?: f32 = 0.0;
+	lock_start_y?: f32 = 0.0;
+	registered?: bool = false;
 	///end
 
 	///if is_forge
-	selectedObject?: object_t = null;
+	selected_object?: object_t = null;
 	///end
 }

+ 239 - 239
base/Sources/Enums.ts

@@ -1,290 +1,290 @@
 
-enum DilateType {
-	DilateInstant,
-	DilateDelayed,
-}
-
-enum BakeType {
-	BakeInit = -1,
-	BakeAO = 0,
-	BakeCurvature = 1,
-	BakeNormal = 2,
-	BakeNormalObject = 3,
-	BakeHeight = 4,
-	BakeDerivative = 5,
-	BakePosition = 6,
-	BakeTexCoord = 7,
-	BakeMaterialID = 8,
-	BakeObjectID = 9,
-	BakeVertexColor = 10,
-	BakeLightmap = 11,
-	BakeBentNormal = 12,
-	BakeThickness = 13,
-}
-
-enum SplitType {
-	SplitObject = 0,
-	SplitGroup = 1,
-	SplitMaterial = 2,
-	SplitUdim = 3,
-}
-
-enum BakeAxis {
-	BakeXYZ = 0,
-	BakeX = 1,
-	BakeY = 2,
-	BakeZ = 3,
-	BakeMX = 4,
-	BakeMY = 5,
-	BakeMZ = 6,
-}
-
-enum BakeUpAxis {
-	BakeUpZ = 0,
-	BakeUpY = 1,
-	BakeUpX = 2,
-}
-
-enum ViewportMode {
-	ViewLit = 0,
-	ViewBaseColor = 1,
-	ViewNormalMap = 2,
-	ViewOcclusion = 3,
-	ViewRoughness = 4,
-	ViewMetallic = 5,
-	ViewOpacity = 6,
-	ViewHeight = 7,
-	ViewPathTrace = 8,
-	ViewEmission = 9,
-	ViewSubsurface = 10,
-	ViewTexCoord = 11,
-	ViewObjectNormal = 12,
-	ViewMaterialID = 13,
-	ViewObjectID = 14,
-	ViewMask = 15,
-}
-
-enum ChannelType {
-	ChannelBaseColor = 0,
-	ChannelOcclusion = 1,
-	ChannelRoughness = 2,
-	ChannelMetallic = 3,
-	ChannelNormalMap = 4,
-	ChannelHeight = 5,
-}
-
-enum RenderMode {
-	RenderDeferred = 0,
-	RenderForward = 1,
-	RenderPathTrace = 2,
+enum dilate_type_t {
+	INSTANT,
+	DELAYED,
+}
+
+enum bake_type_t {
+	INIT = -1,
+	AO = 0,
+	CURVATURE = 1,
+	NORMAL = 2,
+	NORMAL_OBJECT = 3,
+	HEIGHT = 4,
+	DERIVATIVE = 5,
+	POSITION = 6,
+	TEXCOORD = 7,
+	MATERIALID = 8,
+	OBJECTID = 9,
+	VERTEX_COLOR = 10,
+	LIGHTMAP = 11,
+	BENT_NORMAL = 12,
+	THICKNESS = 13,
+}
+
+enum split_type_t {
+	OBJECT = 0,
+	GROUP = 1,
+	MATERIAL = 2,
+	UDIM = 3,
+}
+
+enum bake_axis_t {
+	XYZ = 0,
+	X = 1,
+	Y = 2,
+	Z = 3,
+	MX = 4,
+	MY = 5,
+	MZ = 6,
+}
+
+enum bake_up_axis_t {
+	Z = 0,
+	Y = 1,
+	X = 2,
+}
+
+enum viewport_mode_t {
+	LIT = 0,
+	BASE_COLOR = 1,
+	NORMAL_MAP = 2,
+	OCCLUSION = 3,
+	ROUGHNESS = 4,
+	METALLIC = 5,
+	OPACITY = 6,
+	HEIGHT = 7,
+	PATH_TRACE = 8,
+	EMISSION = 9,
+	SUBSURFACE = 10,
+	TEXCOORD = 11,
+	OBJECT_NORMAL = 12,
+	MATERIAL_ID = 13,
+	OBJECT_ID = 14,
+	MASK = 15,
+}
+
+enum channel_type_t {
+	BASE_COLOR = 0,
+	OCCLUSION = 1,
+	ROUGHNESS = 2,
+	METALLIC = 3,
+	NORMAL_MAP = 4,
+	HEIGHT = 5,
+}
+
+enum render_mode_t {
+	DEFERRED = 0,
+	FORWARD = 1,
+	PATH_TRACE = 2,
 }
 
-enum ExportMode {
-	ExportVisible = 0,
-	ExportSelected = 1,
-	ExportPerObject = 2,
-	ExportPerUdimTile = 3,
+enum export_mode_t {
+	VISIBLE = 0,
+	SELECTED = 1,
+	PER_OBJECT = 2,
+	PER_UDIM_TILE = 3,
 }
 
-enum ExportDestination {
-	DestinationDisk = 0,
-	DestinationPacked = 1,
+enum export_destination_t {
+	DISK = 0,
+	PACKED = 1,
 }
 
-enum PathTraceMode {
-	TraceCore = 0,
-	TraceFull = 1,
+enum path_trace_mode_t {
+	CORE = 0,
+	FULL = 1,
 }
 
-enum FillType {
-	FillObject = 0,
-	FillFace = 1,
-	FillAngle = 2,
-	FillUVIsland = 3,
+enum fill_type_t {
+	OBJECT = 0,
+	FACE = 1,
+	ANGLE = 2,
+	UV_ISLAND = 3,
 }
 
-enum UVType {
-	UVMap = 0,
-	UVTriplanar = 1,
-	UVProject = 2,
+enum uv_type_t {
+	UVMAP = 0,
+	TRIPLANAR = 1,
+	PROJECT = 2,
 }
 
-enum PickerMask {
-	MaskNone = 0,
-	MaskMaterial = 1,
+enum picker_mask_t {
+	NONE = 0,
+	MATERIAL = 1,
 }
 
-enum BlendType {
-	BlendMix = 0,
-	BlendDarken = 1,
-	BlendMultiply = 2,
-	BlendBurn = 3,
-	BlendLighten = 4,
-	BlendScreen = 5,
-	BlendDodge = 6,
-	BlendAdd = 7,
-	BlendOverlay = 8,
-	BlendSoftLight = 9,
-	BlendLinearLight = 10,
-	BlendDifference = 11,
-	BlendSubtract = 12,
-	BlendDivide = 13,
-	BlendHue = 14,
-	BlendSaturation = 15,
-	BlendColor = 16,
-	BlendValue = 17,
+enum blend_type_t {
+	MIX = 0,
+	DARKEN = 1,
+	MULTIPLY = 2,
+	BURN = 3,
+	LIGHTEN = 4,
+	SCREEN = 5,
+	DODGE = 6,
+	ADD = 7,
+	OVERLAY = 8,
+	SOFT_LIGHT = 9,
+	LINEAR_LIGHT = 10,
+	DIFFERENCE = 11,
+	SUBTRACT = 12,
+	DIVIDE = 13,
+	HUE = 14,
+	SATURATION = 15,
+	COLOR = 16,
+	VALUE = 17,
 }
 
-enum CameraControls {
-	ControlsOrbit = 0,
-	ControlsRotate = 1,
-	ControlsFly = 2,
+enum camera_controls_t {
+	ORBIT = 0,
+	ROTATE = 1,
+	FLY = 2,
 }
 
-enum CameraType {
-	CameraPerspective = 0,
-	CameraOrthographic = 1,
+enum camera_type_t {
+	PERSPECTIVE = 0,
+	ORTHOGRAPHIC = 1,
 }
 
-enum TextureBits {
-	Bits8 = 0,
-	Bits16 = 1,
-	Bits32 = 2,
+enum texture_bits_t {
+	BITS8 = 0,
+	BITS16 = 1,
+	BITS32 = 2,
 }
 
-enum TextureLdrFormat {
-	FormatPng = 0,
-	FormatJpg = 1,
+enum texture_ldr_format_t {
+	PNG = 0,
+	JPG = 1,
 }
 
-enum TextureHdrFormat {
-	FormatExr = 0,
+enum texture_hdr_format_t {
+	EXR = 0,
 }
 
-enum MeshFormat {
-	FormatObj = 0,
-	FormatArm = 1,
+enum mesh_format_t {
+	OBJ = 0,
+	ARM = 1,
 }
 
-enum MenuCategory {
-	MenuFile = 0,
-	MenuEdit = 1,
-	MenuViewport = 2,
-	MenuMode = 3,
-	MenuCamera = 4,
-	MenuHelp = 5,
+enum menu_category_t {
+	FILE = 0,
+	EDIT = 1,
+	VIEWPORT = 2,
+	MODE = 3,
+	CAMERA = 4,
+	HELP = 5,
 }
 
-enum CanvasType {
-	CanvasMaterial = 0,
-	CanvasBrush = 1,
+enum canvas_type_t {
+	MATERIAL = 0,
+	BRUSH = 1,
 }
 
-enum View2DType {
-	View2DAsset = 0,
-	View2DNode = 1,
-	View2DFont = 2,
-	View2DLayer = 3,
+enum view_2d_type_t {
+	ASSET = 0,
+	NODE = 1,
+	FONT = 2,
+	LAYER = 3,
 }
 
-enum View2DLayerMode {
-	View2DVisible = 0,
-	View2DSelected = 1,
+enum view_2d_layer_mode_t {
+	VISIBLE = 0,
+	SELECTED = 1,
 }
 
-enum BorderSide {
-	SideLeft = 0,
-	SideRight = 1,
-	SideTop = 2,
-	SideBottom = 3,
+enum border_side_t {
+	LEFT = 0,
+	RIGHT = 1,
+	TOP = 2,
+	BOTTOm = 3,
 }
 
-enum PaintTex {
-	TexBase = 0,
-	TexNormal = 1,
-	TexOcclusion = 2,
-	TexRoughness = 3,
-	TexMetallic = 4,
-	TexOpacity = 5,
-	TexHeight = 6,
+enum paint_tex_t {
+	BASE = 0,
+	NORMAL = 1,
+	OCCLUSION = 2,
+	ROUGHNESS = 3,
+	METALLIC = 4,
+	OPACITY = 5,
+	HEIGHT = 6,
 }
 
-enum ProjectModel {
-	ModelRoundedCube = 0,
-	ModelSphere = 1,
-	ModelTessellatedPlane = 2,
-	ModelCustom = 3,
-}
-
-enum ZoomDirection {
-	ZoomVertical = 0,
-	ZoomVerticalInverted = 1,
-	ZoomHorizontal = 2,
-	ZoomHorizontalInverted = 3,
-	ZoomVerticalAndHorizontal = 4,
-	ZoomVerticalAndHorizontalInverted = 5,
+enum project_model_t {
+	ROUNDED_CUBE = 0,
+	SPHERE = 1,
+	TESSELLATED_PLANE = 2,
+	CUSTOM = 3,
+}
+
+enum zoom_direction_t {
+	VERTICAL = 0,
+	VERTICAL_INVERTED = 1,
+	HORIZONTAL = 2,
+	HORIZONTAL_INVERTED = 3,
+	VERTICAL_HORIZONTAL = 4,
+	VERTICAL_HORIZONTAL_INVERTED = 5,
 }
 
-enum LayerSlotType {
-	SlotLayer = 0,
-	SlotMask = 1,
-	SlotGroup = 2,
+enum layer_slot_type_t {
+	LAYER = 0,
+	MASK = 1,
+	GROUP = 2,
 }
 
-enum SpaceType {
-	Space3D = 0,
-	Space2D = 1,
+enum space_type_t {
+	SPACE3D = 0,
+	SPACE2D = 1,
 }
 
-enum WorkspaceTool {
-	ToolBrush = 0,
-	ToolEraser = 1,
-	ToolFill = 2,
-	ToolDecal = 3,
-	ToolText = 4,
-	ToolClone = 5,
-	ToolBlur = 6,
-	ToolSmudge = 7,
-	ToolParticle = 8,
-	ToolColorId = 9,
-	ToolPicker = 10,
-	ToolBake = 11,
-	ToolGizmo = 12,
-	ToolMaterial = 13,
+enum workspace_tool_t {
+	BRUSH = 0,
+	ERASER = 1,
+	FILL = 2,
+	DECAL = 3,
+	TEXT = 4,
+	CLONE = 5,
+	BLUR = 6,
+	SMUDGE = 7,
+	PARTICLE = 8,
+	COLORID = 9,
+	PICKER = 10,
+	BAKE = 11,
+	GIZMO = 12,
+	MATERIAL = 13,
 }
 
-enum AreaType {
-	AreaViewport = 0,
-	Area2DView = 1,
-	AreaLayers = 2,
-	AreaMaterials = 3,
-	AreaNodes = 4,
-	AreaBrowser = 5,
+enum area_type_t {
+	VIEWPORT = 0,
+	VIEW2D = 1,
+	LAYERS = 2,
+	MATERIALS = 3,
+	NODES = 4,
+	BROWSER = 5,
 }
-
-enum TabArea {
-	TabSidebar0 = 0,
-	TabSidebar1 = 1,
-	TabStatus = 2,
-}
-
-enum TextureRes {
-	Res128 = 0,
-	Res256 = 1,
-	Res512 = 2,
-	Res1024 = 3,
-	Res2048 = 4,
-	Res4096 = 5,
-	Res8192 = 6,
-	Res16384 = 7,
-}
-
-enum LayoutSize {
-	LayoutSidebarW = 0,
-	LayoutSidebarH0 = 1,
-	LayoutSidebarH1 = 2,
-	LayoutNodesW = 3,
-	LayoutNodesH = 4,
-	LayoutStatusH = 5,
-	LayoutHeader = 6, // 0 - hidden, 1 - visible
+
+enum tab_area_t {
+	SIDEBAR0 = 0,
+	SIDEBAR1 = 1,
+	STATUS = 2,
+}
+
+enum texture_res_t {
+	RES128 = 0,
+	RES256 = 1,
+	RES512 = 2,
+	RES1024 = 3,
+	RES2048 = 4,
+	RES4096 = 5,
+	RES8192 = 6,
+	RES16384 = 7,
+}
+
+enum layout_size_t {
+	SIDEBAR_W = 0,
+	SIDEBAR_H0 = 1,
+	SIDEBAR_H1 = 2,
+	NODES_W = 3,
+	NODES_H = 4,
+	STATUS_H = 5,
+	HEADER = 6, // 0 - hidden, 1 - visible
 }

+ 109 - 109
base/Sources/ExportArm.ts

@@ -1,21 +1,21 @@
 
 class ExportArm {
 
-	static runMesh = (path: string, paintObjects: mesh_object_t[]) => {
+	static run_mesh = (path: string, paintObjects: mesh_object_t[]) => {
 		let mesh_datas: mesh_data_t[] = [];
 		for (let p of paintObjects) mesh_datas.push(p.data);
 		let raw: scene_t = { mesh_datas: mesh_datas };
-		let b = armpack_encode(raw);
+		let b: buffer_t = armpack_encode(raw);
 		if (!path.endsWith(".arm")) path += ".arm";
 		krom_file_save_bytes(path, b, b.byteLength + 1);
 	}
 
-	static runProject = () => {
+	static run_project = () => {
 		///if (is_paint || is_sculpt)
 		let mnodes: zui_node_canvas_t[] = [];
 		for (let m of Project.materials) {
 			let c: zui_node_canvas_t = JSON.parse(JSON.stringify(m.canvas));
-			for (let n of c.nodes) ExportArm.exportNode(n);
+			for (let n of c.nodes) ExportArm.export_node(n);
 			mnodes.push(c);
 		}
 
@@ -25,38 +25,38 @@ class ExportArm {
 
 		///if is_lab
 		let c: zui_node_canvas_t = JSON.parse(JSON.stringify(Project.canvas));
-		for (let n of c.nodes) ExportArm.exportNode(n);
+		for (let n of c.nodes) ExportArm.export_node(n);
 		///end
 
 		let mgroups: zui_node_canvas_t[] = null;
-		if (Project.materialGroups.length > 0) {
+		if (Project.material_groups.length > 0) {
 			mgroups = [];
-			for (let g of Project.materialGroups) {
+			for (let g of Project.material_groups) {
 				let c: zui_node_canvas_t = JSON.parse(JSON.stringify(g.canvas));
-				for (let n of c.nodes) ExportArm.exportNode(n);
+				for (let n of c.nodes) ExportArm.export_node(n);
 				mgroups.push(c);
 			}
 		}
 
 		///if (is_paint || is_sculpt)
 		let md: mesh_data_t[] = [];
-		for (let p of Project.paintObjects) md.push(p.data);
+		for (let p of Project.paint_objects) md.push(p.data);
 		///end
 
 		///if is_lab
-		let md = Project.paintObjects[0].data;
+		let md: mesh_data_t = Project.paint_objects[0].data;
 		///end
 
-		let texture_files = ExportArm.assetsToFiles(Project.filepath, Project.assets);
+		let texture_files: string[] = ExportArm.assets_to_files(Project.filepath, Project.assets);
 
 		///if (is_paint || is_sculpt)
-		let font_files = ExportArm.fontsToFiles(Project.filepath, Project.fonts);
-		let mesh_files = ExportArm.meshesToFiles(Project.filepath);
+		let font_files: string[] = ExportArm.fonts_to_files(Project.filepath, Project.fonts);
+		let mesh_files: string[] = ExportArm.meshes_to_files(Project.filepath);
 
-		let bitsPos = Base.bitsHandle.position;
-		let bpp = bitsPos == TextureBits.Bits8 ? 8 : bitsPos == TextureBits.Bits16 ? 16 : 32;
+		let bitsPos: i32 = Base.bits_handle.position;
+		let bpp: i32 = bitsPos == texture_bits_t.BITS8 ? 8 : bitsPos == texture_bits_t.BITS16 ? 16 : 32;
 
-		let ld: TLayerData[] = [];
+		let ld: layer_data_t[] = [];
 		for (let l of Project.layers) {
 			ld.push({
 				name: l.name,
@@ -66,7 +66,7 @@ class ExportArm {
 				uv_scale: l.scale,
 				uv_rot: l.angle,
 				uv_type: l.uvType,
-				decal_mat: l.uvType == UVType.UVProject ? mat4_to_f32_array(l.decalMat) : null,
+				decal_mat: l.uvType == uv_type_t.PROJECT ? mat4_to_f32_array(l.decalMat) : null,
 				opacity_mask: l.maskOpacity,
 				fill_layer: l.fill_layer != null ? Project.materials.indexOf(l.fill_layer) : -1,
 				object_mask: l.objectMask,
@@ -92,11 +92,11 @@ class ExportArm {
 		}
 		///end
 
-		let packed_assets = (Project.raw.packed_assets == null || Project.raw.packed_assets.length == 0) ? null : Project.raw.packed_assets;
+		let packed_assets: packed_asset_t[] = (Project.raw.packed_assets == null || Project.raw.packed_assets.length == 0) ? null : Project.raw.packed_assets;
 		///if krom_ios
-		let sameDrive = false;
+		let sameDrive: bool = false;
 		///else
-		let sameDrive = Project.raw.envmap != null ? Project.filepath.charAt(0) == Project.raw.envmap.charAt(0) : true;
+		let sameDrive: bool = Project.raw.envmap != null ? Project.filepath.charAt(0) == Project.raw.envmap.charAt(0) : true;
 		///end
 
 		Project.raw = {
@@ -105,7 +105,7 @@ class ExportArm {
 			assets: texture_files,
 			packed_assets: packed_assets,
 			swatches: Project.raw.swatches,
-			envmap: Project.raw.envmap != null ? (sameDrive ? Path.toRelative(Project.filepath, Project.raw.envmap) : Project.raw.envmap) : null,
+			envmap: Project.raw.envmap != null ? (sameDrive ? Path.to_relative(Project.filepath, Project.raw.envmap) : Project.raw.envmap) : null,
 			envmap_strength: scene_world.strength,
 			camera_world: mat4_to_f32_array(scene_camera.base.transform.local),
 			camera_origin: ExportArm.vec3f32(Camera.origins[0]),
@@ -121,8 +121,8 @@ class ExportArm {
 			///end
 
 			///if is_paint
-			atlas_objects: Project.atlasObjects,
-			atlas_names: Project.atlasNames,
+			atlas_objects: Project.atlas_objects,
+			atlas_names: Project.atlas_names,
 			///end
 
 			///if is_lab
@@ -138,9 +138,9 @@ class ExportArm {
 		};
 
 		///if (krom_android || krom_ios)
-		let tex = render_path_render_targets.get(Context.raw.renderMode == RenderMode.RenderForward ? "buf" : "tex")._image;
-		let mesh_icon = image_create_render_target(256, 256);
-		let r = app_w() / app_h();
+		let tex: image_t = render_path_render_targets.get(Context.raw.render_mode == render_mode_t.FORWARD ? "buf" : "tex")._image;
+		let mesh_icon: image_t = image_create_render_target(256, 256);
+		let r: f32 = app_w() / app_h();
 		g2_begin(mesh_icon);
 		///if krom_opengl
 		g2_draw_scaled_image(tex, -(256 * r - 256) / 2, 256, 256 * r, -256);
@@ -153,15 +153,15 @@ class ExportArm {
 		g2_begin(mesh_icon);
 		g2_end();
 		///end
-		let mesh_icon_pixels = image_get_pixels(mesh_icon);
-		let u8a = new Uint8Array(mesh_icon_pixels);
-		for (let i = 0; i < 256 * 256 * 4; ++i) {
+		let mesh_icon_pixels: buffer_t = image_get_pixels(mesh_icon);
+		let u8a: Uint8Array = new Uint8Array(mesh_icon_pixels);
+		for (let i: i32 = 0; i < 256 * 256 * 4; ++i) {
 			u8a[i] = Math.floor(Math.pow(u8a[i] / 255, 1.0 / 2.2) * 255);
 		}
 		///if (krom_metal || krom_vulkan)
-		ExportArm.bgraSwap(mesh_icon_pixels);
+		ExportArm.bgra_swap(mesh_icon_pixels);
 		///end
-		Base.notifyOnNextFrame(() => {
+		Base.notify_on_next_frame(() => {
 			image_unload(mesh_icon);
 		});
 		// Project.raw.mesh_icons =
@@ -174,22 +174,22 @@ class ExportArm {
 		///end
 
 		///if (is_paint || is_sculpt)
-		let isPacked = Project.filepath.endsWith("_packed_.arm");
+		let isPacked: bool = Project.filepath.endsWith("_packed_.arm");
 		if (isPacked) { // Pack textures
-			ExportArm.packAssets(Project.raw, Project.assets);
+			ExportArm.pack_assets(Project.raw, Project.assets);
 		}
 		///end
 
-		let buffer = armpack_encode(Project.raw);
+		let buffer: buffer_t = armpack_encode(Project.raw);
 		krom_file_save_bytes(Project.filepath, buffer, buffer.byteLength + 1);
 
 		// Save to recent
 		///if krom_ios
-		let recent_path = Project.filepath.substr(Project.filepath.lastIndexOf("/") + 1);
+		let recent_path: string = Project.filepath.substr(Project.filepath.lastIndexOf("/") + 1);
 		///else
-		let recent_path = Project.filepath;
+		let recent_path: string = Project.filepath;
 		///end
-		let recent = Config.raw.recent_projects;
+		let recent: string[] = Config.raw.recent_projects;
 		array_remove(recent, recent_path);
 		recent.unshift(recent_path);
 		Config.save();
@@ -197,7 +197,7 @@ class ExportArm {
 		Console.info(tr("Project saved"));
 	}
 
-	static textureNodeName = (): string => {
+	static texture_node_name = (): string => {
 		///if (is_paint || is_sculpt)
 		return "TEX_IMAGE";
 		///else
@@ -205,13 +205,13 @@ class ExportArm {
 		///end
 	}
 
-	static exportNode = (n: zui_node_t, assets: TAsset[] = null) => {
-		if (n.type == ExportArm.textureNodeName()) {
-			let index = n.buttons[0].default_value;
-			n.buttons[0].data = Base.enumTexts(n.type)[index];
+	static export_node = (n: zui_node_t, assets: asset_t[] = null) => {
+		if (n.type == ExportArm.texture_node_name()) {
+			let index: i32 = n.buttons[0].default_value;
+			n.buttons[0].data = Base.enum_texts(n.type)[index];
 
 			if (assets != null) {
-				let asset = Project.assets[index];
+				let asset: asset_t = Project.assets[index];
 				if (assets.indexOf(asset) == -1) {
 					assets.push(asset);
 				}
@@ -224,36 +224,36 @@ class ExportArm {
 	}
 
 	///if (is_paint || is_sculpt)
-	static runMaterial = (path: string) => {
+	static run_material = (path: string) => {
 		if (!path.endsWith(".arm")) path += ".arm";
 		let mnodes: zui_node_canvas_t[] = [];
 		let mgroups: zui_node_canvas_t[] = null;
-		let m = Context.raw.material;
+		let m: SlotMaterialRaw = Context.raw.material;
 		let c: zui_node_canvas_t = JSON.parse(JSON.stringify(m.canvas));
-		let assets: TAsset[] = [];
-		if (UINodes.hasGroup(c)) {
+		let assets: asset_t[] = [];
+		if (UINodes.has_group(c)) {
 			mgroups = [];
-			UINodes.traverseGroup(mgroups, c);
-			for (let gc of mgroups) for (let n of gc.nodes) ExportArm.exportNode(n, assets);
+			UINodes.traverse_group(mgroups, c);
+			for (let gc of mgroups) for (let n of gc.nodes) ExportArm.export_node(n, assets);
 		}
-		for (let n of c.nodes) ExportArm.exportNode(n, assets);
+		for (let n of c.nodes) ExportArm.export_node(n, assets);
 		mnodes.push(c);
 
-		let texture_files = ExportArm.assetsToFiles(path, assets);
-		let isCloud = path.endsWith("_cloud_.arm");
+		let texture_files: string[] = ExportArm.assets_to_files(path, assets);
+		let isCloud: bool = path.endsWith("_cloud_.arm");
 		if (isCloud) path = string_replace_all(path, "_cloud_", "");
-		let packed_assets: TPackedAsset[] = null;
-		if (!Context.raw.packAssetsOnExport) {
-			packed_assets = ExportArm.getPackedAssets(path, texture_files);
+		let packed_assets: packed_asset_t[] = null;
+		if (!Context.raw.pack_assets_on_export) {
+			packed_assets = ExportArm.get_packed_assets(path, texture_files);
 		}
 
-		let raw: TProjectFormat = {
+		let raw: project_format_t = {
 			version: manifest_version,
 			material_nodes: mnodes,
 			material_groups: mgroups,
 			material_icons: isCloud ? null :
 				///if (krom_metal || krom_vulkan)
-				[lz4_encode(ExportArm.bgraSwap(image_get_pixels(m.image)))],
+				[lz4_encode(ExportArm.bgra_swap(image_get_pixels(m.image)))],
 				///else
 				[lz4_encode(image_get_pixels(m.image))],
 				///end
@@ -261,27 +261,27 @@ class ExportArm {
 			packed_assets: packed_assets
 		};
 
-		if (Context.raw.writeIconOnExport) { // Separate icon files
+		if (Context.raw.write_icon_on_export) { // Separate icon files
 			krom_write_png(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(m.image), m.image.width, m.image.height, 0);
 			if (isCloud) {
 				krom_write_jpg(path.substr(0, path.length - 4) + "_icon.jpg", image_get_pixels(m.image), m.image.width, m.image.height, 0, 50);
 			}
 		}
 
-		if (Context.raw.packAssetsOnExport) { // Pack textures
-			ExportArm.packAssets(raw, assets);
+		if (Context.raw.pack_assets_on_export) { // Pack textures
+			ExportArm.pack_assets(raw, assets);
 		}
 
-		let buffer = armpack_encode(raw);
+		let buffer: buffer_t = armpack_encode(raw);
 		krom_file_save_bytes(path, buffer, buffer.byteLength + 1);
 	}
 	///end
 
 	///if (krom_metal || krom_vulkan)
-	static bgraSwap = (buffer: ArrayBuffer) => {
-		let view = new DataView(buffer);
-		for (let i = 0; i < Math.floor(buffer.byteLength / 4); ++i) {
-			let r = view.getUint8(i * 4);
+	static bgra_swap = (buffer: ArrayBuffer) => {
+		let view: DataView = new DataView(buffer);
+		for (let i: i32 = 0; i < Math.floor(buffer.byteLength / 4); ++i) {
+			let r: i32 = view.getUint8(i * 4);
 			view.setUint8(i * 4, view.getUint8(i * 4 + 2));
 			view.setUint8(i * 4 + 2, r);
 		}
@@ -290,29 +290,29 @@ class ExportArm {
 	///end
 
 	///if (is_paint || is_sculpt)
-	static runBrush = (path: string) => {
+	static run_brush = (path: string) => {
 		if (!path.endsWith(".arm")) path += ".arm";
 		let bnodes: zui_node_canvas_t[] = [];
-		let b = Context.raw.brush;
+		let b: SlotBrushRaw = Context.raw.brush;
 		let c: zui_node_canvas_t = JSON.parse(JSON.stringify(b.canvas));
-		let assets: TAsset[] = [];
-		for (let n of c.nodes) ExportArm.exportNode(n, assets);
+		let assets: asset_t[] = [];
+		for (let n of c.nodes) ExportArm.export_node(n, assets);
 		bnodes.push(c);
 
-		let texture_files = ExportArm.assetsToFiles(path, assets);
-		let isCloud = path.endsWith("_cloud_.arm");
+		let texture_files: string[] = ExportArm.assets_to_files(path, assets);
+		let isCloud: bool = path.endsWith("_cloud_.arm");
 		if (isCloud) path = string_replace_all(path, "_cloud_", "");
-		let packed_assets: TPackedAsset[] = null;
-		if (!Context.raw.packAssetsOnExport) {
-			packed_assets = ExportArm.getPackedAssets(path, texture_files);
+		let packed_assets: packed_asset_t[] = null;
+		if (!Context.raw.pack_assets_on_export) {
+			packed_assets = ExportArm.get_packed_assets(path, texture_files);
 		}
 
-		let raw: TProjectFormat = {
+		let raw: project_format_t = {
 			version: manifest_version,
 			brush_nodes: bnodes,
 			brush_icons: isCloud ? null :
 			///if (krom_metal || krom_vulkan)
-			[lz4_encode(ExportArm.bgraSwap(image_get_pixels(b.image)))],
+			[lz4_encode(ExportArm.bgra_swap(image_get_pixels(b.image)))],
 			///else
 			[lz4_encode(image_get_pixels(b.image))],
 			///end
@@ -320,30 +320,30 @@ class ExportArm {
 			packed_assets: packed_assets
 		};
 
-		if (Context.raw.writeIconOnExport) { // Separate icon file
+		if (Context.raw.write_icon_on_export) { // Separate icon file
 			krom_write_png(path.substr(0, path.length - 4) + "_icon.png", image_get_pixels(b.image), b.image.width, b.image.height, 0);
 		}
 
-		if (Context.raw.packAssetsOnExport) { // Pack textures
-			ExportArm.packAssets(raw, assets);
+		if (Context.raw.pack_assets_on_export) { // Pack textures
+			ExportArm.pack_assets(raw, assets);
 		}
 
-		let buffer = armpack_encode(raw);
+		let buffer: buffer_t = armpack_encode(raw);
 		krom_file_save_bytes(path, buffer, buffer.byteLength + 1);
 	}
 	///end
 
-	static assetsToFiles = (projectPath: string, assets: TAsset[]): string[] => {
+	static assets_to_files = (projectPath: string, assets: asset_t[]): string[] => {
 		let texture_files: string[] = [];
 		for (let a of assets) {
 			///if krom_ios
-			let sameDrive = false;
+			let sameDrive: bool = false;
 			///else
-			let sameDrive = projectPath.charAt(0) == a.file.charAt(0);
+			let sameDrive: bool = projectPath.charAt(0) == a.file.charAt(0);
 			///end
 			// Convert image path from absolute to relative
 			if (sameDrive) {
-				texture_files.push(Path.toRelative(projectPath, a.file));
+				texture_files.push(Path.to_relative(projectPath, a.file));
 			}
 			else {
 				texture_files.push(a.file);
@@ -353,17 +353,17 @@ class ExportArm {
 	}
 
 	///if (is_paint || is_sculpt)
-	static meshesToFiles = (projectPath: string): string[] => {
+	static meshes_to_files = (projectPath: string): string[] => {
 		let mesh_files: string[] = [];
-		for (let file of Project.meshAssets) {
+		for (let file of Project.mesh_assets) {
 			///if krom_ios
-			let sameDrive = false;
+			let sameDrive: bool = false;
 			///else
-			let sameDrive = projectPath.charAt(0) == file.charAt(0);
+			let sameDrive: bool = projectPath.charAt(0) == file.charAt(0);
 			///end
 			// Convert mesh path from absolute to relative
 			if (sameDrive) {
-				mesh_files.push(Path.toRelative(projectPath, file));
+				mesh_files.push(Path.to_relative(projectPath, file));
 			}
 			else {
 				mesh_files.push(file);
@@ -372,18 +372,18 @@ class ExportArm {
 		return mesh_files;
 	}
 
-	static fontsToFiles = (projectPath: string, fonts: SlotFontRaw[]): string[] => {
+	static fonts_to_files = (projectPath: string, fonts: SlotFontRaw[]): string[] => {
 		let font_files: string[] = [];
 		for (let i = 1; i <fonts.length; ++i) {
-			let f = fonts[i];
+			let f: SlotFontRaw = fonts[i];
 			///if krom_ios
-			let sameDrive = false;
+			let sameDrive: bool = false;
 			///else
-			let sameDrive = projectPath.charAt(0) == f.file.charAt(0);
+			let sameDrive: bool = projectPath.charAt(0) == f.file.charAt(0);
 			///end
 			// Convert font path from absolute to relative
 			if (sameDrive) {
-				font_files.push(Path.toRelative(projectPath, f.file));
+				font_files.push(Path.to_relative(projectPath, f.file));
 			}
 			else {
 				font_files.push(f.file);
@@ -393,17 +393,17 @@ class ExportArm {
 	}
 	///end
 
-	static getPackedAssets = (projectPath: string, texture_files: string[]): TPackedAsset[] => {
-		let packed_assets: TPackedAsset[] = null;
+	static get_packed_assets = (projectPath: string, texture_files: string[]): packed_asset_t[] => {
+		let packed_assets: packed_asset_t[] = null;
 		if (Project.raw.packed_assets != null) {
 			for (let pa of Project.raw.packed_assets) {
 				///if krom_ios
-				let sameDrive = false;
+				let sameDrive: bool = false;
 				///else
-				let sameDrive = projectPath.charAt(0) == pa.name.charAt(0);
+				let sameDrive: bool = projectPath.charAt(0) == pa.name.charAt(0);
 				///end
 				// Convert path from absolute to relative
-				pa.name = sameDrive ? Path.toRelative(projectPath, pa.name) : pa.name;
+				pa.name = sameDrive ? Path.to_relative(projectPath, pa.name) : pa.name;
 				for (let tf of texture_files) {
 					if (pa.name == tf) {
 						if (packed_assets == null) {
@@ -418,15 +418,15 @@ class ExportArm {
 		return packed_assets;
 	}
 
-	static packAssets = (raw: TProjectFormat, assets: TAsset[]) => {
+	static pack_assets = (raw: project_format_t, assets: asset_t[]) => {
 		if (raw.packed_assets == null) {
 			raw.packed_assets = [];
 		}
 		let tempImages: image_t[] = [];
-		for (let i = 0; i < assets.length; ++i) {
-			if (!Project.packedAssetExists(raw.packed_assets, assets[i].file)) {
-				let image = Project.getImage(assets[i]);
-				let temp = image_create_render_target(image.width, image.height);
+		for (let i: i32 = 0; i < assets.length; ++i) {
+			if (!Project.packed_asset_exists(raw.packed_assets, assets[i].file)) {
+				let image: image_t = Project.get_image(assets[i]);
+				let temp: image_t = image_create_render_target(image.width, image.height);
 				g2_begin(temp);
 				g2_draw_image(image, 0, 0);
 				g2_end();
@@ -439,23 +439,23 @@ class ExportArm {
 				});
 			}
 		}
-		Base.notifyOnNextFrame(() => {
+		Base.notify_on_next_frame(() => {
 			for (let image of tempImages) image_unload(image);
 		});
 	}
 
-	static runSwatches = (path: string) => {
+	static run_swatches = (path: string) => {
 		if (!path.endsWith(".arm")) path += ".arm";
-		let raw = {
+		let raw: any = {
 			version: manifest_version,
 			swatches: Project.raw.swatches
 		};
-		let buffer = armpack_encode(raw);
+		let buffer: buffer_t = armpack_encode(raw);
 		krom_file_save_bytes(path, buffer, buffer.byteLength + 1);
 	}
 
 	static vec3f32 = (v: vec4_t): Float32Array => {
-		let res = new Float32Array(3);
+		let res: Float32Array = new Float32Array(3);
 		res[0] = v.x;
 		res[1] = v.y;
 		res[2] = v.z;

+ 2 - 2
base/Sources/ExportGpl.ts

@@ -1,8 +1,8 @@
 
 class ExportGpl {
 
-	static run = (path: string, name: string, swatches: TSwatchColor[]) => {
-		let o = "";
+	static run = (path: string, name: string, swatches: swatch_color_t[]) => {
+		let o: string = "";
 		o += "GIMP Palette\n";
 		o += "Name: " + name + "\n";
 		o += "# armorpaint.org\n";

+ 4 - 4
base/Sources/ExportMesh.ts

@@ -1,9 +1,9 @@
 
 class ExportMesh {
 
-	static run = (path: string, paintObjects: mesh_object_t[] = null, applyDisplacement = false) => {
-		if (paintObjects == null) paintObjects = Project.paintObjects;
-		if (Context.raw.exportMeshFormat == MeshFormat.FormatObj) ExportObj.run(path, paintObjects, applyDisplacement);
-		else ExportArm.runMesh(path, paintObjects);
+	static run = (path: string, paintObjects: mesh_object_t[] = null, applyDisplacement: bool = false) => {
+		if (paintObjects == null) paintObjects = Project.paint_objects;
+		if (Context.raw.export_mesh_format == mesh_format_t.OBJ) ExportObj.run(path, paintObjects, applyDisplacement);
+		else ExportArm.run_mesh(path, paintObjects);
 	}
 }

+ 89 - 89
base/Sources/ExportObj.ts

@@ -1,42 +1,42 @@
 
 class ExportObj {
 
-	static writeString = (out: i32[], str: string) => {
-		for (let i = 0; i < str.length; ++i) {
+	static write_string = (out: i32[], str: string) => {
+		for (let i: i32 = 0; i < str.length; ++i) {
 			out.push(str.charCodeAt(i));
 		}
 	}
 
-	static run = (path: string, paintObjects: mesh_object_t[], applyDisplacement = false) => {
+	static run = (path: string, paintObjects: mesh_object_t[], applyDisplacement: bool = false) => {
 		let o: i32[] = [];
-		ExportObj.writeString(o, "# armorpaint.org\n");
+		ExportObj.write_string(o, "# armorpaint.org\n");
 
-		let poff = 0;
-		let noff = 0;
-		let toff = 0;
+		let poff: i32 = 0;
+		let noff: i32 = 0;
+		let toff: i32 = 0;
 		for (let p of paintObjects) {
-			let mesh = p.data;
-			let inv = 1 / 32767;
-			let sc = p.data.scale_pos * inv;
-			let posa = mesh.vertex_arrays[0].values;
-			let nora = mesh.vertex_arrays[1].values;
-			let texa = mesh.vertex_arrays[2].values;
-			let len = Math.floor(posa.length / 4);
+			let mesh: mesh_data_t = p.data;
+			let inv: f32 = 1 / 32767;
+			let sc: f32 = p.data.scale_pos * inv;
+			let posa: i16_array_t = mesh.vertex_arrays[0].values;
+			let nora: i16_array_t = mesh.vertex_arrays[1].values;
+			let texa: i16_array_t = mesh.vertex_arrays[2].values;
+			let len: i32 = Math.floor(posa.length / 4);
 
 			// Merge shared vertices and remap indices
-			let posa2 = new Int16Array(len * 3);
-			let nora2 = new Int16Array(len * 3);
-			let texa2 = new Int16Array(len * 2);
-			let posmap = new Map<i32, i32>();
-			let normap = new Map<i32, i32>();
-			let texmap = new Map<i32, i32>();
+			let posa2: Int16Array = new Int16Array(len * 3);
+			let nora2: Int16Array = new Int16Array(len * 3);
+			let texa2: Int16Array = new Int16Array(len * 2);
+			let posmap: Map<i32, i32> = new Map();
+			let normap: Map<i32, i32> = new Map();
+			let texmap: Map<i32, i32> = new Map();
 
-			let pi = 0;
-			let ni = 0;
-			let ti = 0;
-			for (let i = 0; i < len; ++i) {
-				let found = false;
-				for (let j = 0; j < pi; ++j) {
+			let pi: i32 = 0;
+			let ni: i32 = 0;
+			let ti: i32 = 0;
+			for (let i: i32 = 0; i < len; ++i) {
+				let found: bool = false;
+				for (let j: i32 = 0; j < pi; ++j) {
 					if (posa2[j * 3    ] == posa[i * 4    ] &&
 						posa2[j * 3 + 1] == posa[i * 4 + 1] &&
 						posa2[j * 3 + 2] == posa[i * 4 + 2]) {
@@ -54,7 +54,7 @@ class ExportObj {
 				}
 
 				found = false;
-				for (let j = 0; j < ni; ++j) {
+				for (let j: i32 = 0; j < ni; ++j) {
 					if (nora2[j * 3    ] == nora[i * 2    ] &&
 						nora2[j * 3 + 1] == nora[i * 2 + 1] &&
 						nora2[j * 3 + 2] == posa[i * 4 + 3]) {
@@ -72,7 +72,7 @@ class ExportObj {
 				}
 
 				found = false;
-				for (let j = 0; j < ti; ++j) {
+				for (let j: i32 = 0; j < ti; ++j) {
 					if (texa2[j * 2    ] == texa[i * 2    ] &&
 						texa2[j * 2 + 1] == texa[i * 2 + 1]) {
 						texmap.set(i, j);
@@ -89,76 +89,76 @@ class ExportObj {
 			}
 
 			if (applyDisplacement) {
-				// let height = Project.layers[0].texpaint_pack.getPixels();
-				// let res = Project.layers[0].texpaint_pack.width;
-				// let strength = 0.1;
-				// for (let i = 0; i < len; ++i) {
-				// 	let x = Math.floor(texa2[i * 2    ] / 32767 * res);
-				// 	let y = Math.floor((1.0 - texa2[i * 2 + 1] / 32767) * res);
-				// 	let h = (1.0 - height.get((y * res + x) * 4 + 3) / 255) * strength;
+				// let height: buffer_t = Project.layers[0].texpaint_pack.getPixels();
+				// let res: i32 = Project.layers[0].texpaint_pack.width;
+				// let strength: f32 = 0.1;
+				// for (let i: i32 = 0; i < len; ++i) {
+				// 	let x: i32 = Math.floor(texa2[i * 2    ] / 32767 * res);
+				// 	let y: i32 = Math.floor((1.0 - texa2[i * 2 + 1] / 32767) * res);
+				// 	let h: f32 = (1.0 - height.get((y * res + x) * 4 + 3) / 255) * strength;
 				// 	posa2[i * 3    ] -= Math.floor(nora2[i * 3    ] * inv * h / sc);
 				// 	posa2[i * 3 + 1] -= Math.floor(nora2[i * 3 + 1] * inv * h / sc);
 				// 	posa2[i * 3 + 2] -= Math.floor(nora2[i * 3 + 2] * inv * h / sc);
 				// }
 			}
 
-			ExportObj.writeString(o, "o " + p.base.name + "\n");
-			for (let i = 0; i < pi; ++i) {
-				ExportObj.writeString(o, "v ");
-				ExportObj.writeString(o, posa2[i * 3] * sc + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, posa2[i * 3 + 2] * sc + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, -posa2[i * 3 + 1] * sc + "");
-				ExportObj.writeString(o, "\n");
+			ExportObj.write_string(o, "o " + p.base.name + "\n");
+			for (let i: i32 = 0; i < pi; ++i) {
+				ExportObj.write_string(o, "v ");
+				ExportObj.write_string(o, posa2[i * 3] * sc + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, posa2[i * 3 + 2] * sc + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, -posa2[i * 3 + 1] * sc + "");
+				ExportObj.write_string(o, "\n");
 			}
-			for (let i = 0; i < ni; ++i) {
-				ExportObj.writeString(o, "vn ");
-				ExportObj.writeString(o, nora2[i * 3] * inv + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, nora2[i * 3 + 2] * inv + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, -nora2[i * 3 + 1] * inv + "");
-				ExportObj.writeString(o, "\n");
+			for (let i: i32 = 0; i < ni; ++i) {
+				ExportObj.write_string(o, "vn ");
+				ExportObj.write_string(o, nora2[i * 3] * inv + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, nora2[i * 3 + 2] * inv + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, -nora2[i * 3 + 1] * inv + "");
+				ExportObj.write_string(o, "\n");
 			}
-			for (let i = 0; i < ti; ++i) {
-				ExportObj.writeString(o, "vt ");
-				ExportObj.writeString(o, texa2[i * 2] * inv + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, 1.0 - texa2[i * 2 + 1] * inv + "");
-				ExportObj.writeString(o, "\n");
+			for (let i: i32 = 0; i < ti; ++i) {
+				ExportObj.write_string(o, "vt ");
+				ExportObj.write_string(o, texa2[i * 2] * inv + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, 1.0 - texa2[i * 2 + 1] * inv + "");
+				ExportObj.write_string(o, "\n");
 			}
 
-			let inda = mesh.index_arrays[0].values;
-			for (let i = 0; i < Math.floor(inda.length / 3); ++i) {
-				let pi1 = posmap.get(inda[i * 3    ]) + 1 + poff;
-				let pi2 = posmap.get(inda[i * 3 + 1]) + 1 + poff;
-				let pi3 = posmap.get(inda[i * 3 + 2]) + 1 + poff;
-				let ni1 = normap.get(inda[i * 3    ]) + 1 + noff;
-				let ni2 = normap.get(inda[i * 3 + 1]) + 1 + noff;
-				let ni3 = normap.get(inda[i * 3 + 2]) + 1 + noff;
-				let ti1 = texmap.get(inda[i * 3    ]) + 1 + toff;
-				let ti2 = texmap.get(inda[i * 3 + 1]) + 1 + toff;
-				let ti3 = texmap.get(inda[i * 3 + 2]) + 1 + toff;
-				ExportObj.writeString(o, "f ");
-				ExportObj.writeString(o, pi1 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ti1 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ni1 + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, pi2 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ti2 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ni2 + "");
-				ExportObj.writeString(o, " ");
-				ExportObj.writeString(o, pi3 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ti3 + "");
-				ExportObj.writeString(o, "/");
-				ExportObj.writeString(o, ni3 + "");
-				ExportObj.writeString(o, "\n");
+			let inda: u32_array_t = mesh.index_arrays[0].values;
+			for (let i: i32 = 0; i < Math.floor(inda.length / 3); ++i) {
+				let pi1: i32 = posmap.get(inda[i * 3    ]) + 1 + poff;
+				let pi2: i32 = posmap.get(inda[i * 3 + 1]) + 1 + poff;
+				let pi3: i32 = posmap.get(inda[i * 3 + 2]) + 1 + poff;
+				let ni1: i32 = normap.get(inda[i * 3    ]) + 1 + noff;
+				let ni2: i32 = normap.get(inda[i * 3 + 1]) + 1 + noff;
+				let ni3: i32 = normap.get(inda[i * 3 + 2]) + 1 + noff;
+				let ti1: i32 = texmap.get(inda[i * 3    ]) + 1 + toff;
+				let ti2: i32 = texmap.get(inda[i * 3 + 1]) + 1 + toff;
+				let ti3: i32 = texmap.get(inda[i * 3 + 2]) + 1 + toff;
+				ExportObj.write_string(o, "f ");
+				ExportObj.write_string(o, pi1 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ti1 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ni1 + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, pi2 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ti2 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ni2 + "");
+				ExportObj.write_string(o, " ");
+				ExportObj.write_string(o, pi3 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ti3 + "");
+				ExportObj.write_string(o, "/");
+				ExportObj.write_string(o, ni3 + "");
+				ExportObj.write_string(o, "\n");
 			}
 			poff += pi;
 			noff += ni;
@@ -167,7 +167,7 @@ class ExportObj {
 
 		if (!path.endsWith(".obj")) path += ".obj";
 
-		let b = Uint8Array.from(o).buffer;
+		let b: ArrayBuffer = Uint8Array.from(o).buffer;
 		krom_file_save_bytes(path, b, b.byteLength);
 	}
 }

+ 161 - 162
base/Sources/ExportTexture.ts

@@ -3,75 +3,75 @@
 
 class ExportTexture {
 
-	static gamma = 1.0 / 2.2;
+	static gamma: f32 = 1.0 / 2.2;
 
-	static run = (path: string, bakeMaterial = false) => {
+	static run = (path: string, bakeMaterial: bool = false) => {
 
 		///if is_paint
 		if (bakeMaterial) {
-			ExportTexture.runBakeMaterial(path);
+			ExportTexture.run_bake_material(path);
 		}
-		else if (Context.raw.layersExport == ExportMode.ExportPerUdimTile) {
+		else if (Context.raw.layers_export == export_mode_t.PER_UDIM_TILE) {
 			let udimTiles: string[] = [];
 			for (let l of Project.layers) {
-				if (SlotLayer.getObjectMask(l) > 0) {
-					let name = Project.paintObjects[SlotLayer.getObjectMask(l) - 1].base.name;
+				if (SlotLayer.get_object_mask(l) > 0) {
+					let name: string = Project.paint_objects[SlotLayer.get_object_mask(l) - 1].base.name;
 					if (name.substr(name.length - 5, 2) == ".1") { // tile.1001
 						udimTiles.push(name.substr(name.length - 5));
 					}
 				}
 			}
 			if (udimTiles.length > 0) {
-				for (let udimTile of udimTiles) ExportTexture.runLayers(path, Project.layers, udimTile);
+				for (let udimTile of udimTiles) ExportTexture.run_layers(path, Project.layers, udimTile);
 			}
-			else ExportTexture.runLayers(path, Project.layers);
+			else ExportTexture.run_layers(path, Project.layers);
 		}
-		else if (Context.raw.layersExport == ExportMode.ExportPerObject) {
+		else if (Context.raw.layers_export == export_mode_t.PER_OBJECT) {
 			let objectNames: string[] = [];
 			for (let l of Project.layers) {
-				if (SlotLayer.getObjectMask(l) > 0) {
-					let name = Project.paintObjects[SlotLayer.getObjectMask(l) - 1].base.name;
+				if (SlotLayer.get_object_mask(l) > 0) {
+					let name: string = Project.paint_objects[SlotLayer.get_object_mask(l) - 1].base.name;
 					if (objectNames.indexOf(name) == -1) {
 						objectNames.push(name);
 					}
 				}
 			}
 			if (objectNames.length > 0) {
-				for (let name of objectNames) ExportTexture.runLayers(path, Project.layers, name);
+				for (let name of objectNames) ExportTexture.run_layers(path, Project.layers, name);
 			}
-			else ExportTexture.runLayers(path, Project.layers);
+			else ExportTexture.run_layers(path, Project.layers);
 		}
 		else { // Visible or selected
-			let atlasExport = false;
-			if (Project.atlasObjects != null) {
-				for (let i = 1; i < Project.atlasObjects.length; ++i) {
-					if (Project.atlasObjects[i - 1] != Project.atlasObjects[i]) {
+			let atlasExport: bool = false;
+			if (Project.atlas_objects != null) {
+				for (let i: i32 = 1; i < Project.atlas_objects.length; ++i) {
+					if (Project.atlas_objects[i - 1] != Project.atlas_objects[i]) {
 						atlasExport = true;
 						break;
 					}
 				}
 			}
 			if (atlasExport) {
-				for (let atlasIndex = 0; atlasIndex < Project.atlasObjects.length; ++atlasIndex) {
+				for (let atlasIndex: i32 = 0; atlasIndex < Project.atlas_objects.length; ++atlasIndex) {
 					let layers: SlotLayerRaw[] = [];
-					for (let objectIndex = 0; objectIndex < Project.atlasObjects.length; ++objectIndex) {
-						if (Project.atlasObjects[objectIndex] == atlasIndex) {
+					for (let objectIndex: i32 = 0; objectIndex < Project.atlas_objects.length; ++objectIndex) {
+						if (Project.atlas_objects[objectIndex] == atlasIndex) {
 							for (let l of Project.layers) {
-								if (SlotLayer.getObjectMask(l) == 0 /* shared object */ || SlotLayer.getObjectMask(l) - 1 == objectIndex) layers.push(l);
+								if (SlotLayer.get_object_mask(l) == 0 /* shared object */ || SlotLayer.get_object_mask(l) - 1 == objectIndex) layers.push(l);
 							}
 						}
 					}
 					if (layers.length > 0) {
-						ExportTexture.runLayers(path, layers, Project.atlasNames[atlasIndex]);
+						ExportTexture.run_layers(path, layers, Project.atlas_names[atlasIndex]);
 					}
 				}
 			}
-			else ExportTexture.runLayers(path, Context.raw.layersExport == ExportMode.ExportSelected ? (SlotLayer.isGroup(Context.raw.layer) ? SlotLayer.getChildren(Context.raw.layer) : [Context.raw.layer]) : Project.layers);
+			else ExportTexture.run_layers(path, Context.raw.layers_export == export_mode_t.SELECTED ? (SlotLayer.is_group(Context.raw.layer) ? SlotLayer.get_children(Context.raw.layer) : [Context.raw.layer]) : Project.layers);
 		}
 		///end
 
 		///if is_lab
-		ExportTexture.runLayers(path, [BrushOutputNode.inst]);
+		ExportTexture.run_layers(path, [BrushOutputNode.inst]);
 		///end
 
 		///if krom_ios
@@ -81,72 +81,71 @@ class ExportTexture {
 		///else
 		Console.info(tr("Textures exported"));
 		///end
-		UIFiles.lastPath = "";
+		UIFiles.last_path = "";
 	}
 
 	///if is_paint
-	static runBakeMaterial = (path: string) => {
+	static run_bake_material = (path: string) => {
 		if (RenderPathPaint.liveLayer == null) {
 			RenderPathPaint.liveLayer = SlotLayer.create("_live");
 		}
 
-		let _tool = Context.raw.tool;
-		Context.raw.tool = WorkspaceTool.ToolFill;
-		MakeMaterial.parsePaintMaterial();
-		let _paintObject = Context.raw.paintObject;
+		let _tool: workspace_tool_t = Context.raw.tool;
+		Context.raw.tool = workspace_tool_t.FILL;
+		MakeMaterial.parse_paint_material();
+		let _paintObject: mesh_object_t = Context.raw.paint_object;
 		let planeo: mesh_object_t = scene_get_child(".Plane").ext;
 		planeo.base.visible = true;
-		Context.raw.paintObject = planeo;
+		Context.raw.paint_object = planeo;
 		Context.raw.pdirty = 1;
-		RenderPathPaint.useLiveLayer(true);
-		RenderPathPaint.commandsPaint(false);
-		RenderPathPaint.useLiveLayer(false);
+		RenderPathPaint.use_live_layer(true);
+		RenderPathPaint.commands_paint(false);
+		RenderPathPaint.use_live_layer(false);
 		Context.raw.tool = _tool;
-		MakeMaterial.parsePaintMaterial();
+		MakeMaterial.parse_paint_material();
 		Context.raw.pdirty = 0;
 		planeo.base.visible = false;
-		Context.raw.paintObject = _paintObject;
+		Context.raw.paint_object = _paintObject;
 
-		ExportTexture.runLayers(path, [RenderPathPaint.liveLayer], "", true);
+		ExportTexture.run_layers(path, [RenderPathPaint.liveLayer], "", true);
 	}
 	///end
 
 	///if is_paint
-	static runLayers = (path: string, layers: SlotLayerRaw[], objectName = "", bakeMaterial = false) => {
+	static run_layers = (path: string, layers: SlotLayerRaw[], objectName: string = "", bakeMaterial: bool = false) => {
 	///end
 
 	///if is_lab
-	static runLayers = (path: string, layers: any[], objectName = "") => {
+	static run_layers = (path: string, layers: any[], objectName: string = "") => {
 	///end
 
-		let textureSizeX = Config.getTextureResX();
-		let textureSizeY = Config.getTextureResY();
-		let formatQuality = Context.raw.formatQuality;
+		let textureSizeX: i32 = Config.get_texture_res_x();
+		let textureSizeY: i32 = Config.get_texture_res_y();
 		///if (krom_android || krom_ios)
-		let f = sys_title();
+		let f: string = sys_title();
 		///else
-		let f = UIFiles.filename;
+		let f: string = UIFiles.filename;
 		///end
 		if (f == "") f = tr("untitled");
-		let formatType = Context.raw.formatType;
-		let bits = Base.bitsHandle.position == TextureBits.Bits8 ? 8 : 16;
-		let ext = bits == 16 ? ".exr" : formatType == TextureLdrFormat.FormatPng ? ".png" : ".jpg";
+		let formatType: texture_ldr_format_t = Context.raw.format_type;
+		let bits: i32 = Base.bits_handle.position == texture_bits_t.BITS8 ? 8 : 16;
+		let ext: string = bits == 16 ? ".exr" : formatType == texture_ldr_format_t.PNG ? ".png" : ".jpg";
 		if (f.endsWith(ext)) f = f.substr(0, f.length - 4);
 
 		///if is_paint
-		let isUdim = Context.raw.layersExport == ExportMode.ExportPerUdimTile;
+		let isUdim: bool = Context.raw.layers_export == export_mode_t.PER_UDIM_TILE;
 		if (isUdim) ext = objectName + ext;
 
-		Base.makeTempImg();
-		Base.makeExportImg();
-		if (Base.pipeMerge == null) Base.makePipe();
+		Base.make_temp_img();
+		Base.make_export_img();
+		if (Base.pipe_merge == null) Base.make_pipe();
 		if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data();
-		let empty = render_path_render_targets.get("empty_white")._image;
+		let empty: image_t = render_path_render_targets.get("empty_white")._image;
 
 		// Append object mask name
-		let exportSelected = Context.raw.layersExport == ExportMode.ExportSelected;
-		if (exportSelected && SlotLayer.getObjectMask(layers[0]) > 0) {
-			f += "_" + Project.paintObjects[SlotLayer.getObjectMask(layers[0]) - 1].base.name;
+		let exportSelected: bool = Context.raw.layers_export == export_mode_t.SELECTED;
+		if (exportSelected && SlotLayer.get_object_mask(layers[0]) > 0) {
+			f += "_" + Project.paint_objects[SlotLayer.get_object_mask(layers[0]) - 1].base.name;
 		}
 		if (!isUdim && !exportSelected && objectName != "") {
 			f += "_" + objectName;
@@ -165,46 +164,46 @@ class ExportTexture {
 
 		// Flatten layers
 		for (let l1 of layers) {
-			if (!exportSelected && !SlotLayer.isVisible(l1)) continue;
-			if (!SlotLayer.isLayer(l1)) continue;
+			if (!exportSelected && !SlotLayer.is_visible(l1)) continue;
+			if (!SlotLayer.is_layer(l1)) continue;
 
-			if (objectName != "" && SlotLayer.getObjectMask(l1) > 0) {
-				if (isUdim && !Project.paintObjects[SlotLayer.getObjectMask(l1) - 1].base.name.endsWith(objectName)) continue;
-				let perObject = Context.raw.layersExport == ExportMode.ExportPerObject;
-				if (perObject && Project.paintObjects[SlotLayer.getObjectMask(l1) - 1].base.name != objectName) continue;
+			if (objectName != "" && SlotLayer.get_object_mask(l1) > 0) {
+				if (isUdim && !Project.paint_objects[SlotLayer.get_object_mask(l1) - 1].base.name.endsWith(objectName)) continue;
+				let perObject: bool = Context.raw.layers_export == export_mode_t.PER_OBJECT;
+				if (perObject && Project.paint_objects[SlotLayer.get_object_mask(l1) - 1].base.name != objectName) continue;
 			}
 
-			let mask = empty;
-			let l1masks = SlotLayer.getMasks(l1);
+			let mask: image_t = empty;
+			let l1masks: SlotLayerRaw[] = SlotLayer.get_masks(l1);
 			if (l1masks != null && !bakeMaterial) {
 				if (l1masks.length > 1) {
-					Base.makeTempMaskImg();
-					g2_begin(Base.tempMaskImage);
+					Base.make_temp_mask_img();
+					g2_begin(Base.temp_mask_image);
 					g2_clear(0x00000000);
 					g2_end();
-					let l1: any = { texpaint: Base.tempMaskImage };
-					for (let i = 0; i < l1masks.length; ++i) {
-						Base.mergeLayer(l1, l1masks[i]);
+					let l1: any = { texpaint: Base.temp_mask_image };
+					for (let i: i32 = 0; i < l1masks.length; ++i) {
+						Base.merge_layer(l1, l1masks[i]);
 					}
-					mask = Base.tempMaskImage;
+					mask = Base.temp_mask_image;
 				}
 				else mask = l1masks[0].texpaint;
 			}
 
 			if (l1.paintBase) {
-				g2_begin(Base.tempImage); // Copy to temp
-				g2_set_pipeline(Base.pipeCopy);
+				g2_begin(Base.temp_image); // Copy to temp
+				g2_set_pipeline(Base.pipe_copy);
 				g2_draw_image(Base.expa, 0, 0);
 				g2_set_pipeline(null);
 				g2_end();
 
 				g4_begin(Base.expa);
-				g4_set_pipeline(Base.pipeMerge);
+				g4_set_pipeline(Base.pipe_merge);
 				g4_set_tex(Base.tex0, l1.texpaint);
 				g4_set_tex(Base.tex1, empty);
 				g4_set_tex(Base.texmask, mask);
-				g4_set_tex(Base.texa, Base.tempImage);
-				g4_set_float(Base.opac, SlotLayer.getOpacity(l1));
+				g4_set_tex(Base.texa, Base.temp_image);
+				g4_set_float(Base.opac, SlotLayer.get_opacity(l1));
 				g4_set_int(Base.blending, layers.length > 1 ? l1.blending : 0);
 				g4_set_vertex_buffer(const_data_screen_aligned_vb);
 				g4_set_index_buffer(const_data_screen_aligned_ib);
@@ -213,19 +212,19 @@ class ExportTexture {
 			}
 
 			if (l1.paintNor) {
-				g2_begin(Base.tempImage);
-				g2_set_pipeline(Base.pipeCopy);
+				g2_begin(Base.temp_image);
+				g2_set_pipeline(Base.pipe_copy);
 				g2_draw_image(Base.expb, 0, 0);
 				g2_set_pipeline(null);
 				g2_end();
 
 				g4_begin(Base.expb);
-				g4_set_pipeline(Base.pipeMerge);
+				g4_set_pipeline(Base.pipe_merge);
 				g4_set_tex(Base.tex0, l1.texpaint);
 				g4_set_tex(Base.tex1, l1.texpaint_nor);
 				g4_set_tex(Base.texmask, mask);
-				g4_set_tex(Base.texa, Base.tempImage);
-				g4_set_float(Base.opac, SlotLayer.getOpacity(l1));
+				g4_set_tex(Base.texa, Base.temp_image);
+				g4_set_float(Base.opac, SlotLayer.get_opacity(l1));
 				g4_set_int(Base.blending, l1.paintNorBlend ? -2 : -1);
 				g4_set_vertex_buffer(const_data_screen_aligned_vb);
 				g4_set_index_buffer(const_data_screen_aligned_ib);
@@ -234,19 +233,19 @@ class ExportTexture {
 			}
 
 			if (l1.paintOcc || l1.paintRough || l1.paintMet || l1.paintHeight) {
-				g2_begin(Base.tempImage);
-				g2_set_pipeline(Base.pipeCopy);
+				g2_begin(Base.temp_image);
+				g2_set_pipeline(Base.pipe_copy);
 				g2_draw_image(Base.expc, 0, 0);
 				g2_set_pipeline(null);
 				g2_end();
 
 				if (l1.paintOcc && l1.paintRough && l1.paintMet && l1.paintHeight) {
-					Base.commandsMergePack(Base.pipeMerge, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.getOpacity(l1), mask, l1.paintHeightBlend ? -3 : -1);
+					Base.commands_merge_pack(Base.pipe_merge, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.get_opacity(l1), mask, l1.paintHeightBlend ? -3 : -1);
 				}
 				else {
-					if (l1.paintOcc) Base.commandsMergePack(Base.pipeMergeR, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.getOpacity(l1), mask);
-					if (l1.paintRough) Base.commandsMergePack(Base.pipeMergeG, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.getOpacity(l1), mask);
-					if (l1.paintMet) Base.commandsMergePack(Base.pipeMergeB, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.getOpacity(l1), mask);
+					if (l1.paintOcc) Base.commands_merge_pack(Base.pipe_merge_r, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.get_opacity(l1), mask);
+					if (l1.paintRough) Base.commands_merge_pack(Base.pipe_merge_g, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.get_opacity(l1), mask);
+					if (l1.paintMet) Base.commands_merge_pack(Base.pipe_merge_b, Base.expc, l1.texpaint, l1.texpaint_pack, SlotLayer.get_opacity(l1), mask);
 				}
 			}
 		}
@@ -263,21 +262,21 @@ class ExportTexture {
 		///end
 
 		///if is_paint
-		let texpaint = Base.expa;
-		let texpaint_nor = Base.expb;
-		let texpaint_pack = Base.expc;
+		let texpaint: image_t = Base.expa;
+		let texpaint_nor: image_t = Base.expb;
+		let texpaint_pack: image_t = Base.expc;
 		///end
 
 		///if is_lab
-		let texpaint = BrushOutputNode.inst.texpaint;
-		let texpaint_nor = BrushOutputNode.inst.texpaint_nor;
-		let texpaint_pack = BrushOutputNode.inst.texpaint_pack;
+		let texpaint: image_t = BrushOutputNode.inst.texpaint;
+		let texpaint_nor: image_t = BrushOutputNode.inst.texpaint_nor;
+		let texpaint_pack: image_t = BrushOutputNode.inst.texpaint_pack;
 		///end
 
 		let pixpaint: ArrayBuffer = null;
 		let pixpaint_nor: ArrayBuffer = null;
 		let pixpaint_pack: ArrayBuffer = null;
-		let preset = BoxExport.preset;
+		let preset: export_preset_t = BoxExport.preset;
 		let pix: ArrayBuffer = null;
 
 		for (let t of preset.textures) {
@@ -289,56 +288,56 @@ class ExportTexture {
 		}
 
 		for (let t of preset.textures) {
-			let c = t.channels;
+			let c: string[] = t.channels;
 			let tex_name = t.name != "" ? "_" + t.name : "";
-			let singleChannel = c[0] == c[1] && c[1] == c[2] && c[3] == "1.0";
+			let singleChannel: bool = c[0] == c[1] && c[1] == c[2] && c[3] == "1.0";
 			if (c[0] == "base_r" && c[1] == "base_g" && c[2] == "base_b" && c[3] == "1.0" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint, 1);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint, 1);
 			}
 			else if (c[0] == "nor_r" && c[1] == "nor_g" && c[2] == "nor_b" && c[3] == "1.0" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_nor, 1);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_nor, 1);
 			}
 			else if (c[0] == "occ" && c[1] == "rough" && c[2] == "metal" && c[3] == "1.0" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 1);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 1);
 			}
 			else if (singleChannel && c[0] == "occ" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 0);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 0);
 			}
 			else if (singleChannel && c[0] == "rough" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 1);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 1);
 			}
 			else if (singleChannel && c[0] == "metal" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 2);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 2);
 			}
 			else if (singleChannel && c[0] == "height" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 3);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint_pack, 2, 3);
 			}
 			else if (singleChannel && c[0] == "opac" && t.color_space == "linear") {
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pixpaint, 2, 3);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pixpaint, 2, 3);
 			}
 			else {
 				if (pix == null) pix = new ArrayBuffer(textureSizeX * textureSizeY * 4 * Math.floor(bits / 8));
-				for (let i = 0; i < 4; ++i) {
-					let c = t.channels[i];
-					if      (c == "base_r") ExportTexture.copyChannel(new DataView(pixpaint), 0, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "base_g") ExportTexture.copyChannel(new DataView(pixpaint), 1, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "base_b") ExportTexture.copyChannel(new DataView(pixpaint), 2, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "height") ExportTexture.copyChannel(new DataView(pixpaint_pack), 3, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "metal") ExportTexture.copyChannel(new DataView(pixpaint_pack), 2, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "nor_r") ExportTexture.copyChannel(new DataView(pixpaint_nor), 0, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "nor_g") ExportTexture.copyChannel(new DataView(pixpaint_nor), 1, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "nor_g_directx") ExportTexture.copyChannelInv(new DataView(pixpaint_nor), 1, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "nor_b") ExportTexture.copyChannel(new DataView(pixpaint_nor), 2, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "occ") ExportTexture.copyChannel(new DataView(pixpaint_pack), 0, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "opac") ExportTexture.copyChannel(new DataView(pixpaint), 3, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "rough") ExportTexture.copyChannel(new DataView(pixpaint_pack), 1, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "smooth") ExportTexture.copyChannelInv(new DataView(pixpaint_pack), 1, new DataView(pix), i, t.color_space == "linear");
-					else if (c == "emis") ExportTexture.extractChannel(new DataView(pixpaint_nor), 3, new DataView(pix), i, 3, 1, t.color_space == "linear");
-					else if (c == "subs") ExportTexture.extractChannel(new DataView(pixpaint_nor), 3, new DataView(pix), i, 3, 2, t.color_space == "linear");
-					else if (c == "0.0") ExportTexture.setChannel(0, new DataView(pix), i);
-					else if (c == "1.0") ExportTexture.setChannel(255, new DataView(pix), i);
+				for (let i: i32 = 0; i < 4; ++i) {
+					let c: string = t.channels[i];
+					if      (c == "base_r") ExportTexture.copy_channel(new DataView(pixpaint), 0, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "base_g") ExportTexture.copy_channel(new DataView(pixpaint), 1, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "base_b") ExportTexture.copy_channel(new DataView(pixpaint), 2, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "height") ExportTexture.copy_channel(new DataView(pixpaint_pack), 3, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "metal") ExportTexture.copy_channel(new DataView(pixpaint_pack), 2, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "nor_r") ExportTexture.copy_channel(new DataView(pixpaint_nor), 0, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "nor_g") ExportTexture.copy_channel(new DataView(pixpaint_nor), 1, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "nor_g_directx") ExportTexture.copy_channel_inv(new DataView(pixpaint_nor), 1, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "nor_b") ExportTexture.copy_channel(new DataView(pixpaint_nor), 2, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "occ") ExportTexture.copy_channel(new DataView(pixpaint_pack), 0, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "opac") ExportTexture.copy_channel(new DataView(pixpaint), 3, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "rough") ExportTexture.copy_channel(new DataView(pixpaint_pack), 1, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "smooth") ExportTexture.copy_channel_inv(new DataView(pixpaint_pack), 1, new DataView(pix), i, t.color_space == "linear");
+					else if (c == "emis") ExportTexture.extract_channel(new DataView(pixpaint_nor), 3, new DataView(pix), i, 3, 1, t.color_space == "linear");
+					else if (c == "subs") ExportTexture.extract_channel(new DataView(pixpaint_nor), 3, new DataView(pix), i, 3, 2, t.color_space == "linear");
+					else if (c == "0.0") ExportTexture.set_channel(0, new DataView(pix), i);
+					else if (c == "1.0") ExportTexture.set_channel(255, new DataView(pix), i);
 				}
-				ExportTexture.writeTexture(path + Path.sep + f + tex_name + ext, pix, 3);
+				ExportTexture.write_texture(path + Path.sep + f + tex_name + ext, pix, 3);
 			}
 		}
 
@@ -348,88 +347,88 @@ class ExportTexture {
 		texpaint_pack.pixels = null;
 	}
 
-	static writeTexture = (file: string, pixels: ArrayBuffer, type = 1, off = 0) => {
-		let resX = Config.getTextureResX();
-		let resY = Config.getTextureResY();
-		let bitsHandle = Base.bitsHandle.position;
-		let bits = bitsHandle == TextureBits.Bits8 ? 8 : bitsHandle == TextureBits.Bits16 ? 16 : 32;
-		let format = 0; // RGBA
+	static write_texture = (file: string, pixels: ArrayBuffer, type: i32 = 1, off: i32 = 0) => {
+		let resX: i32 = Config.get_texture_res_x();
+		let resY: i32 = Config.get_texture_res_y();
+		let bitsHandle: i32 = Base.bits_handle.position;
+		let bits: i32 = bitsHandle == texture_bits_t.BITS8 ? 8 : bitsHandle == texture_bits_t.BITS16 ? 16 : 32;
+		let format: i32 = 0; // RGBA
 		if (type == 1) format = 2; // RGB1
 		if (type == 2 && off == 0) format = 3; // RRR1
 		if (type == 2 && off == 1) format = 4; // GGG1
 		if (type == 2 && off == 2) format = 5; // BBB1
 		if (type == 2 && off == 3) format = 6; // AAA1
 
-		if (Context.raw.layersDestination == ExportDestination.DestinationPacked) {
-			let image = image_from_bytes(pixels, resX, resY);
+		if (Context.raw.layers_destination == export_destination_t.PACKED) {
+			let image: image_t = image_from_bytes(pixels, resX, resY);
 			data_cached_images.set(file, image);
-			let ar = file.split(Path.sep);
-			let name = ar[ar.length - 1];
-			let asset: TAsset = {name: name, file: file, id: Project.assetId++};
+			let ar: string[] = file.split(Path.sep);
+			let name: string = ar[ar.length - 1];
+			let asset: asset_t = {name: name, file: file, id: Project.asset_id++};
 			Project.assets.push(asset);
 			if (Project.raw.assets == null) Project.raw.assets = [];
 			Project.raw.assets.push(asset.file);
-			Project.assetNames.push(asset.name);
-			Project.assetMap.set(asset.id, image);
-			ExportArm.packAssets(Project.raw, [asset]);
+			Project.asset_names.push(asset.name);
+			Project.asset_map.set(asset.id, image);
+			ExportArm.pack_assets(Project.raw, [asset]);
 			return;
 		}
 
-		if (bits == 8 && Context.raw.formatType == TextureLdrFormat.FormatPng) {
+		if (bits == 8 && Context.raw.format_type == texture_ldr_format_t.PNG) {
 			krom_write_png(file, pixels, resX, resY, format);
 		}
-		else if (bits == 8 && Context.raw.formatType == TextureLdrFormat.FormatJpg) {
-			krom_write_jpg(file, pixels, resX, resY, format, Math.floor(Context.raw.formatQuality));
+		else if (bits == 8 && Context.raw.format_type == texture_ldr_format_t.JPG) {
+			krom_write_jpg(file, pixels, resX, resY, format, Math.floor(Context.raw.format_quality));
 		}
 		else { // Exr
-			let b = ParserExr.run(resX, resY, pixels, bits, type, off);
+			let b: ArrayBuffer = ParserExr.run(resX, resY, pixels, bits, type, off);
 			krom_file_save_bytes(file, b, b.byteLength);
 		}
 	}
 
-	static copyChannel = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, linear = true) => {
-		for (let i = 0; i < Math.floor(to.byteLength / 4); ++i) {
+	static copy_channel = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, linear: bool = true) => {
+		for (let i: i32 = 0; i < Math.floor(to.byteLength / 4); ++i) {
 			to.setUint8(i * 4 + toChannel, from.getUint8(i * 4 + fromChannel));
 		}
-		if (!linear) ExportTexture.toSrgb(to, toChannel);
+		if (!linear) ExportTexture.to_srgb(to, toChannel);
 	}
 
-	static copyChannelInv = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, linear = true) => {
-		for (let i = 0; i < Math.floor(to.byteLength / 4); ++i) {
+	static copy_channel_inv = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, linear: bool = true) => {
+		for (let i: i32 = 0; i < Math.floor(to.byteLength / 4); ++i) {
 			to.setUint8(i * 4 + toChannel, 255 - from.getUint8(i * 4 + fromChannel));
 		}
-		if (!linear) ExportTexture.toSrgb(to, toChannel);
+		if (!linear) ExportTexture.to_srgb(to, toChannel);
 	}
 
-	static extractChannel = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, step: i32, mask: i32, linear = true) => {
-		for (let i = 0; i < Math.floor(to.byteLength / 4); ++i) {
+	static extract_channel = (from: DataView, fromChannel: i32, to: DataView, toChannel: i32, step: i32, mask: i32, linear: bool = true) => {
+		for (let i: i32 = 0; i < Math.floor(to.byteLength / 4); ++i) {
 			to.setUint8(i * 4 + toChannel, from.getUint8(i * 4 + fromChannel) % step == mask ? 255 : 0);
 		}
-		if (!linear) ExportTexture.toSrgb(to, toChannel);
+		if (!linear) ExportTexture.to_srgb(to, toChannel);
 	}
 
-	static setChannel = (value: i32, to: DataView, toChannel: i32, linear = true) => {
-		for (let i = 0; i < Math.floor(to.byteLength / 4); ++i) {
+	static set_channel = (value: i32, to: DataView, toChannel: i32, linear: bool = true) => {
+		for (let i: i32 = 0; i < Math.floor(to.byteLength / 4); ++i) {
 			to.setUint8(i * 4 + toChannel, value);
 		}
-		if (!linear) ExportTexture.toSrgb(to, toChannel);
+		if (!linear) ExportTexture.to_srgb(to, toChannel);
 	}
 
-	static toSrgb = (to: DataView, toChannel: i32) => {
-		for (let i = 0; i < Math.floor(to.byteLength / 4); ++i) {
+	static to_srgb = (to: DataView, toChannel: i32) => {
+		for (let i: i32 = 0; i < Math.floor(to.byteLength / 4); ++i) {
 			to.setUint8(i * 4 + toChannel, Math.floor(Math.pow(to.getUint8(i * 4 + toChannel) / 255, ExportTexture.gamma) * 255));
 		}
 	}
 }
 
-type TExportPreset = {
-	textures: TExportPresetTexture[];
-}
+type export_preset_t = {
+	textures?: export_preset_texture_t[];
+};
 
-type TExportPresetTexture = {
-	name: string;
-	channels: string[];
-	color_space: string;
-}
+type export_preset_texture_t = {
+	name?: string;
+	channels?: string[];
+	color_space?: string;
+};
 
 ///end

+ 44 - 44
base/Sources/File.ts

@@ -2,23 +2,23 @@
 class File {
 
 	///if krom_windows
-	static cmd_mkdir = "mkdir";
-	static cmd_copy = "copy";
+	static cmd_mkdir: string = "mkdir";
+	static cmd_copy: string = "copy";
 	///else
-	static cmd_mkdir = "mkdir -p";
-	static cmd_copy = "cp";
+	static cmd_mkdir: string = "mkdir -p";
+	static cmd_copy: string = "cp";
 	///end
 
 	static cloud: Map<string, string[]> = null;
-	static cloudSizes: Map<string, i32> = null;
+	static cloud_sizes: Map<string, i32> = null;
 
 	// ///if krom_android
 	// static let internal: Map<string, string[]> = null; // .apk contents
 	// ///end
 
-	static readDirectory = (path: string, foldersOnly = false): string[] => {
+	static read_directory = (path: string, foldersOnly: bool = false): string[] => {
 		if (path.startsWith("cloud")) {
-			let files = File.cloud != null ? File.cloud.get(string_replace_all(path, "\\", "/")) : null;
+			let files: string[] = File.cloud != null ? File.cloud.get(string_replace_all(path, "\\", "/")) : null;
 			return files != null ? files : [];
 		}
 		// ///if krom_android
@@ -37,7 +37,7 @@ class File {
 		return krom_read_directory(path, foldersOnly).split("\n");
 	}
 
-	static createDirectory = (path: string) => {
+	static create_directory = (path: string) => {
 		krom_sys_command(File.cmd_mkdir + ' "' + path + '"');
 	}
 
@@ -55,7 +55,7 @@ class File {
 		///end
 	}
 
-	static loadUrl = (url: string) => {
+	static load_url = (url: string) => {
 		krom_load_url(url);
 	}
 
@@ -67,7 +67,7 @@ class File {
 		return krom_file_exists(path);
 	}
 
-	static download = (url: string, dstPath: string, done: ()=>void, size = 0) => {
+	static download = (url: string, dstPath: string, done: ()=>void, size: i32 = 0) => {
 		///if (krom_windows || krom_darwin || krom_ios || krom_android)
 		krom_http_request(url, size, (ab: ArrayBuffer) => {
 			if (ab != null) krom_file_save_bytes(dstPath, ab);
@@ -82,8 +82,8 @@ class File {
 		///end
 	}
 
-	static downloadBytes = (url: string, done: (ab: ArrayBuffer)=>void) => {
-		let save = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "download.bin";
+	static download_bytes = (url: string, done: (ab: ArrayBuffer)=>void) => {
+		let save: string = (Path.is_protected() ? krom_save_path() : Path.data() + Path.sep) + "download.bin";
 		File.download(url, save, () => {
 			let buffer: ArrayBuffer = null;
 			try {
@@ -94,30 +94,30 @@ class File {
 		});
 	}
 
-	static cacheCloud = (path: string, done: (s: string)=>void) => {
+	static cache_cloud = (path: string, done: (s: string)=>void) => {
 		///if krom_ios
-		let path2 = string_replace_all(path, "/", "_"); // Cache everything into root folder
+		let path2: string = string_replace_all(path, "/", "_"); // Cache everything into root folder
 		///else
-		let path2 = path;
+		let path2: string = path;
 		///end
-		let dest = (Path.isProtected() ? krom_save_path() : krom_get_files_location() + Path.sep) + path2;
+		let dest: string = (Path.is_protected() ? krom_save_path() : krom_get_files_location() + Path.sep) + path2;
 		if (File.exists(dest)) {
 			///if (krom_darwin || krom_ios)
 			done(dest);
 			///else
-			done((Path.isProtected() ? krom_save_path() : Path.workingDir() + Path.sep) + path);
+			done((Path.is_protected() ? krom_save_path() : Path.working_dir() + Path.sep) + path);
 			///end
 			return;
 		}
 
-		let fileDir = dest.substr(0, dest.lastIndexOf(Path.sep));
-		if (File.readDirectory(fileDir)[0] == "") {
-			File.createDirectory(fileDir);
+		let fileDir: string = dest.substr(0, dest.lastIndexOf(Path.sep));
+		if (File.read_directory(fileDir)[0] == "") {
+			File.create_directory(fileDir);
 		}
 		///if krom_windows
 		path = string_replace_all(path, "\\", "/");
 		///end
-		let url = Config.raw.server + "/" + path;
+		let url: string = Config.raw.server + "/" + path;
 		File.download(url, dest, () => {
 			if (!File.exists(dest)) {
 				Console.error(Strings.error5());
@@ -127,13 +127,13 @@ class File {
 			///if (krom_darwin || krom_ios)
 			done(dest);
 			///else
-			done((Path.isProtected() ? krom_save_path() : Path.workingDir() + Path.sep) + path);
+			done((Path.is_protected() ? krom_save_path() : Path.working_dir() + Path.sep) + path);
 			///end
-		}, File.cloudSizes.get(path));
+		}, File.cloud_sizes.get(path));
 	}
 
-	static initCloudBytes = (done: ()=>void, append = "") => {
-		File.downloadBytes(Config.raw.server + "/?list-type=2" + append, (buffer: ArrayBuffer) => {
+	static init_cloud_bytes = (done: ()=>void, append: string = "") => {
+		File.download_bytes(Config.raw.server + "/?list-type=2" + append, (buffer: ArrayBuffer) => {
 			if (buffer == null) {
 				File.cloud.set("cloud", []);
 				Console.error(Strings.error5());
@@ -142,9 +142,9 @@ class File {
 			let files: string[] = [];
 			let sizes: i32[] = [];
 
-			let str = sys_buffer_to_string(buffer);
-			let pos_start = 0;
-			let pos_end = 0;
+			let str: string = sys_buffer_to_string(buffer);
+			let pos_start: i32 = 0;
+			let pos_end: i32 = 0;
 
 			while (true) {
 				pos_start = str.indexOf("<Key>", pos_start);
@@ -162,38 +162,38 @@ class File {
 			}
 
 			for (let file of files) {
-				if (Path.isFolder(file)) {
+				if (Path.is_folder(file)) {
 					File.cloud.set(file.substr(0, file.length - 1), []);
 				}
 			}
-			for (let i = 0; i < files.length; ++i) {
-				let file = files[i];
-				let nested = file.indexOf("/") != file.lastIndexOf("/");
+			for (let i: i32 = 0; i < files.length; ++i) {
+				let file: string = files[i];
+				let nested: bool = file.indexOf("/") != file.lastIndexOf("/");
 				if (nested) {
-					let delim = Path.isFolder(file) ? file.substr(0, file.length - 1).lastIndexOf("/") : file.lastIndexOf("/");
-					let parent = file.substr(0, delim);
-					let child = Path.isFolder(file) ? file.substring(delim + 1, file.length - 1) : file.substr(delim + 1);
+					let delim: i32 = Path.is_folder(file) ? file.substr(0, file.length - 1).lastIndexOf("/") : file.lastIndexOf("/");
+					let parent: string = file.substr(0, delim);
+					let child: string = Path.is_folder(file) ? file.substring(delim + 1, file.length - 1) : file.substr(delim + 1);
 					File.cloud.get(parent).push(child);
-					if (!Path.isFolder(file)) {
-						File.cloudSizes.set(file, sizes[i]);
+					if (!Path.is_folder(file)) {
+						File.cloud_sizes.set(file, sizes[i]);
 					}
 				}
 			}
 
-			let isTruncated = str.indexOf("<IsTruncated>true") > -1;
+			let isTruncated: bool = str.indexOf("<IsTruncated>true") > -1;
 			if (isTruncated) {
-				let pos_start = str.indexOf("<NextContinuationToken>");
+				let pos_start: i32 = str.indexOf("<NextContinuationToken>");
 				pos_start += 23;
-				let pos_end = str.indexOf("</NextContinuationToken>", pos_start);
-				File.initCloudBytes(done, "&start-after=" + str.substring(pos_start, pos_end));
+				let pos_end: i32 = str.indexOf("</NextContinuationToken>", pos_start);
+				File.init_cloud_bytes(done, "&start-after=" + str.substring(pos_start, pos_end));
 			}
 			else done();
 		});
 	}
 
-	static initCloud = (done: ()=>void) => {
+	static init_cloud = (done: ()=>void) => {
 		File.cloud = new Map();
-		File.cloudSizes = new Map();
-		File.initCloudBytes(done);
+		File.cloud_sizes = new Map();
+		File.init_cloud_bytes(done);
 	}
 }

+ 61 - 61
base/Sources/Geom.ts

@@ -1,57 +1,57 @@
 
 class Geom {
 
-	static make_plane(sizeX = 1.0, sizeY = 1.0, vertsX = 2, vertsY = 2, uvScale = 1.0): TRawMesh {
+	static make_plane(size_x: f32 = 1.0, size_y: f32 = 1.0, verts_x: i32 = 2, verts_y: i32 = 2, uv_scale: f32 = 1.0): raw_mesh_t {
 
-		let mesh: TRawMesh = {};
+		let mesh: raw_mesh_t = {};
 		mesh.scalePos = 1.0;
 		mesh.scaleTex = 1.0;
 		mesh.name = "";
 		mesh.hasNext = false;
 
 		// Pack positions to (-1, 1) range
-		let halfX = sizeX / 2;
-		let halfY = sizeY / 2;
+		let halfX: f32 = size_x / 2;
+		let halfY: f32 = size_y / 2;
 		mesh.scalePos = Math.max(halfX, halfY);
-		let inv = (1 / mesh.scalePos) * 32767;
+		let inv: f32 = (1 / mesh.scalePos) * 32767;
 
-		mesh.posa = new Int16Array(vertsX * vertsY * 4);
-		mesh.nora = new Int16Array(vertsX * vertsY * 2);
-		mesh.texa = new Int16Array(vertsX * vertsY * 2);
-		mesh.inda = new Uint32Array((vertsX - 1) * (vertsY - 1) * 6);
-		let stepX = sizeX / (vertsX - 1);
-		let stepY = sizeY / (vertsY - 1);
-		for (let i = 0; i < vertsX * vertsY; ++i) {
-			let x = (i % vertsX) * stepX - halfX;
-			let y = Math.floor(i / vertsX) * stepY - halfY;
+		mesh.posa = new Int16Array(verts_x * verts_y * 4);
+		mesh.nora = new Int16Array(verts_x * verts_y * 2);
+		mesh.texa = new Int16Array(verts_x * verts_y * 2);
+		mesh.inda = new Uint32Array((verts_x - 1) * (verts_y - 1) * 6);
+		let stepX: f32 = size_x / (verts_x - 1);
+		let stepY: f32 = size_y / (verts_y - 1);
+		for (let i: i32 = 0; i < verts_x * verts_y; ++i) {
+			let x: f32 = (i % verts_x) * stepX - halfX;
+			let y: f32 = Math.floor(i / verts_x) * stepY - halfY;
 			mesh.posa[i * 4    ] = Math.floor(x * inv);
 			mesh.posa[i * 4 + 1] = Math.floor(y * inv);
 			mesh.posa[i * 4 + 2] = 0;
 			mesh.nora[i * 2    ] = 0;
 			mesh.nora[i * 2 + 1] = 0;
 			mesh.posa[i * 4 + 3] = 32767;
-			x = (i % vertsX) / (vertsX - 1);
-			y = 1.0 - Math.floor(i / vertsX) / (vertsY - 1);
-			mesh.texa[i * 2    ] = (Math.floor(x * 32767 * uvScale) - 1) % 32767;
-			mesh.texa[i * 2 + 1] = (Math.floor(y * 32767 * uvScale) - 1) % 32767;
+			x = (i % verts_x) / (verts_x - 1);
+			y = 1.0 - Math.floor(i / verts_x) / (verts_y - 1);
+			mesh.texa[i * 2    ] = (Math.floor(x * 32767 * uv_scale) - 1) % 32767;
+			mesh.texa[i * 2 + 1] = (Math.floor(y * 32767 * uv_scale) - 1) % 32767;
 		}
-		for (let i = 0; i < (vertsX - 1) * (vertsY - 1); ++i) {
-			let x = i % (vertsX - 1);
-			let y = Math.floor(i / (vertsY - 1));
-			mesh.inda[i * 6    ] = y * vertsX + x;
-			mesh.inda[i * 6 + 1] = y * vertsX + x + 1;
-			mesh.inda[i * 6 + 2] = (y + 1) * vertsX + x;
-			mesh.inda[i * 6 + 3] = y * vertsX + x + 1;
-			mesh.inda[i * 6 + 4] = (y + 1) * vertsX + x + 1;
-			mesh.inda[i * 6 + 5] = (y + 1) * vertsX + x;
+		for (let i: i32 = 0; i < (verts_x - 1) * (verts_y - 1); ++i) {
+			let x: f32 = i % (verts_x - 1);
+			let y: f32 = Math.floor(i / (verts_y - 1));
+			mesh.inda[i * 6    ] = y * verts_x + x;
+			mesh.inda[i * 6 + 1] = y * verts_x + x + 1;
+			mesh.inda[i * 6 + 2] = (y + 1) * verts_x + x;
+			mesh.inda[i * 6 + 3] = y * verts_x + x + 1;
+			mesh.inda[i * 6 + 4] = (y + 1) * verts_x + x + 1;
+			mesh.inda[i * 6 + 5] = (y + 1) * verts_x + x;
 		}
 
 		return mesh;
 	}
 
-	static make_uv_sphere(radius = 1.0, widthSegments = 32, heightSegments = 16, stretchUV = true, uvScale = 1.0): TRawMesh {
+	static make_uv_sphere(radius: f32 = 1.0, widthSegments: i32 = 32, heightSegments: i32 = 16, stretchUV: bool = true, uvScale: f32 = 1.0): raw_mesh_t {
 
-		let mesh: TRawMesh = {};
+		let mesh: raw_mesh_t = {};
 		mesh.scalePos = 1.0;
 		mesh.scaleTex = 1.0;
 		mesh.name = "";
@@ -60,33 +60,33 @@ class Geom {
 		// Pack positions to (-1, 1) range
 		mesh.scalePos = radius;
 		mesh.scaleTex = uvScale;
-		let inv = (1 / mesh.scalePos) * 32767;
-		let pi2 = Math.PI * 2;
+		let inv: f32 = (1 / mesh.scalePos) * 32767;
+		let pi2: f32 = Math.PI * 2;
 
-		let widthVerts = widthSegments + 1;
-		let heightVerts = heightSegments + 1;
+		let widthVerts: i32 = widthSegments + 1;
+		let heightVerts: i32 = heightSegments + 1;
 		mesh.posa = new Int16Array(widthVerts * heightVerts * 4);
 		mesh.nora = new Int16Array(widthVerts * heightVerts * 2);
 		mesh.texa = new Int16Array(widthVerts * heightVerts * 2);
 		mesh.inda = new Uint32Array(widthSegments * heightSegments * 6 - widthSegments * 6);
 
-		let nor = vec4_create();
-		let pos = 0;
-		for (let y = 0; y < heightVerts; ++y) {
-			let v = y / heightSegments;
-			let vFlip = 1.0 - v;
+		let nor: vec4_t = vec4_create();
+		let pos: i32 = 0;
+		for (let y: i32 = 0; y < heightVerts; ++y) {
+			let v: f32 = y / heightSegments;
+			let vFlip: f32 = 1.0 - v;
 			if (!stretchUV) vFlip /= 2;
-			let uOff = y == 0 ? 0.5 / widthSegments : y == heightSegments ? -0.5 / widthSegments : 0.0;
-			for (let x = 0; x < widthVerts; ++x) {
-				let u = x / widthSegments;
-				let uPI2 = u * pi2;
-				let vPI  = v * Math.PI;
-				let vPIsin = Math.sin(vPI);
-				let vx = -radius * Math.cos(uPI2) * vPIsin;
-				let vy =  radius * Math.sin(uPI2) * vPIsin;
-				let vz = -radius * Math.cos(vPI);
-				let i4 = pos * 4;
-				let i2 = pos * 2;
+			let uOff: f32 = y == 0 ? 0.5 / widthSegments : y == heightSegments ? -0.5 / widthSegments : 0.0;
+			for (let x: i32 = 0; x < widthVerts; ++x) {
+				let u: f32 = x / widthSegments;
+				let uPI2: f32 = u * pi2;
+				let vPI: f32  = v * Math.PI;
+				let vPIsin: f32 = Math.sin(vPI);
+				let vx: f32 = -radius * Math.cos(uPI2) * vPIsin;
+				let vy: f32 =  radius * Math.sin(uPI2) * vPIsin;
+				let vz: f32 = -radius * Math.cos(vPI);
+				let i4: i32 = pos * 4;
+				let i2: i32 = pos * 2;
 				mesh.posa[i4    ] = Math.floor(vx * inv);
 				mesh.posa[i4 + 1] = Math.floor(vy * inv);
 				mesh.posa[i4 + 2] = Math.floor(vz * inv);
@@ -101,15 +101,15 @@ class Geom {
 		}
 
 		pos = 0;
-		let heightSegments1 = heightSegments - 1;
-		for (let y = 0; y < heightSegments; ++y) {
-			for (let x = 0; x < widthSegments; ++x) {
-				let x1 = x + 1;
-				let y1 = y + 1;
-				let a = y  * widthVerts + x1;
-				let b = y  * widthVerts + x;
-				let c = y1 * widthVerts + x;
-				let d = y1 * widthVerts + x1;
+		let heightSegments1: i32 = heightSegments - 1;
+		for (let y: i32 = 0; y < heightSegments; ++y) {
+			for (let x: i32 = 0; x < widthSegments; ++x) {
+				let x1: i32 = x + 1;
+				let y1: i32 = y + 1;
+				let a: f32 = y  * widthVerts + x1;
+				let b: f32 = y  * widthVerts + x;
+				let c: f32 = y1 * widthVerts + x;
+				let d: f32 = y1 * widthVerts + x1;
 				if (y > 0) {
 					mesh.inda[pos++] = a;
 					mesh.inda[pos++] = b;
@@ -127,13 +127,13 @@ class Geom {
 	}
 }
 
-type TRawMesh = {
+type raw_mesh_t = {
 	posa?: Int16Array;
 	nora?: Int16Array;
 	texa?: Int16Array;
 	inda?: Uint32Array;
 	scalePos?: f32;
-	scaleTex?:f32;
+	scaleTex?: f32;
 	name?: string;
 	hasNext?: bool;
-}
+};

+ 132 - 122
base/Sources/Gizmo.ts

@@ -3,24 +3,24 @@
 
 class Gizmo {
 
-	static v = vec4_create();
-	static v0 = vec4_create();
-	static q = quat_create();
-	static q0 = quat_create();
+	static v: vec4_t = vec4_create();
+	static v0: vec4_t = vec4_create();
+	static q: quat_t = quat_create();
+	static q0: quat_t = quat_create();
 
 	static update = () => {
-		let isObject = Context.raw.tool == WorkspaceTool.ToolGizmo;
-		let isDecal = Base.isDecalLayer();
+		let isObject: bool = Context.raw.tool == workspace_tool_t.GIZMO;
+		let isDecal: bool = Base.is_decal_layer();
 
-		let gizmo = Context.raw.gizmo;
-		let hide = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown);
+		let gizmo: object_t = Context.raw.gizmo;
+		let hide: bool = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown);
 		gizmo.visible = (isObject || isDecal) && !hide;
 		if (!gizmo.visible) return;
 
-		let paintObject: object_t = Context.raw.paintObject.base;
+		let paintObject: object_t = Context.raw.paint_object.base;
 		///if is_forge
-		if (Context.raw.selectedObject != null) {
-			paintObject = Context.raw.selectedObject;
+		if (Context.raw.selected_object != null) {
+			paintObject = Context.raw.selected_object;
 		}
 		///end
 
@@ -30,228 +30,238 @@ class Gizmo {
 		else if (isDecal) {
 			vec4_set(gizmo.transform.loc, Context.raw.layer.decalMat.m[12], Context.raw.layer.decalMat.m[13], Context.raw.layer.decalMat.m[14]);
 		}
-		let cam = scene_camera;
-		let fov = cam.data.fov;
-		let dist = vec4_dist(cam.base.transform.loc, gizmo.transform.loc) / 8 * fov;
+		let cam: camera_object_t = scene_camera;
+		let fov: f32 = cam.data.fov;
+		let dist: f32 = vec4_dist(cam.base.transform.loc, gizmo.transform.loc) / 8 * fov;
 		vec4_set(gizmo.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoTranslateX.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoTranslateY.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoTranslateZ.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoScaleX.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoScaleY.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoScaleZ.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoRotateX.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoRotateY.transform.scale, dist, dist, dist);
-		vec4_set(Context.raw.gizmoRotateZ.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_translate_x.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_translate_y.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_translate_z.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_scale_x.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_scale_y.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_scale_z.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_rotate_x.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_rotate_y.transform.scale, dist, dist, dist);
+		vec4_set(Context.raw.gizmo_rotate_z.transform.scale, dist, dist, dist);
 		transform_build_matrix(gizmo.transform);
 
 		// Scene control
 		if (isObject) {
-			if (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) {
-				if (Context.raw.translateX) {
-					paintObject.transform.loc.x = Context.raw.gizmoDrag;
+			if (Context.raw.translate_x || Context.raw.translate_y || Context.raw.translate_z || Context.raw.scale_x || Context.raw.scale_y || Context.raw.scale_z || Context.raw.rotate_x || Context.raw.rotate_y || Context.raw.rotate_z) {
+				if (Context.raw.translate_x) {
+					paintObject.transform.loc.x = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.translateY) {
-					paintObject.transform.loc.y = Context.raw.gizmoDrag;
+				else if (Context.raw.translate_y) {
+					paintObject.transform.loc.y = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.translateZ) {
-					paintObject.transform.loc.z = Context.raw.gizmoDrag;
+				else if (Context.raw.translate_z) {
+					paintObject.transform.loc.z = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.scaleX) {
-					paintObject.transform.scale.x += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+				else if (Context.raw.scale_x) {
+					paintObject.transform.scale.x += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 				}
-				else if (Context.raw.scaleY) {
-					paintObject.transform.scale.y += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+				else if (Context.raw.scale_y) {
+					paintObject.transform.scale.y += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 				}
-				else if (Context.raw.scaleZ) {
-					paintObject.transform.scale.z += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+				else if (Context.raw.scale_z) {
+					paintObject.transform.scale.z += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 				}
-				else if (Context.raw.rotateX) {
-					quat_from_axis_angle(Gizmo.q0, vec4_x_axis(), Context.raw.gizmoDrag - Context.raw.gizmoDragLast);
+				else if (Context.raw.rotate_x) {
+					quat_from_axis_angle(Gizmo.q0, vec4_x_axis(), Context.raw.gizmo_drag - Context.raw.gizmo_drag_last);
 					quat_mult(paintObject.transform.rot, Gizmo.q0);
 				}
-				else if (Context.raw.rotateY) {
-					quat_from_axis_angle(Gizmo.q0, vec4_y_axis(), Context.raw.gizmoDrag - Context.raw.gizmoDragLast);
+				else if (Context.raw.rotate_y) {
+					quat_from_axis_angle(Gizmo.q0, vec4_y_axis(), Context.raw.gizmo_drag - Context.raw.gizmo_drag_last);
 					quat_mult(paintObject.transform.rot, Gizmo.q0);
 				}
-				else if (Context.raw.rotateZ) {
-					quat_from_axis_angle(Gizmo.q0, vec4_z_axis(), Context.raw.gizmoDrag - Context.raw.gizmoDragLast);
+				else if (Context.raw.rotate_z) {
+					quat_from_axis_angle(Gizmo.q0, vec4_z_axis(), Context.raw.gizmo_drag - Context.raw.gizmo_drag_last);
 					quat_mult(paintObject.transform.rot, Gizmo.q0);
 				}
-				Context.raw.gizmoDragLast = Context.raw.gizmoDrag;
+				Context.raw.gizmo_drag_last = Context.raw.gizmo_drag;
 
 				transform_build_matrix(paintObject.transform);
 				///if arm_physics
-				let pb = (paintObject as any).physicsBody;
+				let pb: any = (paintObject as any).physicsBody;
 				if (pb != null) pb.syncTransform();
 				///end
 			}
 		}
 		// Decal layer control
 		else if (isDecal) {
-			if (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) {
-				if (Context.raw.translateX) {
-					Context.raw.layer.decalMat.m[12] = Context.raw.gizmoDrag;
+			if (Context.raw.translate_x || Context.raw.translate_y || Context.raw.translate_z || Context.raw.scale_x || Context.raw.scale_y || Context.raw.scale_z || Context.raw.rotate_x || Context.raw.rotate_y || Context.raw.rotate_z) {
+				if (Context.raw.translate_x) {
+					Context.raw.layer.decalMat.m[12] = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.translateY) {
-					Context.raw.layer.decalMat.m[13] = Context.raw.gizmoDrag;
+				else if (Context.raw.translate_y) {
+					Context.raw.layer.decalMat.m[13] = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.translateZ) {
-					Context.raw.layer.decalMat.m[14] = Context.raw.gizmoDrag;
+				else if (Context.raw.translate_z) {
+					Context.raw.layer.decalMat.m[14] = Context.raw.gizmo_drag;
 				}
-				else if (Context.raw.scaleX) {
+				else if (Context.raw.scale_x) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					Gizmo.v0.x += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+					Gizmo.v0.x += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				else if (Context.raw.scaleY) {
+				else if (Context.raw.scale_y) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					Gizmo.v0.y += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+					Gizmo.v0.y += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				else if (Context.raw.scaleZ) {
+				else if (Context.raw.scale_z) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					Gizmo.v0.z += Context.raw.gizmoDrag - Context.raw.gizmoDragLast;
+					Gizmo.v0.z += Context.raw.gizmo_drag - Context.raw.gizmo_drag_last;
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				else if (Context.raw.rotateX) {
+				else if (Context.raw.rotate_x) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					quat_from_axis_angle(Gizmo.q0, vec4_x_axis(), -Context.raw.gizmoDrag + Context.raw.gizmoDragLast);
+					quat_from_axis_angle(Gizmo.q0, vec4_x_axis(), -Context.raw.gizmo_drag + Context.raw.gizmo_drag_last);
 					quat_mult_quats(Gizmo.q, Gizmo.q0, Gizmo.q);
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				else if (Context.raw.rotateY) {
+				else if (Context.raw.rotate_y) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					quat_from_axis_angle(Gizmo.q0, vec4_y_axis(), -Context.raw.gizmoDrag + Context.raw.gizmoDragLast);
+					quat_from_axis_angle(Gizmo.q0, vec4_y_axis(), -Context.raw.gizmo_drag + Context.raw.gizmo_drag_last);
 					quat_mult_quats(Gizmo.q, Gizmo.q0, Gizmo.q);
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				else if (Context.raw.rotateZ) {
+				else if (Context.raw.rotate_z) {
 					mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-					quat_from_axis_angle(Gizmo.q0, vec4_z_axis(), Context.raw.gizmoDrag - Context.raw.gizmoDragLast);
+					quat_from_axis_angle(Gizmo.q0, vec4_z_axis(), Context.raw.gizmo_drag - Context.raw.gizmo_drag_last);
 					quat_mult_quats(Gizmo.q, Gizmo.q0, Gizmo.q);
 					mat4_compose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
 				}
-				Context.raw.gizmoDragLast = Context.raw.gizmoDrag;
+				Context.raw.gizmo_drag_last = Context.raw.gizmo_drag;
 
 				if (Context.raw.material != Context.raw.layer.fill_layer) {
-					Context.setMaterial(Context.raw.layer.fill_layer);
+					Context.set_material(Context.raw.layer.fill_layer);
 				}
-				Base.updateFillLayer(Context.raw.gizmoStarted);
+				Base.update_fill_layer(Context.raw.gizmo_started);
 			}
 		}
 
-		Context.raw.gizmoStarted = false;
+		Context.raw.gizmo_started = false;
 		if (mouse_started("left") && paintObject.name != "Scene") {
 			// Translate, scale
-			let trs = [Context.raw.gizmoTranslateX.transform, Context.raw.gizmoTranslateY.transform, Context.raw.gizmoTranslateZ.transform,
-					   Context.raw.gizmoScaleX.transform, Context.raw.gizmoScaleY.transform, Context.raw.gizmoScaleZ.transform];
-			let hit = raycast_closest_box_intersect(trs, mouse_view_x(), mouse_view_y(), scene_camera);
+			let trs: transform_t[] = [
+				Context.raw.gizmo_translate_x.transform,
+				Context.raw.gizmo_translate_y.transform,
+				Context.raw.gizmo_translate_z.transform,
+				Context.raw.gizmo_scale_x.transform,
+				Context.raw.gizmo_scale_y.transform,
+				Context.raw.gizmo_scale_z.transform
+			];
+			let hit: transform_t = raycast_closest_box_intersect(trs, mouse_view_x(), mouse_view_y(), scene_camera);
 			if (hit != null) {
-				if (hit.object == Context.raw.gizmoTranslateX) Context.raw.translateX = true;
-				else if (hit.object == Context.raw.gizmoTranslateY) Context.raw.translateY = true;
-				else if (hit.object == Context.raw.gizmoTranslateZ) Context.raw.translateZ = true;
-				else if (hit.object == Context.raw.gizmoScaleX) Context.raw.scaleX = true;
-				else if (hit.object == Context.raw.gizmoScaleY) Context.raw.scaleY = true;
-				else if (hit.object == Context.raw.gizmoScaleZ) Context.raw.scaleZ = true;
-				if (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ) {
-					Context.raw.gizmoOffset = 0.0;
-					Context.raw.gizmoStarted = true;
+				if (hit.object == Context.raw.gizmo_translate_x) Context.raw.translate_x = true;
+				else if (hit.object == Context.raw.gizmo_translate_y) Context.raw.translate_y = true;
+				else if (hit.object == Context.raw.gizmo_translate_z) Context.raw.translate_z = true;
+				else if (hit.object == Context.raw.gizmo_scale_x) Context.raw.scale_x = true;
+				else if (hit.object == Context.raw.gizmo_scale_y) Context.raw.scale_y = true;
+				else if (hit.object == Context.raw.gizmo_scale_z) Context.raw.scale_z = true;
+				if (Context.raw.translate_x || Context.raw.translate_y || Context.raw.translate_z || Context.raw.scale_x || Context.raw.scale_y || Context.raw.scale_z) {
+					Context.raw.gizmo_offset = 0.0;
+					Context.raw.gizmo_started = true;
 				}
 			}
 			else {
 				// Rotate
-				let trs = [Context.raw.gizmoRotateX.transform, Context.raw.gizmoRotateY.transform, Context.raw.gizmoRotateZ.transform];
-				let hit = raycast_closest_box_intersect(trs, mouse_view_x(), mouse_view_y(), scene_camera);
+				let trs: transform_t[] = [
+					Context.raw.gizmo_rotate_x.transform,
+					Context.raw.gizmo_rotate_y.transform,
+					Context.raw.gizmo_rotate_z.transform
+				];
+				let hit: transform_t = raycast_closest_box_intersect(trs, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (hit.object == Context.raw.gizmoRotateX) Context.raw.rotateX = true;
-					else if (hit.object == Context.raw.gizmoRotateY) Context.raw.rotateY = true;
-					else if (hit.object == Context.raw.gizmoRotateZ) Context.raw.rotateZ = true;
-					if (Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) {
-						Context.raw.gizmoOffset = 0.0;
-						Context.raw.gizmoStarted = true;
+					if (hit.object == Context.raw.gizmo_rotate_x) Context.raw.rotate_x = true;
+					else if (hit.object == Context.raw.gizmo_rotate_y) Context.raw.rotate_y = true;
+					else if (hit.object == Context.raw.gizmo_rotate_z) Context.raw.rotate_z = true;
+					if (Context.raw.rotate_x || Context.raw.rotate_y || Context.raw.rotate_z) {
+						Context.raw.gizmo_offset = 0.0;
+						Context.raw.gizmo_started = true;
 					}
 				}
 			}
 		}
 		else if (mouse_released("left")) {
-			Context.raw.translateX = Context.raw.translateY = Context.raw.translateZ = false;
-			Context.raw.scaleX = Context.raw.scaleY = Context.raw.scaleZ = false;
-			Context.raw.rotateX = Context.raw.rotateY = Context.raw.rotateZ = false;
+			Context.raw.translate_x = Context.raw.translate_y = Context.raw.translate_z = false;
+			Context.raw.scale_x = Context.raw.scale_y = Context.raw.scale_z = false;
+			Context.raw.rotate_x = Context.raw.rotate_y = Context.raw.rotate_z = false;
 		}
 
-		if (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) {
+		if (Context.raw.translate_x || Context.raw.translate_y || Context.raw.translate_z || Context.raw.scale_x || Context.raw.scale_y || Context.raw.scale_z || Context.raw.rotate_x || Context.raw.rotate_y || Context.raw.rotate_z) {
 			Context.raw.rdirty = 2;
 
 			if (isObject) {
-				let t = paintObject.transform;
+				let t: transform_t = paintObject.transform;
 				vec4_set(Gizmo.v, transform_world_x(t), transform_world_y(t), transform_world_z(t));
 			}
 			else if (isDecal) {
 				vec4_set(Gizmo.v, Context.raw.layer.decalMat.m[12], Context.raw.layer.decalMat.m[13], Context.raw.layer.decalMat.m[14]);
 			}
 
-			if (Context.raw.translateX || Context.raw.scaleX) {
-				let hit = raycast_plane_intersect(vec4_y_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			if (Context.raw.translate_x || Context.raw.scale_x) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_y_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.x - Gizmo.v.x;
-					Context.raw.gizmoDrag = hit.x - Context.raw.gizmoOffset;
+					if (Context.raw.gizmo_started) Context.raw.gizmo_offset = hit.x - Gizmo.v.x;
+					Context.raw.gizmo_drag = hit.x - Context.raw.gizmo_offset;
 				}
 			}
-			else if (Context.raw.translateY || Context.raw.scaleY) {
-				let hit = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			else if (Context.raw.translate_y || Context.raw.scale_y) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.y - Gizmo.v.y;
-					Context.raw.gizmoDrag = hit.y - Context.raw.gizmoOffset;
+					if (Context.raw.gizmo_started) Context.raw.gizmo_offset = hit.y - Gizmo.v.y;
+					Context.raw.gizmo_drag = hit.y - Context.raw.gizmo_offset;
 				}
 			}
-			else if (Context.raw.translateZ || Context.raw.scaleZ) {
-				let hit = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			else if (Context.raw.translate_z || Context.raw.scale_z) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) Context.raw.gizmoOffset = hit.z - Gizmo.v.z;
-					Context.raw.gizmoDrag = hit.z - Context.raw.gizmoOffset;
+					if (Context.raw.gizmo_started) Context.raw.gizmo_offset = hit.z - Gizmo.v.z;
+					Context.raw.gizmo_drag = hit.z - Context.raw.gizmo_offset;
 				}
 			}
-			else if (Context.raw.rotateX) {
-				let hit = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			else if (Context.raw.rotate_x) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_x_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) {
+					if (Context.raw.gizmo_started) {
 						mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-						Context.raw.gizmoOffset = Math.atan2(hit.y - Gizmo.v.y, hit.z - Gizmo.v.z);
+						Context.raw.gizmo_offset = Math.atan2(hit.y - Gizmo.v.y, hit.z - Gizmo.v.z);
 					}
-					Context.raw.gizmoDrag = Math.atan2(hit.y - Gizmo.v.y, hit.z - Gizmo.v.z) - Context.raw.gizmoOffset;
+					Context.raw.gizmo_drag = Math.atan2(hit.y - Gizmo.v.y, hit.z - Gizmo.v.z) - Context.raw.gizmo_offset;
 				}
 			}
-			else if (Context.raw.rotateY) {
-				let hit = raycast_plane_intersect(vec4_y_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			else if (Context.raw.rotate_y) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_y_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) {
+					if (Context.raw.gizmo_started) {
 						mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-						Context.raw.gizmoOffset = Math.atan2(hit.z - Gizmo.v.z, hit.x - Gizmo.v.x);
+						Context.raw.gizmo_offset = Math.atan2(hit.z - Gizmo.v.z, hit.x - Gizmo.v.x);
 					}
-					Context.raw.gizmoDrag = Math.atan2(hit.z - Gizmo.v.z, hit.x - Gizmo.v.x) - Context.raw.gizmoOffset;
+					Context.raw.gizmo_drag = Math.atan2(hit.z - Gizmo.v.z, hit.x - Gizmo.v.x) - Context.raw.gizmo_offset;
 				}
 			}
-			else if (Context.raw.rotateZ) {
-				let hit = raycast_plane_intersect(vec4_z_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
+			else if (Context.raw.rotate_z) {
+				let hit: vec4_t = raycast_plane_intersect(vec4_z_axis(), Gizmo.v, mouse_view_x(), mouse_view_y(), scene_camera);
 				if (hit != null) {
-					if (Context.raw.gizmoStarted) {
+					if (Context.raw.gizmo_started) {
 						mat4_decompose(Context.raw.layer.decalMat, Gizmo.v, Gizmo.q, Gizmo.v0);
-						Context.raw.gizmoOffset = Math.atan2(hit.y - Gizmo.v.y, hit.x - Gizmo.v.x);
+						Context.raw.gizmo_offset = Math.atan2(hit.y - Gizmo.v.y, hit.x - Gizmo.v.x);
 					}
-					Context.raw.gizmoDrag = Math.atan2(hit.y - Gizmo.v.y, hit.x - Gizmo.v.x) - Context.raw.gizmoOffset;
+					Context.raw.gizmo_drag = Math.atan2(hit.y - Gizmo.v.y, hit.x - Gizmo.v.x) - Context.raw.gizmo_offset;
 				}
 			}
 
-			if (Context.raw.gizmoStarted) Context.raw.gizmoDragLast = Context.raw.gizmoDrag;
+			if (Context.raw.gizmo_started) Context.raw.gizmo_drag_last = Context.raw.gizmo_drag;
 
 			///if is_forge
-			UtilMesh.removeMergedMesh();
+			UtilMesh.remove_merged_mesh();
 			RenderPathRaytrace.ready = false;
 			///end
 		}
 
-		_input_occupied = (Context.raw.translateX || Context.raw.translateY || Context.raw.translateZ || Context.raw.scaleX || Context.raw.scaleY || Context.raw.scaleZ || Context.raw.rotateX || Context.raw.rotateY || Context.raw.rotateZ) && mouse_view_x() < Base.w();
+		_input_occupied = (Context.raw.translate_x || Context.raw.translate_y || Context.raw.translate_z || Context.raw.scale_x || Context.raw.scale_y || Context.raw.scale_z || Context.raw.rotate_x || Context.raw.rotate_y || Context.raw.rotate_z) && mouse_view_x() < Base.w();
 	}
 }
 

+ 240 - 238
base/Sources/History.ts

@@ -1,25 +1,25 @@
 
 class History {
 
-	static steps: TStep[];
-	static undoI = 0; // Undo layer
-	static undos = 0; // Undos available
-	static redos = 0; // Redos available
+	static steps: step_t[];
+	static undo_i: i32 = 0; // Undo layer
+	static undos: i32 = 0; // Undos available
+	static redos: i32 = 0; // Redos available
 	///if (is_paint || is_sculpt)
-	static pushUndo = false; // Store undo on next paint
-	static undoLayers: SlotLayerRaw[] = null;
+	static push_undo: bool = false; // Store undo on next paint
+	static undo_layers: SlotLayerRaw[] = null;
 	///end
 	///if is_sculpt
-	static pushUndo2 = false;
+	static push_undo2: bool = false;
 	///end
 
 	static undo = () => {
 		if (History.undos > 0) {
-			let active = History.steps.length - 1 - History.redos;
-			let step = History.steps[active];
+			let active: i32 = History.steps.length - 1 - History.redos;
+			let step: step_t = History.steps[active];
 
 			if (step.name == tr("Edit Nodes")) {
-				History.swapCanvas(step);
+				History.swap_canvas(step);
 			}
 
 			///if (is_paint || is_sculpt)
@@ -36,24 +36,24 @@ class History {
 				Context.raw.layer = Project.layers[step.layer > 0 ? step.layer - 1 : 0];
 			}
 			else if (step.name == tr("Delete Layer")) {
-				let parent = step.layer_parent > 0 ? Project.layers[step.layer_parent - 1] : null;
-				let l = SlotLayer.create("", step.layer_type, parent);
+				let parent: SlotLayerRaw = step.layer_parent > 0 ? Project.layers[step.layer_parent - 1] : null;
+				let l: SlotLayerRaw = SlotLayer.create("", step.layer_type, parent);
 				Project.layers.splice(step.layer, 0, l);
-				Context.setLayer(l);
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
+				Context.set_layer(l);
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(l, lay);
 				l.maskOpacity = step.layer_opacity;
 				l.blending = step.layer_blending;
 				l.objectMask = step.layer_object;
-				MakeMaterial.parseMeshMaterial();
+				MakeMaterial.parse_mesh_material();
 
 				// Undo at least second time in order to avoid empty groups
-				if (step.layer_type == LayerSlotType.SlotGroup) {
-					Base.notifyOnNextFrame(() => {
+				if (step.layer_type == layer_slot_type_t.GROUP) {
+					Base.notify_on_next_frame(() => {
 						// 1. Undo deleting group masks
-						let n = 1;
-						while (History.steps[active - n].layer_type == LayerSlotType.SlotMask) {
+						let n: i32 = 1;
+						while (History.steps[active - n].layer_type == layer_slot_type_t.MASK) {
 							History.undo();
 							++n;
 						}
@@ -63,14 +63,14 @@ class History {
 				}
 			}
 			else if (step.name == tr("Clear Layer")) {
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
-				Context.raw.layerPreviewDirty = true;
+				Context.raw.layer_preview_dirty = true;
 			}
 			else if (step.name == tr("Duplicate Layer")) {
-				let children = SlotLayer.getRecursiveChildren(Project.layers[step.layer]);
-				let position = step.layer + 1;
+				let children: SlotLayerRaw[] = SlotLayer.get_recursive_children(Project.layers[step.layer]);
+				let position: i32 = step.layer + 1;
 				if (children != null)
 					position += children.length;
 
@@ -78,7 +78,7 @@ class History {
 				SlotLayer.delete(Context.raw.layer);
 			}
 			else if (step.name == tr("Order Layers")) {
-				let target = Project.layers[step.prev_order];
+				let target: SlotLayerRaw = Project.layers[step.prev_order];
 				Project.layers[step.prev_order] = Project.layers[step.layer];
 				Project.layers[step.layer] = target;
 			}
@@ -86,103 +86,105 @@ class History {
 				Context.raw.layer = Project.layers[step.layer];
 				SlotLayer.delete(Context.raw.layer);
 
-				let parent = step.layer_parent > 0 ? Project.layers[step.layer_parent - 2] : null;
-				let l = SlotLayer.create("", step.layer_type, parent);
+				let parent: SlotLayerRaw = step.layer_parent > 0 ? Project.layers[step.layer_parent - 2] : null;
+				let l: SlotLayerRaw = SlotLayer.create("", step.layer_type, parent);
 				Project.layers.splice(step.layer, 0, l);
-				Context.setLayer(l);
+				Context.set_layer(l);
 
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
 
 				l = SlotLayer.create("", step.layer_type, parent);
 				Project.layers.splice(step.layer + 1, 0, l);
-				Context.setLayer(l);
+				Context.set_layer(l);
 
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				lay = History.undoLayers[History.undoI];
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				lay = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
 
 				Context.raw.layer.maskOpacity = step.layer_opacity;
 				Context.raw.layer.blending = step.layer_blending;
 				Context.raw.layer.objectMask = step.layer_object;
-				Context.raw.layersPreviewDirty = true;
-				MakeMaterial.parseMeshMaterial();
+				Context.raw.layers_preview_dirty = true;
+				MakeMaterial.parse_mesh_material();
 			}
 			else if (step.name == tr("Apply Mask")) {
 				// First restore the layer(s)
-				let maskPosition = step.layer;
-				let currentLayer = null;
+				let maskPosition: i32 = step.layer;
+				let currentLayer: SlotLayerRaw = null;
 				// The layer at the old mask position is a mask, i.e. the layer had multiple masks before.
-				if (SlotLayer.isMask(Project.layers[maskPosition]))
+				if (SlotLayer.is_mask(Project.layers[maskPosition])) {
 					currentLayer = Project.layers[maskPosition].parent;
-				else if (SlotLayer.isLayer(Project.layers[maskPosition]) || SlotLayer.isGroup(Project.layers[maskPosition]))
+				}
+				else if (SlotLayer.is_layer(Project.layers[maskPosition]) || SlotLayer.is_group(Project.layers[maskPosition])) {
 					currentLayer = Project.layers[maskPosition];
+				}
 
-				let layersToRestore = SlotLayer.isGroup(currentLayer) ? SlotLayer.getChildren(currentLayer) : [currentLayer];
+				let layersToRestore: SlotLayerRaw[] = SlotLayer.is_group(currentLayer) ? SlotLayer.get_children(currentLayer) : [currentLayer];
 				layersToRestore.reverse();
 
 				for (let layer of layersToRestore) {
 					// Replace the current layer's content with the old one
 					Context.raw.layer = layer;
-					History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-					let oldLayer = History.undoLayers[History.undoI];
+					History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+					let oldLayer: SlotLayerRaw = History.undo_layers[History.undo_i];
 					SlotLayer.swap(Context.raw.layer, oldLayer);
 				}
 
 				// Now restore the applied mask
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let mask = History.undoLayers[History.undoI];
-				Base.newMask(false, currentLayer, maskPosition);
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let mask: SlotLayerRaw = History.undo_layers[History.undo_i];
+				Base.new_mask(false, currentLayer, maskPosition);
 				SlotLayer.swap(Context.raw.layer, mask);
-				Context.raw.layersPreviewDirty = true;
-				Context.setLayer(Context.raw.layer);
+				Context.raw.layers_preview_dirty = true;
+				Context.set_layer(Context.raw.layer);
 			}
 			else if (step.name == tr("Invert Mask")) {
 				let _next = () => {
 					Context.raw.layer = Project.layers[step.layer];
-					SlotLayer.invertMask(Context.raw.layer);
+					SlotLayer.invert_mask(Context.raw.layer);
 				}
 				app_notify_on_init(_next);
 			}
 			else if (step.name == "Apply Filter") {
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
-				Context.setLayer(Project.layers[step.layer]);
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
+				Context.set_layer(Project.layers[step.layer]);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Base.newMask(false, Context.raw.layer);
+				Base.new_mask(false, Context.raw.layer);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Context.raw.layerPreviewDirty = true;
+				Context.raw.layer_preview_dirty = true;
 			}
 			else if (step.name == tr("To Fill Layer") || step.name == tr("To Fill Mask")) {
-				SlotLayer.toPaintLayer(Context.raw.layer);
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
+				SlotLayer.to_paint_layer(Context.raw.layer);
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
 			}
 			else if (step.name == tr("To Paint Layer") || step.name == tr("To Paint Mask")) {
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
 				Context.raw.layer.fill_layer = Project.materials[step.material];
 			}
 			else if (step.name == tr("Layer Opacity")) {
-				Context.setLayer(Project.layers[step.layer]);
-				let t = Context.raw.layer.maskOpacity;
+				Context.set_layer(Project.layers[step.layer]);
+				let t: f32 = Context.raw.layer.maskOpacity;
 				Context.raw.layer.maskOpacity = step.layer_opacity;
 				step.layer_opacity = t;
-				MakeMaterial.parseMeshMaterial();
+				MakeMaterial.parse_mesh_material();
 			}
 			else if (step.name == tr("Layer Blending")) {
-				Context.setLayer(Project.layers[step.layer]);
-				let t = Context.raw.layer.blending;
+				Context.set_layer(Project.layers[step.layer]);
+				let t: blend_type_t = Context.raw.layer.blending;
 				Context.raw.layer.blending = step.layer_blending;
 				step.layer_blending = t;
-				MakeMaterial.parseMeshMaterial();
+				MakeMaterial.parse_mesh_material();
 			}
 			else if (step.name == tr("Delete Node Group")) {
-				Project.materialGroups.splice(step.canvas_group, 0, { canvas: null, nodes: zui_nodes_create() });
-				History.swapCanvas(step);
+				Project.material_groups.splice(step.canvas_group, 0, { canvas: null, nodes: zui_nodes_create() });
+				History.swap_canvas(step);
 			}
 			else if (step.name == tr("New Material")) {
 				Context.raw.material = Project.materials[step.material];
@@ -193,7 +195,7 @@ class History {
 				Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 				Project.materials.splice(step.material, 0, Context.raw.material);
 				Context.raw.material.canvas = step.canvas;
-				UINodes.canvasChanged();
+				UINodes.canvas_changed();
 				UINodes.hwnd.redraws = 2;
 			}
 			else if (step.name == tr("Duplicate Material")) {
@@ -202,12 +204,12 @@ class History {
 				SlotMaterial.delete(Context.raw.material);
 			}
 			else { // Paint operation
-				History.undoI = History.undoI - 1 < 0 ? Config.raw.undo_steps - 1 : History.undoI - 1;
-				let lay = History.undoLayers[History.undoI];
-				Context.selectPaintObject(Project.paintObjects[step.object]);
-				Context.setLayer(Project.layers[step.layer]);
+				History.undo_i = History.undo_i - 1 < 0 ? Config.raw.undo_steps - 1 : History.undo_i - 1;
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
+				Context.select_paint_object(Project.paint_objects[step.object]);
+				Context.set_layer(Project.layers[step.layer]);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Context.raw.layerPreviewDirty = true;
+				Context.raw.layer_preview_dirty = true;
 			}
 			///end
 
@@ -216,15 +218,15 @@ class History {
 			Context.raw.ddirty = 2;
 
 			///if (is_paint || is_sculpt)
-			UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-			UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+			UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+			UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 			if (UIView2D.show) {
 				UIView2D.hwnd.redraws = 2;
 			}
 
 			if (Config.raw.touch_ui) {
 				// Refresh undo & redo buttons
-				UIMenubar.menuHandle.redraws = 2;
+				UIMenubar.menu_handle.redraws = 2;
 			}
 			///end
 		}
@@ -232,153 +234,153 @@ class History {
 
 	static redo = () => {
 		if (History.redos > 0) {
-			let active = History.steps.length - History.redos;
-			let step = History.steps[active];
+			let active: i32 = History.steps.length - History.redos;
+			let step: step_t = History.steps[active];
 
 			if (step.name == tr("Edit Nodes")) {
-				History.swapCanvas(step);
+				History.swap_canvas(step);
 			}
 
 			///if (is_paint || is_sculpt)
 			else if (step.name == tr("New Layer") || step.name == tr("New Black Mask") || step.name == tr("New White Mask") || step.name == tr("New Fill Mask")) {
-				let parent = step.layer_parent > 0 ? Project.layers[step.layer_parent - 1] : null;
-				let l = SlotLayer.create("", step.layer_type, parent);
+				let parent: SlotLayerRaw = step.layer_parent > 0 ? Project.layers[step.layer_parent - 1] : null;
+				let l: SlotLayerRaw = SlotLayer.create("", step.layer_type, parent);
 				Project.layers.splice(step.layer, 0, l);
 				if (step.name == tr("New Black Mask")) {
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						SlotLayer.clear(l, 0x00000000);
 					});
 				}
 				else if (step.name == tr("New White Mask")) {
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						SlotLayer.clear(l, 0xffffffff);
 					});
 				}
 				else if (step.name == tr("New Fill Mask")) {
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						Context.raw.material = Project.materials[step.material];
-						SlotLayer.toFillLayer(l);
+						SlotLayer.to_fill_layer(l);
 					});
 				}
-				Context.raw.layerPreviewDirty = true;
-				Context.setLayer(l);
+				Context.raw.layer_preview_dirty = true;
+				Context.set_layer(l);
 			}
 			else if (step.name == tr("New Group")) {
-				let l = Project.layers[step.layer - 1];
-				let group = Base.newGroup();
+				let l: SlotLayerRaw = Project.layers[step.layer - 1];
+				let group: SlotLayerRaw = Base.new_group();
 				array_remove(Project.layers, group);
 				Project.layers.splice(step.layer, 0, group);
 				l.parent = group;
-				Context.setLayer(group);
+				Context.set_layer(group);
 			}
 			else if (step.name == tr("Delete Layer")) {
 				Context.raw.layer = Project.layers[step.layer];
-				History.swapActive();
+				History.swap_active();
 				SlotLayer.delete(Context.raw.layer);
 
 				// Redoing the last delete would result in an empty group
 				// Redo deleting all group masks + the group itself
-				if (step.layer_type == LayerSlotType.SlotLayer && History.steps.length >= active + 2 && (History.steps[active + 1].layer_type == LayerSlotType.SlotGroup || History.steps[active + 1].layer_type == LayerSlotType.SlotMask)) {
-					let n = 1;
-					while (History.steps[active + n].layer_type == LayerSlotType.SlotMask) {
+				if (step.layer_type == layer_slot_type_t.LAYER && History.steps.length >= active + 2 && (History.steps[active + 1].layer_type == layer_slot_type_t.GROUP || History.steps[active + 1].layer_type == layer_slot_type_t.MASK)) {
+					let n: i32 = 1;
+					while (History.steps[active + n].layer_type == layer_slot_type_t.MASK) {
 						++n;
 					}
-					Base.notifyOnNextFrame(() => {
-						for (let i = 0; i < n; ++i) History.redo();
+					Base.notify_on_next_frame(() => {
+						for (let i: i32 = 0; i < n; ++i) History.redo();
 					});
 				}
 			}
 			else if (step.name == tr("Clear Layer")) {
 				Context.raw.layer = Project.layers[step.layer];
-				History.swapActive();
+				History.swap_active();
 				SlotLayer.clear(Context.raw.layer);
-				Context.raw.layerPreviewDirty = true;
+				Context.raw.layer_preview_dirty = true;
 			}
 			else if (step.name == tr("Duplicate Layer")) {
 				Context.raw.layer = Project.layers[step.layer];
 				let _next = () => {
-					Base.duplicateLayer(Context.raw.layer);
+					Base.duplicate_layer(Context.raw.layer);
 				}
-				Base.notifyOnNextFrame(_next);
+				Base.notify_on_next_frame(_next);
 			}
 			else if (step.name == tr("Order Layers")) {
-				let target = Project.layers[step.prev_order];
+				let target: SlotLayerRaw = Project.layers[step.prev_order];
 				Project.layers[step.prev_order] = Project.layers[step.layer];
 				Project.layers[step.layer] = target;
 			}
 			else if (step.name == tr("Merge Layers")) {
 				Context.raw.layer = Project.layers[step.layer + 1];
-				app_notify_on_init(History.redoMergeLayers);
-				app_notify_on_init(Base.mergeDown);
+				app_notify_on_init(History.redo_merge_layers);
+				app_notify_on_init(Base.merge_down);
 			}
 			else if (step.name == tr("Apply Mask")) {
 				Context.raw.layer = Project.layers[step.layer];
-					if (SlotLayer.isGroupMask(Context.raw.layer)) {
-						let group = Context.raw.layer.parent;
-						let layers = SlotLayer.getChildren(group);
+					if (SlotLayer.is_group_mask(Context.raw.layer)) {
+						let group: SlotLayerRaw = Context.raw.layer.parent;
+						let layers: SlotLayerRaw[] = SlotLayer.get_children(group);
 						layers.splice(0, 0, Context.raw.layer);
-						History.copyMergingLayers2(layers);
+						History.copy_merging_layers2(layers);
 					}
-					else History.copyMergingLayers2([Context.raw.layer, Context.raw.layer.parent]);
+					else History.copy_merging_layers2([Context.raw.layer, Context.raw.layer.parent]);
 
 				let _next = () => {
-					SlotLayer.applyMask(Context.raw.layer);
-					Context.setLayer(Context.raw.layer);
-					Context.raw.layersPreviewDirty = true;
+					SlotLayer.apply_mask(Context.raw.layer);
+					Context.set_layer(Context.raw.layer);
+					Context.raw.layers_preview_dirty = true;
 				}
-				Base.notifyOnNextFrame(_next);
+				Base.notify_on_next_frame(_next);
 			}
 			else if (step.name == tr("Invert Mask")) {
 				let _next = () => {
 					Context.raw.layer = Project.layers[step.layer];
-					SlotLayer.invertMask(Context.raw.layer);
+					SlotLayer.invert_mask(Context.raw.layer);
 				}
 				app_notify_on_init(_next);
 			}
 			else if (step.name == tr("Apply Filter")) {
-				let lay = History.undoLayers[History.undoI];
-				Context.setLayer(Project.layers[step.layer]);
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
+				Context.set_layer(Project.layers[step.layer]);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Base.newMask(false, lay);
+				Base.new_mask(false, lay);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Context.raw.layerPreviewDirty = true;
-				History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+				Context.raw.layer_preview_dirty = true;
+				History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 			}
 			else if (step.name == tr("To Fill Layer") || step.name == tr("To Fill Mask")) {
-				let lay = History.undoLayers[History.undoI];
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
 				Context.raw.layer.fill_layer = Project.materials[step.material];
-				History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+				History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 			}
 			else if (step.name == tr("To Paint Layer") || step.name == tr("To Paint Mask")) {
-				SlotLayer.toPaintLayer(Context.raw.layer);
-				let lay = History.undoLayers[History.undoI];
+				SlotLayer.to_paint_layer(Context.raw.layer);
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
 				SlotLayer.swap(Context.raw.layer, lay);
-				History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+				History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 			}
 			else if (step.name == tr("Layer Opacity")) {
-				Context.setLayer(Project.layers[step.layer]);
-				let t = Context.raw.layer.maskOpacity;
+				Context.set_layer(Project.layers[step.layer]);
+				let t: f32 = Context.raw.layer.maskOpacity;
 				Context.raw.layer.maskOpacity = step.layer_opacity;
 				step.layer_opacity = t;
-				MakeMaterial.parseMeshMaterial();
+				MakeMaterial.parse_mesh_material();
 			}
 			else if (step.name == tr("Layer Blending")) {
-				Context.setLayer(Project.layers[step.layer]);
-				let t = Context.raw.layer.blending;
+				Context.set_layer(Project.layers[step.layer]);
+				let t: blend_type_t = Context.raw.layer.blending;
 				Context.raw.layer.blending = step.layer_blending;
 				step.layer_blending = t;
-				MakeMaterial.parseMeshMaterial();
+				MakeMaterial.parse_mesh_material();
 			}
 			else if (step.name == tr("Delete Node Group")) {
-				History.swapCanvas(step);
-				array_remove(Project.materialGroups, Project.materialGroups[step.canvas_group]);
+				History.swap_canvas(step);
+				array_remove(Project.material_groups, Project.material_groups[step.canvas_group]);
 			}
 			else if (step.name == tr("New Material")) {
 				Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 				Project.materials.splice(step.material, 0, Context.raw.material);
 				Context.raw.material.canvas = step.canvas;
-				UINodes.canvasChanged();
+				UINodes.canvas_changed();
 				UINodes.hwnd.redraws = 2;
 			}
 			else if (step.name == tr("Delete Material")) {
@@ -390,16 +392,16 @@ class History {
 				Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 				Project.materials.splice(step.material, 0, Context.raw.material);
 				Context.raw.material.canvas = step.canvas;
-				UINodes.canvasChanged();
+				UINodes.canvas_changed();
 				UINodes.hwnd.redraws = 2;
 			}
 			else { // Paint operation
-				let lay = History.undoLayers[History.undoI];
-				Context.selectPaintObject(Project.paintObjects[step.object]);
-				Context.setLayer(Project.layers[step.layer]);
+				let lay: SlotLayerRaw = History.undo_layers[History.undo_i];
+				Context.select_paint_object(Project.paint_objects[step.object]);
+				Context.set_layer(Project.layers[step.layer]);
 				SlotLayer.swap(Context.raw.layer, lay);
-				Context.raw.layerPreviewDirty = true;
-				History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+				Context.raw.layer_preview_dirty = true;
+				History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 			}
 			///end
 
@@ -408,13 +410,13 @@ class History {
 			Context.raw.ddirty = 2;
 
 			///if (is_paint || is_sculpt)
-			UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-			UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+			UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+			UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 			if (UIView2D.show) UIView2D.hwnd.redraws = 2;
 
 			if (Config.raw.touch_ui) {
 				// Refresh undo & redo buttons
-				UIMenubar.menuHandle.redraws = 2;
+				UIMenubar.menu_handle.redraws = 2;
 			}
 			///end
 		}
@@ -422,7 +424,7 @@ class History {
 
 	static reset = () => {
 		///if (is_paint || is_sculpt)
-		History.steps = [{name: tr("New"), layer: 0, layer_type: LayerSlotType.SlotLayer, layer_parent: -1, object: 0, material: 0, brush: 0}];
+		History.steps = [{name: tr("New"), layer: 0, layer_type: layer_slot_type_t.LAYER, layer_parent: -1, object: 0, material: 0, brush: 0}];
 		///end
 		///if is_lab
 		History.steps = [{name: tr("New")}];
@@ -430,16 +432,16 @@ class History {
 
 		History.undos = 0;
 		History.redos = 0;
-		History.undoI = 0;
+		History.undo_i = 0;
 	}
 
 	///if (is_paint || is_sculpt)
-	static editNodes = (canvas: zui_node_canvas_t, canvas_type: i32, canvas_group: Null<i32> = null) => {
+	static edit_nodes = (canvas: zui_node_canvas_t, canvas_type: i32, canvas_group: Null<i32> = null) => {
 	///end
 	///if is_lab
-	static editNodes = (canvas: zui_node_canvas_t, canvas_group: Null<i32> = null) => {
+	static edit_nodes = (canvas: zui_node_canvas_t, canvas_group: Null<i32> = null) => {
 	///end
-		let step = History.push(tr("Edit Nodes"));
+		let step: step_t = History.push(tr("Edit Nodes"));
 		step.canvas_group = canvas_group;
 		///if (is_paint || is_sculpt)
 		step.canvas_type = canvas_type;
@@ -449,171 +451,171 @@ class History {
 
 	///if (is_paint || is_sculpt)
 	static paint = () => {
-		let isMask = SlotLayer.isMask(Context.raw.layer);
-		History.copyToUndo(Context.raw.layer.id, History.undoI, isMask);
+		let isMask: bool = SlotLayer.is_mask(Context.raw.layer);
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, isMask);
 
-		History.pushUndo = false;
-		History.push(tr(UIToolbar.toolNames[Context.raw.tool]));
+		History.push_undo = false;
+		History.push(tr(UIToolbar.tool_names[Context.raw.tool]));
 	}
 
-	static newLayer = () => {
+	static new_layer = () => {
 		History.push(tr("New Layer"));
 	}
 
-	static newBlackMask = () => {
+	static new_black_mask = () => {
 		History.push(tr("New Black Mask"));
 	}
 
-	static newWhiteMask = () => {
+	static new_white_mask = () => {
 		History.push(tr("New White Mask"));
 	}
 
-	static newFillMask = () => {
+	static new_fill_mask = () => {
 		History.push(tr("New Fill Mask"));
 	}
 
-	static newGroup = () => {
+	static new_group = () => {
 		History.push(tr("New Group"));
 	}
 
-	static duplicateLayer = () => {
+	static duplicate_layer = () => {
 		History.push(tr("Duplicate Layer"));
 	}
 
-	static deleteLayer = () => {
-		History.swapActive();
+	static delete_layer = () => {
+		History.swap_active();
 		History.push(tr("Delete Layer"));
 	}
 
-	static clearLayer = () => {
-		History.swapActive();
+	static clear_layer = () => {
+		History.swap_active();
 		History.push(tr("Clear Layer"));
 	}
 
-	static orderLayers = (prevOrder: i32) => {
-		let step = History.push(tr("Order Layers"));
+	static order_layers = (prevOrder: i32) => {
+		let step: step_t = History.push(tr("Order Layers"));
 		step.prev_order = prevOrder;
 	}
 
-	static mergeLayers = () => {
-		History.copyMergingLayers();
+	static merge_layers = () => {
+		History.copy_merging_layers();
 
-		let step = History.push(tr("Merge Layers"));
+		let step: step_t = History.push(tr("Merge Layers"));
 		step.layer -= 1; // Merge down
-		if (SlotLayer.hasMasks(Context.raw.layer)) {
-			step.layer -= SlotLayer.getMasks(Context.raw.layer).length;
+		if (SlotLayer.has_masks(Context.raw.layer)) {
+			step.layer -= SlotLayer.get_masks(Context.raw.layer).length;
 		}
 		History.steps.shift(); // Merge consumes 2 steps
 		History.undos--;
 		// TODO: use undo layer in app_merge_down to save memory
 	}
 
-	static applyMask = () => {
-		if (SlotLayer.isGroupMask(Context.raw.layer)) {
-			let group = Context.raw.layer.parent;
-			let layers = SlotLayer.getChildren(group);
+	static apply_mask = () => {
+		if (SlotLayer.is_group_mask(Context.raw.layer)) {
+			let group: SlotLayerRaw = Context.raw.layer.parent;
+			let layers: SlotLayerRaw[] = SlotLayer.get_children(group);
 			layers.splice(0, 0, Context.raw.layer);
-			History.copyMergingLayers2(layers);
+			History.copy_merging_layers2(layers);
 		}
-		else History.copyMergingLayers2([Context.raw.layer, Context.raw.layer.parent]);
+		else History.copy_merging_layers2([Context.raw.layer, Context.raw.layer.parent]);
 		History.push(tr("Apply Mask"));
 	}
 
 
-	static invertMask = () => {
+	static invert_mask = () => {
 		History.push(tr("Invert Mask"));
 	}
 
-	static applyFilter = () => {
-		History.copyToUndo(Context.raw.layer.id, History.undoI, true);
+	static apply_filter = () => {
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, true);
 		History.push(tr("Apply Filter"));
 	}
 
-	static toFillLayer = () => {
-		History.copyToUndo(Context.raw.layer.id, History.undoI, false);
+	static to_fill_layer = () => {
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, false);
 		History.push(tr("To Fill Layer"));
 	}
 
-	static toFillMask = () => {
-		History.copyToUndo(Context.raw.layer.id, History.undoI, true);
+	static to_fill_mask = () => {
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, true);
 		History.push(tr("To Fill Mask"));
 	}
 
-	static toPaintLayer = () => {
-		History.copyToUndo(Context.raw.layer.id, History.undoI, false);
+	static to_paint_layer = () => {
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, false);
 		History.push(tr("To Paint Layer"));
 	}
 
-	static toPaintMask = () => {
-		History.copyToUndo(Context.raw.layer.id, History.undoI, true);
+	static to_paint_mask = () => {
+		History.copy_to_undo(Context.raw.layer.id, History.undo_i, true);
 		History.push(tr("To Paint Mask"));
 	}
 
-	static layerOpacity = () => {
+	static layer_opacity = () => {
 		History.push(tr("Layer Opacity"));
 	}
 
-	// static layerObject = () => {
+	// static layer_object = () => {
 	// 	History.push("Layer Object");
 	// }
 
-	static layerBlending = () => {
+	static layer_blending = () => {
 		History.push(tr("Layer Blending"));
 	}
 
-	static newMaterial = () => {
-		let step = History.push(tr("New Material"));
+	static new_material = () => {
+		let step: step_t = History.push(tr("New Material"));
 		step.canvas_type = 0;
 		step.canvas = JSON.parse(JSON.stringify(Context.raw.material.canvas));
 	}
 
-	static deleteMaterial = () => {
-		let step = History.push(tr("Delete Material"));
+	static delete_material = () => {
+		let step: step_t = History.push(tr("Delete Material"));
 		step.canvas_type = 0;
 		step.canvas = JSON.parse(JSON.stringify(Context.raw.material.canvas));
 	}
 
-	static duplicateMaterial = () => {
-		let step = History.push(tr("Duplicate Material"));
+	static duplicate_material = () => {
+		let step: step_t = History.push(tr("Duplicate Material"));
 		step.canvas_type = 0;
 		step.canvas = JSON.parse(JSON.stringify(Context.raw.material.canvas));
 	}
 
-	static deleteMaterialGroup = (group: TNodeGroup) => {
-		let step = History.push(tr("Delete Node Group"));
-		step.canvas_type = CanvasType.CanvasMaterial;
-		step.canvas_group = Project.materialGroups.indexOf(group);
+	static delete_material_group = (group: node_group_t) => {
+		let step: step_t = History.push(tr("Delete Node Group"));
+		step.canvas_type = canvas_type_t.MATERIAL;
+		step.canvas_group = Project.material_groups.indexOf(group);
 		step.canvas = JSON.parse(JSON.stringify(group.canvas));
 	}
 	///end
 
-	static push = (name: string): TStep => {
+	static push = (name: string): step_t => {
 		///if (krom_windows || krom_linux || krom_darwin)
-		let filename = Project.filepath == "" ? UIFiles.filename : Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
+		let filename: string = Project.filepath == "" ? UIFiles.filename : Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
 		sys_title_set(filename + "* - " + manifest_title);
 		///end
 
 		if (Config.raw.touch_ui) {
 			// Refresh undo & redo buttons
-			UIMenubar.menuHandle.redraws = 2;
+			UIMenubar.menu_handle.redraws = 2;
 		}
 
 		if (History.undos < Config.raw.undo_steps) History.undos++;
 		if (History.redos > 0) {
-			for (let i = 0; i < History.redos; ++i) History.steps.pop();
+			for (let i: i32 = 0; i < History.redos; ++i) History.steps.pop();
 			History.redos = 0;
 		}
 
 		///if (is_paint || is_sculpt)
-		let opos = Project.paintObjects.indexOf(Context.raw.paintObject);
-		let lpos = Project.layers.indexOf(Context.raw.layer);
-		let mpos = Project.materials.indexOf(Context.raw.material);
-		let bpos = Project.brushes.indexOf(Context.raw.brush);
+		let opos: i32 = Project.paint_objects.indexOf(Context.raw.paint_object);
+		let lpos: i32 = Project.layers.indexOf(Context.raw.layer);
+		let mpos: i32 = Project.materials.indexOf(Context.raw.material);
+		let bpos: i32 = Project.brushes.indexOf(Context.raw.brush);
 
 		History.steps.push({
 			name: name,
 			layer: lpos,
-			layer_type: SlotLayer.isMask(Context.raw.layer) ? LayerSlotType.SlotMask : SlotLayer.isGroup(Context.raw.layer) ? LayerSlotType.SlotGroup : LayerSlotType.SlotLayer,
+			layer_type: SlotLayer.is_mask(Context.raw.layer) ? layer_slot_type_t.MASK : SlotLayer.is_group(Context.raw.layer) ? layer_slot_type_t.GROUP : layer_slot_type_t.LAYER,
 			layer_parent: Context.raw.layer.parent == null ? -1 : Project.layers.indexOf(Context.raw.layer.parent),
 			object: opos,
 			material: mpos,
@@ -635,31 +637,31 @@ class History {
 	}
 
 	///if (is_paint || is_sculpt)
-	static redoMergeLayers = () => {
-		History.copyMergingLayers();
+	static redo_merge_layers = () => {
+		History.copy_merging_layers();
 	}
 
-	static copyMergingLayers = () => {
-		let lay = Context.raw.layer;
-		History.copyToUndo(lay.id, History.undoI, SlotLayer.isMask(Context.raw.layer));
+	static copy_merging_layers = () => {
+		let lay: SlotLayerRaw = Context.raw.layer;
+		History.copy_to_undo(lay.id, History.undo_i, SlotLayer.is_mask(Context.raw.layer));
 
-		let below = Project.layers.indexOf(lay) - 1;
+		let below: i32 = Project.layers.indexOf(lay) - 1;
 		lay = Project.layers[below];
-		History.copyToUndo(lay.id, History.undoI, SlotLayer.isMask(Context.raw.layer));
+		History.copy_to_undo(lay.id, History.undo_i, SlotLayer.is_mask(Context.raw.layer));
 	}
 
-	static copyMergingLayers2 = (layers: SlotLayerRaw[]) => {
+	static copy_merging_layers2 = (layers: SlotLayerRaw[]) => {
 		for (let layer of layers)
-		History.copyToUndo(layer.id, History.undoI, SlotLayer.isMask(layer));
+		History.copy_to_undo(layer.id, History.undo_i, SlotLayer.is_mask(layer));
 	}
 
-	static swapActive = () => {
-		let undoLayer = History.undoLayers[History.undoI];
+	static swap_active = () => {
+		let undoLayer: SlotLayerRaw = History.undo_layers[History.undo_i];
 		SlotLayer.swap(undoLayer, Context.raw.layer);
-		History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+		History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 	}
 
-	static copyToUndo = (fromId: i32, toId: i32, isMask: bool) => {
+	static copy_to_undo = (fromId: i32, toId: i32, isMask: bool) => {
 
 		///if is_sculpt
 		isMask = true;
@@ -678,15 +680,15 @@ class History {
 			render_path_bind_target("texpaint_pack" + fromId, "tex2");
 			render_path_draw_shader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
 		}
-		History.undoI = (History.undoI + 1) % Config.raw.undo_steps;
+		History.undo_i = (History.undo_i + 1) % Config.raw.undo_steps;
 	}
 	///end
 
-	static getCanvasOwner = (step: TStep): any => {
+	static get_canvas_owner = (step: step_t): any => {
 		///if (is_paint || is_sculpt)
 		return step.canvas_group == null ?
 			Project.materials[step.material] :
-			Project.materialGroups[step.canvas_group];
+			Project.material_groups[step.canvas_group];
 		///end
 
 		///if is_lab
@@ -694,16 +696,16 @@ class History {
 		///end
 	}
 
-	static swapCanvas = (step: TStep) => {
+	static swap_canvas = (step: step_t) => {
 		///if (is_paint || is_sculpt)
 		if (step.canvas_type == 0) {
-			let _canvas = History.getCanvasOwner(step).canvas;
-			History.getCanvasOwner(step).canvas = step.canvas;
+			let _canvas: zui_node_canvas_t = History.get_canvas_owner(step).canvas;
+			History.get_canvas_owner(step).canvas = step.canvas;
 			step.canvas = _canvas;
 			Context.raw.material = Project.materials[step.material];
 		}
 		else {
-			let _canvas = Project.brushes[step.brush].canvas;
+			let _canvas: zui_node_canvas_t = Project.brushes[step.brush].canvas;
 			Project.brushes[step.brush].canvas = step.canvas;
 			step.canvas = _canvas;
 			Context.raw.brush = Project.brushes[step.brush];
@@ -711,31 +713,31 @@ class History {
 		///end
 
 		///if is_lab
-		let _canvas = History.getCanvasOwner(step).canvas;
-		History.getCanvasOwner(step).canvas = step.canvas;
+		let _canvas: zui_node_canvas_t = History.get_canvas_owner(step).canvas;
+		History.get_canvas_owner(step).canvas = step.canvas;
 		step.canvas = _canvas;
 		///end
 
-		UINodes.canvasChanged();
+		UINodes.canvas_changed();
 		UINodes.hwnd.redraws = 2;
 	}
 }
 
-type TStep = {
-	name: string;
+type step_t = {
+	name?: string;
 	canvas?: zui_node_canvas_t; // Node history
 	canvas_group?: i32;
 	///if (is_paint || is_sculpt)
-	layer: i32;
-	layer_type: LayerSlotType;
-	layer_parent: i32;
-	object: i32;
-	material: i32;
-	brush: i32;
+	layer?: i32;
+	layer_type?: layer_slot_type_t;
+	layer_parent?: i32;
+	object?: i32;
+	material?: i32;
+	brush?: i32;
 	layer_opacity?: f32;
 	layer_object?: i32;
 	layer_blending?: i32;
 	prev_order?: i32; // Previous layer position
 	canvas_type?: i32;
 	///end
-}
+};

+ 150 - 150
base/Sources/ImportArm.ts

@@ -1,37 +1,37 @@
 
 class ImportArm {
 
-	static runProject = (path: string) => {
+	static run_project = (path: string) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let project: TProjectFormat = armpack_decode(b);
+		let project: project_format_t = armpack_decode(b);
 
 		///if (is_paint || is_sculpt)
 		if (project.version != null && project.layer_datas == null) {
 			// Import as material
 			if (project.material_nodes != null) {
-				ImportArm.runMaterialFromProject(project, path);
+				ImportArm.run_material_from_project(project, path);
 			}
 			// Import as brush
 			else if (project.brush_nodes != null) {
-				ImportArm.runBrushFromProject(project, path);
+				ImportArm.run_brush_from_project(project, path);
 			}
 			// Import as swatches
 			else if (project.swatches != null) {
-				ImportArm.runSwatchesFromProject(project, path);
+				ImportArm.run_swatches_from_project(project, path);
 			}
 			return;
 		}
 
-		let importAsMesh = project.version == null;
-		Context.raw.layersPreviewDirty = true;
-		Context.raw.layerFilter = 0;
+		let importAsMesh: bool = project.version == null;
+		Context.raw.layers_preview_dirty = true;
+		Context.raw.layer_filter = 0;
 		///end
 
 		///if is_lab
-		let importAsMesh = true;
+		let importAsMesh: bool = true;
 		///end
 
-		Project.projectNew(importAsMesh);
+		Project.project_new(importAsMesh);
 		Project.filepath = path;
 		UIFiles.filename = path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf("."));
 		///if (krom_android || krom_ios)
@@ -43,18 +43,18 @@ class ImportArm {
 		///if (is_paint || is_sculpt)
 		// Import as mesh instead
 		if (importAsMesh) {
-			ImportArm.runMesh(project);
+			ImportArm.run_mesh(project);
 			return;
 		}
 		///end
 
 		// Save to recent
 		///if krom_ios
-		let recent_path = path.substr(path.lastIndexOf("/") + 1);
+		let recent_path: string = path.substr(path.lastIndexOf("/") + 1);
 		///else
-		let recent_path = path;
+		let recent_path: string = path;
 		///end
-		let recent = Config.raw.recent_projects;
+		let recent: string[] = Config.raw.recent_projects;
 		array_remove(recent, recent_path);
 		recent.unshift(recent_path);
 		Config.save();
@@ -62,15 +62,15 @@ class ImportArm {
 		Project.raw = project;
 
 		///if (is_paint || is_sculpt)
-		let l0 = project.layer_datas[0];
-		Base.resHandle.position = Config.getTextureResPos(l0.res);
-		let bitsPos = l0.bpp == 8 ? TextureBits.Bits8 : l0.bpp == 16 ? TextureBits.Bits16 : TextureBits.Bits32;
-		Base.bitsHandle.position = bitsPos;
-		let bytesPerPixel = Math.floor(l0.bpp / 8);
-		let format = l0.bpp == 8 ? tex_format_t.RGBA32 : l0.bpp == 16 ? tex_format_t.RGBA64 : tex_format_t.RGBA128;
+		let l0: layer_data_t = project.layer_datas[0];
+		Base.res_handle.position = Config.get_texture_res_pos(l0.res);
+		let bitsPos: texture_bits_t = l0.bpp == 8 ? texture_bits_t.BITS8 : l0.bpp == 16 ? texture_bits_t.BITS16 : texture_bits_t.BITS32;
+		Base.bits_handle.position = bitsPos;
+		let bytesPerPixel: i32 = Math.floor(l0.bpp / 8);
+		let format: tex_format_t = l0.bpp == 8 ? tex_format_t.RGBA32 : l0.bpp == 16 ? tex_format_t.RGBA64 : tex_format_t.RGBA128;
 		///end
 
-		let base = Path.baseDir(path);
+		let base: string = Path.base_dir(path);
 		if (Project.raw.envmap != null) {
 			Project.raw.envmap = data_is_abs(Project.raw.envmap) ? Project.raw.envmap : base + Project.raw.envmap;
 		}
@@ -82,7 +82,7 @@ class ImportArm {
 			transform_decompose(scene_camera.base.transform);
 			scene_camera.data.fov = Project.raw.camera_fov;
 			camera_object_build_proj(scene_camera);
-			let origin = Project.raw.camera_origin;
+			let origin: Float32Array = Project.raw.camera_origin;
 			Camera.origins[0].x = origin[0];
 			Camera.origins[0].y = origin[1];
 			Camera.origins[0].z = origin[2];
@@ -95,15 +95,15 @@ class ImportArm {
 			file = string_replace_all(file, "\\", "/");
 			///end
 			// Convert image path from relative to absolute
-			let abs = data_is_abs(file) ? file : base + file;
+			let abs: string = data_is_abs(file) ? file : base + file;
 			if (project.packed_assets != null) {
 				abs = Path.normalize(abs);
-				ImportArm.unpackAsset(project, abs, file);
+				ImportArm.unpack_asset(project, abs, file);
 			}
 			if (data_cached_images.get(abs) == null && !File.exists(abs)) {
-				ImportArm.makePink(abs);
+				ImportArm.make_pink(abs);
 			}
-			let hdrAsEnvmap = abs.endsWith(".hdr") && Project.raw.envmap == abs;
+			let hdrAsEnvmap: bool = abs.endsWith(".hdr") && Project.raw.envmap == abs;
 			ImportTexture.run(abs, hdrAsEnvmap);
 		}
 
@@ -116,7 +116,7 @@ class ImportArm {
 				file = string_replace_all(file, "\\", "/");
 				///end
 				// Convert font path from relative to absolute
-				let abs = data_is_abs(file) ? file : base + file;
+				let abs: string = data_is_abs(file) ? file : base + file;
 				if (File.exists(abs)) {
 					ImportFont.run(abs);
 				}
@@ -132,84 +132,84 @@ class ImportArm {
 		let md: mesh_data_t = mesh_data_create(project.mesh_data);
 		///end
 
-		mesh_object_set_data(Context.raw.paintObject, md);
-		vec4_set(Context.raw.paintObject.base.transform.scale, 1, 1, 1);
-		transform_build_matrix(Context.raw.paintObject.base.transform);
-		Context.raw.paintObject.base.name = md.name;
-		Project.paintObjects = [Context.raw.paintObject];
+		mesh_object_set_data(Context.raw.paint_object, md);
+		vec4_set(Context.raw.paint_object.base.transform.scale, 1, 1, 1);
+		transform_build_matrix(Context.raw.paint_object.base.transform);
+		Context.raw.paint_object.base.name = md.name;
+		Project.paint_objects = [Context.raw.paint_object];
 
 		///if (is_paint || is_sculpt)
-		for (let i = 1; i < project.mesh_datas.length; ++i) {
-			let raw = project.mesh_datas[i];
+		for (let i: i32 = 1; i < project.mesh_datas.length; ++i) {
+			let raw: mesh_data_t = project.mesh_datas[i];
 			let md: mesh_data_t = mesh_data_create(raw);
-			let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base);
+			let object: mesh_object_t = scene_add_mesh_object(md, Context.raw.paint_object.materials, Context.raw.paint_object.base);
 			object.base.name = md.name;
 			object.skip_context = "paint";
-			Project.paintObjects.push(object);
+			Project.paint_objects.push(object);
 		}
 
 		if (project.mesh_assets != null && project.mesh_assets.length > 0) {
-			let file = project.mesh_assets[0];
-			let abs = data_is_abs(file) ? file : base + file;
-			Project.meshAssets = [abs];
+			let file: string = project.mesh_assets[0];
+			let abs: string = data_is_abs(file) ? file : base + file;
+			Project.mesh_assets = [abs];
 		}
 
 		///if is_paint
-		if (project.atlas_objects != null) Project.atlasObjects = project.atlas_objects;
-		if (project.atlas_names != null) Project.atlasNames = project.atlas_names;
+		if (project.atlas_objects != null) Project.atlas_objects = project.atlas_objects;
+		if (project.atlas_names != null) Project.atlas_names = project.atlas_names;
 		///end
 
 		// No mask by default
-		if (Context.raw.mergedObject == null) UtilMesh.mergeMesh();
+		if (Context.raw.merged_object == null) UtilMesh.merge_mesh();
 		///end
 
-		Context.selectPaintObject(Context.mainObject());
-		Viewport.scaleToBounds();
-		Context.raw.paintObject.skip_context = "paint";
-		Context.raw.mergedObject.base.visible = true;
+		Context.select_paint_object(Context.main_object());
+		Viewport.scale_to_bounds();
+		Context.raw.paint_object.skip_context = "paint";
+		Context.raw.merged_object.base.visible = true;
 
 		///if (is_paint || is_sculpt)
-		let tex = Project.layers[0].texpaint;
-		if (tex.width != Config.getTextureResX() || tex.height != Config.getTextureResY()) {
-			if (History.undoLayers != null) for (let l of History.undoLayers) SlotLayer.resizeAndSetBits(l);
-			let rts = render_path_render_targets;
-			let _texpaint_blend0 = rts.get("texpaint_blend0")._image;
-			Base.notifyOnNextFrame(() => {
+		let tex: image_t = Project.layers[0].texpaint;
+		if (tex.width != Config.get_texture_res_x() || tex.height != Config.get_texture_res_y()) {
+			if (History.undo_layers != null) for (let l of History.undo_layers) SlotLayer.resize_and_set_bits(l);
+			let rts: map_t<string, render_target_t> = render_path_render_targets;
+			let _texpaint_blend0: image_t = rts.get("texpaint_blend0")._image;
+			Base.notify_on_next_frame(() => {
 				image_unload(_texpaint_blend0);
 			});
-			rts.get("texpaint_blend0").width = Config.getTextureResX();
-			rts.get("texpaint_blend0").height = Config.getTextureResY();
-			rts.get("texpaint_blend0")._image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8, depth_format_t.NO_DEPTH);
-			let _texpaint_blend1 = rts.get("texpaint_blend1")._image;
-			Base.notifyOnNextFrame(() => {
+			rts.get("texpaint_blend0").width = Config.get_texture_res_x();
+			rts.get("texpaint_blend0").height = Config.get_texture_res_y();
+			rts.get("texpaint_blend0")._image = image_create_render_target(Config.get_texture_res_x(), Config.get_texture_res_y(), tex_format_t.R8, depth_format_t.NO_DEPTH);
+			let _texpaint_blend1: image_t = rts.get("texpaint_blend1")._image;
+			Base.notify_on_next_frame(() => {
 				image_unload(_texpaint_blend1);
 			});
-			rts.get("texpaint_blend1").width = Config.getTextureResX();
-			rts.get("texpaint_blend1").height = Config.getTextureResY();
-			rts.get("texpaint_blend1")._image = image_create_render_target(Config.getTextureResX(), Config.getTextureResY(), tex_format_t.R8, depth_format_t.NO_DEPTH);
-			Context.raw.brushBlendDirty = true;
+			rts.get("texpaint_blend1").width = Config.get_texture_res_x();
+			rts.get("texpaint_blend1").height = Config.get_texture_res_y();
+			rts.get("texpaint_blend1")._image = image_create_render_target(Config.get_texture_res_x(), Config.get_texture_res_y(), tex_format_t.R8, depth_format_t.NO_DEPTH);
+			Context.raw.brush_blend_dirty = true;
 		}
 
 		for (let l of Project.layers) SlotLayer.unload(l);
 		Project.layers = [];
-		for (let i = 0; i < project.layer_datas.length; ++i) {
-			let ld = project.layer_datas[i];
-			let isGroup = ld.texpaint == null;
+		for (let i: i32 = 0; i < project.layer_datas.length; ++i) {
+			let ld: layer_data_t = project.layer_datas[i];
+			let isGroup: bool = ld.texpaint == null;
 
 			///if is_paint
-			let isMask = ld.texpaint != null && ld.texpaint_nor == null;
+			let isMask: bool = ld.texpaint != null && ld.texpaint_nor == null;
 			///end
 			///if is_sculpt
-			let isMask = false;
+			let isMask: bool = false;
 			///end
 
-			let l = SlotLayer.create("", isGroup ? LayerSlotType.SlotGroup : isMask ? LayerSlotType.SlotMask : LayerSlotType.SlotLayer);
+			let l: SlotLayerRaw = SlotLayer.create("", isGroup ? layer_slot_type_t.GROUP : isMask ? layer_slot_type_t.MASK : layer_slot_type_t.LAYER);
 			if (ld.name != null) l.name = ld.name;
 			l.visible = ld.visible;
 			Project.layers.push(l);
 
 			if (!isGroup) {
-				if (Base.pipeMerge == null) Base.makePipe();
+				if (Base.pipe_merge == null) Base.make_pipe();
 
 				let _texpaint: image_t = null;
 
@@ -222,7 +222,7 @@ class ImportArm {
 					_texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4), ld.res, ld.res, tex_format_t.RGBA32);
 					g2_begin(l.texpaint);
 					// g2_set_pipeline(Base.pipeCopy8);
-					g2_set_pipeline(project.is_bgra ? Base.pipeCopyBGRA : Base.pipeCopy); // Full bits for undo support, R8 is used
+					g2_set_pipeline(project.is_bgra ? Base.pipe_copyBGRA : Base.pipe_copy); // Full bits for undo support, R8 is used
 					g2_draw_image(_texpaint, 0, 0);
 					g2_set_pipeline(null);
 					g2_end();
@@ -231,7 +231,7 @@ class ImportArm {
 					// TODO: create render target from bytes
 					_texpaint = image_from_bytes(lz4_decode(ld.texpaint, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
 					g2_begin(l.texpaint);
-					g2_set_pipeline(project.is_bgra ? Base.pipeCopyBGRA : Base.pipeCopy);
+					g2_set_pipeline(project.is_bgra ? Base.pipe_copyBGRA : Base.pipe_copy);
 					g2_draw_image(_texpaint, 0, 0);
 					g2_set_pipeline(null);
 					g2_end();
@@ -239,14 +239,14 @@ class ImportArm {
 					///if is_paint
 					_texpaint_nor = image_from_bytes(lz4_decode(ld.texpaint_nor, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
 					g2_begin(l.texpaint_nor);
-					g2_set_pipeline(project.is_bgra ? Base.pipeCopyBGRA : Base.pipeCopy);
+					g2_set_pipeline(project.is_bgra ? Base.pipe_copyBGRA : Base.pipe_copy);
 					g2_draw_image(_texpaint_nor, 0, 0);
 					g2_set_pipeline(null);
 					g2_end();
 
 					_texpaint_pack = image_from_bytes(lz4_decode(ld.texpaint_pack, ld.res * ld.res * 4 * bytesPerPixel), ld.res, ld.res, format);
 					g2_begin(l.texpaint_pack);
-					g2_set_pipeline(project.is_bgra ? Base.pipeCopyBGRA : Base.pipeCopy);
+					g2_set_pipeline(project.is_bgra ? Base.pipe_copyBGRA : Base.pipe_copy);
 					g2_draw_image(_texpaint_pack, 0, 0);
 					g2_set_pipeline(null);
 					g2_end();
@@ -275,7 +275,7 @@ class ImportArm {
 				l.paintSubs = ld.paint_subs;
 				///end
 
-				Base.notifyOnNextFrame(() => {
+				Base.notify_on_next_frame(() => {
 					image_unload(_texpaint);
 					///if is_paint
 					if (_texpaint_nor != null) image_unload(_texpaint_nor);
@@ -286,65 +286,65 @@ class ImportArm {
 		}
 
 		// Assign parents to groups and masks
-		for (let i = 0; i < project.layer_datas.length; ++i) {
-			let ld = project.layer_datas[i];
+		for (let i: i32 = 0; i < project.layer_datas.length; ++i) {
+			let ld: layer_data_t = project.layer_datas[i];
 			if (ld.parent >= 0) {
 				Project.layers[i].parent = Project.layers[ld.parent];
 			}
 		}
 
-		Context.setLayer(Project.layers[0]);
+		Context.set_layer(Project.layers[0]);
 
 		// Materials
 		let m0: material_data_t = data_get_material("Scene", "Material");
 
 		Project.materials = [];
 		for (let n of project.material_nodes) {
-			ImportArm.initNodes(n.nodes);
+			ImportArm.init_nodes(n.nodes);
 			Context.raw.material = SlotMaterial.create(m0, n);
 			Project.materials.push(Context.raw.material);
 		}
 		///end
 
 		UINodes.hwnd.redraws = 2;
-		UINodes.groupStack = [];
-		Project.materialGroups = [];
+		UINodes.group_stack = [];
+		Project.material_groups = [];
 		if (project.material_groups != null) {
-			for (let g of project.material_groups) Project.materialGroups.push({ canvas: g, nodes: zui_nodes_create() });
+			for (let g of project.material_groups) Project.material_groups.push({ canvas: g, nodes: zui_nodes_create() });
 		}
 
 		///if (is_paint || is_sculpt)
 		for (let m of Project.materials) {
 			Context.raw.material = m;
-			MakeMaterial.parsePaintMaterial();
-			UtilRender.makeMaterialPreview();
+			MakeMaterial.parse_paint_material();
+			UtilRender.make_material_preview();
 		}
 
 		Project.brushes = [];
 		for (let n of project.brush_nodes) {
-			ImportArm.initNodes(n.nodes);
+			ImportArm.init_nodes(n.nodes);
 			Context.raw.brush = SlotBrush.create(n);
 			Project.brushes.push(Context.raw.brush);
-			MakeMaterial.parseBrush();
-			UtilRender.makeBrushPreview();
+			MakeMaterial.parse_brush();
+			UtilRender.make_brush_preview();
 		}
 
 		// Fill layers
-		for (let i = 0; i < project.layer_datas.length; ++i) {
-			let ld = project.layer_datas[i];
-			let l = Project.layers[i];
-			let isGroup = ld.texpaint == null;
+		for (let i: i32 = 0; i < project.layer_datas.length; ++i) {
+			let ld: layer_data_t = project.layer_datas[i];
+			let l: SlotLayerRaw = Project.layers[i];
+			let isGroup: bool = ld.texpaint == null;
 			if (!isGroup) {
 				l.fill_layer = ld.fill_layer > -1 ? Project.materials[ld.fill_layer] : null;
 			}
 		}
 
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		///end
 
 		///if is_lab
-		ImportArm.initNodes(project.material.nodes);
+		ImportArm.init_nodes(project.material.nodes);
 		Project.canvas = project.material;
 		ParserLogic.parse(Project.canvas);
 		///end
@@ -354,17 +354,17 @@ class ImportArm {
 	}
 
 	///if (is_paint || is_sculpt)
-	static runMesh = (raw: scene_t) => {
-		Project.paintObjects = [];
-		for (let i = 0; i < raw.mesh_datas.length; ++i) {
+	static run_mesh = (raw: scene_t) => {
+		Project.paint_objects = [];
+		for (let i: i32 = 0; i < raw.mesh_datas.length; ++i) {
 			let md: mesh_data_t = mesh_data_create(raw.mesh_datas[i]);
 			let object: mesh_object_t = null;
 			if (i == 0) {
-				mesh_object_set_data(Context.raw.paintObject, md);
-				object = Context.raw.paintObject;
+				mesh_object_set_data(Context.raw.paint_object, md);
+				object = Context.raw.paint_object;
 			}
 			else {
-				object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base);
+				object = scene_add_mesh_object(md, Context.raw.paint_object.materials, Context.raw.paint_object.base);
 				object.base.name = md.name;
 				object.skip_context = "paint";
 				md._.handle = md.name;
@@ -373,23 +373,23 @@ class ImportArm {
 			vec4_set(object.base.transform.scale, 1, 1, 1);
 			transform_build_matrix(object.base.transform);
 			object.base.name = md.name;
-			Project.paintObjects.push(object);
-			UtilMesh.mergeMesh();
-			Viewport.scaleToBounds();
+			Project.paint_objects.push(object);
+			UtilMesh.merge_mesh();
+			Viewport.scale_to_bounds();
 		}
-		app_notify_on_init(Base.initLayers);
+		app_notify_on_init(Base.init_layers);
 		History.reset();
 	}
 
-	static runMaterial = (path: string) => {
+	static run_material = (path: string) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let project: TProjectFormat = armpack_decode(b);
+		let project: project_format_t = armpack_decode(b);
 		if (project.version == null) { data_delete_blob(path); return; }
-		ImportArm.runMaterialFromProject(project, path);
+		ImportArm.run_material_from_project(project, path);
 	}
 
-	static runMaterialFromProject = (project: TProjectFormat, path: string) => {
-		let base = Path.baseDir(path);
+	static run_material_from_project = (project: project_format_t, path: string) => {
+		let base: string = Path.base_dir(path);
 		for (let file of project.assets) {
 			///if krom_windows
 			file = string_replace_all(file, "/", "\\");
@@ -397,13 +397,13 @@ class ImportArm {
 			file = string_replace_all(file, "\\", "/");
 			///end
 			// Convert image path from relative to absolute
-			let abs = data_is_abs(file) ? file : base + file;
+			let abs: string = data_is_abs(file) ? file : base + file;
 			if (project.packed_assets != null) {
 				abs = Path.normalize(abs);
-				ImportArm.unpackAsset(project, abs, file);
+				ImportArm.unpack_asset(project, abs, file);
 			}
 			if (data_cached_images.get(abs) == null && !File.exists(abs)) {
-				ImportArm.makePink(abs);
+				ImportArm.make_pink(abs);
 			}
 			ImportTexture.run(abs);
 		}
@@ -413,43 +413,43 @@ class ImportArm {
 		let imported: SlotMaterialRaw[] = [];
 
 		for (let c of project.material_nodes) {
-			ImportArm.initNodes(c.nodes);
+			ImportArm.init_nodes(c.nodes);
 			Context.raw.material = SlotMaterial.create(m0, c);
 			Project.materials.push(Context.raw.material);
 			imported.push(Context.raw.material);
-			History.newMaterial();
+			History.new_material();
 		}
 
 		if (project.material_groups != null) {
 			for (let c of project.material_groups) {
-				while (ImportArm.groupExists(c)) ImportArm.renameGroup(c.name, imported, project.material_groups); // Ensure unique group name
-				ImportArm.initNodes(c.nodes);
-				Project.materialGroups.push({ canvas: c, nodes: zui_nodes_create() });
+				while (ImportArm.group_exists(c)) ImportArm.rename_group(c.name, imported, project.material_groups); // Ensure unique group name
+				ImportArm.init_nodes(c.nodes);
+				Project.material_groups.push({ canvas: c, nodes: zui_nodes_create() });
 			}
 		}
 
 		let _init = () => {
 			for (let m of imported) {
-				Context.setMaterial(m);
-				MakeMaterial.parsePaintMaterial();
-				UtilRender.makeMaterialPreview();
+				Context.set_material(m);
+				MakeMaterial.parse_paint_material();
+				UtilRender.make_material_preview();
 			}
 		}
 		app_notify_on_init(_init);
 
-		UINodes.groupStack = [];
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		UINodes.group_stack = [];
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		data_delete_blob(path);
 	}
 
-	static groupExists = (c: zui_node_canvas_t): bool => {
-		for (let g of Project.materialGroups) {
+	static group_exists = (c: zui_node_canvas_t): bool => {
+		for (let g of Project.material_groups) {
 			if (g.canvas.name == c.name) return true;
 		}
 		return false;
 	}
 
-	static renameGroup = (name: string, materials: SlotMaterialRaw[], groups: zui_node_canvas_t[]) => {
+	static rename_group = (name: string, materials: SlotMaterialRaw[], groups: zui_node_canvas_t[]) => {
 		for (let m of materials) {
 			for (let n of m.canvas.nodes) {
 				if (n.type == "GROUP" && n.name == name) n.name += ".1";
@@ -463,15 +463,15 @@ class ImportArm {
 		}
 	}
 
-	static runBrush = (path: string) => {
+	static run_brush = (path: string) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let project: TProjectFormat = armpack_decode(b);
+		let project: project_format_t = armpack_decode(b);
 		if (project.version == null) { data_delete_blob(path); return; }
-		ImportArm.runBrushFromProject(project, path);
+		ImportArm.run_brush_from_project(project, path);
 	}
 
-	static runBrushFromProject = (project: TProjectFormat, path: string) => {
-		let base = Path.baseDir(path);
+	static run_brush_from_project = (project: project_format_t, path: string) => {
+		let base: string = Path.base_dir(path);
 		for (let file of project.assets) {
 			///if krom_windows
 			file = string_replace_all(file, "/", "\\");
@@ -479,13 +479,13 @@ class ImportArm {
 			file = string_replace_all(file, "\\", "/");
 			///end
 			// Convert image path from relative to absolute
-			let abs = data_is_abs(file) ? file : base + file;
+			let abs: string = data_is_abs(file) ? file : base + file;
 			if (project.packed_assets != null) {
 				abs = Path.normalize(abs);
-				ImportArm.unpackAsset(project, abs, file);
+				ImportArm.unpack_asset(project, abs, file);
 			}
 			if (data_cached_images.get(abs) == null && !File.exists(abs)) {
-				ImportArm.makePink(abs);
+				ImportArm.make_pink(abs);
 			}
 			ImportTexture.run(abs);
 		}
@@ -493,7 +493,7 @@ class ImportArm {
 		let imported: SlotBrushRaw[] = [];
 
 		for (let n of project.brush_nodes) {
-			ImportArm.initNodes(n.nodes);
+			ImportArm.init_nodes(n.nodes);
 			Context.raw.brush = SlotBrush.create(n);
 			Project.brushes.push(Context.raw.brush);
 			imported.push(Context.raw.brush);
@@ -501,30 +501,30 @@ class ImportArm {
 
 		let _init = () => {
 			for (let b of imported) {
-				Context.setBrush(b);
-				UtilRender.makeBrushPreview();
+				Context.set_brush(b);
+				UtilRender.make_brush_preview();
 			}
 		}
 		app_notify_on_init(_init);
 
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		data_delete_blob(path);
 	}
 	///end
 
-	static runSwatches = (path: string, replaceExisting = false) => {
+	static run_swatches = (path: string, replaceExisting: bool = false) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let project: TProjectFormat = armpack_decode(b);
+		let project: project_format_t = armpack_decode(b);
 		if (project.version == null) { data_delete_blob(path); return; }
-		ImportArm.runSwatchesFromProject(project, path, replaceExisting);
+		ImportArm.run_swatches_from_project(project, path, replaceExisting);
 	}
 
-	static runSwatchesFromProject = (project: TProjectFormat, path: string, replaceExisting = false) => {
+	static run_swatches_from_project = (project: project_format_t, path: string, replaceExisting: bool = false) => {
 		if (replaceExisting) {
 			Project.raw.swatches = [];
 
 			if (project.swatches == null) { // No swatches contained
-				Project.raw.swatches.push(Project.makeSwatch());
+				Project.raw.swatches.push(Project.make_swatch());
 			}
 		}
 
@@ -533,22 +533,22 @@ class ImportArm {
 				Project.raw.swatches.push(s);
 			}
 		}
-		UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+		UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 		data_delete_blob(path);
 	}
 
-	static makePink = (abs: string) => {
+	static make_pink = (abs: string) => {
 		Console.error(Strings.error2() + " " + abs);
-		let b = new Uint8Array(4);
+		let b: Uint8Array = new Uint8Array(4);
 		b[0] = 255;
 		b[1] = 0;
 		b[2] = 255;
 		b[3] = 255;
-		let pink = image_from_bytes(b.buffer, 1, 1);
+		let pink: image_t = image_from_bytes(b.buffer, 1, 1);
 		data_cached_images.set(abs, pink);
 	}
 
-	static textureNodeName = (): string => {
+	static texture_node_name = (): string => {
 		///if (is_paint || is_sculpt)
 		return "TEX_IMAGE";
 		///else
@@ -556,16 +556,16 @@ class ImportArm {
 		///end
 	}
 
-	static initNodes = (nodes: zui_node_t[]) => {
+	static init_nodes = (nodes: zui_node_t[]) => {
 		for (let node of nodes) {
-			if (node.type == ImportArm.textureNodeName()) {
-				node.buttons[0].default_value = Base.getAssetIndex(node.buttons[0].data);
+			if (node.type == ImportArm.texture_node_name()) {
+				node.buttons[0].default_value = Base.get_asset_index(node.buttons[0].data);
 				node.buttons[0].data = "";
 			}
 		}
 	}
 
-	static unpackAsset = (project: TProjectFormat, abs: string, file: string) => {
+	static unpack_asset = (project: project_format_t, abs: string, file: string) => {
 		if (Project.raw.packed_assets == null) {
 			Project.raw.packed_assets = [];
 		}
@@ -578,7 +578,7 @@ class ImportArm {
 			pa.name = Path.normalize(pa.name);
 			if (pa.name == file) pa.name = abs; // From relative to absolute
 			if (pa.name == abs) {
-				if (!Project.packedAssetExists(Project.raw.packed_assets, pa.name)) {
+				if (!Project.packed_asset_exists(Project.raw.packed_assets, pa.name)) {
 					Project.raw.packed_assets.push(pa);
 				}
 				let image: image_t = image_from_encoded_bytes(pa.bytes, pa.name.endsWith(".jpg") ? ".jpg" : ".png");

+ 23 - 23
base/Sources/ImportAsset.ts

@@ -1,20 +1,20 @@
 
 class ImportAsset {
 
-	static run = (path: string, dropX = -1.0, dropY = -1.0, showBox = true, hdrAsEnvmap = true, done: ()=>void = null) => {
+	static run = (path: string, dropX: f32 = -1.0, dropY: f32 = -1.0, showBox: bool = true, hdrAsEnvmap: bool = true, done: ()=>void = null) => {
 
 		if (path.startsWith("cloud")) {
 			let doCacheCloud = () => {
-				File.cacheCloud(path, (abs: string) => {
+				File.cache_cloud(path, (abs: string) => {
 					if (abs == null) return;
 					ImportAsset.run(abs, dropX, dropY, showBox, hdrAsEnvmap, done);
 				});
 			}
 
 			///if (krom_android || krom_ios)
-			Base.notifyOnNextFrame(() => {
+			Base.notify_on_next_frame(() => {
 				Console.toast(tr("Downloading"));
-				Base.notifyOnNextFrame(doCacheCloud);
+				Base.notify_on_next_frame(doCacheCloud);
 			});
 			///else
 			doCacheCloud();
@@ -23,54 +23,54 @@ class ImportAsset {
 			return;
 		}
 
-		if (Path.isMesh(path)) {
-			showBox ? Project.importMeshBox(path) : ImportMesh.run(path);
-			if (dropX > 0) UIBox.clickToHide = false; // Prevent closing when going back to window after drag and drop
+		if (Path.is_mesh(path)) {
+			showBox ? Project.import_mesh_box(path) : ImportMesh.run(path);
+			if (dropX > 0) UIBox.click_to_hide = false; // Prevent closing when going back to window after drag and drop
 		}
-		else if (Path.isTexture(path)) {
+		else if (Path.is_texture(path)) {
 			ImportTexture.run(path, hdrAsEnvmap);
 			// Place image node
-			let x0 = UINodes.wx;
-			let x1 = UINodes.wx + UINodes.ww;
+			let x0: i32 = UINodes.wx;
+			let x1: i32 = UINodes.wx + UINodes.ww;
 			if (UINodes.show && dropX > x0 && dropX < x1) {
-				let assetIndex = 0;
-				for (let i = 0; i < Project.assets.length; ++i) {
+				let assetIndex: i32 = 0;
+				for (let i: i32 = 0; i < Project.assets.length; ++i) {
 					if (Project.assets[i].file == path) {
 						assetIndex = i;
 						break;
 					}
 				}
-				UINodes.acceptAssetDrag(assetIndex);
-				UINodes.getNodes().nodesDrag = false;
+				UINodes.accept_asset_drag(assetIndex);
+				UINodes.get_nodes().nodesDrag = false;
 				UINodes.hwnd.redraws = 2;
 			}
 
 			///if is_paint
-			if (Context.raw.tool == WorkspaceTool.ToolColorId && Project.assetNames.length == 1) {
-				UIHeader.headerHandle.redraws = 2;
+			if (Context.raw.tool == workspace_tool_t.COLORID && Project.asset_names.length == 1) {
+				UIHeader.header_handle.redraws = 2;
 				Context.raw.ddirty = 2;
 			}
 			///end
 		}
-		else if (Path.isProject(path)) {
-			ImportArm.runProject(path);
+		else if (Path.is_project(path)) {
+			ImportArm.run_project(path);
 		}
-		else if (Path.isPlugin(path)) {
+		else if (Path.is_plugin(path)) {
 			ImportPlugin.run(path);
 		}
-		else if (Path.isGimpColorPalette(path)) {
+		else if (Path.is_gimp_color_palette(path)) {
 			ImportGpl.run(path, false);
 		}
 		///if is_paint
-		else if (Path.isFont(path)) {
+		else if (Path.is_font(path)) {
 			ImportFont.run(path);
 		}
-		else if (Path.isFolder(path)) {
+		else if (Path.is_folder(path)) {
 			ImportFolder.run(path);
 		}
 		///end
 		else {
-			if (Context.enableImportPlugin(path)) {
+			if (Context.enable_import_plugin(path)) {
 				ImportAsset.run(path, dropX, dropY, showBox);
 			}
 			else {

+ 46 - 46
base/Sources/ImportBlendMaterial.ts

@@ -5,13 +5,13 @@ class ImportBlendMaterial {
 
 	static run = (path: string) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let bl = ParserBlend.init(b);
+		let bl: BlendRaw = ParserBlend.init(b);
 		if (bl.dna == null) {
 			Console.error(Strings.error3());
 			return;
 		}
 
-		let mats = ParserBlend.get(bl, "Material");
+		let mats: BlHandleRaw[] = ParserBlend.get(bl, "Material");
 		if (mats.length == 0) {
 			Console.error("Error: No materials found");
 			return;
@@ -24,8 +24,8 @@ class ImportBlendMaterial {
 			Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 			Project.materials.push(Context.raw.material);
 			imported.push(Context.raw.material);
-			let nodes = Context.raw.material.nodes;
-			let canvas = Context.raw.material.canvas;
+			let nodes: zui_nodes_t = Context.raw.material.nodes;
+			let canvas: zui_node_canvas_t = Context.raw.material.canvas;
 			canvas.name = BlHandle.get(BlHandle.get(mat, "id"), "name").substr(2); // MAWood
 			let nout: zui_node_t = null;
 			for (let n of canvas.nodes) {
@@ -42,13 +42,13 @@ class ImportBlendMaterial {
 			}
 
 			// Parse nodetree
-			let nodetree = BlHandle.get(mat, "nodetree"); // bNodeTree
-			let blnodes = BlHandle.get(nodetree, "nodes"); // ListBase
-			let bllinks = BlHandle.get(nodetree, "links"); // bNodeLink
+			let nodetree: any = BlHandle.get(mat, "nodetree"); // bNodeTree
+			let blnodes: any = BlHandle.get(nodetree, "nodes"); // ListBase
+			let bllinks: any = BlHandle.get(nodetree, "links"); // bNodeLink
 
 			// Look for Principled BSDF node
 			let node: any = BlHandle.get(blnodes, "first", 0, "bNode");
-			let last = BlHandle.get(blnodes, "last", 0, "bNode");
+			let last: any = BlHandle.get(blnodes, "last", 0, "bNode");
 			while (true) {
 				if (BlHandle.get(node, "idname") == "ShaderNodeBsdfPrincipled") break;
 				if (BlHandle.get(node, "name") == BlHandle.get(last, "name")) break;
@@ -68,12 +68,12 @@ class ImportBlendMaterial {
 			node = BlHandle.get(blnodes, "first", 0, "bNode");
 			while (true) {
 				// Search for node in list
-				let search = BlHandle.get(node, "idname").substr(10).toLowerCase();
+				let search: string = BlHandle.get(node, "idname").substr(10).toLowerCase();
 				let base: zui_node_t = null;
 				for (let list of NodesMaterial.list) {
-					let found = false;
+					let found: bool = false;
 					for (let n of list) {
-						let s = string_replace_all(n.type, "_", "").toLowerCase();
+						let s: string = string_replace_all(n.type, "_", "").toLowerCase();
 						if (search == s) {
 							base = n;
 							found = true;
@@ -84,20 +84,20 @@ class ImportBlendMaterial {
 				}
 
 				if (base != null) {
-					let n = UINodes.makeNode(base, nodes, canvas);
+					let n: zui_node_t = UINodes.make_node(base, nodes, canvas);
 					n.x = BlHandle.get(node, "locx") + 400;
 					n.y = -BlHandle.get(node, "locy") + 400;
 					n.name = BlHandle.get(node, "name");
 
 					// Fill input socket values
-					let inputs = BlHandle.get(node, "inputs");
+					let inputs: any = BlHandle.get(node, "inputs");
 					let sock: any = BlHandle.get(inputs, "first", 0, "bNodeSocket");
-					let pos = 0;
+					let pos: i32 = 0;
 					while (true) {
 						if (pos >= n.inputs.length) break;
-						n.inputs[pos].default_value = ImportBlendMaterial.readBlendSocket(sock);
+						n.inputs[pos].default_value = ImportBlendMaterial.read_blend_socket(sock);
 
-						let last = sock;
+						let last: any = sock;
 						sock = BlHandle.get(sock, "next");
 						if (last.block == sock.block) break;
 						pos++;
@@ -105,19 +105,19 @@ class ImportBlendMaterial {
 
 					// Fill button values
 					if (search == "teximage") {
-						let img = BlHandle.get(node, "id", 0, "Image");
+						let img: any = BlHandle.get(node, "id", 0, "Image");
 						let file: string = BlHandle.get(img, "name").substr(2); // '//desktop\logo.png'
-						file = Path.baseDir(path) + file;
+						file = Path.base_dir(path) + file;
 						ImportTexture.run(file);
-						let ar = file.split(Path.sep);
-						let filename = ar[ar.length - 1];
-						n.buttons[0].default_value = Base.getAssetIndex(filename);
+						let ar: string[] = file.split(Path.sep);
+						let filename: string = ar[ar.length - 1];
+						n.buttons[0].default_value = Base.get_asset_index(filename);
 					}
 					else if (search == "valtorgb") {
 						let ramp: any = BlHandle.get(node, "storage", 0, "ColorBand");
 						n.buttons[0].data = BlHandle.get(ramp, "ipotype") == 0 ? 0 : 1; // Linear / Constant
 						let elems: f32[][] = n.buttons[0].default_value;
-						for (let i = 0; i < BlHandle.get(ramp, "tot"); ++i) {
+						for (let i: i32 = 0; i < BlHandle.get(ramp, "tot"); ++i) {
 							if (i >= elems.length) elems.push([1.0, 1.0, 1.0, 1.0, 0.0]);
 							let cbdata: any = BlHandle.get(ramp, "data", i, "CBData");
 							elems[i][0] = Math.floor(BlHandle.get(cbdata, "r") * 100) / 100;
@@ -132,11 +132,11 @@ class ImportBlendMaterial {
 						n.buttons[1].default_value = BlHandle.get(node, "custom2") & 2;
 					}
 					else if (search == "mapping") {
-						let storage = BlHandle.get(node, "storage", 0, "TexMapping");
+						let storage: any = BlHandle.get(node, "storage", 0, "TexMapping");
 						n.buttons[0].default_value = BlHandle.get(storage, "loc");
 						n.buttons[1].default_value = BlHandle.get(storage, "rot");
 						n.buttons[2].default_value = BlHandle.get(storage, "size");
-						// let mat = BlHandle.get(storage, "mat"); float[4][4]
+						// let mat: any = BlHandle.get(storage, "mat"); float[4][4]
 						// storage.flag & 1 // use_min
 						// storage.flag & 2 // use_max
 						// storage.min[0]
@@ -148,14 +148,14 @@ class ImportBlendMaterial {
 					}
 
 					// Fill output socket values
-					let outputs = BlHandle.get(node, "outputs");
+					let outputs: any = BlHandle.get(node, "outputs");
 					sock = BlHandle.get(outputs, "first", 0, "bNodeSocket");
 					pos = 0;
 					while (true) {
 						if (pos >= n.outputs.length) break;
-						n.outputs[pos].default_value = ImportBlendMaterial.readBlendSocket(sock);
+						n.outputs[pos].default_value = ImportBlendMaterial.read_blend_socket(sock);
 
-						let last = sock;
+						let last: any = sock;
 						sock = BlHandle.get(sock, "next");
 						if (last.block == sock.block) break;
 						pos++;
@@ -171,13 +171,13 @@ class ImportBlendMaterial {
 			// Place links
 			let link: any = BlHandle.get(bllinks, "first", 0, "bNodeLink");
 			while (true) {
-				let fromnode = BlHandle.get(BlHandle.get(link, "fromnode"), "name");
-				let tonode = BlHandle.get(BlHandle.get(link, "tonode"), "name");
-				let fromsock = BlHandle.get(link, "fromsock");
-				let tosock = BlHandle.get(link, "tosock");
+				let fromnode: any = BlHandle.get(BlHandle.get(link, "fromnode"), "name");
+				let tonode: any = BlHandle.get(BlHandle.get(link, "tonode"), "name");
+				let fromsock: any = BlHandle.get(link, "fromsock");
+				let tosock: any = BlHandle.get(link, "tosock");
 
-				let from_id = -1;
-				let to_id = -1;
+				let from_id: i32 = -1;
+				let to_id: i32 = -1;
 				for (let n of canvas.nodes) {
 					if (n.name == fromnode) {
 						from_id = n.id;
@@ -192,25 +192,25 @@ class ImportBlendMaterial {
 				}
 
 				if (from_id >= 0 && to_id >= 0) {
-					let from_socket = 0;
+					let from_socket: i32 = 0;
 					let sock: any = fromsock;
 					while (true) {
-						let last = sock;
+						let last: any = sock;
 						sock = BlHandle.get(sock, "prev");
 						if (last.block == sock.block) break;
 						from_socket++;
 					}
 
-					let to_socket = 0;
+					let to_socket: i32 = 0;
 					sock = tosock;
 					while (true) {
-						let last = sock;
+						let last: any = sock;
 						sock = BlHandle.get(sock, "prev");
 						if (last.block == sock.block) break;
 						to_socket++;
 					}
 
-					let valid = true;
+					let valid: bool = true;
 
 					// Remap principled
 					if (tonode == nout.name) {
@@ -236,28 +236,28 @@ class ImportBlendMaterial {
 					}
 				}
 
-				let last = link;
+				let last: any = link;
 				link = BlHandle.get(link, "next");
 				if (last.block == link.block) break;
 			}
-			History.newMaterial();
+			History.new_material();
 		}
 
 		let _init = () => {
 			for (let m of imported) {
-				Context.setMaterial(m);
-				MakeMaterial.parsePaintMaterial();
-				UtilRender.makeMaterialPreview();
+				Context.set_material(m);
+				MakeMaterial.parse_paint_material();
+				UtilRender.make_material_preview();
 			}
 		}
 		app_notify_on_init(_init);
 
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		data_delete_blob(path);
 	}
 
-	static readBlendSocket = (sock: any): any => {
-		let idname = BlHandle.get(sock, "idname");
+	static read_blend_socket = (sock: any): any => {
+		let idname: any = BlHandle.get(sock, "idname");
 		if (idname.startsWith("NodeSocketVector")) {
 			let v: any = BlHandle.get(BlHandle.get(sock, "default_value", 0, "bNodeSocketValueVector"), "value");
 			v[0] = Math.floor(v[0] * 100) / 100;

+ 148 - 139
base/Sources/ImportBlendMesh.ts

@@ -1,20 +1,20 @@
 
 class ImportBlendMesh {
 
-	static eps = 1.0 / 32767;
+	static eps: f32 = 1.0 / 32767;
 
-	static run = (path: string, replaceExisting = true) => {
+	static run = (path: string, replaceExisting: bool = true) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		let bl = ParserBlend.init(b);
+		let bl: BlendRaw = ParserBlend.init(b);
 		if (bl.dna == null) {
 			Console.error(Strings.error3());
 			return;
 		}
 
-		let obs = ParserBlend.get(bl, "Object");
-		if (obs == null || obs.length == 0) { ImportMesh.makeMesh(null, path); return; }
+		let obs: BlHandleRaw[] = ParserBlend.get(bl, "Object");
+		if (obs == null || obs.length == 0) { ImportMesh.make_mesh(null, path); return; }
 
-		let first = true;
+		let first: bool = true;
 		for (let ob of obs) {
 			if (BlHandle.get(ob, "type") != 1) continue;
 
@@ -24,28 +24,28 @@ class ImportBlendMesh {
 			let m: any = BlHandle.get(ob, "data", 0, "Mesh");
 			if (m == null) continue;
 
-			let totpoly = BlHandle.get(m, "totpoly");
+			let totpoly: i32 = BlHandle.get(m, "totpoly");
 			if (totpoly == 0) continue;
 
-			let numtri = 0;
-			for (let i = 0; i < totpoly; ++i) {
-				let poly = BlHandle.get(m, "mpoly", i);
-				let totloop = BlHandle.get(poly, "totloop");
+			let numtri: i32 = 0;
+			for (let i: i32 = 0; i < totpoly; ++i) {
+				let poly: any = BlHandle.get(m, "mpoly", i);
+				let totloop: i32 = BlHandle.get(poly, "totloop");
 				numtri += totloop - 2;
 			}
-			let inda = new Uint32Array(numtri * 3);
-			for (let i = 0; i < inda.length; ++i) inda[i] = i;
+			let inda: Uint32Array = new Uint32Array(numtri * 3);
+			for (let i: i32 = 0; i < inda.length; ++i) inda[i] = i;
 
-			let posa32 = new Float32Array(numtri * 3 * 4);
-			let posa = new Int16Array(numtri * 3 * 4);
-			let nora = new Int16Array(numtri * 3 * 2);
+			let posa32: Float32Array = new Float32Array(numtri * 3 * 4);
+			let posa: Int16Array = new Int16Array(numtri * 3 * 4);
+			let nora: Int16Array = new Int16Array(numtri * 3 * 2);
 
 			// pdata, 25 == CD_MPOLY
 			// let vdata: any = BlHandle.get(m, "vdata");
 			// let codata: any = null;
-			// let codata_pos = 0;
-			// for (let i = 0; i < BlHandle.get(vdata, "totlayer"); ++i) {
-			// 	let l = BlHandle.get(vdata, "layers", i);
+			// let codata_pos: i32 = 0;
+			// for (let i: i32 = 0; i < BlHandle.get(vdata, "totlayer"); ++i) {
+			// 	let l: any = BlHandle.get(vdata, "layers", i);
 			// 	if (BlHandle.get(l, "type") == 0) { // CD_MVERT
 			// 		let ptr: any = BlHandle.get(l, "data");
 			// 		codata_pos = bl.BlHandle.get(map, ptr).pos;
@@ -55,12 +55,12 @@ class ImportBlendMesh {
 
 			let ldata: any = BlHandle.get(m, "ldata");
 			let uvdata: any = null;
-			let uvdata_pos = 0;
+			let uvdata_pos: i32 = 0;
 			let coldata: any = null;
-			let coldata_pos = 0;
+			let coldata_pos: i32 = 0;
 
-			for (let i = 0; i < BlHandle.get(ldata, "totlayer"); ++i) {
-				let l = BlHandle.get(ldata, "layers", i);
+			for (let i: i32 = 0; i < BlHandle.get(ldata, "totlayer"); ++i) {
+				let l: any = BlHandle.get(ldata, "layers", i);
 				if (BlHandle.get(l, "type") == 16) { // CD_MLOOPUV
 					let ptr: any = BlHandle.get(l, "data");
 					uvdata_pos = bl.map.get(ptr).pos;
@@ -74,28 +74,28 @@ class ImportBlendMesh {
 				// CD_MLOOP == 26
 			}
 
-			let hasuv = uvdata != null;
-			let texa = hasuv ? new Int16Array(numtri * 3 * 2) : null;
-			let hascol = Context.raw.parseVCols && coldata != null;
-			let cola = hascol ? new Int16Array(numtri * 3 * 4) : null;
+			let hasuv: bool = uvdata != null;
+			let texa: Int16Array = hasuv ? new Int16Array(numtri * 3 * 2) : null;
+			let hascol: bool = Context.raw.parse_vcols && coldata != null;
+			let cola: Int16Array = hascol ? new Int16Array(numtri * 3 * 4) : null;
 
-			let tri = 0;
-			let vec0 = vec4_create();
-			let vec1 = vec4_create();
-			let vec2 = vec4_create();
-			for (let i = 0; i < totpoly; ++i) {
-				let poly = BlHandle.get(m, "mpoly", i);
-				// let smooth = BlHandle.get(poly, "flag") & 1 == 1; // ME_SMOOTH
-				let smooth = false; // TODO: fetch smooth normals
-				let loopstart = BlHandle.get(poly, "loopstart");
-				let totloop = BlHandle.get(poly, "totloop");
+			let tri: i32 = 0;
+			let vec0: vec4_t = vec4_create();
+			let vec1: vec4_t = vec4_create();
+			let vec2: vec4_t = vec4_create();
+			for (let i: i32 = 0; i < totpoly; ++i) {
+				let poly: any = BlHandle.get(m, "mpoly", i);
+				// let smooth: bool = BlHandle.get(poly, "flag") & 1 == 1; // ME_SMOOTH
+				let smooth: bool = false; // TODO: fetch smooth normals
+				let loopstart: i32 = BlHandle.get(poly, "loopstart");
+				let totloop: i32 = BlHandle.get(poly, "totloop");
 				if (totloop <= 4) { // Convex, fan triangulation
-					let v0 = ImportBlendMesh.get_mvert_v(m, loopstart + totloop - 1);
-					let v1 = ImportBlendMesh.get_mvert_v(m, loopstart);
-					let co0 = BlHandle.get(v0, "co");
-					let co1 = BlHandle.get(v1, "co");
-					let no0 = BlHandle.get(v0, "no");
-					let no1 = BlHandle.get(v1, "no");
+					let v0: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + totloop - 1);
+					let v1: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart);
+					let co0: any = BlHandle.get(v0, "co");
+					let co1: any = BlHandle.get(v1, "co");
+					let no0: any = BlHandle.get(v0, "no");
+					let no1: any = BlHandle.get(v1, "no");
 					if (smooth) {
 						vec4_normalize(vec4_set(vec0, no0[0] / 32767, no0[1] / 32767, no0[2] / 32767)); // shortmax
 						vec4_normalize(vec4_set(vec1, no1[0] / 32767, no1[1] / 32767, no1[2] / 32767));
@@ -105,11 +105,11 @@ class ImportBlendMesh {
 					let uv2: Float32Array = null;
 					if (hasuv) {
 						bl.pos = uvdata_pos + (loopstart + totloop - 1) * 4 * 3; // * 3 = x, y, flag
-						uv0 = ParserBlend.readf32array(bl, 2);
+						uv0 = ParserBlend.read_f32array(bl, 2);
 						if (uv0[0] > 1.0 + ImportBlendMesh.eps) uv0[0] = uv0[0] - Math.floor(uv0[0]);
 						if (uv0[1] > 1.0 + ImportBlendMesh.eps) uv0[1] = uv0[1] - Math.floor(uv0[1]);
 						bl.pos = uvdata_pos + (loopstart) * 4 * 3;
-						uv1 = ParserBlend.readf32array(bl, 2);
+						uv1 = ParserBlend.read_f32array(bl, 2);
 						if (uv1[0] > 1.0 + ImportBlendMesh.eps) uv1[0] = uv1[0] - Math.floor(uv1[0]);
 						if (uv1[1] > 1.0 + ImportBlendMesh.eps) uv1[1] = uv1[1] - Math.floor(uv1[1]);
 					}
@@ -124,18 +124,18 @@ class ImportBlendMesh {
 					let col2b: i32 = 0;
 					if (hascol) {
 						bl.pos = coldata_pos + (loopstart + totloop - 1) * 1 * 4; // * 4 = r, g, b, a
-						col0r = ParserBlend.read8(bl);
-						col0g = ParserBlend.read8(bl);
-						col0b = ParserBlend.read8(bl);
+						col0r = ParserBlend.read_i8(bl);
+						col0g = ParserBlend.read_i8(bl);
+						col0b = ParserBlend.read_i8(bl);
 						bl.pos = coldata_pos + (loopstart) * 1 * 4;
-						col1r = ParserBlend.read8(bl);
-						col1g = ParserBlend.read8(bl);
-						col1b = ParserBlend.read8(bl);
+						col1r = ParserBlend.read_i8(bl);
+						col1g = ParserBlend.read_i8(bl);
+						col1b = ParserBlend.read_i8(bl);
 					}
-					for (let j = 0; j < totloop - 2; ++j) {
-						let v2 = ImportBlendMesh.get_mvert_v(m, loopstart + j + 1);
-						let co2 = BlHandle.get(v2, "co");
-						let no2 = BlHandle.get(v2, "no");
+					for (let j: i32 = 0; j < totloop - 2; ++j) {
+						let v2: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + j + 1);
+						let co2: any = BlHandle.get(v2, "co");
+						let no2: any = BlHandle.get(v2, "no");
 						if (smooth) {
 							vec4_normalize(vec4_set(vec2, no2[0] / 32767, no2[1] / 32767, no2[2] / 32767));
 						}
@@ -171,7 +171,7 @@ class ImportBlendMesh {
 						vec4_set_from(vec1, vec2);
 						if (hasuv) {
 							bl.pos = uvdata_pos + (loopstart + j + 1) * 4 * 3;
-							uv2 = ParserBlend.readf32array(bl, 2);
+							uv2 = ParserBlend.read_f32array(bl, 2);
 							if (uv2[0] > 1.0 + ImportBlendMesh.eps) uv2[0] = uv2[0] - Math.floor(uv2[0]);
 							if (uv2[1] > 1.0 + ImportBlendMesh.eps) uv2[1] = uv2[1] - Math.floor(uv2[1]);
 							texa[tri * 6    ] = Math.floor(uv0[0] * 32767);
@@ -184,9 +184,9 @@ class ImportBlendMesh {
 						}
 						if (hascol) {
 							bl.pos = coldata_pos + (loopstart + j + 1) * 1 * 4;
-							col2r = ParserBlend.read8(bl);
-							col2g = ParserBlend.read8(bl);
-							col2b = ParserBlend.read8(bl);
+							col2r = ParserBlend.read_i8(bl);
+							col2g = ParserBlend.read_i8(bl);
+							col2b = ParserBlend.read_i8(bl);
 							cola[tri * 12    ] = col0r * 128;
 							cola[tri * 12 + 1] = col0g * 128;
 							cola[tri * 12 + 2] = col0b * 128;
@@ -205,13 +205,13 @@ class ImportBlendMesh {
 				}
 				else { // Convex or concave, ear clipping
 					let va: i32[] = [];
-					for (let i = 0; i < totloop; ++i) va.push(loopstart + i);
-					let v0 = ImportBlendMesh.get_mvert_v(m, loopstart);
-					let v1 = ImportBlendMesh.get_mvert_v(m, loopstart + 1);
-					let v2 = ImportBlendMesh.get_mvert_v(m, loopstart + 2);
-					let co0 = BlHandle.get(v0, "co");
-					let co1 = BlHandle.get(v1, "co");
-					let co2 = BlHandle.get(v2, "co");
+					for (let i: i32 = 0; i < totloop; ++i) va.push(loopstart + i);
+					let v0: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart);
+					let v1: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + 1);
+					let v2: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + 2);
+					let co0: any = BlHandle.get(v0, "co");
+					let co1: any = BlHandle.get(v1, "co");
+					let co2: any = BlHandle.get(v2, "co");
 					vec4_set(vec2, co2[0], co2[1], co2[2]);
 					vec4_set(vec1, co1[0], co1[1], co1[2]);
 					vec4_sub_vecs(vec0, vec2, vec1);
@@ -220,63 +220,63 @@ class ImportBlendMesh {
 					vec4_cross(vec0, vec1);
 					vec4_normalize(vec0, );
 
-					let nx = vec0.x;
-					let ny = vec0.y;
-					let nz = vec0.z;
-					let nxabs = Math.abs(nx);
-					let nyabs = Math.abs(ny);
-					let nzabs = Math.abs(nz);
-					let flip = nx + ny + nz > 0;
-					let axis = nxabs > nyabs && nxabs > nzabs ? 0 : nyabs > nxabs && nyabs > nzabs ? 1 : 2;
-					let axis0 = axis == 0 ? (flip ? 2 : 1) : axis == 1 ? (flip ? 0 : 2) : (flip ? 1 : 0);
-					let axis1 = axis == 0 ? (flip ? 1 : 2) : axis == 1 ? (flip ? 2 : 0) : (flip ? 0 : 1);
+					let nx: f32 = vec0.x;
+					let ny: f32 = vec0.y;
+					let nz: f32 = vec0.z;
+					let nxabs: f32 = Math.abs(nx);
+					let nyabs: f32 = Math.abs(ny);
+					let nzabs: f32 = Math.abs(nz);
+					let flip: bool = nx + ny + nz > 0;
+					let axis: i32 = nxabs > nyabs && nxabs > nzabs ? 0 : nyabs > nxabs && nyabs > nzabs ? 1 : 2;
+					let axis0: i32 = axis == 0 ? (flip ? 2 : 1) : axis == 1 ? (flip ? 0 : 2) : (flip ? 1 : 0);
+					let axis1: i32 = axis == 0 ? (flip ? 1 : 2) : axis == 1 ? (flip ? 2 : 0) : (flip ? 0 : 1);
 
-					let winding = 0.0;
-					for (let i = 0; i < totloop; ++i) {
-						let v0 = ImportBlendMesh.get_mvert_v(m, loopstart + i);
-						let v1 = ImportBlendMesh.get_mvert_v(m, loopstart + ((i + 1) % totloop));
-						let co0 = BlHandle.get(v0, "co");
-						let co1 = BlHandle.get(v1, "co");
+					let winding: f32 = 0.0;
+					for (let i: i32 = 0; i < totloop; ++i) {
+						let v0: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + i);
+						let v1: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, loopstart + ((i + 1) % totloop));
+						let co0: any = BlHandle.get(v0, "co");
+						let co1: any = BlHandle.get(v1, "co");
 						winding += (co1[axis0] - co0[axis0]) * (co1[axis1] + co0[axis1]);
 					}
 					flip = winding > 0 ? nx + ny + nz > 0 : nx + ny + nz < 0;
 					axis0 = axis == 0 ? (flip ? 2 : 1) : axis == 1 ? (flip ? 0 : 2) : (flip ? 1 : 0);
 					axis1 = axis == 0 ? (flip ? 1 : 2) : axis == 1 ? (flip ? 2 : 0) : (flip ? 0 : 1);
 
-					let vi = totloop;
-					let loops = 0;
-					let i = -1;
+					let vi: i32 = totloop;
+					let loops: i32 = 0;
+					let i: i32 = -1;
 					while (vi > 2 && loops++ < vi) {
 						i = (i + 1) % vi;
-						let i1 = (i + 1) % vi;
-						let i2 = (i + 2) % vi;
-						let v0 = ImportBlendMesh.get_mvert_v(m, va[i ]);
-						let v1 = ImportBlendMesh.get_mvert_v(m, va[i1]);
-						let v2 = ImportBlendMesh.get_mvert_v(m, va[i2]);
-						let co0 = BlHandle.get(v0, "co");
-						let co1 = BlHandle.get(v1, "co");
-						let co2 = BlHandle.get(v2, "co");
-						let v0x = co0[axis0];
-						let v0y = co0[axis1];
-						let v1x = co1[axis0];
-						let v1y = co1[axis1];
-						let v2x = co2[axis0];
-						let v2y = co2[axis1];
+						let i1: i32 = (i + 1) % vi;
+						let i2: i32 = (i + 2) % vi;
+						let v0: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, va[i ]);
+						let v1: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, va[i1]);
+						let v2: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, va[i2]);
+						let co0: any = BlHandle.get(v0, "co");
+						let co1: any = BlHandle.get(v1, "co");
+						let co2: any = BlHandle.get(v2, "co");
+						let v0x: f32 = co0[axis0];
+						let v0y: f32 = co0[axis1];
+						let v1x: f32 = co1[axis0];
+						let v1y: f32 = co1[axis1];
+						let v2x: f32 = co2[axis0];
+						let v2y: f32 = co2[axis1];
 
-						let e0x = v0x - v1x; // Not an interior vertex
-						let e0y = v0y - v1y;
-						let e1x = v2x - v1x;
-						let e1y = v2y - v1y;
-						let cross = e0x * e1y - e0y * e1x;
+						let e0x: f32 = v0x - v1x; // Not an interior vertex
+						let e0y: f32 = v0y - v1y;
+						let e1x: f32 = v2x - v1x;
+						let e1y: f32 = v2y - v1y;
+						let cross: f32 = e0x * e1y - e0y * e1x;
 						if (cross <= 0) continue;
 
-						let overlap = false; // Other vertex found inside this triangle
-						for (let j = 0; j < vi - 3; ++j) {
-							let j0 = (i + 3 + j) % vi;
-							let v = ImportBlendMesh.get_mvert_v(m, va[j0]);
-							let co = BlHandle.get(v, "co");
-							let px = co[axis0];
-							let py = co[axis1];
+						let overlap: bool = false; // Other vertex found inside this triangle
+						for (let j: i32 = 0; j < vi - 3; ++j) {
+							let j0: i32 = (i + 3 + j) % vi;
+							let v: BlHandleRaw = ImportBlendMesh.get_mvert_v(m, va[j0]);
+							let co: any = BlHandle.get(v, "co");
+							let px: f32 = co[axis0];
+							let py: f32 = co[axis1];
 
 							if (UtilMesh.pnpoly(v0x, v0y, v1x, v1y, v2x, v2y, px, py)) {
 								overlap = true;
@@ -287,9 +287,9 @@ class ImportBlendMesh {
 
 						// Found ear
 						{
-							let no0 = BlHandle.get(v0, "no");
-							let no1 = BlHandle.get(v1, "no");
-							let no2 = BlHandle.get(v2, "no");
+							let no0: any = BlHandle.get(v0, "no");
+							let no1: any = BlHandle.get(v1, "no");
+							let no2: any = BlHandle.get(v2, "no");
 							if (smooth) {
 								vec4_normalize(vec4_set(vec0, no0[0] / 32767, no0[1] / 32767, no0[2] / 32767)); // shortmax
 								vec4_normalize(vec4_set(vec1, no1[0] / 32767, no1[1] / 32767, no1[2] / 32767));
@@ -309,15 +309,15 @@ class ImportBlendMesh {
 							let uv2: Float32Array = null;
 							if (hasuv) {
 								bl.pos = uvdata_pos + (va[i ]) * 4 * 3;
-								uv0 = ParserBlend.readf32array(bl, 2);
+								uv0 = ParserBlend.read_f32array(bl, 2);
 								if (uv0[0] > 1.0 + ImportBlendMesh.eps) uv0[0] = uv0[0] - Math.floor(uv0[0]);
 								if (uv0[1] > 1.0 + ImportBlendMesh.eps) uv0[1] = uv0[1] - Math.floor(uv0[1]);
 								bl.pos = uvdata_pos + (va[i1]) * 4 * 3;
-								uv1 = ParserBlend.readf32array(bl, 2);
+								uv1 = ParserBlend.read_f32array(bl, 2);
 								if (uv1[0] > 1.0 + ImportBlendMesh.eps) uv1[0] = uv1[0] - Math.floor(uv1[0]);
 								if (uv1[1] > 1.0 + ImportBlendMesh.eps) uv1[1] = uv1[1] - Math.floor(uv1[1]);
 								bl.pos = uvdata_pos + (va[i2]) * 4 * 3;
-								uv2 = ParserBlend.readf32array(bl, 2);
+								uv2 = ParserBlend.read_f32array(bl, 2);
 								if (uv2[0] > 1.0 + ImportBlendMesh.eps) uv2[0] = uv2[0] - Math.floor(uv2[0]);
 								if (uv2[1] > 1.0 + ImportBlendMesh.eps) uv2[1] = uv2[1] - Math.floor(uv2[1]);
 							}
@@ -332,17 +332,17 @@ class ImportBlendMesh {
 							let col2b: i32 = 0;
 							if (hascol) {
 								bl.pos = coldata_pos + (va[i ]) * 1 * 4;
-								col0r = ParserBlend.read8(bl);
-								col0g = ParserBlend.read8(bl);
-								col0b = ParserBlend.read8(bl);
+								col0r = ParserBlend.read_i8(bl);
+								col0g = ParserBlend.read_i8(bl);
+								col0b = ParserBlend.read_i8(bl);
 								bl.pos = coldata_pos + (va[i1]) * 1 * 4;
-								col1r = ParserBlend.read8(bl);
-								col1g = ParserBlend.read8(bl);
-								col1b = ParserBlend.read8(bl);
+								col1r = ParserBlend.read_i8(bl);
+								col1g = ParserBlend.read_i8(bl);
+								col1b = ParserBlend.read_i8(bl);
 								bl.pos = coldata_pos + (va[i2]) * 1 * 4;
-								col2r = ParserBlend.read8(bl);
-								col2g = ParserBlend.read8(bl);
-								col2b = ParserBlend.read8(bl);
+								col2r = ParserBlend.read_i8(bl);
+								col2g = ParserBlend.read_i8(bl);
+								col2b = ParserBlend.read_i8(bl);
 							}
 							posa32[tri * 9    ] = co0[0];
 							posa32[tri * 9 + 1] = co0[1];
@@ -384,7 +384,7 @@ class ImportBlendMesh {
 							tri++;
 						}
 
-						for (let j = ((i + 1) % vi); j < vi - 1; ++j) { // Consume vertex
+						for (let j: i32 = ((i + 1) % vi); j < vi - 1; ++j) { // Consume vertex
 							va[j] = va[j + 1];
 						}
 						vi--;
@@ -395,10 +395,10 @@ class ImportBlendMesh {
 			}
 
 			// Apply world matrix
-			let obmat = BlHandle.get(ob, "obmat", 0, "float", 16);
-			let mat = mat4_transpose(mat4_from_f32_array(obmat));
-			let v = vec4_create();
-			for (let i = 0; i < Math.floor(posa32.length / 3); ++i) {
+			let obmat: any = BlHandle.get(ob, "obmat", 0, "float", 16);
+			let mat: mat4_t = mat4_transpose(mat4_from_f32_array(obmat));
+			let v: vec4_t = vec4_create();
+			for (let i: i32 = 0; i < Math.floor(posa32.length / 3); ++i) {
 				vec4_set(v, posa32[i * 3], posa32[i * 3 + 1], posa32[i * 3 + 2]);
 				vec4_apply_mat4(v, mat);
 				posa32[i * 3    ] = v.x;
@@ -408,7 +408,7 @@ class ImportBlendMesh {
 			mat4_get_inv(mat, mat);
 			mat4_transpose3x3(mat);
 			mat.m[12] = mat.m[13] = mat.m[14] = mat.m[15] = 0;
-			for (let i = 0; i < Math.floor(nora.length / 2); ++i) {
+			for (let i: i32 = 0; i < Math.floor(nora.length / 2); ++i) {
 				vec4_set(v, nora[i * 2] / 32767, nora[i * 2 + 1] / 32767, posa[i * 4 + 3] / 32767);
 				vec4_apply_mat(v, mat);
 				vec4_normalize(v);
@@ -418,21 +418,30 @@ class ImportBlendMesh {
 			}
 
 			// Pack positions to (-1, 1) range
-			let scalePos = 0.0;
-			for (let i = 0; i < posa32.length; ++i) {
-				let f = Math.abs(posa32[i]);
+			let scalePos: f32 = 0.0;
+			for (let i: i32 = 0; i < posa32.length; ++i) {
+				let f: f32 = Math.abs(posa32[i]);
 				if (scalePos < f) scalePos = f;
 			}
-			let inv = 1 / scalePos;
-			for (let i = 0; i < Math.floor(posa32.length / 3); ++i) {
+			let inv: f32 = 1 / scalePos;
+			for (let i: i32 = 0; i < Math.floor(posa32.length / 3); ++i) {
 				posa[i * 4    ] = Math.floor(posa32[i * 3    ] * 32767 * inv);
 				posa[i * 4 + 1] = Math.floor(posa32[i * 3 + 1] * 32767 * inv);
 				posa[i * 4 + 2] = Math.floor(posa32[i * 3 + 2] * 32767 * inv);
 			}
 
-			let obj = {posa: posa, nora: nora, texa: texa, cola: cola, inda: inda, name: name, scalePos: scalePos, scaleTes: 1.0};
+			let obj: any = {
+				posa: posa,
+				nora: nora,
+				texa: texa,
+				cola: cola,
+				inda: inda,
+				name: name,
+				scalePos: scalePos,
+				scaleTes: 1.0
+			};
 
-			(first && replaceExisting) ? ImportMesh.makeMesh(obj, path) : ImportMesh.addMesh(obj);
+			(first && replaceExisting) ? ImportMesh.make_mesh(obj, path) : ImportMesh.add_mesh(obj);
 			first = false;
 		}
 

+ 56 - 56
base/Sources/ImportEnvmap.ts

@@ -2,14 +2,14 @@
 class ImportEnvmap {
 
 	static pipeline: pipeline_t = null;
-	static paramsLocation: kinc_const_loc_t;
-	static params = vec4_create();
-	static n = vec4_create();
-	static radianceLocation: kinc_tex_unit_t;
+	static params_loc: kinc_const_loc_t;
+	static params: vec4_t = vec4_create();
+	static n: vec4_t = vec4_create();
+	static radiance_loc: kinc_tex_unit_t;
 	static radiance: image_t = null;
-	static radianceCpu: image_t = null;
+	static radiance_cpu: image_t = null;
 	static mips: image_t[] = null;
-	static mipsCpu: image_t[] = null;
+	static mips_cpu: image_t[] = null;
 
 	static run = (path: string, image: image_t) => {
 
@@ -18,20 +18,20 @@ class ImportEnvmap {
 			ImportEnvmap.pipeline = g4_pipeline_create();
 			ImportEnvmap.pipeline.vertex_shader = sys_get_shader("pass.vert");
 			ImportEnvmap.pipeline.fragment_shader = sys_get_shader("prefilter_envmap.frag");
-			let vs = g4_vertex_struct_create();
+			let vs: vertex_struct_t = g4_vertex_struct_create();
 			g4_vertex_struct_add(vs, "pos", vertex_data_t.F32_2X);
 			ImportEnvmap.pipeline.input_layout = [vs];
 			ImportEnvmap.pipeline.color_attachment_count = 1;
 			ImportEnvmap.pipeline.color_attachments[0] = tex_format_t.RGBA128;
 			g4_pipeline_compile(ImportEnvmap.pipeline);
-			ImportEnvmap.paramsLocation = g4_pipeline_get_const_loc(ImportEnvmap.pipeline, "params");
-			ImportEnvmap.radianceLocation = g4_pipeline_get_tex_unit(ImportEnvmap.pipeline, "radiance");
+			ImportEnvmap.params_loc = g4_pipeline_get_const_loc(ImportEnvmap.pipeline, "params");
+			ImportEnvmap.radiance_loc = g4_pipeline_get_tex_unit(ImportEnvmap.pipeline, "radiance");
 
 			ImportEnvmap.radiance = image_create_render_target(1024, 512, tex_format_t.RGBA128);
 
 			ImportEnvmap.mips = [];
-			let w = 512;
-			for (let i = 0; i < 10; ++i) {
+			let w: i32 = 512;
+			for (let i: i32 = 0; i < 10; ++i) {
 				ImportEnvmap.mips.push(image_create_render_target(w, w > 1 ? Math.floor(w / 2) : 1, tex_format_t.RGBA128));
 				w = Math.floor(w / 2);
 			}
@@ -41,94 +41,94 @@ class ImportEnvmap {
 
 		// Down-scale to 1024x512
 		g2_begin(ImportEnvmap.radiance);
-		g2_set_pipeline(Base.pipeCopy128);
+		g2_set_pipeline(Base.pipe_copy128);
 		g2_draw_scaled_image(image, 0, 0, 1024, 512);
 		g2_set_pipeline(null);
 		g2_end();
 
-		let radiancePixels = image_get_pixels(ImportEnvmap.radiance);
-		if (ImportEnvmap.radianceCpu != null) {
-			let _radianceCpu = ImportEnvmap.radianceCpu;
-			Base.notifyOnNextFrame(() => {
+		let radiancePixels: buffer_t = image_get_pixels(ImportEnvmap.radiance);
+		if (ImportEnvmap.radiance_cpu != null) {
+			let _radianceCpu: image_t = ImportEnvmap.radiance_cpu;
+			Base.notify_on_next_frame(() => {
 				image_unload(_radianceCpu);
 			});
 		}
-		ImportEnvmap.radianceCpu = image_from_bytes(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height, tex_format_t.RGBA128);
+		ImportEnvmap.radiance_cpu = image_from_bytes(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height, tex_format_t.RGBA128);
 
 		// Radiance
-		if (ImportEnvmap.mipsCpu != null) {
-			for (let mip of ImportEnvmap.mipsCpu) {
-				let _mip = mip;
-				Base.notifyOnNextFrame(() => {
+		if (ImportEnvmap.mips_cpu != null) {
+			for (let mip of ImportEnvmap.mips_cpu) {
+				let _mip: image_t = mip;
+				Base.notify_on_next_frame(() => {
 					///if (!krom_direct3d12) // TODO: crashes after 50+ imports
 					image_unload(_mip);
 					///end
 				});
 			}
 		}
-		ImportEnvmap.mipsCpu = [];
-		for (let i = 0; i < ImportEnvmap.mips.length; ++i) {
-			ImportEnvmap.getRadianceMip(ImportEnvmap.mips[i], i, ImportEnvmap.radiance);
-			ImportEnvmap.mipsCpu.push(image_from_bytes(image_get_pixels(ImportEnvmap.mips[i]), ImportEnvmap.mips[i].width, ImportEnvmap.mips[i].height, tex_format_t.RGBA128));
+		ImportEnvmap.mips_cpu = [];
+		for (let i: i32 = 0; i < ImportEnvmap.mips.length; ++i) {
+			ImportEnvmap.get_radiance_mip(ImportEnvmap.mips[i], i, ImportEnvmap.radiance);
+			ImportEnvmap.mips_cpu.push(image_from_bytes(image_get_pixels(ImportEnvmap.mips[i]), ImportEnvmap.mips[i].width, ImportEnvmap.mips[i].height, tex_format_t.RGBA128));
 		}
-		image_set_mipmaps(ImportEnvmap.radianceCpu, ImportEnvmap.mipsCpu);
+		image_set_mipmaps(ImportEnvmap.radiance_cpu, ImportEnvmap.mips_cpu);
 
 		// Irradiance
-		scene_world._.irradiance = ImportEnvmap.getSphericalHarmonics(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height);
+		scene_world._.irradiance = ImportEnvmap.get_spherical_harmonics(radiancePixels, ImportEnvmap.radiance.width, ImportEnvmap.radiance.height);
 
 		// World
 		scene_world.strength = 1.0;
-		scene_world.radiance_mipmaps = ImportEnvmap.mipsCpu.length - 2;
+		scene_world.radiance_mipmaps = ImportEnvmap.mips_cpu.length - 2;
 		scene_world._.envmap = image;
 		scene_world.envmap = path;
-		scene_world._.radiance = ImportEnvmap.radianceCpu;
-		scene_world._.radiance_mipmaps = ImportEnvmap.mipsCpu;
-		Context.raw.savedEnvmap = image;
-		if (Context.raw.showEnvmapBlur) {
+		scene_world._.radiance = ImportEnvmap.radiance_cpu;
+		scene_world._.radiance_mipmaps = ImportEnvmap.mips_cpu;
+		Context.raw.saved_envmap = image;
+		if (Context.raw.show_envmap_blur) {
 			scene_world._.envmap = scene_world._.radiance_mipmaps[0];
 		}
 		Context.raw.ddirty = 2;
 		Project.raw.envmap = path;
 	}
 
-	static getRadianceMip = (mip: image_t, level: i32, radiance: image_t) => {
+	static get_radiance_mip = (mip: image_t, level: i32, radiance: image_t) => {
 		g4_begin(mip);
 		g4_set_vertex_buffer(const_data_screen_aligned_vb);
 		g4_set_index_buffer(const_data_screen_aligned_ib);
 		g4_set_pipeline(ImportEnvmap.pipeline);
 		ImportEnvmap.params.x = 0.1 + level / 8;
-		g4_set_float4(ImportEnvmap.paramsLocation, ImportEnvmap.params.x, ImportEnvmap.params.y, ImportEnvmap.params.z, ImportEnvmap.params.w);
-		g4_set_tex(ImportEnvmap.radianceLocation, radiance);
+		g4_set_float4(ImportEnvmap.params_loc, ImportEnvmap.params.x, ImportEnvmap.params.y, ImportEnvmap.params.z, ImportEnvmap.params.w);
+		g4_set_tex(ImportEnvmap.radiance_loc, radiance);
 		g4_draw();
 		g4_end();
 	}
 
-	static reverseEquirect = (x: f32, y: f32): vec4_t => {
-		let theta = x * Math.PI * 2 - Math.PI;
-		let phi = y * Math.PI;
+	static reverse_equirect = (x: f32, y: f32): vec4_t => {
+		let theta: f32 = x * Math.PI * 2 - Math.PI;
+		let phi: f32 = y * Math.PI;
 		// return n.set(Math.sin(phi) * Math.cos(theta), -(Math.sin(phi) * Math.sin(theta)), Math.cos(phi));
 		return vec4_set(ImportEnvmap.n, -Math.cos(phi), Math.sin(phi) * Math.cos(theta), -(Math.sin(phi) * Math.sin(theta)));
 	}
 
 	// https://ndotl.wordpress.com/2015/03/07/pbr-cubemap-filtering
 	// https://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering
-	static getSphericalHarmonics = (source: ArrayBuffer, sourceWidth: i32, sourceHeight: i32): Float32Array => {
-		let sh = new Float32Array(9 * 3 + 1); // Align to mult of 4 - 27->28
-		let accum = 0.0;
-		let weight = 1.0;
-		let weight1 = weight * 4 / 17;
-		let weight2 = weight * 8 / 17;
-		let weight3 = weight * 15 / 17;
-		let weight4 = weight * 5 / 68;
-		let weight5 = weight * 15 / 68;
-		let view = new DataView(source);
-
-		for (let x = 0; x < sourceWidth; ++x) {
-			for (let y = 0; y < sourceHeight; ++y) {
-				ImportEnvmap.n = ImportEnvmap.reverseEquirect(x / sourceWidth, y / sourceHeight);
-
-				for (let i = 0; i < 3; ++i) {
-					let value = view.getFloat32(((x + y * sourceWidth) * 16 + i * 4), true);
+	static get_spherical_harmonics = (source: ArrayBuffer, sourceWidth: i32, sourceHeight: i32): Float32Array => {
+		let sh: Float32Array = new Float32Array(9 * 3 + 1); // Align to mult of 4 - 27->28
+		let accum: f32 = 0.0;
+		let weight: f32 = 1.0;
+		let weight1: f32 = weight * 4 / 17;
+		let weight2: f32 = weight * 8 / 17;
+		let weight3: f32 = weight * 15 / 17;
+		let weight4: f32 = weight * 5 / 68;
+		let weight5: f32 = weight * 15 / 68;
+		let view: DataView = new DataView(source);
+
+		for (let x: i32 = 0; x < sourceWidth; ++x) {
+			for (let y: i32 = 0; y < sourceHeight; ++y) {
+				ImportEnvmap.n = ImportEnvmap.reverse_equirect(x / sourceWidth, y / sourceHeight);
+
+				for (let i: i32 = 0; i < 3; ++i) {
+					let value: f32 = view.getFloat32(((x + y * sourceWidth) * 16 + i * 4), true);
 					value = Math.pow(value, 1.0 / 2.2);
 
 					sh[0 + i] += value * weight1;
@@ -148,7 +148,7 @@ class ImportEnvmap {
 			}
 		}
 
-		for (let i = 0; i < sh.length; ++i) {
+		for (let i: i32 = 0; i < sh.length; ++i) {
 			sh[i] /= accum / 16;
 		}
 

+ 8 - 8
base/Sources/ImportFont.ts

@@ -12,14 +12,14 @@ class ImportFont {
 		}
 		let font: g2_font_t = data_get_font(path);
 		g2_font_init(font); // Make sure font_ is ready
-		let count = krom_g2_font_count(font.font_);
+		let count: i32 = krom_g2_font_count(font.font_);
 		let fontSlots: SlotFontRaw[] = [];
-		for (let i = 0; i < count; ++i) {
-			let ar = path.split(Path.sep);
-			let name = ar[ar.length - 1];
-			let f = g2_font_clone(font);
+		for (let i: i32 = 0; i < count; ++i) {
+			let ar: string[] = path.split(Path.sep);
+			let name: string = ar[ar.length - 1];
+			let f: g2_font_t = g2_font_clone(font);
 			g2_font_set_font_index(f, i);
-			let fontSlot = SlotFont.create(name, f, path);
+			let fontSlot: SlotFontRaw = SlotFont.create(name, f, path);
 			fontSlots.push(fontSlot);
 		}
 
@@ -27,12 +27,12 @@ class ImportFont {
 			for (let f of fontSlots) {
 				Context.raw.font = f;
 				Project.fonts.push(f);
-				UtilRender.makeFontPreview();
+				UtilRender.make_font_preview();
 			}
 		}
 		app_notify_on_init(_init);
 
-		UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+		UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 	}
 }
 

+ 8 - 8
base/Sources/ImportGpl.ts

@@ -1,29 +1,29 @@
 
 class ImportGpl {
 
-	static run = (path: string, replaceExisting: bool) => {
+	static run = (path: string, replace_existing: bool) => {
 		let b: ArrayBuffer = data_get_blob(path);
-		// let swatches = [];
+		// let swatches: TSwatchColor[] = [];
 
-		// let str = sys_buffer_to_string(b);
-		// let lines = str.split("\n");
+		// let str: string = sys_buffer_to_string(b);
+		// let lines: string[] = str.split("\n");
 
-		// let view = new DataView(b);
+		// let view: DataView = new DataView(b);
 		// // GIMP's color palette importer: https://gitlab.gnome.org/GNOME/gimp/-/blob/gimp-2-10/app/core/gimppalette-load.c#L39
 		// if (!lines[0].startsWith("GIMP Palette")) {
 		// 	Console.error(tr("Not a valid GIMP color palette"));
 		// 	return;
 		// }
 
-		// let delimiter = ~/\s+/ig;
+		// let delimiter: string = ~/\s+/ig;
 		// for (let line of lines) {
 		// 	if (line.startsWith("Name:")) continue;
 		// 	else if (line.startsWith("Columns:")) continue;
 		// 	else if (line.startsWith("#")) continue;
 		// 	else {
-		// 		let tokens = delimiter.split(line);
+		// 		let tokens: string[] = delimiter.split(line);
 		// 		if (tokens.length < 3) continue;
-		// 		let swatch = Project.makeSwatch(Color.fromBytes(String(tokens[0]), String(tokens[1]), String(tokens[2])));
+		// 		let swatch: TSwatchColor = Project.makeSwatch(Color.fromBytes(String(tokens[0]), String(tokens[1]), String(tokens[2])));
 		// 		swatches.push(swatch);
 		// 	}
 		// }

+ 5 - 5
base/Sources/ImportKeymap.ts

@@ -2,16 +2,16 @@
 class ImportKeymap {
 
 	static run = (path: string) => {
-		if (!Path.isJson(path)) {
+		if (!Path.is_json(path)) {
 			Console.error(Strings.error1());
 			return;
 		}
 
-		let filename = path.substr(path.lastIndexOf(Path.sep) + 1);
-		let dstPath = Path.data() + Path.sep + "keymap_presets" + Path.sep + filename;
+		let filename: string = path.substr(path.lastIndexOf(Path.sep) + 1);
+		let dstPath: string = Path.data() + Path.sep + "keymap_presets" + Path.sep + filename;
 		File.copy(path, dstPath); // Copy to preset folder
-		BoxPreferences.fetchKeymaps(); // Refresh file list
-		BoxPreferences.presetHandle.position = BoxPreferences.getPresetIndex();
+		BoxPreferences.fetch_keymaps(); // Refresh file list
+		BoxPreferences.preset_handle.position = BoxPreferences.get_preset_index();
 		Console.info(tr("Keymap imported:") + " " + filename);
 	}
 }

+ 80 - 80
base/Sources/ImportMesh.ts

@@ -2,49 +2,49 @@
 class ImportMesh {
 
 	///if (is_paint || is_sculpt)
-	static clearLayers = true;
+	static clear_layers: bool = true;
 	///end
 
-	static meshesToUnwrap: any[] = null;
+	static meshes_to_unwrap: any[] = null;
 
 	///if (is_paint || is_sculpt)
-	static run = (path: string, _clearLayers = true, replaceExisting = true) => {
+	static run = (path: string, _clear_layers: bool = true, replace_existing: bool = true) => {
 	///end
 
 	///if is_lab
-	static run = (path: string, replaceExisting = true) => {
+	static run = (path: string, replace_existing: bool = true) => {
 	///end
 
-		if (!Path.isMesh(path)) {
-			if (!Context.enableImportPlugin(path)) {
+		if (!Path.is_mesh(path)) {
+			if (!Context.enable_import_plugin(path)) {
 				Console.error(Strings.error1());
 				return;
 			}
 		}
 
 		///if (is_paint || is_sculpt)
-		ImportMesh.clearLayers = _clearLayers;
-		Context.raw.layerFilter = 0;
+		ImportMesh.clear_layers = _clear_layers;
+		Context.raw.layer_filter = 0;
 		///end
 
-		ImportMesh.meshesToUnwrap = null;
+		ImportMesh.meshes_to_unwrap = null;
 
-		let p = path.toLowerCase();
-		if (p.endsWith(".obj")) ImportObj.run(path, replaceExisting);
-		else if (p.endsWith(".blend")) ImportBlendMesh.run(path, replaceExisting);
+		let p: string = path.toLowerCase();
+		if (p.endsWith(".obj")) ImportObj.run(path, replace_existing);
+		else if (p.endsWith(".blend")) ImportBlendMesh.run(path, replace_existing);
 		else {
-			let ext = path.substr(path.lastIndexOf(".") + 1);
-			let importer = Path.meshImporters.get(ext);
+			let ext: string = path.substr(path.lastIndexOf(".") + 1);
+			let importer: (s: string, f: (a: any)=>void)=>void = Path.mesh_importers.get(ext);
 			importer(path, (mesh: any) => {
-				replaceExisting ? ImportMesh.makeMesh(mesh, path) : ImportMesh.addMesh(mesh);
+				replace_existing ? ImportMesh.make_mesh(mesh, path) : ImportMesh.add_mesh(mesh);
 
-				let has_next = mesh.has_next;
+				let has_next: bool = mesh.has_next;
 				while (has_next) {
 					importer(path, (mesh: any) => {
 						has_next = mesh.has_next;
-						ImportMesh.addMesh(mesh);
+						ImportMesh.add_mesh(mesh);
 
-						// let m = fromFloat32Array(mesh.transform);
+						// let m: mat4_t = fromFloat32Array(mesh.transform);
 						// Project.paintObjects[Project.paintObjects.length - 1].transform.localOnly = true;
 						// Project.paintObjects[Project.paintObjects.length - 1].transform.setMatrix(m);
 					});
@@ -52,42 +52,42 @@ class ImportMesh {
 			});
 		}
 
-		Project.meshAssets = [path];
+		Project.mesh_assets = [path];
 
 		///if (krom_android || krom_ios)
 		sys_title_set(path.substring(path.lastIndexOf(Path.sep) + 1, path.lastIndexOf(".")));
 		///end
 	}
 
-	static finishImport = () => {
-		if (Context.raw.mergedObject != null) {
-			mesh_data_delete(Context.raw.mergedObject.data);
-			mesh_object_remove(Context.raw.mergedObject);
-			Context.raw.mergedObject = null;
+	static finish_import = () => {
+		if (Context.raw.merged_object != null) {
+			mesh_data_delete(Context.raw.merged_object.data);
+			mesh_object_remove(Context.raw.merged_object);
+			Context.raw.merged_object = null;
 		}
 
-		Context.selectPaintObject(Context.mainObject());
+		Context.select_paint_object(Context.main_object());
 
-		if (Project.paintObjects.length > 1) {
+		if (Project.paint_objects.length > 1) {
 			// Sort by name
-			Project.paintObjects.sort((a, b): i32 => {
+			Project.paint_objects.sort((a, b): i32 => {
 				if (a.base.name < b.base.name) return -1;
 				else if (a.base.name > b.base.name) return 1;
 				return 0;
 			});
 
 			// No mask by default
-			for (let p of Project.paintObjects) p.base.visible = true;
-			if (Context.raw.mergedObject == null) UtilMesh.mergeMesh();
-			Context.raw.paintObject.skip_context = "paint";
-			Context.raw.mergedObject.base.visible = true;
+			for (let p of Project.paint_objects) p.base.visible = true;
+			if (Context.raw.merged_object == null) UtilMesh.merge_mesh();
+			Context.raw.paint_object.skip_context = "paint";
+			Context.raw.merged_object.base.visible = true;
 		}
 
-		Viewport.scaleToBounds();
+		Viewport.scale_to_bounds();
 
-		if (Context.raw.paintObject.base.name == "") Context.raw.paintObject.base.name = "Object";
-		MakeMaterial.parsePaintMaterial();
-		MakeMaterial.parseMeshMaterial();
+		if (Context.raw.paint_object.base.name == "") Context.raw.paint_object.base.name = "Object";
+		MakeMaterial.parse_paint_material();
+		MakeMaterial.parse_mesh_material();
 
 		///if (is_paint || is_sculpt)
 		UIView2D.hwnd.redraws = 2;
@@ -98,32 +98,32 @@ class ImportMesh {
 		///end
 
 		///if arm_physics
-		Context.raw.paintBody = null;
+		Context.raw.paint_body = null;
 		///end
 	}
 
-	static _makeMesh = (mesh: any) => {
-		let raw = ImportMesh.rawMesh(mesh);
+	static _make_mesh = (mesh: any) => {
+		let raw: mesh_data_t = ImportMesh.raw_mesh(mesh);
 		if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm" });
 
 		let md: mesh_data_t = mesh_data_create(raw);
-		Context.raw.paintObject = Context.mainObject();
+		Context.raw.paint_object = Context.main_object();
 
-		Context.selectPaintObject(Context.mainObject());
-		for (let i = 0; i < Project.paintObjects.length; ++i) {
-			let p = Project.paintObjects[i];
-			if (p == Context.raw.paintObject) continue;
+		Context.select_paint_object(Context.main_object());
+		for (let i: i32 = 0; i < Project.paint_objects.length; ++i) {
+			let p: mesh_object_t = Project.paint_objects[i];
+			if (p == Context.raw.paint_object) continue;
 			data_delete_mesh(p.data._.handle);
 			mesh_object_remove(p);
 		}
-		let handle = Context.raw.paintObject.data._.handle;
+		let handle: string = Context.raw.paint_object.data._.handle;
 		if (handle != "SceneSphere" && handle != "ScenePlane") {
 			data_delete_mesh(handle);
 		}
 
-		mesh_object_set_data(Context.raw.paintObject, md);
-		Context.raw.paintObject.base.name = mesh.name;
-		Project.paintObjects = [Context.raw.paintObject];
+		mesh_object_set_data(Context.raw.paint_object, md);
+		Context.raw.paint_object.base.name = mesh.name;
+		Project.paint_objects = [Context.raw.paint_object];
 
 		md._.handle = raw.name;
 		data_cached_meshes.set(md._.handle, md);
@@ -131,67 +131,67 @@ class ImportMesh {
 		Context.raw.ddirty = 4;
 
 		///if (is_paint || is_sculpt)
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
-		UtilUV.uvmapCached = false;
-		UtilUV.trianglemapCached = false;
-		UtilUV.dilatemapCached = false;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
+		UtilUV.uvmap_cached = false;
+		UtilUV.trianglemap_cached = false;
+		UtilUV.dilatemap_cached = false;
 		///end
 
 		///if (is_paint || is_sculpt)
-		if (ImportMesh.clearLayers) {
+		if (ImportMesh.clear_layers) {
 			while (Project.layers.length > 0) {
-				let l = Project.layers.pop();
+				let l: SlotLayerRaw = Project.layers.pop();
 				SlotLayer.unload(l);
 			}
-			Base.newLayer(false);
-			app_notify_on_init(Base.initLayers);
+			Base.new_layer(false);
+			app_notify_on_init(Base.init_layers);
 			History.reset();
 		}
 		///end
 
 		// Wait for addMesh calls to finish
-		if (ImportMesh.meshesToUnwrap != null) {
-			Base.notifyOnNextFrame(ImportMesh.finishImport);
+		if (ImportMesh.meshes_to_unwrap != null) {
+			Base.notify_on_next_frame(ImportMesh.finish_import);
 		}
 		else {
-			app_notify_on_init(ImportMesh.finishImport);
+			app_notify_on_init(ImportMesh.finish_import);
 		}
 	}
 
-	static makeMesh = (mesh: any, path: string) => {
+	static make_mesh = (mesh: any, path: string) => {
 		if (mesh == null || mesh.posa == null || mesh.nora == null || mesh.inda == null || mesh.posa.length == 0) {
 			Console.error(Strings.error3());
 			return;
 		}
 
 		if (mesh.texa == null) {
-			if (ImportMesh.meshesToUnwrap == null) {
-				ImportMesh.meshesToUnwrap = [];
+			if (ImportMesh.meshes_to_unwrap == null) {
+				ImportMesh.meshes_to_unwrap = [];
 			}
 			let firstUnwrapDone = (mesh: any) => {
-				ImportMesh._makeMesh(mesh);
-				for (let mesh of ImportMesh.meshesToUnwrap) Project.unwrapMeshBox(mesh, ImportMesh._addMesh, true);
+				ImportMesh._make_mesh(mesh);
+				for (let mesh of ImportMesh.meshes_to_unwrap) Project.unwrap_mesh_box(mesh, ImportMesh._add_mesh, true);
 			}
-			Project.unwrapMeshBox(mesh, firstUnwrapDone);
+			Project.unwrap_mesh_box(mesh, firstUnwrapDone);
 		}
 		else {
-			ImportMesh._makeMesh(mesh);
+			ImportMesh._make_mesh(mesh);
 		}
 	}
 
-	static _addMesh = (mesh: any) => {
-		let raw = ImportMesh.rawMesh(mesh);
+	static _add_mesh = (mesh: any) => {
+		let raw: mesh_data_t = ImportMesh.raw_mesh(mesh);
 		if (mesh.cola != null) raw.vertex_arrays.push({ values: mesh.cola, attrib: "col", data: "short4norm" });
 
 		let md: mesh_data_t = mesh_data_create(raw);
 
-		let object = scene_add_mesh_object(md, Context.raw.paintObject.materials, Context.raw.paintObject.base);
+		let object: mesh_object_t = scene_add_mesh_object(md, Context.raw.paint_object.materials, Context.raw.paint_object.base);
 		object.base.name = mesh.name;
 		object.skip_context = "paint";
 
 		// Ensure unique names
-		for (let p of Project.paintObjects) {
+		for (let p of Project.paint_objects) {
 			if (p.base.name == object.base.name) {
 				p.base.name += ".001";
 				p.data._.handle += ".001";
@@ -199,7 +199,7 @@ class ImportMesh {
 			}
 		}
 
-		Project.paintObjects.push(object);
+		Project.paint_objects.push(object);
 
 		md._.handle = raw.name;
 		data_cached_meshes.set(md._.handle, md);
@@ -207,24 +207,24 @@ class ImportMesh {
 		Context.raw.ddirty = 4;
 
 		///if (is_paint || is_sculpt)
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-		UtilUV.uvmapCached = false;
-		UtilUV.trianglemapCached = false;
-		UtilUV.dilatemapCached = false;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+		UtilUV.uvmap_cached = false;
+		UtilUV.trianglemap_cached = false;
+		UtilUV.dilatemap_cached = false;
 		///end
 	}
 
-	static addMesh = (mesh: any) => {
+	static add_mesh = (mesh: any) => {
 		if (mesh.texa == null) {
-			if (ImportMesh.meshesToUnwrap != null) ImportMesh.meshesToUnwrap.push(mesh);
-			else Project.unwrapMeshBox(mesh, ImportMesh._addMesh);
+			if (ImportMesh.meshes_to_unwrap != null) ImportMesh.meshes_to_unwrap.push(mesh);
+			else Project.unwrap_mesh_box(mesh, ImportMesh._add_mesh);
 		}
 		else {
-			ImportMesh._addMesh(mesh);
+			ImportMesh._add_mesh(mesh);
 		}
 	}
 
-	static rawMesh = (mesh: any): mesh_data_t => {
+	static raw_mesh = (mesh: any): mesh_data_t => {
 		return {
 			name: mesh.name,
 			vertex_arrays: [

+ 46 - 46
base/Sources/ImportObj.ts

@@ -1,52 +1,52 @@
 
 class ImportObj {
 
-	static run = (path: string, replaceExisting = true) => {
-		let i = Context.raw.splitBy;
-		let isUdim = i == SplitType.SplitUdim;
-		let splitCode =
-			(i == SplitType.SplitObject || isUdim) ? "o".charCodeAt(0) :
-			 i == SplitType.SplitGroup 			   ? "g".charCodeAt(0) :
-			 				 			   			 "u".charCodeAt(0); // usemtl
+	static run = (path: string, replace_existing: bool = true) => {
+		let i: split_type_t = Context.raw.split_by;
+		let is_udim: bool = i == split_type_t.UDIM;
+		let split_code: i32 =
+			(i == split_type_t.OBJECT || is_udim) ? "o".charCodeAt(0) :
+			 i == split_type_t.GROUP 			  ? "g".charCodeAt(0) :
+			 				 			   		    "u".charCodeAt(0); // usemtl
 
 		let b: ArrayBuffer = data_get_blob(path);
 
-		if (isUdim) {
-			let part = krom_io_obj_parse(b, splitCode, 0, isUdim);
-			let name = part.name;
-			for (let i = 0; i < part.udims.length; ++i) {
+		if (is_udim) {
+			let part: any = krom_io_obj_parse(b, split_code, 0, is_udim);
+			let name: string = part.name;
+			for (let i: i32 = 0; i < part.udims.length; ++i) {
 				if (part.udims[i].length == 0) continue;
-				let u = i % part.udims_u;
-				let v = Math.floor(i / part.udims_u);
+				let u: i32 = i % part.udims_u;
+				let v: i32 = Math.floor(i / part.udims_u);
 				part.name = name + "." + (1000 + v * 10 + u + 1);
 				part.inda = part.udims[i];
-				i == 0 ? (replaceExisting ? ImportMesh.makeMesh(part, path) : ImportMesh.addMesh(part)) : ImportMesh.addMesh(part);
+				i == 0 ? (replace_existing ? ImportMesh.make_mesh(part, path) : ImportMesh.add_mesh(part)) : ImportMesh.add_mesh(part);
 			}
 		}
 		else {
 			let parts: any[] = [];
-			let part = krom_io_obj_parse(b, splitCode, 0, false);
+			let part: any = krom_io_obj_parse(b, split_code, 0, false);
 			parts.push(part);
 			while (part.has_next) {
-				part = krom_io_obj_parse(b, splitCode, part.pos, false);
+				part = krom_io_obj_parse(b, split_code, part.pos, false);
 				// This part does not contain faces (may contain lines only)
 				if (part.inda.length == 0) {
 					continue;
 				}
 				parts.push(part);
 			}
-			if (Context.raw.splitBy == SplitType.SplitMaterial) {
-				let posa0;
-				let posa1;
-				let nora0;
-				let nora1;
-				let texa0;
-				let texa1;
-				let inda0;
-				let inda1;
+			if (Context.raw.split_by == split_type_t.MATERIAL) {
+				let posa0: Int16Array;
+				let posa1: Int16Array;
+				let nora0: Int16Array;
+				let nora1: Int16Array;
+				let texa0: Int16Array;
+				let texa1: Int16Array;
+				let inda0: Uint32Array;
+				let inda1: Uint32Array;
 				// Merge to single object per material
-				for (let i = 0; i < parts.length; ++i) {
-					let j = i + 1;
+				for (let i: i32 = 0; i < parts.length; ++i) {
+					let j: i32 = i + 1;
 					while (j < parts.length) {
 						if (parts[i].name == parts[j].name) {
 							posa0 = parts[i].posa;
@@ -57,37 +57,37 @@ class ImportObj {
 							texa1 = parts[j].texa != null ? parts[j].texa : null;
 							inda0 = parts[i].inda;
 							inda1 = parts[j].inda;
-							let voff = Math.floor(posa0.length / 4);
+							let voff: i32 = Math.floor(posa0.length / 4);
 							// Repack merged positions
-							let posa32 = new Float32Array(Math.floor(posa0.length / 4) * 3 + Math.floor(posa1.length / 4) * 3);
-							for (let k = 0; k < Math.floor(posa0.length / 4); ++k) {
+							let posa32: Float32Array = new Float32Array(Math.floor(posa0.length / 4) * 3 + Math.floor(posa1.length / 4) * 3);
+							for (let k: i32 = 0; k < Math.floor(posa0.length / 4); ++k) {
 								posa32[k * 3    ] = posa0[k * 4    ] / 32767 * parts[i].scalePos;
 								posa32[k * 3 + 1] = posa0[k * 4 + 1] / 32767 * parts[i].scalePos;
 								posa32[k * 3 + 2] = posa0[k * 4 + 2] / 32767 * parts[i].scalePos;
 							}
-							for (let k = 0; k < Math.floor(posa1.length / 4); ++k) {
+							for (let k: i32 = 0; k < Math.floor(posa1.length / 4); ++k) {
 								posa32[voff * 3 + k * 3    ] = posa1[k * 4    ] / 32767 * parts[j].scalePos;
 								posa32[voff * 3 + k * 3 + 1] = posa1[k * 4 + 1] / 32767 * parts[j].scalePos;
 								posa32[voff * 3 + k * 3 + 2] = posa1[k * 4 + 2] / 32767 * parts[j].scalePos;
 							}
-							let scalePos = 0.0;
-							for (let k = 0; k < posa32.length; ++k) {
-								let f = Math.abs(posa32[k]);
+							let scalePos: f32 = 0.0;
+							for (let k: i32 = 0; k < posa32.length; ++k) {
+								let f: f32 = Math.abs(posa32[k]);
 								if (scalePos < f) scalePos = f;
 							}
-							let inv = 32767 * (1 / scalePos);
-							let posa = new Int16Array(posa0.length + posa1.length);
-							for (let k = 0; k < Math.floor(posa.length / 4); ++k) {
+							let inv: f32 = 32767 * (1 / scalePos);
+							let posa: Int16Array = new Int16Array(posa0.length + posa1.length);
+							for (let k: i32 = 0; k < Math.floor(posa.length / 4); ++k) {
 								posa[k * 4    ] = Math.floor(posa32[k * 3    ] * inv);
 								posa[k * 4 + 1] = Math.floor(posa32[k * 3 + 1] * inv);
 								posa[k * 4 + 2] = Math.floor(posa32[k * 3 + 2] * inv);
 							}
-							for (let k = 0; k < Math.floor(posa0.length / 4); ++k) posa[k * 4 + 3] = posa0[k * 4 + 3];
-							for (let k = 0; k < Math.floor(posa1.length / 4); ++k) posa[posa0.length + k * 4 + 3] = posa1[k * 4 + 3];
+							for (let k: i32 = 0; k < Math.floor(posa0.length / 4); ++k) posa[k * 4 + 3] = posa0[k * 4 + 3];
+							for (let k: i32 = 0; k < Math.floor(posa1.length / 4); ++k) posa[posa0.length + k * 4 + 3] = posa1[k * 4 + 3];
 							// Merge normals and uvs
-							let nora = new Int16Array(nora0.length + nora1.length);
-							let texa = (texa0 != null && texa1 != null) ? new Int16Array(texa0.length + texa1.length) : null;
-							let inda = new Uint32Array(inda0.length + inda1.length);
+							let nora: Int16Array = new Int16Array(nora0.length + nora1.length);
+							let texa: Int16Array = (texa0 != null && texa1 != null) ? new Int16Array(texa0.length + texa1.length) : null;
+							let inda: Uint32Array = new Uint32Array(inda0.length + inda1.length);
 							nora.set(nora0);
 							nora.set(nora1, nora0.length);
 							if (texa != null) {
@@ -95,7 +95,7 @@ class ImportObj {
 								texa.set(texa1, texa0.length);
 							}
 							inda.set(inda0);
-							for (let k = 0; k < inda1.length; ++k) inda[k + inda0.length] = inda1[k] + voff;
+							for (let k: i32 = 0; k < inda1.length; ++k) inda[k + inda0.length] = inda1[k] + voff;
 							parts[i].posa = posa;
 							parts[i].nora = nora;
 							parts[i].texa = texa;
@@ -107,9 +107,9 @@ class ImportObj {
 					}
 				}
 			}
-			replaceExisting ? ImportMesh.makeMesh(parts[0], path) : ImportMesh.addMesh(parts[0]);
-			for (let i = 1; i < parts.length; ++i) {
-				ImportMesh.addMesh(parts[i]);
+			replace_existing ? ImportMesh.make_mesh(parts[0], path) : ImportMesh.add_mesh(parts[0]);
+			for (let i: i32 = 1; i < parts.length; ++i) {
+				ImportMesh.add_mesh(parts[i]);
 			}
 		}
 		data_delete_blob(path);

+ 4 - 4
base/Sources/ImportPlugin.ts

@@ -2,15 +2,15 @@
 class ImportPlugin {
 
 	static run = (path: string) => {
-		if (!Path.isPlugin(path)) {
+		if (!Path.is_plugin(path)) {
 			Console.error(Strings.error1());
 			return;
 		}
 
-		let filename = path.substr(path.lastIndexOf(Path.sep) + 1);
-		let dstPath = Path.data() + Path.sep + "plugins" + Path.sep + filename;
+		let filename: string = path.substr(path.lastIndexOf(Path.sep) + 1);
+		let dstPath: string = Path.data() + Path.sep + "plugins" + Path.sep + filename;
 		File.copy(path, dstPath); // Copy to plugin folder
-		BoxPreferences.filesPlugin = null; // Refresh file list
+		BoxPreferences.files_plugin = null; // Refresh file list
 		Console.info(tr("Plugin imported:") + " " + filename);
 	}
 }

+ 16 - 16
base/Sources/ImportTexture.ts

@@ -1,9 +1,9 @@
 
 class ImportTexture {
 
-	static run = (path: string, hdrAsEnvmap = true) => {
-		if (!Path.isTexture(path)) {
-			if (!Context.enableImportPlugin(path)) {
+	static run = (path: string, hdrAsEnvmap: bool = true) => {
+		if (!Path.is_texture(path)) {
+			if (!Context.enable_import_plugin(path)) {
 				Console.error(Strings.error1());
 				return;
 			}
@@ -15,7 +15,7 @@ class ImportTexture {
 				// Set as envmap
 				if (hdrAsEnvmap && path.toLowerCase().endsWith(".hdr")) {
 					let image: image_t = data_get_image(path);
-					Base.notifyOnNextFrame(() => { // Make sure file browser process did finish
+					Base.notify_on_next_frame(() => { // Make sure file browser process did finish
 						ImportEnvmap.run(path, image);
 					});
 				}
@@ -24,33 +24,33 @@ class ImportTexture {
 			}
 		}
 
-		let ext = path.substr(path.lastIndexOf(".") + 1);
-		let importer = Path.textureImporters.get(ext);
-		let cached = data_cached_images.get(path) != null; // Already loaded or pink texture for missing file
-		if (importer == null || cached) importer = ImportTexture.defaultImporter;
+		let ext: string = path.substr(path.lastIndexOf(".") + 1);
+		let importer: (s: string, f: (img: image_t)=>void)=>void = Path.texture_importers.get(ext);
+		let cached: bool = data_cached_images.get(path) != null; // Already loaded or pink texture for missing file
+		if (importer == null || cached) importer = ImportTexture.default_importer;
 
 		importer(path, (image: image_t) => {
 			data_cached_images.set(path, image);
-			let ar = path.split(Path.sep);
-			let name = ar[ar.length - 1];
-			let asset: TAsset = {name: name, file: path, id: Project.assetId++};
+			let ar: string[] = path.split(Path.sep);
+			let name: string = ar[ar.length - 1];
+			let asset: asset_t = {name: name, file: path, id: Project.asset_id++};
 			Project.assets.push(asset);
 			if (Context.raw.texture == null) Context.raw.texture = asset;
-			Project.assetNames.push(name);
-			Project.assetMap.set(asset.id, image);
-			UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+			Project.asset_names.push(name);
+			Project.asset_map.set(asset.id, image);
+			UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 			Console.info(tr("Texture imported:") + " " + name);
 
 			// Set as envmap
 			if (hdrAsEnvmap && path.toLowerCase().endsWith(".hdr")) {
-				Base.notifyOnNextFrame(() => { // Make sure file browser process did finish
+				Base.notify_on_next_frame(() => { // Make sure file browser process did finish
 					ImportEnvmap.run(path, image);
 				});
 			}
 		});
 	}
 
-	static defaultImporter = (path: string, done: (img: image_t)=>void) => {
+	static default_importer = (path: string, done: (img: image_t)=>void) => {
 		let img: image_t = data_get_image(path);
 		done(img);
 	}

+ 6 - 6
base/Sources/ImportTheme.ts

@@ -2,18 +2,18 @@
 class ImportTheme {
 
 	static run = (path: string) => {
-		if (!Path.isJson(path)) {
+		if (!Path.is_json(path)) {
 			Console.error(Strings.error1());
 			return;
 		}
 
-		let filename = path.substr(path.lastIndexOf(Path.sep) + 1);
-		let dstPath = Path.data() + Path.sep + "themes" + Path.sep + filename;
+		let filename: string = path.substr(path.lastIndexOf(Path.sep) + 1);
+		let dstPath: string = Path.data() + Path.sep + "themes" + Path.sep + filename;
 		File.copy(path, dstPath); // Copy to preset folder
-		BoxPreferences.fetchThemes(); // Refresh file list
+		BoxPreferences.fetch_themes(); // Refresh file list
 		Config.raw.theme = filename;
-		BoxPreferences.themeHandle.position = BoxPreferences.getThemeIndex();
-		Config.loadTheme(Config.raw.theme);
+		BoxPreferences.theme_handle.position = BoxPreferences.get_theme_index();
+		Config.load_theme(Config.raw.theme);
 		Console.info(tr("Theme imported:") + " " + filename);
 	}
 }

+ 69 - 69
base/Sources/LineDraw.ts

@@ -2,31 +2,48 @@
 class LineDraw {
 
 	static color: color_t = 0xffff0000;
-	static strength = 0.005;
+	static strength: f32 = 0.005;
 	static mat: mat4_t = null;
 	static dim: vec4_t = null;
 
-	static vertexBuffer: vertex_buffer_t;
-	static indexBuffer: index_buffer_t;
+	static vertex_buffer: vertex_buffer_t;
+	static index_buffer: index_buffer_t;
 	static pipeline: pipeline_t = null;
 
 	static vp: mat4_t;
-	static vpID: kinc_const_loc_t;
+	static vp_loc: kinc_const_loc_t;
 
-	static vbData: DataView;
-	static ibData: Uint32Array;
+	static vb_data: DataView;
+	static ib_data: Uint32Array;
 
-	static maxLines = 300;
-	static maxVertices = LineDraw.maxLines * 4;
-	static maxIndices = LineDraw.maxLines * 6;
-	static lines = 0;
+	static max_lines: i32 = 300;
+	static max_vertices: i32 = LineDraw.max_lines * 4;
+	static max_indices: i32 = LineDraw.max_lines * 6;
+	static lines: i32 = 0;
+
+	static wpos: vec4_t;
+	static vx: vec4_t = vec4_create();
+	static vy: vec4_t = vec4_create();
+	static vz: vec4_t = vec4_create();
+
+	static v1: vec4_t = vec4_create();
+	static v2: vec4_t = vec4_create();
+	static t: vec4_t = vec4_create();
+
+	static mid_point: vec4_t = vec4_create();
+	static mid_line: vec4_t = vec4_create();
+	static corner1: vec4_t = vec4_create();
+	static corner2: vec4_t = vec4_create();
+	static corner3: vec4_t = vec4_create();
+	static corner4: vec4_t = vec4_create();
+	static camera_look: vec4_t = vec4_create();
 
 	static render = (matrix: mat4_t) => {
 		LineDraw.mat = matrix;
 		LineDraw.dim = mat4_get_scale(matrix);
 
 		if (LineDraw.pipeline == null) {
-			let structure = g4_vertex_struct_create();
+			let structure: vertex_struct_t = g4_vertex_struct_create();
 			g4_vertex_struct_add(structure, "pos", vertex_data_t.F32_3X);
 			g4_vertex_struct_add(structure, "col", vertex_data_t.F32_3X);
 			LineDraw.pipeline = g4_pipeline_create();
@@ -42,10 +59,10 @@ class LineDraw {
 			LineDraw.pipeline.color_attachments[2] = tex_format_t.RGBA64;
 			LineDraw.pipeline.depth_attachment = depth_format_t.DEPTH24;
 			g4_pipeline_compile(LineDraw.pipeline);
-			LineDraw.vpID = g4_pipeline_get_const_loc(LineDraw.pipeline, "VP");
+			LineDraw.vp_loc = g4_pipeline_get_const_loc(LineDraw.pipeline, "VP");
 			LineDraw.vp = mat4_identity();
-			LineDraw.vertexBuffer = g4_vertex_buffer_create(LineDraw.maxVertices, structure, usage_t.DYNAMIC);
-			LineDraw.indexBuffer = g4_index_buffer_create(LineDraw.maxIndices);
+			LineDraw.vertex_buffer = g4_vertex_buffer_create(LineDraw.max_vertices, structure, usage_t.DYNAMIC);
+			LineDraw.index_buffer = g4_index_buffer_create(LineDraw.max_indices);
 		}
 
 		LineDraw.begin();
@@ -53,20 +70,15 @@ class LineDraw {
 		LineDraw.end();
 	}
 
-	static wpos: vec4_t;
-	static vx = vec4_create();
-	static vy = vec4_create();
-	static vz = vec4_create();
-
 	static bounds = (mat: mat4_t, dim: vec4_t) => {
 		LineDraw.wpos = mat4_get_loc(mat);
-		let dx = dim.x / 2;
-		let dy = dim.y / 2;
-		let dz = dim.z / 2;
+		let dx: f32 = dim.x / 2;
+		let dy: f32 = dim.y / 2;
+		let dz: f32 = dim.z / 2;
 
-		let up = mat4_up(mat);
-		let look = mat4_look(mat);
-		let right = mat4_right(mat);
+		let up: vec4_t = mat4_up(mat);
+		let look: vec4_t = mat4_look(mat);
+		let right: vec4_t = mat4_right(mat);
 		vec4_normalize(up);
 		vec4_normalize(look);
 		vec4_normalize(right);
@@ -94,10 +106,6 @@ class LineDraw {
 		LineDraw.lineb( 1,  1, -1,  1,  1,  1);
 	}
 
-	static v1 = vec4_create();
-	static v2 = vec4_create();
-	static t = vec4_create();
-
 	static lineb = (a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) => {
 		vec4_set_from(LineDraw.v1, LineDraw.wpos);
 		vec4_set_from(LineDraw.t, LineDraw.vx); vec4_mult(LineDraw.t, a); vec4_add(LineDraw.v1, LineDraw.t);
@@ -112,32 +120,24 @@ class LineDraw {
 		LineDraw.line(LineDraw.v1.x, LineDraw.v1.y, LineDraw.v1.z, LineDraw.v2.x, LineDraw.v2.y, LineDraw.v2.z);
 	}
 
-	static midPoint = vec4_create();
-	static midLine = vec4_create();
-	static corner1 = vec4_create();
-	static corner2 = vec4_create();
-	static corner3 = vec4_create();
-	static corner4 = vec4_create();
-	static cameraLook = vec4_create();
-
 	static line = (x1: f32, y1: f32, z1: f32, x2: f32, y2: f32, z2: f32) => {
-		if (LineDraw.lines >= LineDraw.maxLines) {
+		if (LineDraw.lines >= LineDraw.max_lines) {
 			LineDraw.end();
 			LineDraw.begin();
 		}
 
-		vec4_set(LineDraw.midPoint, x1 + x2, y1 + y2, z1 + z2);
-		vec4_mult(LineDraw.midPoint, 0.5);
+		vec4_set(LineDraw.mid_point, x1 + x2, y1 + y2, z1 + z2);
+		vec4_mult(LineDraw.mid_point, 0.5);
 
-		vec4_set(LineDraw.midLine, x1, y1, z1);
-		vec4_sub(LineDraw.midLine, LineDraw.midPoint);
+		vec4_set(LineDraw.mid_line, x1, y1, z1);
+		vec4_sub(LineDraw.mid_line, LineDraw.mid_point);
 
-		let camera = scene_camera;
-		LineDraw.cameraLook = mat4_get_loc(camera.base.transform.world);
-		vec4_sub(LineDraw.cameraLook, LineDraw.midPoint);
+		let camera: camera_object_t = scene_camera;
+		LineDraw.camera_look = mat4_get_loc(camera.base.transform.world);
+		vec4_sub(LineDraw.camera_look, LineDraw.mid_point);
 
-		let lineWidth = vec4_cross(LineDraw.cameraLook, LineDraw.midLine);
-		vec4_normalize(lineWidth, );
+		let lineWidth: vec4_t = vec4_cross(LineDraw.camera_look, LineDraw.mid_line);
+		vec4_normalize(lineWidth);
 		vec4_mult(lineWidth, LineDraw.strength);
 
 		vec4_add(vec4_set(LineDraw.corner1, x1, y1, z1), lineWidth);
@@ -145,49 +145,49 @@ class LineDraw {
 		vec4_sub(vec4_set(LineDraw.corner3, x2, y2, z2), lineWidth);
 		vec4_add(vec4_set(LineDraw.corner4, x2, y2, z2), lineWidth);
 
-		let i = LineDraw.lines * 24; // 4 * 6 (structure len)
-		LineDraw.addVbData(i, [LineDraw.corner1.x, LineDraw.corner1.y, LineDraw.corner1.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
+		let i: i32 = LineDraw.lines * 24; // 4 * 6 (structure len)
+		LineDraw.add_vb_data(i, [LineDraw.corner1.x, LineDraw.corner1.y, LineDraw.corner1.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
 		i += 6;
-		LineDraw.addVbData(i, [LineDraw.corner2.x, LineDraw.corner2.y, LineDraw.corner2.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
+		LineDraw.add_vb_data(i, [LineDraw.corner2.x, LineDraw.corner2.y, LineDraw.corner2.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
 		i += 6;
-		LineDraw.addVbData(i, [LineDraw.corner3.x, LineDraw.corner3.y, LineDraw.corner3.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
+		LineDraw.add_vb_data(i, [LineDraw.corner3.x, LineDraw.corner3.y, LineDraw.corner3.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
 		i += 6;
-		LineDraw.addVbData(i, [LineDraw.corner4.x, LineDraw.corner4.y, LineDraw.corner4.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
+		LineDraw.add_vb_data(i, [LineDraw.corner4.x, LineDraw.corner4.y, LineDraw.corner4.z, color_get_rb(LineDraw.color) / 255, color_get_gb(LineDraw.color) / 255, color_get_ab(LineDraw.color) / 255]);
 
 		i = LineDraw.lines * 6;
-		LineDraw.ibData[i    ] = LineDraw.lines * 4;
-		LineDraw.ibData[i + 1] = LineDraw.lines * 4 + 1;
-		LineDraw.ibData[i + 2] = LineDraw.lines * 4 + 2;
-		LineDraw.ibData[i + 3] = LineDraw.lines * 4 + 2;
-		LineDraw.ibData[i + 4] = LineDraw.lines * 4 + 3;
-		LineDraw.ibData[i + 5] = LineDraw.lines * 4;
+		LineDraw.ib_data[i    ] = LineDraw.lines * 4;
+		LineDraw.ib_data[i + 1] = LineDraw.lines * 4 + 1;
+		LineDraw.ib_data[i + 2] = LineDraw.lines * 4 + 2;
+		LineDraw.ib_data[i + 3] = LineDraw.lines * 4 + 2;
+		LineDraw.ib_data[i + 4] = LineDraw.lines * 4 + 3;
+		LineDraw.ib_data[i + 5] = LineDraw.lines * 4;
 
 		LineDraw.lines++;
 	}
 
 	static begin = () => {
 		LineDraw.lines = 0;
-		LineDraw.vbData = g4_vertex_buffer_lock(LineDraw.vertexBuffer);
-		LineDraw.ibData = g4_index_buffer_lock(LineDraw.indexBuffer);
+		LineDraw.vb_data = g4_vertex_buffer_lock(LineDraw.vertex_buffer);
+		LineDraw.ib_data = g4_index_buffer_lock(LineDraw.index_buffer);
 	}
 
 	static end = () => {
-		g4_vertex_buffer_unlock(LineDraw.vertexBuffer);
-		g4_index_buffer_unlock(LineDraw.indexBuffer);
+		g4_vertex_buffer_unlock(LineDraw.vertex_buffer);
+		g4_index_buffer_unlock(LineDraw.index_buffer);
 
-		g4_set_vertex_buffer(LineDraw.vertexBuffer);
-		g4_set_index_buffer(LineDraw.indexBuffer);
+		g4_set_vertex_buffer(LineDraw.vertex_buffer);
+		g4_set_index_buffer(LineDraw.index_buffer);
 		g4_set_pipeline(LineDraw.pipeline);
-		let camera = scene_camera;
+		let camera: camera_object_t = scene_camera;
 		mat4_set_from(LineDraw.vp, camera.v);
 		mat4_mult_mat(LineDraw.vp, camera.p);
-		g4_set_mat(LineDraw.vpID, LineDraw.vp);
+		g4_set_mat(LineDraw.vp_loc, LineDraw.vp);
 		g4_draw(0, LineDraw.lines * 6);
 	}
 
-	static addVbData = (i: i32, data: f32[]) => {
-		for (let offset = 0; offset < 6; ++offset) {
-			LineDraw.vbData.setFloat32((i + offset) * 4, data[offset], true);
+	static add_vb_data = (i: i32, data: f32[]) => {
+		for (let offset: i32 = 0; offset < 6; ++offset) {
+			LineDraw.vb_data.setFloat32((i + offset) * 4, data[offset], true);
 		}
 	}
 }

+ 6 - 6
base/Sources/LogicNode.ts

@@ -5,11 +5,11 @@ class LogicNode {
 
 	constructor() {}
 
-	addInput = (node: LogicNode, from: i32) => {
+	add_input = (node: LogicNode, from: i32) => {
 		this.inputs.push(new LogicNodeInput(node, from));
 	}
 
-	addOutputs = (nodes: LogicNode[]) => {
+	add_outputs = (nodes: LogicNode[]) => {
 		this.outputs.push(nodes);
 	}
 
@@ -17,11 +17,11 @@ class LogicNode {
 		done(null);
 	}
 
-	getAsImage = (from: i32, done: (img: image_t)=>void) => {
+	get_as_image = (from: i32, done: (img: image_t)=>void) => {
 		done(null);
 	}
 
-	getCachedImage = (): image_t => {
+	get_cached_image = (): image_t => {
 		return null;
 	}
 
@@ -41,8 +41,8 @@ class LogicNodeInput {
 		this.node.get(this.from, done);
 	}
 
-	getAsImage = (done: (img: image_t)=>void) => {
-		this.node.getAsImage(this.from, done);
+	get_as_image = (done: (img: image_t)=>void) => {
+		this.node.get_as_image(this.from, done);
 	}
 
 	set = (value: any) => {

+ 12 - 8
base/Sources/MakeVoxel.ts

@@ -3,18 +3,22 @@ class MakeVoxel {
 
 	///if arm_voxels
 	static run = (data: shader_context_t) => {
-		let structure = g4_vertex_struct_create();
+		let structure: vertex_struct_t = g4_vertex_struct_create();
 		g4_vertex_struct_add(structure, "pos", vertex_data_t.I16_4X_NORM);
 		g4_vertex_struct_add(structure, "nor", vertex_data_t.I16_2X_NORM);
 		g4_vertex_struct_add(structure, "tex", vertex_data_t.I16_2X_NORM);
 
-		let pipeState = data._.pipe_state;
+		let pipeState: pipeline_t = data._.pipe_state;
 		pipeState.input_layout = [structure];
-		data.vertex_elements = [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}];
+		data.vertex_elements = [
+			{name: "pos", data: "short4norm"},
+			{name: "nor", data: "short2norm"},
+			{name: "tex", data: "short2norm"}
+		];
 
 		// ///if arm_skin
-		// let isMesh = Context.raw.object.constructor == mesh_object_t;
-		// let skin = isMesh && cast(Context.raw.object, mesh_object_t).data.geom.bones != null;
+		// let is_mesh: bool = Context.raw.object.constructor == mesh_object_t;
+		// let skin: bool = is_mesh && cast(Context.raw.object, mesh_object_t).data.geom.bones != null;
 		// if (skin) {
 		// 	VertexStructure.add(structure, "bone", VertexData.I16_4X_Normalized);
 		// 	VertexStructure.add(structure, "weight", VertexData.I16_4X_Normalized);
@@ -23,8 +27,8 @@ class MakeVoxel {
 		// }
 		// ///end
 
-		let ds = MakeMaterial.getDisplaceStrength();
-		pipeState.vertex_shader = g4_shader_from_source(MakeVoxel.voxelSource(), shader_type_t.VERTEX);
+		let ds: f32 = MakeMaterial.get_displace_strength();
+		pipeState.vertex_shader = g4_shader_from_source(MakeVoxel.voxel_source(), shader_type_t.VERTEX);
 
 		g4_pipeline_compile(pipeState);
 		data.constants = [{ name: "W", type: "mat4", link: "_world_matrix" }, { name: "N", type: "mat3", link: "_normal_matrix" }];
@@ -33,7 +37,7 @@ class MakeVoxel {
 		data._.tex_units = [g4_pipeline_get_tex_unit(pipeState, "texpaint_pack"), g4_pipeline_get_tex_unit(pipeState, "voxels")];
 	}
 
-	static voxelSource = (): string => {
+	static voxel_source = (): string => {
 		///if krom_direct3d11
 		return `#define vec3 float3
 		uniform float4x4 W;

+ 83 - 83
base/Sources/NodeShader.ts

@@ -1,46 +1,46 @@
 
 class NodeShaderRaw {
 	context: NodeShaderContextRaw;
-	shader_type = '';
+	shader_type: string = '';
 	includes: string[] = [];
 	ins: string[] = [];
 	outs: string[] = [];
-	sharedSamplers: string[] = [];
+	shared_samplers: string[] = [];
 	uniforms: string[] = [];
-	functions = new Map<string, string>();
-	main = '';
-	main_init = '';
-	main_end = '';
-	main_normal = '';
-	main_textures = '';
-	main_attribs = '';
-	header = '';
-	write_pre = false;
-	write_normal = 0;
-	write_textures = 0;
-	vstruct_as_vsin = true;
-	lock = false;
+	functions: Map<string, string> = new Map();
+	main: string = '';
+	main_init: string = '';
+	main_end: string = '';
+	main_normal: string = '';
+	main_textures: string = '';
+	main_attribs: string = '';
+	header: string = '';
+	write_pre: bool = false;
+	write_normal: i32 = 0;
+	write_textures: i32 = 0;
+	vstruct_as_vsin: bool = true;
+	lock: bool = false;
 
 	// References
-	bposition = false;
-	wposition = false;
-	mposition = false;
-	vposition = false;
-	wvpposition = false;
-	ndcpos = false;
-	wtangent = false;
-	vVec = false;
-	vVecCam = false;
-	n = false;
-	nAttr = false;
-	dotNV = false;
-	invTBN = false;
+	bposition: bool = false;
+	wposition: bool = false;
+	mposition: bool = false;
+	vposition: bool = false;
+	wvpposition: bool = false;
+	ndcpos: bool = false;
+	wtangent: bool = false;
+	vvec: bool = false;
+	vvec_cam: bool = false;
+	n: bool = false;
+	nattr: bool = false;
+	dotnv: bool = false;
+	inv_tbn: bool = false;
 }
 
 class NodeShader {
 
 	static create(context: NodeShaderContextRaw, shader_type: string): NodeShaderRaw {
-		let raw = new NodeShaderRaw();
+		let raw: NodeShaderRaw = new NodeShaderRaw();
 		raw.context = context;
 		raw.shader_type = shader_type;
 		return raw;
@@ -58,13 +58,13 @@ class NodeShader {
 		raw.outs.push(s);
 	}
 
-	static add_uniform = (raw: NodeShaderRaw, s: string, link: string = null, included = false) => {
-		let ar = s.split(' ');
+	static add_uniform = (raw: NodeShaderRaw, s: string, link: string = null, included: bool = false) => {
+		let ar: string[] = s.split(' ');
 		// layout(RGBA8) image3D voxels
-		let utype = ar[ar.length - 2];
-		let uname = ar[ar.length - 1];
+		let utype: string = ar[ar.length - 2];
+		let uname: string = ar[ar.length - 1];
 		if (utype.startsWith('sampler') || utype.startsWith('image') || utype.startsWith('uimage')) {
-			let is_image = (utype.startsWith('image') || utype.startsWith('uimage')) ? true : false;
+			let is_image: bool = (utype.startsWith('image') || utype.startsWith('uimage')) ? true : false;
 			NodeShaderContext.add_texture_unit(raw.context, utype, uname, link, is_image);
 		}
 		else {
@@ -85,18 +85,18 @@ class NodeShader {
 	}
 
 	static add_shared_sampler = (raw: NodeShaderRaw, s: string) => {
-		if (raw.sharedSamplers.indexOf(s) == -1) {
-			raw.sharedSamplers.push(s);
-			let ar = s.split(' ');
+		if (raw.shared_samplers.indexOf(s) == -1) {
+			raw.shared_samplers.push(s);
+			let ar: string[] = s.split(' ');
 			// layout(RGBA8) sampler2D tex
-			let utype = ar[ar.length - 2];
-			let uname = ar[ar.length - 1];
+			let utype: string = ar[ar.length - 2];
+			let uname: string = ar[ar.length - 1];
 			NodeShaderContext.add_texture_unit(raw.context, utype, uname, null, false);
 		}
 	}
 
 	static add_function = (raw: NodeShaderRaw, s: string) => {
-		let fname = s.split('(')[0];
+		let fname: string = s.split('(')[0];
 		if (raw.functions.has(fname)) return;
 		raw.functions.set(fname, s);
 	}
@@ -155,7 +155,7 @@ class NodeShader {
 	static vstruct_to_vsin = (raw: NodeShaderRaw) => {
 		// if self.shader_type != 'vert' or self.ins != [] or not self.vstruct_as_vsin: # Vertex structure as vertex shader input
 			// return
-		let vs = raw.context.data.vertex_elements;
+		let vs: vertex_element_t[] = raw.context.data.vertex_elements;
 		for (let e of vs) {
 			NodeShader.add_in(raw, 'vec' + NodeShader.dataSize(raw, e.data) + ' ' + e.name);
 		}
@@ -163,7 +163,7 @@ class NodeShader {
 
 	///if (krom_direct3d11 || krom_direct3d12)
 	static get_hlsl(raw: NodeShaderRaw, sharedSampler: string): string {
-		let s = '#define HLSL\n';
+		let s: string = '#define HLSL\n';
 		s += '#define textureArg(tex) Texture2D tex,SamplerState tex ## _sampler\n';
 		s += '#define texturePass(tex) tex,tex ## _sampler\n';
 		s += '#define sampler2D Texture2D\n';
@@ -194,15 +194,15 @@ class NodeShader {
 
 		s += raw.header;
 
-		let in_ext = '';
-		let out_ext = '';
+		let in_ext: string = '';
+		let out_ext: string = '';
 
 		for (let a of raw.includes) {
 			s += '#include "' + a + '"\n';
 		}
 
 		// Input structure
-		let index = 0;
+		let index: i32 = 0;
 		if (raw.ins.length > 0) {
 			s += 'struct SPIRV_Cross_Input {\n';
 			index = 0;
@@ -227,7 +227,7 @@ class NodeShader {
 		}
 
 		// Output structure
-		let num = 0;
+		let num: i32 = 0;
 		if (raw.outs.length > 0 || raw.shader_type == 'vert') {
 			s += 'struct SPIRV_Cross_Output {\n';
 			raw.outs.sort((a, b): i32 => {
@@ -243,7 +243,7 @@ class NodeShader {
 				s += 'float4 svpos : SV_POSITION;\n';
 			}
 			else {
-				let out = raw.outs[0];
+				let out: string = raw.outs[0];
 				// Multiple render targets
 				if (out.charAt(out.length - 1) == ']') {
 					num = parseInt(out.charAt(out.length - 2));
@@ -263,8 +263,8 @@ class NodeShader {
 			}
 		}
 
-		if (raw.sharedSamplers.length > 0) {
-			for (let a of raw.sharedSamplers) {
+		if (raw.shared_samplers.length > 0) {
+			for (let a of raw.shared_samplers) {
 				s += 'uniform ' + a + ';\n';
 			}
 			s += `SamplerState ${sharedSampler};\n`;
@@ -294,7 +294,7 @@ class NodeShader {
 
 		// Declare inputs
 		for (let a of raw.ins) {
-			let b = a.substring(5); // Remove type 'vec4 '
+			let b: string = a.substring(5); // Remove type 'vec4 '
 			s += `${a} = stage_input.${b};\n`;
 		}
 
@@ -325,13 +325,13 @@ class NodeShader {
 				s += 'gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n';
 				s += 'stage_output.svpos = gl_Position;\n';
 				for (let a of raw.outs) {
-					let b = a.substring(5); // Remove type 'vec4 '
+					let b: string = a.substring(5); // Remove type 'vec4 '
 					s += `stage_output.${b} = ${b};\n`;
 				}
 			}
 			else {
 				if (num > 0) {
-					for (let i = 0; i < num; ++i) {
+					for (let i: i32 = 0; i < num; ++i) {
 						s += `stage_output.fragColor[${i}] = fragColor[${i}];\n`;
 					}
 				}
@@ -348,7 +348,7 @@ class NodeShader {
 
 	///if krom_metal
 	static get_msl(raw: NodeShaderRaw, sharedSampler: string): string {
-		let s = '#define METAL\n';
+		let s: string = '#define METAL\n';
 		s += '#include <metal_stdlib>\n';
 		s += '#include <simd/simd.h>\n';
 		s += 'using namespace metal;\n';
@@ -387,7 +387,7 @@ class NodeShader {
 		s += raw.header;
 
 		// Input structure
-		let index = 0;
+		let index: i32 = 0;
 		//if (ins.length > 0) {
 			s += 'struct main_in {\n';
 			index = 0;
@@ -411,7 +411,7 @@ class NodeShader {
 		//}
 
 		// Output structure
-		let num = 0;
+		let num: i32 = 0;
 		if (raw.outs.length > 0 || raw.shader_type == 'vert') {
 			s += 'struct main_out {\n';
 			raw.outs.sort((a, b): i32 => {
@@ -427,11 +427,11 @@ class NodeShader {
 				s += 'float4 svpos [[position]];\n';
 			}
 			else {
-				let out = raw.outs[0];
+				let out: string = raw.outs[0];
 				// Multiple render targets
 				if (out.charAt(out.length - 1) == ']') {
 					num = parseInt(out.charAt(out.length - 2));
-					for (let i = 0; i < num; ++i) {
+					for (let i: i32 = 0; i < num; ++i) {
 						s += `float4 fragColor_${i} [[color(${i})]];\n`;
 					}
 				}
@@ -473,21 +473,21 @@ class NodeShader {
 			s += 'main_in in [[stage_in]]';
 		//}
 		if (raw.uniforms.length > 0) {
-			let bufi = raw.shader_type == 'vert' ? 1 : 0;
+			let bufi: i32 = raw.shader_type == 'vert' ? 1 : 0;
 			s += `, constant main_uniforms& uniforms [[buffer(${bufi})]]`;
 		}
 
 		if (samplers.length > 0) {
-			for (let i = 0; i < samplers.length; ++i) {
+			for (let i: i32 = 0; i < samplers.length; ++i) {
 				s += `, ${samplers[i]} [[texture(${i})]]`;
 				s += ', sampler ' + samplers[i].split(' ')[1] + `_sampler [[sampler(${i})]]`;
 			}
 		}
 
-		if (raw.sharedSamplers.length > 0) {
-			for (let i = 0; i < raw.sharedSamplers.length; ++i) {
-				let index = samplers.length + i;
-				s += `, ${raw.sharedSamplers[i]} [[texture(${index})]]`;
+		if (raw.shared_samplers.length > 0) {
+			for (let i: i32 = 0; i < raw.shared_samplers.length; ++i) {
+				let index: i32 = samplers.length + i;
+				s += `, ${raw.shared_samplers[i]} [[texture(${index})]]`;
 			}
 			s += `, sampler ${sharedSampler} [[sampler(${samplers.length})]]`;
 		}
@@ -506,16 +506,16 @@ class NodeShader {
 
 		// Declare inputs
 		for (let a of raw.ins) {
-			let b = a.substring(5); // Remove type 'vec4 '
+			let b: string = a.substring(5); // Remove type 'vec4 '
 			s += `${a} = in.${b};\n`;
 		}
 
 		for (let a of raw.uniforms) {
 			if (!a.startsWith('sampler')) {
-				let b = a.split(" ")[1]; // Remove type 'vec4 '
+				let b: string = a.split(" ")[1]; // Remove type 'vec4 '
 				if (b.indexOf("[") >= 0) {
 					b = b.substring(0, b.indexOf("["));
-					let type = a.split(" ")[0];
+					let type: string = a.split(" ")[0];
 					s += `constant ${type} *${b} = uniforms.${b};\n`;
 				}
 				else {
@@ -551,13 +551,13 @@ class NodeShader {
 				s += 'gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n';
 				s += 'out.svpos = gl_Position;\n';
 				for (let a of raw.outs) {
-					let b = a.split(" ")[1]; // Remove type 'vec4 '
+					let b: string = a.split(" ")[1]; // Remove type 'vec4 '
 					s += `out.${b} = ${b};\n`;
 				}
 			}
 			else {
 				if (num > 0) {
-					for (let i = 0; i < num; ++i) {
+					for (let i: i32 = 0; i < num; ++i) {
 						s += `out.fragColor_${i} = fragColor[${i}];\n`;
 					}
 				}
@@ -574,7 +574,7 @@ class NodeShader {
 
 	///if (krom_opengl || krom_vulkan)
 	static get_glsl(raw: NodeShaderRaw, sharedSampler: string, version_header: string): string {
-		let s = version_header;
+		let s: string = version_header;
 		s += '#define textureArg(tex) sampler2D tex\n';
 		s += '#define texturePass(tex) tex\n';
 		s += '#define mul(a, b) b * a\n';
@@ -583,8 +583,8 @@ class NodeShader {
 		s += '#define atan2(x, y) atan(y, x)\n';
 		s += raw.header;
 
-		let in_ext = '';
-		let out_ext = '';
+		let in_ext: string = '';
+		let out_ext: string = '';
 
 		for (let a of raw.includes) {
 			s += '#include "' + a + '"\n';
@@ -598,7 +598,7 @@ class NodeShader {
 		for (let a of raw.uniforms) {
 			s += 'uniform ' + a + ';\n';
 		}
-		for (let a of raw.sharedSamplers) {
+		for (let a of raw.shared_samplers) {
 			s += 'uniform ' + a + ';\n';
 		}
 		for (let f of raw.functions.values()) {
@@ -622,28 +622,28 @@ class NodeShader {
 			NodeShader.vstruct_to_vsin(raw);
 		}
 
-		let sharedSampler = 'shared_sampler';
-		if (raw.sharedSamplers.length > 0) {
-			sharedSampler = raw.sharedSamplers[0].split(' ')[1] + '_sampler';
+		let sharedSampler: string = 'shared_sampler';
+		if (raw.shared_samplers.length > 0) {
+			sharedSampler = raw.shared_samplers[0].split(' ')[1] + '_sampler';
 		}
 
 		///if (krom_direct3d11 || krom_direct3d12)
-		let s = NodeShader.get_hlsl(raw, sharedSampler);
+		let s: string = NodeShader.get_hlsl(raw, sharedSampler);
 		///elseif krom_metal
-		let s = NodeShader.get_msl(raw, sharedSampler);
+		let s: string = NodeShader.get_msl(raw, sharedSampler);
 		///elseif krom_vulkan
-		let version_header = '#version 450\n';
-		let s = NodeShader.get_glsl(raw, sharedSampler, version_header);
+		let version_header: string = '#version 450\n';
+		let s: string = NodeShader.get_glsl(raw, sharedSampler, version_header);
 		///elseif krom_android
-		let version_header = '#version 300 es\n';
+		let version_header: string = '#version 300 es\n';
 		if (raw.shader_type == 'frag') {
 			version_header += 'precision highp float;\n';
 			version_header += 'precision mediump int;\n';
 		}
-		let s = NodeShader.get_glsl(raw, sharedSampler, version_header);
+		let s: string = NodeShader.get_glsl(raw, sharedSampler, version_header);
 		///elseif krom_opengl
-		let version_header = '#version 330\n';
-		let s = NodeShader.get_glsl(raw, sharedSampler, version_header);
+		let version_header: string = '#version 330\n';
+		let s: string = NodeShader.get_glsl(raw, sharedSampler, version_header);
 		///end
 
 		return s;

+ 9 - 9
base/Sources/NodeShaderContext.ts

@@ -3,16 +3,16 @@ class NodeShaderContextRaw {
 	vert: NodeShaderRaw;
 	frag: NodeShaderRaw;
 	data: shader_context_t;
-	allow_vcols = false;
-	material: TMaterial;
+	allow_vcols: bool = false;
+	material: material_t;
 	constants: shader_const_t[];
 	tunits: tex_unit_t[];
 }
 
 class NodeShaderContext {
 
-	static create(material: TMaterial, props: any): NodeShaderContextRaw {
-		let raw = new NodeShaderContextRaw();
+	static create(material: material_t, props: any): NodeShaderContextRaw {
+		let raw: NodeShaderContextRaw = new NodeShaderContextRaw();
 		raw.material = material;
 		raw.data = {
 			name: props.name,
@@ -90,7 +90,7 @@ class NodeShaderContext {
 		raw.constants.push(c);
 	}
 
-	static add_texture_unit = (raw: NodeShaderContextRaw, ctype: string, name: string, link: string = null, is_image = false) => {
+	static add_texture_unit = (raw: NodeShaderContextRaw, ctype: string, name: string, link: string = null, is_image: bool = false) => {
 		for (let c of raw.tunits) {
 			if (c.name == name) {
 				return;
@@ -120,7 +120,7 @@ class NodeShaderContext {
 	}
 }
 
-type TMaterial = {
-	name: string;
-	canvas: zui_node_canvas_t;
-}
+type material_t = {
+	name?: string;
+	canvas?: zui_node_canvas_t;
+};

+ 68 - 68
base/Sources/NodesMaterial.ts

@@ -2,7 +2,7 @@
 
 class NodesMaterial {
 
-	static categories = [_tr("Input"), _tr("Texture"), _tr("Color"), _tr("Vector"), _tr("Converter"), _tr("Group")];
+	static categories: string[] = [_tr("Input"), _tr("Texture"), _tr("Color"), _tr("Vector"), _tr("Converter"), _tr("Group")];
 
 	static list: zui_node_t[][] = [
 		[ // Input
@@ -2779,31 +2779,31 @@ class NodesMaterial {
 		]
 	];
 
-	static vectorCurvesButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
-		let but = node.buttons[0];
-		let nhandle = zui_nest(zui_handle("nodesmaterial_0"), node.id);
+	static vector_curves_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
+		let but: zui_node_button_t = node.buttons[0];
+		let nhandle: zui_handle_t = zui_nest(zui_handle("nodesmaterial_0"), node.id);
 		zui_row([1 / 3, 1 / 3, 1 / 3]);
 		zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 0, "X");
 		zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 1, "Y");
 		zui_radio(zui_nest(zui_nest(nhandle, 0), 1), 2, "Z");
 		// Preview
-		let axis = zui_nest(zui_nest(nhandle, 0), 1).position;
+		let axis: i32 = zui_nest(zui_nest(nhandle, 0), 1).position;
 		let val: Float32Array[] = but.default_value[axis]; // [ [[x, y], [x, y], ..], [[x, y]], ..]
-		let num = val.length;
-		// for (let i = 0; i < num; ++i) { ui.line(); }
+		let num: i32 = val.length;
+		// for (let i: i32 = 0; i < num; ++i) { ui.line(); }
 		ui._y += zui_nodes_LINE_H() * 5;
 		// Edit
 		zui_row([1 / 5, 1 / 5, 3 / 5]);
 		if (zui_button("+")) {
-			let f32a = new Float32Array(2);
+			let f32a: Float32Array = new Float32Array(2);
 			f32a[0] = 0; f32a[1] = 0;
 			val.push(f32a);
 		}
 		if (zui_button("-")) {
 			if (val.length > 2) val.pop();
 		}
-		let ihandle = zui_nest(zui_nest(zui_nest(nhandle, 0), 2), axis, {position: 0});
-		let i = Math.floor(zui_slider(ihandle, "Index", 0, num - 1, false, 1, true, zui_align_t.LEFT));
+		let ihandle: zui_handle_t = zui_nest(zui_nest(zui_nest(nhandle, 0), 2), axis, {position: 0});
+		let i: i32 = Math.floor(zui_slider(ihandle, "Index", 0, num - 1, false, 1, true, zui_align_t.LEFT));
 		if (i >= val.length || i < 0) ihandle.value = i = val.length - 1; // Stay in bounds
 		zui_row([1 / 2, 1 / 2]);
 		zui_nest(zui_nest(nhandle, 0), 3).value = val[i][0];
@@ -2812,27 +2812,27 @@ class NodesMaterial {
 		val[i][1] = zui_slider(zui_nest(zui_nest(nhandle, 0), 4, {value: 0}), "Y", -1, 1, true, 100, true, zui_align_t.LEFT);
 	}
 
-	static colorRampButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
-		let but = node.buttons[0];
-		let nhandle = zui_nest(zui_handle("nodesmaterial_1"), node.id);
-		let nx = ui._x;
-		let ny = ui._y;
+	static color_ramp_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
+		let but: zui_node_button_t = node.buttons[0];
+		let nhandle: zui_handle_t = zui_nest(zui_handle("nodesmaterial_1"), node.id);
+		let nx: f32 = ui._x;
+		let ny: f32 = ui._y;
 
 		// Preview
 		let vals: Float32Array[] = but.default_value; // [[r, g, b, a, pos], ..]
-		let sw = ui._w / zui_nodes_SCALE();
+		let sw: f32 = ui._w / zui_nodes_SCALE();
 		for (let val of vals) {
-			let pos = val[4];
-			let col = color_from_floats(val[0], val[1], val[2], 1.0);
+			let pos: f32 = val[4];
+			let col: i32 = color_from_floats(val[0], val[1], val[2], 1.0);
 			zui_fill(pos * sw, 0, (1.0 - pos) * sw, zui_nodes_LINE_H() - 2 * zui_nodes_SCALE(), col);
 		}
 		ui._y += zui_nodes_LINE_H();
 		// Edit
-		let ihandle = zui_nest(zui_nest(nhandle, 0), 2);
+		let ihandle: zui_handle_t = zui_nest(zui_nest(nhandle, 0), 2);
 		zui_row([1 / 4, 1 / 4, 2 / 4]);
 		if (zui_button("+")) {
-			let last = vals[vals.length - 1];
-			let f32a = new Float32Array(5);
+			let last: Float32Array = vals[vals.length - 1];
+			let f32a: Float32Array = new Float32Array(5);
 			f32a[0] = last[0];
 			f32a[1] = last[1];
 			f32a[2] = last[2];
@@ -2848,20 +2848,20 @@ class NodesMaterial {
 		but.data = zui_combo(zui_nest(zui_nest(nhandle, 0), 1, {position: but.data}), [tr("Linear"), tr("Constant")], tr("Interpolate"));
 
 		zui_row([1 / 2, 1 / 2]);
-		let i = Math.floor(zui_slider(ihandle, "Index", 0, vals.length - 1, false, 1, true, zui_align_t.LEFT));
+		let i: i32 = Math.floor(zui_slider(ihandle, "Index", 0, vals.length - 1, false, 1, true, zui_align_t.LEFT));
 		if (i >= vals.length || i < 0) ihandle.value = i = vals.length - 1; // Stay in bounds
 
-		let val = vals[i];
+		let val: Float32Array = vals[i];
 		zui_nest(zui_nest(nhandle, 0), 3).value = val[4];
 		val[4] = zui_slider(zui_nest(zui_nest(nhandle, 0), 3), "Pos", 0, 1, true, 100, true, zui_align_t.LEFT);
 		if (val[4] > 1.0) val[4] = 1.0; // Stay in bounds
 		else if (val[4] < 0.0) val[4] = 0.0;
 
-		let chandle = zui_nest(zui_nest(nhandle, 0), 4);
+		let chandle: zui_handle_t = zui_nest(zui_nest(nhandle, 0), 4);
 		chandle.color = color_from_floats(val[0], val[1], val[2], 1.0);
 		if (zui_text("", zui_align_t.RIGHT, chandle.color) == zui_state_t.STARTED) {
-			let rx = nx + ui._w - zui_nodes_p(37);
-			let ry = ny - zui_nodes_p(5);
+			let rx: f32 = nx + ui._w - zui_nodes_p(37);
+			let ry: f32 = ny - zui_nodes_p(5);
 			nodes._inputStarted = ui.input_started = false;
 			zui_nodes_rgba_popup(ui, chandle, val, Math.floor(rx), Math.floor(ry + zui_ELEMENT_H(ui)));
 		}
@@ -2870,13 +2870,13 @@ class NodesMaterial {
 		val[2] = color_get_bb(chandle.color) / 255;
 	}
 
-	static newGroupButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
+	static new_group_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
 		if (node.name == "New Group") {
-			for (let i = 1; i < 999; ++i) {
+			for (let i: i32 = 1; i < 999; ++i) {
 				node.name = tr("Group") + " " + i;
 
-				let found = false;
-				for (let g of Project.materialGroups) {
+				let found: bool = false;
+				for (let g of Project.material_groups) {
 					if (g.canvas.name == node.name) {
 						found = true;
 						break;
@@ -2927,11 +2927,11 @@ class NodesMaterial {
 				],
 				links: []
 			};
-			Project.materialGroups.push({ canvas: canvas, nodes: zui_nodes_create() });
+			Project.material_groups.push({ canvas: canvas, nodes: zui_nodes_create() });
 		}
 
-		let group: TNodeGroup = null;
-		for (let g of Project.materialGroups) {
+		let group: node_group_t = null;
+		for (let g of Project.material_groups) {
 			if (g.canvas.name == node.name) {
 				group = g;
 				break;
@@ -2939,57 +2939,57 @@ class NodesMaterial {
 		}
 
 		if (zui_button(tr("Nodes"))) {
-			UINodes.groupStack.push(group);
+			UINodes.group_stack.push(group);
 		}
 	}
 
-	static groupInputButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
-		NodesMaterial.addSocketButton(ui, nodes, node, node.outputs);
+	static group_input_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
+		NodesMaterial.add_socket_button(ui, nodes, node, node.outputs);
 	}
 
-	static groupOutputButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
-		NodesMaterial.addSocketButton(ui, nodes, node, node.inputs);
+	static group_output_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t) => {
+		NodesMaterial.add_socket_button(ui, nodes, node, node.inputs);
 	}
 
-	static addSocketButton = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t, sockets: zui_node_socket_t[]) => {
+	static add_socket_button = (ui: zui_t, nodes: zui_nodes_t, node: zui_node_t, sockets: zui_node_socket_t[]) => {
 		if (zui_button(tr("Add"))) {
 			UIMenu.draw((ui: zui_t) => {
-				let groupStack = UINodes.groupStack;
-				let c = groupStack[groupStack.length - 1].canvas;
-				if (UIMenu.menuButton(ui, tr("RGBA"))) {
-					sockets.push(NodesMaterial.createSocket(nodes, node, null, "RGBA", c));
-					NodesMaterial.syncSockets(node);
+				let groupStack: node_group_t[] = UINodes.group_stack;
+				let c: zui_node_canvas_t = groupStack[groupStack.length - 1].canvas;
+				if (UIMenu.menu_button(ui, tr("RGBA"))) {
+					sockets.push(NodesMaterial.create_socket(nodes, node, null, "RGBA", c));
+					NodesMaterial.sync_sockets(node);
 				}
-				if (UIMenu.menuButton(ui, tr("Vector"))) {
-					sockets.push(NodesMaterial.createSocket(nodes, node, null, "VECTOR", c));
-					NodesMaterial.syncSockets(node);
+				if (UIMenu.menu_button(ui, tr("Vector"))) {
+					sockets.push(NodesMaterial.create_socket(nodes, node, null, "VECTOR", c));
+					NodesMaterial.sync_sockets(node);
 				}
-				if (UIMenu.menuButton(ui, tr("Value"))) {
-					sockets.push(NodesMaterial.createSocket(nodes, node, null, "VALUE", c));
-					NodesMaterial.syncSockets(node);
+				if (UIMenu.menu_button(ui, tr("Value"))) {
+					sockets.push(NodesMaterial.create_socket(nodes, node, null, "VALUE", c));
+					NodesMaterial.sync_sockets(node);
 				}
 			}, 3);
 		}
 	}
 
-	static syncSockets = (node: zui_node_t) => {
-		let groupStack = UINodes.groupStack;
-		let c = groupStack[groupStack.length - 1].canvas;
-		for (let m of Project.materials) NodesMaterial.syncGroupSockets(m.canvas, c.name, node);
-		for (let g of Project.materialGroups) NodesMaterial.syncGroupSockets(g.canvas, c.name, node);
+	static sync_sockets = (node: zui_node_t) => {
+		let groupStack: node_group_t[] = UINodes.group_stack;
+		let c: zui_node_canvas_t = groupStack[groupStack.length - 1].canvas;
+		for (let m of Project.materials) NodesMaterial.sync_group_sockets(m.canvas, c.name, node);
+		for (let g of Project.material_groups) NodesMaterial.sync_group_sockets(g.canvas, c.name, node);
 		zui_node_replace.push(node);
 	}
 
-	static syncGroupSockets = (canvas: zui_node_canvas_t, groupName: string, node: zui_node_t) => {
+	static sync_group_sockets = (canvas: zui_node_canvas_t, groupName: string, node: zui_node_t) => {
 		for (let n of canvas.nodes) {
 			if (n.type == "GROUP" && n.name == groupName) {
-				let isInputs = node.name == "Group Input";
-				let oldSockets = isInputs ? n.inputs : n.outputs;
-				let sockets = JSON.parse(JSON.stringify(isInputs ? node.outputs : node.inputs));
+				let isInputs: bool = node.name == "Group Input";
+				let oldSockets: zui_node_socket_t[] = isInputs ? n.inputs : n.outputs;
+				let sockets: zui_node_socket_t[] = json_parse(json_stringify(isInputs ? node.outputs : node.inputs));
 				isInputs ? n.inputs = sockets : n.outputs = sockets;
 				for (let s of sockets) s.node_id = n.id;
-				let numSockets = sockets.length < oldSockets.length ? sockets.length : oldSockets.length;
-				for (let i = 0; i < numSockets; ++i) {
+				let numSockets: i32 = sockets.length < oldSockets.length ? sockets.length : oldSockets.length;
+				for (let i: i32 = 0; i < numSockets; ++i) {
 					if (sockets[i].type == oldSockets[i].type) {
 						sockets[i].default_value = oldSockets[i].default_value;
 					}
@@ -3010,7 +3010,7 @@ class NodesMaterial {
 		return type == "RGBA" ? _tr("Color") : type == "VECTOR" ? _tr("Vector") : _tr("Value");
 	}
 
-	static createSocket = (nodes: zui_nodes_t, node: zui_node_t, name: string, type: string, canvas: zui_node_canvas_t, min = 0.0, max = 1.0, default_value: any = null): zui_node_socket_t => {
+	static create_socket = (nodes: zui_nodes_t, node: zui_node_t, name: string, type: string, canvas: zui_node_canvas_t, min = 0.0, max = 1.0, default_value: any = null): zui_node_socket_t => {
 		return {
 			id: zui_get_socket_id(canvas.nodes),
 			node_id: node.id,
@@ -3023,17 +3023,17 @@ class NodesMaterial {
 		}
 	}
 
-	static getTNode = (nodeType: string): zui_node_t => {
+	static get_node_t = (nodeType: string): zui_node_t => {
 		for (let c of NodesMaterial.list) for (let n of c) if (n.type == nodeType) return n;
 		return null;
 	}
 
-	static createNode = (nodeType: string, group: TNodeGroup = null): zui_node_t => {
-		let n = NodesMaterial.getTNode(nodeType);
+	static create_node = (nodeType: string, group: node_group_t = null): zui_node_t => {
+		let n: zui_node_t = NodesMaterial.get_node_t(nodeType);
 		if (n == null) return null;
-		let canvas = group != null ? group.canvas : Context.raw.material.canvas;
-		let nodes = group != null ? group.nodes : Context.raw.material.nodes;
-		let node = UINodes.makeNode(n, nodes, canvas);
+		let canvas: zui_node_canvas_t = group != null ? group.canvas : Context.raw.material.canvas;
+		let nodes: zui_nodes_t = group != null ? group.nodes : Context.raw.material.nodes;
+		let node: zui_node_t = UINodes.make_node(n, nodes, canvas);
 		canvas.nodes.push(node);
 		return node;
 	}

+ 8 - 8
base/Sources/Operator.ts

@@ -1,7 +1,7 @@
 
 class Operator {
 
-	static ops = new Map<string, any>();
+	static ops: Map<string, any> = new Map();
 
 	static register = (name: string, call: any) => {
 		Operator.ops.set(name, call);
@@ -21,18 +21,18 @@ class Operator {
 
 	static shortcut = (s: string, type = ShortcutType.ShortcutStarted): bool => {
 		if (s == "") return false;
-		let shift = s.indexOf("shift") >= 0;
-		let ctrl = s.indexOf("ctrl") >= 0;
-		let alt = s.indexOf("alt") >= 0;
-		let flag = shift == keyboard_down("shift") &&
-				   ctrl == keyboard_down("control") &&
-				   alt == keyboard_down("alt");
+		let shift: bool = s.indexOf("shift") >= 0;
+		let ctrl: bool = s.indexOf("ctrl") >= 0;
+		let alt: bool = s.indexOf("alt") >= 0;
+		let flag: bool = shift == keyboard_down("shift") &&
+				   		 ctrl == keyboard_down("control") &&
+				   		 alt == keyboard_down("alt");
 		if (s.indexOf("+") > 0) {
 			s = s.substr(s.lastIndexOf("+") + 1);
 			if (s == "number") return flag;
 		}
 		else if (shift || ctrl || alt) return flag;
-		let key = (s == "left" || s == "right" || s == "middle") ?
+		let key: bool = (s == "left" || s == "right" || s == "middle") ?
 			// Mouse
 			(type == ShortcutType.ShortcutDown ? mouse_down(s) : mouse_started(s)) :
 			// Keyboard

+ 130 - 130
base/Sources/ParserBlend.ts

@@ -3,9 +3,9 @@
 // https://github.com/fschutt/mystery-of-the-blend-backup
 // https://web.archive.org/web/20170630054951/http://www.atmind.nl/blender/mystery_ot_blend.html
 // Usage:
-// let bl = ParserBlend.init(blob: DataView);
+// let bl: BlendRaw = ParserBlend.init(blob: DataView);
 // krom_log(ParserBlend.dir(bl, "Scene"));
-// let scenes = ParserBlend.get(bl, "Scene");
+// let scenes: any = ParserBlend.get(bl, "Scene");
 // krom_log(BlHandle.get(BlHandle.get(scenes[0], "id"), "name"));
 
 class BlendRaw {
@@ -14,24 +14,24 @@ class BlendRaw {
 
 	// Header
 	version: string;
-	pointerSize: i32;
-	littleEndian: bool;
+	pointer_size: i32;
+	little_endian: bool;
 	// Data
 	blocks: Block[] = [];
 	dna: Dna = null;
-	map = new Map<any, Block>(); // Map blocks by memory address
+	map: Map<any, Block> = new Map(); // Map blocks by memory address
 }
 
 class ParserBlend {
 
 	static init = (buffer: ArrayBuffer): BlendRaw => {
-		let raw = new BlendRaw();
+		let raw: BlendRaw = new BlendRaw();
 		raw.view = new DataView(buffer);
 		raw.pos = 0;
-		if (ParserBlend.readChars(raw, 7) != "BLENDER") {
+		if (ParserBlend.read_chars(raw, 7) != "BLENDER") {
 			raw.view = new DataView(krom_inflate(buffer, false));
 			raw.pos = 0;
-			if (ParserBlend.readChars(raw, 7) != "BLENDER") return null;
+			if (ParserBlend.read_chars(raw, 7) != "BLENDER") return null;
 		}
 		ParserBlend.parse(raw);
 		return raw;
@@ -39,13 +39,13 @@ class ParserBlend {
 
 	static dir = (raw: BlendRaw, type: string): string[] => {
 		// Return structure fields
-		let typeIndex = ParserBlend.getTypeIndex(raw.dna, type);
+		let typeIndex: i32 = ParserBlend.get_type_index(raw.dna, type);
 		if (typeIndex == -1) return null;
-		let ds = ParserBlend.getStruct(raw.dna, typeIndex);
+		let ds: DnaStruct = ParserBlend.get_struct(raw.dna, typeIndex);
 		let fields: string[] = [];
-		for (let i = 0; i < ds.fieldNames.length; ++i) {
-			let nameIndex = ds.fieldNames[i];
-			let typeIndex = ds.fieldTypes[i];
+		for (let i: i32 = 0; i < ds.field_names.length; ++i) {
+			let nameIndex: i32 = ds.field_names[i];
+			let typeIndex: i32 = ds.field_types[i];
 			fields.push(raw.dna.types[typeIndex] + " " + raw.dna.names[nameIndex]);
 		}
 		return fields;
@@ -54,13 +54,13 @@ class ParserBlend {
 	static get = (raw: BlendRaw, type: string): BlHandleRaw[] => {
 		if (raw.dna == null) return null;
 		// Return all structures of type
-		let typeIndex = ParserBlend.getTypeIndex(raw.dna, type);
+		let typeIndex: i32 = ParserBlend.get_type_index(raw.dna, type);
 		if (typeIndex == -1) return null;
-		let ds = ParserBlend.getStruct(raw.dna, typeIndex);
+		let ds: DnaStruct = ParserBlend.get_struct(raw.dna, typeIndex);
 		let handles: BlHandleRaw[] = [];
 		for (let b of raw.blocks) {
-			if (raw.dna.structs[b.sdnaIndex].type == typeIndex) {
-				let h = new BlHandleRaw();
+			if (raw.dna.structs[b.sdna_index].type == typeIndex) {
+				let h: BlHandleRaw = new BlHandleRaw();
 				handles.push(h);
 				h.block = b;
 				h.ds = ds;
@@ -69,50 +69,50 @@ class ParserBlend {
 		return handles;
 	}
 
-	static getStruct = (dna: Dna, typeIndex: i32): DnaStruct => {
+	static get_struct = (dna: Dna, typeIndex: i32): DnaStruct => {
 		for (let ds of dna.structs) if (ds.type == typeIndex) return ds;
 		return null;
 	}
 
-	static getTypeIndex = (dna: Dna, type: string): i32 => {
-		for (let i = 0; i < dna.types.length; ++i) if (type == dna.types[i]) return i;
+	static get_type_index = (dna: Dna, type: string): i32 => {
+		for (let i: i32 = 0; i < dna.types.length; ++i) if (type == dna.types[i]) return i;
 		return -1;
 	}
 
 	static parse = (raw: BlendRaw) => {
 		// Pointer size: _ 32bit, - 64bit
-		raw.pointerSize = ParserBlend.readChar(raw) == "_" ? 4 : 8;
+		raw.pointer_size = ParserBlend.read_char(raw) == "_" ? 4 : 8;
 
 		// v - little endian, V - big endian
-		raw.littleEndian = ParserBlend.readChar(raw) == "v";
+		raw.little_endian = ParserBlend.read_char(raw) == "v";
 
-		raw.version = ParserBlend.readChars(raw, 3);
+		raw.version = ParserBlend.read_chars(raw, 3);
 
 		// Reading file blocks
 		// Header - data
 		while (raw.pos < raw.view.byteLength) {
 			ParserBlend.align(raw);
-			let b = new Block();
+			let b: Block = new Block();
 
 			// Block type
-			b.code = ParserBlend.readChars(raw, 4);
+			b.code = ParserBlend.read_chars(raw, 4);
 			if (b.code == "ENDB") break;
 
 			raw.blocks.push(b);
 			b.blend = raw;
 
 			// Total block length
-			b.size = ParserBlend.read32(raw);
+			b.size = ParserBlend.read_i32(raw);
 
 			// Memory address
-			let addr = ParserBlend.readPointer(raw);
+			let addr: any = ParserBlend.read_pointer(raw);
 			if (!raw.map.has(addr)) raw.map.set(addr, b);
 
 			// Index of dna struct contained in this block
-			b.sdnaIndex = ParserBlend.read32(raw);
+			b.sdna_index = ParserBlend.read_i32(raw);
 
 			// Number of dna structs in this block
-			b.count = ParserBlend.read32(raw);
+			b.count = ParserBlend.read_i32(raw);
 
 			b.pos = raw.pos;
 
@@ -120,41 +120,41 @@ class ParserBlend {
 			if (b.code == "DNA1") {
 				raw.dna = new Dna();
 
-				let id = ParserBlend.readChars(raw, 4); // SDNA
-				let nameId = ParserBlend.readChars(raw, 4); // NAME
-				let namesCount = ParserBlend.read32(raw);
-				for (let i = 0; i < namesCount; ++i) {
-					raw.dna.names.push(ParserBlend.readString(raw));
+				ParserBlend.read_chars(raw, 4); // SDNA
+				ParserBlend.read_chars(raw, 4); // NAME
+				let namesCount: i32 = ParserBlend.read_i32(raw);
+				for (let i: i32 = 0; i < namesCount; ++i) {
+					raw.dna.names.push(ParserBlend.read_string(raw));
 				}
 				ParserBlend.align(raw);
 
-				let typeId = ParserBlend.readChars(raw, 4); // TYPE
-				let typesCount = ParserBlend.read32(raw);
-				for (let i = 0; i < typesCount; ++i) {
-					raw.dna.types.push(ParserBlend.readString(raw));
+				ParserBlend.read_chars(raw, 4); // TYPE
+				let typesCount: i32 = ParserBlend.read_i32(raw);
+				for (let i: i32 = 0; i < typesCount; ++i) {
+					raw.dna.types.push(ParserBlend.read_string(raw));
 				}
 				ParserBlend.align(raw);
 
-				let lenId = ParserBlend.readChars(raw, 4); // TLEN
-				for (let i = 0; i < typesCount; ++i) {
-					raw.dna.typesLength.push(ParserBlend.read16(raw));
+				ParserBlend.read_chars(raw, 4); // TLEN
+				for (let i: i32 = 0; i < typesCount; ++i) {
+					raw.dna.types_length.push(ParserBlend.read_i16(raw));
 				}
 				ParserBlend.align(raw);
 
-				let structId = ParserBlend.readChars(raw, 4); // STRC
-				let structCount = ParserBlend.read32(raw);
-				for (let i = 0; i < structCount; ++i) {
-					let ds = new DnaStruct();
+				ParserBlend.read_chars(raw, 4); // STRC
+				let structCount: i32 = ParserBlend.read_i32(raw);
+				for (let i: i32 = 0; i < structCount; ++i) {
+					let ds: DnaStruct = new DnaStruct();
 					raw.dna.structs.push(ds);
 					ds.dna = raw.dna;
-					ds.type = ParserBlend.read16(raw);
-					let fieldCount = ParserBlend.read16(raw);
+					ds.type = ParserBlend.read_i16(raw);
+					let fieldCount: i32 = ParserBlend.read_i16(raw);
 					if (fieldCount > 0) {
-						ds.fieldTypes = [];
-						ds.fieldNames = [];
-						for (let j = 0; j < fieldCount; ++j) {
-							ds.fieldTypes.push(ParserBlend.read16(raw));
-							ds.fieldNames.push(ParserBlend.read16(raw));
+						ds.field_types = [];
+						ds.field_names = [];
+						for (let j: i32 = 0; j < fieldCount; ++j) {
+							ds.field_types.push(ParserBlend.read_i16(raw));
+							ds.field_names.push(ParserBlend.read_i16(raw));
 						}
 					}
 				}
@@ -167,87 +167,87 @@ class ParserBlend {
 
 	static align = (raw: BlendRaw) => {
 		// 4 bytes aligned
-		let mod = raw.pos % 4;
+		let mod: i32 = raw.pos % 4;
 		if (mod > 0) raw.pos += 4 - mod;
 	}
 
-	static read8 = (raw: BlendRaw): i32 => {
-		let i = raw.view.getUint8(raw.pos);
+	static read_i8 = (raw: BlendRaw): i32 => {
+		let i: i32 = raw.view.getUint8(raw.pos);
 		raw.pos += 1;
 		return i;
 	}
 
-	static read16 = (raw: BlendRaw): i32 => {
-		let i = raw.view.getInt16(raw.pos, raw.littleEndian);
+	static read_i16 = (raw: BlendRaw): i32 => {
+		let i: i32 = raw.view.getInt16(raw.pos, raw.little_endian);
 		raw.pos += 2;
 		return i;
 	}
 
-	static read32 = (raw: BlendRaw): i32 => {
-		let i = raw.view.getInt32(raw.pos, raw.littleEndian);
+	static read_i32 = (raw: BlendRaw): i32 => {
+		let i: i32 = raw.view.getInt32(raw.pos, raw.little_endian);
 		raw.pos += 4;
 		return i;
 	}
 
-	static read64 = (raw: BlendRaw): any => {
+	static read_i64 = (raw: BlendRaw): any => {
 		let aview: any = raw.view;
-		let i = aview.getBigInt64(raw.pos, raw.littleEndian);
+		let i: i32 = aview.getBigInt64(raw.pos, raw.little_endian);
 		raw.pos += 8;
 		return i;
 	}
 
-	static readf32 = (raw: BlendRaw): f32 => {
-		let f = raw.view.getFloat32(raw.pos, raw.littleEndian);
+	static read_f32 = (raw: BlendRaw): f32 => {
+		let f: f32 = raw.view.getFloat32(raw.pos, raw.little_endian);
 		raw.pos += 4;
 		return f;
 	}
 
-	static read8array = (raw: BlendRaw, len: i32): Int32Array => {
-		let ar = new Int32Array(len);
-		for (let i = 0; i < len; ++i) ar[i] = ParserBlend.read8(raw);
+	static read_i8array = (raw: BlendRaw, len: i32): Int32Array => {
+		let ar: Int32Array = new Int32Array(len);
+		for (let i: i32 = 0; i < len; ++i) ar[i] = ParserBlend.read_i8(raw);
 		return ar;
 	}
 
-	static read16array = (raw: BlendRaw, len: i32): Int32Array => {
-		let ar = new Int32Array(len);
-		for (let i = 0; i < len; ++i) ar[i] = ParserBlend.read16(raw);
+	static read_i16array = (raw: BlendRaw, len: i32): Int32Array => {
+		let ar: Int32Array = new Int32Array(len);
+		for (let i: i32 = 0; i < len; ++i) ar[i] = ParserBlend.read_i16(raw);
 		return ar;
 	}
 
-	static read32array = (raw: BlendRaw, len: i32): Int32Array => {
-		let ar = new Int32Array(len);
-		for (let i = 0; i < len; ++i) ar[i] = ParserBlend.read32(raw);
+	static read_i32array = (raw: BlendRaw, len: i32): Int32Array => {
+		let ar: Int32Array = new Int32Array(len);
+		for (let i: i32 = 0; i < len; ++i) ar[i] = ParserBlend.read_i32(raw);
 		return ar;
 	}
 
-	static readf32array = (raw: BlendRaw, len: i32): Float32Array => {
-		let ar = new Float32Array(len);
-		for (let i = 0; i < len; ++i) ar[i] = ParserBlend.readf32(raw);
+	static read_f32array = (raw: BlendRaw, len: i32): Float32Array => {
+		let ar: Float32Array = new Float32Array(len);
+		for (let i: i32 = 0; i < len; ++i) ar[i] = ParserBlend.read_f32(raw);
 		return ar;
 	}
 
-	static readString = (raw: BlendRaw): string => {
-		let s = "";
+	static read_string = (raw: BlendRaw): string => {
+		let s: string = "";
 		while (true) {
-			let ch = ParserBlend.read8(raw);
+			let ch: i32 = ParserBlend.read_i8(raw);
 			if (ch == 0) break;
 			s += String.fromCharCode(ch);
 		}
 		return s;
 	}
 
-	static readChars = (raw: BlendRaw, len: i32): string => {
-		let s = "";
-		for (let i = 0; i < len; ++i) s += ParserBlend.readChar(raw);
+	static read_chars = (raw: BlendRaw, len: i32): string => {
+		let s: string = "";
+		for (let i: i32 = 0; i < len; ++i) s += ParserBlend.read_char(raw);
 		return s;
 	}
 
-	static readChar = (raw: BlendRaw): string => {
-		return String.fromCharCode(ParserBlend.read8(raw));
+	static read_char = (raw: BlendRaw): string => {
+		return String.fromCharCode(ParserBlend.read_i8(raw));
 	}
 
-	static readPointer = (raw: BlendRaw): any => {
-		return raw.pointerSize == 4 ? ParserBlend.read32(raw) : ParserBlend.read64(raw);
+	static read_pointer = (raw: BlendRaw): any => {
+		return raw.pointer_size == 4 ? ParserBlend.read_i32(raw) : ParserBlend.read_i64(raw);
 	}
 }
 
@@ -255,7 +255,7 @@ class Block {
 	blend: BlendRaw;
 	code: string;
 	size: i32;
-	sdnaIndex: i32;
+	sdna_index: i32;
 	count: i32;
 	pos: i32; // Byte pos of data start in blob
 }
@@ -263,15 +263,15 @@ class Block {
 class Dna {
 	names: string[] = [];
 	types: string[] = [];
-	typesLength: i32[] = [];
+	types_length: i32[] = [];
 	structs: DnaStruct[] = [];
 }
 
 class DnaStruct {
 	dna: Dna;
 	type: i32; // Index in dna.types
-	fieldTypes: i32[]; // Index in dna.types
-	fieldNames: i32[]; // Index in dna.names
+	field_types: i32[]; // Index in dna.types
+	field_names: i32[]; // Index in dna.names
 }
 
 class BlHandleRaw {
@@ -281,42 +281,42 @@ class BlHandleRaw {
 }
 
 class BlHandle {
-	static getSize = (raw: BlHandleRaw, index: i32): i32 => {
-		let nameIndex = raw.ds.fieldNames[index];
-		let typeIndex = raw.ds.fieldTypes[index];
-		let dna = raw.ds.dna;
-		let n = dna.names[nameIndex];
-		let size = 0;
-		if (n.indexOf("*") >= 0) size = raw.block.blend.pointerSize;
-		else size = dna.typesLength[typeIndex];
-		if (n.indexOf("[") > 0) size *= BlHandle.getArrayLen(n);
+	static get_size = (raw: BlHandleRaw, index: i32): i32 => {
+		let nameIndex: i32 = raw.ds.field_names[index];
+		let typeIndex: i32 = raw.ds.field_types[index];
+		let dna: Dna = raw.ds.dna;
+		let n: string = dna.names[nameIndex];
+		let size: i32 = 0;
+		if (n.indexOf("*") >= 0) size = raw.block.blend.pointer_size;
+		else size = dna.types_length[typeIndex];
+		if (n.indexOf("[") > 0) size *= BlHandle.get_array_len(n);
 		return size;
 	}
 
-	static baseName = (s: string): string => {
+	static base_name = (s: string): string => {
 		while (s.charAt(0) == "*") s = s.substring(1, s.length);
 		if (s.charAt(s.length - 1) == "]") s = s.substring(0, s.indexOf("["));
 		return s;
 	}
 
-	static getArrayLen = (s: string): i32 => {
+	static get_array_len = (s: string): i32 => {
 		return parseInt(s.substring(s.indexOf("[") + 1, s.indexOf("]")));
 	}
 
-	static get = (raw: BlHandleRaw, name: string, index = 0, asType: string = null, arrayLen = 0): any => {
+	static get = (raw: BlHandleRaw, name: string, index: i32 = 0, asType: string = null, arrayLen: i32 = 0): any => {
 		// Return raw type or structure
-		let dna = raw.ds.dna;
-		for (let i = 0; i < raw.ds.fieldNames.length; ++i) {
-			let nameIndex = raw.ds.fieldNames[i];
-			let dnaName = dna.names[nameIndex];
-			if (name == BlHandle.baseName(dnaName)) {
-				let typeIndex = raw.ds.fieldTypes[i];
-				let type = dna.types[typeIndex];
-				let newOffset = raw.offset;
-				for (let j = 0; j < i; ++j) newOffset += BlHandle.getSize(raw, j);
+		let dna: Dna = raw.ds.dna;
+		for (let i: i32 = 0; i < raw.ds.field_names.length; ++i) {
+			let nameIndex: i32 = raw.ds.field_names[i];
+			let dnaName: string = dna.names[nameIndex];
+			if (name == BlHandle.base_name(dnaName)) {
+				let typeIndex: i32 = raw.ds.field_types[i];
+				let type: string = dna.types[typeIndex];
+				let newOffset: i32 = raw.offset;
+				for (let j: i32 = 0; j < i; ++j) newOffset += BlHandle.get_size(raw, j);
 				// Cast void * to type
 				if (asType != null) {
-					for (let i = 0; i < dna.types.length; ++i) {
+					for (let i: i32 = 0; i < dna.types.length; ++i) {
 						if (dna.types[i] == asType) {
 							typeIndex = i;
 							break;
@@ -325,32 +325,32 @@ class BlHandle {
 				}
 				// Raw type
 				if (typeIndex < 12) {
-					let blend = raw.block.blend;
+					let blend: BlendRaw = raw.block.blend;
 					blend.pos = raw.block.pos + newOffset;
-					let isArray = dnaName.charAt(dnaName.length - 1) == "]";
-					let len = isArray ? (arrayLen > 0 ? arrayLen : this.getArrayLen(dnaName)) : 1;
+					let isArray: bool = dnaName.charAt(dnaName.length - 1) == "]";
+					let len: i32 = isArray ? (arrayLen > 0 ? arrayLen : this.get_array_len(dnaName)) : 1;
 					switch (type) {
-						case "int": return isArray ? ParserBlend.read32array(blend, len) : ParserBlend.read32(blend);
-						case "char": return isArray ? ParserBlend.readString(blend) : ParserBlend.read8(blend);
-						case "uchar": return isArray ? ParserBlend.read8array(blend, len) : ParserBlend.read8(blend);
-						case "short": return isArray ? ParserBlend.read16array(blend, len) : ParserBlend.read16(blend);
-						case "ushort": return isArray ? ParserBlend.read16array(blend, len) : ParserBlend.read16(blend);
-						case "float": return isArray ? ParserBlend.readf32array(blend, len) : ParserBlend.readf32(blend);
+						case "int": return isArray ? ParserBlend.read_i32array(blend, len) : ParserBlend.read_i32(blend);
+						case "char": return isArray ? ParserBlend.read_string(blend) : ParserBlend.read_i8(blend);
+						case "uchar": return isArray ? ParserBlend.read_i8array(blend, len) : ParserBlend.read_i8(blend);
+						case "short": return isArray ? ParserBlend.read_i16array(blend, len) : ParserBlend.read_i16(blend);
+						case "ushort": return isArray ? ParserBlend.read_i16array(blend, len) : ParserBlend.read_i16(blend);
+						case "float": return isArray ? ParserBlend.read_f32array(blend, len) : ParserBlend.read_f32(blend);
 						case "double": return 0; //ParserBlend.readf64(blend);
-						case "long": return isArray ? ParserBlend.read32array(blend, len) : ParserBlend.read32(blend);
-						case "ulong": return isArray ? ParserBlend.read32array(blend, len) : ParserBlend.read32(blend);
-						case "int64_t": return ParserBlend.read64(blend);
-						case "uint64_t": return ParserBlend.read64(blend);
-						case "void": if (dnaName.charAt(0) == "*") { return ParserBlend.read64(blend); };
+						case "long": return isArray ? ParserBlend.read_i32array(blend, len) : ParserBlend.read_i32(blend);
+						case "ulong": return isArray ? ParserBlend.read_i32array(blend, len) : ParserBlend.read_i32(blend);
+						case "int64_t": return ParserBlend.read_i64(blend);
+						case "uint64_t": return ParserBlend.read_i64(blend);
+						case "void": if (dnaName.charAt(0) == "*") { return ParserBlend.read_i64(blend); };
 					}
 				}
 				// Structure
-				let h = new BlHandleRaw();
-				h.ds = ParserBlend.getStruct(dna, typeIndex);
-				let isPointer = dnaName.charAt(0) == "*";
+				let h: BlHandleRaw = new BlHandleRaw();
+				h.ds = ParserBlend.get_struct(dna, typeIndex);
+				let isPointer: bool = dnaName.charAt(0) == "*";
 				if (isPointer) {
 					raw.block.blend.pos = raw.block.pos + newOffset;
-					let addr = ParserBlend.readPointer(raw.block.blend);
+					let addr: any = ParserBlend.read_pointer(raw.block.blend);
 					if (raw.block.blend.map.has(addr)) {
 						h.block = raw.block.blend.map.get(addr);
 					}
@@ -361,7 +361,7 @@ class BlHandle {
 					h.block = raw.block;
 					h.offset = newOffset;
 				}
-				h.offset += dna.typesLength[typeIndex] * index;
+				h.offset += dna.types_length[typeIndex] * index;
 				return h;
 			}
 		}

+ 37 - 37
base/Sources/ParserExr.ts

@@ -4,14 +4,14 @@
 
 class ParserExr {
 
-	static writeString = (out: i32[], str: string) => {
-		for (let i = 0; i < str.length; ++i) {
+	static write_string = (out: i32[], str: string) => {
+		for (let i: i32 = 0; i < str.length; ++i) {
 			out.push(str.charCodeAt(i));
 		}
 	}
 
-	static run = (width: i32, height: i32, src: ArrayBuffer, bits = 16, type = 1, off = 0): ArrayBuffer => {
-		let out = [];
+	static run = (width: i32, height: i32, src: ArrayBuffer, bits: i32 = 16, type: i32 = 1, off: i32 = 0): ArrayBuffer => {
+		let out: u8[] = [];
 		out.push(0x76); // magic
 		out.push(0x2f);
 		out.push(0x31);
@@ -20,9 +20,9 @@ class ParserExr {
 		out.push(0);
 		out.push(0);
 		out.push(0);
-		ParserExr.writeString(out, "channels");
+		ParserExr.write_string(out, "channels");
 		out.push(0);
-		ParserExr.writeString(out, "chlist");
+		ParserExr.write_string(out, "chlist");
 		out.push(0);
 
 		out.push(55);
@@ -30,7 +30,7 @@ class ParserExr {
 		out.push(0);
 		out.push(0);
 
-		let attrib = bits == 16 ? 1 : 2; // half, float
+		let attrib: i32 = bits == 16 ? 1 : 2; // half, float
 
 		out.push("B".charCodeAt(0)); // B
 		out.push(0);
@@ -103,9 +103,9 @@ class ParserExr {
 
 		out.push(0);
 
-		ParserExr.writeString(out, "compression");
+		ParserExr.write_string(out, "compression");
 		out.push(0);
-		ParserExr.writeString(out, "compression");
+		ParserExr.write_string(out, "compression");
 		out.push(0);
 
 		out.push(1);
@@ -114,9 +114,9 @@ class ParserExr {
 		out.push(0);
 		out.push(0); // no compression
 
-		ParserExr.writeString(out, "dataWindow");
+		ParserExr.write_string(out, "dataWindow");
 		out.push(0);
-		ParserExr.writeString(out, "box2i");
+		ParserExr.write_string(out, "box2i");
 		out.push(0);
 
 		out.push(16);
@@ -134,8 +134,8 @@ class ParserExr {
 		out.push(0);
 		out.push(0);
 
-		let ww = width - 1;
-		let hh = height - 1;
+		let ww: i32 = width - 1;
+		let hh: i32 = height - 1;
 
 		out.push(ww & 0xff);
 		out.push((ww >> 8) & 0xff);
@@ -147,9 +147,9 @@ class ParserExr {
 		out.push((hh >> 16) & 0xff);
 		out.push((hh >> 24) & 0xff);
 
-		ParserExr.writeString(out, "displayWindow");
+		ParserExr.write_string(out, "displayWindow");
 		out.push(0);
-		ParserExr.writeString(out, "box2i");
+		ParserExr.write_string(out, "box2i");
 		out.push(0);
 
 		out.push(16);
@@ -177,9 +177,9 @@ class ParserExr {
 		out.push((hh >> 16) & 0xff);
 		out.push((hh >> 24) & 0xff);
 
-		ParserExr.writeString(out, "lineOrder");
+		ParserExr.write_string(out, "lineOrder");
 		out.push(0);
-		ParserExr.writeString(out, "lineOrder");
+		ParserExr.write_string(out, "lineOrder");
 		out.push(0);
 
 		out.push(1);
@@ -188,9 +188,9 @@ class ParserExr {
 		out.push(0);
 		out.push(0); // increasing Y
 
-		ParserExr.writeString(out, "pixelAspectRatio");
+		ParserExr.write_string(out, "pixelAspectRatio");
 		out.push(0);
-		ParserExr.writeString(out, "float");
+		ParserExr.write_string(out, "float");
 		out.push(0);
 
 		out.push(4);
@@ -203,10 +203,10 @@ class ParserExr {
 		out.push(0x80);
 		out.push(0x3f);
 
-		ParserExr.writeString(out, "screenWindowCenter");
+		ParserExr.write_string(out, "screenWindowCenter");
 		out.push(0);
 
-		ParserExr.writeString(out, "v2f");
+		ParserExr.write_string(out, "v2f");
 		out.push(0);
 
 		out.push(8);
@@ -224,10 +224,10 @@ class ParserExr {
 		out.push(0);
 		out.push(0);
 
-		ParserExr.writeString(out, "screenWindowWidth");
+		ParserExr.write_string(out, "screenWindowWidth");
 		out.push(0);
 
-		ParserExr.writeString(out, "float");
+		ParserExr.write_string(out, "float");
 		out.push(0);
 
 		out.push(4);
@@ -242,16 +242,16 @@ class ParserExr {
 
 		out.push(0); // end of header
 
-		let channels = 4;
-		let byteSize = bits == 16 ? 2 : 4;
-		let kHeaderSize = out.length;
-		let kScanlineTableSize = 8 * height;
-		let pixelRowSize = width * 3 * byteSize;
-		let fullRowSize = pixelRowSize + 8;
+		let channels: i32 = 4;
+		let byteSize: i32 = bits == 16 ? 2 : 4;
+		let kHeaderSize: i32 = out.length;
+		let kScanlineTableSize: i32 = 8 * height;
+		let pixelRowSize: i32 = width * 3 * byteSize;
+		let fullRowSize: i32 = pixelRowSize + 8;
 
 		// line offset table
-		let ofs = kHeaderSize + kScanlineTableSize;
-		for (let y = 0; y < height; ++y) {
+		let ofs: i32 = kHeaderSize + kScanlineTableSize;
+		for (let y: i32 = 0; y < height; ++y) {
 			out.push(ofs & 0xff);
 			out.push((ofs >> 8) & 0xff);
 			out.push((ofs >> 16) & 0xff);
@@ -264,12 +264,12 @@ class ParserExr {
 		}
 
 		// scanline data
-		let stride = channels * byteSize;
-		let pos = 0;
-		let srcView = new DataView(src);
+		let stride: i32 = channels * byteSize;
+		let pos: i32 = 0;
+		let srcView: DataView = new DataView(src);
 
 		let writeLine16 = (bytePos: i32) => {
-			for (let x = 0; x < width; ++x) {
+			for (let x: i32 = 0; x < width; ++x) {
 				out.push(srcView.getUint8(bytePos    ));
 				out.push(srcView.getUint8(bytePos + 1));
 				bytePos += stride;
@@ -277,7 +277,7 @@ class ParserExr {
 		}
 
 		let writeLine32 = (bytePos: i32) => {
-			for (let x = 0; x < width; ++x) {
+			for (let x: i32 = 0; x < width; ++x) {
 				out.push(srcView.getUint8(bytePos    ));
 				out.push(srcView.getUint8(bytePos + 1));
 				out.push(srcView.getUint8(bytePos + 2));
@@ -302,7 +302,7 @@ class ParserExr {
 
 		let writeData = type == 1 ? writeBGR : writeSingle;
 
-		for (let y = 0; y < height; ++y) {
+		for (let y: i32 = 0; y < height; ++y) {
 			// coordinate
 			out.push(y & 0xff);
 			out.push((y >> 8) & 0xff);

+ 40 - 41
base/Sources/ParserLogic.ts

@@ -1,7 +1,7 @@
 
 class ParserLogic {
 
-	static customNodes = new Map();
+	static customNodes: Map<any, any> = new Map();
 	static nodes: zui_node_t[];
 	static links: zui_node_link_t[];
 
@@ -10,28 +10,28 @@ class ParserLogic {
 	static nodeMap: Map<string, LogicNode>;
 	static rawMap: Map<LogicNode, zui_node_t>;
 
-	static getLogicNode = (node: zui_node_t): LogicNode => {
+	static get_logic_node = (node: zui_node_t): LogicNode => {
 		return ParserLogic.nodeMap.get(ParserLogic.node_name(node));
 	}
 
-	static getRawNode = (node: LogicNode): zui_node_t => {
+	static get_raw_node = (node: LogicNode): zui_node_t => {
 		return ParserLogic.rawMap.get(node);
 	}
 
-	static getNode = (id: i32): zui_node_t => {
+	static get_node = (id: i32): zui_node_t => {
 		for (let n of ParserLogic.nodes) if (n.id == id) return n;
 		return null;
 	}
 
-	static getLink = (id: i32): zui_node_link_t => {
+	static get_link = (id: i32): zui_node_link_t => {
 		for (let l of ParserLogic.links) if (l.id == id) return l;
 		return null;
 	}
 
-	static getInputLink = (inp: zui_node_socket_t): zui_node_link_t => {
+	static get_input_link = (inp: zui_node_socket_t): zui_node_link_t => {
 		for (let l of ParserLogic.links) {
 			if (l.to_id == inp.node_id) {
-				let node = ParserLogic.getNode(inp.node_id);
+				let node: zui_node_t = ParserLogic.get_node(inp.node_id);
 				if (node.inputs.length <= l.to_socket) return null;
 				if (node.inputs[l.to_socket] == inp) return l;
 			}
@@ -39,11 +39,11 @@ class ParserLogic {
 		return null;
 	}
 
-	static getOutputLinks = (out: zui_node_socket_t): zui_node_link_t[] => {
+	static get_output_links = (out: zui_node_socket_t): zui_node_link_t[] => {
 		let res: zui_node_link_t[] = [];
 		for (let l of ParserLogic.links) {
 			if (l.from_id == out.node_id) {
-				let node = ParserLogic.getNode(out.node_id);
+				let node: zui_node_t = ParserLogic.get_node(out.node_id);
 				if (node.outputs.length <= l.from_socket) continue;
 				if (node.outputs[l.from_socket] == out) res.push(l);
 			}
@@ -56,7 +56,7 @@ class ParserLogic {
 	}
 
 	static node_name = (node: zui_node_t): string => {
-		let s = ParserLogic.safe_src(node.name) + node.id;
+		let s: string = ParserLogic.safe_src(node.name) + node.id;
 		return s;
 	}
 
@@ -68,14 +68,14 @@ class ParserLogic {
 		ParserLogic.parsed_labels = new Map();
 		ParserLogic.nodeMap = new Map();
 		ParserLogic.rawMap = new Map();
-		let root_nodes = ParserLogic.get_root_nodes(canvas);
+		let root_nodes: zui_node_t[] = ParserLogic.get_root_nodes(canvas);
 
 		for (let node of root_nodes) ParserLogic.build_node(node);
 	}
 
 	static build_node = (node: zui_node_t): string => {
 		// Get node name
-		let name = ParserLogic.node_name(node);
+		let name: string = ParserLogic.node_name(node);
 
 		// Check if node already exists
 		if (ParserLogic.parsed_nodes.indexOf(name) != -1) {
@@ -85,16 +85,16 @@ class ParserLogic {
 		ParserLogic.parsed_nodes.push(name);
 
 		// Create node
-		let v = ParserLogic.createClassInstance(node.type, []);
+		let v: any = ParserLogic.create_class_instance(node.type, []);
 		ParserLogic.nodeMap.set(name, v);
 		ParserLogic.rawMap.set(v, node);
 
 		// Expose button values in node class
 		for (let b of node.buttons) {
 			if (b.type == "ENUM") {
-				// let arrayData = Array.isArray(b.data);
-				let arrayData = b.data.length > 1;
-				let texts = arrayData ? b.data : zui_enum_texts_js(node.type);
+				// let arrayData: bool = Array.isArray(b.data);
+				let arrayData: bool = b.data.length > 1;
+				let texts: string[] = arrayData ? b.data : zui_enum_texts_js(node.type);
 				v[b.name] = texts[b.default_value];
 			}
 			else {
@@ -104,13 +104,13 @@ class ParserLogic {
 
 		// Create inputs
 		let inp_node: LogicNode = null;
-		let inp_from = 0;
-		for (let i = 0; i < node.inputs.length; ++i) {
-			let inp = node.inputs[i];
+		let inp_from: i32 = 0;
+		for (let i: i32 = 0; i < node.inputs.length; ++i) {
+			let inp: zui_node_socket_t = node.inputs[i];
 			// Is linked - find node
-			let l = ParserLogic.getInputLink(inp);
+			let l: zui_node_link_t = ParserLogic.get_input_link(inp);
 			if (l != null) {
-				inp_node = ParserLogic.nodeMap.get(ParserLogic.build_node(ParserLogic.getNode(l.from_id)));
+				inp_node = ParserLogic.nodeMap.get(ParserLogic.build_node(ParserLogic.get_node(l.from_id)));
 				inp_from = l.from_socket;
 			}
 			// Not linked - create node with default values
@@ -119,17 +119,17 @@ class ParserLogic {
 				inp_from = 0;
 			}
 			// Add input
-			v.addInput(inp_node, inp_from);
+			v.add_input(inp_node, inp_from);
 		}
 
 		// Create outputss
 		for (let out of node.outputs) {
-			let outNodes:LogicNode[] = [];
-			let ls = ParserLogic.getOutputLinks(out);
+			let outNodes: LogicNode[] = [];
+			let ls: zui_node_link_t[] = ParserLogic.get_output_links(out);
 			if (ls != null && ls.length > 0) {
 				for (let l of ls) {
-					let n = ParserLogic.getNode(l.to_id);
-					let out_name = ParserLogic.build_node(n);
+					let n: zui_node_t = ParserLogic.get_node(l.to_id);
+					let out_name: string = ParserLogic.build_node(n);
 					outNodes.push(ParserLogic.nodeMap.get(out_name));
 				}
 			}
@@ -138,7 +138,7 @@ class ParserLogic {
 				outNodes.push(ParserLogic.build_default_node(out));
 			}
 			// Add outputs
-			v.addOutputs(outNodes);
+			v.add_outputs(outNodes);
 		}
 
 		return name;
@@ -147,9 +147,9 @@ class ParserLogic {
 	static get_root_nodes = (node_group: zui_node_canvas_t): zui_node_t[] => {
 		let roots: zui_node_t[] = [];
 		for (let node of node_group.nodes) {
-			let linked = false;
+			let linked: bool = false;
 			for (let out of node.outputs) {
-				let ls = ParserLogic.getOutputLinks(out);
+				let ls: zui_node_link_t[] = ParserLogic.get_output_links(out);
 				if (ls != null && ls.length > 0) {
 					linked = true;
 					break;
@@ -163,46 +163,45 @@ class ParserLogic {
 	}
 
 	static build_default_node = (inp: zui_node_socket_t): LogicNode => {
-
 		let v: LogicNode = null;
 
 		if (inp.type == "VECTOR") {
 			if (inp.default_value == null) inp.default_value = [0, 0, 0]; // TODO
-			v = ParserLogic.createClassInstance("VectorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
+			v = ParserLogic.create_class_instance("VectorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
 		}
 		else if (inp.type == "RGBA") {
 			if (inp.default_value == null) inp.default_value = [0, 0, 0, 0]; // TODO
-			v = ParserLogic.createClassInstance("ColorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
+			v = ParserLogic.create_class_instance("ColorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
 		}
 		else if (inp.type == "RGB") {
 			if (inp.default_value == null) inp.default_value = [0, 0, 0, 0]; // TODO
-			v = ParserLogic.createClassInstance("ColorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
+			v = ParserLogic.create_class_instance("ColorNode", [inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
 		}
 		else if (inp.type == "VALUE") {
-			v = ParserLogic.createClassInstance("FloatNode", [inp.default_value]);
+			v = ParserLogic.create_class_instance("FloatNode", [inp.default_value]);
 		}
 		else if (inp.type == "INT") {
-			v = ParserLogic.createClassInstance("IntegerNode", [inp.default_value]);
+			v = ParserLogic.create_class_instance("IntegerNode", [inp.default_value]);
 		}
 		else if (inp.type == "BOOLEAN") {
-			v = ParserLogic.createClassInstance("BooleanNode", [inp.default_value]);
+			v = ParserLogic.create_class_instance("BooleanNode", [inp.default_value]);
 		}
 		else if (inp.type == "STRING") {
-			v = ParserLogic.createClassInstance("StringNode", [inp.default_value]);
+			v = ParserLogic.create_class_instance("StringNode", [inp.default_value]);
 		}
 		else {
-			v = ParserLogic.createClassInstance("NullNode", []);
+			v = ParserLogic.create_class_instance("NullNode", []);
 		}
 		return v;
 	}
 
-	static createClassInstance = (className: string, args: any[]): any => {
+	static create_class_instance = (className: string, args: any[]): any => {
 		if (ParserLogic.customNodes.get(className) != null) {
-			let node = new LogicNode();
+			let node: LogicNode = new LogicNode();
 			node.get = (from: i32) => { return ParserLogic.customNodes.get(className)(node, from); }
 			return node;
 		}
-		let dynamic_class = eval(`${className}`);
+		let dynamic_class: any = eval(`${className}`);
 		return new dynamic_class(args);
 	}
 }

文件差异内容过多而无法显示
+ 258 - 255
base/Sources/ParserMaterial.ts


+ 63 - 63
base/Sources/Path.ts

@@ -9,43 +9,43 @@ class Path {
 		///end
 	}
 
-	static meshFormats = ["obj", "blend"];
-	static textureFormats = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"];
+	static mesh_formats: string[] = ["obj", "blend"];
+	static texture_formats: string[] = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"];
 
-	static meshImporters = new Map<string, (s: string, f: (a: any)=>void)=>void>();
-	static textureImporters = new Map<string, (s: string, f: (img: image_t)=>void)=>void>();
+	static mesh_importers: Map<string, (s: string, f: (a: any)=>void)=>void> = new Map();
+	static texture_importers: Map<string, (s: string, f: (img: image_t)=>void)=>void> = new Map();
 
-	static baseColorExt = ["albedo", "alb", "basecol", "basecolor", "diffuse", "diff", "base", "bc", "d", "color", "col"];
-	static opacityExt = ["opac", "opacity", "alpha"];
-	static normalMapExt = ["normal", "nor", "n", "nrm", "normalgl"];
-	static occlusionExt = ["ao", "occlusion", "ambientOcclusion", "o", "occ"];
-	static roughnessExt = ["roughness", "rough", "r", "rgh"];
-	static metallicExt = ["metallic", "metal", "metalness", "m", "met"];
-	static displacementExt = ["displacement", "height", "h", "disp"];
+	static base_color_ext: string[] = ["albedo", "alb", "basecol", "basecolor", "diffuse", "diff", "base", "bc", "d", "color", "col"];
+	static opacity_ext: string[] = ["opac", "opacity", "alpha"];
+	static normal_map_ext: string[] = ["normal", "nor", "n", "nrm", "normalgl"];
+	static occlusion_ext: string[] = ["ao", "occlusion", "ambientOcclusion", "o", "occ"];
+	static roughness_ext: string[] = ["roughness", "rough", "r", "rgh"];
+	static metallic_ext: string[] = ["metallic", "metal", "metalness", "m", "met"];
+	static displacement_ext: string[] = ["displacement", "height", "h", "disp"];
 
-	static workingDirCache: string = null;
+	static working_dir_cache: string = null;
 
 	static data = (): string => {
 		return krom_get_files_location() + Path.sep + data_path();
 	}
 
-	static toRelative = (from: string, to: string): string => {
-		let a = from.split(Path.sep);
-		let b = to.split(Path.sep);
+	static to_relative = (from: string, to: string): string => {
+		let a: string[] = from.split(Path.sep);
+		let b: string[] = to.split(Path.sep);
 		while (a[0] == b[0]) {
 			a.shift();
 			b.shift();
 			if (a.length == 0 || b.length == 0) break;
 		}
-		let base = "";
-		for (let i = 0; i < a.length - 1; ++i) base += ".." + Path.sep;
+		let base: string = "";
+		for (let i: i32 = 0; i < a.length - 1; ++i) base += ".." + Path.sep;
 		base += b.join(Path.sep);
 		return base;
 	}
 
 	static normalize = (path: string): string => {
-		let ar = path.split(Path.sep);
-		let i = 0;
+		let ar: string[] = path.split(Path.sep);
+		let i: i32 = 0;
 		while (i < ar.length) {
 			if (i > 0 && ar[i] == ".." && ar[i - 1] != "..") {
 				ar.splice(i - 1, 2);
@@ -56,7 +56,7 @@ class Path {
 		return ar.join(Path.sep);
 	}
 
-	static baseDir = (path: string): string => {
+	static base_dir = (path: string): string => {
 		return path.substr(0, path.lastIndexOf(Path.sep) + 1);
 	}
 
@@ -68,65 +68,65 @@ class Path {
 		///end
 	}
 
-	static workingDir = (): string => {
-		if (Path.workingDirCache == null) {
-			let cmd = Path.pwd;
-			let save = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "working_dir.txt";
+	static working_dir = (): string => {
+		if (Path.working_dir_cache == null) {
+			let cmd: string = Path.pwd;
+			let save: string = (Path.is_protected() ? krom_save_path() : Path.data() + Path.sep) + "working_dir.txt";
 			krom_sys_command(cmd + ' > "' + save + '"');
-			Path.workingDirCache = trim_end(sys_buffer_to_string(krom_load_blob(save)));
+			Path.working_dir_cache = trim_end(sys_buffer_to_string(krom_load_blob(save)));
 		}
-		return Path.workingDirCache;
+		return Path.working_dir_cache;
 	}
 
-	static isMesh = (path: string): bool => {
-		let p = path.toLowerCase();
-		for (let s of Path.meshFormats) if (p.endsWith("." + s)) return true;
+	static is_mesh = (path: string): bool => {
+		let p: string = path.toLowerCase();
+		for (let s of Path.mesh_formats) if (p.endsWith("." + s)) return true;
 		return false;
 	}
 
-	static isTexture = (path: string): bool => {
-		let p = path.toLowerCase();
-		for (let s of Path.textureFormats) if (p.endsWith("." + s)) return true;
+	static is_texture = (path: string): bool => {
+		let p: string = path.toLowerCase();
+		for (let s of Path.texture_formats) if (p.endsWith("." + s)) return true;
 		return false;
 	}
 
-	static isFont = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_font = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".ttf") ||
 				p.endsWith(".ttc") ||
 				p.endsWith(".otf");
 	}
 
-	static isProject = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_project = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".arm");
 	}
 
-	static isPlugin = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_plugin = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".js");
 	}
 
-	static isJson = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_json = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".json");
 	}
 
-	static isText = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_text = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".txt");
 	}
 
-	static isGimpColorPalette = (path: string): bool => {
-		let p = path.toLowerCase();
+	static is_gimp_color_palette = (path: string): bool => {
+		let p: string = path.toLowerCase();
 		return p.endsWith(".gpl");
 	}
 
-	static isKnown = (path: string): bool => {
-		return Path.isMesh(path) || Path.isTexture(path) || Path.isFont(path) || Path.isProject(path) || Path.isPlugin(path) || Path.isText(path) || Path.isGimpColorPalette(path);
+	static is_known = (path: string): bool => {
+		return Path.is_mesh(path) || Path.is_texture(path) || Path.is_font(path) || Path.is_project(path) || Path.is_plugin(path) || Path.is_text(path) || Path.is_gimp_color_palette(path);
 	}
 
-	static checkExt = (p: string, exts: string[]): bool => {
+	static check_ext = (p: string, exts: string[]): bool => {
 		p = string_replace_all(p, "-", "_");
 		for (let ext of exts) {
 			if (p.endsWith("_" + ext) ||
@@ -137,33 +137,33 @@ class Path {
 		return false;
 	}
 
-	static isBaseColorTex = (p: string): bool => {
-		return Path.checkExt(p, Path.baseColorExt);
+	static is_base_color_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.base_color_ext);
 	}
-	static isOpacityTex = (p: string): bool => {
-		return Path.checkExt(p, Path.opacityExt);
+	static is_opacity_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.opacity_ext);
 	}
-	static isNormalMapTex = (p: string): bool => {
-		return Path.checkExt(p, Path.normalMapExt);
+	static is_normal_map_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.normal_map_ext);
 	}
-	static isOcclusionTex = (p: string): bool => {
-		return Path.checkExt(p, Path.occlusionExt);
+	static is_occlusion_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.occlusion_ext);
 	}
-	static isRoughnessTex = (p: string): bool => {
-		return Path.checkExt(p, Path.roughnessExt);
+	static is_roughness_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.roughness_ext);
 	}
-	static isMetallicTex = (p: string): bool => {
-		return Path.checkExt(p, Path.metallicExt);
+	static is_metallic_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.metallic_ext);
 	}
-	static isDisplacementTex = (p: string): bool => {
-		return Path.checkExt(p, Path.displacementExt);
+	static is_displacement_tex = (p: string): bool => {
+		return Path.check_ext(p, Path.displacement_ext);
 	}
 
-	static isFolder = (p: string): bool => {
+	static is_folder = (p: string): bool => {
 		return string_replace_all(p, "\\", "/").split("/").pop().indexOf(".") == -1;
 	}
 
-	static isProtected = (): bool => {
+	static is_protected = (): bool => {
 		///if krom_windows
 		return krom_get_files_location().indexOf("Program Files") >= 0;
 		///elseif krom_android

+ 163 - 169
base/Sources/PhysicsBody.ts

@@ -2,7 +2,7 @@
 ///if arm_physics
 
 class PhysicsBodyRaw {
-	_mass = 0.0;
+	_mass: f32 = 0.0;
 
 	get mass(): f32 {
 		return this._mass;
@@ -11,7 +11,7 @@ class PhysicsBodyRaw {
 	set mass(f: f32) {
 		if (this.ready) {
 			// remove();
-			let t = new PhysicsBodyRaw();
+			let t: PhysicsBodyRaw = new PhysicsBodyRaw();
 			t._mass = f;
 			PhysicsBody.init(t, this.object);
 			(this.object as any).physicsBody = t;
@@ -20,53 +20,53 @@ class PhysicsBodyRaw {
 	}
 
 	object: object_t;
-	friction = 0.5;
-	restitution = 0.0;
-	collisionMargin = 0.0;
-	linearDamping = 0.04;
-	angularDamping = 0.1;
-	linearFactors = [1.0, 1.0, 1.0];
-	angularFactors = [1.0, 1.0, 1.0];
-	linearThreshold = 0.0;
-	angularThreshold = 0.0;
-	ccd = false; // Continuous collision detection
-	trigger = false;
-	group = 1;
-	mask = 1;
-	shape = ShapeType.ShapeBox;
-	destroyed = false;
-	bodyScaleX: f32; // Transform scale at creation time
-	bodyScaleY: f32;
-	bodyScaleZ: f32;
-	currentScaleX: f32;
-	currentScaleY: f32;
-	currentScaleZ: f32;
+	friction: f32 = 0.5;
+	restitution: f32 = 0.0;
+	collision_margin: f32 = 0.0;
+	linear_damping: f32 = 0.04;
+	angular_damping: f32 = 0.1;
+	linear_factors: f32[] = [1.0, 1.0, 1.0];
+	angular_factors: f32[] = [1.0, 1.0, 1.0];
+	linear_threshold: f32 = 0.0;
+	angular_threshold: f32 = 0.0;
+	ccd: bool = false; // Continuous collision detection
+	trigger: bool = false;
+	group: i32 = 1;
+	mask: i32 = 1;
+	shape: shape_type_t = shape_type_t.BOX;
+	destroyed: bool = false;
+	body_scale_x: f32; // Transform scale at creation time
+	body_scale_y: f32;
+	body_scale_z: f32;
+	current_scale_x: f32;
+	current_scale_y: f32;
+	current_scale_z: f32;
 
 	body: Ammo.btRigidBody = null;
-	motionState: Ammo.btMotionState;
+	motion_state: Ammo.btMotionState;
 	btshape: Ammo.btCollisionShape;
-	ready = false;
-	id = 0;
-	heightData: Uint8Array = null;
+	ready: bool = false;
+	id: i32 = 0;
+	height_data: Uint8Array = null;
 }
 
 class PhysicsBody {
 
-	static nextId = 0;
-	static ammoArray: i32 = -1;
-	static gimpactRegistered = false;
-	static first = true;
+	static next_id: i32 = 0;
+	static ammo_array: i32 = -1;
+	static gimpact_registered: bool = false;
+	static first: bool = true;
 	static vec1: Ammo.btVector3;
 	static vec2: Ammo.btVector3;
 	static vec3: Ammo.btVector3;
 	static quat1: Ammo.btQuaternion;
 	static trans1: Ammo.btTransform;
 	static trans2: Ammo.btTransform;
-	static quat = quat_create();
+	static quat: quat_t = quat_create();
 
-	static convexHullCache = new Map<mesh_data_t, Ammo.btConvexHullShape>();
-	static triangleMeshCache = new Map<mesh_data_t, Ammo.btTriangleMesh>();
-	static usersCache = new Map<mesh_data_t, i32>();
+	static convex_hull_cache: Map<mesh_data_t, Ammo.btConvexHullShape> = new Map();
+	static triangle_mesh_cache: Map<mesh_data_t, Ammo.btTriangleMesh> = new Map();
+	static users_cache: Map<mesh_data_t, i32> = new Map();
 
 	static create(): PhysicsBodyRaw {
 		if (PhysicsBody.first) {
@@ -78,12 +78,12 @@ class PhysicsBody {
 			PhysicsBody.trans1 = new Ammo.btTransform();
 			PhysicsBody.trans2 = new Ammo.btTransform();
 		}
-		let pb = new PhysicsBodyRaw();
+		let pb: PhysicsBodyRaw = new PhysicsBodyRaw();
 		return pb;
 	}
 
-	static withMargin = (pb: PhysicsBodyRaw, f: f32) => {
-		return f - f * pb.collisionMargin;
+	static with_margin = (pb: PhysicsBodyRaw, f: f32) => {
+		return f - f * pb.collision_margin;
 	}
 
 	static init = (pb: PhysicsBodyRaw, o: object_t) => {
@@ -96,77 +96,77 @@ class PhysicsBody {
 		if (pb.object.ext_type != "mesh_object_t") {
 			return; // No mesh data
 		}
-		let transform = o.transform;
-		let physics = PhysicsWorld.active;
+		let transform: transform_t = o.transform;
+		let physics: PhysicsWorldRaw = PhysicsWorld.active;
 
-		if (pb.shape == ShapeType.ShapeBox) {
-			PhysicsWorld.vec1.setX(PhysicsBody.withMargin(pb, transform.dim.x / 2));
-			PhysicsWorld.vec1.setY(PhysicsBody.withMargin(pb, transform.dim.y / 2));
-			PhysicsWorld.vec1.setZ(PhysicsBody.withMargin(pb, transform.dim.z / 2));
+		if (pb.shape == shape_type_t.BOX) {
+			PhysicsWorld.vec1.setX(PhysicsBody.with_margin(pb, transform.dim.x / 2));
+			PhysicsWorld.vec1.setY(PhysicsBody.with_margin(pb, transform.dim.y / 2));
+			PhysicsWorld.vec1.setZ(PhysicsBody.with_margin(pb, transform.dim.z / 2));
 			pb.btshape = new Ammo.btBoxShape(PhysicsWorld.vec1);
 		}
-		else if (pb.shape == ShapeType.ShapeSphere) {
-			pb.btshape = new Ammo.btSphereShape(PhysicsBody.withMargin(pb, transform.dim.x / 2));
+		else if (pb.shape == shape_type_t.SPHERE) {
+			pb.btshape = new Ammo.btSphereShape(PhysicsBody.with_margin(pb, transform.dim.x / 2));
 		}
-		else if (pb.shape == ShapeType.ShapeConvexHull) {
-			let shapeConvex = PhysicsBody.fillConvexHull(pb, transform.scale, pb.collisionMargin);
+		else if (pb.shape == shape_type_t.CONVEX_HULL) {
+			let shapeConvex: Ammo.btConvexHullShape = PhysicsBody.fill_convex_hull(pb, transform.scale, pb.collision_margin);
 			pb.btshape = shapeConvex;
 		}
-		else if (pb.shape == ShapeType.ShapeCone) {
-			let coneZ = new Ammo.btConeShapeZ(
-				PhysicsBody.withMargin(pb, transform.dim.x / 2), // Radius
-				PhysicsBody.withMargin(pb, transform.dim.z));	 // Height
+		else if (pb.shape == shape_type_t.CONE) {
+			let coneZ: Ammo.btConeShapeZ = new Ammo.btConeShapeZ(
+				PhysicsBody.with_margin(pb, transform.dim.x / 2), // Radius
+				PhysicsBody.with_margin(pb, transform.dim.z));	 // Height
 			let cone: Ammo.btConeShape = coneZ;
 			pb.btshape = cone;
 		}
-		else if (pb.shape == ShapeType.ShapeCylinder) {
-			PhysicsWorld.vec1.setX(PhysicsBody.withMargin(pb, transform.dim.x / 2));
-			PhysicsWorld.vec1.setY(PhysicsBody.withMargin(pb, transform.dim.y / 2));
-			PhysicsWorld.vec1.setZ(PhysicsBody.withMargin(pb, transform.dim.z / 2));
-			let cylZ = new Ammo.btCylinderShapeZ(PhysicsWorld.vec1);
+		else if (pb.shape == shape_type_t.CYLINDER) {
+			PhysicsWorld.vec1.setX(PhysicsBody.with_margin(pb, transform.dim.x / 2));
+			PhysicsWorld.vec1.setY(PhysicsBody.with_margin(pb, transform.dim.y / 2));
+			PhysicsWorld.vec1.setZ(PhysicsBody.with_margin(pb, transform.dim.z / 2));
+			let cylZ: Ammo.btCylinderShapeZ = new Ammo.btCylinderShapeZ(PhysicsWorld.vec1);
 			let cyl: Ammo.btCylinderShape = cylZ;
 			pb.btshape = cyl;
 		}
-		else if (pb.shape == ShapeType.ShapeCapsule) {
-			let r = transform.dim.x / 2;
-			let capsZ = new Ammo.btCapsuleShapeZ(
-				PhysicsBody.withMargin(pb, r), // Radius
-				PhysicsBody.withMargin(pb, transform.dim.z - r * 2)); // Distance between 2 sphere centers
+		else if (pb.shape == shape_type_t.CAPSULE) {
+			let r: f32 = transform.dim.x / 2;
+			let capsZ: Ammo.btCapsuleShapeZ = new Ammo.btCapsuleShapeZ(
+				PhysicsBody.with_margin(pb, r), // Radius
+				PhysicsBody.with_margin(pb, transform.dim.z - r * 2)); // Distance between 2 sphere centers
 			let caps: Ammo.btCapsuleShape = capsZ;
 			pb.btshape = caps;
 		}
-		else if (pb.shape == ShapeType.ShapeMesh) {
-			let meshInterface = PhysicsBody.fillTriangleMesh(pb, transform.scale);
+		else if (pb.shape == shape_type_t.MESH) {
+			let meshInterface: Ammo.btTriangleMesh = PhysicsBody.fill_triangle_mesh(pb, transform.scale);
 			if (pb.mass > 0) {
-				let shapeGImpact = new Ammo.btGImpactMeshShape(meshInterface);
+				let shapeGImpact: Ammo.btGImpactMeshShape = new Ammo.btGImpactMeshShape(meshInterface);
 				shapeGImpact.updateBound();
 				let shapeConcave: Ammo.btConcaveShape = shapeGImpact;
 				pb.btshape = shapeConcave;
-				if (!PhysicsBody.gimpactRegistered) {
-					PhysicsBody.gimpactRegistered = true;
+				if (!PhysicsBody.gimpact_registered) {
+					PhysicsBody.gimpact_registered = true;
 					new Ammo.GImpactCollisionAlgorithm().registerAlgorithm(physics.dispatcher);
 				}
 			}
 			else {
-				let shapeBvh = new Ammo.btBvhTriangleMeshShape(meshInterface, true, true);
+				let shapeBvh: Ammo.btBvhTriangleMeshShape = new Ammo.btBvhTriangleMeshShape(meshInterface, true, true);
 				let shapeTri: Ammo.btTriangleMeshShape = shapeBvh;
 				let shapeConcave: Ammo.btConcaveShape = shapeTri;
 				pb.btshape = shapeConcave;
 			}
 		}
-		else if (pb.shape == ShapeType.ShapeTerrain) {
-			let length = pb.heightData.length;
-			if (PhysicsBody.ammoArray == -1) {
-				PhysicsBody.ammoArray = Ammo._malloc(length);
+		else if (pb.shape == shape_type_t.TERRAIN) {
+			let length: i32 = pb.height_data.length;
+			if (PhysicsBody.ammo_array == -1) {
+				PhysicsBody.ammo_array = Ammo._malloc(length);
 			}
 			// From texture bytes
-			for (let i = 0; i < length; ++i) {
-				Ammo.HEAPU8[PhysicsBody.ammoArray + i] = pb.heightData[i];
+			for (let i: i32 = 0; i < length; ++i) {
+				Ammo.HEAPU8[PhysicsBody.ammo_array + i] = pb.height_data[i];
 			}
-			let slice = Math.floor(Math.sqrt(length)); // Assuming square terrain data
-			let axis = 2; // z
-			let dataType = 5; // u8
-			pb.btshape = new Ammo.btHeightfieldTerrainShape(slice, slice, PhysicsBody.ammoArray, 1 / 255, 0, 1, axis, dataType, false);
+			let slice: i32 = Math.floor(Math.sqrt(length)); // Assuming square terrain data
+			let axis: i32 = 2; // z
+			let dataType: i32 = 5; // u8
+			pb.btshape = new Ammo.btHeightfieldTerrainShape(slice, slice, PhysicsBody.ammo_array, 1 / 255, 0, 1, axis, dataType, false);
 			PhysicsBody.vec1.setX(transform.dim.x / slice);
 			PhysicsBody.vec1.setY(transform.dim.y / slice);
 			PhysicsBody.vec1.setZ(transform.dim.z);
@@ -182,68 +182,68 @@ class PhysicsBody {
 		PhysicsBody.quat1.setValue(PhysicsBody.quat.x, PhysicsBody.quat.y, PhysicsBody.quat.z, PhysicsBody.quat.w);
 		PhysicsBody.trans1.setRotation(PhysicsBody.quat1);
 		PhysicsBody.trans2.setIdentity();
-		pb.motionState = new Ammo.btDefaultMotionState(PhysicsBody.trans1, PhysicsBody.trans2); // Transform, center of mass offset
+		pb.motion_state = new Ammo.btDefaultMotionState(PhysicsBody.trans1, PhysicsBody.trans2); // Transform, center of mass offset
 
 		PhysicsBody.vec1.setX(0);
 		PhysicsBody.vec1.setY(0);
 		PhysicsBody.vec1.setZ(0);
-		let inertia = PhysicsBody.vec1;
+		let inertia: Ammo.btVector3 = PhysicsBody.vec1;
 
 		if (pb.mass > 0) {
 			pb.btshape.calculateLocalInertia(pb.mass, inertia);
 		}
-		let bodyCI = new Ammo.btRigidBodyConstructionInfo(pb.mass, pb.motionState, pb.btshape, inertia);
+		let bodyCI: Ammo.btRigidBodyConstructionInfo = new Ammo.btRigidBodyConstructionInfo(pb.mass, pb.motion_state, pb.btshape, inertia);
 		pb.body = new Ammo.btRigidBody(bodyCI);
 
 		pb.body.setFriction(pb.friction);
-		if (pb.shape == ShapeType.ShapeSphere || pb.shape == ShapeType.ShapeCylinder || pb.shape == ShapeType.ShapeCone || pb.shape == ShapeType.ShapeCapsule) {
-			pb.angularDamping += pb.friction;
+		if (pb.shape == shape_type_t.SPHERE || pb.shape == shape_type_t.CYLINDER || pb.shape == shape_type_t.CONE || pb.shape == shape_type_t.CAPSULE) {
+			pb.angular_damping += pb.friction;
 		}
 		pb.body.setRestitution(pb.restitution);
 		// pb.body.setSleepingThresholds(linearThreshold, angularThreshold);
 		// pb.body.setDeactivationTime(deactivationTime);
-		pb.body.setDamping(pb.linearDamping, pb.angularDamping);
-		PhysicsBody.setLinearFactor(pb, pb.linearFactors[0], pb.linearFactors[1], pb.linearFactors[2]);
-		PhysicsBody.setAngularFactor(pb, pb.angularFactors[0], pb.angularFactors[1], pb.angularFactors[2]);
+		pb.body.setDamping(pb.linear_damping, pb.angular_damping);
+		PhysicsBody.set_linear_factor(pb, pb.linear_factors[0], pb.linear_factors[1], pb.linear_factors[2]);
+		PhysicsBody.set_angular_factor(pb, pb.angular_factors[0], pb.angular_factors[1], pb.angular_factors[2]);
 		if (pb.trigger) {
-			pb.body.setCollisionFlags(pb.body.getCollisionFlags() | CollisionFlags.CF_NO_CONTACT_RESPONSE);
+			pb.body.setCollisionFlags(pb.body.getCollisionFlags() | collision_flags_t.CF_NO_CONTACT_RESPONSE);
 		}
 		if (pb.mass == 0.0) {
-			pb.body.setCollisionFlags(pb.body.getCollisionFlags() | CollisionFlags.CF_STATIC_OBJECT);
+			pb.body.setCollisionFlags(pb.body.getCollisionFlags() | collision_flags_t.CF_STATIC_OBJECT);
 		}
 		if (pb.ccd) {
-			PhysicsBody.setCcd(pb, transform.radius);
+			PhysicsBody.set_ccd(pb, transform.radius);
 		}
 
-		pb.bodyScaleX = pb.currentScaleX = transform.scale.x;
-		pb.bodyScaleY = pb.currentScaleY = transform.scale.y;
-		pb.bodyScaleZ = pb.currentScaleZ = transform.scale.z;
+		pb.body_scale_x = pb.current_scale_x = transform.scale.x;
+		pb.body_scale_y = pb.current_scale_y = transform.scale.y;
+		pb.body_scale_z = pb.current_scale_z = transform.scale.z;
 
-		pb.id = PhysicsBody.nextId++;
+		pb.id = PhysicsBody.next_id++;
 		pb.body.userIndex = pb.id;
 
-		PhysicsWorld.addBody(physics, pb);
+		PhysicsWorld.add_body(physics, pb);
 
 		// notifyOnRemove(removeFromWorld);
 
 		Ammo.destroy(bodyCI);
 	}
 
-	static physicsUpdate = (pb: PhysicsBodyRaw) => {
+	static physics_update = (pb: PhysicsBodyRaw) => {
 		if (!pb.ready) {
 			return;
 		}
-		let trans = pb.body.getWorldTransform();
+		let trans: Ammo.btTransform = pb.body.getWorldTransform();
 
-		let p = trans.getOrigin();
-		let q = trans.getRotation();
+		let p: Ammo.btVector3 = trans.getOrigin();
+		let q: Ammo.btQuaternion = trans.getRotation();
 		let qw: Ammo.btQuadWord = q;
 
-		let transform = pb.object.transform;
+		let transform: transform_t = pb.object.transform;
 		vec4_set(transform.loc, p.x(), p.y(), p.z());
 		quat_set(transform.rot, qw.x(), qw.y(), qw.z(), qw.w());
 		if (pb.object.parent != null) {
-			let ptransform = pb.object.parent.transform;
+			let ptransform: transform_t = pb.object.parent.transform;
 			transform.loc.x -= transform_world_x(ptransform);
 			transform.loc.y -= transform_world_y(ptransform);
 			transform.loc.z -= transform_world_z(ptransform);
@@ -251,20 +251,20 @@ class PhysicsBody {
 		transform_build_matrix(transform);
 	}
 
-	static removeFromWorld = (pb: PhysicsBodyRaw) => {
-		PhysicsWorld.removeBody(PhysicsWorld.active, pb);
+	static remove_from_world = (pb: PhysicsBodyRaw) => {
+		PhysicsWorld.remove_body(PhysicsWorld.active, pb);
 	}
 
 	static activate = (pb: PhysicsBodyRaw) => {
 		pb.body.activate(false);
 	}
 
-	static setGravity = (pb: PhysicsBodyRaw, v: vec4_t) => {
+	static set_gravity = (pb: PhysicsBodyRaw, v: vec4_t) => {
 		PhysicsBody.vec1.setValue(v.x, v.y, v.z);
 		pb.body.setGravity(PhysicsBody.vec1);
 	}
 
-	static applyForce = (pb: PhysicsBodyRaw, force: vec4_t, loc: vec4_t = null) => {
+	static apply_force = (pb: PhysicsBodyRaw, force: vec4_t, loc: vec4_t = null) => {
 		PhysicsBody.activate(pb);
 		PhysicsBody.vec1.setValue(force.x, force.y, force.z);
 		if (loc == null) {
@@ -276,7 +276,7 @@ class PhysicsBody {
 		}
 	}
 
-	static applyImpulse = (pb: PhysicsBodyRaw, impulse: vec4_t, loc: vec4_t = null) => {
+	static apply_impulse = (pb: PhysicsBodyRaw, impulse: vec4_t, loc: vec4_t = null) => {
 		PhysicsBody.activate(pb);
 		PhysicsBody.vec1.setValue(impulse.x, impulse.y, impulse.z);
 		if (loc == null) {
@@ -288,68 +288,68 @@ class PhysicsBody {
 		}
 	}
 
-	static applyTorque = (pb: PhysicsBodyRaw, torque: vec4_t) => {
+	static apply_torque = (pb: PhysicsBodyRaw, torque: vec4_t) => {
 		PhysicsBody.activate(pb);
 		PhysicsBody.vec1.setValue(torque.x, torque.y, torque.z);
 		pb.body.applyTorque(PhysicsBody.vec1);
 	}
 
-	static applyTorqueImpulse = (pb: PhysicsBodyRaw, torque: vec4_t) => {
+	static apply_torque_impulse = (pb: PhysicsBodyRaw, torque: vec4_t) => {
 		PhysicsBody.activate(pb);
 		PhysicsBody.vec1.setValue(torque.x, torque.y, torque.z);
 		pb.body.applyTorqueImpulse(PhysicsBody.vec1);
 	}
 
-	static setLinearFactor = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
+	static set_linear_factor = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
 		PhysicsBody.vec1.setValue(x, y, z);
 		pb.body.setLinearFactor(PhysicsBody.vec1);
 	}
 
-	static setAngularFactor = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
+	static set_angular_factor = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
 		PhysicsBody.vec1.setValue(x, y, z);
 		pb.body.setAngularFactor(PhysicsBody.vec1);
 	}
 
-	static getLinearVelocity = (pb: PhysicsBodyRaw): vec4_t => {
-		let v = pb.body.getLinearVelocity();
+	static get_linear_velocity = (pb: PhysicsBodyRaw): vec4_t => {
+		let v: Ammo.btVector3 = pb.body.getLinearVelocity();
 		return vec4_create(v.x(), v.y(), v.z());
 	}
 
-	static setLinearVelocity = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
+	static set_linear_velocity = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
 		PhysicsBody.vec1.setValue(x, y, z);
 		pb.body.setLinearVelocity(PhysicsBody.vec1);
 	}
 
-	static getAngularVelocity = (pb: PhysicsBodyRaw): vec4_t => {
-		let v = pb.body.getAngularVelocity();
+	static get_angular_velocity = (pb: PhysicsBodyRaw): vec4_t => {
+		let v: Ammo.btVector3 = pb.body.getAngularVelocity();
 		return vec4_create(v.x(), v.y(), v.z());
 	}
 
-	static setAngularVelocity = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
+	static set_angular_velocity = (pb: PhysicsBodyRaw, x: f32, y: f32, z: f32) => {
 		PhysicsBody.vec1.setValue(x, y, z);
 		pb.body.setAngularVelocity(PhysicsBody.vec1);
 	}
 
-	static setFriction = (pb: PhysicsBodyRaw, f: f32) => {
+	static set_friction = (pb: PhysicsBodyRaw, f: f32) => {
 		pb.body.setFriction(f);
 		pb.friction = f;
 	}
 
-	static setScale = (pb: PhysicsBodyRaw, v: vec4_t) => {
-		pb.currentScaleX = v.x;
-		pb.currentScaleY = v.y;
-		pb.currentScaleZ = v.z;
-		PhysicsBody.vec1.setX(v.x / pb.bodyScaleX);
-		PhysicsBody.vec1.setY(v.y / pb.bodyScaleY);
-		PhysicsBody.vec1.setZ(v.z / pb.bodyScaleZ);
+	static set_scale = (pb: PhysicsBodyRaw, v: vec4_t) => {
+		pb.current_scale_x = v.x;
+		pb.current_scale_y = v.y;
+		pb.current_scale_z = v.z;
+		PhysicsBody.vec1.setX(v.x / pb.body_scale_x);
+		PhysicsBody.vec1.setY(v.y / pb.body_scale_y);
+		PhysicsBody.vec1.setZ(v.z / pb.body_scale_z);
 		pb.btshape.setLocalScaling(PhysicsBody.vec1);
 		let worldDyn: Ammo.btDynamicsWorld = PhysicsWorld.active.world;
 		let worldCol: Ammo.btCollisionWorld = worldDyn;
 		worldCol.updateSingleAabb(pb.body);
 	}
 
-	static syncTransform = (pb: PhysicsBodyRaw) => {
-		let t = pb.object.transform;
+	static sync_transform = (pb: PhysicsBodyRaw) => {
+		let t: transform_t = pb.object.transform;
 		transform_build_matrix(t);
 		PhysicsBody.vec1.setValue(transform_world_x(t), transform_world_y(t), transform_world_z(t));
 		PhysicsBody.trans1.setOrigin(PhysicsBody.vec1);
@@ -357,31 +357,31 @@ class PhysicsBody {
 		PhysicsBody.quat1.setValue(PhysicsBody.quat.x, PhysicsBody.quat.y, PhysicsBody.quat.z, PhysicsBody.quat.w);
 		PhysicsBody.trans1.setRotation(PhysicsBody.quat1);
 		pb.body.setWorldTransform(PhysicsBody.trans1);
-		if (pb.currentScaleX != t.scale.x || pb.currentScaleY != t.scale.y || pb.currentScaleZ != t.scale.z) {
-			PhysicsBody.setScale(pb, t.scale);
+		if (pb.current_scale_x != t.scale.x || pb.current_scale_y != t.scale.y || pb.current_scale_z != t.scale.z) {
+			PhysicsBody.set_scale(pb, t.scale);
 		}
 		PhysicsBody.activate(pb);
 	}
 
-	static setCcd = (pb: PhysicsBodyRaw, sphereRadius: f32, motionThreshold = 1e-7) => {
+	static set_ccd = (pb: PhysicsBodyRaw, sphereRadius: f32, motionThreshold = 1e-7) => {
 		pb.body.setCcdSweptSphereRadius(sphereRadius);
 		pb.body.setCcdMotionThreshold(motionThreshold);
 	}
 
-	static fillConvexHull = (pb: PhysicsBodyRaw, scale: vec4_t, margin: f32): Ammo.btConvexHullShape => {
+	static fill_convex_hull = (pb: PhysicsBodyRaw, scale: vec4_t, margin: f32): Ammo.btConvexHullShape => {
 		// Check whether shape already exists
-		let data = pb.object.ext.data;
-		let shape = PhysicsBody.convexHullCache.get(data);
+		let data: any = pb.object.ext.data;
+		let shape: Ammo.btConvexHullShape = PhysicsBody.convex_hull_cache.get(data);
 		if (shape != null) {
-			PhysicsBody.usersCache.set(data, PhysicsBody.usersCache.get(data) + 1);
+			PhysicsBody.users_cache.set(data, PhysicsBody.users_cache.get(data) + 1);
 			return shape;
 		}
 
 		shape = new Ammo.btConvexHullShape();
-		PhysicsBody.convexHullCache.set(data, shape);
-		PhysicsBody.usersCache.set(data, 1);
+		PhysicsBody.convex_hull_cache.set(data, shape);
+		PhysicsBody.users_cache.set(data, 1);
 
-		let positions = mesh_data_get_vertex_array(data, 'pos').values;
+		let positions: i16_array_t = mesh_data_get_vertex_array(data, 'pos').values;
 
 		let sx: f32 = scale.x * (1.0 - margin) * (1 / 32767);
 		let sy: f32 = scale.y * (1.0 - margin) * (1 / 32767);
@@ -391,7 +391,7 @@ class PhysicsBody {
 		sy *= data.scale_pos;
 		sz *= data.scale_pos;
 
-		for (let i = 0; i < Math.floor(positions.length / 4); ++i) {
+		for (let i: i32 = 0; i < Math.floor(positions.length / 4); ++i) {
 			PhysicsBody.vec1.setX(positions[i * 4    ] * sx);
 			PhysicsBody.vec1.setY(positions[i * 4 + 1] * sy);
 			PhysicsBody.vec1.setZ(positions[i * 4 + 2] * sz);
@@ -400,21 +400,21 @@ class PhysicsBody {
 		return shape;
 	}
 
-	static fillTriangleMesh = (pb: PhysicsBodyRaw, scale: vec4_t): Ammo.btTriangleMesh => {
+	static fill_triangle_mesh = (pb: PhysicsBodyRaw, scale: vec4_t): Ammo.btTriangleMesh => {
 		// Check whether shape already exists
-		let data = pb.object.ext.data;
-		let triangleMesh = PhysicsBody.triangleMeshCache.get(data);
+		let data: any = pb.object.ext.data;
+		let triangleMesh: Ammo.btTriangleMesh = PhysicsBody.triangle_mesh_cache.get(data);
 		if (triangleMesh != null) {
-			PhysicsBody.usersCache.set(data, PhysicsBody.usersCache.get(data) + 1);
+			PhysicsBody.users_cache.set(data, PhysicsBody.users_cache.get(data) + 1);
 			return triangleMesh;
 		}
 
 		triangleMesh = new Ammo.btTriangleMesh(true, true);
-		PhysicsBody.triangleMeshCache.set(data, triangleMesh);
-		PhysicsBody.usersCache.set(data, 1);
+		PhysicsBody.triangle_mesh_cache.set(data, triangleMesh);
+		PhysicsBody.users_cache.set(data, 1);
 
-		let positions = mesh_data_get_vertex_array(data, 'pos').values;
-		let indices = data._indices;
+		let positions: i16_array_t = mesh_data_get_vertex_array(data, 'pos').values;
+		let indices: any = data._indices;
 
 		let sx: f32 = scale.x * (1 / 32767);
 		let sy: f32 = scale.y * (1 / 32767);
@@ -425,7 +425,7 @@ class PhysicsBody {
 		sz *= data.scale_pos;
 
 		for (let ar of indices) {
-			for (let i = 0; i < Math.floor(ar.length / 3); ++i) {
+			for (let i: i32 = 0; i < Math.floor(ar.length / 3); ++i) {
 				PhysicsBody.vec1.setX(positions[ar[i * 3    ] * 4    ] * sx);
 				PhysicsBody.vec1.setY(positions[ar[i * 3    ] * 4 + 1] * sy);
 				PhysicsBody.vec1.setZ(positions[ar[i * 3    ] * 4 + 2] * sz);
@@ -442,47 +442,41 @@ class PhysicsBody {
 	}
 
 	static delete = (pb: PhysicsBodyRaw) => {
-		Ammo.destroy(pb.motionState);
+		Ammo.destroy(pb.motion_state);
 		Ammo.destroy(pb.body);
 
 		// Delete shape if no other user is found
-		if (pb.shape == ShapeType.ShapeConvexHull || pb.shape == ShapeType.ShapeMesh) {
-			let data = pb.object.ext.data;
-			let i = PhysicsBody.usersCache.get(data) - 1;
-			PhysicsBody.usersCache.set(data, i);
+		if (pb.shape == shape_type_t.CONVEX_HULL || pb.shape == shape_type_t.MESH) {
+			let data: any = pb.object.ext.data;
+			let i: i32 = PhysicsBody.users_cache.get(data) - 1;
+			PhysicsBody.users_cache.set(data, i);
 			if (i <= 0) {
 				Ammo.destroy(pb.btshape);
-				pb.shape == ShapeType.ShapeConvexHull ?
-					PhysicsBody.convexHullCache.delete(data) :
-					PhysicsBody.triangleMeshCache.delete(data);
+				pb.shape == shape_type_t.CONVEX_HULL ?
+					PhysicsBody.convex_hull_cache.delete(data) :
+					PhysicsBody.triangle_mesh_cache.delete(data);
 			}
 		}
 		else Ammo.destroy(pb.btshape);
 	}
 }
 
-enum ShapeType {
-	ShapeBox,
-	ShapeSphere,
-	ShapeConvexHull,
-	ShapeMesh,
-	ShapeCone,
-	ShapeCylinder,
-	ShapeCapsule,
-	ShapeTerrain,
+enum shape_type_t {
+	BOX,
+	SPHERE,
+	CONVEX_HULL,
+	MESH,
+	CONE,
+	CYLINDER,
+	CAPSULE,
+	TERRAIN,
 }
 
-enum CollisionFlags {
+enum collision_flags_t {
 	CF_STATIC_OBJECT = 1,
 	CF_KINEMATIC_OBJECT = 2,
 	CF_NO_CONTACT_RESPONSE = 4,
 	CF_CHARACTER_OBJECT = 16,
 }
 
-// static ACTIVE_TAG = 1;
-// static ISLAND_SLEEPING = 2;
-// static WANTS_DEACTIVATION = 3;
-// static DISABLE_DEACTIVATION = 4;
-// static DISABLE_SIMULATION = 5;
-
 ///end

+ 67 - 67
base/Sources/PhysicsWorld.ts

@@ -4,11 +4,11 @@
 class PhysicsWorldRaw {
 	world: Ammo.btDiscreteDynamicsWorld;
 	dispatcher: Ammo.btCollisionDispatcher;
-	contacts: TPair[] = [];
-	bodyMap = new Map<i32, PhysicsBodyRaw>();
-	timeScale = 1.0;
-	timeStep = 1 / 60;
-	maxSteps = 1;
+	contacts: pair_t[] = [];
+	bodyMap: Map<i32, PhysicsBodyRaw> = new Map();
+	timeScale: f32 = 1.0;
+	timeStep: f32 = 1 / 60;
+	maxSteps: i32 = 1;
 }
 
 class PhysicsWorld {
@@ -16,18 +16,18 @@ class PhysicsWorld {
 	static active: PhysicsWorldRaw = null;
 	static vec1: Ammo.btVector3 = null;
 	static vec2: Ammo.btVector3 = null;
-	static v1 = vec4_create();
-	static v2 = vec4_create();
+	static v1: vec4_t = vec4_create();
+	static v2: vec4_t = vec4_create();
 
 	static load = (done: ()=>void) => {
-		let b = krom_load_blob("data/plugins/ammo.js");
+		let b: buffer_t = krom_load_blob("data/plugins/ammo.js");
 		globalThis.eval(sys_buffer_to_string(b));
 		let print = (s: string) => { krom_log(s); };
 		Ammo({print: print}).then(done);
 	}
 
 	static create(): PhysicsWorldRaw {
-		let pw = new PhysicsWorldRaw();
+		let pw: PhysicsWorldRaw = new PhysicsWorldRaw();
 		PhysicsWorld.active = pw;
 		PhysicsWorld.vec1 = new Ammo.btVector3(0, 0, 0);
 		PhysicsWorld.vec2 = new Ammo.btVector3(0, 0, 0);
@@ -36,29 +36,29 @@ class PhysicsWorld {
 	}
 
 	static reset = (pw: PhysicsWorldRaw) => {
-		for (let body of pw.bodyMap.values()) PhysicsWorld.removeBody(pw, body);
+		for (let body of pw.bodyMap.values()) PhysicsWorld.remove_body(pw, body);
 	}
 
 	static init = (pw: PhysicsWorldRaw) => {
-		let broadphase = new Ammo.btDbvtBroadphase();
-		let collisionConfiguration = new Ammo.btDefaultCollisionConfiguration();
+		let broadphase: Ammo.btDbvtBroadphase = new Ammo.btDbvtBroadphase();
+		let collisionConfiguration: Ammo.btDefaultCollisionConfiguration = new Ammo.btDefaultCollisionConfiguration();
 		pw.dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration);
-		let solver = new Ammo.btSequentialImpulseConstraintSolver();
+		let solver: Ammo.btSequentialImpulseConstraintSolver = new Ammo.btSequentialImpulseConstraintSolver();
 		pw.world = new Ammo.btDiscreteDynamicsWorld(pw.dispatcher, broadphase, solver, collisionConfiguration);
-		PhysicsWorld.setGravity(pw, vec4_create(0, 0, -9.81));
+		PhysicsWorld.set_gravity(pw, vec4_create(0, 0, -9.81));
 	}
 
-	static setGravity = (pw: PhysicsWorldRaw, v: vec4_t) => {
+	static set_gravity = (pw: PhysicsWorldRaw, v: vec4_t) => {
 		PhysicsWorld.vec1.setValue(v.x, v.y, v.z);
 		pw.world.setGravity(PhysicsWorld.vec1);
 	}
 
-	static addBody = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw) => {
+	static add_body = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw) => {
 		pw.world.addRigidBody(pb.body, pb.group, pb.mask);
 		pw.bodyMap.set(pb.id, pb);
 	}
 
-	static removeBody = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw) => {
+	static remove_body = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw) => {
 		if (pb.destroyed) return;
 		pb.destroyed = true;
 		if (pw.world != null) pw.world.removeRigidBody(pb.body);
@@ -66,11 +66,11 @@ class PhysicsWorld {
 		PhysicsBody.delete(pb);
 	}
 
-	static getContacts = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw): PhysicsBodyRaw[] => {
+	static get_contacts = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw): PhysicsBodyRaw[] => {
 		if (pw.contacts.length == 0) return null;
 		let res: PhysicsBodyRaw[] = [];
-		for (let i = 0; i < pw.contacts.length; ++i) {
-			let c = pw.contacts[i];
+		for (let i: i32 = 0; i < pw.contacts.length; ++i) {
+			let c: pair_t = pw.contacts[i];
 			let pb: PhysicsBodyRaw = null;
 			if (c.a == pb.body.userIndex) pb = pw.bodyMap.get(c.b);
 			else if (c.b == pb.body.userIndex) pb = pw.bodyMap.get(c.a);
@@ -79,47 +79,47 @@ class PhysicsWorld {
 		return res;
 	}
 
-	static getContactPairs = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw): TPair[] => {
+	static get_contact_pairs = (pw: PhysicsWorldRaw, pb: PhysicsBodyRaw): pair_t[] => {
 		if (pw.contacts.length == 0) return null;
-		let res: TPair[] = [];
-		for (let i = 0; i < pw.contacts.length; ++i) {
-			let c = pw.contacts[i];
+		let res: pair_t[] = [];
+		for (let i: i32 = 0; i < pw.contacts.length; ++i) {
+			let c: pair_t = pw.contacts[i];
 			if (c.a == pb.body.userIndex) res.push(c);
 			else if (c.b == pb.body.userIndex) res.push(c);
 		}
 		return res;
 	}
 
-	static lateUpdate = (pw: PhysicsWorldRaw) => {
-		let t = time_delta() * pw.timeScale;
+	static late_update = (pw: PhysicsWorldRaw) => {
+		let t: f32 = time_delta() * pw.timeScale;
 		if (t == 0.0) return; // Simulation paused
 
 		pw.world.stepSimulation(pw.timeStep, pw.maxSteps, t);
-		PhysicsWorld.updateContacts(pw);
-		for (let body of pw.bodyMap.values()) PhysicsBody.physicsUpdate(body);
+		PhysicsWorld.update_contacts(pw);
+		for (let body of pw.bodyMap.values()) PhysicsBody.physics_update(body);
 	}
 
-	static updateContacts = (pw: PhysicsWorldRaw) => {
+	static update_contacts = (pw: PhysicsWorldRaw) => {
 		pw.contacts = [];
 		let disp: Ammo.btDispatcher = pw.dispatcher;
-		let numManifolds = disp.getNumManifolds();
+		let numManifolds: i32 = disp.getNumManifolds();
 
-		for (let i = 0; i < numManifolds; ++i) {
-			let contactManifold = disp.getManifoldByIndexInternal(i);
-			let body0 = Ammo.btRigidBody.prototype.upcast(contactManifold.getBody0());
-			let body1 = Ammo.btRigidBody.prototype.upcast(contactManifold.getBody1());
+		for (let i: i32 = 0; i < numManifolds; ++i) {
+			let contactManifold: Ammo.btPersistentManifold = disp.getManifoldByIndexInternal(i);
+			let body0: Ammo.btRigidBody = Ammo.btRigidBody.prototype.upcast(contactManifold.getBody0());
+			let body1: Ammo.btRigidBody = Ammo.btRigidBody.prototype.upcast(contactManifold.getBody1());
 
-			let numContacts = contactManifold.getNumContacts();
+			let numContacts: i32 = contactManifold.getNumContacts();
 			let pt: Ammo.btManifoldPoint = null;
 			let posA: Ammo.btVector3 = null;
 			let posB: Ammo.btVector3 = null;
 			let nor: Ammo.btVector3 = null;
-			for (let j = 0; j < numContacts; ++j) {
+			for (let j: i32 = 0; j < numContacts; ++j) {
 				pt = contactManifold.getContactPoint(j);
 				posA = pt.get_m_positionWorldOnA();
 				posB = pt.get_m_positionWorldOnB();
 				nor = pt.get_m_normalWorldOnB();
-				let cp: TPair = {
+				let cp: pair_t = {
 					a: body0.userIndex,
 					b: body1.userIndex,
 					posA: vec4_create(posA.x(), posA.y(), posA.z()),
@@ -133,23 +133,23 @@ class PhysicsWorld {
 		}
 	}
 
-	static pickClosest = (pw: PhysicsWorldRaw, inputX: f32, inputY: f32): PhysicsBodyRaw => {
-		let camera = scene_camera;
-		let start = vec4_create();
-		let end = vec4_create();
+	static pick_closest = (pw: PhysicsWorldRaw, inputX: f32, inputY: f32): PhysicsBodyRaw => {
+		let camera: camera_object_t = scene_camera;
+		let start: vec4_t = vec4_create();
+		let end: vec4_t = vec4_create();
 		raycast_get_dir(start, end, inputX, inputY, camera);
-		let hit = PhysicsWorld.rayCast(pw, mat4_get_loc(camera.base.transform.world), end);
-		let body = (hit != null) ? hit.body : null;
+		let hit: hit_t = PhysicsWorld.ray_cast(pw, mat4_get_loc(camera.base.transform.world), end);
+		let body: PhysicsBodyRaw = (hit != null) ? hit.body : null;
 		return body;
 	}
 
-	static rayCast = (pw: PhysicsWorldRaw, from: vec4_t, to: vec4_t, group: i32 = 0x00000001, mask = 0xffffffff): THit => {
-		let rayFrom = PhysicsWorld.vec1;
-		let rayTo = PhysicsWorld.vec2;
+	static ray_cast = (pw: PhysicsWorldRaw, from: vec4_t, to: vec4_t, group: i32 = 0x00000001, mask: i32 = 0xffffffff): hit_t => {
+		let rayFrom: Ammo.btVector3 = PhysicsWorld.vec1;
+		let rayTo: Ammo.btVector3 = PhysicsWorld.vec2;
 		rayFrom.setValue(from.x, from.y, from.z);
 		rayTo.setValue(to.x, to.y, to.z);
 
-		let rayCallback = new Ammo.ClosestRayResultCallback(rayFrom, rayTo);
+		let rayCallback: Ammo.ClosestRayResultCallback = new Ammo.ClosestRayResultCallback(rayFrom, rayTo);
 
 		rayCallback.set_m_collisionFilterGroup(group);
 		rayCallback.set_m_collisionFilterMask(mask);
@@ -158,15 +158,15 @@ class PhysicsWorld {
 		let worldCol: Ammo.btCollisionWorld = worldDyn;
 		worldCol.rayTest(rayFrom, rayTo, rayCallback);
 		let pb: PhysicsBodyRaw = null;
-		let hitInfo: THit = null;
+		let hitInfo: hit_t = null;
 
 		let rc: Ammo.RayResultCallback = rayCallback;
 		if (rc.hasHit()) {
-			let co = rayCallback.get_m_collisionObject();
-			let body = Ammo.btRigidBody.prototype.upcast(co);
-			let hit = rayCallback.get_m_hitPointWorld();
+			let co: Ammo.btCollisionObject = rayCallback.get_m_collisionObject();
+			let body: Ammo.btRigidBody = Ammo.btRigidBody.prototype.upcast(co);
+			let hit: Ammo.btVector3 = rayCallback.get_m_hitPointWorld();
 			vec4_set(PhysicsWorld.v1, hit.x(), hit.y(), hit.z());
-			let norm = rayCallback.get_m_hitNormalWorld();
+			let norm: Ammo.btVector3 = rayCallback.get_m_hitNormalWorld();
 			vec4_set(PhysicsWorld.v2, norm.x(), norm.y(), norm.z());
 			pb = pw.bodyMap.get(body.userIndex);
 			hitInfo = {
@@ -181,20 +181,20 @@ class PhysicsWorld {
 	}
 }
 
-type THit = {
-	body: PhysicsBodyRaw;
-	pos: vec4_t;
-	normal: vec4_t;
-}
-
-type TPair = {
-	a: i32;
-	b: i32;
-	posA: vec4_t;
-	posB: vec4_t;
-	normOnB: vec4_t;
-	impulse: f32;
-	distance: f32;
-}
+type hit_t = {
+	body?: PhysicsBodyRaw;
+	pos?: vec4_t;
+	normal?: vec4_t;
+};
+
+type pair_t = {
+	a?: i32;
+	b?: i32;
+	posA?: vec4_t;
+	posB?: vec4_t;
+	normOnB?: vec4_t;
+	impulse?: f32;
+	distance?: f32;
+};
 
 ///end

+ 8 - 8
base/Sources/Plugin.ts

@@ -1,22 +1,22 @@
 
 class PluginRaw {
-	drawUI: (ui: zui_t)=>void = null;
+	draw_ui: (ui: zui_t)=>void = null;
 	draw: ()=>void = null;
 	update: ()=>void = null;
 	delete: ()=>void = null;
-	version = "0.1";
-	apiversion = "0.1";
+	version: string = "0.1";
+	apiversion: string = "0.1";
 	name: string;
 }
 
 class Plugin {
 
 	static plugins: Map<string, PluginRaw> = new Map();
-	static pluginName: string;
+	static plugin_name: string;
 
 	static create(): PluginRaw {
-		let p = new PluginRaw();
-		p.name = Plugin.pluginName;
+		let p: PluginRaw = new PluginRaw();
+		p.name = Plugin.plugin_name;
 		Plugin.plugins.set(p.name, p);
 		return p;
 	}
@@ -24,7 +24,7 @@ class Plugin {
 	static start = (plugin: string) => {
 		try {
 			let blob: ArrayBuffer = data_get_blob("plugins/" + plugin);
-			Plugin.pluginName = plugin;
+			Plugin.plugin_name = plugin;
 			// (1, eval)(sys_buffer_to_string(blob)); // Global scope
 			eval(sys_buffer_to_string(blob)); // Local scope
 			data_delete_blob("plugins/" + plugin);
@@ -36,7 +36,7 @@ class Plugin {
 	}
 
 	static stop = (plugin: string) => {
-		let p = Plugin.plugins.get(plugin);
+		let p: PluginRaw = Plugin.plugins.get(plugin);
 		if (p != null && p.delete != null) p.delete();
 		Plugin.plugins.delete(plugin);
 	}

+ 198 - 198
base/Sources/Project.ts

@@ -1,99 +1,99 @@
 
 class Project {
 
-	static raw: TProjectFormat = {};
-	static filepath = "";
-	static assets: TAsset[] = [];
-	static assetNames: string[] = [];
-	static assetId = 0;
-	static meshAssets: string[] = [];
-	static materialGroups: TNodeGroup[] = [];
-	static paintObjects: mesh_object_t[] = null;
-	static assetMap = new Map<i32, any>(); // ImageRaw | FontRaw
-	static meshList: string[] = null;
+	static raw: project_format_t = {};
+	static filepath: string = "";
+	static assets: asset_t[] = [];
+	static asset_names: string[] = [];
+	static asset_id: i32 = 0;
+	static mesh_assets: string[] = [];
+	static material_groups: node_group_t[] = [];
+	static paint_objects: mesh_object_t[] = null;
+	static asset_map: Map<i32, any> = new Map(); // ImageRaw | FontRaw
+	static mesh_list: string[] = null;
 	///if (is_paint || is_sculpt)
 	static materials: SlotMaterialRaw[] = null;
 	static brushes: SlotBrushRaw[] = null;
 	static layers: SlotLayerRaw[] = null;
 	static fonts: SlotFontRaw[] = null;
-	static atlasObjects: i32[] = null;
-	static atlasNames: string[] = null;
+	static atlas_objects: i32[] = null;
+	static atlas_names: string[] = null;
 	///end
 	///if is_lab
-	static materialData: material_data_t = null; ////
+	static material_data: material_data_t = null; ////
 	static materials: any[] = null; ////
 	static nodes: zui_nodes_t;
 	static canvas: zui_node_canvas_t;
-	static defaultCanvas: ArrayBuffer = null;
+	static default_canvas: ArrayBuffer = null;
 	///end
 
-	static projectOpen = () => {
+	static project_open = () => {
 		UIFiles.show("arm", false, false, (path: string) => {
 			if (!path.endsWith(".arm")) {
 				Console.error(Strings.error0());
 				return;
 			}
 
-			let current = _g2_current;
+			let current: image_t = _g2_current;
 			if (current != null) g2_end();
 
-			ImportArm.runProject(path);
+			ImportArm.run_project(path);
 
 			if (current != null) g2_begin(current);
 		});
 	}
 
-	static projectSave = (saveAndQuit = false) => {
+	static project_save = (saveAndQuit: bool = false) => {
 		if (Project.filepath == "") {
 			///if krom_ios
-			let documentDirectory = krom_save_dialog("", "");
+			let documentDirectory: string = krom_save_dialog("", "");
 			documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled'
 			Project.filepath = documentDirectory + "/" + sys_title() + ".arm";
 			///elseif krom_android
 			Project.filepath = krom_save_path() + "/" + sys_title() + ".arm";
 			///else
-			Project.projectSaveAs(saveAndQuit);
+			Project.project_save_as(saveAndQuit);
 			return;
 			///end
 		}
 
 		///if (krom_windows || krom_linux || krom_darwin)
-		let filename = Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
+		let filename: string = Project.filepath.substring(Project.filepath.lastIndexOf(Path.sep) + 1, Project.filepath.length - 4);
 		sys_title_set(filename + " - " + manifest_title);
 		///end
 
 		let _init = () => {
-			ExportArm.runProject();
+			ExportArm.run_project();
 			if (saveAndQuit) sys_stop();
 		}
 		app_notify_on_init(_init);
 	}
 
-	static projectSaveAs = (saveAndQuit = false) => {
+	static project_save_as = (saveAndQuit: bool = false) => {
 		UIFiles.show("arm", true, false, (path: string) => {
-			let f = UIFiles.filename;
+			let f: string = UIFiles.filename;
 			if (f == "") f = tr("untitled");
 			Project.filepath = path + Path.sep + f;
 			if (!Project.filepath.endsWith(".arm")) Project.filepath += ".arm";
-			Project.projectSave(saveAndQuit);
+			Project.project_save(saveAndQuit);
 		});
 	}
 
-	static projectNewBox = () => {
+	static project_new_box = () => {
 		///if (is_paint || is_sculpt)
-		UIBox.showCustom((ui: zui_t) => {
+		UIBox.show_custom((ui: zui_t) => {
 			if (zui_tab(zui_handle("project_0"), tr("New Project"))) {
-				if (Project.meshList == null) {
-					Project.meshList = File.readDirectory(Path.data() + Path.sep + "meshes");
-					for (let i = 0; i < Project.meshList.length; ++i) Project.meshList[i] = Project.meshList[i].substr(0, Project.meshList[i].length - 4); // Trim .arm
-					Project.meshList.unshift("plane");
-					Project.meshList.unshift("sphere");
-					Project.meshList.unshift("rounded_cube");
+				if (Project.mesh_list == null) {
+					Project.mesh_list = File.read_directory(Path.data() + Path.sep + "meshes");
+					for (let i: i32 = 0; i < Project.mesh_list.length; ++i) Project.mesh_list[i] = Project.mesh_list[i].substr(0, Project.mesh_list[i].length - 4); // Trim .arm
+					Project.mesh_list.unshift("plane");
+					Project.mesh_list.unshift("sphere");
+					Project.mesh_list.unshift("rounded_cube");
 				}
 
 				zui_row([0.5, 0.5]);
-				Context.raw.projectType = zui_combo(zui_handle("project_1", { position: Context.raw.projectType }), Project.meshList, tr("Template"), true);
-				Context.raw.projectAspectRatio = zui_combo(zui_handle("project_2", { position: Context.raw.projectAspectRatio }), ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true);
+				Context.raw.project_type = zui_combo(zui_handle("project_1", { position: Context.raw.project_type }), Project.mesh_list, tr("Template"), true);
+				Context.raw.project_aspect_ratio = zui_combo(zui_handle("project_2", { position: Context.raw.project_aspect_ratio }), ["1:1", "2:1", "1:2"], tr("Aspect Ratio"), true);
 
 				zui_end_element();
 				zui_row([0.5, 0.5]);
@@ -101,8 +101,8 @@ class Project {
 					UIBox.hide();
 				}
 				if (zui_button(tr("OK")) || ui.is_return_down) {
-					Project.projectNew();
-					Viewport.scaleToBounds();
+					Project.project_new();
+					Viewport.scale_to_bounds();
 					UIBox.hide();
 				}
 			}
@@ -110,112 +110,112 @@ class Project {
 		///end
 
 		///if is_lab
-		Project.projectNew();
-		Viewport.scaleToBounds();
+		Project.project_new();
+		Viewport.scale_to_bounds();
 		///end
 	}
 
-	static projectNew = (resetLayers = true) => {
+	static project_new = (resetLayers: bool = true) => {
 		///if (krom_windows || krom_linux || krom_darwin)
 		sys_title_set(manifest_title);
 		///end
 		Project.filepath = "";
 
 		///if (is_paint || is_sculpt)
-		if (Context.raw.mergedObject != null) {
-			mesh_object_remove(Context.raw.mergedObject);
-			data_delete_mesh(Context.raw.mergedObject.data._.handle);
-			Context.raw.mergedObject = null;
+		if (Context.raw.merged_object != null) {
+			mesh_object_remove(Context.raw.merged_object);
+			data_delete_mesh(Context.raw.merged_object.data._.handle);
+			Context.raw.merged_object = null;
 		}
-		Context.raw.layerPreviewDirty = true;
-		Context.raw.layerFilter = 0;
-		Project.meshAssets = [];
+		Context.raw.layer_preview_dirty = true;
+		Context.raw.layer_filter = 0;
+		Project.mesh_assets = [];
 		///end
 
 		Viewport.reset();
-		Context.raw.paintObject = Context.mainObject();
+		Context.raw.paint_object = Context.main_object();
 
-		Context.selectPaintObject(Context.mainObject());
-		for (let i = 1; i < Project.paintObjects.length; ++i) {
-			let p = Project.paintObjects[i];
-			if (p == Context.raw.paintObject) continue;
+		Context.select_paint_object(Context.main_object());
+		for (let i: i32 = 1; i < Project.paint_objects.length; ++i) {
+			let p: mesh_object_t = Project.paint_objects[i];
+			if (p == Context.raw.paint_object) continue;
 			data_delete_mesh(p.data._.handle);
 			mesh_object_remove(p);
 		}
-		let meshes = scene_meshes;
-		let len = meshes.length;
-		for (let i = 0; i < len; ++i) {
-			let m = meshes[len - i - 1];
-			if (Context.raw.projectObjects.indexOf(m) == -1 &&
+		let meshes: mesh_object_t[] = scene_meshes;
+		let len: i32 = meshes.length;
+		for (let i: i32 = 0; i < len; ++i) {
+			let m: mesh_object_t = meshes[len - i - 1];
+			if (Context.raw.project_objects.indexOf(m) == -1 &&
 				m.base.name != ".ParticleEmitter" &&
 				m.base.name != ".Particle") {
 				data_delete_mesh(m.data._.handle);
 				mesh_object_remove(m);
 			}
 		}
-		let handle = Context.raw.paintObject.data._.handle;
+		let handle: string = Context.raw.paint_object.data._.handle;
 		if (handle != "SceneSphere" && handle != "ScenePlane") {
 			data_delete_mesh(handle);
 		}
 
-		if (Context.raw.projectType != ProjectModel.ModelRoundedCube) {
+		if (Context.raw.project_type != project_model_t.ROUNDED_CUBE) {
 			let raw: mesh_data_t = null;
-			if (Context.raw.projectType == ProjectModel.ModelSphere || Context.raw.projectType == ProjectModel.ModelTessellatedPlane) {
-				let mesh: any = Context.raw.projectType == ProjectModel.ModelSphere ?
+			if (Context.raw.project_type == project_model_t.SPHERE || Context.raw.project_type == project_model_t.TESSELLATED_PLANE) {
+				let mesh: any = Context.raw.project_type == project_model_t.SPHERE ?
 					Geom.make_uv_sphere(1, 512, 256) :
 					Geom.make_plane(1, 1, 512, 512);
 				mesh.name = "Tessellated";
-				raw = ImportMesh.rawMesh(mesh);
+				raw = ImportMesh.raw_mesh(mesh);
 
 				///if is_sculpt
-				Base.notifyOnNextFrame(() => {
-					let f32a = new Float32Array(Config.getTextureResX() * Config.getTextureResY() * 4);
-					for (let i = 0; i < Math.floor(mesh.inda.length); ++i) {
-						let index = mesh.inda[i];
+				Base.notify_on_next_frame(() => {
+					let f32a: Float32Array = new Float32Array(Config.get_texture_res_x() * Config.get_texture_res_y() * 4);
+					for (let i: i32 = 0; i < Math.floor(mesh.inda.length); ++i) {
+						let index: i32 = mesh.inda[i];
 						f32a[i * 4]     = mesh.posa[index * 4]     / 32767;
 						f32a[i * 4 + 1] = mesh.posa[index * 4 + 1] / 32767;
 						f32a[i * 4 + 2] = mesh.posa[index * 4 + 2] / 32767;
 						f32a[i * 4 + 3] = 1.0;
 					}
 
-					let imgmesh = image_from_bytes(f32a.buffer, Config.getTextureResX(), Config.getTextureResY(), tex_format_t.RGBA128);
-					let texpaint = Project.layers[0].texpaint;
+					let imgmesh: image_t = image_from_bytes(f32a.buffer, Config.get_texture_res_x(), Config.get_texture_res_y(), tex_format_t.RGBA128);
+					let texpaint: image_t = Project.layers[0].texpaint;
 					g2_begin(texpaint);
-					g2_set_pipeline(Base.pipeCopy128);
-					g2_draw_scaled_image(imgmesh, 0, 0, Config.getTextureResX(), Config.getTextureResY());
+					g2_set_pipeline(Base.pipe_copy128);
+					g2_draw_scaled_image(imgmesh, 0, 0, Config.get_texture_res_x(), Config.get_texture_res_y());
 					g2_set_pipeline(null);
 					g2_end();
 				});
 				///end
 			}
 			else {
-				let b: ArrayBuffer = data_get_blob("meshes/" + Project.meshList[Context.raw.projectType] + ".arm");
+				let b: ArrayBuffer = data_get_blob("meshes/" + Project.mesh_list[Context.raw.project_type] + ".arm");
 				raw = armpack_decode(b).mesh_datas[0];
 			}
 
 			let md: mesh_data_t = mesh_data_create(raw);
 			data_cached_meshes.set("SceneTessellated", md);
 
-			if (Context.raw.projectType == ProjectModel.ModelTessellatedPlane) {
-				Viewport.setView(0, 0, 0.75, 0, 0, 0); // Top
+			if (Context.raw.project_type == project_model_t.TESSELLATED_PLANE) {
+				Viewport.set_view(0, 0, 0.75, 0, 0, 0); // Top
 			}
 		}
 
-		let n = Context.raw.projectType == ProjectModel.ModelRoundedCube ? ".Cube" : "Tessellated";
+		let n: string = Context.raw.project_type == project_model_t.ROUNDED_CUBE ? ".Cube" : "Tessellated";
 		let md: mesh_data_t = data_get_mesh("Scene", n);
 
-		let current = _g2_current;
+		let current: image_t = _g2_current;
 		if (current != null) g2_end();
 
 		///if is_paint
-		Context.raw.pickerMaskHandle.position = PickerMask.MaskNone;
+		Context.raw.picker_mask_handle.position = picker_mask_t.NONE;
 		///end
 
-		mesh_object_set_data(Context.raw.paintObject, md);
-		vec4_set(Context.raw.paintObject.base.transform.scale, 1, 1, 1);
-		transform_build_matrix(Context.raw.paintObject.base.transform);
-		Context.raw.paintObject.base.name = n;
-		Project.paintObjects = [Context.raw.paintObject];
+		mesh_object_set_data(Context.raw.paint_object, md);
+		vec4_set(Context.raw.paint_object.base.transform.scale, 1, 1, 1);
+		transform_build_matrix(Context.raw.paint_object.base.transform);
+		Context.raw.paint_object.base.name = n;
+		Project.paint_objects = [Context.raw.paint_object];
 		///if (is_paint || is_sculpt)
 		while (Project.materials.length > 0) SlotMaterial.unload(Project.materials.pop());
 		///end
@@ -224,7 +224,7 @@ class Project {
 		Project.materials.push(SlotMaterial.create(m));
 		///end
 		///if is_lab
-		Project.materialData = m;
+		Project.material_data = m;
 		///end
 
 		///if (is_paint || is_sculpt)
@@ -232,8 +232,8 @@ class Project {
 		///end
 
 		UINodes.hwnd.redraws = 2;
-		UINodes.groupStack = [];
-		Project.materialGroups = [];
+		UINodes.group_stack = [];
+		Project.material_groups = [];
 
 		///if (is_paint || is_sculpt)
 		Project.brushes = [SlotBrush.create()];
@@ -243,62 +243,62 @@ class Project {
 		Context.raw.font = Project.fonts[0];
 		///end
 
-		Project.setDefaultSwatches();
+		Project.set_default_swatches();
 		Context.raw.swatch = Project.raw.swatches[0];
 
-		Context.raw.pickedColor = Project.makeSwatch();
-		Context.raw.colorPickerCallback = null;
+		Context.raw.picked_color = Project.make_swatch();
+		Context.raw.color_picker_callback = null;
 		History.reset();
 
-		MakeMaterial.parsePaintMaterial();
+		MakeMaterial.parse_paint_material();
 
 		///if (is_paint || is_sculpt)
-		UtilRender.makeMaterialPreview();
+		UtilRender.make_material_preview();
 		///end
 
 		for (let a of Project.assets) data_delete_image(a.file);
 		Project.assets = [];
-		Project.assetNames = [];
-		Project.assetMap = new Map();
-		Project.assetId = 0;
+		Project.asset_names = [];
+		Project.asset_map = new Map();
+		Project.asset_id = 0;
 		Project.raw.packed_assets = [];
 		Context.raw.ddirty = 4;
 
 		///if (is_paint || is_sculpt)
-		UIBase.hwnds[TabArea.TabSidebar0].redraws = 2;
-		UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR0].redraws = 2;
+		UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 		///end
 
 		if (resetLayers) {
 
 			///if (is_paint || is_sculpt)
-			let aspectRatioChanged = Project.layers[0].texpaint.width != Config.getTextureResX() || Project.layers[0].texpaint.height != Config.getTextureResY();
+			let aspectRatioChanged: bool = Project.layers[0].texpaint.width != Config.get_texture_res_x() || Project.layers[0].texpaint.height != Config.get_texture_res_y();
 			while (Project.layers.length > 0) SlotLayer.unload(Project.layers.pop());
-			let layer = SlotLayer.create();
+			let layer: SlotLayerRaw = SlotLayer.create();
 			Project.layers.push(layer);
-			Context.setLayer(layer);
+			Context.set_layer(layer);
 			if (aspectRatioChanged) {
-				app_notify_on_init(Base.resizeLayers);
+				app_notify_on_init(Base.resize_layers);
 			}
 			///end
 
-			app_notify_on_init(Base.initLayers);
+			app_notify_on_init(Base.init_layers);
 		}
 
 		if (current != null) g2_begin(current);
 
-		Context.raw.savedEnvmap = null;
-		Context.raw.envmapLoaded = false;
-		scene_world._.envmap = Context.raw.emptyEnvmap;
+		Context.raw.saved_envmap = null;
+		Context.raw.envmap_loaded = false;
+		scene_world._.envmap = Context.raw.empty_envmap;
 		scene_world.envmap = "World_radiance.k";
-		Context.raw.showEnvmapHandle.selected = Context.raw.showEnvmap = false;
-		scene_world._.radiance = Context.raw.defaultRadiance;
-		scene_world._.radiance_mipmaps = Context.raw.defaultRadianceMipmaps;
-		scene_world._.irradiance = Context.raw.defaultIrradiance;
+		Context.raw.show_envmap_handle.selected = Context.raw.show_envmap = false;
+		scene_world._.radiance = Context.raw.default_radiance;
+		scene_world._.radiance_mipmaps = Context.raw.default_radiance_mipmaps;
+		scene_world._.irradiance = Context.raw.default_irradiance;
 		scene_world.strength = 4.0;
 
 		///if (is_paint || is_sculpt)
-		Context.initTool();
+		Context.init_tool();
 		///end
 
 		///if (krom_direct3d12 || krom_vulkan || krom_metal)
@@ -307,22 +307,22 @@ class Project {
 	}
 
 	///if (is_paint || is_sculpt)
-	static importMaterial = () => {
+	static import_material = () => {
 		UIFiles.show("arm,blend", false, true, (path: string) => {
 			path.endsWith(".blend") ?
 				ImportBlendMaterial.run(path) :
-				ImportArm.runMaterial(path);
+				ImportArm.run_material(path);
 		});
 	}
 
-	static importBrush = () => {
-		UIFiles.show("arm," + Path.textureFormats.join(","), false, true, (path: string) => {
+	static import_brush = () => {
+		UIFiles.show("arm," + Path.texture_formats.join(","), false, true, (path: string) => {
 			// Create brush from texture
-			if (Path.isTexture(path)) {
+			if (Path.is_texture(path)) {
 				// Import texture
 				ImportAsset.run(path);
-				let assetIndex = 0;
-				for (let i = 0; i < Project.assets.length; ++i) {
+				let assetIndex: i32 = 0;
+				for (let i: i32 = 0; i < Project.assets.length; ++i) {
 					if (Project.assets[i].file == path) {
 						assetIndex = i;
 						break;
@@ -334,11 +334,11 @@ class Project {
 				Project.brushes.push(Context.raw.brush);
 
 				// Create and link image node
-				let n = NodesBrush.createNode("TEX_IMAGE");
+				let n: zui_node_t = NodesBrush.create_node("TEX_IMAGE");
 				n.x = 83;
 				n.y = 340;
 				n.buttons[0].default_value = assetIndex;
-				let links = Context.raw.brush.canvas.links;
+				let links: zui_node_link_t[] = Context.raw.brush.canvas.links;
 				links.push({
 					id: zui_get_link_id(links),
 					from_id: n.id,
@@ -348,40 +348,40 @@ class Project {
 				});
 
 				// Parse brush
-				MakeMaterial.parseBrush();
+				MakeMaterial.parse_brush();
 				UINodes.hwnd.redraws = 2;
 				let _init = () => {
-					UtilRender.makeBrushPreview();
+					UtilRender.make_brush_preview();
 				}
 				app_notify_on_init(_init);
 			}
 			// Import from project file
 			else {
-				ImportArm.runBrush(path);
+				ImportArm.run_brush(path);
 			}
 		});
 	}
 	///end
 
-	static importMesh = (replaceExisting = true, done: ()=>void = null) => {
-		UIFiles.show(Path.meshFormats.join(","), false, false, (path: string) => {
-			Project.importMeshBox(path, replaceExisting, true, done);
+	static import_mesh = (replaceExisting: bool = true, done: ()=>void = null) => {
+		UIFiles.show(Path.mesh_formats.join(","), false, false, (path: string) => {
+			Project.import_mesh_box(path, replaceExisting, true, done);
 		});
 	}
 
-	static importMeshBox = (path: string, replaceExisting = true, clearLayers = true, done: ()=>void = null) => {
+	static import_mesh_box = (path: string, replaceExisting: bool = true, clearLayers: bool = true, done: ()=>void = null) => {
 
 		///if krom_ios
 		// Import immediately while access to resource is unlocked
 		// data_get_blob(path, (b: Blob) => {});
 		///end
 
-		UIBox.showCustom((ui: zui_t) => {
-			let tabVertical = Config.raw.touch_ui;
+		UIBox.show_custom((ui: zui_t) => {
+			let tabVertical: bool = Config.raw.touch_ui;
 			if (zui_tab(zui_handle("project_3"), tr("Import Mesh"), tabVertical)) {
 
 				if (path.toLowerCase().endsWith(".obj")) {
-					Context.raw.splitBy = zui_combo(zui_handle("project_4"), [
+					Context.raw.split_by = zui_combo(zui_handle("project_4"), [
 						tr("Object"),
 						tr("Group"),
 						tr("Material"),
@@ -398,7 +398,7 @@ class Project {
 				///if (is_paint || is_sculpt)
 				// if (path.toLowerCase().endsWith(".fbx") || path.toLowerCase().endsWith(".blend")) {
 				if (path.toLowerCase().endsWith(".blend")) {
-					Context.raw.parseVCols = zui_check(zui_handle("project_6", { selected: Context.raw.parseVCols }), tr("Parse Vertex Colors"));
+					Context.raw.parse_vcols = zui_check(zui_handle("project_6", { selected: Context.raw.parse_vcols }), tr("Parse Vertex Colors"));
 					if (ui.is_hovered) zui_tooltip(tr("Import vertex color data"));
 				}
 				///end
@@ -419,46 +419,46 @@ class Project {
 						if (done != null) done();
 					}
 					///if (krom_android || krom_ios)
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						Console.toast(tr("Importing mesh"));
-						Base.notifyOnNextFrame(doImport);
+						Base.notify_on_next_frame(doImport);
 					});
 					///else
 					doImport();
 					///end
 				}
 				if (zui_button(tr("?"))) {
-					File.loadUrl("https://github.com/armory3d/armorpaint_docs/blob/master/faq.md");
+					File.load_url("https://github.com/armory3d/armorpaint_docs/blob/master/faq.md");
 				}
 			}
 		});
-		UIBox.clickToHide = false; // Prevent closing when going back to window from file browser
+		UIBox.click_to_hide = false; // Prevent closing when going back to window from file browser
 	}
 
-	static reimportMesh = () => {
-		if (Project.meshAssets != null && Project.meshAssets.length > 0 && File.exists(Project.meshAssets[0])) {
-			Project.importMeshBox(Project.meshAssets[0], true, false);
+	static reimport_mesh = () => {
+		if (Project.mesh_assets != null && Project.mesh_assets.length > 0 && File.exists(Project.mesh_assets[0])) {
+			Project.import_mesh_box(Project.mesh_assets[0], true, false);
 		}
-		else Project.importAsset();
+		else Project.import_asset();
 	}
 
-	static unwrapMeshBox = (mesh: any, done: (a: any)=>void, skipUI = false) => {
-		UIBox.showCustom((ui: zui_t) => {
-			let tabVertical = Config.raw.touch_ui;
+	static unwrap_mesh_box = (mesh: any, done: (a: any)=>void, skipUI: bool = false) => {
+		UIBox.show_custom((ui: zui_t) => {
+			let tabVertical: bool = Config.raw.touch_ui;
 			if (zui_tab(zui_handle("project_7"), tr("Unwrap Mesh"), tabVertical)) {
 
 				let unwrapPlugins: string[] = [];
-				if (BoxPreferences.filesPlugin == null) {
-					BoxPreferences.fetchPlugins();
+				if (BoxPreferences.files_plugin == null) {
+					BoxPreferences.fetch_plugins();
 				}
-				for (let f of BoxPreferences.filesPlugin) {
+				for (let f of BoxPreferences.files_plugin) {
 					if (f.indexOf("uv_unwrap") >= 0 && f.endsWith(".js")) {
 						unwrapPlugins.push(f);
 					}
 				}
 				unwrapPlugins.push("equirect");
 
-				let unwrapBy = zui_combo(zui_handle("project_8"), unwrapPlugins, tr("Plugin"), true);
+				let unwrapBy: i32 = zui_combo(zui_handle("project_8"), unwrapPlugins, tr("Plugin"), true);
 
 				zui_row([0.5, 0.5]);
 				if (zui_button(tr("Cancel"))) {
@@ -468,12 +468,12 @@ class Project {
 					UIBox.hide();
 					let doUnwrap = () => {
 						if (unwrapBy == unwrapPlugins.length - 1) {
-							UtilMesh.equirectUnwrap(mesh);
+							UtilMesh.equirect_unwrap(mesh);
 						}
 						else {
-							let f = unwrapPlugins[unwrapBy];
+							let f: string = unwrapPlugins[unwrapBy];
 							if (Config.raw.plugins.indexOf(f) == -1) {
-								Config.enablePlugin(f);
+								Config.enable_plugin(f);
 								Console.info(f + " " + tr("plugin enabled"));
 							}
 							UtilMesh.unwrappers.get(f)(mesh);
@@ -481,9 +481,9 @@ class Project {
 						done(mesh);
 					}
 					///if (krom_android || krom_ios)
-					Base.notifyOnNextFrame(() => {
+					Base.notify_on_next_frame(() => {
 						Console.toast(tr("Unwrapping mesh"));
-						Base.notifyOnNextFrame(doUnwrap);
+						Base.notify_on_next_frame(doUnwrap);
 					});
 					///else
 					doUnwrap();
@@ -493,55 +493,55 @@ class Project {
 		});
 	}
 
-	static importAsset = (filters: string = null, hdrAsEnvmap = true) => {
-		if (filters == null) filters = Path.textureFormats.join(",") + "," + Path.meshFormats.join(",");
+	static import_asset = (filters: string = null, hdrAsEnvmap: bool = true) => {
+		if (filters == null) filters = Path.texture_formats.join(",") + "," + Path.mesh_formats.join(",");
 		UIFiles.show(filters, false, true, (path: string) => {
 			ImportAsset.run(path, -1.0, -1.0, true, hdrAsEnvmap);
 		});
 	}
 
-	static importSwatches = (replaceExisting = false) => {
+	static import_swatches = (replaceExisting: bool = false) => {
 		UIFiles.show("arm,gpl", false, false, (path: string) => {
-			if (Path.isGimpColorPalette(path)) ImportGpl.run(path, replaceExisting);
-			else ImportArm.runSwatches(path, replaceExisting);
+			if (Path.is_gimp_color_palette(path)) ImportGpl.run(path, replaceExisting);
+			else ImportArm.run_swatches(path, replaceExisting);
 		});
 	}
 
-	static reimportTextures = () => {
+	static reimport_textures = () => {
 		for (let asset of Project.assets) {
-			Project.reimportTexture(asset);
+			Project.reimport_texture(asset);
 		}
 	}
 
-	static reimportTexture = (asset: TAsset) => {
+	static reimport_texture = (asset: asset_t) => {
 		let load = (path: string) => {
 			asset.file = path;
-			let i = Project.assets.indexOf(asset);
+			let i: i32 = Project.assets.indexOf(asset);
 			data_delete_image(asset.file);
-			Project.assetMap.delete(asset.id);
-			let oldAsset = Project.assets[i];
+			Project.asset_map.delete(asset.id);
+			let oldAsset: asset_t = Project.assets[i];
 			Project.assets.splice(i, 1);
-			Project.assetNames.splice(i, 1);
+			Project.asset_names.splice(i, 1);
 			ImportTexture.run(asset.file);
 			Project.assets.splice(i, 0, Project.assets.pop());
-			Project.assetNames.splice(i, 0, Project.assetNames.pop());
+			Project.asset_names.splice(i, 0, Project.asset_names.pop());
 
 			///if (is_paint || is_sculpt)
 			if (Context.raw.texture == oldAsset) Context.raw.texture = Project.assets[i];
 			///end
 
 			let _next = () => {
-				MakeMaterial.parsePaintMaterial();
+				MakeMaterial.parse_paint_material();
 
 				///if (is_paint || is_sculpt)
-				UtilRender.makeMaterialPreview();
-				UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+				UtilRender.make_material_preview();
+				UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 				///end
 			}
-			Base.notifyOnNextFrame(_next);
+			Base.notify_on_next_frame(_next);
 		}
 		if (!File.exists(asset.file)) {
-			let filters = Path.textureFormats.join(",");
+			let filters: string = Path.texture_formats.join(",");
 			UIFiles.show(filters, false, false, (path: string) => {
 				load(path);
 			});
@@ -549,79 +549,79 @@ class Project {
 		else load(asset.file);
 	}
 
-	static getImage = (asset: TAsset): image_t => {
-		return asset != null ? Project.assetMap.get(asset.id) : null;
+	static get_image = (asset: asset_t): image_t => {
+		return asset != null ? Project.asset_map.get(asset.id) : null;
 	}
 
 	///if (is_paint || is_sculpt)
-	static getUsedAtlases = (): string[] => {
-		if (Project.atlasObjects == null) return null;
+	static get_used_atlases = (): string[] => {
+		if (Project.atlas_objects == null) return null;
 		let used: i32[] = [];
-		for (let i of Project.atlasObjects) if (used.indexOf(i) == -1) used.push(i);
+		for (let i of Project.atlas_objects) if (used.indexOf(i) == -1) used.push(i);
 		if (used.length > 1) {
 			let res: string[] = [];
-			for (let i of used) res.push(Project.atlasNames[i]);
+			for (let i of used) res.push(Project.atlas_names[i]);
 			return res;
 		}
 		else return null;
 	}
 
-	static isAtlasObject = (p: mesh_object_t): bool => {
-		if (Context.raw.layerFilter <= Project.paintObjects.length) return false;
-		let atlasName = Project.getUsedAtlases()[Context.raw.layerFilter - Project.paintObjects.length - 1];
-		let atlasI = Project.atlasNames.indexOf(atlasName);
-		return atlasI == Project.atlasObjects[Project.paintObjects.indexOf(p)];
+	static is_atlas_object = (p: mesh_object_t): bool => {
+		if (Context.raw.layer_filter <= Project.paint_objects.length) return false;
+		let atlasName: string = Project.get_used_atlases()[Context.raw.layer_filter - Project.paint_objects.length - 1];
+		let atlasI: i32 = Project.atlas_names.indexOf(atlasName);
+		return atlasI == Project.atlas_objects[Project.paint_objects.indexOf(p)];
 	}
 
-	static getAtlasObjects = (objectMask: i32): mesh_object_t[] => {
-		let atlasName = Project.getUsedAtlases()[objectMask - Project.paintObjects.length - 1];
-		let atlasI = Project.atlasNames.indexOf(atlasName);
+	static get_atlas_objects = (objectMask: i32): mesh_object_t[] => {
+		let atlasName: string = Project.get_used_atlases()[objectMask - Project.paint_objects.length - 1];
+		let atlasI: i32 = Project.atlas_names.indexOf(atlasName);
 		let visibles: mesh_object_t[] = [];
-		for (let i = 0; i < Project.paintObjects.length; ++i) if (Project.atlasObjects[i] == atlasI) visibles.push(Project.paintObjects[i]);
+		for (let i: i32 = 0; i < Project.paint_objects.length; ++i) if (Project.atlas_objects[i] == atlasI) visibles.push(Project.paint_objects[i]);
 		return visibles;
 	}
 	///end
 
-	static packedAssetExists = (packed_assets: TPackedAsset[], name: string): bool => {
+	static packed_asset_exists = (packed_assets: packed_asset_t[], name: string): bool => {
 		for (let pa of packed_assets) if (pa.name == name) return true;
 		return false;
 	}
 
-	static exportSwatches = () => {
+	static export_swatches = () => {
 		UIFiles.show("arm,gpl", true, false, (path: string) => {
-			let f = UIFiles.filename;
+			let f: string = UIFiles.filename;
 			if (f == "") f = tr("untitled");
-			if (Path.isGimpColorPalette(f)) ExportGpl.run(path + Path.sep + f, f.substring(0, f.lastIndexOf(".")), Project.raw.swatches);
-			else ExportArm.runSwatches(path + Path.sep + f);
+			if (Path.is_gimp_color_palette(f)) ExportGpl.run(path + Path.sep + f, f.substring(0, f.lastIndexOf(".")), Project.raw.swatches);
+			else ExportArm.run_swatches(path + Path.sep + f);
 		});
 	}
 
-	static makeSwatch = (base = 0xffffffff): TSwatchColor => {
+	static make_swatch = (base: i32 = 0xffffffff): swatch_color_t => {
 		return { base: base, opacity: 1.0, occlusion: 1.0, roughness: 0.0, metallic: 0.0, normal: 0xff8080ff, emission: 0.0, height: 0.0, subsurface: 0.0 };
 	}
 
-	static cloneSwatch = (swatch: TSwatchColor): TSwatchColor => {
+	static clone_swatch = (swatch: swatch_color_t): swatch_color_t => {
 		return { base: swatch.base, opacity: swatch.opacity, occlusion: swatch.occlusion, roughness: swatch.roughness, metallic: swatch.metallic, normal: swatch.normal, emission: swatch.emission, height: swatch.height, subsurface: swatch.subsurface };
 	}
 
-	static setDefaultSwatches = () => {
+	static set_default_swatches = () => {
 		// 32-Color Palette by Andrew Kensler
 		// http://eastfarthing.com/blog/2016-05-06-palette/
 		Project.raw.swatches = [];
-		let colors = [0xffffffff, 0xff000000, 0xffd6a090, 0xffa12c32, 0xfffa2f7a, 0xfffb9fda, 0xffe61cf7, 0xff992f7c, 0xff47011f, 0xff051155, 0xff4f02ec, 0xff2d69cb, 0xff00a6ee, 0xff6febff, 0xff08a29a, 0xff2a666a, 0xff063619, 0xff4a4957, 0xff8e7ba4, 0xffb7c0ff, 0xffacbe9c, 0xff827c70, 0xff5a3b1c, 0xffae6507, 0xfff7aa30, 0xfff4ea5c, 0xff9b9500, 0xff566204, 0xff11963b, 0xff51e113, 0xff08fdcc];
-		for (let c of colors) Project.raw.swatches.push(Project.makeSwatch(c));
+		let colors: i32[] = [0xffffffff, 0xff000000, 0xffd6a090, 0xffa12c32, 0xfffa2f7a, 0xfffb9fda, 0xffe61cf7, 0xff992f7c, 0xff47011f, 0xff051155, 0xff4f02ec, 0xff2d69cb, 0xff00a6ee, 0xff6febff, 0xff08a29a, 0xff2a666a, 0xff063619, 0xff4a4957, 0xff8e7ba4, 0xffb7c0ff, 0xffacbe9c, 0xff827c70, 0xff5a3b1c, 0xffae6507, 0xfff7aa30, 0xfff4ea5c, 0xff9b9500, 0xff566204, 0xff11963b, 0xff51e113, 0xff08fdcc];
+		for (let c of colors) Project.raw.swatches.push(Project.make_swatch(c));
 	}
 
-	static getMaterialGroupByName = (groupName: string): TNodeGroup => {
-		for (let g of Project.materialGroups) if (g.canvas.name == groupName) return g;
+	static get_material_group_by_name = (groupName: string): node_group_t => {
+		for (let g of Project.material_groups) if (g.canvas.name == groupName) return g;
 		return null;
 	}
 
 	///if (is_paint || is_sculpt)
-	static isMaterialGroupInUse = (group: TNodeGroup): bool => {
+	static is_material_group_in_use = (group: node_group_t): bool => {
 		let canvases: zui_node_canvas_t[] = [];
 		for (let m of Project.materials) canvases.push(m.canvas);
-		for (let m of Project.materialGroups) canvases.push(m.canvas);
+		for (let m of Project.material_groups) canvases.push(m.canvas);
 		for (let canvas of canvases) {
 			for (let n of canvas.nodes) {
 				if (n.type == "GROUP" && n.name == group.canvas.name) {
@@ -634,7 +634,7 @@ class Project {
 	///end
 }
 
-type TNodeGroup = {
-	nodes: zui_nodes_t;
-	canvas: zui_node_canvas_t;
-}
+type node_group_t = {
+	nodes?: zui_nodes_t;
+	canvas?: zui_node_canvas_t;
+};

+ 54 - 54
base/Sources/ProjectFormat.ts

@@ -1,15 +1,15 @@
 
-type TProjectFormat = {
+type project_format_t = {
 	version?: string;
 	assets?: string[]; // texture_assets
 	is_bgra?: Null<bool>; // Swapped red and blue channels for layer textures
-	packed_assets?: TPackedAsset[];
+	packed_assets?: packed_asset_t[];
 	envmap?: string; // Asset name
 	envmap_strength?: Null<f32>;
 	camera_world?: Float32Array;
 	camera_origin?: Float32Array;
 	camera_fov?: Null<f32>;
-	swatches?: TSwatchColor[];
+	swatches?: swatch_color_t[];
 
 	///if (is_paint || is_sculpt)
 	brush_nodes?: zui_node_canvas_t[];
@@ -18,7 +18,7 @@ type TProjectFormat = {
 	material_groups?: zui_node_canvas_t[];
 	material_icons?: ArrayBuffer[];
 	font_assets?: string[];
-	layer_datas?: TLayerData[];
+	layer_datas?: layer_data_t[];
 	mesh_datas?: mesh_data_t[];
 	mesh_assets?: string[];
 	mesh_icons?: ArrayBuffer[];
@@ -35,61 +35,61 @@ type TProjectFormat = {
 	mesh_data?: mesh_data_t;
 	mesh_icon?: ArrayBuffer;
 	///end
-}
+};
 
-type TAsset = {
-	id: i32;
-	name: string;
-	file: string;
-}
+type asset_t = {
+	id?: i32;
+	name?: string;
+	file?: string;
+};
 
-type TPackedAsset = {
-	name: string;
-	bytes: ArrayBuffer;
-}
+type packed_asset_t = {
+	name?: string;
+	bytes?: ArrayBuffer;
+};
 
-type TSwatchColor = {
-	base: color_t;
-	opacity: f32;
-	occlusion: f32;
-	roughness: f32;
-	metallic: f32;
-	normal: color_t;
-	emission: f32;
-	height: f32;
-	subsurface: f32;
-}
+type swatch_color_t = {
+	base?: color_t;
+	opacity?: f32;
+	occlusion?: f32;
+	roughness?: f32;
+	metallic?: f32;
+	normal?: color_t;
+	emission?: f32;
+	height?: f32;
+	subsurface?: f32;
+};
 
 ///if (is_paint || is_sculpt)
-type TLayerData = {
-	name: string;
-	res: i32; // Width pixels
-	bpp: i32; // Bits per pixel
-	texpaint: ArrayBuffer;
-	uv_scale: f32;
-	uv_rot: f32;
-	uv_type: i32;
-	decal_mat: Float32Array;
-	opacity_mask: f32;
-	fill_layer: i32;
-	object_mask: i32;
-	blending: i32;
-	parent: i32;
-	visible: bool;
+type layer_data_t = {
+	name?: string;
+	res?: i32; // Width pixels
+	bpp?: i32; // Bits per pixel
+	texpaint?: ArrayBuffer;
+	uv_scale?: f32;
+	uv_rot?: f32;
+	uv_type?: i32;
+	decal_mat?: Float32Array;
+	opacity_mask?: f32;
+	fill_layer?: i32;
+	object_mask?: i32;
+	blending?: i32;
+	parent?: i32;
+	visible?: bool;
 	///if is_paint
-	texpaint_nor: ArrayBuffer;
-	texpaint_pack: ArrayBuffer;
-	paint_base: bool;
-	paint_opac: bool;
-	paint_occ: bool;
-	paint_rough: bool;
-	paint_met: bool;
-	paint_nor: bool;
-	paint_nor_blend: bool;
-	paint_height: bool;
-	paint_height_blend: bool;
-	paint_emis: bool;
-	paint_subs: bool;
+	texpaint_nor?: ArrayBuffer;
+	texpaint_pack?: ArrayBuffer;
+	paint_base?: bool;
+	paint_opac?: bool;
+	paint_occ?: bool;
+	paint_rough?: bool;
+	paint_met?: bool;
+	paint_nor?: bool;
+	paint_nor_blend?: bool;
+	paint_height?: bool;
+	paint_height_blend?: bool;
+	paint_emis?: bool;
+	paint_subs?: bool;
 	///end
-}
+};
 ///end

+ 153 - 153
base/Sources/RenderPathBase.ts

@@ -1,34 +1,34 @@
 
 class RenderPathBase {
 
-	static taaFrame = 0;
-	static superSample = 1.0;
-	static lastX = -1.0;
-	static lastY = -1.0;
-	static bloomMipmaps: render_target_t[];
-	static bloomCurrentMip = 0;
-	static bloomSampleScale: f32;
+	static taa_frame: i32 = 0;
+	static super_sample: f32 = 1.0;
+	static last_x: f32 = -1.0;
+	static last_y: f32 = -1.0;
+	static bloom_mipmaps: render_target_t[];
+	static bloom_current_mip: i32 = 0;
+	static bloom_sample_scale: f32;
 	///if arm_voxels
-	static voxelsRes = 256;
-	static voxelsCreated = false;
+	static voxels_res: i32 = 256;
+	static voxels_created: bool = false;
 	///end
 
 	static init = () => {
-		RenderPathBase.superSample = Config.raw.rp_supersample;
+		RenderPathBase.super_sample = Config.raw.rp_supersample;
 	}
 
 	///if arm_voxels
-	static initVoxels = (targetName = "voxels") => {
-		if (Config.raw.rp_gi != true || RenderPathBase.voxelsCreated) return;
-		RenderPathBase.voxelsCreated = true;
+	static init_voxels = (targetName: string = "voxels") => {
+		if (Config.raw.rp_gi != true || RenderPathBase.voxels_created) return;
+		RenderPathBase.voxels_created = true;
 
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = targetName;
 			t.format = "R8";
-			t.width = RenderPathBase.voxelsRes;
-			t.height = RenderPathBase.voxelsRes;
-			t.depth = RenderPathBase.voxelsRes;
+			t.width = RenderPathBase.voxels_res;
+			t.height = RenderPathBase.voxels_res;
+			t.depth = RenderPathBase.voxels_res;
 			t.is_image = true;
 			t.mipmaps = true;
 			render_path_create_render_target(t);
@@ -36,37 +36,37 @@ class RenderPathBase {
 	}
 	///end
 
-	static applyConfig = () => {
-		if (RenderPathBase.superSample != Config.raw.rp_supersample) {
-			RenderPathBase.superSample = Config.raw.rp_supersample;
+	static apply_config = () => {
+		if (RenderPathBase.super_sample != Config.raw.rp_supersample) {
+			RenderPathBase.super_sample = Config.raw.rp_supersample;
 			for (let rt of render_path_render_targets.values()) {
 				if (rt.width == 0 && rt.scale != null) {
-					rt.scale = RenderPathBase.superSample;
+					rt.scale = RenderPathBase.super_sample;
 				}
 			}
 			render_path_resize();
 		}
 		///if arm_voxels
-		if (!RenderPathBase.voxelsCreated) RenderPathBase.initVoxels();
+		if (!RenderPathBase.voxels_created) RenderPathBase.init_voxels();
 		///end
 	}
 
-	static getSuperSampling = (): f32 => {
-		return RenderPathBase.superSample;
+	static get_super_sampling = (): f32 => {
+		return RenderPathBase.super_sample;
 	}
 
-	static drawCompass = () => {
-		if (Context.raw.showCompass) {
-			let cam = scene_camera;
+	static draw_compass = () => {
+		if (Context.raw.show_compass) {
+			let cam: camera_object_t = scene_camera;
 			let compass: mesh_object_t = scene_get_child(".Compass").ext;
 
-			let _visible = compass.base.visible;
-			let _parent = compass.base.parent;
-			let _loc = compass.base.transform.loc;
-			let _rot = compass.base.transform.rot;
-			let crot = cam.base.transform.rot;
-			let ratio = app_w() / app_h();
-			let _P = cam.p;
+			let _visible: bool = compass.base.visible;
+			let _parent: object = compass.base.parent;
+			let _loc: vec4_t = compass.base.transform.loc;
+			let _rot: quat_t = compass.base.transform.rot;
+			let crot: quat_t = cam.base.transform.rot;
+			let ratio: f32 = app_w() / app_h();
+			let _P: mat4_t = cam.p;
 			cam.p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2);
 			compass.base.visible = true;
 			compass.base.parent = cam.base;
@@ -88,68 +88,68 @@ class RenderPathBase {
 
 	static begin = () => {
 		// Begin split
-		if (Context.raw.splitView && !Context.raw.paint2dView) {
-			if (Context.raw.viewIndexLast == -1 && Context.raw.viewIndex == -1) {
+		if (Context.raw.split_view && !Context.raw.paint2d_view) {
+			if (Context.raw.view_index_last == -1 && Context.raw.view_index == -1) {
 				// Begin split, draw right viewport first
-				Context.raw.viewIndex = 1;
+				Context.raw.view_index = 1;
 			}
 			else {
 				// Set current viewport
-				Context.raw.viewIndex = mouse_view_x() > Base.w() / 2 ? 1 : 0;
+				Context.raw.view_index = mouse_view_x() > Base.w() / 2 ? 1 : 0;
 			}
 
-			let cam = scene_camera;
-			if (Context.raw.viewIndexLast > -1) {
+			let cam: camera_object_t = scene_camera;
+			if (Context.raw.view_index_last > -1) {
 				// Save current viewport camera
-				mat4_set_from(Camera.views[Context.raw.viewIndexLast], cam.base.transform.local);
+				mat4_set_from(Camera.views[Context.raw.view_index_last], cam.base.transform.local);
 			}
 
-			let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
+			let decal: bool = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
 
-			if (Context.raw.viewIndexLast != Context.raw.viewIndex || decal || !Config.raw.brush_3d) {
+			if (Context.raw.view_index_last != Context.raw.view_index || decal || !Config.raw.brush_3d) {
 				// Redraw on current viewport change
 				Context.raw.ddirty = 1;
 			}
 
-			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]);
+			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.view_index]);
 			camera_object_build_mat(cam);
 			camera_object_build_proj(cam);
 		}
 
 		// Match projection matrix jitter
-		let skipTaa = Context.raw.splitView || ((Context.raw.tool == WorkspaceTool.ToolClone || Context.raw.tool == WorkspaceTool.ToolBlur || Context.raw.tool == WorkspaceTool.ToolSmudge) && Context.raw.pdirty > 0);
-		scene_camera.frame = skipTaa ? 0 : RenderPathBase.taaFrame;
+		let skipTaa: bool = Context.raw.split_view || ((Context.raw.tool == workspace_tool_t.CLONE || Context.raw.tool == workspace_tool_t.BLUR || Context.raw.tool == workspace_tool_t.SMUDGE) && Context.raw.pdirty > 0);
+		scene_camera.frame = skipTaa ? 0 : RenderPathBase.taa_frame;
 		camera_object_proj_jitter(scene_camera);
 		camera_object_build_mat(scene_camera);
 	}
 
 	static end = () => {
 		// End split
-		Context.raw.viewIndexLast = Context.raw.viewIndex;
-		Context.raw.viewIndex = -1;
+		Context.raw.view_index_last = Context.raw.view_index;
+		Context.raw.view_index = -1;
 
-		if (Context.raw.foregroundEvent && !mouse_down()) {
-			Context.raw.foregroundEvent = false;
+		if (Context.raw.foreground_event && !mouse_down()) {
+			Context.raw.foreground_event = false;
 			Context.raw.pdirty = 0;
 		}
 
-		RenderPathBase.taaFrame++;
+		RenderPathBase.taa_frame++;
 	}
 
 	static ssaa4 = (): bool => {
 		return Config.raw.rp_supersample == 4;
 	}
 
-	static isCached = (): bool => {
+	static is_cached = (): bool => {
 		if (sys_width() == 0 || sys_height() == 0) return true;
 
-		let mx = RenderPathBase.lastX;
-		let my = RenderPathBase.lastY;
-		RenderPathBase.lastX = mouse_view_x();
-		RenderPathBase.lastY = mouse_view_y();
+		let mx: f32 = RenderPathBase.last_x;
+		let my: f32 = RenderPathBase.last_y;
+		RenderPathBase.last_x = mouse_view_x();
+		RenderPathBase.last_y = mouse_view_y();
 
 		if (Context.raw.ddirty <= 0 && Context.raw.rdirty <= 0 && Context.raw.pdirty <= 0) {
-			if (mx != RenderPathBase.lastX || my != RenderPathBase.lastY || mouse_locked) Context.raw.ddirty = 0;
+			if (mx != RenderPathBase.last_x || my != RenderPathBase.last_y || mouse_locked) Context.raw.ddirty = 0;
 			///if (krom_metal || krom_android)
 			if (Context.raw.ddirty > -6) {
 			///else
@@ -160,7 +160,7 @@ class RenderPathBase {
 				RenderPathBase.ssaa4() ?
 					render_path_draw_shader("shader_datas/supersample_resolve/supersample_resolve") :
 					render_path_draw_shader("shader_datas/copy_pass/copy_pass");
-				RenderPathPaint.commandsCursor();
+				RenderPathPaint.commands_cursor();
 				if (Context.raw.ddirty <= 0) Context.raw.ddirty--;
 			}
 			RenderPathBase.end();
@@ -169,116 +169,116 @@ class RenderPathBase {
 		return false;
 	}
 
-	static commands = (drawCommands: ()=>void) => {
-		if (RenderPathBase.isCached()) return;
+	static commands = (draw_commands: ()=>void) => {
+		if (RenderPathBase.is_cached()) return;
 		RenderPathBase.begin();
 
 		RenderPathPaint.begin();
-		RenderPathBase.drawSplit(drawCommands);
-		RenderPathBase.drawGbuffer();
+		RenderPathBase.draw_split(draw_commands);
+		RenderPathBase.draw_gbuffer();
 		RenderPathPaint.draw();
 
 		///if (krom_direct3d12 || krom_vulkan || krom_metal)
-		if (Context.raw.viewportMode ==  ViewportMode.ViewPathTrace) {
+		if (Context.raw.viewport_mode ==  viewport_mode_t.PATH_TRACE) {
 			///if is_paint
-			let useLiveLayer = Context.raw.tool == WorkspaceTool.ToolMaterial;
+			let useLiveLayer: bool = Context.raw.tool == workspace_tool_t.MATERIAL;
 			///else
-			let useLiveLayer = false;
+			let useLiveLayer: bool = false;
 			///end
 			RenderPathRaytrace.draw(useLiveLayer);
 			return;
 		}
 		///end
 
-		drawCommands();
+		draw_commands();
 		RenderPathPaint.end();
 		RenderPathBase.end();
 	}
 
-	static drawBloom = (tex = "tex") => {
+	static draw_bloom = (tex: string = "tex") => {
 		if (Config.raw.rp_bloom != false) {
-			if (RenderPathBase.bloomMipmaps == null) {
-				RenderPathBase.bloomMipmaps = [];
+			if (RenderPathBase.bloom_mipmaps == null) {
+				RenderPathBase.bloom_mipmaps = [];
 
-				let prevScale = 1.0;
-				for (let i = 0; i < 10; ++i) {
-					let t = render_target_create();
+				let prevScale: f32 = 1.0;
+				for (let i: i32 = 0; i < 10; ++i) {
+					let t: render_target_t = render_target_create();
 					t.name = "bloom_mip_" + i;
 					t.width = 0;
 					t.height = 0;
 					t.scale = (prevScale *= 0.5);
 					t.format = "RGBA64";
-					RenderPathBase.bloomMipmaps.push(render_path_create_render_target(t));
+					RenderPathBase.bloom_mipmaps.push(render_path_create_render_target(t));
 				}
 
 				render_path_load_shader("shader_datas/bloom_pass/bloom_downsample_pass");
 				render_path_load_shader("shader_datas/bloom_pass/bloom_upsample_pass");
 			}
 
-			let bloomRadius = 6.5;
-			let minDim = Math.min(render_path_current_w,render_path_current_h);
-			let logMinDim = Math.max(1.0, Math.log2(minDim) + (bloomRadius - 8.0));
-			let numMips = Math.floor(logMinDim);
-			RenderPathBase.bloomSampleScale = 0.5 + logMinDim - numMips;
+			let bloomRadius: f32 = 6.5;
+			let minDim: f32 = Math.min(render_path_current_w,render_path_current_h);
+			let logMinDim: f32 = Math.max(1.0, Math.log2(minDim) + (bloomRadius - 8.0));
+			let numMips: i32 = Math.floor(logMinDim);
+			RenderPathBase.bloom_sample_scale = 0.5 + logMinDim - numMips;
 
-			for (let i = 0; i < numMips; ++i) {
-				RenderPathBase.bloomCurrentMip = i;
-				render_path_set_target(RenderPathBase.bloomMipmaps[i].name);
+			for (let i: i32 = 0; i < numMips; ++i) {
+				RenderPathBase.bloom_current_mip = i;
+				render_path_set_target(RenderPathBase.bloom_mipmaps[i].name);
 				render_path_clear_target();
-				render_path_bind_target(i == 0 ? tex : RenderPathBase.bloomMipmaps[i - 1].name, "tex");
+				render_path_bind_target(i == 0 ? tex : RenderPathBase.bloom_mipmaps[i - 1].name, "tex");
 				render_path_draw_shader("shader_datas/bloom_pass/bloom_downsample_pass");
 			}
-			for (let i = 0; i < numMips; ++i) {
-				let mipLevel = numMips - 1 - i;
-				RenderPathBase.bloomCurrentMip = mipLevel;
-				render_path_set_target(mipLevel == 0 ? tex : RenderPathBase.bloomMipmaps[mipLevel - 1].name);
-				render_path_bind_target(RenderPathBase.bloomMipmaps[mipLevel].name, "tex");
+			for (let i: i32 = 0; i < numMips; ++i) {
+				let mipLevel: i32 = numMips - 1 - i;
+				RenderPathBase.bloom_current_mip = mipLevel;
+				render_path_set_target(mipLevel == 0 ? tex : RenderPathBase.bloom_mipmaps[mipLevel - 1].name);
+				render_path_bind_target(RenderPathBase.bloom_mipmaps[mipLevel].name, "tex");
 				render_path_draw_shader("shader_datas/bloom_pass/bloom_upsample_pass");
 			}
 		}
 	}
 
-	static drawSplit = (drawCommands: ()=>void) => {
-		if (Context.raw.splitView && !Context.raw.paint2dView) {
+	static draw_split = (drawCommands: ()=>void) => {
+		if (Context.raw.split_view && !Context.raw.paint2d_view) {
 			Context.raw.ddirty = 2;
-			let cam = scene_camera;
+			let cam: camera_object_t = scene_camera;
 
-			Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0;
-			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]);
+			Context.raw.view_index = Context.raw.view_index == 0 ? 1 : 0;
+			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.view_index]);
 			camera_object_build_mat(cam);
 			camera_object_build_proj(cam);
 
-			RenderPathBase.drawGbuffer();
+			RenderPathBase.draw_gbuffer();
 
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
 			///if is_paint
-			let useLiveLayer = Context.raw.tool == WorkspaceTool.ToolMaterial;
+			let useLiveLayer: bool = Context.raw.tool == workspace_tool_t.MATERIAL;
 			///else
-			let useLiveLayer = false;
+			let useLiveLayer: bool = false;
 			///end
-			Context.raw.viewportMode == ViewportMode.ViewPathTrace ? RenderPathRaytrace.draw(useLiveLayer) : drawCommands();
+			Context.raw.viewport_mode == viewport_mode_t.PATH_TRACE ? RenderPathRaytrace.draw(useLiveLayer) : drawCommands();
 			///else
 			drawCommands();
 			///end
 
-			Context.raw.viewIndex = Context.raw.viewIndex == 0 ? 1 : 0;
-			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.viewIndex]);
+			Context.raw.view_index = Context.raw.view_index == 0 ? 1 : 0;
+			transform_set_matrix(cam.base.transform, Camera.views[Context.raw.view_index]);
 			camera_object_build_mat(cam);
 			camera_object_build_proj(cam);
 		}
 	}
 
 	///if arm_voxels
-	static drawVoxels = () => {
+	static draw_voxels = () => {
 		if (Config.raw.rp_gi != false) {
-			let voxelize = Context.raw.ddirty > 0 && RenderPathBase.taaFrame > 0;
+			let voxelize: bool = Context.raw.ddirty > 0 && RenderPathBase.taa_frame > 0;
 			if (voxelize) {
 				render_path_clear_image("voxels", 0x00000000);
 				render_path_set_target("");
-				render_path_set_viewport(RenderPathBase.voxelsRes, RenderPathBase.voxelsRes);
+				render_path_set_viewport(RenderPathBase.voxels_res, RenderPathBase.voxels_res);
 				render_path_bind_target("voxels", "voxels");
 				if (MakeMaterial.heightUsed) {
-					let tid = 0; // Project.layers[0].id;
+					let tid: i32 = 0; // Project.layers[0].id;
 					render_path_bind_target("texpaint_pack" + tid, "texpaint_pack");
 				}
 				render_path_draw_meshes("voxel");
@@ -288,23 +288,23 @@ class RenderPathBase {
 	}
 	///end
 
-	static initSSAO = () => {
+	static init_ssao = () => {
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "singlea";
 			t.width = 0;
 			t.height = 0;
 			t.format = "R8";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "singleb";
 			t.width = 0;
 			t.height = 0;
 			t.format = "R8";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		render_path_load_shader("shader_datas/ssao_pass/ssao_pass");
@@ -312,11 +312,11 @@ class RenderPathBase {
 		render_path_load_shader("shader_datas/ssao_blur_pass/ssao_blur_pass_y");
 	}
 
-	static drawSSAO = () => {
-		let ssao = Config.raw.rp_ssao != false && Context.raw.cameraType == CameraType.CameraPerspective;
-		if (ssao && Context.raw.ddirty > 0 && RenderPathBase.taaFrame > 0) {
+	static draw_ssao = () => {
+		let ssao: bool = Config.raw.rp_ssao != false && Context.raw.camera_type == camera_type_t.PERSPECTIVE;
+		if (ssao && Context.raw.ddirty > 0 && RenderPathBase.taa_frame > 0) {
 			if (render_path_render_targets.get("singlea") == null) {
-				RenderPathBase.initSSAO();
+				RenderPathBase.init_ssao();
 			}
 
 			render_path_set_target("singlea");
@@ -336,20 +336,20 @@ class RenderPathBase {
 		}
 	}
 
-	static drawDeferredLight = () => {
+	static draw_deferred_light = () => {
 		render_path_set_target("tex");
 		render_path_bind_target("_main", "gbufferD");
 		render_path_bind_target("gbuffer0", "gbuffer0");
 		render_path_bind_target("gbuffer1", "gbuffer1");
-		let ssao = Config.raw.rp_ssao != false && Context.raw.cameraType == CameraType.CameraPerspective;
-		if (ssao && RenderPathBase.taaFrame > 0) {
+		let ssao: bool = Config.raw.rp_ssao != false && Context.raw.camera_type == camera_type_t.PERSPECTIVE;
+		if (ssao && RenderPathBase.taa_frame > 0) {
 			render_path_bind_target("singlea", "ssaotex");
 		}
 		else {
 			render_path_bind_target("empty_white", "ssaotex");
 		}
 
-		let voxelao_pass = false;
+		let voxelao_pass: bool = false;
 		///if arm_voxels
 		if (Config.raw.rp_gi != false) {
 			voxelao_pass = true;
@@ -373,11 +373,11 @@ class RenderPathBase {
 		///end
 	}
 
-	static drawSSR = () => {
+	static draw_ssr = () => {
 		if (Config.raw.rp_ssr != false) {
 			if (_render_path_cached_shader_contexts.get("shader_datas/ssr_pass/ssr_pass") == null) {
 				{
-					let t = render_target_create();
+					let t: render_target_t = render_target_create();
 					t.name = "bufb";
 					t.width = 0;
 					t.height = 0;
@@ -388,8 +388,8 @@ class RenderPathBase {
 				render_path_load_shader("shader_datas/ssr_blur_pass/ssr_blur_pass_x");
 				render_path_load_shader("shader_datas/ssr_blur_pass/ssr_blur_pass_y3_blend");
 			}
-			let targeta = "bufb";
-			let targetb = "gbuffer1";
+			let targeta: string = "bufb";
+			let targetb: string = "gbuffer1";
 
 			render_path_set_target(targeta);
 			render_path_bind_target("tex", "tex");
@@ -410,7 +410,7 @@ class RenderPathBase {
 		}
 	}
 
-	// static drawMotionBlur = () => {
+	// static draw_motion_blur = () => {
 	// 	if (Config.raw.rp_motionblur != false) {
 	// 		render_path_set_target("buf");
 	// 		render_path_bind_target("tex", "tex");
@@ -432,9 +432,9 @@ class RenderPathBase {
 	// 	}
 	// }
 
-	// static drawHistogram = () => {
+	// static draw_histogram = () => {
 	// 	{
-	// 		let t = RenderTarget.create();
+	// 		let t: render_target_t = RenderTarget.create();
 	// 		t.name = "histogram";
 	// 		t.width = 1;
 	// 		t.height = 1;
@@ -449,9 +449,9 @@ class RenderPathBase {
 	// 	render_path_draw_shader("shader_datas/histogram_pass/histogram_pass");
 	// }
 
-	static drawTAA = () => {
-		let current = RenderPathBase.taaFrame % 2 == 0 ? "buf2" : "taa2";
-		let last = RenderPathBase.taaFrame % 2 == 0 ? "taa2" : "buf2";
+	static draw_taa = () => {
+		let current: string = RenderPathBase.taa_frame % 2 == 0 ? "buf2" : "taa2";
+		let last: string = RenderPathBase.taa_frame % 2 == 0 ? "taa2" : "buf2";
 
 		render_path_set_target(current);
 		render_path_clear_target(0x00000000);
@@ -469,7 +469,7 @@ class RenderPathBase {
 		render_path_bind_target("gbuffer2", "sveloc");
 		render_path_draw_shader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
 
-		let skipTaa = Context.raw.splitView;
+		let skipTaa: bool = Context.raw.split_view;
 		if (skipTaa) {
 			render_path_set_target("taa");
 			render_path_bind_target(current, "tex");
@@ -485,37 +485,37 @@ class RenderPathBase {
 
 		if (RenderPathBase.ssaa4()) {
 			render_path_set_target("");
-			render_path_bind_target(RenderPathBase.taaFrame % 2 == 0 ? "taa2" : "taa", "tex");
+			render_path_bind_target(RenderPathBase.taa_frame % 2 == 0 ? "taa2" : "taa", "tex");
 			render_path_draw_shader("shader_datas/supersample_resolve/supersample_resolve");
 		}
 		else {
 			render_path_set_target("");
-			render_path_bind_target(RenderPathBase.taaFrame == 0 ? current : "taa", "tex");
+			render_path_bind_target(RenderPathBase.taa_frame == 0 ? current : "taa", "tex");
 			render_path_draw_shader("shader_datas/copy_pass/copy_pass");
 		}
 	}
 
-	static drawGbuffer = () => {
+	static draw_gbuffer = () => {
 		render_path_set_target("gbuffer0"); // Only clear gbuffer0
 		///if krom_metal
 		render_path_clear_target(0x00000000, 1.0, clear_flag_t.COLOR | clear_flag_t.DEPTH);
 		///else
 		render_path_clear_target(null, 1.0, clear_flag_t.DEPTH);
 		///end
-		if (MakeMesh.layerPassCount == 1) {
+		if (MakeMesh.layer_pass_count == 1) {
 			render_path_set_target("gbuffer2");
 			render_path_clear_target(0xff000000);
 		}
 		render_path_set_target("gbuffer0", ["gbuffer1", "gbuffer2"]);
-		RenderPathPaint.bindLayers();
+		RenderPathPaint.bind_layers();
 		render_path_draw_meshes("mesh");
-		RenderPathPaint.unbindLayers();
-		if (MakeMesh.layerPassCount > 1) {
-			RenderPathBase.makeGbufferCopyTextures();
-			for (let i = 1; i < MakeMesh.layerPassCount; ++i) {
-				let ping = i % 2 == 1 ? "_copy" : "";
-				let pong = i % 2 == 1 ? "" : "_copy";
-				if (i == MakeMesh.layerPassCount - 1) {
+		RenderPathPaint.unbind_layers();
+		if (MakeMesh.layer_pass_count > 1) {
+			RenderPathBase.make_gbuffer_copy_textures();
+			for (let i: i32 = 1; i < MakeMesh.layer_pass_count; ++i) {
+				let ping: string = i % 2 == 1 ? "_copy" : "";
+				let pong: string = i % 2 == 1 ? "" : "_copy";
+				if (i == MakeMesh.layer_pass_count - 1) {
 					render_path_set_target("gbuffer2" + ping);
 					render_path_clear_target(0xff000000);
 				}
@@ -523,49 +523,49 @@ class RenderPathBase {
 				render_path_bind_target("gbuffer0" + pong, "gbuffer0");
 				render_path_bind_target("gbuffer1" + pong, "gbuffer1");
 				render_path_bind_target("gbuffer2" + pong, "gbuffer2");
-				RenderPathPaint.bindLayers();
+				RenderPathPaint.bind_layers();
 				render_path_draw_meshes("mesh" + i);
-				RenderPathPaint.unbindLayers();
+				RenderPathPaint.unbind_layers();
 			}
-			if (MakeMesh.layerPassCount % 2 == 0) {
-				RenderPathBase.copyToGbuffer();
+			if (MakeMesh.layer_pass_count % 2 == 0) {
+				RenderPathBase.copy_to_gbuffer();
 			}
 		}
 
-		let hide = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown) || keyboard_down("control");
-		let isDecal = Base.isDecalLayer();
+		let hide: bool = Operator.shortcut(Config.keymap.stencil_hide, ShortcutType.ShortcutDown) || keyboard_down("control");
+		let isDecal: bool = Base.is_decal_layer();
 		if (isDecal && !hide) LineDraw.render(Context.raw.layer.decalMat);
 	}
 
-	static makeGbufferCopyTextures = () => {
-		let copy = render_path_render_targets.get("gbuffer0_copy");
+	static make_gbuffer_copy_textures = () => {
+		let copy: render_target_t = render_path_render_targets.get("gbuffer0_copy");
 		if (copy == null || copy._image.width != render_path_render_targets.get("gbuffer0")._image.width || copy._image.height != render_path_render_targets.get("gbuffer0")._image.height) {
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "gbuffer0_copy";
 				t.width = 0;
 				t.height = 0;
 				t.format = "RGBA64";
-				t.scale = RenderPathBase.getSuperSampling();
+				t.scale = RenderPathBase.get_super_sampling();
 				t.depth_buffer = "main";
 				render_path_create_render_target(t);
 			}
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "gbuffer1_copy";
 				t.width = 0;
 				t.height = 0;
 				t.format = "RGBA64";
-				t.scale = RenderPathBase.getSuperSampling();
+				t.scale = RenderPathBase.get_super_sampling();
 				render_path_create_render_target(t);
 			}
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "gbuffer2_copy";
 				t.width = 0;
 				t.height = 0;
 				t.format = "RGBA64";
-				t.scale = RenderPathBase.getSuperSampling();
+				t.scale = RenderPathBase.get_super_sampling();
 				render_path_create_render_target(t);
 			}
 
@@ -577,7 +577,7 @@ class RenderPathBase {
 		}
 	}
 
-	static copyToGbuffer = () => {
+	static copy_to_gbuffer = () => {
 		render_path_set_target("gbuffer0", ["gbuffer1", "gbuffer2"]);
 		render_path_bind_target("gbuffer0_copy", "tex0");
 		render_path_bind_target("gbuffer1_copy", "tex1");

+ 38 - 38
base/Sources/RenderPathDeferred.ts

@@ -5,47 +5,47 @@ class RenderPathDeferred {
 		render_path_create_depth_buffer("main", "DEPTH24");
 
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "gbuffer0";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			t.depth_buffer = "main";
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "gbuffer1";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "gbuffer2";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "tex";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			///if krom_opengl
 			t.depth_buffer = "main";
 			///end
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "buf";
 			t.width = 0;
 			t.height = 0;
@@ -56,56 +56,56 @@ class RenderPathDeferred {
 			///else
 			t.format = "RGBA32";
 			///end
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "buf2";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA32";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "taa";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA32";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "taa2";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA32";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "empty_white";
 			t.width = 1;
 			t.height = 1;
 			t.format = "R8";
-			let b = new ArrayBuffer(1);
-			let v = new DataView(b);
+			let b: ArrayBuffer = new ArrayBuffer(1);
+			let v: DataView = new DataView(b);
 			v.setUint8(0, 255);
 			t._image = image_from_bytes(b, t.width, t.height, tex_format_t.R8);
 			render_path_render_targets.set(t.name, t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "empty_black";
 			t.width = 1;
 			t.height = 1;
 			t.format = "RGBA32";
-			let b = new ArrayBuffer(4);
-			let v = new DataView(b);
+			let b: ArrayBuffer = new ArrayBuffer(4);
+			let v: DataView = new DataView(b);
 			v.setUint8(0, 0);
 			v.setUint8(1, 0);
 			v.setUint8(2, 0);
@@ -116,27 +116,27 @@ class RenderPathDeferred {
 
 		///if is_sculpt
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "gbuffer0_undo";
 			t.width = 0;
 			t.height = 0;
 			t.format = "RGBA64";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		{
-			let t = render_target_create();
+			let t: render_target_t = render_target_create();
 			t.name = "gbufferD_undo";
 			t.width = 0;
 			t.height = 0;
 			t.format = "R32";
-			t.scale = RenderPathBase.getSuperSampling();
+			t.scale = RenderPathBase.get_super_sampling();
 			render_path_create_render_target(t);
 		}
 		///end
 
 		if (Config.raw.rp_ssao) {
-			RenderPathBase.initSSAO();
+			RenderPathBase.init_ssao();
 		}
 
 		render_path_load_shader("shader_datas/world_pass/world_pass");
@@ -153,7 +153,7 @@ class RenderPathDeferred {
 		// render_path_load_shader("shader_datas/motion_blur_veloc_pass/motion_blur_veloc_pass");
 		///if arm_voxels
 		{
-			RenderPathBase.initVoxels();
+			RenderPathBase.init_voxels();
 			render_path_load_shader("shader_datas/deferred_light/deferred_light_voxel");
 		}
 		///end
@@ -171,19 +171,19 @@ class RenderPathDeferred {
 
 	static commands = () => {
 		///if is_paint
-		RenderPathPaint.liveBrushDirty();
+		RenderPathPaint.live_brush_dirty();
 		///end
-		RenderPathBase.commands(RenderPathDeferred.drawDeferred);
+		RenderPathBase.commands(RenderPathDeferred.draw_deferred);
 	}
 
-	static drawDeferred = () => {
-		RenderPathBase.drawSSAO();
+	static draw_deferred = () => {
+		RenderPathBase.draw_ssao();
 		///if arm_voxels
-		RenderPathBase.drawVoxels();
+		RenderPathBase.draw_voxels();
 		///end
-		RenderPathBase.drawDeferredLight();
-		RenderPathBase.drawBloom();
-		RenderPathBase.drawSSR();
+		RenderPathBase.draw_deferred_light();
+		RenderPathBase.draw_bloom();
+		RenderPathBase.draw_ssr();
 		// RenderPathBase.drawMotionBlur();
 		// RenderPathBase.drawHistogram();
 
@@ -193,9 +193,9 @@ class RenderPathDeferred {
 		render_path_draw_shader("shader_datas/compositor_pass/compositor_pass");
 
 		render_path_set_target("buf");
-		RenderPathBase.drawCompass();
+		RenderPathBase.draw_compass();
 		render_path_draw_meshes("overlay");
 
-		RenderPathBase.drawTAA();
+		RenderPathBase.draw_taa();
 	}
 }

+ 5 - 5
base/Sources/RenderPathForward.ts

@@ -6,12 +6,12 @@ class RenderPathForward {
 
 	static commands = () => {
 		///if is_paint
-		RenderPathPaint.liveBrushDirty();
+		RenderPathPaint.live_brush_dirty();
 		///end
-		RenderPathBase.commands(RenderPathForward.drawForward);
+		RenderPathBase.commands(RenderPathForward.draw_forward);
 	}
 
-	static drawForward = () => {
+	static draw_forward = () => {
 		render_path_set_depth_from("gbuffer1", "gbuffer0");
 		render_path_set_target("gbuffer1");
 		render_path_draw_skydome("shader_datas/world_pass/world_pass");
@@ -22,9 +22,9 @@ class RenderPathForward {
 		render_path_draw_shader("shader_datas/compositor_pass/compositor_pass");
 
 		render_path_set_target("buf");
-		RenderPathBase.drawCompass();
+		RenderPathBase.draw_compass();
 		render_path_draw_meshes("overlay");
 
-		RenderPathBase.drawTAA();
+		RenderPathBase.draw_taa();
 	}
 }

+ 75 - 78
base/Sources/RenderPathRaytrace.ts

@@ -3,71 +3,71 @@
 
 class RenderPathRaytrace {
 
-	static frame = 0;
-	static ready = false;
-	static dirty = 0;
-	static uvScale = 1.0;
-	static first = true;
-	static f32a = new Float32Array(24);
-	static helpMat = mat4_identity();
-	static vb_scale = 1.0;
+	static frame: i32 = 0;
+	static ready: bool = false;
+	static dirty: i32 = 0;
+	static uv_scale: f32 = 1.0;
+	static first: bool = true;
+	static f32a: Float32Array = new Float32Array(24);
+	static help_mat: mat4_t = mat4_identity();
+	static vb_scale: f32 = 1.0;
 	static vb: vertex_buffer_t;
 	static ib: index_buffer_t;
 
-	static lastEnvmap: image_t = null;
-	static isBake = false;
+	static last_envmap: image_t = null;
+	static is_bake: bool = false;
 
 	///if krom_direct3d12
-	static ext = ".cso";
+	static ext: string = ".cso";
 	///elseif krom_metal
-	static ext = ".metal";
+	static ext: string = ".metal";
 	///else
-	static ext = ".spirv";
+	static ext: string = ".spirv";
 	///end
 
 	///if is_lab
-	static lastTexpaint: image_t = null;
+	static last_texpaint: image_t = null;
 	///end
 
 	static init = () => {
 	}
 
 	static commands = (useLiveLayer: bool) => {
-		if (!RenderPathRaytrace.ready || RenderPathRaytrace.isBake) {
+		if (!RenderPathRaytrace.ready || RenderPathRaytrace.is_bake) {
 			RenderPathRaytrace.ready = true;
-			RenderPathRaytrace.isBake = false;
-			let mode = Context.raw.pathTraceMode == PathTraceMode.TraceCore ? "core" : "full";
-			RenderPathRaytrace.raytraceInit("raytrace_brute_" + mode + RenderPathRaytrace.ext);
-			RenderPathRaytrace.lastEnvmap = null;
+			RenderPathRaytrace.is_bake = false;
+			let mode: string = Context.raw.pathtrace_mode == path_trace_mode_t.CORE ? "core" : "full";
+			RenderPathRaytrace.raytrace_init("raytrace_brute_" + mode + RenderPathRaytrace.ext);
+			RenderPathRaytrace.last_envmap = null;
 		}
 
-		if (!Context.raw.envmapLoaded) {
-			Context.loadEnvmap();
-			Context.updateEnvmap();
+		if (!Context.raw.envmap_loaded) {
+			Context.load_envmap();
+			Context.update_envmap();
 		}
 
-		let probe = scene_world;
-		let savedEnvmap = Context.raw.showEnvmapBlur ? probe._.radiance_mipmaps[0] : Context.raw.savedEnvmap;
+		let probe: world_data_t = scene_world;
+		let savedEnvmap: image_t = Context.raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : Context.raw.saved_envmap;
 
-		if (RenderPathRaytrace.lastEnvmap != savedEnvmap) {
-			RenderPathRaytrace.lastEnvmap = savedEnvmap;
+		if (RenderPathRaytrace.last_envmap != savedEnvmap) {
+			RenderPathRaytrace.last_envmap = savedEnvmap;
 
-			let bnoise_sobol = scene_embedded.get("bnoise_sobol.k");
-			let bnoise_scramble = scene_embedded.get("bnoise_scramble.k");
-			let bnoise_rank = scene_embedded.get("bnoise_rank.k");
+			let bnoise_sobol: image_t = scene_embedded.get("bnoise_sobol.k");
+			let bnoise_scramble: image_t = scene_embedded.get("bnoise_scramble.k");
+			let bnoise_rank: image_t = scene_embedded.get("bnoise_rank.k");
 
-			let l = Base.flatten(true);
+			let l: any = Base.flatten(true);
 			krom_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
 		}
 
 		///if is_lab
-		let l = Base.flatten(true);
-		if (l.texpaint != RenderPathRaytrace.lastTexpaint) {
-			RenderPathRaytrace.lastTexpaint = l.texpaint;
+		let l: any = Base.flatten(true);
+		if (l.texpaint != RenderPathRaytrace.last_texpaint) {
+			RenderPathRaytrace.last_texpaint = l.texpaint;
 
-			let bnoise_sobol = scene_embedded.get("bnoise_sobol.k");
-			let bnoise_scramble = scene_embedded.get("bnoise_scramble.k");
-			let bnoise_rank = scene_embedded.get("bnoise_rank.k");
+			let bnoise_sobol: image_t = scene_embedded.get("bnoise_sobol.k");
+			let bnoise_scramble: image_t = scene_embedded.get("bnoise_scramble.k");
+			let bnoise_rank: image_t = scene_embedded.get("bnoise_rank.k");
 
 			krom_raytrace_set_textures(l.texpaint, l.texpaint_nor, l.texpaint_pack, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
 		}
@@ -77,11 +77,11 @@ class RenderPathRaytrace {
 			Base.flatten(true);
 		}
 
-		let cam = scene_camera;
-		let ct = cam.base.transform;
-		mat4_set_from(RenderPathRaytrace.helpMat, cam.v);
-		mat4_mult_mat(RenderPathRaytrace.helpMat, cam.p);
-		mat4_get_inv(RenderPathRaytrace.helpMat, RenderPathRaytrace.helpMat);
+		let cam: camera_object_t = scene_camera;
+		let ct: transform_t = cam.base.transform;
+		mat4_set_from(RenderPathRaytrace.help_mat, cam.v);
+		mat4_mult_mat(RenderPathRaytrace.help_mat, cam.p);
+		mat4_get_inv(RenderPathRaytrace.help_mat, RenderPathRaytrace.help_mat);
 		RenderPathRaytrace.f32a[0] = transform_world_x(ct);
 		RenderPathRaytrace.f32a[1] = transform_world_y(ct);
 		RenderPathRaytrace.f32a[2] = transform_world_z(ct);
@@ -93,31 +93,31 @@ class RenderPathRaytrace {
 		RenderPathRaytrace.frame = (RenderPathRaytrace.frame % 4) + 1; // _PAINT
 		// frame = frame + 1; // _RENDER
 		///end
-		RenderPathRaytrace.f32a[4] = RenderPathRaytrace.helpMat.m[0];
-		RenderPathRaytrace.f32a[5] = RenderPathRaytrace.helpMat.m[1];
-		RenderPathRaytrace.f32a[6] = RenderPathRaytrace.helpMat.m[2];
-		RenderPathRaytrace.f32a[7] = RenderPathRaytrace.helpMat.m[3];
-		RenderPathRaytrace.f32a[8] = RenderPathRaytrace.helpMat.m[4];
-		RenderPathRaytrace.f32a[9] = RenderPathRaytrace.helpMat.m[5];
-		RenderPathRaytrace.f32a[10] = RenderPathRaytrace.helpMat.m[6];
-		RenderPathRaytrace.f32a[11] = RenderPathRaytrace.helpMat.m[7];
-		RenderPathRaytrace.f32a[12] = RenderPathRaytrace.helpMat.m[8];
-		RenderPathRaytrace.f32a[13] = RenderPathRaytrace.helpMat.m[9];
-		RenderPathRaytrace.f32a[14] = RenderPathRaytrace.helpMat.m[10];
-		RenderPathRaytrace.f32a[15] = RenderPathRaytrace.helpMat.m[11];
-		RenderPathRaytrace.f32a[16] = RenderPathRaytrace.helpMat.m[12];
-		RenderPathRaytrace.f32a[17] = RenderPathRaytrace.helpMat.m[13];
-		RenderPathRaytrace.f32a[18] = RenderPathRaytrace.helpMat.m[14];
-		RenderPathRaytrace.f32a[19] = RenderPathRaytrace.helpMat.m[15];
+		RenderPathRaytrace.f32a[4] = RenderPathRaytrace.help_mat.m[0];
+		RenderPathRaytrace.f32a[5] = RenderPathRaytrace.help_mat.m[1];
+		RenderPathRaytrace.f32a[6] = RenderPathRaytrace.help_mat.m[2];
+		RenderPathRaytrace.f32a[7] = RenderPathRaytrace.help_mat.m[3];
+		RenderPathRaytrace.f32a[8] = RenderPathRaytrace.help_mat.m[4];
+		RenderPathRaytrace.f32a[9] = RenderPathRaytrace.help_mat.m[5];
+		RenderPathRaytrace.f32a[10] = RenderPathRaytrace.help_mat.m[6];
+		RenderPathRaytrace.f32a[11] = RenderPathRaytrace.help_mat.m[7];
+		RenderPathRaytrace.f32a[12] = RenderPathRaytrace.help_mat.m[8];
+		RenderPathRaytrace.f32a[13] = RenderPathRaytrace.help_mat.m[9];
+		RenderPathRaytrace.f32a[14] = RenderPathRaytrace.help_mat.m[10];
+		RenderPathRaytrace.f32a[15] = RenderPathRaytrace.help_mat.m[11];
+		RenderPathRaytrace.f32a[16] = RenderPathRaytrace.help_mat.m[12];
+		RenderPathRaytrace.f32a[17] = RenderPathRaytrace.help_mat.m[13];
+		RenderPathRaytrace.f32a[18] = RenderPathRaytrace.help_mat.m[14];
+		RenderPathRaytrace.f32a[19] = RenderPathRaytrace.help_mat.m[15];
 		RenderPathRaytrace.f32a[20] = scene_world.strength * 1.5;
-		if (!Context.raw.showEnvmap) RenderPathRaytrace.f32a[20] = -RenderPathRaytrace.f32a[20];
-		RenderPathRaytrace.f32a[21] = Context.raw.envmapAngle;
-		RenderPathRaytrace.f32a[22] = RenderPathRaytrace.uvScale;
+		if (!Context.raw.show_envmap) RenderPathRaytrace.f32a[20] = -RenderPathRaytrace.f32a[20];
+		RenderPathRaytrace.f32a[21] = Context.raw.envmap_angle;
+		RenderPathRaytrace.f32a[22] = RenderPathRaytrace.uv_scale;
 		///if is_lab
 		RenderPathRaytrace.f32a[22] *= scene_meshes[0].data.scale_tex;
 		///end
 
-		let framebuffer = render_path_render_targets.get("buf")._image;
+		let framebuffer: image_t = render_path_render_targets.get("buf")._image;
 		krom_raytrace_dispatch_rays(framebuffer.render_target_, RenderPathRaytrace.f32a.buffer);
 
 		if (Context.raw.ddirty == 1 || Context.raw.pdirty == 1) {
@@ -134,7 +134,7 @@ class RenderPathRaytrace {
 		// Context.raw.ddirty = 1; // _RENDER
 	}
 
-	static raytraceInit = (shaderName: string, build = true) => {
+	static raytrace_init = (shaderName: string, build: bool = true) => {
 		if (RenderPathRaytrace.first) {
 			RenderPathRaytrace.first = false;
 			scene_embed_data("bnoise_sobol.k");
@@ -143,22 +143,19 @@ class RenderPathRaytrace {
 		}
 
 		let shader: ArrayBuffer = data_get_blob(shaderName);
-		if (build) RenderPathRaytrace.buildData();
-		let bnoise_sobol = scene_embedded.get("bnoise_sobol.k");
-		let bnoise_scramble = scene_embedded.get("bnoise_scramble.k");
-		let bnoise_rank = scene_embedded.get("bnoise_rank.k");
+		if (build) RenderPathRaytrace.build_data();
 		krom_raytrace_init(shader, RenderPathRaytrace.vb.buffer_, RenderPathRaytrace.ib.buffer_, RenderPathRaytrace.vb_scale);
 	}
 
-	static buildData = () => {
-		if (Context.raw.mergedObject == null) UtilMesh.mergeMesh();
+	static build_data = () => {
+		if (Context.raw.merged_object == null) UtilMesh.merge_mesh();
 		///if is_paint
-		let mo = !Context.layerFilterUsed() ? Context.raw.mergedObject : Context.raw.paintObject;
+		let mo: mesh_object_t = !Context.layer_filter_used() ? Context.raw.merged_object : Context.raw.paint_object;
 		///else
-		let mo = scene_meshes[0];
+		let mo: mesh_object_t = scene_meshes[0];
 		///end
-		let md = mo.data;
-		let mo_scale = mo.base.transform.scale.x; // Uniform scale only
+		let md: mesh_data_t = mo.data;
+		let mo_scale: f32 = mo.base.transform.scale.x; // Uniform scale only
 		RenderPathRaytrace.vb_scale = md.scale_pos * mo_scale;
 		if (mo.base.parent != null) RenderPathRaytrace.vb_scale *= mo.base.parent.transform.scale.x;
 		RenderPathRaytrace.vb = md._.vertex_buffer;
@@ -166,24 +163,24 @@ class RenderPathRaytrace {
 	}
 
 	static draw = (useLiveLayer: bool) => {
-		let isLive = Config.raw.brush_live && RenderPathPaint.liveLayerDrawn > 0;
+		let isLive: bool = Config.raw.brush_live && RenderPathPaint.liveLayerDrawn > 0;
 		if (Context.raw.ddirty > 1 || Context.raw.pdirty > 0 || isLive) RenderPathRaytrace.frame = 0;
 
 		///if krom_metal
 		// Delay path tracing additional samples while painting
-		let down = mouse_down() || pen_down();
-		if (Context.inViewport() && down) RenderPathRaytrace.frame = 0;
+		let down: bool = mouse_down() || pen_down();
+		if (Context.in_viewport() && down) RenderPathRaytrace.frame = 0;
 		///end
 
 		RenderPathRaytrace.commands(useLiveLayer);
 
 		if (Config.raw.rp_bloom != false) {
-			RenderPathBase.drawBloom("buf");
+			RenderPathBase.draw_bloom("buf");
 		}
 		render_path_set_target("buf");
 		render_path_draw_meshes("overlay");
 		render_path_set_target("buf");
-		RenderPathBase.drawCompass();
+		RenderPathBase.draw_compass();
 		render_path_set_target("taa");
 		render_path_bind_target("buf", "tex");
 		render_path_draw_shader("shader_datas/compositor_pass/compositor_pass");
@@ -191,7 +188,7 @@ class RenderPathRaytrace {
 		render_path_bind_target("taa", "tex");
 		render_path_draw_shader("shader_datas/copy_pass/copy_pass");
 		if (Config.raw.brush_3d) {
-			RenderPathPaint.commandsCursor();
+			RenderPathPaint.commands_cursor();
 		}
 	}
 }

+ 67 - 67
base/Sources/RenderPathRaytraceBake.ts

@@ -3,23 +3,23 @@
 
 class RenderPathRaytraceBake {
 
-	static raysPix = 0;
-	static raysSec = 0;
-	static currentSample = 0;
-	static raysTimer = 0.0;
-	static raysCounter = 0;
-	static lastLayer: image_t = null;
-	static lastBake = 0;
+	static rays_pix: i32 = 0;
+	static rays_sec: i32 = 0;
+	static current_sample: i32 = 0;
+	static rays_timer: f32 = 0.0;
+	static rays_counter: i32 = 0;
+	static last_layer: image_t = null;
+	static last_bake: i32 = 0;
 
 	static commands = (parsePaintMaterial: (b?: bool)=>void): bool => {
 
-		if (!RenderPathRaytrace.ready || !RenderPathRaytrace.isBake || RenderPathRaytraceBake.lastBake != Context.raw.bakeType) {
-			let rebuild = !(RenderPathRaytrace.ready && RenderPathRaytrace.isBake && RenderPathRaytraceBake.lastBake != Context.raw.bakeType);
-			RenderPathRaytraceBake.lastBake = Context.raw.bakeType;
+		if (!RenderPathRaytrace.ready || !RenderPathRaytrace.is_bake || RenderPathRaytraceBake.last_bake != Context.raw.bake_type) {
+			let rebuild: bool = !(RenderPathRaytrace.ready && RenderPathRaytrace.is_bake && RenderPathRaytraceBake.last_bake != Context.raw.bake_type);
+			RenderPathRaytraceBake.last_bake = Context.raw.bake_type;
 			RenderPathRaytrace.ready = true;
-			RenderPathRaytrace.isBake = true;
-			RenderPathRaytrace.lastEnvmap = null;
-			RenderPathRaytraceBake.lastLayer = null;
+			RenderPathRaytrace.is_bake = true;
+			RenderPathRaytrace.last_envmap = null;
+			RenderPathRaytraceBake.last_layer = null;
 
 			if (render_path_render_targets.get("baketex0") != null) {
 				image_unload(render_path_render_targets.get("baketex0")._image);
@@ -28,83 +28,83 @@ class RenderPathRaytraceBake {
 			}
 
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "baketex0";
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = "RGBA64";
 				render_path_create_render_target(t);
 			}
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "baketex1";
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = "RGBA64";
 				render_path_create_render_target(t);
 			}
 			{
-				let t = render_target_create();
+				let t: render_target_t = render_target_create();
 				t.name = "baketex2";
-				t.width = Config.getTextureResX();
-				t.height = Config.getTextureResY();
+				t.width = Config.get_texture_res_x();
+				t.height = Config.get_texture_res_y();
 				t.format = "RGBA64"; // Match raytrace_target format
 				render_path_create_render_target(t);
 			}
 
-			let _bakeType = Context.raw.bakeType;
-			Context.raw.bakeType = BakeType.BakeInit;
+			let _bakeType: bake_type_t = Context.raw.bake_type;
+			Context.raw.bake_type = bake_type_t.INIT;
 			parsePaintMaterial();
 			render_path_set_target("baketex0");
 			render_path_clear_target(0x00000000); // Pixels with alpha of 0.0 are skipped during raytracing
 			render_path_set_target("baketex0", ["baketex1"]);
 			render_path_draw_meshes("paint");
-			Context.raw.bakeType = _bakeType;
+			Context.raw.bake_type = _bakeType;
 			let _next = () => {
 				parsePaintMaterial();
 			}
-			Base.notifyOnNextFrame(_next);
+			Base.notify_on_next_frame(_next);
 
-			RenderPathRaytrace.raytraceInit(RenderPathRaytraceBake.getBakeShaderName(), rebuild);
+			RenderPathRaytrace.raytrace_init(RenderPathRaytraceBake.get_bake_shader_name(), rebuild);
 
 			return false;
 		}
 
-		if (!Context.raw.envmapLoaded) {
-			Context.loadEnvmap();
-			Context.updateEnvmap();
+		if (!Context.raw.envmap_loaded) {
+			Context.load_envmap();
+			Context.update_envmap();
 		}
-		let probe = scene_world;
-		let savedEnvmap = Context.raw.showEnvmapBlur ? probe._.radiance_mipmaps[0] : Context.raw.savedEnvmap;
-		if (RenderPathRaytrace.lastEnvmap != savedEnvmap || RenderPathRaytraceBake.lastLayer != Context.raw.layer.texpaint) {
-			RenderPathRaytrace.lastEnvmap = savedEnvmap;
-			RenderPathRaytraceBake.lastLayer = Context.raw.layer.texpaint;
-
-			let baketex0 = render_path_render_targets.get("baketex0")._image;
-			let baketex1 = render_path_render_targets.get("baketex1")._image;
-			let bnoise_sobol = scene_embedded.get("bnoise_sobol.k");
-			let bnoise_scramble = scene_embedded.get("bnoise_scramble.k");
-			let bnoise_rank = scene_embedded.get("bnoise_rank.k");
-			let texpaint_undo = render_path_render_targets.get("texpaint_undo" + History.undoI)._image;
+		let probe: world_data_t = scene_world;
+		let savedEnvmap: image_t = Context.raw.show_envmap_blur ? probe._.radiance_mipmaps[0] : Context.raw.saved_envmap;
+		if (RenderPathRaytrace.last_envmap != savedEnvmap || RenderPathRaytraceBake.last_layer != Context.raw.layer.texpaint) {
+			RenderPathRaytrace.last_envmap = savedEnvmap;
+			RenderPathRaytraceBake.last_layer = Context.raw.layer.texpaint;
+
+			let baketex0: image_t = render_path_render_targets.get("baketex0")._image;
+			let baketex1: image_t = render_path_render_targets.get("baketex1")._image;
+			let bnoise_sobol: image_t = scene_embedded.get("bnoise_sobol.k");
+			let bnoise_scramble: image_t = scene_embedded.get("bnoise_scramble.k");
+			let bnoise_rank: image_t = scene_embedded.get("bnoise_rank.k");
+			let texpaint_undo: image_t = render_path_render_targets.get("texpaint_undo" + History.undo_i)._image;
 			krom_raytrace_set_textures(baketex0, baketex1, texpaint_undo, savedEnvmap.texture_, bnoise_sobol.texture_, bnoise_scramble.texture_, bnoise_rank.texture_);
 		}
 
-		if (Context.raw.brushTime > 0) {
+		if (Context.raw.brush_time > 0) {
 			Context.raw.pdirty = 2;
 			Context.raw.rdirty = 2;
 		}
 
 		if (Context.raw.pdirty > 0) {
-			let f32a = RenderPathRaytrace.f32a;
+			let f32a: Float32Array = RenderPathRaytrace.f32a;
 			f32a[0] = RenderPathRaytrace.frame++;
-			f32a[1] = Context.raw.bakeAoStrength;
-			f32a[2] = Context.raw.bakeAoRadius;
-			f32a[3] = Context.raw.bakeAoOffset;
+			f32a[1] = Context.raw.bake_ao_strength;
+			f32a[2] = Context.raw.bake_ao_radius;
+			f32a[3] = Context.raw.bake_ao_offset;
 			f32a[4] = scene_world.strength;
-			f32a[5] = Context.raw.bakeUpAxis;
-			f32a[6] = Context.raw.envmapAngle;
+			f32a[5] = Context.raw.bake_up_axis;
+			f32a[6] = Context.raw.envmap_angle;
 
-			let framebuffer = render_path_render_targets.get("baketex2")._image;
+			let framebuffer: image_t = render_path_render_targets.get("baketex2")._image;
 			krom_raytrace_dispatch_rays(framebuffer.render_target_, f32a.buffer);
 
 			render_path_set_target("texpaint" + Context.raw.layer.id);
@@ -112,36 +112,36 @@ class RenderPathRaytraceBake {
 			render_path_draw_shader("shader_datas/copy_pass/copy_pass");
 
 			///if krom_metal
-			let samplesPerFrame = 4;
+			let samplesPerFrame: i32 = 4;
 			///else
-			let samplesPerFrame = 64;
+			let samplesPerFrame: i32 = 64;
 			///end
 
-			RenderPathRaytraceBake.raysPix = RenderPathRaytrace.frame * samplesPerFrame;
-			RenderPathRaytraceBake.raysCounter += samplesPerFrame;
-			RenderPathRaytraceBake.raysTimer += time_real_delta();
-			if (RenderPathRaytraceBake.raysTimer >= 1) {
-				RenderPathRaytraceBake.raysSec = RenderPathRaytraceBake.raysCounter;
-				RenderPathRaytraceBake.raysTimer = 0;
-				RenderPathRaytraceBake.raysCounter = 0;
+			RenderPathRaytraceBake.rays_pix = RenderPathRaytrace.frame * samplesPerFrame;
+			RenderPathRaytraceBake.rays_counter += samplesPerFrame;
+			RenderPathRaytraceBake.rays_timer += time_real_delta();
+			if (RenderPathRaytraceBake.rays_timer >= 1) {
+				RenderPathRaytraceBake.rays_sec = RenderPathRaytraceBake.rays_counter;
+				RenderPathRaytraceBake.rays_timer = 0;
+				RenderPathRaytraceBake.rays_counter = 0;
 			}
-			RenderPathRaytraceBake.currentSample++;
+			RenderPathRaytraceBake.current_sample++;
 			krom_delay_idle_sleep();
 			return true;
 		}
 		else {
 			RenderPathRaytrace.frame = 0;
-			RenderPathRaytraceBake.raysTimer = 0;
-			RenderPathRaytraceBake.raysCounter = 0;
-			RenderPathRaytraceBake.currentSample = 0;
+			RenderPathRaytraceBake.rays_timer = 0;
+			RenderPathRaytraceBake.rays_counter = 0;
+			RenderPathRaytraceBake.current_sample = 0;
 			return false;
 		}
 	}
 
-	static getBakeShaderName = (): string => {
-		return Context.raw.bakeType == BakeType.BakeAO  		? "raytrace_bake_ao" + RenderPathRaytrace.ext :
-			   Context.raw.bakeType == BakeType.BakeLightmap 	? "raytrace_bake_light" + RenderPathRaytrace.ext :
-			   Context.raw.bakeType == BakeType.BakeBentNormal  ? "raytrace_bake_bent" + RenderPathRaytrace.ext :
+	static get_bake_shader_name = (): string => {
+		return Context.raw.bake_type == bake_type_t.AO  		? "raytrace_bake_ao" + RenderPathRaytrace.ext :
+			   Context.raw.bake_type == bake_type_t.LIGHTMAP 	? "raytrace_bake_light" + RenderPathRaytrace.ext :
+			   Context.raw.bake_type == bake_type_t.BENT_NORMAL  ? "raytrace_bake_bent" + RenderPathRaytrace.ext :
 												  				  "raytrace_bake_thick" + RenderPathRaytrace.ext;
 	}
 }

+ 16 - 16
base/Sources/Res.ts

@@ -4,7 +4,7 @@ class Res {
 	static bundled: Map<string, image_t> = new Map();
 
 	static load = (names: string[], done: ()=>void) => {
-		let loaded = 0;
+		let loaded: i32 = 0;
 		for (let s of names) {
 			let image: image_t = data_get_image(s);
 			Res.bundled.set(s, image);
@@ -17,41 +17,41 @@ class Res {
 		return Res.bundled.get(name);
 	}
 
-	static tile50 = (img: image_t, x: i32, y: i32): TRect => {
-		let size = Config.raw.window_scale > 1 ? 100 : 50;
+	static tile50 = (img: image_t, x: i32, y: i32): rect_t => {
+		let size: i32 = Config.raw.window_scale > 1 ? 100 : 50;
 		return { x: x * size, y: y * size, w: size, h: size };
 	}
 
-	static tile25 = (img: image_t, x: i32, y: i32): TRect => {
-		let size = Config.raw.window_scale > 1 ? 50 : 25;
+	static tile25 = (img: image_t, x: i32, y: i32): rect_t => {
+		let size: i32 = Config.raw.window_scale > 1 ? 50 : 25;
 		return { x: x * size, y: y * size, w: size, h: size };
 	}
 
-	static tile18 = (img: image_t, x: i32, y: i32): TRect => {
-		let size = Config.raw.window_scale > 1 ? 36 : 18;
+	static tile18 = (img: image_t, x: i32, y: i32): rect_t => {
+		let size: i32 = Config.raw.window_scale > 1 ? 36 : 18;
 		return { x: x * size, y: img.height - (y + 1) * size, w: size, h: size };
 	}
 
 	///if arm_snapshot
-	static embedRaw = (handle: string, name: string, file: ArrayBuffer) => {
+	static embed_raw = (handle: string, name: string, file: ArrayBuffer) => {
 		data_cached_blobs.set(name, file);
 		data_get_scene_raw(handle, (_) => {});
 		data_cached_blobs.delete(name);
 	}
 
-	static embedBlob = (name: string, file: ArrayBuffer) => {
+	static embed_blob = (name: string, file: ArrayBuffer) => {
 		data_cached_blobs.set(name, file);
 	}
 
-	static embedFont = (name: string, file: ArrayBuffer) => {
+	static embed_font = (name: string, file: ArrayBuffer) => {
 		data_cached_fonts.set(name, g2_font_create(file));
 	}
 	///end
 }
 
-type TRect = {
-	x: i32;
-	y: i32;
-	w: i32;
-	h: i32;
-}
+type rect_t = {
+	x?: i32;
+	y?: i32;
+	w?: i32;
+	h?: i32;
+};

+ 21 - 21
base/Sources/ShaderFunctions.ts

@@ -1,7 +1,7 @@
 
 class ShaderFunctions {
 
-	static str_tex_checker = `
+	static str_tex_checker: string = `
 vec3 tex_checker(const vec3 co, const vec3 col1, const vec3 col2, const float scale) {
 	// Prevent precision issues on unit coordinates
 	vec3 p = (co + 0.000001 * 0.999999) * scale;
@@ -22,7 +22,7 @@ float tex_checker_f(const vec3 co, const float scale) {
 
 	// Created by inigo quilez - iq/2013
 	// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
-	static str_tex_voronoi = `
+	static str_tex_voronoi: string = `
 vec4 tex_voronoi(const vec3 x, textureArg(snoise256)) {
 	vec3 p = floor(x);
 	vec3 f = fract(x);
@@ -47,7 +47,7 @@ vec4 tex_voronoi(const vec3 x, textureArg(snoise256)) {
 
 	// By Morgan McGuire @morgan3d, http://graphicscodex.com Reuse permitted under the BSD license.
 	// https://www.shadertoy.com/view/4dS3Wd
-	static str_tex_noise = `
+	static str_tex_noise: string = `
 float hash(float n) { return fract(sin(n) * 1e4); }
 float tex_noise_f(vec3 x) {
     const vec3 step = vec3(110, 241, 171);
@@ -72,7 +72,7 @@ float tex_noise(vec3 p) {
 
 	// Based on noise created by Nikita Miropolskiy, nikat/2013
 	// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
-	static str_tex_musgrave = `
+	static str_tex_musgrave: string = `
 vec3 random3(const vec3 c) {
 	float j = 4096.0 * sin(dot(c, vec3(17.0, 59.4, 15.0)));
 	vec3 r;
@@ -111,7 +111,7 @@ float tex_musgrave_f(const vec3 p) {
 }
 `;
 
-	static str_hue_sat = `
+	static str_hue_sat: string = `
 vec3 hsv_to_rgb(const vec3 c) {
 	const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
 	vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
@@ -135,14 +135,14 @@ vec3 hue_sat(const vec3 col, const vec4 shift) {
 `;
 
 	// https://twitter.com/Donzanoid/status/903424376707657730
-	static str_wavelength_to_rgb = `
+	static str_wavelength_to_rgb: string = `
 vec3 wavelength_to_rgb(const float t) {
 	vec3 r = t * 2.1 - vec3(1.8, 1.14, 0.3);
 	return 1.0 - r * r;
 }
 `;
 
-	static str_tex_magic = `
+	static str_tex_magic: string = `
 vec3 tex_magic(const vec3 p) {
 	float a = 1.0 - (sin(p.x) + sin(p.y));
 	float b = 1.0 - sin(p.x - p.y);
@@ -155,7 +155,7 @@ float tex_magic_f(const vec3 p) {
 }
 `;
 
-	static str_tex_brick = `
+	static str_tex_brick: string = `
 float tex_brick_noise(int n) { /* fast integer noise */
 	int nn;
 	n = (n >> 13) ^ n;
@@ -183,13 +183,13 @@ float tex_brick_f(vec3 p) {
 }
 `;
 
-	static str_tex_wave = `
+	static str_tex_wave: string = `
 float tex_wave_f(const vec3 p) {
 	return 1.0 - sin((p.x + p.y) * 10.0);
 }
 `;
 
-	static str_brightcontrast = `
+	static str_brightcontrast: string = `
 vec3 brightcontrast(const vec3 col, const float bright, const float contr) {
 	float a = 1.0 + contr;
 	float b = bright - contr * 0.5;
@@ -200,7 +200,7 @@ vec3 brightcontrast(const vec3 col, const float bright, const float contr) {
 //
 
 	///if arm_voxels
-	static str_traceAO = `
+	static str_trace_ao: string = `
 float traceConeAO(sampler3D voxels, const vec3 origin, vec3 dir, const float aperture, const float maxDist, const float offset) {
 	const ivec3 voxelgiResolution = ivec3(256, 256, 256);
 	const float voxelgiStep = 1.0;
@@ -252,7 +252,7 @@ float traceAO(const vec3 origin, const vec3 normal, const float vrange, const fl
 `;
 	///end
 
-	static str_cotangentFrame = `
+	static str_cotangent_frame: string = `
 mat3 cotangentFrame(const vec3 n, const vec3 p, const vec2 duv1, const vec2 duv2) {
 	vec3 dp1 = dFdx(p);
 	vec3 dp2 = dFdy(p);
@@ -268,13 +268,13 @@ mat3 cotangentFrame(const vec3 n, const vec3 p, const vec2 texCoord) {
 }
 `;
 
-	static str_octahedronWrap = `
+	static str_octahedron_wrap: string = `
 vec2 octahedronWrap(const vec2 v) {
 	return (1.0 - abs(v.yx)) * (vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0));
 }
 `;
 
-	static str_packFloatInt16 = `
+	static str_pack_float_int16: string = `
 float packFloatInt16(const float f, const uint i) {
 	const float prec = float(1 << 16);
 	const float maxi = float(1 << 4);
@@ -286,7 +286,7 @@ float packFloatInt16(const float f, const uint i) {
 `;
 
 	///if arm_skin
-	static str_getSkinningDualQuat = `
+	static str_get_skinning_dual_quat: string = `
 void getSkinningDualQuat(const ivec4 bone, vec4 weight, out vec4 A, inout vec4 B) {
 	ivec4 bonei = bone * 2;
 	mat4 matA = mat4(
@@ -309,14 +309,14 @@ void getSkinningDualQuat(const ivec4 bone, vec4 weight, out vec4 A, inout vec4 B
 `;
 	///end
 
-	static str_createBasis = `
+	static str_create_basis: string = `
 void createBasis(vec3 normal, out vec3 tangent, out vec3 binormal) {
 	tangent = normalize(cameraRight - normal * dot(cameraRight, normal));
 	binormal = cross(tangent, normal);
 }
 `;
 
-	static get str_shIrradiance(): string {
+	static get str_sh_irradiance(): string {
 		///if krom_metal
 		return `vec3 shIrradiance(const vec3 nor, constant vec4 shirr[7]) {
 	const float c1 = 0.429043;
@@ -380,7 +380,7 @@ void createBasis(vec3 normal, out vec3 tangent, out vec3 binormal) {
 ///end
 	}
 
-	static str_envMapEquirect = `
+	static str_envmap_equirect: string = `
 vec2 envMapEquirect(const vec3 normal, const float angle) {
 	const float PI = 3.1415926535;
 	const float PI2 = PI * 2.0;
@@ -392,7 +392,7 @@ vec2 envMapEquirect(const vec3 normal, const float angle) {
 
 	// Linearly Transformed Cosines
 	// https://eheitzresearch.wordpress.com/415-2/
-	static str_ltcEvaluate = `
+	static str_ltc_evaluate: string = `
 float integrateEdge(vec3 v1, vec3 v2) {
 	float cosTheta = dot(v1, v2);
 	float theta = acos(cosTheta);
@@ -500,7 +500,7 @@ float ltcEvaluate(vec3 N, vec3 V, float dotNV, vec3 P, mat3 Minv, vec3 points0,
 }
 `;
 
-	static str_get_pos_from_depth = `
+	static str_get_pos_from_depth: string = `
 vec3 get_pos_from_depth(vec2 uv, mat4 invVP, textureArg(gbufferD)) {
 	#if defined(HLSL) || defined(METAL) || defined(SPIRV)
 	float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
@@ -513,7 +513,7 @@ vec3 get_pos_from_depth(vec2 uv, mat4 invVP, textureArg(gbufferD)) {
 }
 `;
 
-	static str_get_nor_from_depth = `
+	static str_get_nor_from_depth: string = `
 vec3 get_nor_from_depth(vec3 p0, vec2 uv, mat4 invVP, vec2 texStep, textureArg(gbufferD)) {
 	vec3 p1 = get_pos_from_depth(uv + vec2(texStep.x * 4.0, 0.0), invVP, texturePass(gbufferD));
 	vec3 p2 = get_pos_from_depth(uv + vec2(0.0, texStep.y * 4.0), invVP, texturePass(gbufferD));

+ 53 - 53
base/Sources/TabBrowser.ts

@@ -1,34 +1,34 @@
 
 class TabBrowser {
 
-	static hpath = zui_handle_create();
-	static hsearch = zui_handle_create();
-	static known = false;
-	static lastPath =  "";
+	static hpath: zui_handle_t = zui_handle_create();
+	static hsearch: zui_handle_t = zui_handle_create();
+	static known: bool = false;
+	static last_path: string =  "";
 
-	static showDirectory = (directory: string) => {
+	static show_directory = (directory: string) => {
 		TabBrowser.hpath.text = directory;
 		TabBrowser.hsearch.text = "";
-		UIBase.htabs[TabArea.TabStatus].position = 0;
+		UIBase.htabs[tab_area_t.STATUS].position = 0;
 	}
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Browser")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Browser")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			if (Config.raw.bookmarks == null) {
 				Config.raw.bookmarks = [];
 			}
 
-			let bookmarksW = Math.floor(100 * zui_SCALE(ui));
+			let bookmarksW: i32 = Math.floor(100 * zui_SCALE(ui));
 
 			if (TabBrowser.hpath.text == "" && Config.raw.bookmarks.length > 0) { // Init to first bookmark
 				TabBrowser.hpath.text = Config.raw.bookmarks[0];
 			}
 
 			zui_begin_sticky();
-			let step = (1 - bookmarksW / ui._w);
+			let step: i32 = (1 - bookmarksW / ui._w);
 			if (TabBrowser.hsearch.text != "") {
 				zui_row([bookmarksW / ui._w, step * 0.73, step * 0.07, step * 0.17, step * 0.03]);
 			}
@@ -43,8 +43,8 @@ class TabBrowser {
 			if (ui.is_hovered) zui_tooltip(tr("Add bookmark"));
 
 			///if krom_android
-			let stripped = false;
-			let strip = "/storage/emulated/0/";
+			let stripped: bool = false;
+			let strip: string = "/storage/emulated/0/";
 			if (TabBrowser.hpath.text.startsWith(strip)) {
 				TabBrowser.hpath.text = TabBrowser.hpath.text.substr(strip.length - 1);
 				stripped = true;
@@ -59,8 +59,8 @@ class TabBrowser {
 			}
 			///end
 
-			let refresh = false;
-			let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+			let refresh: bool = false;
+			let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
 						  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 			if (zui_button(tr("Refresh")) || (inFocus && ui.is_key_pressed && ui.key == key_code_t.F5)) {
 				refresh = true;
@@ -75,52 +75,52 @@ class TabBrowser {
 			}
 			zui_end_sticky();
 
-			if (TabBrowser.lastPath != TabBrowser.hpath.text) {
+			if (TabBrowser.last_path != TabBrowser.hpath.text) {
 				TabBrowser.hsearch.text = "";
 			}
-			TabBrowser.lastPath = TabBrowser.hpath.text;
+			TabBrowser.last_path = TabBrowser.hpath.text;
 
-			let _y = ui._y;
+			let _y: f32 = ui._y;
 			ui._x = bookmarksW;
 			ui._w -= bookmarksW;
-			UIFiles.fileBrowser(ui, TabBrowser.hpath, false, true, TabBrowser.hsearch.text, refresh, (file: string) => {
-				let fileName = file.substr(file.lastIndexOf(Path.sep) + 1);
+			UIFiles.file_browser(ui, TabBrowser.hpath, false, true, TabBrowser.hsearch.text, refresh, (file: string) => {
+				let fileName: string = file.substr(file.lastIndexOf(Path.sep) + 1);
 				if (fileName != "..") {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Import"))) {
+						if (UIMenu.menu_button(ui, tr("Import"))) {
 							ImportAsset.run(file);
 						}
-						if (Path.isTexture(file)) {
-							if (UIMenu.menuButton(ui, tr("Set as Envmap"))) {
+						if (Path.is_texture(file)) {
+							if (UIMenu.menu_button(ui, tr("Set as Envmap"))) {
 								ImportAsset.run(file, -1.0, -1.0, true, true, () => {
-									Base.notifyOnNextFrame(() => {
-										let assetIndex = -1;
-										for (let i = 0; i < Project.assets.length; ++i) {
+									Base.notify_on_next_frame(() => {
+										let assetIndex: i32 = -1;
+										for (let i: i32 = 0; i < Project.assets.length; ++i) {
 											if (Project.assets[i].file == file) {
 												assetIndex = i;
 												break;
 											}
 										}
 										if (assetIndex != -1) {
-											ImportEnvmap.run(file, Project.getImage(Project.assets[assetIndex]));
+											ImportEnvmap.run(file, Project.get_image(Project.assets[assetIndex]));
 										}
 									});
 								});
 							}
 
 							///if (is_paint || is_sculpt)
-							if (UIMenu.menuButton(ui, tr("Set as Mask"))) {
+							if (UIMenu.menu_button(ui, tr("Set as Mask"))) {
 								ImportAsset.run(file, -1.0, -1.0, true, true, () => {
-									Base.notifyOnNextFrame(() => {
-										let assetIndex = -1;
-										for (let i = 0; i < Project.assets.length; ++i) {
+									Base.notify_on_next_frame(() => {
+										let assetIndex: i32 = -1;
+										for (let i: i32 = 0; i < Project.assets.length; ++i) {
 											if (Project.assets[i].file == file) {
 												assetIndex = i;
 												break;
 											}
 										}
 										if (assetIndex != -1) {
-											Base.createImageMask(Project.assets[assetIndex]);
+											Base.create_image_mask(Project.assets[assetIndex]);
 										}
 									});
 								});
@@ -128,22 +128,22 @@ class TabBrowser {
 							///end
 
 							///if is_paint
-							if (UIMenu.menuButton(ui, tr("Set as Color ID Map"))) {
+							if (UIMenu.menu_button(ui, tr("Set as Color ID Map"))) {
 								ImportAsset.run(file, -1.0, -1.0, true, true, () => {
-									Base.notifyOnNextFrame(() => {
-										let assetIndex = -1;
-										for (let i = 0; i < Project.assets.length; ++i) {
+									Base.notify_on_next_frame(() => {
+										let assetIndex: i32 = -1;
+										for (let i: i32 = 0; i < Project.assets.length; ++i) {
 											if (Project.assets[i].file == file) {
 												assetIndex = i;
 												break;
 											}
 										}
 										if (assetIndex != -1) {
-											Context.raw.colorIdHandle.position = assetIndex;
-											Context.raw.colorIdPicked = false;
-											UIToolbar.toolbarHandle.redraws = 1;
-											if (Context.raw.tool == WorkspaceTool.ToolColorId) {
-												UIHeader.headerHandle.redraws = 2;
+											Context.raw.colorid_handle.position = assetIndex;
+											Context.raw.colorid_picked = false;
+											UIToolbar.toolbar_handle.redraws = 1;
+											if (Context.raw.tool == workspace_tool_t.COLORID) {
+												UIHeader.header_handle.redraws = 2;
 												Context.raw.ddirty = 2;
 											}
 										}
@@ -152,15 +152,15 @@ class TabBrowser {
 							}
 							///end
 						}
-						if (UIMenu.menuButton(ui, tr("Open Externally"))) {
+						if (UIMenu.menu_button(ui, tr("Open Externally"))) {
 							File.start(file);
 						}
-					}, Path.isTexture(file) ? 5 : 2);
+					}, Path.is_texture(file) ? 5 : 2);
 				}
 			});
 
 			if (TabBrowser.known) {
-				let path = TabBrowser.hpath.text;
+				let path: string = TabBrowser.hpath.text;
 				app_notify_on_init(() => {
 					ImportAsset.run(path);
 				});
@@ -171,7 +171,7 @@ class TabBrowser {
 			if (TabBrowser.hpath.text.endsWith("." + manifest_title.toLowerCase())) TabBrowser.known = false;
 			///end
 
-			let bottomY = ui._y;
+			let bottomY: i32 = ui._y;
 			ui._x = 0;
 			ui._y = _y;
 			ui._w = bookmarksW;
@@ -183,26 +183,26 @@ class TabBrowser {
 			if (zui_button(tr("Disk"), zui_align_t.LEFT)) {
 				///if krom_android
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Download"))) {
-						TabBrowser.hpath.text = UIFiles.defaultPath;
+					if (UIMenu.menu_button(ui, tr("Download"))) {
+						TabBrowser.hpath.text = UIFiles.default_path;
 					}
-					if (UIMenu.menuButton(ui, tr("Pictures"))) {
+					if (UIMenu.menu_button(ui, tr("Pictures"))) {
 						TabBrowser.hpath.text = "/storage/emulated/0/Pictures";
 					}
-					if (UIMenu.menuButton(ui, tr("Camera"))) {
+					if (UIMenu.menu_button(ui, tr("Camera"))) {
 						TabBrowser.hpath.text = "/storage/emulated/0/DCIM/Camera";
 					}
-					if (UIMenu.menuButton(ui, tr("Projects"))) {
+					if (UIMenu.menu_button(ui, tr("Projects"))) {
 						TabBrowser.hpath.text = krom_save_path();
 					}
 				}, 4);
 				///else
-				TabBrowser.hpath.text = UIFiles.defaultPath;
+				TabBrowser.hpath.text = UIFiles.default_path;
 				///end
 			}
 
 			for (let b of Config.raw.bookmarks) {
-				let folder = b.substr(b.lastIndexOf(Path.sep) + 1);
+				let folder: string = b.substr(b.lastIndexOf(Path.sep) + 1);
 
 				if (zui_button(folder, zui_align_t.LEFT)) {
 					TabBrowser.hpath.text = b;
@@ -210,7 +210,7 @@ class TabBrowser {
 
 				if (ui.is_hovered && ui.input_released_r) {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Delete"))) {
+						if (UIMenu.menu_button(ui, tr("Delete"))) {
 							array_remove(Config.raw.bookmarks, b);
 							Config.save();
 						}

+ 46 - 46
base/Sources/TabBrushes.ts

@@ -4,53 +4,53 @@
 class TabBrushes {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+		let ui: zui_t = UIBase.ui;
 		if (zui_tab(htab, tr("Brushes"))) {
 			zui_begin_sticky();
 			zui_row([1 / 4, 1 / 4, 1 / 4]);
 			if (zui_button(tr("New"))) {
 				Context.raw.brush = SlotBrush.create();
 				Project.brushes.push(Context.raw.brush);
-				MakeMaterial.parseBrush();
+				MakeMaterial.parse_brush();
 				UINodes.hwnd.redraws = 2;
 			}
 			if (zui_button(tr("Import"))) {
-				Project.importBrush();
+				Project.import_brush();
 			}
 			if (zui_button(tr("Nodes"))) {
-				UIBase.showBrushNodes();
+				UIBase.show_brush_nodes();
 			}
 			zui_end_sticky();
 			zui_separator(3, false);
 
-			let slotw = Math.floor(51 * zui_SCALE(ui));
-			let num = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] / slotw);
+			let slotw: i32 = Math.floor(51 * zui_SCALE(ui));
+			let num: i32 = Math.floor(Config.raw.layout[layout_size_t.SIDEBAR_W] / slotw);
 
-			for (let row = 0; row < Math.floor(Math.ceil(Project.brushes.length / num)); ++row) {
-				let mult = Config.raw.show_asset_names ? 2 : 1;
-				let ar = [];
-				for (let i = 0; i < num * mult; ++i) ar.push(1 / num);
+			for (let row: i32 = 0; row < Math.floor(Math.ceil(Project.brushes.length / num)); ++row) {
+				let mult: i32 = Config.raw.show_asset_names ? 2 : 1;
+				let ar: f32[] = [];
+				for (let i: i32 = 0; i < num * mult; ++i) ar.push(1 / num);
 				zui_row(ar);
 
 				ui._x += 2;
-				let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
+				let off: f32 = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
 				if (row > 0) ui._y += off;
 
-				for (let j = 0; j < num; ++j) {
-					let imgw = Math.floor(50 * zui_SCALE(ui));
-					let i = j + row * num;
+				for (let j: i32 = 0; j < num; ++j) {
+					let imgw: i32 = Math.floor(50 * zui_SCALE(ui));
+					let i: i32 = j + row * num;
 					if (i >= Project.brushes.length) {
 						zui_end_element(imgw);
 						if (Config.raw.show_asset_names) zui_end_element(0);
 						continue;
 					}
-					let img = zui_SCALE(ui) > 1 ? Project.brushes[i].image : Project.brushes[i].imageIcon;
-					let imgFull = Project.brushes[i].image;
+					let img: image_t = zui_SCALE(ui) > 1 ? Project.brushes[i].image : Project.brushes[i].image_icon;
+					let imgFull: image_t = Project.brushes[i].image;
 
 					if (Context.raw.brush == Project.brushes[i]) {
 						// Zui.fill(1, -2, img.width + 3, img.height + 3, ui.t.HIGHLIGHT_COL); // TODO
-						let off = row % 2 == 1 ? 1 : 0;
-						let w = 50;
+						let off: i32 = row % 2 == 1 ? 1 : 0;
+						let w: i32 = 50;
 						if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2);
 						zui_fill(-1,         -2, w + 3,       2, ui.t.HIGHLIGHT_COL);
 						zui_fill(-1,    w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL);
@@ -58,43 +58,43 @@ class TabBrushes {
 						zui_fill(w + 1,      -2,     2,   w + 4, ui.t.HIGHLIGHT_COL);
 					}
 
-					let uix = ui._x;
-					//let uiy = ui._y;
-					let tile = zui_SCALE(ui) > 1 ? 100 : 50;
-					let state = Project.brushes[i].previewReady ? zui_image(img) : zui_image(Res.get("icons.k"), -1, -1.0, tile * 5, tile, tile, tile);
+					let uix: f32 = ui._x;
+					//let uiy: f32 = ui._y;
+					let tile: i32 = zui_SCALE(ui) > 1 ? 100 : 50;
+					let state: zui_state_t = Project.brushes[i].preview_ready ? zui_image(img) : zui_image(Res.get("icons.k"), -1, -1.0, tile * 5, tile, tile, tile);
 					if (state == zui_state_t.STARTED) {
-						if (Context.raw.brush != Project.brushes[i]) Context.selectBrush(i);
-						if (time_time() - Context.raw.selectTime < 0.25) UIBase.showBrushNodes();
-						Context.raw.selectTime = time_time();
+						if (Context.raw.brush != Project.brushes[i]) Context.select_brush(i);
+						if (time_time() - Context.raw.select_time < 0.25) UIBase.show_brush_nodes();
+						Context.raw.select_time = time_time();
 						// app_drag_off_x = -(mouse_x - uix - ui._windowX - 3);
 						// app_drag_off_y = -(mouse_y - uiy - ui._windowY + 1);
 						// app_drag_brush = Context.raw.brush;
 					}
 					if (ui.is_hovered && ui.input_released_r) {
-						Context.selectBrush(i);
-						let add = Project.brushes.length > 1 ? 1 : 0;
+						Context.select_brush(i);
+						let add: i32 = Project.brushes.length > 1 ? 1 : 0;
 						UIMenu.draw((ui: zui_t) => {
-							//let b = Project.brushes[i];
+							//let b: SlotBrushRaw = Project.brushes[i];
 
-							if (UIMenu.menuButton(ui, tr("Export"))) {
-								Context.selectBrush(i);
-								BoxExport.showBrush();
+							if (UIMenu.menu_button(ui, tr("Export"))) {
+								Context.select_brush(i);
+								BoxExport.show_brush();
 							}
 
-							if (UIMenu.menuButton(ui, tr("Duplicate"))) {
+							if (UIMenu.menu_button(ui, tr("Duplicate"))) {
 								let _init = () => {
 									Context.raw.brush = SlotBrush.create();
 									Project.brushes.push(Context.raw.brush);
-									let cloned = JSON.parse(JSON.stringify(Project.brushes[i].canvas));
+									let cloned: any = json_parse(json_stringify(Project.brushes[i].canvas));
 									Context.raw.brush.canvas = cloned;
-									Context.setBrush(Context.raw.brush);
-									UtilRender.makeBrushPreview();
+									Context.set_brush(Context.raw.brush);
+									UtilRender.make_brush_preview();
 								}
 								app_notify_on_init(_init);
 							}
 
-							if (Project.brushes.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) {
-								TabBrushes.deleteBrush(Project.brushes[i]);
+							if (Project.brushes.length > 1 && UIMenu.menu_button(ui, tr("Delete"), "delete")) {
+								TabBrushes.delete_brush(Project.brushes[i]);
 							}
 						}, 2 + add);
 					}
@@ -102,10 +102,10 @@ class TabBrushes {
 					if (ui.is_hovered) {
 						if (imgFull == null) {
 							app_notify_on_init(() => {
-								let _brush = Context.raw.brush;
+								let _brush: SlotBrushRaw = Context.raw.brush;
 								Context.raw.brush = Project.brushes[i];
-								MakeMaterial.parseBrush();
-								UtilRender.makeBrushPreview();
+								MakeMaterial.parse_brush();
+								UtilRender.make_brush_preview();
 								Context.raw.brush = _brush;
 							});
 						}
@@ -130,18 +130,18 @@ class TabBrushes {
 				ui._y += 6;
 			}
 
-			let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
-						  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
+			let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+						  		ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 			if (inFocus && ui.is_delete_down && Project.brushes.length > 1) {
 				ui.is_delete_down = false;
-				TabBrushes.deleteBrush(Context.raw.brush);
+				TabBrushes.delete_brush(Context.raw.brush);
 			}
 		}
 	}
 
-	static deleteBrush = (b: SlotBrushRaw) => {
-		let i = Project.brushes.indexOf(b);
-		Context.selectBrush(i == Project.brushes.length - 1 ? i - 1 : i + 1);
+	static delete_brush = (b: SlotBrushRaw) => {
+		let i: i32 = Project.brushes.indexOf(b);
+		Context.select_brush(i == Project.brushes.length - 1 ? i - 1 : i + 1);
 		Project.brushes.splice(i, 1);
 		UIBase.hwnds[1].redraws = 2;
 	}

+ 12 - 12
base/Sources/TabConsole.ts

@@ -2,13 +2,13 @@
 class TabConsole {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+		let ui: zui_t = UIBase.ui;
 
-		let title = Console.messageTimer > 0 ? Console.message + "        " : tr("Console");
-		let color = Console.messageTimer > 0 ? Console.messageColor : -1;
+		let title: string = Console.message_timer > 0 ? Console.message + "        " : tr("Console");
+		let color: i32 = Console.message_timer > 0 ? Console.message_color : -1;
 
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, title, false, color) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, title, false, color) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 			///if (krom_windows || krom_linux || krom_darwin) // Copy
@@ -28,12 +28,12 @@ class TabConsole {
 			///end
 
 			if (zui_button(tr("Clear"))) {
-				Console.lastTraces = [];
+				Console.last_traces = [];
 			}
 			if (zui_button(tr("Export"))) {
-				let str = Console.lastTraces.join("\n");
+				let str: string = Console.last_traces.join("\n");
 				UIFiles.show("txt", true, false, (path: string) => {
-					let f = UIFiles.filename;
+					let f: string = UIFiles.filename;
 					if (f == "") f = tr("untitled");
 					path = path + Path.sep + f;
 					if (!path.endsWith(".txt")) path += ".txt";
@@ -42,19 +42,19 @@ class TabConsole {
 			}
 			///if (krom_windows || krom_linux || krom_darwin)
 			if (zui_button(tr("Copy"))) {
-				let str = Console.lastTraces.join("\n");
+				let str: string = Console.last_traces.join("\n");
 				krom_copy_to_clipboard(str);
 			}
 			///end
 
 			zui_end_sticky();
 
-			let _font = ui.font;
-			let _fontSize = ui.font_size;
+			let _font: g2_font_t = ui.font;
+			let _fontSize: i32 = ui.font_size;
 			let f: g2_font_t = data_get_font("font_mono.ttf");
 			zui_set_font(ui, f);
 			ui.font_size = Math.floor(15 * zui_SCALE(ui));
-			for (let t of Console.lastTraces) {
+			for (let t of Console.last_traces) {
 				zui_text(t);
 			}
 			zui_set_font(ui, _font);

+ 38 - 39
base/Sources/TabFonts.ts

@@ -4,9 +4,9 @@
 class TabFonts {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Fonts")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Fonts")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 			if (Config.raw.touch_ui) {
@@ -16,43 +16,43 @@ class TabFonts {
 				zui_row([1 / 14, 1 / 14]);
 			}
 
-			if (zui_button(tr("Import"))) Project.importAsset("ttf,ttc,otf");
+			if (zui_button(tr("Import"))) Project.import_asset("ttf,ttc,otf");
 			if (ui.is_hovered) zui_tooltip(tr("Import font file"));
 
 			if (zui_button(tr("2D View"))) {
-				UIBase.show2DView(View2DType.View2DFont);
+				UIBase.show_2d_view(view_2d_type_t.FONT);
 			}
 			zui_end_sticky();
 			zui_separator(3, false);
 
-			let statusw = sys_width() - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
-			let slotw = Math.floor(51 * zui_SCALE(ui));
-			let num = Math.floor(statusw / slotw);
+			let statusw: i32 = sys_width() - UIToolbar.toolbar_w - Config.raw.layout[layout_size_t.SIDEBAR_W];
+			let slotw: i32 = Math.floor(51 * zui_SCALE(ui));
+			let num: i32 = Math.floor(statusw / slotw);
 
-			for (let row = 0; row < Math.floor(Math.ceil(Project.fonts.length / num)); ++row) {
-				let mult = Config.raw.show_asset_names ? 2 : 1;
-				let ar = [];
-				for (let i = 0; i < num * mult; ++i) ar.push(1 / num);
+			for (let row: i32 = 0; row < Math.floor(Math.ceil(Project.fonts.length / num)); ++row) {
+				let mult: i32 = Config.raw.show_asset_names ? 2 : 1;
+				let ar: f32[] = [];
+				for (let i: i32 = 0; i < num * mult; ++i) ar.push(1 / num);
 				zui_row(ar);
 
 				ui._x += 2;
-				let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
+				let off: f32 = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
 				if (row > 0) ui._y += off;
 
-				for (let j = 0; j < num; ++j) {
-					let imgw = Math.floor(50 * zui_SCALE(ui));
-					let i = j + row * num;
+				for (let j: i32 = 0; j < num; ++j) {
+					let imgw: i32 = Math.floor(50 * zui_SCALE(ui));
+					let i: i32 = j + row * num;
 					if (i >= Project.fonts.length) {
 						zui_end_element(imgw);
 						if (Config.raw.show_asset_names) zui_end_element(0);
 						continue;
 					}
-					let img = Project.fonts[i].image;
+					let img: image_t = Project.fonts[i].image;
 
 					if (Context.raw.font == Project.fonts[i]) {
 						// Zui.fill(1, -2, img.width + 3, img.height + 3, ui.t.HIGHLIGHT_COL); // TODO
-						let off = row % 2 == 1 ? 1 : 0;
-						let w = 50;
+						let off: i32 = row % 2 == 1 ? 1 : 0;
+						let w: i32 = 50;
 						if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2);
 						zui_fill(-1,         -2, w + 3,       2, ui.t.HIGHLIGHT_COL);
 						zui_fill(-1,    w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL);
@@ -60,10 +60,10 @@ class TabFonts {
 						zui_fill(w + 1,      -2,     2,   w + 4, ui.t.HIGHLIGHT_COL);
 					}
 
-					let uix = ui._x;
-					let tile = zui_SCALE(ui) > 1 ? 100 : 50;
-					let state = zui_state_t.IDLE;
-					if (Project.fonts[i].previewReady) {
+					let uix: f32 = ui._x;
+					let tile: i32 = zui_SCALE(ui) > 1 ? 100 : 50;
+					let state: zui_state_t = zui_state_t.IDLE;
+					if (Project.fonts[i].preview_ready) {
 						// g2_set_pipeline(UIView2D.pipe); // L8
 						// ///if krom_opengl
 						// g4_set_pipeline(UIView2D.pipe);
@@ -79,29 +79,28 @@ class TabFonts {
 					if (state == zui_state_t.STARTED) {
 						if (Context.raw.font != Project.fonts[i]) {
 							let _init = () => {
-								Context.selectFont(i);
+								Context.select_font(i);
 							}
 							app_notify_on_init(_init);
 						}
-						if (time_time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DFont);
-						Context.raw.selectTime = time_time();
+						if (time_time() - Context.raw.select_time < 0.25) UIBase.show_2d_view(view_2d_type_t.FONT);
+						Context.raw.select_time = time_time();
 					}
 					if (ui.is_hovered && ui.input_released_r) {
-						Context.selectFont(i);
-						let add = Project.fonts.length > 1 ? 1 : 0;
-						let fontName = Project.fonts[i].name;
+						Context.select_font(i);
+						let add: i32 = Project.fonts.length > 1 ? 1 : 0;
 						UIMenu.draw((ui: zui_t) => {
-							if (Project.fonts.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete") && Project.fonts[i].file != "") {
-								TabFonts.deleteFont(Project.fonts[i]);
+							if (Project.fonts.length > 1 && UIMenu.menu_button(ui, tr("Delete"), "delete") && Project.fonts[i].file != "") {
+								TabFonts.delete_font(Project.fonts[i]);
 							}
 						}, 0 + add);
 					}
 					if (ui.is_hovered) {
 						if (img == null) {
 							app_notify_on_init(() => {
-								let _font = Context.raw.font;
+								let _font: SlotFontRaw = Context.raw.font;
 								Context.raw.font = Project.fonts[i];
-								UtilRender.makeFontPreview();
+								UtilRender.make_font_preview();
 								Context.raw.font = _font;
 							});
 						}
@@ -126,19 +125,19 @@ class TabFonts {
 				ui._y += 6;
 			}
 
-			let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
-						  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
+			let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+						  		ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 			if (inFocus && ui.is_delete_down && Project.fonts.length > 1 && Context.raw.font.file != "") {
 				ui.is_delete_down = false;
-				TabFonts.deleteFont(Context.raw.font);
+				TabFonts.delete_font(Context.raw.font);
 			}
 		}
 	}
 
-	static deleteFont = (font: SlotFontRaw) => {
-		let i = Project.fonts.indexOf(font);
+	static delete_font = (font: SlotFontRaw) => {
+		let i: i32 = Project.fonts.indexOf(font);
 		let _init = () => {
-			Context.selectFont(i == Project.fonts.length - 1 ? i - 1 : i + 1);
+			Context.select_font(i == Project.fonts.length - 1 ? i - 1 : i + 1);
 			data_delete_font(Project.fonts[i].file);
 			Project.fonts.splice(i, 1);
 		}

+ 4 - 4
base/Sources/TabHistory.ts

@@ -4,16 +4,16 @@
 class TabHistory {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+		let ui: zui_t = UIBase.ui;
 		if (zui_tab(htab, tr("History"))) {
-			for (let i = 0; i < History.steps.length; ++i) {
-				let active = History.steps.length - 1 - History.redos;
+			for (let i: i32 = 0; i < History.steps.length; ++i) {
+				let active: i32 = History.steps.length - 1 - History.redos;
 				if (i == active) {
 					zui_fill(0, 0, ui._window_w, ui.t.ELEMENT_H, ui.t.HIGHLIGHT_COL);
 				}
 				zui_text(History.steps[i].name);
 				if (ui.is_released) { // Jump to undo step
-					let diff = i - active;
+					let diff: i32 = i - active;
 					while (diff > 0) {
 						diff--;
 						History.redo();

+ 121 - 124
base/Sources/TabMaterials.ts

@@ -4,86 +4,84 @@
 class TabMaterials {
 
 	static draw = (htab: zui_handle_t) => {
-		let mini = Config.raw.layout[LayoutSize.LayoutSidebarW] <= UIBase.sidebarMiniW;
-		mini ? TabMaterials.drawMini(htab) : TabMaterials.drawFull(htab);
+		let mini: bool = Config.raw.layout[layout_size_t.SIDEBAR_W] <= UIBase.sidebar_mini_w;
+		mini ? TabMaterials.draw_mini(htab) : TabMaterials.draw_full(htab);
 	}
 
-	static drawMini = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+	static draw_mini = (htab: zui_handle_t) => {
 		zui_set_hovered_tab_name(tr("Materials"));
 
 		zui_begin_sticky();
 		zui_separator(5);
 
-		TabMaterials.buttonNodes();
-		TabMaterials.buttonNew("+");
+		TabMaterials.button_nodes();
+		TabMaterials.button_new("+");
 
 		zui_end_sticky();
 		zui_separator(3, false);
-		TabMaterials.drawSlots(true);
+		TabMaterials.draw_slots(true);
 	}
 
-	static drawFull = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+	static draw_full = (htab: zui_handle_t) => {
 		if (zui_tab(htab, tr("Materials"))) {
 			zui_begin_sticky();
 			zui_row([1 / 4, 1 / 4, 1 / 4]);
 
-			TabMaterials.buttonNew(tr("New"));
+			TabMaterials.button_new(tr("New"));
 			if (zui_button(tr("Import"))) {
-				Project.importMaterial();
+				Project.import_material();
 			}
-			TabMaterials.buttonNodes();
+			TabMaterials.button_nodes();
 
 			zui_end_sticky();
 			zui_separator(3, false);
-			TabMaterials.drawSlots(false);
+			TabMaterials.draw_slots(false);
 		}
 	}
 
-	static buttonNodes = () => {
-		let ui = UIBase.ui;
+	static button_nodes = () => {
+		let ui: zui_t = UIBase.ui;
 		if (zui_button(tr("Nodes"))) {
-			UIBase.showMaterialNodes();
+			UIBase.show_material_nodes();
 		}
 		else if (ui.is_hovered) zui_tooltip(tr("Show Node Editor") + ` (${Config.keymap.toggle_node_editor})`);
 	}
 
-	static drawSlots = (mini: bool) => {
-		let ui = UIBase.ui;
-		let slotw = Math.floor(51 * zui_SCALE(ui));
-		let num = Math.floor(Config.raw.layout[LayoutSize.LayoutSidebarW] / slotw);
+	static draw_slots = (mini: bool) => {
+		let ui: zui_t = UIBase.ui;
+		let slotw: i32 = Math.floor(51 * zui_SCALE(ui));
+		let num: i32 = Math.floor(Config.raw.layout[layout_size_t.SIDEBAR_W] / slotw);
 
-		for (let row = 0; row < Math.floor(Math.ceil(Project.materials.length / num)); ++row) {
-			let mult = Config.raw.show_asset_names ? 2 : 1;
-			let ar = [];
+		for (let row: i32 = 0; row < Math.floor(Math.ceil(Project.materials.length / num)); ++row) {
+			let mult: i32 = Config.raw.show_asset_names ? 2 : 1;
+			let ar: f32[] = [];
 			for (let i = 0; i < num * mult; ++i) ar.push(1 / num);
 			zui_row(ar);
 
 			ui._x += 2;
-			let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
+			let off: f32 = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
 			if (row > 0) ui._y += off;
 
-			for (let j = 0; j < num; ++j) {
-				let imgw = Math.floor(50 * zui_SCALE(ui));
-				let i = j + row * num;
+			for (let j: i32 = 0; j < num; ++j) {
+				let imgw: i32 = Math.floor(50 * zui_SCALE(ui));
+				let i: i32 = j + row * num;
 				if (i >= Project.materials.length) {
 					zui_end_element(imgw);
 					if (Config.raw.show_asset_names) zui_end_element(0);
 					continue;
 				}
-				let img = zui_SCALE(ui) > 1 ? Project.materials[i].image : Project.materials[i].imageIcon;
-				let imgFull = Project.materials[i].image;
+				let img: image_t = zui_SCALE(ui) > 1 ? Project.materials[i].image : Project.materials[i].image_icon;
+				let imgFull: image_t = Project.materials[i].image;
 
 				// Highligh selected
 				if (Context.raw.material == Project.materials[i]) {
 					if (mini) {
-						let w = ui._w / zui_SCALE(ui);
+						let w: f32 = ui._w / zui_SCALE(ui);
 						zui_rect(0, -2, w - 2, w - 4, ui.t.HIGHLIGHT_COL, 3);
 					}
 					else {
-						let off = row % 2 == 1 ? 1 : 0;
-						let w = 50;
+						let off: i32 = row % 2 == 1 ? 1 : 0;
+						let w: i32 = 50;
 						if (Config.raw.window_scale > 1) w += Math.floor(Config.raw.window_scale * 2);
 						zui_fill(-1,         -2, w + 3,       2, ui.t.HIGHLIGHT_COL);
 						zui_fill(-1,    w - off, w + 3, 2 + off, ui.t.HIGHLIGHT_COL);
@@ -93,25 +91,25 @@ class TabMaterials {
 				}
 
 				///if krom_opengl
-				ui.image_invert_y = Project.materials[i].previewReady;
+				ui.image_invert_y = Project.materials[i].preview_ready;
 				///end
 
 				// Draw material icon
-				let uix = ui._x;
-				let uiy = ui._y;
-				let tile = zui_SCALE(ui) > 1 ? 100 : 50;
-				let imgh: f32 = mini ? UIBase.defaultSidebarMiniW * 0.85 * zui_SCALE(ui) : -1.0;
-				let state = Project.materials[i].previewReady ?
+				let uix: f32 = ui._x;
+				let uiy: f32 = ui._y;
+				let tile: i32 = zui_SCALE(ui) > 1 ? 100 : 50;
+				let imgh: f32 = mini ? UIBase.default_sidebar_mini_w * 0.85 * zui_SCALE(ui) : -1.0;
+				let state = Project.materials[i].preview_ready ?
 					zui_image(img, 0xffffffff, imgh) :
 					zui_image(Res.get("icons.k"), 0xffffffff, -1.0, tile, tile, tile, tile);
 
 				// Draw material numbers when selecting a material via keyboard shortcut
-				let isTyping = ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing;
+				let isTyping: bool = ui.is_typing || UIView2D.ui.is_typing || UINodes.ui.is_typing;
 				if (!isTyping) {
 					if (i < 9 && Operator.shortcut(Config.keymap.select_material, ShortcutType.ShortcutDown)) {
-						let number = String(i + 1);
-						let width = g2_font_width(ui.font, ui.font_size, number) + 10;
-						let height = g2_font_height(ui.font, ui.font_size);
+						let number: string = String(i + 1);
+						let width: i32 = g2_font_width(ui.font, ui.font_size, number) + 10;
+						let height: i32 = g2_font_height(ui.font, ui.font_size);
 						g2_set_color(ui.t.TEXT_COL);
 						g2_fill_rect(uix, uiy, width, height);
 						g2_set_color(ui.t.ACCENT_COL);
@@ -122,96 +120,96 @@ class TabMaterials {
 				// Select material
 				if (state == zui_state_t.STARTED && ui.input_y > ui._window_y) {
 					if (Context.raw.material != Project.materials[i]) {
-						Context.selectMaterial(i);
+						Context.select_material(i);
 						///if is_paint
-						if (Context.raw.tool == WorkspaceTool.ToolMaterial) {
+						if (Context.raw.tool == workspace_tool_t.MATERIAL) {
 							let _init = () => {
-								Base.updateFillLayers();
+								Base.update_fill_layers();
 							}
 							app_notify_on_init(_init);
 						}
 						///end
 					}
-					Base.dragOffX = -(mouse_x - uix - ui._window_x - 3);
-					Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1);
-					Base.dragMaterial = Context.raw.material;
+					Base.drag_off_x = -(mouse_x - uix - ui._window_x - 3);
+					Base.drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
+					Base.drag_material = Context.raw.material;
 					// Double click to show nodes
-					if (time_time() - Context.raw.selectTime < 0.25) {
-						UIBase.showMaterialNodes();
-						Base.dragMaterial = null;
-						Base.isDragging = false;
+					if (time_time() - Context.raw.select_time < 0.25) {
+						UIBase.show_material_nodes();
+						Base.drag_material = null;
+						Base.is_dragging = false;
 					}
-					Context.raw.selectTime = time_time();
+					Context.raw.select_time = time_time();
 				}
 
 				// Context menu
 				if (ui.is_hovered && ui.input_released_r) {
-					Context.selectMaterial(i);
-					let add = Project.materials.length > 1 ? 1 : 0;
+					Context.select_material(i);
+					let add: i32 = Project.materials.length > 1 ? 1 : 0;
 
 					UIMenu.draw((ui: zui_t) => {
-						let m = Project.materials[i];
+						let m: SlotMaterialRaw = Project.materials[i];
 
-						if (UIMenu.menuButton(ui, tr("To Fill Layer"))) {
-							Context.selectMaterial(i);
-							Base.createFillLayer();
+						if (UIMenu.menu_button(ui, tr("To Fill Layer"))) {
+							Context.select_material(i);
+							Base.create_fill_layer();
 						}
 
-						if (UIMenu.menuButton(ui, tr("Export"))) {
-							Context.selectMaterial(i);
-							BoxExport.showMaterial();
+						if (UIMenu.menu_button(ui, tr("Export"))) {
+							Context.select_material(i);
+							BoxExport.show_material();
 						}
 
 						///if is_paint
-						if (UIMenu.menuButton(ui, tr("Bake"))) {
-							Context.selectMaterial(i);
-							BoxExport.showBakeMaterial();
+						if (UIMenu.menu_button(ui, tr("Bake"))) {
+							Context.select_material(i);
+							BoxExport.show_bake_material();
 						}
 						///end
 
-						if (UIMenu.menuButton(ui, tr("Duplicate"))) {
+						if (UIMenu.menu_button(ui, tr("Duplicate"))) {
 							let _init = () => {
 								Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 								Project.materials.push(Context.raw.material);
-								let cloned = JSON.parse(JSON.stringify(Project.materials[i].canvas));
+								let cloned: zui_node_canvas_t = json_parse(json_stringify(Project.materials[i].canvas));
 								Context.raw.material.canvas = cloned;
-								TabMaterials.updateMaterial();
-								History.duplicateMaterial();
+								TabMaterials.update_material();
+								History.duplicate_material();
 							}
 							app_notify_on_init(_init);
 						}
 
-						if (Project.materials.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) {
-							TabMaterials.deleteMaterial(m);
+						if (Project.materials.length > 1 && UIMenu.menu_button(ui, tr("Delete"), "delete")) {
+							TabMaterials.delete_material(m);
 						}
 
-						let baseHandle = zui_nest(zui_handle("tabmaterials_0"), m.id, {selected: m.paintBase});
-						let opacHandle = zui_nest(zui_handle("tabmaterials_1"), m.id, {selected: m.paintOpac});
-						let norHandle = zui_nest(zui_handle("tabmaterials_2"), m.id, {selected: m.paintNor});
-						let occHandle = zui_nest(zui_handle("tabmaterials_3"), m.id, {selected: m.paintOcc});
-						let roughHandle = zui_nest(zui_handle("tabmaterials_4"), m.id, {selected: m.paintRough});
-						let metHandle = zui_nest(zui_handle("tabmaterials_5"), m.id, {selected: m.paintMet});
-						let heightHandle = zui_nest(zui_handle("tabmaterials_6"), m.id, {selected: m.paintHeight});
-						let emisHandle = zui_nest(zui_handle("tabmaterials_7"), m.id, {selected: m.paintEmis});
-						let subsHandle = zui_nest(zui_handle("tabmaterials_8"), m.id, {selected: m.paintSubs});
-						UIMenu.menuFill(ui);
-						m.paintBase = zui_check(baseHandle, tr("Base Color"));
-						UIMenu.menuFill(ui);
-						m.paintOpac = zui_check(opacHandle, tr("Opacity"));
-						UIMenu.menuFill(ui);
-						m.paintNor = zui_check(norHandle, tr("Normal"));
-						UIMenu.menuFill(ui);
-						m.paintOcc = zui_check(occHandle, tr("Occlusion"));
-						UIMenu.menuFill(ui);
-						m.paintRough = zui_check(roughHandle, tr("Roughness"));
-						UIMenu.menuFill(ui);
-						m.paintMet = zui_check(metHandle, tr("Metallic"));
-						UIMenu.menuFill(ui);
-						m.paintHeight = zui_check(heightHandle, tr("Height"));
-						UIMenu.menuFill(ui);
-						m.paintEmis = zui_check(emisHandle, tr("Emission"));
-						UIMenu.menuFill(ui);
-						m.paintSubs = zui_check(subsHandle, tr("Subsurface"));
+						let baseHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_0"), m.id, {selected: m.paint_base});
+						let opacHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_1"), m.id, {selected: m.paint_opac});
+						let norHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_2"), m.id, {selected: m.paint_nor});
+						let occHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_3"), m.id, {selected: m.paint_occ});
+						let roughHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_4"), m.id, {selected: m.paint_rough});
+						let metHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_5"), m.id, {selected: m.paint_met});
+						let heightHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_6"), m.id, {selected: m.paint_height});
+						let emisHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_7"), m.id, {selected: m.paint_emis});
+						let subsHandle: zui_handle_t = zui_nest(zui_handle("tabmaterials_8"), m.id, {selected: m.paint_subs});
+						UIMenu.menu_fill(ui);
+						m.paint_base = zui_check(baseHandle, tr("Base Color"));
+						UIMenu.menu_fill(ui);
+						m.paint_opac = zui_check(opacHandle, tr("Opacity"));
+						UIMenu.menu_fill(ui);
+						m.paint_nor = zui_check(norHandle, tr("Normal"));
+						UIMenu.menu_fill(ui);
+						m.paint_occ = zui_check(occHandle, tr("Occlusion"));
+						UIMenu.menu_fill(ui);
+						m.paint_rough = zui_check(roughHandle, tr("Roughness"));
+						UIMenu.menu_fill(ui);
+						m.paint_met = zui_check(metHandle, tr("Metallic"));
+						UIMenu.menu_fill(ui);
+						m.paint_height = zui_check(heightHandle, tr("Height"));
+						UIMenu.menu_fill(ui);
+						m.paint_emis = zui_check(emisHandle, tr("Emission"));
+						UIMenu.menu_fill(ui);
+						m.paint_subs = zui_check(subsHandle, tr("Subsurface"));
 						if (baseHandle.changed ||
 							opacHandle.changed ||
 							norHandle.changed ||
@@ -221,8 +219,8 @@ class TabMaterials {
 							heightHandle.changed ||
 							emisHandle.changed ||
 							subsHandle.changed) {
-							MakeMaterial.parsePaintMaterial();
-							UIMenu.keepOpen = true;
+							MakeMaterial.parse_paint_material();
+							UIMenu.keep_open = true;
 						}
 					}, 13 + add);
 				}
@@ -254,38 +252,37 @@ class TabMaterials {
 			///end
 		}
 
-		let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
-					  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
+		let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+					  		ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 		if (inFocus && ui.is_delete_down && Project.materials.length > 1) {
 			ui.is_delete_down = false;
-			TabMaterials.deleteMaterial(Context.raw.material);
+			TabMaterials.delete_material(Context.raw.material);
 		}
 	}
 
-	static buttonNew = (text: string) => {
-		let ui = UIBase.ui;
+	static button_new = (text: string) => {
 		if (zui_button(text)) {
-			let current = _g2_current;
+			let current: image_t = _g2_current;
 			g2_end();
 			Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 			Project.materials.push(Context.raw.material);
-			TabMaterials.updateMaterial();
+			TabMaterials.update_material();
 			g2_begin(current);
-			History.newMaterial();
+			History.new_material();
 		}
 	}
 
-	static updateMaterial = () => {
-		UIHeader.headerHandle.redraws = 2;
+	static update_material = () => {
+		UIHeader.header_handle.redraws = 2;
 		UINodes.hwnd.redraws = 2;
-		UINodes.groupStack = [];
-		MakeMaterial.parsePaintMaterial();
-		UtilRender.makeMaterialPreview();
-		let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
-		if (decal) UtilRender.makeDecalPreview();
+		UINodes.group_stack = [];
+		MakeMaterial.parse_paint_material();
+		UtilRender.make_material_preview();
+		let decal: bool = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
+		if (decal) UtilRender.make_decal_preview();
 	}
 
-	static updateMaterialPointers = (nodes: zui_node_t[], i: i32) => {
+	static update_material_pointers = (nodes: zui_node_t[], i: i32) => {
 		for (let n of nodes) {
 			if (n.type == "MATERIAL") {
 				if (n.buttons[0].default_value == i) {
@@ -298,7 +295,7 @@ class TabMaterials {
 		}
 	}
 
-	static acceptSwatchDrag = (swatch: TSwatchColor) => {
+	static accept_swatch_drag = (swatch: swatch_color_t) => {
 		Context.raw.material = SlotMaterial.create(Project.materials[0].data);
 		for (let node of Context.raw.material.canvas.nodes) {
 			if (node.type == "RGB" ) {
@@ -318,18 +315,18 @@ class TabMaterials {
 			}
 		}
 		Project.materials.push(Context.raw.material);
-		TabMaterials.updateMaterial();
-		History.newMaterial();
+		TabMaterials.update_material();
+		History.new_material();
 	}
 
-	static deleteMaterial = (m: SlotMaterialRaw) => {
-		let i = Project.materials.indexOf(m);
+	static delete_material = (m: SlotMaterialRaw) => {
+		let i: i32 = Project.materials.indexOf(m);
 		for (let l of Project.layers) if (l.fill_layer == m) l.fill_layer = null;
-		History.deleteMaterial();
-		Context.selectMaterial(i == Project.materials.length - 1 ? i - 1 : i + 1);
+		History.delete_material();
+		Context.select_material(i == Project.materials.length - 1 ? i - 1 : i + 1);
 		Project.materials.splice(i, 1);
 		UIBase.hwnds[1].redraws = 2;
-		for (let m of Project.materials) TabMaterials.updateMaterialPointers(m.canvas.nodes, i);
+		for (let m of Project.materials) TabMaterials.update_material_pointers(m.canvas.nodes, i);
 	}
 }
 

+ 51 - 51
base/Sources/TabMeshes.ts

@@ -2,9 +2,9 @@
 class TabMeshes {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Meshes")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Meshes")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 
@@ -28,11 +28,11 @@ class TabMeshes {
 
 			if (zui_button(tr("Import"))) {
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Replace Existing"), `${Config.keymap.file_import_assets}`)) {
-						Project.importMesh(true);
+					if (UIMenu.menu_button(ui, tr("Replace Existing"), `${Config.keymap.file_import_assets}`)) {
+						Project.import_mesh(true);
 					}
-					if (UIMenu.menuButton(ui, tr("Append"))) {
-						Project.importMesh(false);
+					if (UIMenu.menu_button(ui, tr("Append"))) {
+						Project.import_mesh(false);
 					}
 				}, 2);
 			}
@@ -41,59 +41,59 @@ class TabMeshes {
 			///if is_lab
 			if (zui_button(tr("Set Default"))) {
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Cube"))) TabMeshes.setDefaultMesh(".Cube");
-					if (UIMenu.menuButton(ui, tr("Plane"))) TabMeshes.setDefaultMesh(".Plane");
-					if (UIMenu.menuButton(ui, tr("Sphere"))) TabMeshes.setDefaultMesh(".Sphere");
-					if (UIMenu.menuButton(ui, tr("Cylinder"))) TabMeshes.setDefaultMesh(".Cylinder");
+					if (UIMenu.menu_button(ui, tr("Cube"))) TabMeshes.set_default_mesh(".Cube");
+					if (UIMenu.menu_button(ui, tr("Plane"))) TabMeshes.set_default_mesh(".Plane");
+					if (UIMenu.menu_button(ui, tr("Sphere"))) TabMeshes.set_default_mesh(".Sphere");
+					if (UIMenu.menu_button(ui, tr("Cylinder"))) TabMeshes.set_default_mesh(".Cylinder");
 				}, 4);
 			}
 			///end
 
 			if (zui_button(tr("Flip Normals"))) {
-				UtilMesh.flipNormals();
+				UtilMesh.flip_normals();
 				Context.raw.ddirty = 2;
 			}
 
 			if (zui_button(tr("Calculate Normals"))) {
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Smooth"))) { UtilMesh.calcNormals(true); Context.raw.ddirty = 2; }
-					if (UIMenu.menuButton(ui, tr("Flat"))) { UtilMesh.calcNormals(false); Context.raw.ddirty = 2; }
+					if (UIMenu.menu_button(ui, tr("Smooth"))) { UtilMesh.calc_normals(true); Context.raw.ddirty = 2; }
+					if (UIMenu.menu_button(ui, tr("Flat"))) { UtilMesh.calc_normals(false); Context.raw.ddirty = 2; }
 				}, 2);
 			}
 
 			if (zui_button(tr("Geometry to Origin"))) {
-				UtilMesh.toOrigin();
+				UtilMesh.to_origin();
 				Context.raw.ddirty = 2;
 			}
 
 			if (zui_button(tr("Apply Displacement"))) {
 				///if is_paint
-				UtilMesh.applyDisplacement(Project.layers[0].texpaint_pack);
+				UtilMesh.apply_displacement(Project.layers[0].texpaint_pack);
 				///end
 				///if is_lab
-				let displace_strength = Config.raw.displace_strength > 0 ? Config.raw.displace_strength : 1.0;
-				let uv_scale = scene_meshes[0].data.scale_tex * Context.raw.brushScale;
-				UtilMesh.applyDisplacement(BrushOutputNode.inst.texpaint_pack, 0.05 * displace_strength, uv_scale);
+				let displace_strength: f32 = Config.raw.displace_strength > 0 ? Config.raw.displace_strength : 1.0;
+				let uv_scale: f32 = scene_meshes[0].data.scale_tex * Context.raw.brush_scale;
+				UtilMesh.apply_displacement(BrushOutputNode.inst.texpaint_pack, 0.05 * displace_strength, uv_scale);
 				///end
 
-				UtilMesh.calcNormals();
+				UtilMesh.calc_normals();
 				Context.raw.ddirty = 2;
 			}
 
 			if (zui_button(tr("Rotate"))) {
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Rotate X"))) {
-						UtilMesh.swapAxis(1, 2);
+					if (UIMenu.menu_button(ui, tr("Rotate X"))) {
+						UtilMesh.swap_axis(1, 2);
 						Context.raw.ddirty = 2;
 					}
 
-					if (UIMenu.menuButton(ui, tr("Rotate Y"))) {
-						UtilMesh.swapAxis(2, 0);
+					if (UIMenu.menu_button(ui, tr("Rotate Y"))) {
+						UtilMesh.swap_axis(2, 0);
 						Context.raw.ddirty = 2;
 					}
 
-					if (UIMenu.menuButton(ui, tr("Rotate Z"))) {
-						UtilMesh.swapAxis(0, 1);
+					if (UIMenu.menu_button(ui, tr("Rotate Z"))) {
+						UtilMesh.swap_axis(0, 1);
 						Context.raw.ddirty = 2;
 					}
 				}, 3);
@@ -101,42 +101,42 @@ class TabMeshes {
 
 			zui_end_sticky();
 
-			for (let i = 0; i < Project.paintObjects.length; ++i) {
-				let o = Project.paintObjects[i];
-				let h = zui_handle("tabmeshes_0");
+			for (let i: i32 = 0; i < Project.paint_objects.length; ++i) {
+				let o: mesh_object_t = Project.paint_objects[i];
+				let h: zui_handle_t = zui_handle("tabmeshes_0");
 				h.selected = o.base.visible;
 				o.base.visible = zui_check(h, o.base.name);
 				if (ui.is_hovered && ui.input_released_r) {
 					UIMenu.draw((ui: zui_t) => {
-						if (UIMenu.menuButton(ui, tr("Export"))) {
-							Context.raw.exportMeshIndex = i + 1;
-							BoxExport.showMesh();
+						if (UIMenu.menu_button(ui, tr("Export"))) {
+							Context.raw.export_mesh_index = i + 1;
+							BoxExport.show_mesh();
 						}
-						if (Project.paintObjects.length > 1 && UIMenu.menuButton(ui, tr("Delete"))) {
-							array_remove(Project.paintObjects, o);
+						if (Project.paint_objects.length > 1 && UIMenu.menu_button(ui, tr("Delete"))) {
+							array_remove(Project.paint_objects, o);
 							while (o.base.children.length > 0) {
-								let child = o.base.children[0];
+								let child: object_t = o.base.children[0];
 								object_set_parent(child, null);
-								if (Project.paintObjects[0].base != child) {
-									object_set_parent(child, Project.paintObjects[0].base);
+								if (Project.paint_objects[0].base != child) {
+									object_set_parent(child, Project.paint_objects[0].base);
 								}
 								if (o.base.children.length == 0) {
-									vec4_set_from(Project.paintObjects[0].base.transform.scale, o.base.transform.scale);
-									transform_build_matrix(Project.paintObjects[0].base.transform);
+									vec4_set_from(Project.paint_objects[0].base.transform.scale, o.base.transform.scale);
+									transform_build_matrix(Project.paint_objects[0].base.transform);
 								}
 							}
 							data_delete_mesh(o.data._.handle);
 							mesh_object_remove(o);
-							Context.raw.paintObject = Context.mainObject();
-							UtilMesh.mergeMesh();
+							Context.raw.paint_object = Context.main_object();
+							UtilMesh.merge_mesh();
 							Context.raw.ddirty = 2;
 						}
-					}, Project.paintObjects.length > 1 ? 2 : 1);
+					}, Project.paint_objects.length > 1 ? 2 : 1);
 				}
 				if (h.changed) {
 					let visibles: mesh_object_t[] = [];
-					for (let p of Project.paintObjects) if (p.base.visible) visibles.push(p);
-					UtilMesh.mergeMesh(visibles);
+					for (let p of Project.paint_objects) if (p.base.visible) visibles.push(p);
+					UtilMesh.merge_mesh(visibles);
 					Context.raw.ddirty = 2;
 				}
 			}
@@ -144,12 +144,12 @@ class TabMeshes {
 	}
 
 	///if is_lab
-	static setDefaultMesh = (name: string) => {
+	static set_default_mesh = (name: string) => {
 		let mo: mesh_object_t = null;
 		if (name == ".Plane" || name == ".Sphere") {
-			let res = Config.raw.rp_supersample > 1.0 ? 2048 : 1024;
+			let res: i32 = Config.raw.rp_supersample > 1.0 ? 2048 : 1024;
 			let mesh: any = name == ".Plane" ? Geom.make_plane(1, 1, res, res) : Geom.make_uv_sphere(1.0, res, Math.floor(res / 2), false, 2.0);
-			let raw = {
+			let raw: any = {
 				name: "Tessellated",
 				vertex_arrays: [
 					{ values: mesh.posa, attrib: "pos", data: "short4norm" },
@@ -163,7 +163,7 @@ class TabMeshes {
 				scale_tex: mesh.scaleTex
 			};
 			let md: mesh_data_t = mesh_data_create(raw);
-			mo = mesh_object_create(md, Context.raw.paintObject.materials);
+			mo = mesh_object_create(md, Context.raw.paint_object.materials);
 			array_remove(scene_meshes, mo);
 			mo.base.name = "Tessellated";
 		}
@@ -173,9 +173,9 @@ class TabMeshes {
 
 		mo.base.visible = true;
 		Context.raw.ddirty = 2;
-		Context.raw.paintObject = mo;
-		Project.paintObjects[0] = mo;
-		if (UIHeader.worktab.position == SpaceType.Space3D) {
+		Context.raw.paint_object = mo;
+		Project.paint_objects[0] = mo;
+		if (UIHeader.worktab.position == space_type_t.SPACE3D) {
 			scene_meshes = [mo];
 		}
 

+ 2 - 2
base/Sources/TabPlugins.ts

@@ -2,7 +2,7 @@
 class TabPlugins {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
+		let ui: zui_t = UIBase.ui;
 		if (zui_tab(htab, tr("Plugins"))) {
 
 			zui_begin_sticky();
@@ -21,7 +21,7 @@ class TabPlugins {
 			zui_end_sticky();
 
 			// Draw plugins
-			for (let p of Plugin.plugins.values()) if (p.drawUI != null) p.drawUI(ui);
+			for (let p of Plugin.plugins.values()) if (p.draw_ui != null) p.draw_ui(ui);
 		}
 	}
 }

+ 16 - 16
base/Sources/TabScript.ts

@@ -1,13 +1,13 @@
 
 class TabScript {
 
-	static hscript = zui_handle_create();
-	static textColoring: zui_text_coloring_t = null;
+	static hscript: zui_handle_t = zui_handle_create();
+	static text_coloring: zui_text_coloring_t = null;
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Script")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Script")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 			if (Config.raw.touch_ui) {
@@ -35,9 +35,9 @@ class TabScript {
 				});
 			}
 			if (zui_button(tr("Export"))) {
-				let str = TabScript.hscript.text;
+				let str: string = TabScript.hscript.text;
 				UIFiles.show("js", true, false, (path: string) => {
-					let f = UIFiles.filename;
+					let f: string = UIFiles.filename;
 					if (f == "") f = tr("untitled");
 					path = path + Path.sep + f;
 					if (!path.endsWith(".js")) path += ".js";
@@ -46,14 +46,14 @@ class TabScript {
 			}
 			zui_end_sticky();
 
-			let _font = ui.font;
-			let _fontSize = ui.font_size;
+			let _font: g2_font_t = ui.font;
+			let _fontSize: i32 = ui.font_size;
 			let f: g2_font_t = data_get_font("font_mono.ttf");
 			zui_set_font(ui, f);
 			ui.font_size = Math.floor(15 * zui_SCALE(ui));
 			zui_set_text_area_line_numbers(true);
 			zui_set_text_area_scroll_past_end(true);
-			zui_set_text_area_coloring(TabScript.getTextColoring());
+			zui_set_text_area_coloring(TabScript.get_text_coloring());
 			zui_text_area(TabScript.hscript);
 			zui_set_text_area_line_numbers(false);
 			zui_set_text_area_scroll_past_end(false);
@@ -63,15 +63,15 @@ class TabScript {
 		}
 	}
 
-	static getTextColoring = (): zui_text_coloring_t => {
-		if (TabScript.textColoring == null) {
+	static get_text_coloring = (): zui_text_coloring_t => {
+		if (TabScript.text_coloring == null) {
 			let blob: ArrayBuffer = data_get_blob("text_coloring.json");
-			TabScript.textColoring = JSON.parse(sys_buffer_to_string(blob));
-			TabScript.textColoring.default_color = Math.floor(TabScript.textColoring.default_color);
-			for (let coloring of TabScript.textColoring.colorings) {
+			TabScript.text_coloring = JSON.parse(sys_buffer_to_string(blob));
+			TabScript.text_coloring.default_color = Math.floor(TabScript.text_coloring.default_color);
+			for (let coloring of TabScript.text_coloring.colorings) {
 				coloring.color = Math.floor(coloring.color);
 			}
 		}
-		return TabScript.textColoring;
+		return TabScript.text_coloring;
 	}
 }

+ 78 - 80
base/Sources/TabSwatches.ts

@@ -2,6 +2,7 @@
 class TabSwatches {
 
 	static _empty: image_t;
+	static drag_pos: i32 = -1;
 
 	static set empty(image: image_t) {
 		TabSwatches._empty = image;
@@ -9,7 +10,7 @@ class TabSwatches {
 
 	static get empty(): image_t {
 		if (TabSwatches._empty == null) {
-			let b = new Uint8Array(4);
+			let b: Uint8Array = new Uint8Array(4);
 			b[0] = 255;
 			b[1] = 255;
 			b[2] = 255;
@@ -19,12 +20,10 @@ class TabSwatches {
 		return TabSwatches._empty;
 	}
 
-	static dragPosition: i32 = -1;
-
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Swatches")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Swatches")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 			if (Config.raw.touch_ui) {
@@ -35,65 +34,64 @@ class TabSwatches {
 			}
 
 			if (zui_button(tr("New"))) {
-				Context.setSwatch(Project.makeSwatch());
+				Context.set_swatch(Project.make_swatch());
 				Project.raw.swatches.push(Context.raw.swatch);
 			}
 			if (ui.is_hovered) zui_tooltip(tr("Add new swatch"));
 
 			if (zui_button(tr("Import"))) {
 				UIMenu.draw((ui: zui_t) => {
-					if (UIMenu.menuButton(ui, tr("Replace Existing"))) {
-						Project.importSwatches(true);
-						Context.setSwatch(Project.raw.swatches[0]);
+					if (UIMenu.menu_button(ui, tr("Replace Existing"))) {
+						Project.import_swatches(true);
+						Context.set_swatch(Project.raw.swatches[0]);
 					}
-					if (UIMenu.menuButton(ui, tr("Append"))) {
-						Project.importSwatches(false);
+					if (UIMenu.menu_button(ui, tr("Append"))) {
+						Project.import_swatches(false);
 					}
 				}, 2);
 			}
 			if (ui.is_hovered) zui_tooltip(tr("Import swatches"));
 
-			if (zui_button(tr("Export"))) Project.exportSwatches();
+			if (zui_button(tr("Export"))) Project.export_swatches();
 			if (ui.is_hovered) zui_tooltip(tr("Export swatches"));
 
 			if (zui_button(tr("Clear"))) {
-				Context.setSwatch(Project.makeSwatch());
+				Context.set_swatch(Project.make_swatch());
 				Project.raw.swatches = [Context.raw.swatch];
 			}
 
 			if (zui_button(tr("Restore"))) {
-				Project.setDefaultSwatches();
-				Context.setSwatch(Project.raw.swatches[0]);
+				Project.set_default_swatches();
+				Context.set_swatch(Project.raw.swatches[0]);
 			}
 			if (ui.is_hovered) zui_tooltip(tr("Restore default swatches"));
 
 			zui_end_sticky();
 			zui_separator(3, false);
 
-			let slotw = Math.floor(26 * zui_SCALE(ui));
-			let num = Math.floor(ui._w / (slotw + 3));
-			let dragPositionSet = false;
+			let slotw: i32 = Math.floor(26 * zui_SCALE(ui));
+			let num: i32 = Math.floor(ui._w / (slotw + 3));
+			let dragPositionSet: bool = false;
 
-			let uix = 0.0;
-			let uiy = 0.0;
-			for (let row = 0; row < Math.floor(Math.ceil(Project.raw.swatches.length / num)); ++row) {
-				let ar = [];
-				for (let i = 0; i < num; ++i) ar.push(1 / num);
+			let uix: f32 = 0.0;
+			let uiy: f32 = 0.0;
+			for (let row: i32 = 0; row < Math.floor(Math.ceil(Project.raw.swatches.length / num)); ++row) {
+				let ar: f32[] = [];
+				for (let i: i32 = 0; i < num; ++i) ar.push(1 / num);
 				zui_row(ar);
 
 				ui._x += 2;
 				if (row > 0) ui._y += 6;
 
-				for (let j = 0; j < num; ++j) {
-					let i = j + row * num;
+				for (let j: i32 = 0; j < num; ++j) {
+					let i: i32 = j + row * num;
 					if (i >= Project.raw.swatches.length) {
 						zui_end_element(slotw);
 						continue;
 					}
 
 					if (Context.raw.swatch == Project.raw.swatches[i]) {
-						let off = row % 2 == 1 ? 1 : 0;
-						let w = 32;
+						let w: i32 = 32;
 						zui_fill(-2, -2, w, w, ui.t.HIGHLIGHT_COL);
 					}
 
@@ -101,63 +99,63 @@ class TabSwatches {
 					uiy = ui._y;
 
 					// Draw the drag position indicator
-					if (Base.dragSwatch != null && TabSwatches.dragPosition == i) {
+					if (Base.drag_swatch != null && TabSwatches.drag_pos == i) {
 						zui_fill(-1, -2 , 2, 32, ui.t.HIGHLIGHT_COL);
 					}
 
-					let state = zui_image(TabSwatches.empty, Project.raw.swatches[i].base, slotw);
+					let state: zui_state_t = zui_image(TabSwatches.empty, Project.raw.swatches[i].base, slotw);
 
 					if (state == zui_state_t.STARTED) {
-						Context.setSwatch(Project.raw.swatches[i]);
+						Context.set_swatch(Project.raw.swatches[i]);
 
-						Base.dragOffX = -(mouse_x - uix - ui._window_x - 2 * slotw);
-						Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1);
-						Base.dragSwatch = Context.raw.swatch;
+						Base.drag_off_x = -(mouse_x - uix - ui._window_x - 2 * slotw);
+						Base.drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
+						Base.drag_swatch = Context.raw.swatch;
 					}
 					else if (state == zui_state_t.HOVERED) {
-						TabSwatches.dragPosition = (mouse_x > uix + ui._window_x + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center
+						TabSwatches.drag_pos = (mouse_x > uix + ui._window_x + slotw / 2) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center
 						dragPositionSet = true;
 					}
 					else if (state == zui_state_t.RELEASED) {
-						if (time_time() - Context.raw.selectTime < 0.25) {
+						if (time_time() - Context.raw.select_time < 0.25) {
 							UIMenu.draw((ui: zui_t) => {
 								ui.changed = false;
-								let h = zui_handle("tabswatches_0");
+								let h: zui_handle_t = zui_handle("tabswatches_0");
 								h.color = Context.raw.swatch.base;
 
 								Context.raw.swatch.base = zui_color_wheel(h, false, null, 11 * ui.t.ELEMENT_H * zui_SCALE(ui), true, () => {
-									Context.raw.colorPickerPreviousTool = Context.raw.tool;
-									Context.selectTool(WorkspaceTool.ToolPicker);
-									Context.raw.colorPickerCallback = (color: TSwatchColor) => {
-										Project.raw.swatches[i] = Project.cloneSwatch(color);
+									Context.raw.color_picker_previous_tool = Context.raw.tool;
+									Context.select_tool(workspace_tool_t.PICKER);
+									Context.raw.color_picker_callback = (color: swatch_color_t) => {
+										Project.raw.swatches[i] = Project.clone_swatch(color);
 									};
 								});
-								let hopacity = zui_handle("tabswatches_1");
+								let hopacity: zui_handle_t = zui_handle("tabswatches_1");
 								hopacity.value = Context.raw.swatch.opacity;
 								Context.raw.swatch.opacity = zui_slider(hopacity, "Opacity", 0, 1, true);
-								let hocclusion = zui_handle("tabswatches_2");
+								let hocclusion: zui_handle_t = zui_handle("tabswatches_2");
 								hocclusion.value = Context.raw.swatch.occlusion;
 								Context.raw.swatch.occlusion = zui_slider(hocclusion, "Occlusion", 0, 1, true);
-								let hroughness = zui_handle("tabswatches_3");
+								let hroughness: zui_handle_t = zui_handle("tabswatches_3");
 								hroughness.value = Context.raw.swatch.roughness;
 								Context.raw.swatch.roughness = zui_slider(hroughness, "Roughness", 0, 1, true);
-								let hmetallic = zui_handle("tabswatches_4");
+								let hmetallic: zui_handle_t = zui_handle("tabswatches_4");
 								hmetallic.value = Context.raw.swatch.metallic;
 								Context.raw.swatch.metallic = zui_slider(hmetallic, "Metallic", 0, 1, true);
-								let hheight = zui_handle("tabswatches_5");
+								let hheight: zui_handle_t = zui_handle("tabswatches_5");
 								hheight.value = Context.raw.swatch.height;
 								Context.raw.swatch.height = zui_slider(hheight, "Height", 0, 1, true);
 
-								if (ui.changed || ui.is_typing) UIMenu.keepOpen = true;
-								if (ui.input_released) Context.setSwatch(Context.raw.swatch); // Trigger material preview update
+								if (ui.changed || ui.is_typing) UIMenu.keep_open = true;
+								if (ui.input_released) Context.set_swatch(Context.raw.swatch); // Trigger material preview update
 							}, 16, Math.floor(mouse_x - 200 * zui_SCALE(ui)), Math.floor(mouse_y - 250 * zui_SCALE(ui)));
 						}
 
-						Context.raw.selectTime = time_time();
+						Context.raw.select_time = time_time();
 					}
 					if (ui.is_hovered && ui.input_released_r) {
-						Context.setSwatch(Project.raw.swatches[i]);
-						let add = Project.raw.swatches.length > 1 ? 1 : 0;
+						Context.set_swatch(Project.raw.swatches[i]);
+						let add: i32 = Project.raw.swatches.length > 1 ? 1 : 0;
 						///if (krom_windows || krom_linux || krom_darwin)
 						add += 1; // Copy
 						///end
@@ -170,38 +168,38 @@ class TabSwatches {
 						///end
 
 						UIMenu.draw((ui: zui_t) => {
-							if (UIMenu.menuButton(ui, tr("Duplicate"))) {
-								Context.setSwatch(Project.cloneSwatch(Context.raw.swatch));
+							if (UIMenu.menu_button(ui, tr("Duplicate"))) {
+								Context.set_swatch(Project.clone_swatch(Context.raw.swatch));
 								Project.raw.swatches.push(Context.raw.swatch);
 							}
 							///if (krom_windows || krom_linux || krom_darwin)
-							else if (UIMenu.menuButton(ui, tr("Copy Hex Code"))) {
-								let color = Context.raw.swatch.base;
+							else if (UIMenu.menu_button(ui, tr("Copy Hex Code"))) {
+								let color: i32 = Context.raw.swatch.base;
 								color = color_set_ab(color, Context.raw.swatch.opacity * 255);
-								let val = color;
+								let val: i32 = color;
 								if (val < 0) val += 4294967296;
 								krom_copy_to_clipboard(val.toString(16));
 							}
 							///end
-							else if (Project.raw.swatches.length > 1 && UIMenu.menuButton(ui, tr("Delete"), "delete")) {
-								TabSwatches.deleteSwatch(Project.raw.swatches[i]);
+							else if (Project.raw.swatches.length > 1 && UIMenu.menu_button(ui, tr("Delete"), "delete")) {
+								TabSwatches.delete_swatch(Project.raw.swatches[i]);
 							}
 							///if (is_paint || is_sculpt)
-							else if (UIMenu.menuButton(ui, tr("Create Material"))) {
-								TabMaterials.acceptSwatchDrag(Project.raw.swatches[i]);
+							else if (UIMenu.menu_button(ui, tr("Create Material"))) {
+								TabMaterials.accept_swatch_drag(Project.raw.swatches[i]);
 							}
-							else if (UIMenu.menuButton(ui, tr("Create Color Layer"))) {
-								let color = Project.raw.swatches[i].base;
+							else if (UIMenu.menu_button(ui, tr("Create Color Layer"))) {
+								let color: i32 = Project.raw.swatches[i].base;
 								color = color_set_ab(color, Project.raw.swatches[i].opacity * 255);
-								Base.createColorLayer(color, Project.raw.swatches[i].occlusion, Project.raw.swatches[i].roughness, Project.raw.swatches[i].metallic);
+								Base.create_color_layer(color, Project.raw.swatches[i].occlusion, Project.raw.swatches[i].roughness, Project.raw.swatches[i].metallic);
 							}
 							///end
 						}, add);
 					}
 					if (ui.is_hovered) {
-						let color = Project.raw.swatches[i].base;
+						let color: i32 = Project.raw.swatches[i].base;
 						color = color_set_ab(color, Project.raw.swatches[i].opacity * 255);
-						let val = color;
+						let val: i32 = color;
 						if (val < 0) val += 4294967296;
 						zui_tooltip("#" + val.toString(16));
 					}
@@ -209,7 +207,7 @@ class TabSwatches {
 			}
 
 			// Draw the rightmost line next to the last swatch
-			if (Base.dragSwatch != null && TabSwatches.dragPosition == Project.raw.swatches.length) {
+			if (Base.drag_swatch != null && TabSwatches.drag_pos == Project.raw.swatches.length) {
 				ui._x = uix; // Reset the position because otherwise it would start in the row below
 				ui._y = uiy;
 				zui_fill(28, -2, 2, 32, ui.t.HIGHLIGHT_COL);
@@ -217,39 +215,39 @@ class TabSwatches {
 
 			// Currently there is no valid dragPosition so reset it
 			if (!dragPositionSet) {
-				TabSwatches.dragPosition = -1;
+				TabSwatches.drag_pos = -1;
 			}
 
-			let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
-						  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
+			let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+						  		ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 			if (inFocus && ui.is_delete_down && Project.raw.swatches.length > 1) {
 				ui.is_delete_down = false;
-				TabSwatches.deleteSwatch(Context.raw.swatch);
+				TabSwatches.delete_swatch(Context.raw.swatch);
 			}
 		}
 	}
 
-	static acceptSwatchDrag = (swatch: TSwatchColor) => {
+	static accept_swatch_drag = (swatch: swatch_color_t) => {
 		// No valid position available
-		if (TabSwatches.dragPosition == -1) return;
+		if (TabSwatches.drag_pos == -1) return;
 
-		let swatchPosition = Project.raw.swatches.indexOf(swatch);
+		let swatchPosition: i32 = Project.raw.swatches.indexOf(swatch);
 		// A new swatch from color picker
 		if (swatchPosition == -1) {
-			Project.raw.swatches.splice(TabSwatches.dragPosition, 0, swatch);
+			Project.raw.swatches.splice(TabSwatches.drag_pos, 0, swatch);
 		}
-		else if (Math.abs(swatchPosition - TabSwatches.dragPosition) > 0) { // Existing swatch is reordered
+		else if (Math.abs(swatchPosition - TabSwatches.drag_pos) > 0) { // Existing swatch is reordered
 			array_remove(Project.raw.swatches, swatch);
 			// If the new position is after the old one, decrease by one because the swatch has been deleted
-			let newPosition = TabSwatches.dragPosition - swatchPosition > 0 ? TabSwatches.dragPosition -1 : TabSwatches.dragPosition;
+			let newPosition: i32 = TabSwatches.drag_pos - swatchPosition > 0 ? TabSwatches.drag_pos -1 : TabSwatches.drag_pos;
 			Project.raw.swatches.splice(newPosition, 0, swatch);
 		}
 	}
 
-	static deleteSwatch = (swatch: TSwatchColor) => {
-		let i = Project.raw.swatches.indexOf(swatch);
-		Context.setSwatch(Project.raw.swatches[i == Project.raw.swatches.length - 1 ? i - 1 : i + 1]);
+	static delete_swatch = (swatch: swatch_color_t) => {
+		let i: i32 = Project.raw.swatches.indexOf(swatch);
+		Context.set_swatch(Project.raw.swatches[i == Project.raw.swatches.length - 1 ? i - 1 : i + 1]);
 		Project.raw.swatches.splice(i, 1);
-		UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+		UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 	}
 }

+ 81 - 81
base/Sources/TabTextures.ts

@@ -2,9 +2,9 @@
 class TabTextures {
 
 	static draw = (htab: zui_handle_t) => {
-		let ui = UIBase.ui;
-		let statush = Config.raw.layout[LayoutSize.LayoutStatusH];
-		if (zui_tab(htab, tr("Textures")) && statush > UIStatus.defaultStatusH * zui_SCALE(ui)) {
+		let ui: zui_t = UIBase.ui;
+		let statush: i32 = Config.raw.layout[layout_size_t.STATUS_H];
+		if (zui_tab(htab, tr("Textures")) && statush > UIStatus.default_status_h * zui_SCALE(ui)) {
 
 			zui_begin_sticky();
 
@@ -16,71 +16,71 @@ class TabTextures {
 			}
 
 			if (zui_button(tr("Import"))) {
-				UIFiles.show(Path.textureFormats.join(","), false, true, (path: string) => {
+				UIFiles.show(Path.texture_formats.join(","), false, true, (path: string) => {
 					ImportAsset.run(path, -1.0, -1.0, true, false);
-					UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+					UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 				});
 			}
 			if (ui.is_hovered) zui_tooltip(tr("Import texture file") + ` (${Config.keymap.file_import_assets})`);
 
-			if (zui_button(tr("2D View"))) UIBase.show2DView(View2DType.View2DAsset);
+			if (zui_button(tr("2D View"))) UIBase.show_2d_view(view_2d_type_t.ASSET);
 
 			zui_end_sticky();
 
 			if (Project.assets.length > 0) {
 
 				///if (is_paint || is_sculpt)
-				let statusw = sys_width() - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW];
+				let statusw: i32 = sys_width() - UIToolbar.toolbar_w - Config.raw.layout[layout_size_t.SIDEBAR_W];
 				///end
 				///if is_lab
-				let statusw = sys_width();
+				let statusw: i32 = sys_width();
 				///end
 
-				let slotw = Math.floor(52 * zui_SCALE(ui));
-				let num = Math.floor(statusw / slotw);
+				let slotw: i32 = Math.floor(52 * zui_SCALE(ui));
+				let num: i32 = Math.floor(statusw / slotw);
 
-				for (let row = 0; row < Math.floor(Math.ceil(Project.assets.length / num)); ++row) {
-					let mult = Config.raw.show_asset_names ? 2 : 1;
-					let ar = [];
-					for (let i = 0; i < num * mult; ++i) ar.push(1 / num);
+				for (let row: i32 = 0; row < Math.floor(Math.ceil(Project.assets.length / num)); ++row) {
+					let mult: i32 = Config.raw.show_asset_names ? 2 : 1;
+					let ar: f32[] = [];
+					for (let i: i32 = 0; i < num * mult; ++i) ar.push(1 / num);
 					zui_row(ar);
 
 					ui._x += 2;
-					let off = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
+					let off: f32 = Config.raw.show_asset_names ? zui_ELEMENT_OFFSET(ui) * 10.0 : 6;
 					if (row > 0) ui._y += off;
 
-					for (let j = 0; j < num; ++j) {
-						let imgw = Math.floor(50 * zui_SCALE(ui));
-						let i = j + row * num;
+					for (let j: i32 = 0; j < num; ++j) {
+						let imgw: i32 = Math.floor(50 * zui_SCALE(ui));
+						let i: i32 = j + row * num;
 						if (i >= Project.assets.length) {
 							zui_end_element(imgw);
 							if (Config.raw.show_asset_names) zui_end_element(0);
 							continue;
 						}
 
-						let asset = Project.assets[i];
-						let img = Project.getImage(asset);
-						let uix = ui._x;
-						let uiy = ui._y;
-						let sw = img.height < img.width ? img.height : 0;
+						let asset: asset_t = Project.assets[i];
+						let img: image_t = Project.get_image(asset);
+						let uix: f32 = ui._x;
+						let uiy: f32 = ui._y;
+						let sw: i32 = img.height < img.width ? img.height : 0;
 						if (zui_image(img, 0xffffffff, slotw, 0, 0, sw, sw) == zui_state_t.STARTED && ui.input_y > ui._window_y) {
-							Base.dragOffX = -(mouse_x - uix - ui._window_x - 3);
-							Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1);
-							Base.dragAsset = asset;
+							Base.drag_off_x = -(mouse_x - uix - ui._window_x - 3);
+							Base.drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
+							Base.drag_asset = asset;
 							Context.raw.texture = asset;
 
-							if (time_time() - Context.raw.selectTime < 0.25) UIBase.show2DView(View2DType.View2DAsset);
-							Context.raw.selectTime = time_time();
+							if (time_time() - Context.raw.select_time < 0.25) UIBase.show_2d_view(view_2d_type_t.ASSET);
+							Context.raw.select_time = time_time();
 							UIView2D.hwnd.redraws = 2;
 						}
 
 						if (asset == Context.raw.texture) {
-							let _uix = ui._x;
-							let _uiy = ui._y;
+							let _uix: f32 = ui._x;
+							let _uiy: f32 = ui._y;
 							ui._x = uix;
 							ui._y = uiy;
-							let off = i % 2 == 1 ? 1 : 0;
-							let w = 50;
+							let off: i32 = i % 2 == 1 ? 1 : 0;
+							let w: i32 = 50;
 							zui_fill(0,               0, w + 3,       2, ui.t.HIGHLIGHT_COL);
 							zui_fill(0,     w - off + 2, w + 3, 2 + off, ui.t.HIGHLIGHT_COL);
 							zui_fill(0,               0,     2,   w + 3, ui.t.HIGHLIGHT_COL);
@@ -89,7 +89,7 @@ class TabTextures {
 							ui._y = _uiy;
 						}
 
-						let isPacked = Project.raw.packed_assets != null && Project.packedAssetExists(Project.raw.packed_assets, asset.file);
+						let isPacked: bool = Project.raw.packed_assets != null && Project.packed_asset_exists(Project.raw.packed_assets, asset.file);
 
 						if (ui.is_hovered) {
 							zui_tooltip_image(img, 256);
@@ -99,7 +99,7 @@ class TabTextures {
 						if (ui.is_hovered && ui.input_released_r) {
 							Context.raw.texture = asset;
 
-							let count = 0;
+							let count: i32 = 0;
 
 							///if (is_paint || is_sculpt)
 							count = isPacked ? 6 : 8;
@@ -109,24 +109,24 @@ class TabTextures {
 							///end
 
 							UIMenu.draw((ui: zui_t) => {
-								if (UIMenu.menuButton(ui, tr("Export"))) {
+								if (UIMenu.menu_button(ui, tr("Export"))) {
 									UIFiles.show("png", true, false, (path: string) => {
-										Base.notifyOnNextFrame(() => {
+										Base.notify_on_next_frame(() => {
 											///if (is_paint || is_sculpt)
-											if (Base.pipeMerge == null) Base.makePipe();
+											if (Base.pipe_merge == null) Base.make_pipe();
 											///end
 											///if is_lab
-											if (Base.pipeCopy == null) Base.makePipe();
+											if (Base.pipe_copy == null) Base.make_pipe();
 											///end
 
-											let target = image_create_render_target(TabTextures.to_pow2(img.width), TabTextures.to_pow2(img.height));
+											let target: image_t = image_create_render_target(TabTextures.to_pow2(img.width), TabTextures.to_pow2(img.height));
 											g2_begin(target);
-											g2_set_pipeline(Base.pipeCopy);
+											g2_set_pipeline(Base.pipe_copy);
 											g2_draw_scaled_image(img, 0, 0, target.width, target.height);
 											g2_set_pipeline(null);
 											g2_end();
-											Base.notifyOnNextFrame(() => {
-												let f = UIFiles.filename;
+											Base.notify_on_next_frame(() => {
+												let f: string = UIFiles.filename;
 												if (f == "") f = tr("untitled");
 												if (!f.endsWith(".png")) f += ".png";
 												krom_write_png(path + Path.sep + f, image_get_pixels(target), target.width, target.height, 0);
@@ -135,44 +135,44 @@ class TabTextures {
 										});
 									});
 								}
-								if (UIMenu.menuButton(ui, tr("Reimport"))) {
-									Project.reimportTexture(asset);
+								if (UIMenu.menu_button(ui, tr("Reimport"))) {
+									Project.reimport_texture(asset);
 								}
 
 								///if (is_paint || is_sculpt)
-								if (UIMenu.menuButton(ui, tr("To Mask"))) {
-									Base.notifyOnNextFrame(() => {
-										Base.createImageMask(asset);
+								if (UIMenu.menu_button(ui, tr("To Mask"))) {
+									Base.notify_on_next_frame(() => {
+										Base.create_image_mask(asset);
 									});
 								}
 								///end
 
-								if (UIMenu.menuButton(ui, tr("Set as Envmap"))) {
-									Base.notifyOnNextFrame(() => {
+								if (UIMenu.menu_button(ui, tr("Set as Envmap"))) {
+									Base.notify_on_next_frame(() => {
 										ImportEnvmap.run(asset.file, img);
 									});
 								}
 
 								///if is_paint
-								if (UIMenu.menuButton(ui, tr("Set as Color ID Map"))) {
-									Context.raw.colorIdHandle.position = i;
-									Context.raw.colorIdPicked = false;
-									UIToolbar.toolbarHandle.redraws = 1;
-									if (Context.raw.tool == WorkspaceTool.ToolColorId) {
-										UIHeader.headerHandle.redraws = 2;
+								if (UIMenu.menu_button(ui, tr("Set as Color ID Map"))) {
+									Context.raw.colorid_handle.position = i;
+									Context.raw.colorid_picked = false;
+									UIToolbar.toolbar_handle.redraws = 1;
+									if (Context.raw.tool == workspace_tool_t.COLORID) {
+										UIHeader.header_handle.redraws = 2;
 										Context.raw.ddirty = 2;
 									}
 								}
 								///end
 
-								if (UIMenu.menuButton(ui, tr("Delete"), "delete")) {
-									TabTextures.deleteTexture(asset);
+								if (UIMenu.menu_button(ui, tr("Delete"), "delete")) {
+									TabTextures.delete_texture(asset);
 								}
-								if (!isPacked && UIMenu.menuButton(ui, tr("Open Containing Directory..."))) {
+								if (!isPacked && UIMenu.menu_button(ui, tr("Open Containing Directory..."))) {
 									File.start(asset.file.substr(0, asset.file.lastIndexOf(Path.sep)));
 								}
-								if (!isPacked && UIMenu.menuButton(ui, tr("Open in Browser"))) {
-									TabBrowser.showDirectory(asset.file.substr(0, asset.file.lastIndexOf(Path.sep)));
+								if (!isPacked && UIMenu.menu_button(ui, tr("Open in Browser"))) {
+									TabBrowser.show_directory(asset.file.substr(0, asset.file.lastIndexOf(Path.sep)));
 								}
 							}, count);
 						}
@@ -191,17 +191,17 @@ class TabTextures {
 				}
 			}
 			else {
-				let img = Res.get("icons.k");
-				let r = Res.tile50(img, 0, 1);
+				let img: image_t = Res.get("icons.k");
+				let r: rect_t = Res.tile50(img, 0, 1);
 				zui_image(img, ui.t.BUTTON_COL, r.h, r.x, r.y, r.w, r.h);
 				if (ui.is_hovered) zui_tooltip(tr("Drag and drop files here"));
 			}
 
-			let inFocus = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
-						  ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
+			let inFocus: bool = ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w &&
+						 	 	ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h;
 			if (inFocus && ui.is_delete_down && Project.assets.length > 0 && Project.assets.indexOf(Context.raw.texture) >= 0) {
 				ui.is_delete_down = false;
-				TabTextures.deleteTexture(Context.raw.texture);
+				TabTextures.delete_texture(Context.raw.texture);
 			}
 		}
 	}
@@ -217,7 +217,7 @@ class TabTextures {
 		return i;
 	}
 
-	static updateTexturePointers = (nodes: zui_node_t[], i: i32) => {
+	static update_texture_pointers = (nodes: zui_node_t[], i: i32) => {
 		for (let n of nodes) {
 			if (n.type == "TEX_IMAGE") {
 				if (n.buttons[0].default_value == i) {
@@ -230,39 +230,39 @@ class TabTextures {
 		}
 	}
 
-	static deleteTexture = (asset: TAsset) => {
-		let i = Project.assets.indexOf(asset);
+	static delete_texture = (asset: asset_t) => {
+		let i: i32 = Project.assets.indexOf(asset);
 		if (Project.assets.length > 1) {
 			Context.raw.texture = Project.assets[i == Project.assets.length - 1 ? i - 1 : i + 1];
 		}
-		UIBase.hwnds[TabArea.TabStatus].redraws = 2;
+		UIBase.hwnds[tab_area_t.STATUS].redraws = 2;
 
 		///if is_paint
-		if (Context.raw.tool == WorkspaceTool.ToolColorId && i == Context.raw.colorIdHandle.position) {
-			UIHeader.headerHandle.redraws = 2;
+		if (Context.raw.tool == workspace_tool_t.COLORID && i == Context.raw.colorid_handle.position) {
+			UIHeader.header_handle.redraws = 2;
 			Context.raw.ddirty = 2;
-			Context.raw.colorIdPicked = false;
-			UIToolbar.toolbarHandle.redraws = 1;
+			Context.raw.colorid_picked = false;
+			UIToolbar.toolbar_handle.redraws = 1;
 		}
 		///end
 
 		data_delete_image(asset.file);
-		Project.assetMap.delete(asset.id);
+		Project.asset_map.delete(asset.id);
 		Project.assets.splice(i, 1);
-		Project.assetNames.splice(i, 1);
+		Project.asset_names.splice(i, 1);
 		let _next = () => {
-			MakeMaterial.parsePaintMaterial();
+			MakeMaterial.parse_paint_material();
 
 			///if (is_paint || is_sculpt)
-			UtilRender.makeMaterialPreview();
-			UIBase.hwnds[TabArea.TabSidebar1].redraws = 2;
+			UtilRender.make_material_preview();
+			UIBase.hwnds[tab_area_t.SIDEBAR1].redraws = 2;
 			///end
 		}
-		Base.notifyOnNextFrame(_next);
+		Base.notify_on_next_frame(_next);
 
-		for (let m of Project.materials) TabTextures.updateTexturePointers(m.canvas.nodes, i);
+		for (let m of Project.materials) TabTextures.update_texture_pointers(m.canvas.nodes, i);
 		///if (is_paint || is_sculpt)
-		for (let b of Project.brushes) TabTextures.updateTexturePointers(b.canvas.nodes, i);
+		for (let b of Project.brushes) TabTextures.update_texture_pointers(b.canvas.nodes, i);
 		///end
 	}
 }

+ 33 - 33
base/Sources/Translator.ts

@@ -3,7 +3,7 @@ class Translator {
 
 	static translations: Map<string, string> = new Map();
 	// The font index is a value specific to font_cjk.ttc.
-	static cjkFontIndices: Map<string, i32> = new Map([
+	static cjk_font_indices: Map<string, i32> = new Map([
 		["ja", 0],
 		["ko", 1],
 		["zh_cn", 2],
@@ -11,7 +11,7 @@ class Translator {
 		["zh_tw.big5", 4]
 	]);
 
-	static lastLocale = "en";
+	static last_locale: string = "en";
 
 	// Mark strings as localizable in order to be parsed by the extract_locale script.
 	// The string will not be translated to the currently selected locale though.
@@ -22,11 +22,11 @@ class Translator {
 	// Localizes a string with the given placeholders replaced (format is `{placeholderName}`).
 	// If the string isn't available in the translation, this method will return the source English string.
 	static tr = (id: string, vars: Map<string, string> = null): string => {
-		let translation = id;
+		let translation: string = id;
 
 		// English is the source language
 		if (Config.raw.locale != "en" && Translator.translations.has(id)) {
-			let atranslations = Translator.translations as any;
+			let atranslations: any = Translator.translations as any;
 			translation = atranslations[id];
 		}
 
@@ -40,13 +40,13 @@ class Translator {
 	}
 
 	// (Re)loads translations for the specified locale
-	static loadTranslations = (newLocale: string) => {
+	static load_translations = (newLocale: string) => {
 		if (newLocale == "system") {
 			Config.raw.locale = krom_language();
 		}
 
 		// Check whether the requested or detected locale is available
-		if (Config.raw.locale != "en" && Translator.getSupportedLocales().indexOf(Config.raw.locale) == -1) {
+		if (Config.raw.locale != "en" && Translator.get_supported_locales().indexOf(Config.raw.locale) == -1) {
 			// Fall back to English
 			Config.raw.locale = "en";
 		}
@@ -55,30 +55,30 @@ class Translator {
 		// Clear existing translations if switching languages at runtime
 		Translator.translations.clear();
 
-		if (Config.raw.locale == "en" && Translator.lastLocale == "en") {
+		if (Config.raw.locale == "en" && Translator.last_locale == "en") {
 			// No need to generate extended font atlas for English locale
 			return;
 		}
-		Translator.lastLocale = Config.raw.locale;
+		Translator.last_locale = Config.raw.locale;
 
 		if (Config.raw.locale != "en") {
 			// Load the translation file
-			let translationJson = sys_buffer_to_string(krom_load_blob(`data/locale/${Config.raw.locale}.json`));
+			let translationJson: string = sys_buffer_to_string(krom_load_blob(`data/locale/${Config.raw.locale}.json`));
 
-			let data = JSON.parse(translationJson);
+			let data: any = json_parse(translationJson);
 			for (let field in data) {
-				let atranslations = Translator.translations as any;
+				let atranslations: any = Translator.translations as any;
 				atranslations[field] = data[field];
 			}
 		}
 
 		// Generate extended font atlas
-		Translator.extendedGlyphs();
+		Translator.extended_glyphs();
 
 		// Push additional char codes contained in translation file
-		let cjk = false;
+		let cjk: bool = false;
 		for (let s of Translator.translations.values()) {
-			for (let i = 0; i < s.length; ++i) {
+			for (let i: i32 = 0; i < s.length; ++i) {
 				// Assume cjk in the > 1119 range for now
 				if (s.charCodeAt(i) > 1119 && _g2_font_glyphs.indexOf(s.charCodeAt(i)) == -1) {
 					if (!cjk) {
@@ -91,40 +91,40 @@ class Translator {
 		}
 
 		if (cjk) {
-			let cjkFontPath = (Path.isProtected() ? krom_save_path() : "") + "font_cjk.ttc";
-			let cjkFontDiskPath = (Path.isProtected() ? krom_save_path() : Path.data() + Path.sep) + "font_cjk.ttc";
+			let cjkFontPath: string = (Path.is_protected() ? krom_save_path() : "") + "font_cjk.ttc";
+			let cjkFontDiskPath: string = (Path.is_protected() ? krom_save_path() : Path.data() + Path.sep) + "font_cjk.ttc";
 			if (!File.exists(cjkFontDiskPath)) {
 				File.download("https://github.com/armory3d/armorbase/raw/main/Assets/common/extra/font_cjk.ttc", cjkFontDiskPath, () => {
 					if (!File.exists(cjkFontDiskPath)) {
 						// Fall back to English
 						Config.raw.locale = "en";
-						Translator.extendedGlyphs();
+						Translator.extended_glyphs();
 						Translator.translations.clear();
-						Translator.initFont(false, "font.ttf", 1.0);
+						Translator.init_font(false, "font.ttf", 1.0);
 					}
-					else Translator.initFont(true, cjkFontPath, 1.4);
+					else Translator.init_font(true, cjkFontPath, 1.4);
 				}, 20332392);
 			}
-			else Translator.initFont(true, cjkFontPath, 1.4);
+			else Translator.init_font(true, cjkFontPath, 1.4);
 		}
-		else Translator.initFont(false, "font.ttf", 1.0);
+		else Translator.init_font(false, "font.ttf", 1.0);
 	}
 
-	static initFont = (cjk: bool, fontPath: string, fontScale: f32) => {
+	static init_font = (cjk: bool, fontPath: string, fontScale: f32) => {
 		_g2_font_glyphs.sort((a: i32, b: i32) => { return a - b; });
 		// Load and assign font with cjk characters
 		app_notify_on_init(() => {
 			let f: g2_font_t = data_get_font(fontPath);
 			if (cjk) {
-				let acjkFontIndices = Translator.cjkFontIndices as any;
-				let fontIndex = Translator.cjkFontIndices.has(Config.raw.locale) ? acjkFontIndices[Config.raw.locale] : 0;
+				let acjkFontIndices: any = Translator.cjk_font_indices as any;
+				let fontIndex: i32 = Translator.cjk_font_indices.has(Config.raw.locale) ? acjkFontIndices[Config.raw.locale] : 0;
 				g2_font_set_font_index(f, fontIndex);
 			}
 			Base.font = f;
 			// Scale up the font size and elements width a bit
-			Base.theme.FONT_SIZE = Math.floor(Base.defaultFontSize * fontScale);
-			Base.theme.ELEMENT_W = Math.floor(Base.defaultElementW * (Config.raw.locale != "en" ? 1.4 : 1.0));
-			let uis = Base.getUIs();
+			Base.theme.FONT_SIZE = Math.floor(Base.default_font_size * fontScale);
+			Base.theme.ELEMENT_W = Math.floor(Base.default_element_w * (Config.raw.locale != "en" ? 1.4 : 1.0));
+			let uis: zui_t[] = Base.get_uis();
 			for (let ui of uis) {
 				zui_set_font(ui, f);
 				zui_set_scale(ui, zui_SCALE(ui));
@@ -132,19 +132,19 @@ class Translator {
 		});
 	}
 
-	static extendedGlyphs = () => {
+	static extended_glyphs = () => {
 		// Basic Latin + Latin-1 Supplement + Latin Extended-A
 		_g2_font_glyphs = _g2_make_glyphs(32, 383);
 		// + Greek
-		for (let i = 880; i < 1023; ++i) _g2_font_glyphs.push(i);
+		for (let i: i32 = 880; i < 1023; ++i) _g2_font_glyphs.push(i);
 		// + Cyrillic
-		for (let i = 1024; i < 1119; ++i) _g2_font_glyphs.push(i);
+		for (let i: i32 = 1024; i < 1119; ++i) _g2_font_glyphs.push(i);
 	}
 
 	// Returns a list of supported locales (plus English and the automatically detected system locale)
-	static getSupportedLocales = (): string[] => {
-		let locales = ["system", "en"];
-		for (let localeFilename of File.readDirectory(Path.data() + Path.sep + "locale")) {
+	static get_supported_locales = (): string[] => {
+		let locales: string[] = ["system", "en"];
+		for (let localeFilename of File.read_directory(Path.data() + Path.sep + "locale")) {
 			// Trim the `.json` file extension from file names
 			locales.push(localeFilename.substr(0, -5));
 		}

文件差异内容过多而无法显示
+ 319 - 319
base/Sources/UIBase.ts


+ 69 - 69
base/Sources/UIBox.ts

@@ -1,39 +1,39 @@
 
 class UIBox {
 
-	static show = false;
-	static draggable = true;
-	static hwnd = zui_handle_create();
-	static boxTitle = "";
-	static boxText = "";
-	static boxCommands: (ui: zui_t)=>void = null;
-	static clickToHide = true;
-	static modalW = 400;
-	static modalH = 170;
-	static modalOnHide: ()=>void = null;
-	static draws = 0;
-	static copyable = false;
+	static show: bool = false;
+	static draggable: bool = true;
+	static hwnd: zui_handle_t = zui_handle_create();
+	static box_title: string = "";
+	static box_text: string = "";
+	static box_commands: (ui: zui_t)=>void = null;
+	static click_to_hide: bool = true;
+	static modalw: i32 = 400;
+	static modalh: i32 = 170;
+	static modal_on_hide: ()=>void = null;
+	static draws: i32 = 0;
+	static copyable: bool = false;
 	///if (krom_android || krom_ios)
-	static tweenAlpha = 0.0;
+	static tween_alpha: f32 = 0.0;
 	///end
 
 	static render = () => {
 		if (!UIMenu.show) {
-			let ui = Base.uiBox;
-			let inUse = ui.combo_selected_handle_ptr != 0;
-			let isEscape = keyboard_started("escape");
+			let ui: zui_t = Base.ui_box;
+			let inUse: bool = ui.combo_selected_handle_ptr != 0;
+			let isEscape: bool = keyboard_started("escape");
 			if (UIBox.draws > 2 && (ui.input_released || isEscape) && !inUse && !ui.is_typing) {
-				let appw = sys_width();
-				let apph = sys_height();
-				let mw = Math.floor(UIBox.modalW * zui_SCALE(ui));
-				let mh = Math.floor(UIBox.modalH * zui_SCALE(ui));
-				let left = (appw / 2 - mw / 2) + UIBox.hwnd.drag_x;
-				let right = (appw / 2 + mw / 2) + UIBox.hwnd.drag_x;
-				let top = (apph / 2 - mh / 2) + UIBox.hwnd.drag_y;
-				let bottom = (apph / 2 + mh / 2) + UIBox.hwnd.drag_y;
-				let mx = mouse_x;
-				let my = mouse_y;
-				if ((UIBox.clickToHide && (mx < left || mx > right || my < top || my > bottom)) || isEscape) {
+				let appw: i32 = sys_width();
+				let apph: i32 = sys_height();
+				let mw: i32 = Math.floor(UIBox.modalw * zui_SCALE(ui));
+				let mh: i32 = Math.floor(UIBox.modalh * zui_SCALE(ui));
+				let left: f32 = (appw / 2 - mw / 2) + UIBox.hwnd.drag_x;
+				let right: f32 = (appw / 2 + mw / 2) + UIBox.hwnd.drag_x;
+				let top: f32 = (apph / 2 - mh / 2) + UIBox.hwnd.drag_y;
+				let bottom: f32 = (apph / 2 + mh / 2) + UIBox.hwnd.drag_y;
+				let mx: i32 = mouse_x;
+				let my: i32 = mouse_y;
+				if ((UIBox.click_to_hide && (mx < left || mx > right || my < top || my > bottom)) || isEscape) {
 					UIBox.hide();
 				}
 			}
@@ -41,7 +41,7 @@ class UIBox {
 
 		if (Config.raw.touch_ui) { // Darken bg
 			///if (krom_android || krom_ios)
-			g2_set_color(color_from_floats(0, 0, 0, UIBox.tweenAlpha));
+			g2_set_color(color_from_floats(0, 0, 0, UIBox.tween_alpha));
 			///else
 			g2_set_color(color_from_floats(0, 0, 0, 0.5));
 			///end
@@ -50,27 +50,27 @@ class UIBox {
 
 		g2_end();
 
-		let ui = Base.uiBox;
-		let appw = sys_width();
-		let apph = sys_height();
-		let mw = Math.floor(UIBox.modalW * zui_SCALE(ui));
-		let mh = Math.floor(UIBox.modalH * zui_SCALE(ui));
+		let ui: zui_t = Base.ui_box;
+		let appw: i32 = sys_width();
+		let apph: i32 = sys_height();
+		let mw: i32 = Math.floor(UIBox.modalw * zui_SCALE(ui));
+		let mh: i32 = Math.floor(UIBox.modalh * zui_SCALE(ui));
 		if (mw > appw) mw = appw;
 		if (mh > apph) mh = apph;
-		let left = Math.floor(appw / 2 - mw / 2);
-		let top = Math.floor(apph / 2 - mh / 2);
+		let left: i32 = Math.floor(appw / 2 - mw / 2);
+		let top: i32 = Math.floor(apph / 2 - mh / 2);
 
-		if (UIBox.boxCommands == null) {
+		if (UIBox.box_commands == null) {
 			zui_begin(ui);
 			if (zui_window(UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) {
 				ui._y += 10;
-				let tabVertical = Config.raw.touch_ui;
-				if (zui_tab(zui_handle("uibox_0"), UIBox.boxTitle, tabVertical)) {
-					let htext = zui_handle("uibox_1");
-					htext.text = UIBox.boxText;
+				let tabVertical: bool = Config.raw.touch_ui;
+				if (zui_tab(zui_handle("uibox_0"), UIBox.box_title, tabVertical)) {
+					let htext: zui_handle_t = zui_handle("uibox_1");
+					htext.text = UIBox.box_text;
 					UIBox.copyable ?
 						zui_text_area(htext, zui_align_t.LEFT, false) :
-						zui_text(UIBox.boxText);
+						zui_text(UIBox.box_text);
 					zui_end_element();
 
 					///if (krom_windows || krom_linux || krom_darwin)
@@ -84,14 +84,14 @@ class UIBox {
 
 					///if (krom_windows || krom_linux || krom_darwin)
 					if (UIBox.copyable && zui_button(tr("Copy"))) {
-						krom_copy_to_clipboard(UIBox.boxText);
+						krom_copy_to_clipboard(UIBox.box_text);
 					}
 					///end
 					if (zui_button(tr("OK"))) {
 						UIBox.hide();
 					}
 				}
-				UIBox.windowBorder(ui);
+				UIBox.window_border(ui);
 			}
 			zui_end();
 		}
@@ -99,8 +99,8 @@ class UIBox {
 			zui_begin(ui);
 			if (zui_window(UIBox.hwnd, left, top, mw, mh, UIBox.draggable)) {
 				ui._y += 10;
-				UIBox.boxCommands(ui);
-				UIBox.windowBorder(ui);
+				UIBox.box_commands(ui);
+				UIBox.window_border(ui);
 			}
 			zui_end();
 		}
@@ -110,56 +110,56 @@ class UIBox {
 		UIBox.draws++;
 	}
 
-	static showMessage = (title: string, text: string, copyable = false) => {
+	static show_message = (title: string, text: string, copyable: bool = false) => {
 		UIBox.init();
-		UIBox.modalW = 400;
-		UIBox.modalH = 210;
-		UIBox.boxTitle = title;
-		UIBox.boxText = text;
-		UIBox.boxCommands = null;
+		UIBox.modalw = 400;
+		UIBox.modalh = 210;
+		UIBox.box_title = title;
+		UIBox.box_text = text;
+		UIBox.box_commands = null;
 		UIBox.copyable = copyable;
 		UIBox.draggable = true;
 		///if (krom_android || krom_ios)
-		UIBox.tweenIn();
+		UIBox.tween_in();
 		///end
 	}
 
-	static showCustom = (commands: (ui: zui_t)=>void = null, mw = 400, mh = 200, onHide: ()=>void = null, draggable = true) => {
+	static show_custom = (commands: (ui: zui_t)=>void = null, mw: i32 = 400, mh: i32 = 200, onHide: ()=>void = null, draggable: bool = true) => {
 		UIBox.init();
-		UIBox.modalW = mw;
-		UIBox.modalH = mh;
-		UIBox.modalOnHide = onHide;
-		UIBox.boxCommands = commands;
+		UIBox.modalw = mw;
+		UIBox.modalh = mh;
+		UIBox.modal_on_hide = onHide;
+		UIBox.box_commands = commands;
 		UIBox.draggable = draggable;
 		///if (krom_android || krom_ios)
-		UIBox.tweenIn();
+		UIBox.tween_in();
 		///end
 	}
 
 	static hide = () => {
 		///if (krom_android || krom_ios)
-		UIBox.tweenOut();
+		UIBox.tween_out();
 		///else
-		UIBox.hideInternal();
+		UIBox.hide_internal();
 		///end
 	}
 
-	static hideInternal = () => {
-		if (UIBox.modalOnHide != null) UIBox.modalOnHide();
+	static hide_internal = () => {
+		if (UIBox.modal_on_hide != null) UIBox.modal_on_hide();
 		UIBox.show = false;
-		Base.redrawUI();
+		Base.redraw_ui();
 	}
 
 	///if (krom_android || krom_ios)
-	static tweenIn = () => {
+	static tween_in = () => {
 		tween_reset();
 		tween_to({target: UIBox, props: { tweenAlpha: 0.5 }, duration: 0.2, ease: ease_t.EXPO_OUT});
 		UIBox.hwnd.drag_y = Math.floor(sys_height() / 2);
-		tween_to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: ease_t.EXPO_OUT, tick: () => { Base.redrawUI(); }});
+		tween_to({target: UIBox.hwnd, props: { dragY: 0 }, duration: 0.2, ease: ease_t.EXPO_OUT, tick: () => { Base.redraw_ui(); }});
 	}
 
-	static tweenOut = () => {
-		tween_to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: ease_t.EXPO_IN, done: UIBox.hideInternal});
+	static tween_out = () => {
+		tween_to({target: UIBox, props: { tweenAlpha: 0.0 }, duration: 0.2, ease: ease_t.EXPO_IN, done: UIBox.hide_internal});
 		tween_to({target: UIBox.hwnd, props: { dragY: sys_height() / 2 }, duration: 0.2, ease: ease_t.EXPO_IN});
 	}
 	///end
@@ -170,10 +170,10 @@ class UIBox {
 		UIBox.hwnd.drag_y = 0;
 		UIBox.show = true;
 		UIBox.draws = 0;
-		UIBox.clickToHide = true;
+		UIBox.click_to_hide = true;
 	}
 
-	static windowBorder = (ui: zui_t) => {
+	static window_border = (ui: zui_t) => {
 		if (ui.scissor) {
 			ui.scissor = false;
 			g2_disable_scissor();

+ 102 - 102
base/Sources/UIFiles.ts

@@ -1,7 +1,7 @@
 
 class UIFiles {
 
-	static defaultPath =
+	static default_path: string =
 		///if krom_windows
 		"C:\\Users"
 		///elseif krom_android
@@ -14,14 +14,14 @@ class UIFiles {
 	;
 
 	static filename: string;
-	static path = UIFiles.defaultPath;
-	static lastPath = "";
-	static lastSearch = "";
+	static path: string = UIFiles.default_path;
+	static last_path: string = "";
+	static last_search: string = "";
 	static files: string[] = null;
-	static iconMap: Map<string, image_t> = null;
-	static selected = -1;
-	static showExtensions = false;
-	static offline = false;
+	static icon_map: Map<string, image_t> = null;
+	static selected: i32 = -1;
+	static show_extensions: bool = false;
+	static offline: bool = false;
 
 	static show = (filters: string, isSave: bool, openMultiple: bool, filesDone: (s: string)=>void) => {
 		if (isSave) {
@@ -35,7 +35,7 @@ class UIFiles {
 			}
 		}
 		else {
-			let paths = krom_open_dialog(filters, "", openMultiple);
+			let paths: string[] = krom_open_dialog(filters, "", openMultiple);
 			if (paths != null) {
 				for (let path of paths) {
 					while (path.indexOf(Path.sep + Path.sep) >= 0) path = string_replace_all(path, Path.sep + Path.sep, Path.sep);
@@ -46,15 +46,15 @@ class UIFiles {
 			}
 		}
 
-		UIFiles.releaseKeys();
+		UIFiles.release_keys();
 	}
 
-	// static showCustom = (filters: string, isSave: bool, filesDone: (s: string)=>void) => {
-	// 	let known = false;
-	// 	UIBox.showCustom((ui: ZuiRaw) => {
+	// static show_custom = (filters: string, isSave: bool, filesDone: (s: string)=>void) => {
+	// 	let known: bool = false;
+	// 	UIBox.show_custom((ui: ZuiRaw) => {
 	// 		if (Zui.tab(Zui.handle(), tr("File Browser"))) {
-	// 			let pathHandle = Zui.handle();
-	// 			let fileHandle = Zui.handle();
+	// 			let pathHandle: zui_handle_t = Zui.handle();
+	// 			let fileHandle: zui_handle_t = Zui.handle();
 	// 			Zui.row([6 / 10, 2 / 10, 2 / 10]);
 	// 			filename = Zui.textInput(fileHandle, tr("File"));
 	// 			Zui.text("*." + filters, Center);
@@ -70,7 +70,7 @@ class UIFiles {
 	// 	}, 600, 500);
 	// }
 
-	static releaseKeys = () => {
+	static release_keys = () => {
 		// File dialog may prevent firing key up events
 		keyboard_up_listener(key_code_t.SHIFT);
 		keyboard_up_listener(key_code_t.CONTROL);
@@ -79,101 +79,101 @@ class UIFiles {
 		///end
 	}
 
-	static fileBrowser = (ui: zui_t, handle: zui_handle_t, foldersOnly = false, dragFiles = false, search = "", refresh = false, contextMenu: (s: string)=>void = null): string => {
+	static file_browser = (ui: zui_t, handle: zui_handle_t, foldersOnly: bool = false, dragFiles: bool = false, search: string = "", refresh: bool = false, contextMenu: (s: string)=>void = null): string => {
 
-		let icons = Res.get("icons.k");
-		let folder = Res.tile50(icons, 2, 1);
-		let file = Res.tile50(icons, 3, 1);
-		let isCloud = handle.text.startsWith("cloud");
+		let icons: image_t = Res.get("icons.k");
+		let folder: rect_t = Res.tile50(icons, 2, 1);
+		let file: rect_t = Res.tile50(icons, 3, 1);
+		let isCloud: bool = handle.text.startsWith("cloud");
 
-		if (isCloud && File.cloud == null) File.initCloud(() => { UIBase.hwnds[TabArea.TabStatus].redraws = 3; });
-		if (isCloud && File.readDirectory("cloud", false).length == 0) return handle.text;
+		if (isCloud && File.cloud == null) File.init_cloud(() => { UIBase.hwnds[tab_area_t.STATUS].redraws = 3; });
+		if (isCloud && File.read_directory("cloud", false).length == 0) return handle.text;
 
 		///if krom_ios
-		let documentDirectory = krom_save_dialog("", "");
+		let documentDirectory: string = krom_save_dialog("", "");
 		documentDirectory = documentDirectory.substr(0, documentDirectory.length - 8); // Strip /'untitled'
 		///end
 
-		if (handle.text == "") handle.text = UIFiles.defaultPath;
-		if (handle.text != UIFiles.lastPath || search != UIFiles.lastSearch || refresh) {
+		if (handle.text == "") handle.text = UIFiles.default_path;
+		if (handle.text != UIFiles.last_path || search != UIFiles.last_search || refresh) {
 			UIFiles.files = [];
 
 			// Up directory
-			let i1 = handle.text.indexOf(Path.sep);
-			let nested = i1 > -1 && handle.text.length - 1 > i1;
+			let i1: i32 = handle.text.indexOf(Path.sep);
+			let nested: bool = i1 > -1 && handle.text.length - 1 > i1;
 			///if krom_windows
 			// Server addresses like \\server are not nested
 			nested = nested && !(handle.text.length >= 2 && handle.text.charAt(0) == Path.sep && handle.text.charAt(1) == Path.sep && handle.text.lastIndexOf(Path.sep) == 1);
 			///end
 			if (nested) UIFiles.files.push("..");
 
-			let dirPath = handle.text;
+			let dirPath: string = handle.text;
 			///if krom_ios
 			if (!isCloud) dirPath = documentDirectory + dirPath;
 			///end
-			let filesAll = File.readDirectory(dirPath, foldersOnly);
+			let filesAll: string[] = File.read_directory(dirPath, foldersOnly);
 
 			for (let f of filesAll) {
 				if (f == "" || f.charAt(0) == ".") continue; // Skip hidden
-				if (f.indexOf(".") > 0 && !Path.isKnown(f)) continue; // Skip unknown extensions
+				if (f.indexOf(".") > 0 && !Path.is_known(f)) continue; // Skip unknown extensions
 				if (isCloud && f.indexOf("_icon.") >= 0) continue; // Skip thumbnails
 				if (f.toLowerCase().indexOf(search.toLowerCase()) < 0) continue; // Search filter
 				UIFiles.files.push(f);
 			}
 		}
-		UIFiles.lastPath = handle.text;
-		UIFiles.lastSearch = search;
+		UIFiles.last_path = handle.text;
+		UIFiles.last_search = search;
 		handle.changed = false;
 
-		let slotw = Math.floor(70 * zui_SCALE(ui));
-		let num = Math.floor(ui._w / slotw);
+		let slotw: i32 = Math.floor(70 * zui_SCALE(ui));
+		let num: i32 = Math.floor(ui._w / slotw);
 
 		ui._y += 4; // Don't cut off the border around selected materials
 		// Directory contents
-		for (let row = 0; row < Math.floor(Math.ceil(UIFiles.files.length / num)); ++row) {
-			let ar = [];
-			for (let i = 0; i < num * 2; ++i) ar.push(1 / num);
+		for (let row: i32 = 0; row < Math.floor(Math.ceil(UIFiles.files.length / num)); ++row) {
+			let ar: f32[] = [];
+			for (let i: i32 = 0; i < num * 2; ++i) ar.push(1 / num);
 			zui_row(ar);
 			if (row > 0) ui._y += zui_ELEMENT_OFFSET(ui) * 14.0;
 
-			for (let j = 0; j < num; ++j) {
-				let i = j + row * num;
+			for (let j: i32 = 0; j < num; ++j) {
+				let i: i32 = j + row * num;
 				if (i >= UIFiles.files.length) {
 					zui_end_element(slotw);
 					zui_end_element(slotw);
 					continue;
 				}
 
-				let f = UIFiles.files[i];
-				let _x = ui._x;
+				let f: string = UIFiles.files[i];
+				let _x: f32 = ui._x;
 
-				let rect = f.indexOf(".") > 0 ? file : folder;
-				let col = rect == file ? ui.t.LABEL_COL : ui.t.LABEL_COL - 0x00202020;
+				let rect: rect_t = f.indexOf(".") > 0 ? file : folder;
+				let col: i32 = rect == file ? ui.t.LABEL_COL : ui.t.LABEL_COL - 0x00202020;
 				if (UIFiles.selected == i) col = ui.t.HIGHLIGHT_COL;
 
-				let off = ui._w / 2 - 25 * zui_SCALE(ui);
+				let off: f32 = ui._w / 2 - 25 * zui_SCALE(ui);
 				ui._x += off;
 
-				let uix = ui._x;
-				let uiy = ui._y;
-				let state = zui_state_t.IDLE;
-				let generic = true;
+				let uix: f32 = ui._x;
+				let uiy: f32 = ui._y;
+				let state: zui_state_t = zui_state_t.IDLE;
+				let generic: bool = true;
 				let icon: image_t = null;
 
 				if (isCloud && f != ".." && !UIFiles.offline) {
-					if (UIFiles.iconMap == null) UIFiles.iconMap = new Map();
-					icon = UIFiles.iconMap.get(handle.text + Path.sep + f);
+					if (UIFiles.icon_map == null) UIFiles.icon_map = new Map();
+					icon = UIFiles.icon_map.get(handle.text + Path.sep + f);
 					if (icon == null) {
-						let filesAll = File.readDirectory(handle.text);
-						let iconFile = f.substr(0, f.lastIndexOf(".")) + "_icon.jpg";
+						let filesAll: string[] = File.read_directory(handle.text);
+						let iconFile: string = f.substr(0, f.lastIndexOf(".")) + "_icon.jpg";
 						if (filesAll.indexOf(iconFile) >= 0) {
-							let empty = render_path_render_targets.get("empty_black")._image;
-							UIFiles.iconMap.set(handle.text + Path.sep + f, empty);
-							File.cacheCloud(handle.text + Path.sep + iconFile, (abs: string) => {
+							let empty: image_t = render_path_render_targets.get("empty_black")._image;
+							UIFiles.icon_map.set(handle.text + Path.sep + f, empty);
+							File.cache_cloud(handle.text + Path.sep + iconFile, (abs: string) => {
 								if (abs != null) {
 									let image: image_t = data_get_image(abs);
 									app_notify_on_init(() => {
-										if (Base.pipeCopyRGB == null) Base.makePipeCopyRGB();
+										if (Base.pipe_copyRGB == null) Base.make_pipe_copy_rgb();
 										icon = image_create_render_target(image.width, image.height);
 										if (f.endsWith(".arm")) { // Used for material sphere alpha cutout
 											g2_begin(icon);
@@ -186,12 +186,12 @@ class UIFiles {
 											g2_begin(icon);
 											g2_clear(0xffffffff);
 										}
-										g2_set_pipeline(Base.pipeCopyRGB);
+										g2_set_pipeline(Base.pipe_copyRGB);
 										g2_draw_image(image, 0, 0);
 										g2_set_pipeline(null);
 										g2_end();
-										UIFiles.iconMap.set(handle.text + Path.sep + f, icon);
-										UIBase.hwnds[TabArea.TabStatus].redraws = 3;
+										UIFiles.icon_map.set(handle.text + Path.sep + f, icon);
+										UIBase.hwnds[tab_area_t.STATUS].redraws = 3;
 									});
 								}
 								else UIFiles.offline = true;
@@ -199,7 +199,7 @@ class UIFiles {
 						}
 					}
 					if (icon != null) {
-						let w = 50;
+						let w: i32 = 50;
 						if (i == UIFiles.selected) {
 							zui_fill(-2,        -2, w + 4,     2, ui.t.HIGHLIGHT_COL);
 							zui_fill(-2,     w + 2, w + 4,     2, ui.t.HIGHLIGHT_COL);
@@ -215,47 +215,47 @@ class UIFiles {
 					}
 				}
 				if (f.endsWith(".arm") && !isCloud) {
-					if (UIFiles.iconMap == null) UIFiles.iconMap = new Map();
-					let key = handle.text + Path.sep + f;
-					icon = UIFiles.iconMap.get(key);
-					if (!UIFiles.iconMap.has(key)) {
-						let blobPath = key;
+					if (UIFiles.icon_map == null) UIFiles.icon_map = new Map();
+					let key: string = handle.text + Path.sep + f;
+					icon = UIFiles.icon_map.get(key);
+					if (!UIFiles.icon_map.has(key)) {
+						let blobPath: string = key;
 
 						///if krom_ios
 						blobPath = documentDirectory + blobPath;
 						// TODO: implement native .arm parsing first
 						///else
 
-						let buffer = krom_load_blob(blobPath);
-						let raw = armpack_decode(buffer);
+						let buffer: buffer_t = krom_load_blob(blobPath);
+						let raw: any = armpack_decode(buffer);
 						if (raw.material_icons != null) {
-							let bytesIcon = raw.material_icons[0];
+							let bytesIcon: any = raw.material_icons[0];
 							icon = image_from_bytes(lz4_decode(bytesIcon, 256 * 256 * 4), 256, 256);
 						}
 
 						///if (is_paint || is_sculpt)
 						else if (raw.mesh_icons != null) {
-							let bytesIcon = raw.mesh_icons[0];
+							let bytesIcon: any = raw.mesh_icons[0];
 							icon = image_from_bytes(lz4_decode(bytesIcon, 256 * 256 * 4), 256, 256);
 						}
 						else if (raw.brush_icons != null) {
-							let bytesIcon = raw.brush_icons[0];
+							let bytesIcon: any = raw.brush_icons[0];
 							icon = image_from_bytes(lz4_decode(bytesIcon, 256 * 256 * 4), 256, 256);
 						}
 						///end
 
 						///if is_lab
 						if (raw.mesh_icon != null) {
-							let bytesIcon = raw.mesh_icon;
+							let bytesIcon: any = raw.mesh_icon;
 							icon = image_from_bytes(lz4_decode(bytesIcon, 256 * 256 * 4), 256, 256);
 						}
 						///end
 
-						UIFiles.iconMap.set(key, icon);
+						UIFiles.icon_map.set(key, icon);
 						///end
 					}
 					if (icon != null) {
-						let w = 50;
+						let w: i32 = 50;
 						if (i == UIFiles.selected) {
 							zui_fill(-2,        -2, w + 4,     2, ui.t.HIGHLIGHT_COL);
 							zui_fill(-2,     w + 2, w + 4,     2, ui.t.HIGHLIGHT_COL);
@@ -271,28 +271,28 @@ class UIFiles {
 					}
 				}
 
-				if (Path.isTexture(f) && !isCloud) {
-					let w = 50;
-					if (UIFiles.iconMap == null) UIFiles.iconMap = new Map();
-					let shandle = handle.text + Path.sep + f;
-					icon = UIFiles.iconMap.get(shandle);
+				if (Path.is_texture(f) && !isCloud) {
+					let w: i32 = 50;
+					if (UIFiles.icon_map == null) UIFiles.icon_map = new Map();
+					let shandle: string = handle.text + Path.sep + f;
+					icon = UIFiles.icon_map.get(shandle);
 					if (icon == null) {
-						let empty = render_path_render_targets.get("empty_black")._image;
-						UIFiles.iconMap.set(shandle, empty);
+						let empty: image_t = render_path_render_targets.get("empty_black")._image;
+						UIFiles.icon_map.set(shandle, empty);
 						let image: image_t = data_get_image(shandle);
 						app_notify_on_init(() => {
-							if (Base.pipeCopyRGB == null) Base.makePipeCopyRGB();
-							let sw = image.width > image.height ? w : Math.floor(1.0 * image.width / image.height * w);
-							let sh = image.width > image.height ? Math.floor(1.0 * image.height / image.width * w) : w;
+							if (Base.pipe_copyRGB == null) Base.make_pipe_copy_rgb();
+							let sw: i32 = image.width > image.height ? w : Math.floor(1.0 * image.width / image.height * w);
+							let sh: i32 = image.width > image.height ? Math.floor(1.0 * image.height / image.width * w) : w;
 							icon = image_create_render_target(sw, sh);
 							g2_begin(icon);
 							g2_clear(0xffffffff);
-							g2_set_pipeline(Base.pipeCopyRGB);
+							g2_set_pipeline(Base.pipe_copyRGB);
 							g2_draw_scaled_image(image, 0, 0, sw, sh);
 							g2_set_pipeline(null);
 							g2_end();
-							UIFiles.iconMap.set(shandle, icon);
-							UIBase.hwnds[TabArea.TabStatus].redraws = 3;
+							UIFiles.icon_map.set(shandle, icon);
+							UIBase.hwnds[tab_area_t.STATUS].redraws = 3;
 							data_delete_image(shandle); // The big image is not needed anymore
 						});
 					}
@@ -318,24 +318,24 @@ class UIFiles {
 
 				if (state == zui_state_t.STARTED) {
 					if (f != ".." && dragFiles) {
-						Base.dragOffX = -(mouse_x - uix - ui._window_x - 3);
-						Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1);
-						Base.dragFile = handle.text;
+						Base.drag_off_x = -(mouse_x - uix - ui._window_x - 3);
+						Base.drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
+						Base.drag_file = handle.text;
 						///if krom_ios
-						if (!isCloud) Base.dragFile = documentDirectory + Base.dragFile;
+						if (!isCloud) Base.drag_file = documentDirectory + Base.drag_file;
 						///end
-						if (Base.dragFile.charAt(Base.dragFile.length - 1) != Path.sep) {
-							Base.dragFile += Path.sep;
+						if (Base.drag_file.charAt(Base.drag_file.length - 1) != Path.sep) {
+							Base.drag_file += Path.sep;
 						}
-						Base.dragFile += f;
-						Base.dragFileIcon = icon;
+						Base.drag_file += f;
+						Base.drag_file_icon = icon;
 					}
 
 					UIFiles.selected = i;
-					if (time_time() - Context.raw.selectTime < 0.25) {
-						Base.dragFile = null;
-						Base.dragFileIcon = null;
-						Base.isDragging = false;
+					if (time_time() - Context.raw.select_time < 0.25) {
+						Base.drag_file = null;
+						Base.drag_file_icon = null;
+						Base.is_dragging = false;
 						handle.changed = ui.changed = true;
 						if (f == "..") { // Up
 							handle.text = handle.text.substring(0, handle.text.lastIndexOf(Path.sep));
@@ -350,14 +350,14 @@ class UIFiles {
 						}
 						UIFiles.selected = -1;
 					}
-					Context.raw.selectTime = time_time();
+					Context.raw.select_time = time_time();
 				}
 
 				// Label
 				ui._x = _x;
 				ui._y += slotw * 0.75;
-				let label0 = (UIFiles.showExtensions || f.indexOf(".") <= 0) ? f : f.substr(0, f.lastIndexOf("."));
-				let label1 = "";
+				let label0: string = (UIFiles.show_extensions || f.indexOf(".") <= 0) ? f : f.substr(0, f.lastIndexOf("."));
+				let label1: string = "";
 				while (label0.length > 0 && g2_font_width(ui.font, ui.font_size, label0) > ui._w - 6) { // 2 line split
 					label1 = label0.charAt(label0.length - 1) + label1;
 					label0 = label0.substr(0, label0.length - 1);

+ 216 - 216
base/Sources/UIHeader.ts

@@ -1,131 +1,131 @@
 
 class UIHeader {
 
-	static defaultHeaderH = 28;
-	static headerh = UIHeader.defaultHeaderH;
-	static headerHandle = zui_handle_create({ layout: zui_layout_t.HORIZONTAL });
-	static worktab = zui_handle_create();
+	static default_header_h: i32 = 28;
+	static headerh: i32 = UIHeader.default_header_h;
+	static header_handle: zui_handle_t = zui_handle_create({ layout: zui_layout_t.HORIZONTAL });
+	static worktab: zui_handle_t = zui_handle_create();
 
 	constructor() {
 	}
 
-	static renderUI = () => {
-		let ui = UIBase.ui;
+	static render_ui = () => {
+		let ui: zui_t = UIBase.ui;
 		if (Config.raw.touch_ui) {
-			UIHeader.headerh = UIHeader.defaultHeaderH + 6;
+			UIHeader.headerh = UIHeader.default_header_h + 6;
 		}
 		else {
-			UIHeader.headerh = UIHeader.defaultHeaderH;
+			UIHeader.headerh = UIHeader.default_header_h;
 		}
 		UIHeader.headerh = Math.floor(UIHeader.headerh * zui_SCALE(ui));
 
-		if (Config.raw.layout[LayoutSize.LayoutHeader] == 0) return;
+		if (Config.raw.layout[layout_size_t.HEADER] == 0) return;
 
-		let nodesw = (UINodes.show || UIView2D.show) ? Config.raw.layout[LayoutSize.LayoutNodesW] : 0;
+		let nodesw: i32 = (UINodes.show || UIView2D.show) ? Config.raw.layout[layout_size_t.NODES_W] : 0;
 		///if is_lab
-		let ww = sys_width() - nodesw;
+		let ww: i32 = sys_width() - nodesw;
 		///else
-		let ww = sys_width() - UIToolbar.toolbarw - Config.raw.layout[LayoutSize.LayoutSidebarW] - nodesw;
+		let ww: i32 = sys_width() - UIToolbar.toolbar_w - Config.raw.layout[layout_size_t.SIDEBAR_W] - nodesw;
 		///end
 
-		if (zui_window(UIHeader.headerHandle, app_x(), UIHeader.headerh, ww, UIHeader.headerh)) {
+		if (zui_window(UIHeader.header_handle, app_x(), UIHeader.headerh, ww, UIHeader.headerh)) {
 			ui._y += 2;
-			UIHeader.drawToolProperties(ui);
+			UIHeader.draw_tool_properties(ui);
 		}
 	}
 
 	///if is_paint
 
-	static drawToolProperties = (ui: zui_t) => {
-		if (Context.raw.tool == WorkspaceTool.ToolColorId) {
+	static draw_tool_properties = (ui: zui_t) => {
+		if (Context.raw.tool == workspace_tool_t.COLORID) {
 			zui_text(tr("Picked Color"));
-			if (Context.raw.colorIdPicked) {
+			if (Context.raw.colorid_picked) {
 				zui_image(render_path_render_targets.get("texpaint_colorid")._image, 0xffffffff, 64);
 			}
-			ui.enabled = Context.raw.colorIdPicked;
+			ui.enabled = Context.raw.colorid_picked;
 			if (zui_button(tr("Clear"))) {
-				Context.raw.colorIdPicked = false;
-				UIToolbar.toolbarHandle.redraws = 1;
+				Context.raw.colorid_picked = false;
+				UIToolbar.toolbar_handle.redraws = 1;
 			}
 			ui.enabled = true;
 			zui_text(tr("Color ID Map"));
-			if (Project.assetNames.length > 0) {
-				let cid = zui_combo(Context.raw.colorIdHandle, Base.enumTexts("TEX_IMAGE"), tr("Color ID"));
-				if (Context.raw.colorIdHandle.changed) {
+			if (Project.asset_names.length > 0) {
+				let cid: i32 = zui_combo(Context.raw.colorid_handle, Base.enum_texts("TEX_IMAGE"), tr("Color ID"));
+				if (Context.raw.colorid_handle.changed) {
 					Context.raw.ddirty = 2;
-					Context.raw.colorIdPicked = false;
-					UIToolbar.toolbarHandle.redraws = 1;
+					Context.raw.colorid_picked = false;
+					UIToolbar.toolbar_handle.redraws = 1;
 				}
-				zui_image(Project.getImage(Project.assets[cid]));
-				if (ui.is_hovered) zui_tooltip_image(Project.getImage(Project.assets[cid]), 256);
+				zui_image(Project.get_image(Project.assets[cid]));
+				if (ui.is_hovered) zui_tooltip_image(Project.get_image(Project.assets[cid]), 256);
 			}
 			if (zui_button(tr("Import"))) {
-				UIFiles.show(Path.textureFormats.join(","), false, true, (path: string) => {
+				UIFiles.show(Path.texture_formats.join(","), false, true, (path: string) => {
 					ImportAsset.run(path, -1.0, -1.0, true, false);
 
-					Context.raw.colorIdHandle.position = Project.assetNames.length - 1;
+					Context.raw.colorid_handle.position = Project.asset_names.length - 1;
 					for (let a of Project.assets) {
 						// Already imported
-						if (a.file == path) Context.raw.colorIdHandle.position = Project.assets.indexOf(a);
+						if (a.file == path) Context.raw.colorid_handle.position = Project.assets.indexOf(a);
 					}
 					Context.raw.ddirty = 2;
-					Context.raw.colorIdPicked = false;
-					UIToolbar.toolbarHandle.redraws = 1;
+					Context.raw.colorid_picked = false;
+					UIToolbar.toolbar_handle.redraws = 1;
 					UIBase.hwnds[2].redraws = 2;
 				});
 			}
-			ui.enabled = Context.raw.colorIdPicked;
+			ui.enabled = Context.raw.colorid_picked;
 			if (zui_button(tr("To Mask"))) {
-				if (SlotLayer.isMask(Context.raw.layer)) Context.setLayer(Context.raw.layer.parent);
-				let m = Base.newMask(false, Context.raw.layer);
+				if (SlotLayer.is_mask(Context.raw.layer)) Context.set_layer(Context.raw.layer.parent);
+				let m: SlotLayerRaw = Base.new_mask(false, Context.raw.layer);
 				let _next = () => {
-					if (Base.pipeMerge == null) Base.makePipe();
+					if (Base.pipe_merge == null) Base.make_pipe();
 					if (const_data_screen_aligned_vb == null) const_data_create_screen_aligned_data();
 					g4_begin(m.texpaint);
-					g4_set_pipeline(Base.pipeColorIdToMask);
-					g4_set_tex(Base.texpaintColorId,render_path_render_targets.get("texpaint_colorid")._image);
-					g4_set_tex(Base.texColorId, Project.getImage(Project.assets[Context.raw.colorIdHandle.position]));
+					g4_set_pipeline(Base.pipe_colorid_to_mask);
+					g4_set_tex(Base.texpaint_colorid,render_path_render_targets.get("texpaint_colorid")._image);
+					g4_set_tex(Base.tex_colorid, Project.get_image(Project.assets[Context.raw.colorid_handle.position]));
 					g4_set_vertex_buffer(const_data_screen_aligned_vb);
 					g4_set_index_buffer(const_data_screen_aligned_ib);
 					g4_draw();
 					g4_end();
-					Context.raw.colorIdPicked = false;
-					UIToolbar.toolbarHandle.redraws = 1;
-					UIHeader.headerHandle.redraws = 1;
-					Context.raw.layerPreviewDirty = true;
-					Base.updateFillLayers();
+					Context.raw.colorid_picked = false;
+					UIToolbar.toolbar_handle.redraws = 1;
+					UIHeader.header_handle.redraws = 1;
+					Context.raw.layer_preview_dirty = true;
+					Base.update_fill_layers();
 				}
-				Base.notifyOnNextFrame(_next);
-				History.newWhiteMask();
+				Base.notify_on_next_frame(_next);
+				History.new_white_mask();
 			}
 			ui.enabled = true;
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolPicker || Context.raw.tool == WorkspaceTool.ToolMaterial) {
-			let baseRPicked = Math.round(color_get_rb(Context.raw.pickedColor.base) / 255 * 10) / 10;
-			let baseGPicked = Math.round(color_get_gb(Context.raw.pickedColor.base) / 255 * 10) / 10;
-			let baseBPicked = Math.round(color_get_bb(Context.raw.pickedColor.base) / 255 * 10) / 10;
-			let normalRPicked = Math.round(color_get_rb(Context.raw.pickedColor.normal) / 255 * 10) / 10;
-			let normalGPicked = Math.round(color_get_gb(Context.raw.pickedColor.normal) / 255 * 10) / 10;
-			let normalBPicked = Math.round(color_get_bb(Context.raw.pickedColor.normal) / 255 * 10) / 10;
-			let occlusionPicked = Math.round(Context.raw.pickedColor.occlusion * 100) / 100;
-			let roughnessPicked = Math.round(Context.raw.pickedColor.roughness * 100) / 100;
-			let metallicPicked = Math.round(Context.raw.pickedColor.metallic * 100) / 100;
-			let heightPicked = Math.round(Context.raw.pickedColor.height * 100) / 100;
-			let opacityPicked = Math.round(Context.raw.pickedColor.opacity * 100) / 100;
-
-			let h = zui_handle("uiheader_0");
+		else if (Context.raw.tool == workspace_tool_t.PICKER || Context.raw.tool == workspace_tool_t.MATERIAL) {
+			let baseRPicked: f32 = Math.round(color_get_rb(Context.raw.picked_color.base) / 255 * 10) / 10;
+			let baseGPicked: f32 = Math.round(color_get_gb(Context.raw.picked_color.base) / 255 * 10) / 10;
+			let baseBPicked: f32 = Math.round(color_get_bb(Context.raw.picked_color.base) / 255 * 10) / 10;
+			let normalRPicked: f32 = Math.round(color_get_rb(Context.raw.picked_color.normal) / 255 * 10) / 10;
+			let normalGPicked: f32 = Math.round(color_get_gb(Context.raw.picked_color.normal) / 255 * 10) / 10;
+			let normalBPicked: f32 = Math.round(color_get_bb(Context.raw.picked_color.normal) / 255 * 10) / 10;
+			let occlusionPicked: f32 = Math.round(Context.raw.picked_color.occlusion * 100) / 100;
+			let roughnessPicked: f32 = Math.round(Context.raw.picked_color.roughness * 100) / 100;
+			let metallicPicked: f32 = Math.round(Context.raw.picked_color.metallic * 100) / 100;
+			let heightPicked: f32 = Math.round(Context.raw.picked_color.height * 100) / 100;
+			let opacityPicked: f32 = Math.round(Context.raw.picked_color.opacity * 100) / 100;
+
+			let h: zui_handle_t = zui_handle("uiheader_0");
 			let color: color_t = 0xffffffff;
 			color = color_set_rb(color, baseRPicked * 255);
 			color = color_set_gb(color, baseGPicked * 255);
 			color = color_set_bb(color, baseBPicked * 255);
 			h.color = color;
-			let state = zui_text("", 0, h.color);
+			let state: zui_state_t = zui_text("", 0, h.color);
 			if (state == zui_state_t.STARTED) {
-				let uix = ui._x;
-				let uiy = ui._y;
-				Base.dragOffX = -(mouse_x - uix - ui._window_x - 3);
-				Base.dragOffY = -(mouse_y - uiy - ui._window_y + 1);
-				Base.dragSwatch = Project.cloneSwatch(Context.raw.pickedColor);
+				let uix: i32 = ui._x;
+				let uiy: i32 = ui._y;
+				Base.drag_off_x = -(mouse_x - uix - ui._window_x - 3);
+				Base.drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
+				Base.drag_swatch = Project.clone_swatch(Context.raw.picked_color);
 			}
 			if (ui.is_hovered) zui_tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor"));
 			if (ui.is_hovered && ui.input_released) {
@@ -133,12 +133,12 @@ class UIHeader {
 					zui_fill(0, 0, ui._w / zui_SCALE(ui), ui.t.ELEMENT_H * 9, ui.t.SEPARATOR_COL);
 					ui.changed = false;
 					zui_color_wheel(h, false, null, 10 * ui.t.ELEMENT_H * zui_SCALE(ui), false);
-					if (ui.changed) UIMenu.keepOpen = true;
+					if (ui.changed) UIMenu.keep_open = true;
 				}, 10);
 			}
 			if (zui_button(tr("Add Swatch"))) {
-				let newSwatch = Project.cloneSwatch(Context.raw.pickedColor);
-				Context.setSwatch(newSwatch);
+				let newSwatch: swatch_color_t = Project.clone_swatch(Context.raw.picked_color);
+				Context.set_swatch(newSwatch);
 				Project.raw.swatches.push(newSwatch);
 				UIBase.hwnds[2].redraws = 1;
 			}
@@ -151,42 +151,42 @@ class UIHeader {
 			zui_text(tr("Metallic") + ` (${metallicPicked})`);
 			zui_text(tr("Height") + ` (${heightPicked})`);
 			zui_text(tr("Opacity") + ` (${opacityPicked})`);
-			Context.raw.pickerSelectMaterial = zui_check(zui_handle("uiheader_1", { selected: Context.raw.pickerSelectMaterial }), tr("Select Material"));
-			zui_combo(Context.raw.pickerMaskHandle, [tr("None"), tr("Material")], tr("Mask"), true);
-			if (Context.raw.pickerMaskHandle.changed) {
-				MakeMaterial.parsePaintMaterial();
+			Context.raw.picker_select_material = zui_check(zui_handle("uiheader_1", { selected: Context.raw.picker_select_material }), tr("Select Material"));
+			zui_combo(Context.raw.picker_mask_handle, [tr("None"), tr("Material")], tr("Mask"), true);
+			if (Context.raw.picker_mask_handle.changed) {
+				MakeMaterial.parse_paint_material();
 			}
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolBake) {
+		else if (Context.raw.tool == workspace_tool_t.BAKE) {
 			ui.changed = false;
 
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
-			let baking = Context.raw.pdirty > 0;
-			let rtBake = Context.raw.bakeType == BakeType.BakeAO || Context.raw.bakeType == BakeType.BakeLightmap || Context.raw.bakeType == BakeType.BakeBentNormal || Context.raw.bakeType == BakeType.BakeThickness;
+			let baking: bool = Context.raw.pdirty > 0;
+			let rtBake: bool = Context.raw.bake_type == bake_type_t.AO || Context.raw.bake_type == bake_type_t.LIGHTMAP || Context.raw.bake_type == bake_type_t.BENT_NORMAL || Context.raw.bake_type == bake_type_t.THICKNESS;
 			if (baking && zui_button(tr("Stop"))) {
 				Context.raw.pdirty = 0;
 				Context.raw.rdirty = 2;
 			}
 			///else
-			let baking = false;
-			let rtBake = false;
+			let baking: bool = false;
+			let rtBake: bool = false;
 			///end
 
 			if (!baking && zui_button(tr("Bake"))) {
-				Context.raw.pdirty = rtBake ? Context.raw.bakeSamples : 1;
+				Context.raw.pdirty = rtBake ? Context.raw.bake_samples : 1;
 				Context.raw.rdirty = 3;
-				Base.notifyOnNextFrame(() => {
-					Context.raw.layerPreviewDirty = true;
+				Base.notify_on_next_frame(() => {
+					Context.raw.layer_preview_dirty = true;
 				});
 				UIBase.hwnds[0].redraws = 2;
-				History.pushUndo = true;
+				History.push_undo = true;
 				///if (krom_direct3d12 || krom_vulkan || krom_metal)
-				RenderPathRaytraceBake.currentSample = 0;
+				RenderPathRaytraceBake.current_sample = 0;
 				///end
 			}
 
-			let bakeHandle = zui_handle("uiheader_2", { position: Context.raw.bakeType });
-			let bakes = [
+			let bakeHandle: zui_handle_t = zui_handle("uiheader_2", { position: Context.raw.bake_type });
+			let bakes: string[] = [
 				tr("AO"),
 				tr("Curvature"),
 				tr("Normal"),
@@ -210,40 +210,40 @@ class UIHeader {
 			}
 			///end
 
-			Context.raw.bakeType = zui_combo(bakeHandle, bakes, tr("Bake"));
+			Context.raw.bake_type = zui_combo(bakeHandle, bakes, tr("Bake"));
 
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
 			if (!krom_raytrace_supported()) {
-				Context.raw.bakeType += 1; // Offset for removed AO
+				Context.raw.bake_type += 1; // Offset for removed AO
 			}
 			///end
 
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
 			if (rtBake) {
-				let samplesHandle = zui_handle("uiheader_3", { value: Context.raw.bakeSamples });
-				Context.raw.bakeSamples = Math.floor(zui_slider(samplesHandle, tr("Samples"), 1, 512, true, 1));
+				let samplesHandle: zui_handle_t = zui_handle("uiheader_3", { value: Context.raw.bake_samples });
+				Context.raw.bake_samples = Math.floor(zui_slider(samplesHandle, tr("Samples"), 1, 512, true, 1));
 			}
 			///end
 
-			if (Context.raw.bakeType == BakeType.BakeNormalObject || Context.raw.bakeType == BakeType.BakePosition || Context.raw.bakeType == BakeType.BakeBentNormal) {
-				let bakeUpAxisHandle = zui_handle("uiheader_4", { position: Context.raw.bakeUpAxis });
-				Context.raw.bakeUpAxis = zui_combo(bakeUpAxisHandle, [tr("Z"), tr("Y")], tr("Up Axis"), true);
+			if (Context.raw.bake_type == bake_type_t.NORMAL_OBJECT || Context.raw.bake_type == bake_type_t.POSITION || Context.raw.bake_type == bake_type_t.BENT_NORMAL) {
+				let bakeUpAxisHandle: zui_handle_t = zui_handle("uiheader_4", { position: Context.raw.bake_up_axis });
+				Context.raw.bake_up_axis = zui_combo(bakeUpAxisHandle, [tr("Z"), tr("Y")], tr("Up Axis"), true);
 			}
-			if (Context.raw.bakeType == BakeType.BakeAO || Context.raw.bakeType == BakeType.BakeCurvature) {
-				let bakeAxisHandle = zui_handle("uiheader_5", { position: Context.raw.bakeAxis });
-				Context.raw.bakeAxis = zui_combo(bakeAxisHandle, [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")], tr("Axis"), true);
+			if (Context.raw.bake_type == bake_type_t.AO || Context.raw.bake_type == bake_type_t.CURVATURE) {
+				let bakeAxisHandle: zui_handle_t = zui_handle("uiheader_5", { position: Context.raw.bake_axis });
+				Context.raw.bake_axis = zui_combo(bakeAxisHandle, [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")], tr("Axis"), true);
 			}
-			if (Context.raw.bakeType == BakeType.BakeAO) {
-				let strengthHandle = zui_handle("uiheader_6", { value: Context.raw.bakeAoStrength });
-				Context.raw.bakeAoStrength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true);
-				let radiusHandle = zui_handle("uiheader_7", { value: Context.raw.bakeAoRadius });
-				Context.raw.bakeAoRadius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true);
-				let offsetHandle = zui_handle("uiheader_8", { value: Context.raw.bakeAoOffset });
-				Context.raw.bakeAoOffset = zui_slider(offsetHandle, tr("Offset"), 0.0, 2.0, true);
+			if (Context.raw.bake_type == bake_type_t.AO) {
+				let strengthHandle: zui_handle_t = zui_handle("uiheader_6", { value: Context.raw.bake_ao_strength });
+				Context.raw.bake_ao_strength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true);
+				let radiusHandle: zui_handle_t = zui_handle("uiheader_7", { value: Context.raw.bake_ao_radius });
+				Context.raw.bake_ao_radius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true);
+				let offsetHandle: zui_handle_t = zui_handle("uiheader_8", { value: Context.raw.bake_ao_offset });
+				Context.raw.bake_ao_offset = zui_slider(offsetHandle, tr("Offset"), 0.0, 2.0, true);
 			}
 			///if (krom_direct3d12 || krom_vulkan || krom_metal)
 			if (rtBake) {
-				let progress = RenderPathRaytraceBake.currentSample / Context.raw.bakeSamples;
+				let progress: f32 = RenderPathRaytraceBake.current_sample / Context.raw.bake_samples;
 				if (progress > 1.0) progress = 1.0;
 				// Progress bar
 				g2_set_color(ui.t.SEPARATOR_COL);
@@ -251,91 +251,91 @@ class UIHeader {
 				g2_set_color(ui.t.HIGHLIGHT_COL);
 				zui_draw_rect(true, ui._x + 1, ui._y, (ui._w - 2) * progress, zui_ELEMENT_H(ui));
 				g2_set_color(0xffffffff);
-				zui_text(tr("Samples") + ": " + RenderPathRaytraceBake.currentSample);
-				zui_text(tr("Rays/pixel" + ": ") + RenderPathRaytraceBake.raysPix);
-				zui_text(tr("Rays/second" + ": ") + RenderPathRaytraceBake.raysSec);
+				zui_text(tr("Samples") + ": " + RenderPathRaytraceBake.current_sample);
+				zui_text(tr("Rays/pixel" + ": ") + RenderPathRaytraceBake.rays_pix);
+				zui_text(tr("Rays/second" + ": ") + RenderPathRaytraceBake.rays_sec);
 			}
 			///end
-			if (Context.raw.bakeType == BakeType.BakeCurvature) {
-				let strengthHandle = zui_handle("uiheader_9", { value: Context.raw.bakeCurvStrength });
-				Context.raw.bakeCurvStrength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true);
-				let radiusHandle = zui_handle("uiheader_10", { value: Context.raw.bakeCurvRadius });
-				Context.raw.bakeCurvRadius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true);
-				let offsetHandle = zui_handle("uiheader_11", { value: Context.raw.bakeCurvOffset });
-				Context.raw.bakeCurvOffset = zui_slider(offsetHandle, tr("Offset"), -2.0, 2.0, true);
-				let smoothHandle = zui_handle("uiheader_12", { value: Context.raw.bakeCurvSmooth });
-				Context.raw.bakeCurvSmooth = Math.floor(zui_slider(smoothHandle, tr("Smooth"), 0, 5, false, 1));
-			}
-			if (Context.raw.bakeType == BakeType.BakeNormal || Context.raw.bakeType == BakeType.BakeHeight || Context.raw.bakeType == BakeType.BakeDerivative) {
-				let ar = [];
-				for (let p of Project.paintObjects) ar.push(p.base.name);
-				let polyHandle = zui_handle("uiheader_13", { position: Context.raw.bakeHighPoly });
-				Context.raw.bakeHighPoly = zui_combo(polyHandle, ar, tr("High Poly"));
+			if (Context.raw.bake_type == bake_type_t.CURVATURE) {
+				let strengthHandle: zui_handle_t = zui_handle("uiheader_9", { value: Context.raw.bake_curv_strength });
+				Context.raw.bake_curv_strength = zui_slider(strengthHandle, tr("Strength"), 0.0, 2.0, true);
+				let radiusHandle: zui_handle_t = zui_handle("uiheader_10", { value: Context.raw.bake_curv_radius });
+				Context.raw.bake_curv_radius = zui_slider(radiusHandle, tr("Radius"), 0.0, 2.0, true);
+				let offsetHandle: zui_handle_t = zui_handle("uiheader_11", { value: Context.raw.bake_curv_offset });
+				Context.raw.bake_curv_offset = zui_slider(offsetHandle, tr("Offset"), -2.0, 2.0, true);
+				let smoothHandle: zui_handle_t = zui_handle("uiheader_12", { value: Context.raw.bake_curv_smooth });
+				Context.raw.bake_curv_smooth = Math.floor(zui_slider(smoothHandle, tr("Smooth"), 0, 5, false, 1));
+			}
+			if (Context.raw.bake_type == bake_type_t.NORMAL || Context.raw.bake_type == bake_type_t.HEIGHT || Context.raw.bake_type == bake_type_t.DERIVATIVE) {
+				let ar: string[] = [];
+				for (let p of Project.paint_objects) ar.push(p.base.name);
+				let polyHandle: zui_handle_t = zui_handle("uiheader_13", { position: Context.raw.bake_high_poly });
+				Context.raw.bake_high_poly = zui_combo(polyHandle, ar, tr("High Poly"));
 			}
 			if (ui.changed) {
-				MakeMaterial.parsePaintMaterial();
+				MakeMaterial.parse_paint_material();
 			}
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolBrush ||
-				 Context.raw.tool == WorkspaceTool.ToolEraser ||
-				 Context.raw.tool == WorkspaceTool.ToolFill ||
-				 Context.raw.tool == WorkspaceTool.ToolDecal ||
-				 Context.raw.tool == WorkspaceTool.ToolText ||
-				 Context.raw.tool == WorkspaceTool.ToolClone ||
-				 Context.raw.tool == WorkspaceTool.ToolBlur ||
-				 Context.raw.tool == WorkspaceTool.ToolSmudge ||
-				 Context.raw.tool == WorkspaceTool.ToolParticle) {
-
-			let decal = Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText;
-			let decalMask = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown);
-			if (Context.raw.tool != WorkspaceTool.ToolFill) {
+		else if (Context.raw.tool == workspace_tool_t.BRUSH ||
+				 Context.raw.tool == workspace_tool_t.ERASER ||
+				 Context.raw.tool == workspace_tool_t.FILL ||
+				 Context.raw.tool == workspace_tool_t.DECAL ||
+				 Context.raw.tool == workspace_tool_t.TEXT ||
+				 Context.raw.tool == workspace_tool_t.CLONE ||
+				 Context.raw.tool == workspace_tool_t.BLUR ||
+				 Context.raw.tool == workspace_tool_t.SMUDGE ||
+				 Context.raw.tool == workspace_tool_t.PARTICLE) {
+
+			let decal: bool = Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT;
+			let decalMask: bool = decal && Operator.shortcut(Config.keymap.decal_mask, ShortcutType.ShortcutDown);
+			if (Context.raw.tool != workspace_tool_t.FILL) {
 				if (decalMask) {
-					Context.raw.brushDecalMaskRadius = zui_slider(Context.raw.brushDecalMaskRadiusHandle, tr("Radius"), 0.01, 2.0, true);
+					Context.raw.brush_decal_mask_radius = zui_slider(Context.raw.brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true);
 					if (ui.is_hovered) zui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", new Map([["brush_radius", Config.keymap.brush_radius], ["brush_radius_decrease", Config.keymap.brush_radius_decrease], ["brush_radius_increase", Config.keymap.brush_radius_increase]])));
 				}
 				else {
-					Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true);
+					Context.raw.brush_radius = zui_slider(Context.raw.brush_radius_handle, tr("Radius"), 0.01, 2.0, true);
 					if (ui.is_hovered) zui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", new Map([["brush_radius", Config.keymap.brush_radius], ["brush_radius_decrease", Config.keymap.brush_radius_decrease], ["brush_radius_increase", Config.keymap.brush_radius_increase]])));
 				}
 			}
 
-			if (Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText) {
-				Context.raw.brushScaleX = zui_slider(Context.raw.brushScaleXHandle, tr("Scale X"), 0.01, 2.0, true);
+			if (Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT) {
+				Context.raw.brush_scale_x = zui_slider(Context.raw.brush_scale_x_handle, tr("Scale X"), 0.01, 2.0, true);
 			}
 
-			if (Context.raw.tool == WorkspaceTool.ToolBrush  ||
-				Context.raw.tool == WorkspaceTool.ToolFill   ||
-				Context.raw.tool == WorkspaceTool.ToolDecal  ||
-				Context.raw.tool == WorkspaceTool.ToolText) {
-				let brushScaleHandle = zui_handle("uiheader_14", { value: Context.raw.brushScale });
-				Context.raw.brushScale = zui_slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true);
+			if (Context.raw.tool == workspace_tool_t.BRUSH  ||
+				Context.raw.tool == workspace_tool_t.FILL   ||
+				Context.raw.tool == workspace_tool_t.DECAL  ||
+				Context.raw.tool == workspace_tool_t.TEXT) {
+				let brushScaleHandle: zui_handle_t = zui_handle("uiheader_14", { value: Context.raw.brush_scale });
+				Context.raw.brush_scale = zui_slider(brushScaleHandle, tr("UV Scale"), 0.01, 5.0, true);
 				if (brushScaleHandle.changed) {
-					if (Context.raw.tool == WorkspaceTool.ToolDecal || Context.raw.tool == WorkspaceTool.ToolText) {
-						let current = _g2_current;
+					if (Context.raw.tool == workspace_tool_t.DECAL || Context.raw.tool == workspace_tool_t.TEXT) {
+						let current: image_t = _g2_current;
 						g2_end();
-						UtilRender.makeDecalPreview();
+						UtilRender.make_decal_preview();
 						g2_begin(current);
 					}
 				}
 
-				Context.raw.brushAngle = zui_slider(Context.raw.brushAngleHandle, tr("Angle"), 0.0, 360.0, true, 1);
+				Context.raw.brush_angle = zui_slider(Context.raw.brush_angle_handle, tr("Angle"), 0.0, 360.0, true, 1);
 				if (ui.is_hovered) zui_tooltip(tr("Hold {brush_angle} and move mouse to the left to decrease the angle\nHold {brush_angle} and move mouse to the right to increase the angle", new Map([["brush_angle", Config.keymap.brush_angle]])));
 
-				if (Context.raw.brushAngleHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+				if (Context.raw.brush_angle_handle.changed) {
+					MakeMaterial.parse_paint_material();
 				}
 			}
 
-			Context.raw.brushOpacity = zui_slider(Context.raw.brushOpacityHandle, tr("Opacity"), 0.0, 1.0, true);
+			Context.raw.brush_opacity = zui_slider(Context.raw.brush_opacity_handle, tr("Opacity"), 0.0, 1.0, true);
 			if (ui.is_hovered) zui_tooltip(tr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to increase the opacity", new Map([["brush_opacity", Config.keymap.brush_opacity]])));
 
-			if (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolEraser || Context.raw.tool == WorkspaceTool.ToolClone || decalMask) {
-				Context.raw.brushHardness = zui_slider(zui_handle("uiheader_15", { value: Context.raw.brushHardness }), tr("Hardness"), 0.0, 1.0, true);
+			if (Context.raw.tool == workspace_tool_t.BRUSH || Context.raw.tool == workspace_tool_t.ERASER || Context.raw.tool == workspace_tool_t.CLONE || decalMask) {
+				Context.raw.brush_hardness = zui_slider(zui_handle("uiheader_15", { value: Context.raw.brush_hardness }), tr("Hardness"), 0.0, 1.0, true);
 			}
 
-			if (Context.raw.tool != WorkspaceTool.ToolEraser) {
-				let brushBlendingHandle = zui_handle("uiheader_16", { value: Context.raw.brushBlending });
-				Context.raw.brushBlending = zui_combo(brushBlendingHandle, [
+			if (Context.raw.tool != workspace_tool_t.ERASER) {
+				let brushBlendingHandle: zui_handle_t = zui_handle("uiheader_16", { value: Context.raw.brush_blending });
+				Context.raw.brush_blending = zui_combo(brushBlendingHandle, [
 					tr("Mix"),
 					tr("Darken"),
 					tr("Multiply"),
@@ -356,77 +356,77 @@ class UIHeader {
 					tr("Value"),
 				], tr("Blending"));
 				if (brushBlendingHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+					MakeMaterial.parse_paint_material();
 				}
 			}
 
-			if (Context.raw.tool == WorkspaceTool.ToolBrush || Context.raw.tool == WorkspaceTool.ToolFill) {
-				let paintHandle = zui_handle("uiheader_17");
-				Context.raw.brushPaint = zui_combo(paintHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], tr("TexCoord"));
+			if (Context.raw.tool == workspace_tool_t.BRUSH || Context.raw.tool == workspace_tool_t.FILL) {
+				let paintHandle: zui_handle_t = zui_handle("uiheader_17");
+				Context.raw.brush_paint = zui_combo(paintHandle, [tr("UV Map"), tr("Triplanar"), tr("Project")], tr("TexCoord"));
 				if (paintHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+					MakeMaterial.parse_paint_material();
 				}
 			}
-			if (Context.raw.tool == WorkspaceTool.ToolText) {
-				let h = zui_handle("uiheader_18");
-				h.text = Context.raw.textToolText;
-				let w = ui._w;
+			if (Context.raw.tool == workspace_tool_t.TEXT) {
+				let h: zui_handle_t = zui_handle("uiheader_18");
+				h.text = Context.raw.text_tool_text;
+				let w: i32 = ui._w;
 				if (ui.text_selected_handle_ptr == h.ptr || ui.submit_text_handle_ptr == h.ptr) {
 					ui._w *= 3;
 				}
 
-				Context.raw.textToolText = zui_text_input(h, "", zui_align_t.LEFT, true, true);
+				Context.raw.text_tool_text = zui_text_input(h, "", zui_align_t.LEFT, true, true);
 				ui._w = w;
 
 				if (h.changed) {
-					let current = _g2_current;
+					let current: image_t = _g2_current;
 					g2_end();
-					UtilRender.makeTextPreview();
-					UtilRender.makeDecalPreview();
+					UtilRender.make_text_preview();
+					UtilRender.make_decal_preview();
 					g2_begin(current);
 				}
 			}
 
-			if (Context.raw.tool == WorkspaceTool.ToolFill) {
-				zui_combo(Context.raw.fillTypeHandle, [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")], tr("Fill Mode"));
-				if (Context.raw.fillTypeHandle.changed) {
-					if (Context.raw.fillTypeHandle.position == FillType.FillFace) {
-						let current = _g2_current;
+			if (Context.raw.tool == workspace_tool_t.FILL) {
+				zui_combo(Context.raw.fill_type_handle, [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")], tr("Fill Mode"));
+				if (Context.raw.fill_type_handle.changed) {
+					if (Context.raw.fill_type_handle.position == fill_type_t.FACE) {
+						let current: image_t = _g2_current;
 						g2_end();
 						// UtilUV.cacheUVMap();
-						UtilUV.cacheTriangleMap();
+						UtilUV.cache_triangle_map();
 						g2_begin(current);
 						// wireframeHandle.selected = drawWireframe = true;
 					}
-					MakeMaterial.parsePaintMaterial();
-					MakeMaterial.parseMeshMaterial();
+					MakeMaterial.parse_paint_material();
+					MakeMaterial.parse_mesh_material();
 				}
 			}
 			else {
-				let _w = ui._w;
-				let sc = zui_SCALE(ui);
-				let touchHeader = (Config.raw.touch_ui && Config.raw.layout[LayoutSize.LayoutHeader] == 1);
+				let _w: i32 = ui._w;
+				let sc: f32 = zui_SCALE(ui);
+				let touchHeader: bool = (Config.raw.touch_ui && Config.raw.layout[layout_size_t.HEADER] == 1);
 				if (touchHeader) ui._x -= 4 * sc;
 				ui._w = Math.floor((touchHeader ? 54 : 60) * sc);
 
-				let xrayHandle = zui_handle("uiheader_19", { selected: Context.raw.xray });
+				let xrayHandle: zui_handle_t = zui_handle("uiheader_19", { selected: Context.raw.xray });
 				Context.raw.xray = zui_check(xrayHandle, tr("X-Ray"));
 				if (xrayHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+					MakeMaterial.parse_paint_material();
 				}
 
-				let symXHandle = zui_handle("uiheader_20", { selected: false });
-				let symYHandle = zui_handle("uiheader_21", { selected: false });
-				let symZHandle = zui_handle("uiheader_22", { selected: false });
+				let symXHandle: zui_handle_t = zui_handle("uiheader_20", { selected: false });
+				let symYHandle: zui_handle_t = zui_handle("uiheader_21", { selected: false });
+				let symZHandle: zui_handle_t = zui_handle("uiheader_22", { selected: false });
 
-				if (Config.raw.layout[LayoutSize.LayoutHeader] == 1) {
+				if (Config.raw.layout[layout_size_t.HEADER] == 1) {
 					if (Config.raw.touch_ui) {
 						ui._w = Math.floor(19 * sc);
-						Context.raw.symX = zui_check(symXHandle, "");
+						Context.raw.sym_x = zui_check(symXHandle, "");
 						ui._x -= 4 * sc;
-						Context.raw.symY = zui_check(symYHandle, "");
+						Context.raw.sym_y = zui_check(symYHandle, "");
 						ui._x -= 4 * sc;
-						Context.raw.symZ = zui_check(symZHandle, "");
+						Context.raw.sym_z = zui_check(symZHandle, "");
 						ui._x -= 4 * sc;
 						ui._w = Math.floor(40 * sc);
 						zui_text(tr("X") + tr("Y") + tr("Z"));
@@ -435,33 +435,33 @@ class UIHeader {
 						ui._w = Math.floor(56 * sc);
 						zui_text(tr("Symmetry"));
 						ui._w = Math.floor(25 * sc);
-						Context.raw.symX = zui_check(symXHandle, tr("X"));
-						Context.raw.symY = zui_check(symYHandle, tr("Y"));
-						Context.raw.symZ = zui_check(symZHandle, tr("Z"));
+						Context.raw.sym_x = zui_check(symXHandle, tr("X"));
+						Context.raw.sym_y = zui_check(symYHandle, tr("Y"));
+						Context.raw.sym_z = zui_check(symZHandle, tr("Z"));
 					}
 					ui._w = _w;
 				}
 				else {
 					// Popup
 					ui._w = _w;
-					Context.raw.symX = zui_check(symXHandle, tr("Symmetry") + " " + tr("X"));
-					Context.raw.symY = zui_check(symYHandle, tr("Symmetry") + " " + tr("Y"));
-					Context.raw.symZ = zui_check(symZHandle, tr("Symmetry") + " " + tr("Z"));
+					Context.raw.sym_x = zui_check(symXHandle, tr("Symmetry") + " " + tr("X"));
+					Context.raw.sym_y = zui_check(symYHandle, tr("Symmetry") + " " + tr("Y"));
+					Context.raw.sym_z = zui_check(symZHandle, tr("Symmetry") + " " + tr("Z"));
 				}
 
 				if (symXHandle.changed || symYHandle.changed || symZHandle.changed) {
-					MakeMaterial.parsePaintMaterial();
+					MakeMaterial.parse_paint_material();
 				}
 			}
 
 			///if arm_physics
-			if (Context.raw.tool == WorkspaceTool.ToolParticle) {
+			if (Context.raw.tool == workspace_tool_t.PARTICLE) {
 				ui._x += 10 * zui_SCALE(ui);
-				let physHandle = zui_handle("uiheader_23", { selected: false });
-				Context.raw.particlePhysics = zui_check(physHandle, tr("Physics"));
+				let physHandle: zui_handle_t = zui_handle("uiheader_23", { selected: false });
+				Context.raw.particle_physics = zui_check(physHandle, tr("Physics"));
 				if (physHandle.changed) {
-					UtilParticle.initParticlePhysics();
-					MakeMaterial.parsePaintMaterial();
+					UtilParticle.init_particle_physics();
+					MakeMaterial.parse_paint_material();
 				}
 			}
 			///end
@@ -471,29 +471,29 @@ class UIHeader {
 	///end
 
 	///if is_sculpt
-	static drawToolProperties = (ui: zui_t) => {
-		if (Context.raw.tool == WorkspaceTool.ToolBrush) {
-			Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true);
+	static draw_tool_properties = (ui: zui_t) => {
+		if (Context.raw.tool == workspace_tool_t.BRUSH) {
+			Context.raw.brush_radius = zui_slider(Context.raw.brush_radius_handle, tr("Radius"), 0.01, 2.0, true);
 			if (ui.is_hovered) zui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", new Map([["brush_radius", Config.keymap.brush_radius], ["brush_radius_decrease", Config.keymap.brush_radius_decrease], ["brush_radius_increase", Config.keymap.brush_radius_increase]])));
 		}
 	}
 	///end
 
 	///if is_lab
-	static drawToolProperties = (ui: zui_t) => {
-		if (Context.raw.tool == WorkspaceTool.ToolPicker) {
+	static draw_tool_properties = (ui: zui_t) => {
+		if (Context.raw.tool == workspace_tool_t.PICKER) {
 
 		}
-		else if (Context.raw.tool == WorkspaceTool.ToolEraser ||
-				 Context.raw.tool == WorkspaceTool.ToolClone  ||
-				 Context.raw.tool == WorkspaceTool.ToolBlur   ||
-				 Context.raw.tool == WorkspaceTool.ToolSmudge) {
-
-			let nodes = UINodes.getNodes();
-			let canvas = UINodes.getCanvas(true);
-			let inpaint = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
+		else if (Context.raw.tool == workspace_tool_t.ERASER ||
+				 Context.raw.tool == workspace_tool_t.CLONE  ||
+				 Context.raw.tool == workspace_tool_t.BLUR   ||
+				 Context.raw.tool == workspace_tool_t.SMUDGE) {
+
+			let nodes: zui_nodes_t = UINodes.get_nodes();
+			let canvas: zui_node_canvas_t = UINodes.get_canvas(true);
+			let inpaint: bool = nodes.nodesSelectedId.length > 0 && zui_get_node(canvas.nodes, nodes.nodesSelectedId[0]).type == "InpaintNode";
 			if (inpaint) {
-				Context.raw.brushRadius = zui_slider(Context.raw.brushRadiusHandle, tr("Radius"), 0.01, 2.0, true);
+				Context.raw.brush_radius = zui_slider(Context.raw.brush_radius_handle, tr("Radius"), 0.01, 2.0, true);
 				if (ui.is_hovered) zui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", new Map([["brush_radius", Config.keymap.brush_radius], ["brush_radius_decrease", Config.keymap.brush_radius_decrease], ["brush_radius_increase", Config.keymap.brush_radius_increase]])));
 			}
 		}

部分文件因为文件数量过多而无法显示