Skip to content

Commit

Permalink
Fix #12 #13 - Lists not being compared correctly / container path
Browse files Browse the repository at this point in the history
  • Loading branch information
ephread committed Apr 11, 2020
1 parent 18abcd8 commit 3cb55c2
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export_presets.cfg
# inkgd ignores

.inkgd_compiler.cfg
inkgd-issue-*
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
13 changes: 13 additions & 0 deletions addons/inkgd/runtime/ink_list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyValuePair<InkListItem, int>>
func get_ordered_items():
var ordered = []
Expand Down
7 changes: 4 additions & 3 deletions addons/inkgd/runtime/ink_list_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")

# ############################################################################ #

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion addons/inkgd/runtime/ink_path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ func get_class():
return "InkPath"

static func InkPath():
return load("res://addons/inkgd/runtime/ink_path.gd")
return load("res://addons/inkgd/runtime/ink_path.gd")
31 changes: 15 additions & 16 deletions examples/scenes/ink_runner.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"]
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/fixture/compiled/extra/list_comparison.ink.json
Original file line number Diff line number Diff line change
@@ -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}}}
18 changes: 18 additions & 0 deletions test/fixture/original/extra/list_comparison.ink
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/integration/test_extra.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ############################################################################ #
# Copyright © 2019-present Frédéric Maquin <[email protected]>
# 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/"
1 change: 1 addition & 0 deletions test/tests.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3cb55c2

Please sign in to comment.