init
This commit is contained in:
commit
b99855351d
434 changed files with 50357 additions and 0 deletions
58
addons/inkgd/runtime/content/choices/ink_choice.gd
Normal file
58
addons/inkgd/runtime/content/choices/ink_choice.gd
Normal file
|
@ -0,0 +1,58 @@
|
|||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkChoice
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var text: String
|
||||
|
||||
var path_string_on_choice: String:
|
||||
get:
|
||||
# TODO: handle null case?
|
||||
return target_path._to_string()
|
||||
|
||||
set(value):
|
||||
target_path = InkPath.new_with_components_string(value)
|
||||
|
||||
|
||||
var source_path = null # String?
|
||||
|
||||
|
||||
var index: int = 0
|
||||
|
||||
|
||||
var target_path: InkPath = null
|
||||
|
||||
|
||||
var thread_at_generation: InkCallStack.InkThread = null
|
||||
|
||||
|
||||
var original_thread_index: int = 0
|
||||
|
||||
|
||||
var is_invisible_default: bool = false
|
||||
|
||||
|
||||
var tags = null # Array<String>?
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type):
|
||||
return type == "Choice" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class():
|
||||
return "Choice"
|
122
addons/inkgd/runtime/content/choices/ink_choice_point.gd
Normal file
122
addons/inkgd/runtime/content/choices/ink_choice_point.gd
Normal file
|
@ -0,0 +1,122 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkChoicePoint
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
# () -> InkPath
|
||||
# (InkPath) -> void
|
||||
var path_on_choice: InkPath:
|
||||
get:
|
||||
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
|
||||
|
||||
set(value):
|
||||
_path_on_choice = value
|
||||
|
||||
var _path_on_choice: InkPath = null
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var choice_target: InkContainer:
|
||||
get:
|
||||
var cont: InkContainer = resolve_path(self._path_on_choice).container
|
||||
return cont
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var path_string_on_choice: String:
|
||||
get:
|
||||
return compact_path_string(self.path_on_choice)
|
||||
|
||||
set(value):
|
||||
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 flags: int:
|
||||
get:
|
||||
var flags: int = 0
|
||||
|
||||
if has_condition:
|
||||
flags |= 1
|
||||
if has_start_content:
|
||||
flags |= 2
|
||||
if has_choice_only_content:
|
||||
flags |= 4
|
||||
if is_invisible_default:
|
||||
flags |= 8
|
||||
if once_only:
|
||||
flags |= 16
|
||||
|
||||
return flags
|
||||
|
||||
set(value):
|
||||
has_condition = (value & 1) > 0
|
||||
has_start_content = (value & 2) > 0
|
||||
has_choice_only_content = (value & 4) > 0
|
||||
is_invisible_default = (value & 8) > 0
|
||||
once_only = (value & 16) > 0
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
func _init(once_only: bool = true):
|
||||
self.once_only = once_only
|
||||
|
||||
|
||||
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 %d(%s)" % [target_line_num, target_string]
|
||||
|
||||
return "Choice: -> %s" % target_string
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "ChoicePoint" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "ChoicePoint"
|
333
addons/inkgd/runtime/content/ink_container.gd
Normal file
333
addons/inkgd/runtime/content/ink_container.gd
Normal file
|
@ -0,0 +1,333 @@
|
|||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkContainer
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
|
||||
var name = null # String?
|
||||
|
||||
|
||||
var content: Array: # Array<InkObject>
|
||||
get:
|
||||
return self._content
|
||||
set(value):
|
||||
add_content(value)
|
||||
|
||||
|
||||
var _content: Array # Array<InkObject>
|
||||
|
||||
|
||||
var named_content: Dictionary # Dictionary<string, INamedContent>
|
||||
|
||||
|
||||
var named_only_content: # Dictionary<string, InkObject>?
|
||||
get:
|
||||
var named_only_content_dict = {} # Dictionary<string, InkObject>?
|
||||
for key in self.named_content:
|
||||
named_only_content_dict[key] = self.named_content[key]
|
||||
|
||||
for c in self.content:
|
||||
var named = InkUtils.as_INamedContent_or_null(c)
|
||||
if named != null && named.has_valid_name:
|
||||
named_only_content_dict.erase(named.name)
|
||||
|
||||
if named_only_content_dict.size() == 0:
|
||||
named_only_content_dict = null
|
||||
|
||||
return named_only_content_dict
|
||||
|
||||
set(value):
|
||||
var existing_named_only = named_only_content
|
||||
if existing_named_only != null:
|
||||
for key in existing_named_only:
|
||||
self.named_content.erase(key)
|
||||
|
||||
if value == null:
|
||||
return
|
||||
|
||||
for key in value:
|
||||
var named = InkUtils.as_INamedContent_or_null(value[key])
|
||||
if named != null:
|
||||
add_to_named_content_only(named)
|
||||
|
||||
|
||||
var visits_should_be_counted: bool = false
|
||||
|
||||
|
||||
var turn_index_should_be_counted: bool = false
|
||||
|
||||
|
||||
var counting_at_start_only: bool = false
|
||||
|
||||
|
||||
enum CountFlags {
|
||||
VISITS = 1,
|
||||
TURNS = 2,
|
||||
COUNT_START_ONLY = 4
|
||||
}
|
||||
|
||||
|
||||
# CountFlags
|
||||
var count_flags: int:
|
||||
get:
|
||||
var flags = 0
|
||||
|
||||
if visits_should_be_counted: flags |= CountFlags.VISITS
|
||||
if turn_index_should_be_counted: flags |= CountFlags.TURNS
|
||||
if counting_at_start_only: flags |= CountFlags.COUNT_START_ONLY
|
||||
|
||||
if flags == CountFlags.COUNT_START_ONLY:
|
||||
flags = 0
|
||||
|
||||
return flags
|
||||
|
||||
set(value):
|
||||
var flag = value
|
||||
if (flag & CountFlags.VISITS) > 0: visits_should_be_counted = true
|
||||
if (flag & CountFlags.TURNS) > 0: turn_index_should_be_counted = true
|
||||
if (flag & CountFlags.COUNT_START_ONLY) > 0: counting_at_start_only = true
|
||||
|
||||
|
||||
var has_valid_name: bool:
|
||||
get: return self.name != null && self.name.length() > 0
|
||||
|
||||
var path_to_first_leaf_content: InkPath:
|
||||
get:
|
||||
if self._path_to_first_leaf_content == null:
|
||||
self._path_to_first_leaf_content = self.path.path_by_appending_path(self.internal_path_to_first_leaf_content)
|
||||
|
||||
return self._path_to_first_leaf_content
|
||||
|
||||
# InkPath?
|
||||
var _path_to_first_leaf_content: InkPath = null
|
||||
|
||||
|
||||
# TODO: Make inspectable
|
||||
var internal_path_to_first_leaf_content: InkPath:
|
||||
get:
|
||||
var components: Array = [] # Array<InkPath.InkComponent>
|
||||
var container: InkContainer = self
|
||||
while container != null:
|
||||
if container.content.size() > 0:
|
||||
components.append(InkPath.Component.new(0))
|
||||
container = InkUtils.as_or_null(container.content[0], "InkContainer")
|
||||
|
||||
return InkPath.new_with_components(components)
|
||||
|
||||
|
||||
func _init():
|
||||
self._content = [] # Array<InkObject>
|
||||
self.named_content = {} # Dictionary<string, INamedContent>
|
||||
|
||||
|
||||
func add_content(content_obj_or_content_list) -> void:
|
||||
if InkUtils.is_ink_class(content_obj_or_content_list, "InkObject"):
|
||||
var content_obj: InkObject = content_obj_or_content_list
|
||||
self.content.append(content_obj)
|
||||
|
||||
if content_obj.parent:
|
||||
InkUtils.throw_exception("content is already in %s" % content_obj.parent._to_string())
|
||||
return
|
||||
|
||||
content_obj.parent = self
|
||||
|
||||
try_add_named_content(content_obj)
|
||||
elif content_obj_or_content_list is Array:
|
||||
var content_list: Array = content_obj_or_content_list
|
||||
for c in content_list:
|
||||
add_content(c)
|
||||
|
||||
|
||||
func insert_content(content_obj: InkObject, index: int) -> void:
|
||||
self.content.insert(index, content_obj)
|
||||
|
||||
if content_obj.parent:
|
||||
InkUtils.throw_exception("content is already in %s" % content_obj.parent._to_string())
|
||||
return
|
||||
|
||||
content_obj.parent = self
|
||||
|
||||
try_add_named_content(content_obj)
|
||||
|
||||
|
||||
func try_add_named_content(content_obj: InkObject) -> void:
|
||||
var named_content_obj = InkUtils.as_INamedContent_or_null(content_obj)
|
||||
if (named_content_obj != null && named_content_obj.has_valid_name):
|
||||
add_to_named_content_only(named_content_obj)
|
||||
|
||||
|
||||
# (INamedContent) -> void
|
||||
func add_to_named_content_only(named_content_obj: InkObject) -> void:
|
||||
InkUtils.__assert__(named_content_obj.is_ink_class("InkObject"), "Can only add Runtime.Objects to a Runtime.Container")
|
||||
var runtime_obj = named_content_obj
|
||||
runtime_obj.parent = self
|
||||
|
||||
named_content[named_content_obj.name] = named_content_obj
|
||||
|
||||
|
||||
func add_contents_of_container(other_container: InkContainer) -> void:
|
||||
self.content = self.content + other_container.content
|
||||
for obj in other_container.content:
|
||||
obj.parent = self
|
||||
try_add_named_content(obj)
|
||||
|
||||
|
||||
func content_with_path_component(component: InkPath.Component) -> InkObject:
|
||||
if component.is_index:
|
||||
if component.index >= 0 && component.index < self.content.size():
|
||||
return self.content[component.index]
|
||||
else:
|
||||
return null
|
||||
elif component.is_parent:
|
||||
return self.parent
|
||||
else:
|
||||
if named_content.has(component.name):
|
||||
var found_content = named_content[component.name]
|
||||
return found_content
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
func content_at_path(
|
||||
path: InkPath,
|
||||
partial_path_start: int = 0,
|
||||
partial_path_length: int = -1
|
||||
) -> InkSearchResult:
|
||||
if partial_path_length == -1:
|
||||
partial_path_length = path.length
|
||||
|
||||
var result: InkSearchResult = InkSearchResult.new()
|
||||
result.approximate = false
|
||||
|
||||
var current_container: InkContainer = self
|
||||
var current_obj: InkObject = self
|
||||
|
||||
var i: int = partial_path_start
|
||||
while i < partial_path_length:
|
||||
var comp = path.get_component(i)
|
||||
|
||||
if current_container == null:
|
||||
result.approximate = true
|
||||
break
|
||||
|
||||
var found_obj: InkObject = current_container.content_with_path_component(comp)
|
||||
|
||||
if found_obj == null:
|
||||
result.approximate = true
|
||||
break
|
||||
|
||||
current_obj = found_obj
|
||||
current_container = InkUtils.as_or_null(found_obj, "InkContainer")
|
||||
|
||||
i += 1
|
||||
|
||||
result.obj = current_obj
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func build_string_of_hierarchy(
|
||||
existing_hierarchy: String,
|
||||
indentation: int,
|
||||
pointed_obj: InkObject
|
||||
) -> String:
|
||||
existing_hierarchy = _append_indentation(existing_hierarchy, indentation)
|
||||
existing_hierarchy += "["
|
||||
|
||||
if self.has_valid_name:
|
||||
existing_hierarchy += str(" (%s) " % self.name)
|
||||
|
||||
if self == pointed_obj:
|
||||
existing_hierarchy += " <---"
|
||||
|
||||
existing_hierarchy += "\n"
|
||||
|
||||
indentation += 1
|
||||
|
||||
var i = 0
|
||||
while i < self.content.size():
|
||||
var obj = self.content[i]
|
||||
|
||||
if InkUtils.is_ink_class(obj, "InkContainer"):
|
||||
existing_hierarchy = obj.build_string_of_hierarchy(existing_hierarchy, indentation, pointed_obj)
|
||||
else:
|
||||
existing_hierarchy = _append_indentation(existing_hierarchy, indentation)
|
||||
if InkUtils.is_ink_class(obj, "StringValue"):
|
||||
existing_hierarchy += "\""
|
||||
existing_hierarchy += obj._to_string().replace("\n", "\\n")
|
||||
existing_hierarchy += "\""
|
||||
else:
|
||||
existing_hierarchy += obj._to_string()
|
||||
|
||||
if i != self.content.size() - 1:
|
||||
existing_hierarchy += ","
|
||||
|
||||
if !InkUtils.is_ink_class(obj, "InkContainer") && obj == pointed_obj:
|
||||
existing_hierarchy += " <---"
|
||||
|
||||
existing_hierarchy += "\n"
|
||||
i += 1
|
||||
|
||||
var only_named: Dictionary = {} # Dictionary<String, INamedContent>
|
||||
|
||||
for obj_key in self.named_content:
|
||||
var value = self.named_content[obj_key]
|
||||
if self.content.find(value) != -1:
|
||||
continue
|
||||
else:
|
||||
only_named[obj_key] = value
|
||||
|
||||
if only_named.size() > 0:
|
||||
existing_hierarchy = _append_indentation(existing_hierarchy, indentation)
|
||||
existing_hierarchy += "-- named: --\n"
|
||||
|
||||
for object_key in only_named:
|
||||
var value = only_named[object_key]
|
||||
InkUtils.__assert__(InkUtils.is_ink_class(value, "InkContainer"), "Can only print out named Containers")
|
||||
var container = value
|
||||
existing_hierarchy = container.build_string_of_hierarchy(existing_hierarchy, indentation, pointed_obj)
|
||||
existing_hierarchy += "\n"
|
||||
|
||||
indentation -= 1
|
||||
|
||||
existing_hierarchy = _append_indentation(existing_hierarchy, indentation)
|
||||
existing_hierarchy += "]"
|
||||
|
||||
return existing_hierarchy
|
||||
|
||||
|
||||
func build_full_string_of_hierarchy() -> String:
|
||||
return build_string_of_hierarchy("", 0, null)
|
||||
|
||||
|
||||
func _append_indentation(string: String, indentation: int) -> String:
|
||||
var spaces_per_indent = 4
|
||||
var i = 0
|
||||
while(i < spaces_per_indent * indentation):
|
||||
string += " "
|
||||
i += 1
|
||||
|
||||
return string
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "InkContainer" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "InkContainer"
|
213
addons/inkgd/runtime/content/ink_control_command.gd
Normal file
213
addons/inkgd/runtime/content/ink_control_command.gd
Normal file
|
@ -0,0 +1,213 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkControlCommand
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
enum CommandType {
|
||||
NOT_SET = -1,
|
||||
EVAL_START,
|
||||
EVAL_OUTPUT,
|
||||
EVAL_END,
|
||||
DUPLICATE,
|
||||
POP_EVALUATED_VALUE,
|
||||
POP_FUNCTION,
|
||||
POP_TUNNEL,
|
||||
BEGIN_STRING,
|
||||
END_STRING,
|
||||
NO_OP,
|
||||
CHOICE_COUNT,
|
||||
TURNS,
|
||||
TURNS_SINCE,
|
||||
READ_COUNT,
|
||||
RANDOM,
|
||||
SEED_RANDOM,
|
||||
VISIT_INDEX,
|
||||
SEQUENCE_SHUFFLE_INDEX,
|
||||
START_THREAD,
|
||||
DONE,
|
||||
END,
|
||||
LIST_FROM_INT,
|
||||
LIST_RANGE,
|
||||
LIST_RANDOM,
|
||||
BEGIN_TAG,
|
||||
END_TAG,
|
||||
#----
|
||||
TOTAL_VALUES
|
||||
}
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
# CommandType
|
||||
var command_type: int
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init(command_type: int = CommandType.NOT_SET):
|
||||
self.command_type = command_type
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
func copy() -> InkControlCommand:
|
||||
return InkControlCommand.new(self.command_type)
|
||||
|
||||
static func eval_start() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.EVAL_START)
|
||||
|
||||
|
||||
static func eval_output() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.EVAL_OUTPUT)
|
||||
|
||||
|
||||
static func eval_end() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.EVAL_END)
|
||||
|
||||
|
||||
static func duplicate() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.DUPLICATE)
|
||||
|
||||
|
||||
static func pop_evaluated_value() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.POP_EVALUATED_VALUE)
|
||||
|
||||
|
||||
static func pop_function() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.POP_FUNCTION)
|
||||
|
||||
|
||||
static func pop_tunnel() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.POP_TUNNEL)
|
||||
|
||||
|
||||
static func begin_string() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.BEGIN_STRING)
|
||||
|
||||
|
||||
static func end_string() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.END_STRING)
|
||||
|
||||
|
||||
static func no_op() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.NO_OP)
|
||||
|
||||
|
||||
static func choice_count() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.CHOICE_COUNT)
|
||||
|
||||
|
||||
static func turns() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.TURNS)
|
||||
|
||||
|
||||
static func turns_since() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.TURNS_SINCE)
|
||||
|
||||
|
||||
static func read_count() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.READ_COUNT)
|
||||
|
||||
|
||||
static func random() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.RANDOM)
|
||||
|
||||
|
||||
static func seed_random() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.SEED_RANDOM)
|
||||
|
||||
|
||||
static func visit_index() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.VISIT_INDEX)
|
||||
|
||||
|
||||
static func sequence_shuffle_index() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.SEQUENCE_SHUFFLE_INDEX)
|
||||
|
||||
|
||||
static func done() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.DONE)
|
||||
|
||||
|
||||
static func end() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.END)
|
||||
|
||||
|
||||
static func list_from_int() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.LIST_FROM_INT)
|
||||
|
||||
|
||||
static func list_range() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.LIST_RANGE)
|
||||
|
||||
|
||||
static func list_random() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.LIST_RANDOM)
|
||||
|
||||
|
||||
static func begin_tag() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.BEGIN_TAG)
|
||||
|
||||
|
||||
static func end_tag() -> InkControlCommand:
|
||||
return InkControlCommand.new(CommandType.END_TAG)
|
||||
|
||||
|
||||
# () -> String
|
||||
func _to_string() -> String:
|
||||
var command_name: String = ""
|
||||
match self.command_type:
|
||||
CommandType.NOT_SET: command_name = "NOT_SET"
|
||||
CommandType.EVAL_START: command_name = "EVAL_START"
|
||||
CommandType.EVAL_OUTPUT: command_name = "EVAL_OUTPUT"
|
||||
CommandType.EVAL_END: command_name = "EVAL_END"
|
||||
CommandType.DUPLICATE: command_name = "DUPLICATE"
|
||||
CommandType.POP_EVALUATED_VALUE: command_name = "POP_EVALUATED_VALUE"
|
||||
CommandType.POP_FUNCTION: command_name = "POP_FUNCTION"
|
||||
CommandType.POP_TUNNEL: command_name = "POP_TUNNEL"
|
||||
CommandType.BEGIN_STRING: command_name = "BEGIN_STRING"
|
||||
CommandType.END_STRING: command_name = "END_STRING"
|
||||
CommandType.NO_OP: command_name = "NO_OP"
|
||||
CommandType.CHOICE_COUNT: command_name = "CHOICE_COUNT"
|
||||
CommandType.TURNS: command_name = "TURNS"
|
||||
CommandType.TURNS_SINCE: command_name = "TURNS_SINCE"
|
||||
CommandType.READ_COUNT: command_name = "READ_COUNT"
|
||||
CommandType.RANDOM: command_name = "RANDOM"
|
||||
CommandType.SEED_RANDOM: command_name = "SEED_RANDOM"
|
||||
CommandType.VISIT_INDEX: command_name = "VISIT_INDEX"
|
||||
CommandType.SEQUENCE_SHUFFLE_INDEX: command_name = "SEQUENCE_SHUFFLE_INDEX"
|
||||
CommandType.START_THREAD: command_name = "START_THREAD"
|
||||
CommandType.DONE: command_name = "DONE"
|
||||
CommandType.END: command_name = "END"
|
||||
CommandType.LIST_FROM_INT: command_name = "LIST_FROM_INT"
|
||||
CommandType.LIST_RANGE: command_name = "LIST_RANGE"
|
||||
CommandType.LIST_RANDOM: command_name = "LIST_RANDOM"
|
||||
CommandType.BEGIN_TAG: command_name = "BEGIN_TAG"
|
||||
CommandType.END_TAG: command_name = "END_TAG"
|
||||
CommandType.TOTAL_VALUES: command_name = "TOTAL_VALUES"
|
||||
|
||||
return "Command(%s)" % command_name
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "ControlCommand" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "ControlCommand"
|
145
addons/inkgd/runtime/content/ink_divert.gd
Normal file
145
addons/inkgd/runtime/content/ink_divert.gd
Normal file
|
@ -0,0 +1,145 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkDivert
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var target_path: InkPath:
|
||||
get:
|
||||
if self._target_path != null && self._target_path.is_relative:
|
||||
var target_obj: InkObject = self.target_pointer.resolve()
|
||||
if target_obj:
|
||||
self._target_path = target_obj.path
|
||||
|
||||
return self._target_path
|
||||
|
||||
set(value):
|
||||
self._target_path = value
|
||||
self._target_pointer = InkPointer.null_pointer
|
||||
|
||||
var _target_path: InkPath = null
|
||||
|
||||
|
||||
var target_pointer: InkPointer:
|
||||
get:
|
||||
if self._target_pointer.is_null:
|
||||
var target_obj = resolve_path(self._target_path).obj
|
||||
|
||||
if self._target_path.last_component.is_index:
|
||||
self._target_pointer = InkPointer.new(
|
||||
InkUtils.as_or_null(target_obj.parent, "InkContainer"),
|
||||
self._target_path.last_component.index
|
||||
)
|
||||
else:
|
||||
self._target_pointer = InkPointer.start_of(InkUtils.as_or_null(target_obj, "InkContainer"))
|
||||
|
||||
return self._target_pointer
|
||||
|
||||
var _target_pointer: InkPointer = InkPointer.null_pointer
|
||||
|
||||
|
||||
var target_path_string: # String?
|
||||
get:
|
||||
if self.target_path == null:
|
||||
return null
|
||||
|
||||
return self.compact_path_string(self.target_path)
|
||||
|
||||
set(value):
|
||||
if value == null:
|
||||
self.target_path = null
|
||||
else:
|
||||
self.target_path = InkPath.new_with_components_string(value)
|
||||
|
||||
|
||||
var variable_divert_name = null # String?
|
||||
var has_variable_target: bool:
|
||||
get: return self.variable_divert_name != null
|
||||
|
||||
|
||||
var pushes_to_stack: bool = false
|
||||
|
||||
var stack_push_type: int = 0 # Ink.PushPopType
|
||||
|
||||
var is_external: bool = false
|
||||
|
||||
var external_args: int = 0
|
||||
|
||||
var is_conditional: bool = false
|
||||
|
||||
|
||||
# (int?) -> InkDivert
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init_with(stack_push_type = null):
|
||||
self.pushes_to_stack = false
|
||||
|
||||
if stack_push_type != null:
|
||||
self.pushes_to_stack = true
|
||||
self.stack_push_type = stack_push_type
|
||||
|
||||
|
||||
func equals(obj: InkBase) -> bool:
|
||||
var other_divert: InkDivert = InkUtils.as_or_null(obj, "Divert")
|
||||
if other_divert:
|
||||
if self.has_variable_target == other_divert.has_variable_target:
|
||||
if self.has_variable_target:
|
||||
return self.variable_divert_name == other_divert.variable_divert_name
|
||||
else:
|
||||
return self.target_path.equals(other_divert.target_path)
|
||||
|
||||
return false
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
if self.has_variable_target:
|
||||
return "Divert(variable: %s)" % self.variable_divert_name
|
||||
elif self.target_path == null:
|
||||
return "Divert(null)"
|
||||
else:
|
||||
var _string = ""
|
||||
|
||||
var target_str: String = self.target_path._to_string()
|
||||
var target_line_num = debug_line_number_of_path(self.target_path)
|
||||
if target_line_num != null:
|
||||
target_str = "line " + target_line_num
|
||||
|
||||
_string += "Divert"
|
||||
|
||||
if self.is_conditional:
|
||||
_string += "?"
|
||||
|
||||
if self.pushes_to_stack:
|
||||
if self.stack_push_type == Ink.PushPopType.FUNCTION:
|
||||
_string += " function"
|
||||
else:
|
||||
_string += " tunnel"
|
||||
|
||||
_string += " -> "
|
||||
_string += self.target_path_string
|
||||
|
||||
_string += " (%s)" % target_str
|
||||
|
||||
return _string
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "Divert" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "Divert"
|
29
addons/inkgd/runtime/content/ink_glue.gd
Normal file
29
addons/inkgd/runtime/content/ink_glue.gd
Normal file
|
@ -0,0 +1,29 @@
|
|||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkGlue
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
func _to_string() -> String:
|
||||
return "Glue"
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "Glue" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "Glue"
|
372
addons/inkgd/runtime/content/ink_native_function_call.gd
Normal file
372
addons/inkgd/runtime/content/ink_native_function_call.gd
Normal file
|
@ -0,0 +1,372 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkNativeFunctionCall
|
||||
|
||||
# ############################################################################ #
|
||||
# Imports
|
||||
# ############################################################################ #
|
||||
|
||||
# TODO: Migrate to Ink.ValueType
|
||||
const ValueType = preload("res://addons/inkgd/runtime/values/value_type.gd").ValueType
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
# (String) -> NativeFunctionCall
|
||||
@warning_ignore("shadowed_variable")
|
||||
static func call_with_name(
|
||||
function_name: String,
|
||||
_static_native_function_call: InkStaticNativeFunctionCall = null
|
||||
) -> InkNativeFunctionCall:
|
||||
return InkNativeFunctionCall.new_with_name(function_name, _static_native_function_call)
|
||||
|
||||
|
||||
var name: String:
|
||||
get:
|
||||
return _name
|
||||
|
||||
set(value):
|
||||
_name = value
|
||||
if !_is_prototype:
|
||||
_prototype = self._static_native_function_call.native_functions[_name]
|
||||
|
||||
var _name: String
|
||||
|
||||
|
||||
var number_of_parameters: int:
|
||||
get:
|
||||
if _prototype:
|
||||
return _prototype.number_of_parameters
|
||||
else:
|
||||
return _number_of_parameters
|
||||
|
||||
set(value):
|
||||
_number_of_parameters = value
|
||||
|
||||
var _number_of_parameters: int = 0
|
||||
|
||||
|
||||
# (Array<InkObject>) -> InkObject
|
||||
#
|
||||
# The name is different to avoid shadowing 'Object.call'
|
||||
#
|
||||
# The method takes a `StoryErrorMetadata` object as a parameter that
|
||||
# doesn't exist in upstream. The metadat are used in case an 'exception'
|
||||
# is raised. For more information, see story.gd.
|
||||
func call_with_parameters(parameters: Array, metadata: StoryErrorMetadata) -> InkObject:
|
||||
if _prototype:
|
||||
return _prototype.call_with_parameters(parameters, metadata)
|
||||
|
||||
if self.number_of_parameters != parameters.size():
|
||||
InkUtils.throw_exception("Unexpected number of parameters")
|
||||
return null
|
||||
|
||||
var has_list = false
|
||||
for p in parameters:
|
||||
if InkUtils.is_ink_class(p, "Void"):
|
||||
InkUtils.throw_story_exception(
|
||||
"Attempting to perform operation on a void value. Did you forget to " +
|
||||
"'return' a value from a function you called here?",
|
||||
false,
|
||||
metadata
|
||||
)
|
||||
return null
|
||||
if InkUtils.is_ink_class(p, "ListValue"):
|
||||
has_list = true
|
||||
|
||||
if parameters.size() == 2 && has_list:
|
||||
return call_binary_list_operation(parameters, metadata)
|
||||
|
||||
var coerced_params: Array = coerce_values_to_single_type(parameters, metadata)
|
||||
|
||||
# ValueType
|
||||
var coerced_type: int = coerced_params[0].value_type
|
||||
|
||||
if (
|
||||
coerced_type == ValueType.INT ||
|
||||
coerced_type == ValueType.FLOAT ||
|
||||
coerced_type == ValueType.STRING ||
|
||||
coerced_type == ValueType.DIVERT_TARGET ||
|
||||
coerced_type == ValueType.LIST
|
||||
):
|
||||
return call_coerced(coerced_params, metadata)
|
||||
|
||||
return null
|
||||
|
||||
|
||||
# (Array<Value>) -> Value # Call<T> in the original code
|
||||
#
|
||||
# The method takes a `StoryErrorMetadata` object as a parameter that
|
||||
# doesn't exist in upstream. The metadat are used in case an 'exception'
|
||||
# is raised. For more information, see story.gd.
|
||||
func call_coerced(parameters_of_single_type: Array, metadata: StoryErrorMetadata) -> InkValue:
|
||||
var param1: InkValue = parameters_of_single_type[0]
|
||||
var val_type: int = param1.value_type
|
||||
|
||||
var param_count: int = parameters_of_single_type.size()
|
||||
|
||||
if param_count == 2 || param_count == 1:
|
||||
var op_for_type = null
|
||||
if _operation_funcs.has(val_type):
|
||||
op_for_type = _operation_funcs[val_type]
|
||||
else:
|
||||
var type_name = InkUtils.value_type_name(val_type)
|
||||
InkUtils.throw_story_exception(
|
||||
"Cannot perform operation '%s' on value of type (%d)" \
|
||||
% [self.name, type_name],
|
||||
false,
|
||||
metadata
|
||||
)
|
||||
return null
|
||||
|
||||
if param_count == 2:
|
||||
var param2 = parameters_of_single_type[1]
|
||||
|
||||
var result_val = self._static_native_function_call.call(op_for_type, param1.value, param2.value)
|
||||
|
||||
return InkValue.create(result_val)
|
||||
else:
|
||||
var result_val = self._static_native_function_call.call(op_for_type, param1.value)
|
||||
|
||||
return InkValue.create(result_val)
|
||||
else:
|
||||
InkUtils.throw_exception(
|
||||
"Unexpected number of parameters to NativeFunctionCall: %d" % \
|
||||
parameters_of_single_type.size()
|
||||
)
|
||||
return null
|
||||
|
||||
|
||||
# (Array<InkObject>) -> Value
|
||||
#
|
||||
# The method takes a `StoryErrorMetadata` object as a parameter that
|
||||
# doesn't exist in upstream. The metadat are used in case an 'exception'
|
||||
# is raised. For more information, see story.gd.
|
||||
func call_binary_list_operation(parameters: Array, metadata: StoryErrorMetadata) -> InkValue:
|
||||
if ((self.name == "+" || self.name == "-") &&
|
||||
InkUtils.is_ink_class(parameters[0], "ListValue") &&
|
||||
InkUtils.is_ink_class(parameters [1], "IntValue")
|
||||
):
|
||||
return call_list_increment_operation(parameters)
|
||||
|
||||
var v1 = InkUtils.as_or_null(parameters[0], "Value")
|
||||
var v2 = InkUtils.as_or_null(parameters[1], "Value")
|
||||
|
||||
if ((self.name == "&&" || self.name == "||") &&
|
||||
(v1.value_type != ValueType.LIST || v2.value_type != ValueType.LIST)
|
||||
):
|
||||
var op: String = _operation_funcs[ValueType.INT]
|
||||
var result = bool(self._static_native_function_call.call(
|
||||
"op_for_type",
|
||||
1 if v1.is_truthy else 0,
|
||||
1 if v2.is_truthy else 0
|
||||
))
|
||||
|
||||
return InkBoolValue.new_with(result)
|
||||
|
||||
if v1.value_type == ValueType.LIST && v2.value_type == ValueType.LIST:
|
||||
return call_coerced([v1, v2], metadata)
|
||||
|
||||
var v1_type_name = InkUtils.value_type_name(v1.value_type)
|
||||
var v2_type_name = InkUtils.value_type_name(v2.value_type)
|
||||
InkUtils.throw_story_exception(
|
||||
"Can not call use '%s' operation on %s and %s" % \
|
||||
[self.name, v1_type_name, v2_type_name],
|
||||
false,
|
||||
metadata
|
||||
)
|
||||
|
||||
return null
|
||||
|
||||
|
||||
# (Array<InkObject>) -> Value
|
||||
func call_list_increment_operation(list_int_params: Array) -> InkValue:
|
||||
var list_val: InkListValue = InkUtils.cast(list_int_params[0], "ListValue")
|
||||
var int_val: InkIntValue = InkUtils.cast(list_int_params [1], "IntValue")
|
||||
|
||||
var result_raw_list = InkList.new()
|
||||
|
||||
for list_item in list_val.value.keys(): # TODO: Optimize?
|
||||
var list_item_value = list_val.value.get_item(list_item)
|
||||
|
||||
var int_op: String = _operation_funcs[ValueType.INT]
|
||||
|
||||
var target_int = int(
|
||||
self._static_native_function_call.call(
|
||||
int_op,
|
||||
list_item_value,
|
||||
int_val.value
|
||||
)
|
||||
)
|
||||
|
||||
var item_origin: InkListDefinition = null
|
||||
for origin in list_val.value.origins:
|
||||
if origin.name == list_item.origin_name:
|
||||
item_origin = origin
|
||||
break
|
||||
|
||||
if item_origin != null:
|
||||
var incremented_item: InkTryGetResult = item_origin.try_get_item_with_value(target_int)
|
||||
if incremented_item.exists:
|
||||
result_raw_list.set_item(incremented_item.result, target_int)
|
||||
|
||||
return InkListValue.new_with(result_raw_list)
|
||||
|
||||
|
||||
# (Array<InkObject>) -> Array<Value>?
|
||||
#
|
||||
# The method takes a `StoryErrorMetadata` object as a parameter that
|
||||
# doesn't exist in upstream. The metadata are used in case an 'exception'
|
||||
# is raised. For more information, see story.gd.
|
||||
func coerce_values_to_single_type(parameters_in: Array, metadata: StoryErrorMetadata):
|
||||
var val_type: int = ValueType.INT
|
||||
|
||||
var special_case_list: InkListValue = null
|
||||
|
||||
for obj in parameters_in:
|
||||
var val: InkValue = obj
|
||||
if val.value_type > val_type:
|
||||
val_type = val.value_type
|
||||
|
||||
if val.value_type == ValueType.LIST:
|
||||
special_case_list = InkUtils.as_or_null(val, "ListValue")
|
||||
|
||||
var parameters_out: Array = [] # Array<Value>
|
||||
|
||||
if val_type == ValueType.LIST:
|
||||
for val in parameters_in:
|
||||
if val.value_type == ValueType.LIST:
|
||||
parameters_out.append(val)
|
||||
elif val.value_type == ValueType.INT:
|
||||
var int_val = int(val.value_object)
|
||||
var list = special_case_list.value.origin_of_max_item
|
||||
|
||||
var item: InkTryGetResult = list.try_get_item_with_value(int_val)
|
||||
if item.exists:
|
||||
var casted_value = InkListValue.new_with_single_item(item.result, int_val)
|
||||
parameters_out.append(casted_value)
|
||||
else:
|
||||
InkUtils.throw_story_exception(
|
||||
"Could not find List item with the value %d in %s" \
|
||||
% [int_val, list.name],
|
||||
false,
|
||||
metadata
|
||||
)
|
||||
|
||||
return null
|
||||
else:
|
||||
var type_name = InkUtils.value_type_name(val.value_type)
|
||||
InkUtils.throw_story_exception(
|
||||
"Cannot mix Lists and %s values in this operation" % type_name,
|
||||
false,
|
||||
metadata
|
||||
)
|
||||
|
||||
return null
|
||||
|
||||
else:
|
||||
for val in parameters_in:
|
||||
var casted_value = val.cast(val_type)
|
||||
parameters_out.append(casted_value)
|
||||
|
||||
return parameters_out
|
||||
|
||||
|
||||
func _init(static_native_function_call: InkStaticNativeFunctionCall = null):
|
||||
generate_native_functions_if_necessary(static_native_function_call)
|
||||
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init_with_name(name: String):
|
||||
self.name = name
|
||||
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init_with_name_and_number_of_parameters(name: String, number_of_parameters: int):
|
||||
_is_prototype = true
|
||||
self.name = name
|
||||
self.number_of_parameters = number_of_parameters
|
||||
|
||||
|
||||
func generate_native_functions_if_necessary(static_native_function_call: InkStaticNativeFunctionCall) -> void:
|
||||
find_static_objects(static_native_function_call)
|
||||
self._static_native_function_call.generate_native_functions_if_necessary()
|
||||
|
||||
|
||||
func add_op_func_for_type(val_type: int, op: String) -> void:
|
||||
if _operation_funcs == null:
|
||||
_operation_funcs = {}
|
||||
|
||||
_operation_funcs[val_type] = op
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return "Native '%s'" % self.name
|
||||
|
||||
|
||||
var _prototype: InkNativeFunctionCall = null
|
||||
|
||||
var _is_prototype: bool = false
|
||||
|
||||
# Dictionary<ValueType, String>
|
||||
var _operation_funcs: Dictionary = {}
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type):
|
||||
return type == "NativeFunctionCall" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class():
|
||||
return "NativeFunctionCall"
|
||||
|
||||
|
||||
var _static_native_function_call: InkStaticNativeFunctionCall:
|
||||
get: return _weak_static_native_function_call.get_ref()
|
||||
|
||||
var _weak_static_native_function_call = WeakRef.new()
|
||||
|
||||
|
||||
func find_static_objects(static_native_function_call: InkStaticNativeFunctionCall = null):
|
||||
if _static_native_function_call == null:
|
||||
if static_native_function_call:
|
||||
_weak_static_native_function_call = weakref(static_native_function_call)
|
||||
else:
|
||||
var ink_runtime = Engine.get_main_loop().root.get_node("__InkRuntime")
|
||||
_weak_static_native_function_call = weakref(ink_runtime.native_function_call)
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
static func new_with_name(
|
||||
name: String,
|
||||
static_native_function_call: InkStaticNativeFunctionCall = null
|
||||
):
|
||||
var native_function_call = InkNativeFunctionCall.new(static_native_function_call)
|
||||
native_function_call._init_with_name(name)
|
||||
return native_function_call
|
||||
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
static func new_with_name_and_number_of_parameters(
|
||||
name: String,
|
||||
number_of_parameters: int,
|
||||
static_native_function_call: InkStaticNativeFunctionCall = null
|
||||
):
|
||||
var native_function_call = InkNativeFunctionCall.new(static_native_function_call)
|
||||
native_function_call._init_with_name_and_number_of_parameters(name, number_of_parameters)
|
||||
return native_function_call
|
36
addons/inkgd/runtime/content/ink_tag.gd
Normal file
36
addons/inkgd/runtime/content/ink_tag.gd
Normal file
|
@ -0,0 +1,36 @@
|
|||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkTag
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var text: String
|
||||
|
||||
|
||||
func _init(tag_text: String):
|
||||
text = tag_text
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return '# ' + text
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "Tag" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "Tag"
|
60
addons/inkgd/runtime/content/ink_variable_assignment.gd
Normal file
60
addons/inkgd/runtime/content/ink_variable_assignment.gd
Normal file
|
@ -0,0 +1,60 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkVariableAssignment
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var variable_name = null # String?
|
||||
|
||||
var is_new_declaration: bool = false
|
||||
|
||||
var is_global: bool = false
|
||||
|
||||
|
||||
func _init():
|
||||
_init_with(null, false)
|
||||
|
||||
|
||||
# (String?, bool) -> InkVariableAssignment
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init_with(variable_name, is_new_declaration: bool):
|
||||
self.variable_name = variable_name
|
||||
self.is_new_declaration = is_new_declaration
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return "VarAssign to %s" % variable_name
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "VariableAssignment" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "VariableAssignment"
|
||||
|
||||
|
||||
# (String?, bool) -> InkVariableAssignment
|
||||
@warning_ignore("shadowed_variable")
|
||||
static func new_with(
|
||||
variable_name: String,
|
||||
is_new_declaration: bool
|
||||
) -> InkVariableAssignment:
|
||||
var variable_assignment = InkVariableAssignment.new()
|
||||
variable_assignment._init_with(variable_name, is_new_declaration)
|
||||
return variable_assignment
|
69
addons/inkgd/runtime/content/ink_variable_reference.gd
Normal file
69
addons/inkgd/runtime/content/ink_variable_reference.gd
Normal file
|
@ -0,0 +1,69 @@
|
|||
# warning-ignore-all:shadowed_variable
|
||||
# warning-ignore-all:unused_class_variable
|
||||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkVariableReference
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
var name = null # String?
|
||||
|
||||
# InkPath
|
||||
var path_for_count: InkPath = null
|
||||
|
||||
# Container?
|
||||
var container_for_count: InkContainer:
|
||||
get: return self.resolve_path(path_for_count).container
|
||||
|
||||
# String?
|
||||
var path_string_for_count:
|
||||
get:
|
||||
if path_for_count == null:
|
||||
return null
|
||||
|
||||
return compact_path_string(path_for_count)
|
||||
|
||||
set(value):
|
||||
if value == null:
|
||||
path_for_count = null
|
||||
else:
|
||||
path_for_count = InkPath.new_with_components_string(value)
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
@warning_ignore("shadowed_variable")
|
||||
func _init(name = null):
|
||||
if name:
|
||||
self.name = name
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
|
||||
func _to_string() -> String:
|
||||
if name != null:
|
||||
return "var(%s)" % name
|
||||
else:
|
||||
var path_str = self.path_string_for_count
|
||||
return "read_count(%s)" % path_str
|
||||
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "VariableReference" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "VariableReference"
|
27
addons/inkgd/runtime/content/ink_void.gd
Normal file
27
addons/inkgd/runtime/content/ink_void.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
# ############################################################################ #
|
||||
# Copyright © 2015-2021 inkle Ltd.
|
||||
# Copyright © 2019-2022 Frédéric Maquin <fred@ephread.com>
|
||||
# All Rights Reserved
|
||||
#
|
||||
# This file is part of inkgd.
|
||||
# inkgd is licensed under the terms of the MIT license.
|
||||
# ############################################################################ #
|
||||
|
||||
extends InkObject
|
||||
|
||||
class_name InkVoid
|
||||
|
||||
# ############################################################################ #
|
||||
# GDScript extra methods
|
||||
# ############################################################################ #
|
||||
|
||||
func is_ink_class(type: String) -> bool:
|
||||
return type == "Void" || super.is_ink_class(type)
|
||||
|
||||
|
||||
func get_ink_class() -> String:
|
||||
return "Void"
|
||||
|
||||
|
||||
func _to_string() -> String:
|
||||
return "Void"
|
Loading…
Add table
Add a link
Reference in a new issue