|
|
|
@ -19,14 +19,14 @@ var max_lines: float = 0
|
|
|
|
set(value):
|
|
|
|
set(value):
|
|
|
|
progress = value
|
|
|
|
progress = value
|
|
|
|
if is_node_ready() and not all_text_revealed:
|
|
|
|
if is_node_ready() and not all_text_revealed:
|
|
|
|
var start_index = 0
|
|
|
|
var start_index := 0
|
|
|
|
if progress >= substring_sizes.size() or progress < 0:
|
|
|
|
if progress >= substring_sizes.size() or progress < 0:
|
|
|
|
label.visible_ratio = 1
|
|
|
|
label.visible_ratio = 1
|
|
|
|
elif progress > 0:
|
|
|
|
elif progress > 0:
|
|
|
|
for i in range(min(progress, substring_sizes.size()-1) as int) if progress > 0 else range(substring_sizes.size()-1):
|
|
|
|
for i in range(min(progress, substring_sizes.size()-1) as int) if progress > 0 else range(substring_sizes.size()-1):
|
|
|
|
start_index += substring_sizes[i]
|
|
|
|
start_index += substring_sizes[i]
|
|
|
|
|
|
|
|
|
|
|
|
label.visible_characters = start_index + substring_sizes[min(progress as int, substring_sizes.size()-1)] * fmod(progress, 1)
|
|
|
|
label.visible_characters = start_index + int(substring_sizes[min(progress as int, substring_sizes.size()-1)] * fmod(progress, 1))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
label.visible_ratio = 0
|
|
|
|
label.visible_ratio = 0
|
|
|
|
|
|
|
|
|
|
|
|
@ -94,14 +94,14 @@ func _rebuild():
|
|
|
|
max_lines = float(label.get_line_count())
|
|
|
|
max_lines = float(label.get_line_count())
|
|
|
|
|
|
|
|
|
|
|
|
func try_scroll():
|
|
|
|
func try_scroll():
|
|
|
|
var forward_target: int
|
|
|
|
var forward_target: float
|
|
|
|
|
|
|
|
|
|
|
|
#print_debug( "max lines: " + str(max_lines))
|
|
|
|
#print( "max lines: " + str(max_lines))
|
|
|
|
#print_debug( "current lines: " + str(label.get_character_line(label.visible_characters)))
|
|
|
|
#print( "current lines: " + str(label.get_character_line(label.visible_characters)))
|
|
|
|
|
|
|
|
|
|
|
|
var visible_ratio: float = float(label.get_character_line(label.visible_characters)) / max_lines
|
|
|
|
var visible_ratio: float = float(label.get_character_line(label.visible_characters)) / max_lines
|
|
|
|
|
|
|
|
|
|
|
|
#print_debug("Tried scrolling with ratio of %f. Comparing %f against %f" % [visible_ratio, label.size.y * visible_ratio - scroll_container.scroll_vertical, scroll_container.size.y * 0.9])
|
|
|
|
#print("Tried scrolling with ratio of %f. Comparing %f against %f" % [visible_ratio, label.size.y * visible_ratio - scroll_container.scroll_vertical, scroll_container.size.y * 0.9])
|
|
|
|
|
|
|
|
|
|
|
|
if label.size.y * visible_ratio + scroll_container.scroll_vertical > scroll_container.size.y * 0.9:
|
|
|
|
if label.size.y * visible_ratio + scroll_container.scroll_vertical > scroll_container.size.y * 0.9:
|
|
|
|
if scroll_container.scroll_vertical + scroll_container.size.y * 0.9 < label.size.y:
|
|
|
|
if scroll_container.scroll_vertical + scroll_container.size.y * 0.9 < label.size.y:
|
|
|
|
@ -109,7 +109,7 @@ func try_scroll():
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
forward_target = label.size.y - scroll_container.size.y
|
|
|
|
forward_target = label.size.y - scroll_container.size.y
|
|
|
|
if scroll_target != null:
|
|
|
|
if scroll_target != null:
|
|
|
|
var tween: Tween = get_tree().create_tween()
|
|
|
|
#var tween: Tween = get_tree().create_tween()
|
|
|
|
##tween.set_trans()
|
|
|
|
##tween.set_trans()
|
|
|
|
scroll_target = forward_target
|
|
|
|
scroll_target = forward_target
|
|
|
|
|
|
|
|
|
|
|
|
@ -150,18 +150,18 @@ func play_scene():
|
|
|
|
finished.emit()
|
|
|
|
finished.emit()
|
|
|
|
|
|
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
var just_revealed_text = false
|
|
|
|
var just_revealed_text := false
|
|
|
|
if event is InputEventMouseButton:
|
|
|
|
if event is InputEventMouseButton:
|
|
|
|
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
|
|
|
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
|
|
|
scroll_target += 40
|
|
|
|
scroll_target += 40
|
|
|
|
if not all_text_revealed: just_revealed_text
|
|
|
|
if not all_text_revealed:
|
|
|
|
all_text_revealed = true
|
|
|
|
just_revealed_text = true
|
|
|
|
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
|
|
|
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
|
|
|
scroll_target -= 40
|
|
|
|
scroll_target -= 40
|
|
|
|
if not all_text_revealed: just_revealed_text
|
|
|
|
if not all_text_revealed:
|
|
|
|
all_text_revealed = true
|
|
|
|
just_revealed_text = true
|
|
|
|
if just_revealed_text:
|
|
|
|
if just_revealed_text and animation_complete:
|
|
|
|
if animation_complete: all_text_revealed = true
|
|
|
|
all_text_revealed = true
|
|
|
|
|
|
|
|
|
|
|
|
var scroll_target: float = 0:
|
|
|
|
var scroll_target: float = 0:
|
|
|
|
set(value):
|
|
|
|
set(value):
|
|
|
|
@ -170,7 +170,7 @@ func _process(delta: float) -> void:
|
|
|
|
# FIXME: maybe change this to has stage?
|
|
|
|
# FIXME: maybe change this to has stage?
|
|
|
|
if visible and not Engine.is_editor_hint():
|
|
|
|
if visible and not Engine.is_editor_hint():
|
|
|
|
if scroll_container.scroll_vertical != scroll_target:
|
|
|
|
if scroll_container.scroll_vertical != scroll_target:
|
|
|
|
scroll_container.scroll_vertical += (scroll_target-scroll_container.scroll_vertical)*delta*6
|
|
|
|
scroll_container.scroll_vertical += int((scroll_target-scroll_container.scroll_vertical)*delta*6)
|
|
|
|
|
|
|
|
|
|
|
|
var intro_triggered:= false
|
|
|
|
var intro_triggered:= false
|
|
|
|
func trigger_intro():
|
|
|
|
func trigger_intro():
|
|
|
|
|