forked from harper/spooktober-vnj
Added mapping tool, reworked scene structure, and added test data.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
extends GraphNode
|
||||
class_name GraphFileNode
|
||||
var scene : DialogueScene = null
|
||||
# static var base_loc :String = "res://dialogue/resources/"
|
||||
var file_loc : String
|
||||
func _init(loc : String):
|
||||
file_loc = loc
|
||||
title = loc
|
||||
name = loc.replace("/", ";").replace(".","*")
|
||||
scene = DialogueScene.load_scene(loc)
|
||||
|
||||
func _ready():
|
||||
add_child(Control.new())
|
||||
set_slot(0, true, 0, Color.BLACK, false, 0, Color.BLACK)
|
||||
|
||||
if scene == null:
|
||||
return
|
||||
var dias : Array[Dialogue] = scene.get_scene()
|
||||
var i = 1
|
||||
for dia in dias:
|
||||
if dia.choices.is_empty():
|
||||
continue
|
||||
else:
|
||||
for chc : Choice in dia.choices:
|
||||
var l = Label.new()
|
||||
if chc.response.is_empty() :
|
||||
l.text = "(invisible choice)"
|
||||
else:
|
||||
l.text = chc.response
|
||||
add_child(l)
|
||||
set_slot(i, false, 0, Color.BLACK, true, 0, Color.from_hsv(float(i-1)*0.1, 1, 1))
|
||||
i+=1
|
||||
func map(ge : GraphEdit):
|
||||
if scene != null:
|
||||
var to_map_arr : Array[GraphFileNode] = []
|
||||
var dias : Array[Dialogue] = scene.get_scene()
|
||||
var i = 0
|
||||
for dia in dias:
|
||||
|
||||
if dia.choices.is_empty():
|
||||
continue
|
||||
else:
|
||||
for chc : Choice in dia.choices:
|
||||
for t : ChoiceTarget in chc.targets:
|
||||
var name1 = t.target_scene_loc.replace("/", ";").replace(".","*")
|
||||
var outNode : GraphFileNode
|
||||
if !ge.has_node(name1):
|
||||
outNode = GraphFileNode.new(t.target_scene_loc)
|
||||
ge.add_child(outNode)
|
||||
to_map_arr.append(outNode)
|
||||
ge.connect_node(self.name, i, name1, 0)
|
||||
i+=1
|
||||
for to_map : GraphFileNode in to_map_arr:
|
||||
to_map.map(ge)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bnyumo4kb4h1q
|
||||
@@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
func _on_map_button_button_up() -> void:
|
||||
$UI/VBox/GraphEdit.clear_connections()
|
||||
for child in $UI/VBox/GraphEdit.get_children():
|
||||
if child is GraphFileNode :
|
||||
$UI/VBox/GraphEdit.remove_child(child)
|
||||
child.queue_free()
|
||||
var startNode : GraphFileNode = GraphFileNode.new("test_scene1.json")
|
||||
$UI/VBox/GraphEdit.add_child(startNode)
|
||||
startNode.map($UI/VBox/GraphEdit)
|
||||
$UI/VBox/GraphEdit.arrange_nodes()
|
||||
@@ -0,0 +1 @@
|
||||
uid://dvomfsvrdv4pr
|
||||
@@ -0,0 +1,33 @@
|
||||
[gd_scene format=3 uid="uid://bvgr4gp4xnqdl"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dvomfsvrdv4pr" path="res://tools/map/map.gd" id="1_6lvw1"]
|
||||
|
||||
[node name="Map" type="Node" unique_id=1335935698]
|
||||
script = ExtResource("1_6lvw1")
|
||||
|
||||
[node name="UI" type="Control" parent="." unique_id=1741993090]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="UI" unique_id=2056072322]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="MapButton" type="Button" parent="UI/VBox" unique_id=2030873199]
|
||||
layout_mode = 2
|
||||
text = "Map!"
|
||||
|
||||
[node name="GraphEdit" type="GraphEdit" parent="UI/VBox" unique_id=49166899]
|
||||
custom_minimum_size = Vector2(100, 500)
|
||||
layout_mode = 2
|
||||
|
||||
[connection signal="button_up" from="UI/VBox/MapButton" to="." method="_on_map_button_button_up"]
|
||||
Reference in New Issue
Block a user