Abandon ScaleGrid bg for now, working though!

This commit is contained in:
3wc 2024-02-18 13:38:32 -03:00
parent 2ad54aa613
commit 610d107e60
4 changed files with 34 additions and 28 deletions

View File

@ -56,18 +56,26 @@ menubutton:active {
flow.dialogue-container { flow.dialogue-container {
fill-width: true; fill-width: true;
height: 20; height: 20;
debug: true; layout: vertical;
} }
dialogue-box { dialogue-box {
fill-width: true; fill-width: true;
height: 20; height: 20;
/* background: tile("ui.png", 5, 5); */
/* background-tile-pos: 1 1; */
background: blue;
padding: 10;
} }
scale-grid#dialogueBackground { dialogue-options {
/* fill-width: true; */ fill-width: true;
background: red;
layout: vertical;
} }
/* text#dialogueText { */ dialogue-option {
/* font : url("res/font/minecraftia_regular_6.fnt"); */ fill-width: true;
/* } */ background: green;
padding: 10;
}

View File

@ -22,6 +22,8 @@ class GameContainer extends h2d.Flow implements h2d.domkit.Object {
public function new(?parent) { public function new(?parent) {
super(parent); super(parent);
initComponent(); initComponent();
this.maxWidth = Const.W;
this.minWidth = Const.W;
} }
} }
@ -83,8 +85,8 @@ class Game extends hxd.App {
var dialogueParent = new h2d.Flow(); var dialogueParent = new h2d.Flow();
dialogueParent.dom = domkit.Properties.create("flow", dialogueParent); dialogueParent.dom = domkit.Properties.create("flow", dialogueParent);
dialogueParent.dom.addClass('dialogue-container'); dialogueParent.dom.addClass('dialogue-container');
style.addObject(dialogueParent);
layer.addChildAt(dialogueParent, 2); layer.addChildAt(dialogueParent, 2);
style.addObject(dialogueParent);
dialogueBoxController = new DialogueBoxController(globalEventBus, dialogueParent, style); dialogueBoxController = new DialogueBoxController(globalEventBus, dialogueParent, style);
#if debug #if debug

View File

@ -1,6 +1,7 @@
package components; package components;
import dialogue.event.NextLine; import dialogue.event.NextLine;
import dialogue.event.OptionsShown.OptionChoice;
@:uiComp("dialogue-option") @:uiComp("dialogue-option")
class DialogueOptionComponent extends h2d.Flow implements h2d.domkit.Object { class DialogueOptionComponent extends h2d.Flow implements h2d.domkit.Object {
@ -46,7 +47,17 @@ class DialogueOptionsComponent extends h2d.Flow implements h2d.domkit.Object {
${options} ${options}
</dialogue-options>; </dialogue-options>;
public var options:Array<DialogueOptionComponent>; public var options = new Array<DialogueOptionComponent>();
public function new(options:Array<OptionChoice>, ?parent) {
super(parent);
initComponent();
for (option in options) {
this.options.push(
new DialogueOptionComponent(option.text, this)
);
}
}
} }
@:uiComp("dialogue-box") @:uiComp("dialogue-box")
@ -57,9 +68,7 @@ class DialogueBoxComponent extends h2d.Flow implements h2d.domkit.Object {
var game:Game; var game:Game;
static var SRC = <dialogue-box> static var SRC = <dialogue-box>
<scale-grid id="dialogueBackground">
<text text={displayedText} public font={Game.current.font} id="dialogueText" /> <text text={displayedText} public font={Game.current.font} id="dialogueText" />
</scale-grid>
</dialogue-box> </dialogue-box>
public var displayedText(get, set):String; public var displayedText(get, set):String;
@ -88,13 +97,6 @@ class DialogueBoxComponent extends h2d.Flow implements h2d.domkit.Object {
super(parent); super(parent);
initComponent(); initComponent();
internalText = text; internalText = text;
this.dialogueBackground.tile = Res.ui.toTile();
this.dialogueBackground.borderWidth = 5;
this.dialogueBackground.borderHeight = 5;
this.dialogueBackground.colorKey = 0xFF00FF;
this.dialogueBackground.width = this.innerWidth;
this.dialogueBackground.height = this.innerHeight;
// trace(this.dialogueBackground.width);
enableInteractive = true; enableInteractive = true;
interactive.onClick = function(_) onClick(); interactive.onClick = function(_) onClick();

View File

@ -45,7 +45,7 @@ class DialogueBoxController {
// int.onClick = function(_) click(); // int.onClick = function(_) click();
eventBus.subscribe(LineShown, dialogue); eventBus.subscribe(LineShown, dialogue);
// eventBus.subscribe(OptionsShown, renderOptions); eventBus.subscribe(OptionsShown, renderOptions);
// eventBus.subscribe(OptionSelected, onOptionSelected); // eventBus.subscribe(OptionSelected, onOptionSelected);
eventBus.subscribe(DialogueComplete, onDialogueComplete); eventBus.subscribe(DialogueComplete, onDialogueComplete);
} }
@ -71,15 +71,9 @@ class DialogueBoxController {
curDialogue = d; curDialogue = d;
} }
// function renderOptions(event:OptionsShown) { function renderOptions(event:OptionsShown) {
// for (option in event.options) { new DialogueOptionsComponent(event.options, this.parent);
// addOption(option.text, option.enabled, function() { }
// if (option.enabled) {
// globalEventBus.publishEvent(new OptionSelected(option.index));
// }
// });
// }
// }
// //
// function newPanel(w, h) { // function newPanel(w, h) {
// var g = new h2d.ScaleGrid(Res.ui.toTile(), 5, 5); // var g = new h2d.ScaleGrid(Res.ui.toTile(), 5, 5);