3 Commits

3 changed files with 68 additions and 11 deletions

View File

@@ -18,10 +18,8 @@ class Main extends Sprite {
private function onInit(e:Event) private function onInit(e:Event)
{ {
//Scanner.scanTextureDir(); //Scanner.scanTextureDir();
trace("heyy");
stage.frameRate = 1000; stage.frameRate = 1000;
var game:Game = new Game(stage); var game:Game = new Game(stage);
trace("kokk");
stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame); stage.addEventListener(Event.ENTER_FRAME, game.onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN,Input.onKeyIsDown); stage.addEventListener(KeyboardEvent.KEY_DOWN,Input.onKeyIsDown);
stage.addEventListener(KeyboardEvent.KEY_UP,Input.onKeyIsUp); stage.addEventListener(KeyboardEvent.KEY_UP,Input.onKeyIsUp);
@@ -30,7 +28,6 @@ class Main extends Sprite {
//Mode.setVideoMode(1280, 960); //Mode.setVideoMode(1280, 960);
} }
private function onResize (event:Event):Void { private function onResize (event:Event):Void {
trace("yeet");
//Here we can do shit with window scaling //Here we can do shit with window scaling
//stage.stageWidth; //stage.stageWidth;
//stage.stageHeight; //stage.stageHeight;

View File

@@ -1,5 +1,7 @@
package engine.tools.ui; package engine.tools.ui;
import game.ui.text.TextFormats;
import openfl.text.TextFormat;
import openfl.text.TextField; import openfl.text.TextField;
import engine.ui.UIPane; import engine.ui.UIPane;
import lime.app.Event; import lime.app.Event;
@@ -10,10 +12,18 @@ import engine.ConVar;
import game.ui.console.Console; import game.ui.console.Console;
//import Lib.application. //import Lib.application.
typedef UINode = {
object:UIPane,
?children:Array<UINode>
}
class UITool{ class UITool{
public static var ccmd_dev_uitool = ConVar.registerCCmd("dev_uitool", (args:Array<String>) -> { open();}); public static var ccmd_dev_uitool = ConVar.registerCCmd("dev_uitool", (args:Array<String>) -> { open();});
public static var uiEditorWindow:openfl.display.Window; public static var uiEditorWindow:openfl.display.Window;
public static var uiEditorSprite:Sprite; public static var uiEditorSprite:Sprite;
private static var tf:TextField;
public static function spawnUIEditorWindow(){ public static function spawnUIEditorWindow(){
var secondWindow = Lib.application.createWindow({title: "UI Outliner"}); var secondWindow = Lib.application.createWindow({title: "UI Outliner"});
if(uiEditorSprite == null){ if(uiEditorSprite == null){
@@ -26,16 +36,63 @@ class UITool{
secondWindow.onClose.add(()->{ secondWindow.onClose.add(()->{
uiEditorWindow = null; uiEditorWindow = null;
}); });
var tf:TextField = new TextField(); tf = new TextField();
TextFormats.getFormats();
var tformat = TextFormats.formats.cInputFmt;
tf.setTextFormat(tformat);
tf.autoSize = LEFT;
uiEditorSprite.addChild(tf);
update([]);
}
public static var ccmd_dev_uitool_refresh = ConVar.registerCCmd("dev_uitool_refresh", update);
public static var uiNodes:Map<UIPane, UINode> = [];
public static var rootNodes:Array<UINode> = [];
public static function collect(){
for(pane in UIPane.panelist){
var node:UINode = null;
if(uiNodes[pane] == null){
node = {
object: pane,
children: []
};
}
else{
node = uiNodes[pane];
}
var parentNode:UINode = null;
if(uiNodes[pane.parent] == null){
parentNode = {
object:pane.parent,
children: []
}
}
else{
parentNode = uiNodes[pane.parent];
}
parentNode.children.push(node);
if(pane.parent == null){
rootNodes.push(node);
}
}
}
public static function update(args:Array<String>){
tf.text = "";
for(pane in UIPane.panelist){ for(pane in UIPane.panelist){
//check if pane is toplevel //check if pane is toplevel
Console.devMsg("Pane: "+ pane.name); Console.devMsg("Pane: "+ pane.name);
//Get all Root UI Panes
if(pane.parent == null) { if(pane.parent == null) {
tf.appendText("-");
tf.appendText(pane.name+"\n"); tf.appendText(pane.name+"\n");
} }
} }
uiEditorSprite.addChild(tf);
} }
public static function open(){ public static function open(){
if(uiEditorWindow == null){ if(uiEditorWindow == null){
spawnUIEditorWindow(); spawnUIEditorWindow();

View File

@@ -6,10 +6,13 @@ package engine.ui;
// | ____ | | | |_ \ | ____| // | ____ | | | |_ \ | ____|
// | | | | | \__/ | | |____ // | | | | | \__/ | | |____
// |__| |__| \______/ |______| // |__| |__| \______/ |______|
// file: UIPane.hx
// author: and.schaafsma@gmail.com /*
// purpose: Class for resizable and scalable UI Panels / file: UIPane.hx
// My hope is that this code is so awful I'm never allowed to write UI code again. / author: and.schaafsma@gmail.com
/ purpose: Class for resizable and scalable UI Panels
/ My hope is that this code is so awful I'm never allowed to write UI code again.
*/
import game.ui.console.Console; import game.ui.console.Console;
import openfl.display.Sprite; import openfl.display.Sprite;
import openfl.display.BitmapData; import openfl.display.BitmapData;