Make dialogue system work (hackily) with domkit

This commit is contained in:
3wc 2024-02-14 12:13:29 -03:00
parent 477b57e2a7
commit 021aac9914
2 changed files with 63 additions and 63 deletions

View File

@ -17,7 +17,7 @@ class DialogueBox extends h2d.Object {
if (text == null) if (text == null)
text = "NULL"; text = "NULL";
game = Game.current; game = Game.current;
game.root.add(this, 1); game.root.scene.getH2dObject().getScene().add(this, 1);
bg = new h2d.ScaleGrid(Res.ui.toTile(), 5, 5, this); bg = new h2d.ScaleGrid(Res.ui.toTile(), 5, 5, this);
bg.colorKey = 0xFF00FF; bg.colorKey = 0xFF00FF;
tf = new h2d.Text(game.font, this); tf = new h2d.Text(game.font, this);

View File

@ -8,9 +8,9 @@ import event.EventBus;
import event.ChangeSceneEvent; import event.ChangeSceneEvent;
import Const; import Const;
// import DialogueBox; import DialogueBox;
// import DialogueManager; import DialogueManager;
// import DialogueManager.Option; import DialogueManager.Option;
@:uiComp("game-container") @:uiComp("game-container")
class GameContainer extends h2d.Flow implements h2d.domkit.Object { class GameContainer extends h2d.Flow implements h2d.domkit.Object {
@ -69,19 +69,19 @@ class Game extends hxd.App {
setGameScene(new TitleScene(root)); setGameScene(new TitleScene(root));
#end #end
// font = Res.font.minecraftia_regular_6.toFont(); font = Res.font.minecraftia_regular_6.toFont();
// font.resizeTo(24); font.resizeTo(24);
//
// dialogueManager = new DialogueManager(dialogue, renderActions); dialogueManager = new DialogueManager(dialogue, renderActions);
//
// var yarnText = [ var yarnText = [
// hxd.Res.text.intro.entry.getText(), hxd.Res.text.intro.entry.getText(),
// ]; ];
// var yarnFileNames = [ var yarnFileNames = [
// hxd.Res.text.intro.entry.name, hxd.Res.text.intro.entry.name,
// ]; ];
// dialogueManager.load(yarnText, yarnFileNames); dialogueManager.load(yarnText, yarnFileNames);
// dialogueManager.runNode("Intro"); dialogueManager.runNode("Intro");
} }
public function new() { public function new() {
@ -98,52 +98,52 @@ class Game extends hxd.App {
style.sync(); style.sync();
} }
// function dialogue(manager:DialogueManager, t:String) { function dialogue(manager:DialogueManager, t:String) {
// var d = new DialogueBox(Const.W, 100, t); var d = new DialogueBox(Const.W, 100, t);
// d.y = 0; d.y = 0;
// d.onClick = function() { d.onClick = function() {
// manager.resume(); manager.resume();
// }; };
//
// curDialogue = d; curDialogue = d;
// } }
//
// function renderActions(manager:DialogueManager, t:Array<Option>) { function renderActions(manager:DialogueManager, t:Array<Option>) {
// for (action in t) { for (action in t) {
// addAction(action.text, action.callback); addAction(action.text, action.callback);
// } }
// } }
//
// 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);
// g.width = w; g.width = w;
// g.height = h; g.height = h;
// g.colorKey = 0xFF00FF; g.colorKey = 0xFF00FF;
// scene.add(g, 1); root.scene.getH2dObject().getScene().add(g, 1);
// return g; return g;
// } }
//
// function addAction(a: String, callback: () -> Void) { function addAction(a: String, callback: () -> Void) {
// var spr = newPanel(Const.W, 60); var spr = newPanel(Const.W, 60);
// curDialogue.addChild(spr); curDialogue.addChild(spr);
// var tf = new h2d.Text(font, spr); var tf = new h2d.Text(font, spr);
// tf.text = a; tf.text = a;
// tf.x = 10; tf.x = 10;
// tf.y = 10; tf.y = 10;
// spr.x = 0; spr.x = 0;
// spr.y = 100 + actions.length * 60; spr.y = 100 + actions.length * 60;
// var int = new h2d.Interactive(spr.width, spr.height, spr); var int = new h2d.Interactive(spr.width, spr.height, spr);
// int.onClick = function(_) { int.onClick = function(_) {
// for (action in actions) { for (action in actions) {
// action.remove(); action.remove();
// } }
// callback(); callback();
// removeDialog(); // removeDialog();
// } }
// int.cursor = Button; int.cursor = Button;
// actions.push(spr); actions.push(spr);
// return spr; return spr;
// } }
public function onChangeScene(event:ChangeSceneEvent) { public function onChangeScene(event:ChangeSceneEvent) {
setGameScene(event.newScene); setGameScene(event.newScene);