Files
armorpaint/Sources/Main.hx
T

77 lines
2.3 KiB
Haxe
Raw Normal View History

2019-05-25 20:15:08 +02: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-08-20 10:46:56 +02:00
using StringTools;
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
2019-06-22 00:25:38 +02:00
static var tasks:Int;
public static function main() {
tasks = 1;
2019-08-21 11:53:56 +02:00
tasks++; Config.load(function() { tasks--; start(); });
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
2019-06-22 00:25:38 +02:00
if (Config.raw == null) Config.raw = {};
var c = Config.raw;
if (c.window_mode == null) c.window_mode = 0;
if (c.window_resizable == null) c.window_resizable = true;
if (c.window_minimizable == null) c.window_minimizable = true;
if (c.window_maximizable == null) c.window_maximizable = true;
if (c.window_w == null) c.window_w = 1600;
if (c.window_h == null) c.window_h = 900;
2019-09-04 00:03:15 +02:00
if (c.window_x == null) c.window_x = -1;
if (c.window_y == null) c.window_y = -1;
2019-06-22 00:25:38 +02:00
if (c.window_scale == null) c.window_scale = 1.0;
if (c.window_vsync == null) c.window_vsync = true;
2019-10-06 19:03:59 +02: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);
title = title.replace("\\", "/");
var lasti = title.lastIndexOf("/");
if (lasti >= 0) title = title.substr(lasti + 1);
if (title.endsWith(".exe")) title = title.substr(0, title.length - 4);
#else
var title = "untitled - ArmorPaint";
#end
2019-09-04 00:03:15 +02:00
System.start({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}}, function(window:Window) {
2019-06-22 00:25:38 +02:00
iron.App.init(function() {
2019-08-22 12:05:03 +02: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-06-22 00:25:38 +02:00
});
});
});
}
2019-05-25 20:15:08 +02:00
}