106 lines
2.3 KiB
GDScript
106 lines
2.3 KiB
GDScript
extends Node
|
|
|
|
# types of fades?
|
|
|
|
class Fade:
|
|
func _init():
|
|
pass
|
|
|
|
const Data = preload("res://data.gd")
|
|
|
|
# pull them into Game too
|
|
const DEFAULT_CHARS_PER_SECOND = Data.DEFAULT_CHARS_PER_SECOND
|
|
const Characters = Data.Characters
|
|
const Images = Data.Images
|
|
const Scenes = Data.Scenes
|
|
const Themes = Data.Themes
|
|
|
|
# generic game config globals
|
|
var game_started = false setget _on_game_started_set
|
|
var reading_speed = 1.0 setget _on_set_reading_speed
|
|
var master_vol = 50 setget _on_set_master_vol
|
|
var music_vol = 50 setget _on_set_music_vol
|
|
var sfx_vol = 50 setget _on_set_sfx_vol
|
|
|
|
# options state
|
|
signal on_reading_speed_changed(new_value)
|
|
signal on_master_volume_changed(new_value)
|
|
signal on_music_volume_changed(new_value)
|
|
signal on_sfx_volume_changed(new_value)
|
|
|
|
signal on_settings_enter()
|
|
signal on_settings_exit()
|
|
|
|
# music related
|
|
onready var music_player = get_node("music_player")
|
|
onready var sfx_player = get_node("sfx_player")
|
|
|
|
# transition node
|
|
onready var transition = get_node("trans_layer/transition")
|
|
|
|
# actual game state here
|
|
var current_registry
|
|
|
|
func _ready():
|
|
pass
|
|
|
|
func _register_functions():
|
|
|
|
# default VN.. functions
|
|
current_registry["SWITCH_SCENE"] = funcref(self, "_switch_scene_fnc")
|
|
current_registry["SET_BACKGROUND"] = funcref(self, "_set_background_fnc")
|
|
|
|
|
|
func _set_background_fnc(args):
|
|
if args.size() == 1:
|
|
var bg_name = args[0]
|
|
var bg_texture = load(Images[bg_name])
|
|
SceneSwitcher.current_scene.set_background(bg_texture)
|
|
|
|
func _switch_scene_fnc(args):
|
|
if args.size() == 1:
|
|
var scene_name = args[0]
|
|
var scene_path = Scenes[scene_name]
|
|
switch_scene_to(scene_path)
|
|
|
|
func _on_game_started_set(v):
|
|
if v and not game_started:
|
|
print("STARTO")
|
|
_on_game_start()
|
|
game_started = v
|
|
|
|
func _on_set_reading_speed(s):
|
|
pass
|
|
|
|
func _on_set_master_vol(v):
|
|
pass
|
|
|
|
func _on_set_music_vol(v):
|
|
pass
|
|
|
|
func _on_set_sfx_vol(v):
|
|
pass
|
|
|
|
func _on_game_start():
|
|
|
|
# all game state here
|
|
current_registry = {}
|
|
|
|
# register all de stuff
|
|
_register_functions()
|
|
|
|
|
|
# public interface sorta
|
|
func switch_scene_to(scene_path, fade = true):
|
|
|
|
if fade:
|
|
transition.start_transition()
|
|
yield(transition, "on_transition_time")
|
|
|
|
SceneSwitcher.goto_scene(scene_path)
|
|
|
|
if fade:
|
|
yield(transition, "on_transition_completed")
|
|
if SceneSwitcher.current_scene.has_method("on_scene_start"):
|
|
SceneSwitcher.current_scene.on_scene_start()
|
|
|