Skip to content

Commit

Permalink
Merge pull request #78 from Jeremi360/1.0
Browse files Browse the repository at this point in the history
fix few bugs with saving settings
  • Loading branch information
Jeremi360 committed May 13, 2022
2 parents 93299a2 + c0cf9d0 commit dd54576
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
31 changes: 25 additions & 6 deletions addons/Rakugo/Rakugo.gd
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func has_variable(var_name:String) -> bool:
func _ready():
self.scene_anchor = get_tree().get_root()
History.init()
var version = ProjectSettings.get(Rakugo.game_version)
var title = ProjectSettings.get(Rakugo.game_title)
var version = ProjectSettings.get_setting(Rakugo.game_version)
var title = ProjectSettings.get_setting(Rakugo.game_title)
OS.set_window_title(title + " " + version)

narrator = Character.new()
narrator.init(ProjectSettings.get(Rakugo.narrator_name), "", Color.transparent)
narrator.init(ProjectSettings.get_setting(Rakugo.narrator_name), "", Color.transparent)

func get_narrator():
return narrator
Expand Down Expand Up @@ -117,8 +117,13 @@ func prepare_quitting():
if self.started:
self.save_game("auto")

# Settings.save_property_list()

# this don't exist in godot
# ProjectSettings.save_property_list()

# TODO: remove in future
# if current_dialogue:
# current_dialogue.exit()

func reset_game():
started = false
emit_signal("game_ended")
Expand All @@ -134,6 +139,20 @@ func _exit_tree() -> void:
func parser_add_regex_at_runtime(key:String, regex:String):
current_parser.add_regex_at_runtime(key, regex)

## Dialogue flow control

# TODO: remove in future
# func exit_dialogue():
# self.set_current_dialogue(null)

# func set_current_dialogue(new_dialogue:Dialogue):
# if current_dialogue != new_dialogue:
# if self.current_dialogue \
# and self.current_dialogue.is_running():
# self.current_dialogue.exit()

# current_dialogue = new_dialogue

func activate_skipping():
self.skipping = true
skip_timer.start()
Expand Down Expand Up @@ -174,7 +193,7 @@ func debug_dict(parameters:Dictionary, parameters_names:Array = [], some_custom_
# for printing debugs is only print if debug_on == true
# put some string array or string as argument
func debug(some_text = []):
if not ProjectSettings.get(Rakugo.debug):
if not ProjectSettings.get_setting(Rakugo.debug):
return

if not started:
Expand Down
8 changes: 4 additions & 4 deletions addons/Rakugo/lib/systems/History.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func _on_say(character, text):
tag = character.tag

entry.init(tag, text)
Rakugo.store.history.push_front(entry)
global_history[last_say_hash] = true #Using Dictionary as a python Set to benefit from the lookup table
Rakugo.store_manager.get_current_store()["history"].push_front(entry)
global_history[last_say_hash] = true # Using Dictionary as a python Set to benefit from the lookup table


func _store(store):
log_step = true
step_has_unseen = false
last_say_hash = 0 #Remember to empty the hash_say !
Rakugo.persistent.global_history = global_history
last_say_hash = 0 # Remember to empty the hash_say !
Rakugo.persistent.global_history = global_history
store.event_played = event_played.duplicate()


Expand Down
8 changes: 4 additions & 4 deletions addons/Rakugo/lib/systems/StoreManager.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Node

const save_folder_path = "users://saves"
const save_folder_path = "usr://saves"

var store_stack = []
var store_stack_max_length = 5
Expand Down Expand Up @@ -166,9 +166,9 @@ func change_current_stack_index(index):
### Store Stack

func init_store_stack():
store_stack_max_length = ProjectSettings.get(Rakugo.rollback_steps)
store_stack_max_length = ProjectSettings.get_setting(Rakugo.rollback_steps)
var new_save := Store.new()
new_save.game_version = ProjectSettings.get(Rakugo.game_version)
new_save.game_version = ProjectSettings.get_setting(Rakugo.game_version)
new_save.rakugo_version = Rakugo.rakugo_version
new_save.scene = Rakugo.current_scene_name
new_save.history = []
Expand Down Expand Up @@ -253,7 +253,7 @@ func init_persistent_store():
persistent_store = load(persistent_path)
else:
persistent_store = Store.new()
persistent_store.game_version = ProjectSettings.get(Rakugo.game_version)
persistent_store.game_version = ProjectSettings.get_setting(Rakugo.game_version)
persistent_store.rakugo_version = Rakugo.rakugo_version

func save_persistent_store():
Expand Down

0 comments on commit dd54576

Please sign in to comment.