2019-12-09 00:28:10 +01:00
|
|
|
package;
|
2019-06-22 00:25:38 +02:00
|
|
|
|
|
|
|
|
import kha.Window;
|
|
|
|
|
import kha.WindowOptions;
|
|
|
|
|
import kha.WindowMode;
|
|
|
|
|
import kha.System;
|
2019-08-21 11:53:56 +02:00
|
|
|
import iron.object.Object;
|
2019-06-22 00:25:38 +02:00
|
|
|
import iron.Scene;
|
|
|
|
|
import iron.RenderPath;
|
|
|
|
|
import arm.render.Inc;
|
|
|
|
|
import arm.render.RenderPathDeferred;
|
2019-08-25 21:21:56 +02:00
|
|
|
import arm.render.Uniforms;
|
2019-06-22 00:25:38 +02:00
|
|
|
import arm.Config;
|
2019-11-11 15:35:00 +01:00
|
|
|
#if arm_player
|
2020-03-18 20:26:28 +01:00
|
|
|
import arm.sys.Path;
|
2019-11-11 15:35:00 +01:00
|
|
|
#end
|
2019-06-22 00:25:38 +02:00
|
|
|
|
2019-05-25 20:15:08 +02:00
|
|
|
class Main {
|
2019-10-06 19:03:59 +02:00
|
|
|
|
2020-03-18 20:26:28 +01:00
|
|
|
public static var version = "0.8";
|
|
|
|
|
|
2019-12-09 00:28:10 +01:00
|
|
|
static var tasks: Int;
|
2019-06-22 00:25:38 +02:00
|
|
|
|
|
|
|
|
public static function main() {
|
2020-03-18 20:26:28 +01:00
|
|
|
// Used to locate external application data folder
|
2020-01-24 12:51:18 +01:00
|
|
|
Krom.setApplicationName("ArmorPaint");
|
2020-03-18 20:26:28 +01:00
|
|
|
|
2019-06-22 00:25:38 +02:00
|
|
|
tasks = 1;
|
2019-08-21 11:53:56 +02:00
|
|
|
tasks++; Config.load(function() { tasks--; start(); });
|
2019-12-03 00:25:38 +01:00
|
|
|
#if arm_physics
|
2020-03-18 20:26:28 +01:00
|
|
|
tasks++; arm.plugin.PhysicsWorld.load();
|
2019-12-03 00:25:38 +01:00
|
|
|
#end
|
2019-06-22 00:25:38 +02:00
|
|
|
tasks--; start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static function start() {
|
|
|
|
|
if (tasks > 0) return;
|
2019-10-06 19:03:59 +02:00
|
|
|
|
2020-01-21 09:49:13 +01:00
|
|
|
Config.init();
|
2019-06-22 00:25:38 +02:00
|
|
|
var c = Config.raw;
|
2020-03-18 20:26:28 +01:00
|
|
|
|
2019-06-22 00:25:38 +02:00
|
|
|
var windowMode = c.window_mode == 0 ? WindowMode.Windowed : WindowMode.Fullscreen;
|
|
|
|
|
var windowFeatures = None;
|
|
|
|
|
if (c.window_resizable) windowFeatures |= FeatureResizable;
|
|
|
|
|
if (c.window_maximizable) windowFeatures |= FeatureMaximizable;
|
|
|
|
|
if (c.window_minimizable) windowFeatures |= FeatureMinimizable;
|
|
|
|
|
|
2019-08-20 10:46:56 +02:00
|
|
|
#if arm_player
|
|
|
|
|
var title = Krom.getArg(0);
|
2020-02-16 21:50:14 +01:00
|
|
|
var lasti = title.lastIndexOf(Path.sep);
|
2019-08-20 10:46:56 +02:00
|
|
|
if (lasti >= 0) title = title.substr(lasti + 1);
|
|
|
|
|
if (title.endsWith(".exe")) title = title.substr(0, title.length - 4);
|
|
|
|
|
#else
|
2020-01-24 12:51:18 +01:00
|
|
|
var title = "untitled - ArmorPaint";
|
2019-08-20 10:46:56 +02:00
|
|
|
#end
|
|
|
|
|
|
2019-12-09 00:28:10 +01:00
|
|
|
var options: kha.SystemOptions = {
|
|
|
|
|
title: title,
|
|
|
|
|
window: {
|
|
|
|
|
width: c.window_w,
|
|
|
|
|
height: c.window_h,
|
|
|
|
|
x: c.window_x,
|
|
|
|
|
y: c.window_y,
|
|
|
|
|
mode: windowMode,
|
|
|
|
|
windowFeatures: windowFeatures
|
|
|
|
|
},
|
|
|
|
|
framebuffer: {
|
|
|
|
|
samplesPerPixel: 1,
|
|
|
|
|
verticalSync: c.window_vsync
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
System.start(options, function(window: Window) {
|
2020-01-24 12:51:18 +01:00
|
|
|
Krom.setApplicationName("ArmorPaint");
|
2019-06-22 00:25:38 +02:00
|
|
|
iron.App.init(function() {
|
2019-12-09 00:28:10 +01:00
|
|
|
Scene.setActive("Scene", function(o: Object) {
|
2019-08-25 21:21:56 +02:00
|
|
|
Uniforms.init();
|
2019-08-22 12:05:03 +02:00
|
|
|
var path = new RenderPath();
|
|
|
|
|
Inc.init(path);
|
|
|
|
|
RenderPathDeferred.init(path);
|
|
|
|
|
path.commands = RenderPathDeferred.commands;
|
|
|
|
|
RenderPath.setActive(path);
|
|
|
|
|
#if arm_player
|
|
|
|
|
new arm.Player();
|
|
|
|
|
#else
|
|
|
|
|
new arm.App();
|
2019-08-20 10:46:56 +02:00
|
|
|
#end
|
2019-12-03 00:25:38 +01:00
|
|
|
#if arm_physics
|
|
|
|
|
o.addTrait(new arm.plugin.PhysicsWorld());
|
|
|
|
|
#end
|
2019-06-22 00:25:38 +02:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-05-25 20:15:08 +02:00
|
|
|
}
|