Files
armorpaint/Sources/arm/Plugin.hx
T

113 lines
3.3 KiB
Haxe
Raw Normal View History

2018-02-28 09:53:15 +01:00
package arm;
2018-04-18 21:35:36 +02:00
// ArmorPaint plugin API
2019-10-10 14:27:17 +02:00
@:keep
2018-02-28 09:53:15 +01:00
class Plugin {
2019-12-09 00:28:10 +01:00
public static var plugins: Map<String, Plugin> = [];
static var pluginName: String;
2018-04-18 21:35:36 +02:00
2019-12-09 00:28:10 +01:00
public var drawUI: zui.Zui->Void = null;
public var draw: Void->Void = null;
public var update: Void->Void = null;
public var delete: Void->Void = null;
2019-11-11 22:22:17 +01:00
public var version = "0.1";
public var apiversion = "0.1";
2019-12-09 00:28:10 +01:00
var name: String;
2018-04-18 21:35:36 +02:00
public function new() {
2019-10-10 14:27:17 +02:00
name = pluginName;
plugins.set(name, this);
2018-04-18 21:35:36 +02:00
}
2019-12-09 00:28:10 +01:00
public static function start(plugin: String) {
2019-10-10 14:27:17 +02:00
try {
2019-12-09 00:28:10 +01:00
iron.data.Data.getBlob("plugins/" + plugin, function(blob: kha.Blob) {
2019-10-10 14:27:17 +02:00
pluginName = plugin;
#if js
untyped __js__("(1, eval)({0})", blob.toString());
#end
2019-10-14 10:57:12 +02:00
iron.data.Data.deleteBlob("plugins/" + plugin);
2019-10-10 14:27:17 +02:00
});
}
2019-12-09 00:28:10 +01:00
catch (e: Dynamic) { trace("Failed to load plugin '" + plugin + "'"); trace(e); }
2018-04-18 21:35:36 +02:00
}
2019-12-09 00:28:10 +01:00
public static function stop(plugin: String) {
2019-10-10 14:27:17 +02:00
var p = plugins.get(plugin);
2019-10-21 19:56:17 +02:00
if (p != null && p.delete != null) p.delete();
2019-10-10 14:27:17 +02:00
plugins.remove(plugin);
2018-02-28 09:53:15 +01:00
}
}
2018-04-18 21:35:36 +02:00
2019-08-31 20:44:48 +02:00
@:expose("iron")
2019-10-09 23:45:42 +02:00
class IronBridge {
2019-08-31 20:44:48 +02:00
public static var App = iron.App;
public static var Scene = iron.Scene;
2019-12-05 22:29:30 +01:00
public static var RenderPath = iron.RenderPath;
2019-08-31 20:44:48 +02:00
public static var Time = iron.system.Time;
public static var Input = iron.system.Input;
2019-10-30 21:40:35 +01:00
public static var ArmPack = iron.system.ArmPack;
2019-08-31 20:44:48 +02:00
public static var Object = iron.object.Object;
public static var Data = iron.data.Data;
2019-10-09 23:45:42 +02:00
}
@:expose("arm")
class ArmBridge {
2019-10-30 21:40:35 +01:00
public static var Json = haxe.Json;
public static var ReflectFields = Reflect.fields;
public static var ReflectField = Reflect.field;
public static var ReflectSetField = Reflect.setField;
public static var StdIs = Std.is;
2019-10-21 19:56:17 +02:00
public static var Bytes = haxe.io.Bytes;
2019-12-25 13:00:22 +01:00
public static var BytesInput = haxe.io.BytesInput;
2019-10-30 21:40:35 +01:00
public static var Blob = kha.Blob;
2019-10-21 19:56:17 +02:00
public static var Image = kha.Image;
2019-10-30 21:40:35 +01:00
public static var Scheduler = kha.Scheduler;
2019-10-20 19:48:57 +02:00
public static var App = arm.App;
public static var Config = arm.Config;
2019-10-09 23:45:42 +02:00
public static var Context = arm.Context;
2019-10-20 19:48:57 +02:00
public static var History = arm.History;
public static var Layers = arm.Layers;
2019-10-10 14:27:17 +02:00
public static var Log = arm.Log;
2019-10-20 19:48:57 +02:00
public static var Operator = arm.Operator;
public static var Plugin = arm.Plugin;
public static var Project = arm.Project;
public static var Res = arm.Res;
2019-11-13 13:51:17 +01:00
public static var Path = arm.sys.Path;
2019-11-30 14:24:26 +01:00
public static var File = arm.sys.File;
2019-11-13 15:17:10 +01:00
public static var NodesMaterial = arm.node.NodesMaterial;
public static var Material = arm.node.Material;
2019-10-30 21:40:35 +01:00
public static var UITrait = arm.ui.UITrait;
public static var UINodes = arm.ui.UINodes;
public static var UIFiles = arm.ui.UIFiles;
2019-12-12 22:55:57 +01:00
public static var UIMenu = arm.ui.UIMenu;
2019-11-19 21:02:31 +01:00
public static var MeshUtil = arm.util.MeshUtil;
public static var MaterialUtil = arm.util.MaterialUtil;
public static var RenderUtil = arm.util.RenderUtil;
public static var UVUtil = arm.util.UVUtil;
public static var ViewportUtil = arm.util.ViewportUtil;
2019-12-09 00:28:10 +01:00
public static function colorFromFloats(r: Float, g: Float, b: Float, a: Float): kha.Color {
return kha.Color.fromFloats(r, g, b, a);
}
2019-08-31 20:44:48 +02:00
}
2019-10-10 14:27:17 +02:00
@:expose("zui")
class ZuiBridge {
public static var Handle = zui.Zui.Handle;
2019-12-12 22:55:57 +01:00
public static var Ext = zui.Ext;
2019-10-10 14:27:17 +02:00
}
2019-10-30 21:40:35 +01:00
@:keep
class Keep {
2019-12-07 15:01:24 +01:00
public static function keep() {
var x = iron.system.ArmPack.decode;
var x = iron.system.ArmPack.encode;
2019-11-30 14:24:26 +01:00
#if arm_creator
2019-12-07 15:01:24 +01:00
var x = arm.sys.Path.workingDir;
var x = arm.sys.File.createDirectory;
2019-11-30 14:24:26 +01:00
#end
2019-10-30 21:40:35 +01:00
}
}