diff --git a/README.md b/README.md index 50941923..db7c13f6 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Ren ![Logo](graphics/window_icon.png) -![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square) +[![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square)](LICENSE) [![Discord Server](https://img.shields.io/discord/484604562183815169.svg?style=flat-square)](https://discord.gg/K9gvjdg) [![GitHub](https://img.shields.io/github/contributors/jeremi360/Ren.svg?style=flat-square)](https://github.com/jeremi360/Ren) [![GitHub](https://img.shields.io/github/stars/jeremi360/Ren.svg?style=flat-square)](https://github.com/jeremi360/Ren) @@ -17,12 +17,13 @@ It means games that are for example: - Visual Novels ![](https://img.shields.io/badge/VN-90%25-brightgreen.svg?style=flat-square) - Click & Point Adventures ![](https://img.shields.io/badge/Adv-25%25-yellowgreen.svg?style=flat-square) -- RPG ![](https://img.shields.io/badge/RPG-25%25-yellowgreen.svg?style=flat-square) +- RPG ![](https://img.shields.io/badge/RPG-40%25-green.svg?style=flat-square) You can use it with: - GDScript -- VisualScript (ToDo) +- JSON (ToDo) - RenScript (ToDo) +- VisualScript (ToDo) Ren use [PersistenceNode](https://github.com/MatiasVME/Persistence) for saving/load game. diff --git a/addons/Ren/Ren.tscn b/addons/Ren/Ren.tscn index f35d1912..cec5d176 100644 --- a/addons/Ren/Ren.tscn +++ b/addons/Ren/Ren.tscn @@ -21,7 +21,7 @@ [ext_resource path="res://addons/Ren/nodes/ren_timer.gd" type="Script" id=19] [ext_resource path="res://addons/Ren/icons/ren_timer.svg" type="Texture" id=20] -[node name="Ren" type="Node"] +[node name="Ren" type="Node" index="0"] pause_mode = 2 script = ExtResource( 1 ) @@ -29,7 +29,7 @@ _sections_unfolded = [ "Pause" ] game_title = "Your New Game" game_version = "0.0.1" game_credits = "Your Company" -markups = "ren" +markup = "ren" links_color = Color( 0.133333, 0.368627, 0.74902, 1 ) debug_on = false save_folder = "saves" diff --git a/addons/Ren/main.gd b/addons/Ren/main.gd index 0437c10d..938a5593 100644 --- a/addons/Ren/main.gd +++ b/addons/Ren/main.gd @@ -3,21 +3,21 @@ extends Node export (String) var game_title = "Your New Game" export (String) var game_version = "0.0.1" export (String) var game_credits = "Your Company" -export (String, "ren", "bbcode") var markups = "ren" +export (String, "ren", "bbcode") var markup = "ren" export (Color) var links_color = Color("#225ebf") export (bool) var debug_on = true export (String) var save_folder = "saves" export (String) var save_password = "Ren" export (String, DIR) var scenes_dir = "res://scenes/examples/" -const ren_version = "0.9.51" +const ren_version = "1.0.0" const credits_path = "res://addons/Ren/credits.txt" ## init vars for settings var _skip_all_text = false var _skip_after_choices = false var _auto_speed = 1 -var _text_speed = 0.01 +var _text_speed = 30 var _notify_time = 5 enum Type { @@ -199,8 +199,8 @@ func on_stop_audio(node_id): ## parse text like in renpy to bbcode if mode == "ren" ## or parse bbcode with {vars} if mode == "bbcode" -## default mode = Ren.markups -func text_passer(text, mode = markups): +## default mode = Ren.markup +func text_passer(text, mode = markup): return $Text.text_passer(text, variables, mode, links_color.to_html()) ## add/overwrite global variable that Ren will see diff --git a/scenes/examples/Test/Test.tscn b/scenes/examples/Test/Test.tscn index 043dd9cd..4262de21 100644 --- a/scenes/examples/Test/Test.tscn +++ b/scenes/examples/Test/Test.tscn @@ -66,7 +66,7 @@ tracks/0/keys = { "values": [ 0.0, 360.0 ] } -[node name="Test" type="Node2D" index="0"] +[node name="Test" type="Node2D"] script = ExtResource( 1 ) _sections_unfolded = [ "Material", "Transform", "Z Index" ] diff --git a/scenes/gui/OptionsBox/ApplyButton.gd b/scenes/gui/OptionsBox/ApplyButton.gd index aa961e2a..b1661e36 100644 --- a/scenes/gui/OptionsBox/ApplyButton.gd +++ b/scenes/gui/OptionsBox/ApplyButton.gd @@ -1,4 +1,5 @@ extends Button func _ready(): - connect("pressed", settings, "apply") \ No newline at end of file + connect("pressed", settings, "apply") + diff --git a/scenes/gui/OptionsBox/OptionsBox.tscn b/scenes/gui/OptionsBox/OptionsBox.tscn index cb3ed17e..cf311a9c 100644 --- a/scenes/gui/OptionsBox/OptionsBox.tscn +++ b/scenes/gui/OptionsBox/OptionsBox.tscn @@ -386,11 +386,11 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 -min_value = -0.1 -max_value = 0.0 -step = 0.01 +min_value = 0.0 +max_value = 100.0 +step = 1.0 page = 0.0 -value = -0.01 +value = 30.0 exp_edit = false rounded = false editable = true @@ -549,6 +549,7 @@ default = 5.0 [node name="GraphicsBox" type="VBoxContainer" parent="HBoxContainer" index="1"] +editor/display_folded = true anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 @@ -886,7 +887,7 @@ margin_right = 246.0 margin_bottom = 129.0 grow_horizontal = 0 -[node name="MasterBusControl3" parent="HBoxContainer/MusicBox" index="2" instance=ExtResource( 15 )] +[node name="BGMBusControl3" parent="HBoxContainer/MusicBox" index="2" instance=ExtResource( 15 )] margin_top = 133.0 margin_right = 246.0 diff --git a/scenes/gui/OptionsBox/SoundBusControl.gd b/scenes/gui/OptionsBox/SoundBusControl.gd index 7f68cadc..c075d91b 100644 --- a/scenes/gui/OptionsBox/SoundBusControl.gd +++ b/scenes/gui/OptionsBox/SoundBusControl.gd @@ -3,23 +3,26 @@ extends VBoxContainer export(String) var label = "Volume" export(String) var bus_name = "Master" var bus_id = 0 +var mute = false +var volume = 0 func _ready(): bus_id = AudioServer.get_bus_index(bus_name) - $VBox/Label.text = label + $VBox/Label.text = label + if AudioServer.is_bus_mute(bus_id): $VBox/OffButton.pressed = true else: $VBox/OnButton.pressed = true $VBox/OnButton.connect( - "pressed", AudioServer, + "pressed", self, "set_bus_mute", [bus_id, false] ) $VBox/OffButton.connect( - "pressed", AudioServer, + "pressed", self, "set_bus_mute", [bus_id, true] ) @@ -37,4 +40,9 @@ func _on_visibility_changed(): $Bar.value = AudioServer.get_bus_volume_db(bus_id) func set_bus_volume(value, bus_id): - AudioServer.set_bus_volume_db(bus_id, value) \ No newline at end of file + AudioServer.set_bus_volume_db(bus_id, value) + volume = value + +func set_bus_mute(bus_id, value): + AudioServer.set_bus_mute(bus_id, value) + mute = value diff --git a/scenes/gui/Screens/Screens.gd b/scenes/gui/Screens/Screens.gd index 4e665a0e..86315f6e 100644 --- a/scenes/gui/Screens/Screens.gd +++ b/scenes/gui/Screens/Screens.gd @@ -4,6 +4,7 @@ onready var in_game_gui = get_node("/root/Window/InGameGUI") var current_node = self var nav_path = "Navigation/ScrollContainer/VBoxContainer/" + func _ready(): get_tree().set_auto_accept_quit(false) connect("visibility_changed", self, "_on_visibility_changed") @@ -89,9 +90,8 @@ func _on_Quests_pressed(): # if press "yes" on quit page func _on_Yes_pressed(): - if !Ren.savefile("auto"): - return - + Ren.savefile("auto") + settings.save_conf() get_tree().quit() func _on_Quit_pressed(): diff --git a/scenes/gui/Window/Window.gd b/scenes/gui/Window/Window.gd index 61810925..12975e8f 100644 --- a/scenes/gui/Window/Window.gd +++ b/scenes/gui/Window/Window.gd @@ -1,6 +1,8 @@ extends Node2D func _ready(): + var default = settings.default_window_size + scale = OS.window_size / default settings.connect("window_size_changed", self, "_on_window_size_changed") func _on_window_size_changed(prev, now): diff --git a/scenes/gui/settings.gd b/scenes/gui/settings.gd index 3ce90936..7c93bc94 100644 --- a/scenes/gui/settings.gd +++ b/scenes/gui/settings.gd @@ -22,15 +22,17 @@ signal window_maximized_changed(value) signal window_fullscreen_changed(value) func _ready(): + temp_window_type_id = get_window_type_id() + temp_window_size = OS.window_size + temp_vsync_enabled = OS.vsync_enabled + + load_conf() + _prev_window_size = OS.window_size _prev_window_minimized = OS.window_minimized _prev_window_maximized = OS.window_maximized _prev_window_fullscreen = OS.window_fullscreen - temp_window_size = OS.window_size - temp_vsync_enabled = OS.vsync_enabled - temp_window_type_id = get_window_type_id() - func get_window_type_id(): var window_type_id = 0 @@ -92,12 +94,89 @@ func _process(delta): _prev_window_maximized = OS.window_maximized _prev_window_fullscreen = OS.window_fullscreen +func save_conf(): + var config = ConfigFile.new() + config.set_value("display", "width", _get_window_size().x) + config.set_value("display", "height", _get_window_size().y) + config.set_value("display", "fullscreen", get_window_type_id()) + config.set_value("display", "vsync", OS.vsync_enabled) + + var audio_bus = [ + "Master", + "BGM", + "SFX", + "Dialogs" + ] + + for bus_name in audio_bus: + var bus_id = AudioServer.get_bus_index(bus_name) + var mute = AudioServer.is_bus_mute(bus_id) + var volume = AudioServer.get_bus_volume_db(bus_id) + config.set_value("audio", bus_name + "_mute", mute) + config.set_value("audio", bus_name + "_volume", volume) + + config.set_value("ren", "Text_Speed", Ren.get_value("text_speed")) + config.set_value("ren", "Auto_Forward_Speed", Ren.get_value("auto_speed")) + config.set_value("ren", "Notify_Time", Ren.get_value("notify_time")) + + ## do nothing for now + config.set_value("ren", "Skip_All_Text", Ren.get_value("skip_all_text")) + config.set_value("ren", "Skip_After_Choices", Ren.get_value("skip_after_choices")) + + # Save the changes by overwriting the previous file + config.save("user://settings.cfg") + +func load_conf(): + var config = ConfigFile.new() + var err = config.load("user://settings.cfg") + if err != OK: # if not, something went wrong with the file loading + return + + # Look for the display/width pair, and default to 1024 if missing + temp_window_size.x = config.get_value("display", "width", default_window_size.x) + temp_window_size.y = config.get_value("display", "height", default_window_size.y) + temp_window_type_id = config.get_value("display", "fullscreen", 0) + temp_vsync_enabled = config.get_value("display", "vsync", true) + + apply() + + var audio_bus = [ + "Master", + "BGM", + "SFX", + "Dialogs" + ] + + for bus_name in audio_bus: + var bus_id = AudioServer.get_bus_index(bus_name) + var mute = config.get_value("audio", bus_name + "_mute", false) + var volume = config.get_value("audio", bus_name + "_volume", 0) + + AudioServer.set_bus_mute(bus_id, mute) + AudioServer.set_bus_volume_db(bus_id, volume) + + var text_speed = config.get_value("ren", "Text_Speed", Ren._text_speed) + var auto_speed = config.get_value("ren", "Auto_Forward_Speed", Ren._auto_speed) + var notify_time = config.get_value("ren", "Notify_Time", Ren._notify_time) + + ## do nothing for now + var skip_all_text = config.get_value("ren", "Skip_All_Text", Ren._skip_all_text) + var skip_after_choices = config.get_value("ren", "Skip_After_Choices", Ren._skip_after_choices) + + Ren.set_var("text_speed", text_speed) + Ren.set_var("auto_speed", auto_speed) + Ren.set_var("notify_time", notify_time) + + ## do nothing for now + Ren.set_var("skip_all_text", skip_all_text) + Ren.set_var("skip_after_choices", skip_after_choices) + func set_window_options(fullscreen, maximized): - settings.window_fullscreen = fullscreen - settings.window_maximized = maximized + _set_window_fullscreen(fullscreen) + _set_window_maximized(maximized) func apply(): - match settings.temp_window_type_id: + match temp_window_type_id: 0: # Windowed set_window_options(false, false) 1: # Fullscreen @@ -105,7 +184,6 @@ func apply(): 2: # Maximized set_window_options(false, true) - settings.window_size = settings.temp_window_size - OS.vsync_enabled = settings.temp_vsync_enabled - + _set_window_size(temp_window_size) + OS.vsync_enabled = temp_vsync_enabled