Break out title screen into separate file

This commit is contained in:
3wc 2024-02-13 13:47:24 -03:00
parent aaddce255a
commit 17ba4ada30
3 changed files with 36 additions and 34 deletions

View File

@ -7,7 +7,7 @@ view.mybox {
padding: 10;
}
container {
title-screen {
max-width: 300;
layout: vertical;
}

View File

@ -1,36 +1,5 @@
import components.MenubuttonComponent;
import screens.TitleScreen;
@: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;
@ -39,7 +8,7 @@ class Main extends hxd.App {
center = new h2d.Flow(s2d);
center.horizontalAlign = center.verticalAlign = Middle;
onResize();
var root = new ContainerComp(Right, center);
var root = new TitleScreen(Right, center);
root.btnNewGame.onClick = function() {
Game.inst = new Game();

View File

@ -0,0 +1,33 @@
package screens;
import components.MenubuttonComponent;
@:uiComp("heading")
class HeadingComp extends h2d.Flow implements h2d.domkit.Object {
static var SRC = <heading class="mybox" min-width="200" content-halign={align}>
<text text={"Rewild"}/>
for( i in icons )
<bitmap src={i} id="icons[]"/>
</heading>;
public function new(align:h2d.Flow.FlowAlign, icons:Array<h2d.Tile>, ?parent) {
super(parent);
initComponent();
}
}
@:uiComp("title-screen")
class TitleScreen extends h2d.Flow implements h2d.domkit.Object {
static var SRC = <title-screen>
<heading(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"/>
</title-screen>;
public function new(align:h2d.Flow.FlowAlign, ?parent) {
super(parent);
initComponent();
}
}