Skip to content

Commit

Permalink
Continue adding more type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
ephread committed Dec 24, 2021
1 parent b727db4 commit 00965d3
Show file tree
Hide file tree
Showing 20 changed files with 677 additions and 603 deletions.
3 changes: 1 addition & 2 deletions addons/inkgd/runtime.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ static func init(root_node, should_pause_on_error = true):
if root_node.has_node("__InkRuntime"):
return root_node.get_node("__InkRuntime")

var InkRuntime = load("res://addons/inkgd/runtime/static/ink_runtime.gd")
var _ink_runtime = InkRuntime.new()
var _ink_runtime = load("res://addons/inkgd/runtime/static/ink_runtime.gd").new()

_ink_runtime.should_pause_execution_on_exception = should_pause_on_error
_ink_runtime.should_pause_execution_on_error = should_pause_on_error
Expand Down
4 changes: 2 additions & 2 deletions addons/inkgd/runtime/common/ink_object.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func debug_line_number_of_path(path: InkPath):
return null

# InkPath
var path: Path setget , get_path
func get_path() -> Path:
var path: InkPath setget , get_path
func get_path() -> InkPath:
if _path == null:
if self.parent == null:
_path = InkPath().new()
Expand Down
32 changes: 19 additions & 13 deletions addons/inkgd/runtime/content/choices/choice.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@ class_name InkChoice
# Imports
# ############################################################################ #

var CallStack = load("res://addons/inkgd/runtime/callstack.gd")
var CallStack := load("res://addons/inkgd/runtime/callstack.gd") as GDScript

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

var text # String
var text: String

# () -> String
# (String) -> void
var path_string_on_choice setget set_path_string_on_choice, get_path_string_on_choice
func get_path_string_on_choice():
var path_string_on_choice: String setget set_path_string_on_choice, get_path_string_on_choice
func get_path_string_on_choice() -> String:
return target_path.to_string()

func set_path_string_on_choice(value):
func set_path_string_on_choice(value: String):
target_path = InkPath().new_with_components_string(value)

var source_path = null # String
var index = 0 # index
var target_path = null # InkPath
var thread_at_generation = null # CallStack.InkThread
var original_thread_index = 0 # int
var is_invisible_default = false # bool
# String?
var source_path = null

var index: int = 0

# InkPath?
var target_path = null

# CallStack.InkThread?
var thread_at_generation = null

var original_thread_index: int = 0

var is_invisible_default: bool = false

# ############################################################################ #
# GDScript extra methods
Expand Down
54 changes: 24 additions & 30 deletions addons/inkgd/runtime/content/choices/choice_point.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,48 @@ class_name InkChoicePoint

# () -> InkPath
# (InkPath) -> void
var path_on_choice setget set_path_on_choice, get_path_on_choice
func get_path_on_choice():
var path_on_choice: InkPath setget set_path_on_choice, get_path_on_choice
func get_path_on_choice() -> InkPath:
if self._path_on_choice != null && self._path_on_choice.is_relative:
var choice_target_obj = self.choice_target
if choice_target_obj:
self._path_on_choice = choice_target_obj.path

return _path_on_choice
func set_path_on_choice(value):
func set_path_on_choice(value: InkPath):
_path_on_choice = value

var _path_on_choice = null # InkPath
# InkPath?
var _path_on_choice = null

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

# () -> InkContainer
# (InkContainer) -> void
var choice_target setget , get_choice_target
func get_choice_target():
var choice_target: InkContainer setget , get_choice_target
func get_choice_target() -> InkContainer:
var cont = resolve_path(self._path_on_choice).container
return cont

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

# () -> String
# (String) -> void
var path_string_on_choice setget set_path_string_on_choice, get_path_string_on_choice
func get_path_string_on_choice():
var path_string_on_choice: String setget \
set_path_string_on_choice, \
get_path_string_on_choice
func get_path_string_on_choice() -> String:
return compact_path_string(self.path_on_choice)
func set_path_string_on_choice(value):
func set_path_string_on_choice(value: String):
self.path_on_choice = InkPath().new_with_components_string(value)

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

var has_condition # bool
var has_start_content # bool
var has_choice_only_content # bool
var once_only # bool
var is_invisible_default # bool
var has_condition: bool
var has_start_content: bool
var has_choice_only_content: bool
var once_only: bool
var is_invisible_default: bool

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

# () -> int
# (int) -> void
var flags setget set_flags, get_flags

var flags: int setget set_flags, get_flags
func get_flags() -> int:
var flags: int = 0

Expand All @@ -79,8 +75,7 @@ func get_flags() -> int:
flags |= 16

return flags

func set_flags(value):
func set_flags(value: int):
has_condition = (value & 1) > 0
has_start_content = (value & 2) > 0
has_choice_only_content = (value & 4) > 0
Expand All @@ -92,22 +87,21 @@ func set_flags(value):
func _init(once_only: bool = true):
self.once_only = once_only

# () -> String
func to_string():
func to_string() -> String:
var target_line_num = debug_line_number_of_path(self.path_on_choice)
var target_string = self.path_on_choice.to_string()

if target_line_num != null:
target_string = " line " + target_line_num + "(" + target_string + ")"
target_string = " line %d(%s)" % [target_line_num, target_string]

return "Choice: -> " + target_string
return "Choice: -> %s" % target_string

# ############################################################################ #
# GDScript extra methods
# ############################################################################ #

func is_class(type):
func is_class(type: String) -> bool:
return type == "ChoicePoint" || .is_class(type)

func get_class():
func get_class() -> String:
return "ChoicePoint"
Loading

0 comments on commit 00965d3

Please sign in to comment.