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

Commit

Permalink
Merge pull request #83 from jeremi360/testing
Browse files Browse the repository at this point in the history
Final for 1.0.0
  • Loading branch information
Jeremi360 authored Jan 13, 2019
2 parents 4d0ed55 + a75816a commit fbc94d1
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 34 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions addons/Ren/Ren.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
[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 )
_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"
Expand Down
10 changes: 5 additions & 5 deletions addons/Ren/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scenes/examples/Test/Test.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
3 changes: 2 additions & 1 deletion scenes/gui/OptionsBox/ApplyButton.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extends Button

func _ready():
connect("pressed", settings, "apply")
connect("pressed", settings, "apply")

11 changes: 6 additions & 5 deletions scenes/gui/OptionsBox/OptionsBox.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions scenes/gui/OptionsBox/SoundBusControl.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)

Expand All @@ -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)
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
6 changes: 3 additions & 3 deletions scenes/gui/Screens/Screens.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 2 additions & 0 deletions scenes/gui/Window/Window.gd
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
98 changes: 88 additions & 10 deletions scenes/gui/settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -92,20 +94,96 @@ 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
set_window_options(true, false)
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

0 comments on commit fbc94d1

Please sign in to comment.