Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Marge simple workround for #154 bug for question branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremi360 committed Jul 7, 2019
1 parent b4468c8 commit 13d33cd
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 36 deletions.
23 changes: 14 additions & 9 deletions addons/Rakugo/lib/jump.gd
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
extends Node

func invoke(
id_of_scene:String,
scene_id:String,
node_name:String,
dialog_name:String,
state := 0,
force_reload := false
) ->void :

var r = Rakugo
var scenes_links = load(r.scenes_links).get_as_dict()
var path = r.current_scene
r.current_node_name = node_name
r.current_dialog_name = dialog_name
r.story_state = state
r.current_scene = id_of_scene

r.debug(["jump to scene:", r.current_scene, "with dialog:", dialog_name, "from:", r.story_state])

if scenes_links.has(id_of_scene):
path = scenes_links[id_of_scene].resource_path
load_scene(scene_id, force_reload)

if r.started:
r.story_step()

func load_scene(scene_id, force_reload = true):
var r = Rakugo
var scenes_links = load(r.scenes_links).get_as_dict()
var path = r.current_scene
r.current_scene = scene_id

if scene_id in scenes_links:
path = scenes_links[scene_id].resource_path

if (r.current_scene_path != path) or force_reload:
r.current_scene = path
Expand All @@ -32,6 +40,3 @@ func invoke(
get_tree().get_root().add_child(r.current_root_node)
r.started = true
r.emit_signal("started")

if r.started:
r.story_step()
12 changes: 7 additions & 5 deletions addons/Rakugo/lib/load_file.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary):
save_file_path += ".res"

if not file.file_exists(save_file_path):
print("Save file %s doesn't exist" % save_file_path)
printerr("Save file %s doesn't exist" % save_file_path)
r.loading_in_progress = false
return false

Expand Down Expand Up @@ -67,16 +67,19 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary):

r.start(true)

var story_state = save.story_state

if story_state > 0:
story_state -= 1

r.jump(
save.scene,
save.node_name,
save.dialog_name,
save.story_state,
story_state,
true
)

r.history_id = save.history_id

for node in r.get_tree().get_nodes_in_group("save"):
if node.has_method("on_load"):
node.on_load(r.game_version)
Expand All @@ -90,5 +93,4 @@ func invoke(save_folder: String, save_name: String, variables: Dictionary):
rc.on_load()

r.loading_in_progress = false

return true
18 changes: 9 additions & 9 deletions addons/Rakugo/lib/load_global_history.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ func invoke() -> bool:

var save_folder = r.save_folder
var save_folder_path = "usr://".plus_file(save_folder)

if r.test_save:
save_folder_path = "res://".plus_file(save_folder)

var save_path = save_folder_path.plus_file(save_name)

if r.test_save:
save_path += ".tres"

else:
save_path += ".res"

r.debug(["load global history from:", save_name])

var file:= File.new()

if not file.file_exists(save_path):
print("global history file %s doesn't exist" % save_path)
printerr("global history file %s doesn't exist" % save_path)
r.loading_in_progress = false
return false

var save_hist : HistorySave = load(save_path)
r.global_history = save_hist.history_data

r.loading_in_progress = false
return true

return true
10 changes: 7 additions & 3 deletions addons/Rakugo/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func define_from_str(var_name:String, var_str:String, var_type:String) -> Rakugo
## overwrite existing global variable and returns it as RakugoVar
func set_var(var_name:String, value) -> RakugoVar:
if not (var_name in variables):
prints(var_name, "variable don't exist in Rakugo")
printerr("%s variable don't exist in Rakugo" %var_name)
return null

var var_to_change = variables[var_name]
Expand Down Expand Up @@ -735,16 +735,20 @@ func _get_history_id() -> int:
## use this to change/assign current scene and dialog
## id_of_current_scene is id to scene defined in scenes_links or full path to scene
func jump(
id_of_scene:String, node_name:String,
scene_id:String, node_name:String,
dialog_name:String, state := 0, force_reload := false
) -> void:

$Jump.invoke(
id_of_scene,
scene_id,
node_name, dialog_name,
state, force_reload
)

## use this to load scene don't start with dialog or don't have any
func load_scene(scene_id:String) -> void:
$Jump.load_scene(scene_id)

## use this to assign beginning scene and dialog
## root of path_to_current_scene is scenes_dir
## provide path_to_current_scene with out ".tscn"
Expand Down
16 changes: 16 additions & 0 deletions addons/Rakugo/nodes/gdscript_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ func check_dialog(node_name, dialog_name, check_for) -> bool:
])
return result

func fake_check_dialog(fake_node_name, node_name, dialog_name, check_for) -> bool:
var result = true

if node_name != fake_node_name:
result = false

if dialog_name != check_for:
result = false

Rakugo.debug([
"check_dialog:", result,
"(",'"'+fake_node_name +'"', '"'+node_name+'"', ")",
"(", '"'+dialog_name+'"', '"'+check_for+'"', ")"
])
return result

func define(var_name:String, value = null, save_included := true) -> RakugoVar:
return Rakugo.define(var_name, value, save_included)

Expand Down
4 changes: 2 additions & 2 deletions addons/Rakugo/nodes/rakugo_anim_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ func _on_stop(id : String, reset : bool) -> void:

func on_save():
if not node_link:
prints("error with saveing:" , node_id)
printerr("error with saveing:" , node_id)
return

node_link.value["anim_name"] = current_animation
node_link.value["is_playing"] = is_playing()

func on_load(game_version:String) -> void:
if not node_link:
prints("error with loading:" , node_id)
printerr("error with loading:" , node_id)
return

if "is_playing" in node_link.value:
Expand Down
4 changes: 2 additions & 2 deletions addons/Rakugo/nodes/rakugo_audio_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ func _on_stop(id : String) -> void:

func on_save():
if not node_link:
prints("error with saveing:" , node_id)
printerr("error with saveing:" , node_id)
return

node_link.value["is_playing"] = is_playing()
node_link.value["from_pos"] = last_pos

func on_load(game_version:String) -> void:
if not node_link:
prints("error with loading:" , node_id)
printerr("error with loading:" , node_id)
return

if "is_playing" in node_link:
Expand Down
4 changes: 2 additions & 2 deletions addons/Rakugo/nodes/rakugo_control.gd
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func on_save() -> void:
return

if not node_link:
prints("error with saveing:" , node_id)
printerr("error with saveing:" , node_id)
return

node_link.value["visible"] = visible
Expand All @@ -123,7 +123,7 @@ func on_load(game_version:String) -> void:
return

if not node_link:
prints("error with loading:" , node_id)
printerr("error with loading:" , node_id)
return

visible = node_link.value["visible"]
Expand Down
4 changes: 2 additions & 2 deletions addons/Rakugo/nodes/rakugo_node2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func _exit_tree() -> void:

func on_save() -> void:
if not node_link:
prints("error with saveing:" , node_id)
printerr("error with saveing:" , node_id)
return

node_link.value["visible"] = visible
Expand All @@ -109,7 +109,7 @@ func on_save() -> void:

func on_load(game_version:String) -> void:
if not node_link:
prints("error with loading:" , node_id)
printerr("error with loading:" , node_id)
return

if "visible" in node_link.value:
Expand Down
4 changes: 2 additions & 2 deletions addons/Rakugo/nodes/rakugo_spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func _exit_tree() -> void:

func on_save() -> void:
if not node_link:
prints("error with saveing:" , node_id)
printerr("error with saveing:" , node_id)
return

node_link.value["visible"] = visible
Expand All @@ -110,7 +110,7 @@ func on_save() -> void:

func on_load(game_version:String) -> void:
if not node_link:
prints("error with loading:" , node_id)
printerr("error with loading:" , node_id)
return

visible = node_link.value["visible"]
Expand Down

0 comments on commit 13d33cd

Please sign in to comment.