glasshouse/src/Main.hx

79 lines
1.8 KiB
Haxe

import components.MenubuttonComponent;
@:uiComp("view")
class ViewComp extends h2d.Flow implements h2d.domkit.Object {
static var SRC = <view class="mybox" min-width="200" content-halign={align}>
<text text={"Rewild"}/>
for( i in icons )
<bitmap src={i} id="icons[]"/>
</view>;
public function new(align:h2d.Flow.FlowAlign, icons:Array<h2d.Tile>, ?parent) {
super(parent);
initComponent();
}
}
@:uiComp("container")
class ContainerComp extends h2d.Flow implements h2d.domkit.Object {
static var SRC = <container>
<view(align,[]) id="view"/>
<menubutton("New game") public id="btnNewGame"/>
<menubutton("Continue game") public id="btnContinueGame"/>
<menubutton("Credits") public id="btnCredits"/>
<menubutton("Quit") public id="btnQuit"/>
</container>;
public function new(align:h2d.Flow.FlowAlign, ?parent) {
super(parent);
initComponent();
}
}
// PARAM=-lib domkit
class Main extends hxd.App {
var center:h2d.Flow;
var style = null;
override function init() {
center = new h2d.Flow(s2d);
center.horizontalAlign = center.verticalAlign = Middle;
onResize();
var root = new ContainerComp(Right, center);
root.btnNewGame.onClick = function() {
Game.inst = new Game();
}
root.btnContinueGame.onClick = function() {
root.btnContinueGame.dom.addClass("highlight");
}
// root.btnQuit.onClick = function() {
// Sys.exit(0);
// }
style = new h2d.domkit.Style();
style.load(hxd.Res.style);
style.allowInspect = true;
style.addObject(root);
}
override function onResize() {
center.minWidth = center.maxWidth = s2d.width;
center.minHeight = center.maxHeight = s2d.height;
}
override function update(dt:Float) {
style.sync();
}
static function main() {
#if hl
hxd.res.Resource.LIVE_UPDATE = true;
hxd.Res.initLocal();
#else
hxd.Res.initEmbed();
#end
new Main();
}
}