Skip to content

Commit

Permalink
Merge pull request #201 from theludovyc/GodotV4
Browse files Browse the repository at this point in the history
Godot v4
  • Loading branch information
Jeremi360 authored Mar 8, 2023
2 parents 0a6fc2f + 113e682 commit 956a367
Show file tree
Hide file tree
Showing 121 changed files with 5,546 additions and 5,407 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.godot/
*.translation
export_presets.cfg
/.import/
/.vscode/
/.mono/
Expand Down
25 changes: 13 additions & 12 deletions .gut_editor_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"background_color": "ff262626",
"compact_mode": false,
"config_file": "res://.gutconfig.json",
"dirs": [
"res://Test/TestParser",
Expand All @@ -11,6 +12,7 @@
"font_color": "ffcccccc",
"font_name": "CourierPrime",
"font_size": 16,
"gut_on_top": true,
"hide_orphans": false,
"ignore_pause": false,
"include_subdirs": true,
Expand All @@ -19,27 +21,26 @@
"junit_xml_timestamp": false,
"log_level": 1,
"opacity": 100,
"paint_after": 0.1,
"panel_options": {
"font_name": "CourierPrime",
"font_size": 30,
"hide_output_text": false,
"hide_result_tree": false,
"hide_settings": true,
"use_colors": false
},
"post_run_script": "",
"pre_run_script": "",
"prefix": "Test",
"selected": "TestMenu.gd",
"selected": "TestVariablesRk.gd",
"should_exit": false,
"should_exit_on_success": false,
"should_maximize": false,
"compact_mode": false,
"show_help": false,
"suffix": ".gd",
"tests": [

],
"unit_test_name": "test_menu",
"gut_on_top": true,
"panel_options": {
"font_name": "CourierPrime",
"font_size": 30,
"hide_result_tree": false,
"hide_output_text": false,
"hide_settings": false,
"use_colors": false
}
"unit_test_name": "test_variables"
}
64 changes: 49 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ![Logo](WindowIcon.png) Rakugo
# ![Logo](WindowIcon.png) Rakugo Dialog System

![MIT License](https://img.shields.io/static/v1.svg?label=📜%20License&message=MIT&color=informational)
[![Join the Discord channel](https://img.shields.io/static/v1.svg?label=Join%20our%20Discord%20channel&message=🎆&color=7289DA&logo=discord&logoColor=white&labelColor=2C2F33)](https://discord.gg/K9gvjdg)
Expand All @@ -9,12 +9,13 @@
[![GitHub](https://img.shields.io/github/issues/rakugoteam/Rakugo.svg)](https://github.com/rakugoteam/Rakugo/issues)
[![GitHub](https://img.shields.io/github/issues-closed/rakugoteam/Rakugo.svg)](https://github.com/rakugoteam/Rakugo/issues)

Core of our projects. Inspired by [Ren'Py](https://www.renpy.org), Rakugo is a project aiming to provide a way to make narrative-based games on [Godot](https://godotengine.org) easily. Simplify your project, if it is a visual novel, point and click, RPG, interactive text game or many other styles and blends of styles.
Core of our projects. Inspired by [Ren'Py](https://www.renpy.org), this project aiming to provide a way to make narrative-based games on [Godot](https://godotengine.org) easily. Simplify your project, if it is a visual novel, point and click, RPG, interactive text game or many other styles and blends of styles.

Support this project here [itch.io](https://rakugoteam.github.io/donations/).

[Showcase](#Showcase) -
[Installation](#Installation) -
[Use .rk files](#Use-.rk-files) -
[Get Started](#Get-Started) -
[Documentation](#Documentation) -
[Rakugo Addons](#Rakugo-Addons) -
Expand All @@ -29,7 +30,7 @@ Support this project here [itch.io](https://rakugoteam.github.io/donations/).
* Own script language
* Save/Load system
* Global variables and character's variables
* [Gut](https://github.com/bitwes/Gut) (Godot Unit Test)
* Unit tested with [Gut](https://github.com/bitwes/Gut)

## Showcase

Expand All @@ -45,43 +46,66 @@ Check our project [Examples](https://github.com/rakugoteam/Examples) to see exam

If your game uses Rakugo, tell us on [Discord](https://discord.gg/K9gvjdg).

## Update from Godot 3.X to 4.X
Signal system have changed. So we renamed all Rakugo signals.

Just add "sg_" at begining. Like "old_signal_name" to "sg_old_signal_name".

Everything else is the same.

## Installation

To install Rakugo plugin, download it as a [ZIP archive](https://github.com/rakugoteam/Rakugo/releases). Extract the `addons/Rakugo` folder into your project folder. Then, enable the plugin in project settings and restart Godot-Engine.
To install Rakugo plugin, download it [here](https://github.com/rakugoteam/Rakugo/releases). Then extract the `Rakugo` folder into your `res://addons` folder. Finaly, enable the plugin in project settings and restart Godot-Engine.

If you want to know more about installing plugins you can read the [godot official documentation page](https://docs.godotengine.org/en/stable/tutorials/plugins/editor/installing_plugins.html).

## Use .rk files
### Configure Godot
Rk files are text files. So you can use .txt extension. But if you want to use .rk you can do this :
- Go to Editor > Editor Settings
- In search bar type : "Extensi"
- Add "rk"

### Export
**/!\ .rk files are not exported by default /!\\**

Follow this guide https://rakugoteam.github.io/rakugo-docs/export/

## Get Started

- Create a scene with a Node and script on it
- Create a scene with a Node and add a script on it

Basic GdScript (Node.gd) :
GdScript (Node.gd) :

```gdscript
extends Node
const file_path = "res://Timeline.rk"
func _ready():
Rakugo.connect("say", self, "_on_say")
Rakugo.connect("step", self, "_on_step")
Rakugo.sg_say.connect(_on_say)
Rakugo.sg_step.connect(_on_step)
Rakugo.sg_execute_script_finished.connect(_on_execute_script_finished)
Rakugo.parse_and_execute_script(file_path)
Rakugo.parse_and_execute_script(file_path)
func _on_say(character:Dictionary, text:String):
prints("say", character.get("name", ""), text)
prints("Say", character.get("name", ""), text)
func _on_step():
prints("Press 'Enter' to continue...")
prints("Press \"Enter\" to continue...")
func _on_execute_script_finished(file_name:String, error_str:String):
prints("End of script")
func _process(delta):
if Rakugo.is_waiting_step() and Input.is_action_just_pressed("ui_accept"):
Rakugo.do_step()
if Rakugo.is_waiting_step() and Input.is_action_just_pressed("ui_accept"):
Rakugo.do_step()
```

- Create your first RakuScript (text file) *"Timeline.rk"* at root of your project folder (res://)

Basic RkScript (Timeline.rk) :
RkScript (Timeline.rk) :

```
character Gd "Godot"
Expand All @@ -91,7 +115,17 @@ Gd "I'm <Gd.name> !"

- Run Scene (F6)

Out :
```
Say Godot Hello, world !
Press "Enter" to continue...
Say Godot I'm Godot !
Press "Enter" to continue...
End of script
```

## Documentation
If you want to know how to use Rakugo or write rk scripts.

Go to https://rakugoteam.github.io/rakugo-docs/ !

Expand All @@ -107,7 +141,7 @@ Go to https://rakugoteam.github.io/rakugo-docs/ !
**A:** Yes

**Q:** What difference with [Dialogic](https://github.com/coppolaemilio/dialogic) ?</p>
**A:** Our project use normal coding with our own scripting langue inspired by Ren'Py, instead of visual. Plus is just a core, simple as possible, autoloaded when you enabled the plugin. If you wnat more check our addons and kits bellow.
**A:** Our project use normal coding with our own scripting langue inspired by Ren'Py, instead of visual. Plus is just a core, simple as possible, autoloaded when you enabled the plugin. If you want more check our addons and kits bellow.

## Rakugo Addons

Expand Down
26 changes: 13 additions & 13 deletions Test/RakugoTest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ func get_file_base_name(file_path:String) -> String:
func watch_rakugo_signals():
watch_signals(Rakugo)

func wait_signal(signal_name:String, parameters:Array):
yield(yield_to(Rakugo, signal_name, 0.2), YIELD)
func wait_signal(sg:Signal, parameters:Array):
await wait_for_signal(sg, 0.2)

assert_signal_emitted_with_parameters(
Rakugo,
signal_name,
sg.get_name(),
parameters)

func wait_execute_script_start(file_base_name:String):
return wait_signal("execute_script_start", [file_base_name])
await wait_signal(Rakugo.sg_execute_script_start, [file_base_name])

func wait_parse_and_execute_script(file_path:String):
Rakugo.parse_and_execute_script(file_path)

return wait_execute_script_start(get_file_base_name(file_path))
await wait_execute_script_start(get_file_base_name(file_path))

func wait_ask(character:Dictionary, text:String, default_answer:String):
return wait_signal("ask", [character, text, default_answer])
await wait_signal(Rakugo.sg_ask, [character, text, default_answer])

func assert_ask_return(var_name:String, value):
assert_true(Rakugo.is_waiting_ask_return())
Expand All @@ -33,7 +33,7 @@ func assert_ask_return(var_name:String, value):
assert_eq(value, Rakugo.get_variable(var_name))

func wait_execute_script_finished(file_base_name:String, error_str:String = ""):
return wait_signal("execute_script_finished", [file_base_name, error_str])
await wait_signal(Rakugo.sg_execute_script_finished, [file_base_name, error_str])

func assert_character_name_eq(char_tag:String, value:String):
var character = Rakugo.get_character(char_tag)
Expand All @@ -46,7 +46,7 @@ func assert_do_step():
Rakugo.do_step()

func wait_say(character:Dictionary, text:String):
return wait_signal("say", [character, text])
await wait_signal(Rakugo.sg_say, [character, text])

func assert_variable(var_name:String, var_type, value):
var var_ = Rakugo.get_variable(var_name)
Expand All @@ -55,19 +55,19 @@ func assert_variable(var_name:String, var_type, value):
assert_eq(var_, value)

func wait_character_variable_changed(char_tag:String, var_name:String, var_type, value):
yield(wait_signal("character_variable_changed", [char_tag, var_name, value]), "completed")
await wait_signal(Rakugo.sg_character_variable_changed, [char_tag, var_name, value])

assert_variable(char_tag+"."+var_name, var_type, value)

func wait_variable_changed(var_name:String, var_type, value):
yield(wait_signal("variable_changed", [var_name, value]), "completed")
await wait_signal(Rakugo.sg_variable_changed, [var_name, value])

assert_variable(var_name, var_type, value)

func wait_menu(choices:PoolStringArray):
return wait_signal("menu", [choices])
func wait_menu(choices:PackedStringArray):
await wait_signal(Rakugo.sg_menu, [choices])

func assert_menu_return(index:int):
assert_true(Rakugo.is_waiting_menu_return())

Rakugo.menu_return(index)
Rakugo.menu_return(index)
6 changes: 3 additions & 3 deletions Test/TestExecuter/TestStop/TestStop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ var file_base_name = get_file_base_name(file_path)
func test_stop():
watch_rakugo_signals()

yield(wait_parse_and_execute_script(file_path), "completed")
await wait_parse_and_execute_script(file_path)

yield(wait_say({}, "You can see this message"), "completed")
await wait_say({}, "You can see this message")

Rakugo.stop_last_script()

yield(wait_execute_script_finished(file_base_name), "completed")
await wait_execute_script_finished(file_base_name)
18 changes: 9 additions & 9 deletions Test/TestGui/TestGui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ extends Node

const file_name = "res://Test/TestParser/Timeline.rk"

onready var label = $RichTextLabel
onready var line_edit = $LineEdit
onready var menu_container = $MenuContainer
@onready var label = $RichTextLabel
@onready var line_edit = $LineEdit
@onready var menu_container = $MenuContainer

func _ready():
Rakugo.connect("say", self, "_on_say")
Rakugo.connect("step", self, "_on_step")
Rakugo.connect("ask", self, "_on_ask")
Rakugo.connect("menu", self, "_on_menu")
Rakugo.connect("notify", self, "_on_notify")
Rakugo.connect("say",Callable(self,"_on_say"))
Rakugo.connect("step",Callable(self,"_on_step"))
Rakugo.connect("ask",Callable(self,"_on_ask"))
Rakugo.connect("menu",Callable(self,"_on_menu"))
Rakugo.connect("notify",Callable(self,"_on_notify"))

var narrator_name = ProjectSettings.get_setting(Rakugo.narrator_name)

Expand Down Expand Up @@ -45,7 +45,7 @@ func _on_menu(choices):
for choice in choices:
var button = Button.new()
button.text = choice
button.connect("pressed", self, "_on_menu_button_pressed", [button])
button.connect("pressed",Callable(self,"_on_menu_button_pressed").bind(button))
menu_container.add_child(button)

menu_container.visible = true
Expand Down
14 changes: 7 additions & 7 deletions Test/TestGui/TestGui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ script = ExtResource( 1 )
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -136.0
offset_top = -136.0
text = "Test
1
2
Expand All @@ -25,18 +25,18 @@ visible = false
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = -24.0
offset_top = -24.0

[node name="MenuContainer" type="VBoxContainer" parent="."]
visible = false
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -20.0
margin_top = -20.0
margin_right = 20.0
margin_bottom = 20.0
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
alignment = 1

[connection signal="text_entered" from="LineEdit" to="." method="_on_LineEdit_text_entered"]
[connection signal="text_submitted" from="LineEdit" to="." method="_on_LineEdit_text_entered"]
6 changes: 3 additions & 3 deletions Test/TestParser/TestAsk/TestAsk.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ var file_base_name = get_file_base_name(file_path)
func test_ask():
watch_rakugo_signals()

yield(wait_parse_and_execute_script(file_path), "completed")
await wait_parse_and_execute_script(file_path)

yield(wait_ask({}, "Are you human ?", "Yes"), "completed")
await wait_ask({}, "Are you human ?", "Yes")

assert_ask_return("answer", "No")

yield(wait_execute_script_finished(file_base_name), "completed")
await wait_execute_script_finished(file_base_name)
4 changes: 2 additions & 2 deletions Test/TestParser/TestCharacter/TestCharacter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var file_base_name = get_file_base_name(file_path)
func test_character():
watch_rakugo_signals()

yield(wait_parse_and_execute_script(file_path), "completed")
await wait_parse_and_execute_script(file_path)

yield(wait_execute_script_finished(file_base_name), "completed")
await wait_execute_script_finished(file_base_name)

assert_character_name_eq("Sy", "Sylvie")

Expand Down
2 changes: 1 addition & 1 deletion Test/TestParser/TestCharacter/TestCharacter.rk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
character Sy "Sylvie"
character Gd "Godot"
character Gd "Godot"
4 changes: 2 additions & 2 deletions Test/TestParser/TestFinish/TestFinish.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var file_base_name = get_file_base_name(file_path)
func test_finish():
watch_rakugo_signals()

yield(wait_parse_and_execute_script(file_path), "completed")
await wait_parse_and_execute_script(file_path)

assert_do_step()

yield(wait_execute_script_finished(file_base_name), "completed")
await wait_execute_script_finished(file_base_name)
Loading

0 comments on commit 956a367

Please sign in to comment.