diff --git a/.gitignore b/.gitignore index 068e52d9..71056145 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ export_presets.cfg # inkgd ignores .inkgd_compiler.cfg +inkgd-issue-* diff --git a/CHANGELOG.md b/CHANGELOG.md index aabbef6c..779d785a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Change Log Important changes to _inkgd_ will be documented in this file. +## 0.1.4 +Released on 2020-XX-XX. + +### Fixed +- Fixed [#12] – Combined lists and functions don't work as intended. +- Fixed [#13] – Multiline functions are executed all at once. + +[#12]: https://github.com/ephread/inkgd/issues/12 +[#13]: https://github.com/ephread/inkgd/issues/13 + ## [0.1.3](https://github.com/ephread/inkgd/releases/tag/0.1.3) Released on 2019-10-10. diff --git a/addons/inkgd/runtime/ink_list.gd b/addons/inkgd/runtime/ink_list.gd index f79a9b9c..c155b2d1 100644 --- a/addons/inkgd/runtime/ink_list.gd +++ b/addons/inkgd/runtime/ink_list.gd @@ -275,6 +275,19 @@ func list_with_sub_range(min_bound, max_bound): return sub_list +func equals(other): + var other_raw_list = other + # Simple test to make sure the object is of the right type. + if !(other_raw_list is Object): return false + if !(other_raw_list.is_class("InkList")): return false + + if other_raw_list.size() != self.size(): return false + for key in keys(): + if (!other_raw_list.has(key)): + return false + + return true + var ordered_items setget , get_ordered_items # Array> func get_ordered_items(): var ordered = [] diff --git a/addons/inkgd/runtime/ink_list_item.gd b/addons/inkgd/runtime/ink_list_item.gd index c6eea9be..521a9ad7 100644 --- a/addons/inkgd/runtime/ink_list_item.gd +++ b/addons/inkgd/runtime/ink_list_item.gd @@ -41,11 +41,12 @@ static func null(): var is_null setget , get_is_null # bool func get_is_null(): - return origin_name == null && item_name == null + return self.origin_name == null && self.item_name == null var full_name setget , get_full_name # String func get_full_name(): - return (origin_name if origin_name else "?") + "." + str(item_name) + # In C#, concatenating null produce nothing, in GDScript, it appends "Null". + return (self.origin_name if self.origin_name else "?") + "." + str(self.item_name if self.item_name else "") # ############################################################################ # @@ -57,7 +58,7 @@ func to_string(): func equals(obj): if obj.is_class("InkListItem"): var other_item = obj - return other_item.item_name == item_name && other_item.origin_name == origin_name + return other_item.item_name == self.item_name && self.other_item.origin_name == self.origin_name return false diff --git a/addons/inkgd/runtime/ink_path.gd b/addons/inkgd/runtime/ink_path.gd index 26a5e293..5e2f2de0 100644 --- a/addons/inkgd/runtime/ink_path.gd +++ b/addons/inkgd/runtime/ink_path.gd @@ -255,4 +255,4 @@ func get_class(): return "InkPath" static func InkPath(): - return load("res://addons/inkgd/runtime/ink_path.gd") \ No newline at end of file + return load("res://addons/inkgd/runtime/ink_path.gd") diff --git a/examples/scenes/ink_runner.tscn b/examples/scenes/ink_runner.tscn index 39741cf2..362f306c 100644 --- a/examples/scenes/ink_runner.tscn +++ b/examples/scenes/ink_runner.tscn @@ -5,32 +5,31 @@ [ext_resource path="res://examples/images/inkgd_the_intercept.png" type="Texture" id=3] [ext_resource path="res://examples/images/spinner.png" type="Texture" id=4] -[sub_resource type="StyleBoxFlat" id=2] +[sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0, 0, 0, 1 ) -[sub_resource type="StyleBoxFlat" id=3] +[sub_resource type="StyleBoxFlat" id=2] bg_color = Color( 0.145098, 0.145098, 0.145098, 1 ) -[sub_resource type="StyleBoxFlat" id=4] +[sub_resource type="StyleBoxFlat" id=3] bg_color = Color( 0.270588, 0.270588, 0.270588, 1 ) -[sub_resource type="StyleBoxEmpty" id=5] +[sub_resource type="StyleBoxEmpty" id=4] -[sub_resource type="StyleBoxEmpty" id=6] +[sub_resource type="StyleBoxEmpty" id=5] -[sub_resource type="Theme" id=7] +[sub_resource type="Theme" id=6] VScrollBar/icons/decrement = ExtResource( 2 ) VScrollBar/icons/decrement_highlight = ExtResource( 2 ) VScrollBar/icons/increment = ExtResource( 2 ) VScrollBar/icons/increment_highlight = ExtResource( 2 ) -VScrollBar/styles/grabber = SubResource( 2 ) -VScrollBar/styles/grabber_highlight = SubResource( 3 ) -VScrollBar/styles/grabber_pressed = SubResource( 4 ) -VScrollBar/styles/scroll = SubResource( 5 ) -VScrollBar/styles/scroll_focus = SubResource( 6 ) - -[sub_resource type="Animation" id=1] -resource_name = "LoadingAnimation" +VScrollBar/styles/grabber = SubResource( 1 ) +VScrollBar/styles/grabber_highlight = SubResource( 2 ) +VScrollBar/styles/grabber_pressed = SubResource( 3 ) +VScrollBar/styles/scroll = SubResource( 4 ) +VScrollBar/styles/scroll_focus = SubResource( 5 ) + +[sub_resource type="Animation" id=7] loop = true tracks/0/type = "value" tracks/0/path = NodePath("LoadingAnimationPlayer/CenterContainer/VBoxContainer/CenterContainer/SpinnerTextureRect:rect_rotation") @@ -70,7 +69,7 @@ margin_top = 40.0 margin_right = 1670.0 margin_bottom = 1040.0 grow_horizontal = 2 -theme = SubResource( 7 ) +theme = SubResource( 6 ) scroll_horizontal_enabled = false [node name="StoryVBoxContainer" type="VBoxContainer" parent="StoryMarginContainer/StoryScrollContainer"] @@ -81,7 +80,7 @@ custom_constants/separation = 20 [node name="LoadingAnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "LoadingAnimation" -anims/LoadingAnimation = SubResource( 1 ) +anims/LoadingAnimation = SubResource( 7 ) [node name="CenterContainer" type="CenterContainer" parent="LoadingAnimationPlayer"] anchor_right = 1.0 diff --git a/test/fixture/compiled/extra/list_comparison.ink.json b/test/fixture/compiled/extra/list_comparison.ink.json new file mode 100644 index 00000000..3573cdd5 --- /dev/null +++ b/test/fixture/compiled/extra/list_comparison.ink.json @@ -0,0 +1 @@ +{"inkVersion":19,"root":[[{"->":"start"},["done",{"#n":"g-0"}],null],"done",{"set_actor":[{"temp=":"x"},"ev",{"VAR?":"x"},"/ev",["du","ev",{"VAR?":"P"},"==","/ev",{"->":".^.b","c":true},{"b":["pop","\n","ev","str","^Philippe","/str","/ev",{"VAR=":"currentActor","re":true},{"->":".^.^.^.7"},null]}],["du","ev",{"VAR?":"A"},"==","/ev",{"->":".^.b","c":true},{"b":["pop","\n","ev","str","^Andre","/str","/ev",{"VAR=":"currentActor","re":true},{"->":".^.^.^.7"},null]}],[{"->":".^.b"},{"b":["pop","\n","ev","str","^Bobby","/str","/ev",{"VAR=":"currentActor","re":true},{"->":".^.^.^.7"},null]}],"nop","\n",{"#f":3}],"start":["ev",{"VAR?":"P"},{"f()":"s","var":true},"out","/ev","^ Hey, my name is ","ev",{"VAR?":"currentActor"},"out","/ev","^. What about yours?","\n","ev",{"VAR?":"A"},{"f()":"s","var":true},"out","/ev","^ I am ","ev",{"VAR?":"currentActor"},"out","/ev","^ and I need my rheumatism pills!","\n","ev",{"VAR?":"P"},{"f()":"s","var":true},"out","/ev","^ Would you like me, ","ev",{"VAR?":"currentActor"},"out","/ev","^, to get some more for you?","\n","end",{"#f":3}],"global decl":["ev","str","^Bobby","/str",{"VAR=":"currentActor"},{"list":{},"origins":["listOfActors"]},{"VAR=":"listOfActors"},{"^->":"set_actor"},{"VAR=":"s"},"/ev","end",null],"#f":3}],"listDefs":{"listOfActors":{"P":1,"A":2,"S":3,"C":4}}} \ No newline at end of file diff --git a/test/fixture/original/extra/list_comparison.ink b/test/fixture/original/extra/list_comparison.ink new file mode 100644 index 00000000..40d00d12 --- /dev/null +++ b/test/fixture/original/extra/list_comparison.ink @@ -0,0 +1,18 @@ +VAR currentActor = "Bobby" + +LIST listOfActors = P, A, S, C +VAR s = -> set_actor +-> start + +===function set_actor(x) +{ x: +- P: ~ currentActor = "Philippe" +- A: ~ currentActor = "Andre" +- else: ~ currentActor = "Bobby" +} + +=== start === +{s(P)} Hey, my name is {currentActor}. What about yours? +{s(A)} I am {currentActor} and I need my rheumatism pills! +{s(P)} Would you like me, {currentActor}, to get some more for you? +-> END diff --git a/test/integration/test_extra.gd b/test/integration/test_extra.gd new file mode 100644 index 00000000..edfe1579 --- /dev/null +++ b/test/integration/test_extra.gd @@ -0,0 +1,21 @@ +# ############################################################################ # +# Copyright © 2019-present Frédéric Maquin +# All Rights Reserved +# +# This file is part of inkgd. +# inkgd is licensed under the terms of the MIT license. +# ############################################################################ # + +extends "res://test/integration/test_base.gd" + +# ############################################################################ # + +func test_list_comparison(): + var story = Story.new(load_file("list_comparison")) + + assert_eq(story.continue_maximally(), "Hey, my name is Philippe. What about yours?\nI am Andre and I need my rheumatism pills!\nWould you like me, Philippe, to get some more for you?\n") + +# ############################################################################ # + +func _prefix(): + return "extra/" diff --git a/test/tests.tscn b/test/tests.tscn index 014492e8..f831aef6 100644 --- a/test/tests.tscn +++ b/test/tests.tscn @@ -10,6 +10,7 @@ anchor_bottom = 1.0 rect_min_size = Vector2( 740, 250 ) script = ExtResource( 1 ) __meta__ = { +"_edit_use_anchors_": false, "_editor_icon": ExtResource( 2 ) } _yield_between_tests = false