Split yarn, handle inactive options

This commit is contained in:
3wc
2024-02-16 03:51:57 -03:00
parent 808958f7cc
commit fd6b9ee8dd
4 changed files with 45 additions and 36 deletions

View File

@ -1,5 +1,6 @@
import h2d.Layers;
import h2d.Console;
import h3d.Vector4;
import scene.TitleScene;
import scene.WorldMapScene;
@ -87,9 +88,11 @@ class Game extends hxd.App {
var yarnText = [
hxd.Res.text.intro.entry.getText(),
hxd.Res.text.rooms.entry.getText(),
];
var yarnFileNames = [
hxd.Res.text.intro.entry.name,
hxd.Res.text.rooms.entry.name,
];
dialogueManager.load(yarnText, yarnFileNames);
@ -135,8 +138,10 @@ class Game extends hxd.App {
function renderOptions(event:OptionsShown) {
for (option in event.options) {
addOption(option.text, function() {
globalEventBus.publishEvent(new OptionSelected(option.index));
addOption(option.text, option.enabled, function() {
if (option.enabled) {
globalEventBus.publishEvent(new OptionSelected(option.index));
}
});
}
}
@ -150,10 +155,13 @@ class Game extends hxd.App {
return g;
}
function addOption(o: String, callback: () -> Void) {
function addOption(o: String, enabled : Bool, callback: () -> Void) {
var spr = newPanel(Const.W, 60);
curDialogue.addChild(spr);
var tf = new h2d.Text(font, spr);
if (!enabled) {
tf.color = new Vector4(0.5, 0.5, 0.5, 1);
}
tf.text = o;
tf.x = 10;
tf.y = 10;

View File

@ -42,7 +42,6 @@ class WorldMapScene extends h2d.Flow implements GameScene implements h2d.domkit.
area.x = obj.x;
area.y = obj.y;
area.onClick = function(_) {
trace("Room:" + obj.name);
var room = rooms.get(obj.name);
if (room.isOpen) {
Game.current.globalEventBus.publishEvent(new StartDialogueNode("Room:" + obj.name));