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 #386 from Jeremi360/rpg-ext-support
Browse files Browse the repository at this point in the history
add Rakugo.can_show_in_game_gui value
  • Loading branch information
Jeremi360 authored Aug 23, 2020
2 parents b3e2a3e + 64edfb6 commit 7ea9816
Show file tree
Hide file tree
Showing 15 changed files with 330 additions and 262 deletions.
4 changes: 2 additions & 2 deletions addons/Rakugo/init.tres
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[resource]
script = ExtResource( 1 )
game_version = "0.0.1"
rakugo_version = "2.1.05"
rakugo_version = "2.1.06"
history = {
"Start,SomeDialog,some_dialog,1": {
"parameters": {
Expand Down Expand Up @@ -554,7 +554,7 @@ data = {
},
"rakugo_version": {
"type": 1,
"value": "2.1.05"
"value": "2.1.06"
},
"rebeccapurple": {
"type": 13,
Expand Down
73 changes: 37 additions & 36 deletions addons/Rakugo/lib/load_global_history.gd
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
extends Object

func invoke() -> bool:
var r = Rakugo
var save_name = "global_history"
r.loading_in_progress = true

var save_folder = r.save_folder
var save_folder_path = "user://".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: %s" %save_name])

var file := File.new()
var save_hist: = HistorySave.new()

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

save_hist = load(save_path)
r.global_history = save_hist.history_data
r.loading_in_progress = false

return true
extends Object

func invoke() -> bool:
var r = Rakugo
var save_name = "global_history"
r.loading_in_progress = true

var save_folder = r.save_folder
var save_folder_path = "user://".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: %s" %save_name])

var file := File.new()
var save_hist: = HistorySave.new()

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

save_hist = load(save_path)
r.global_history = save_hist.history_data

r.loading_in_progress = false

return true
63 changes: 46 additions & 17 deletions addons/Rakugo/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ const credits_path := "res://addons/Rakugo/credits.txt"
const save_folder := "saves"

# project settings integration
onready var game_title = ProjectSettings.get_setting("application/config/name")
onready var game_version = ProjectSettings.get_setting("application/rakugo/version")
onready var game_credits = ProjectSettings.get_setting("application/rakugo/game_credits")
onready var markup = ProjectSettings.get_setting("application/rakugo/markup")
onready var debug_on = ProjectSettings.get_setting("application/rakugo/debug")
onready var test_save = ProjectSettings.get_setting("application/rakugo/test_saves")
onready var scene_links = ProjectSettings.get_setting("application/rakugo/scene_links")

onready var theme = load(ProjectSettings.get_setting("application/rakugo/theme"))
onready var default_kind = ProjectSettings.get_setting("application/rakugo/default_kind")
onready var default_mkind = ProjectSettings.get_setting("application/rakugo/default_mkind")
onready var default_mcolumns = ProjectSettings.get_setting("application/rakugo/default_mcolumns")
onready var default_manchor = ProjectSettings.get_setting("application/rakugo/default_manchor")
onready var game_title : String = ProjectSettings.get_setting("application/config/name")
onready var game_version : String = ProjectSettings.get_setting("application/rakugo/version")
onready var game_credits : String = ProjectSettings.get_setting("application/rakugo/game_credits")
onready var markup : String = ProjectSettings.get_setting("application/rakugo/markup")
onready var debug_on : bool = ProjectSettings.get_setting("application/rakugo/debug")
onready var test_save : bool = ProjectSettings.get_setting("application/rakugo/test_saves")
onready var scene_links : String = ProjectSettings.get_setting("application/rakugo/scene_links")

onready var theme : RakugoTheme = load(ProjectSettings.get_setting("application/rakugo/theme"))
onready var default_kind :String = ProjectSettings.get_setting("application/rakugo/default_kind")
onready var default_mkind : String = ProjectSettings.get_setting("application/rakugo/default_mkind")
onready var default_mcolumns : int = ProjectSettings.get_setting("application/rakugo/default_mcolumns")
onready var default_manchor : String = ProjectSettings.get_setting("application/rakugo/default_manchor")

# init vars for settings
var _skip_all_text := false
Expand Down Expand Up @@ -65,11 +65,19 @@ var current_dialog_name := ""
var current_node_name := ""
var current_scene := ""

# this store log of all dialog up this point in current game
# {["scene_id", "node_name", "dialog_name", story_step]:{"type":type, "parameters": parameters}}
var history := {}

# this store log of all dialog that player saw
var global_history := {}

# this store all RakugoVars
var variables := {}

# if `false` then InGameGUI will stay hidden even if `Rakugo.show("InGameGUI")` is called
var can_show_in_game_gui := true setget _set_in_game_gui, _get_in_game_gui

# don't save this
onready var menu_node: = $Menu
var viewport : Viewport
Expand All @@ -83,6 +91,7 @@ var can_alphanumeric := true
var emoji_size := 16
var skipping := false
var current_dialogs := {}
var can_save := true

const skip_types := [
StatementType.SAY,
Expand Down Expand Up @@ -160,11 +169,14 @@ func _ready() -> void:

load_init_data()

for v in variables:
variables[v].save_included = false

# set by game developer
define("title", game_title, true)
define("version", game_version, true)
define("title", game_title, false)
define("version", game_version, false)
OS.set_window_title(game_title + " " + game_version)
define("credits", game_credits, true)
define("credits", game_credits, false)

# it must be before define rakugo_version and godot_version to parse corretly :o
file.open(credits_path, file.READ)
Expand All @@ -180,6 +192,7 @@ func _ready() -> void:
define("story_state", 0)
define("v2_inf", Vector2.INF, false)
define("v3_inf", Vector3.INF, false)
define("can_show_in_game_gui", true)

step_timer.connect("timeout", self, "_on_time_active_timeout")

Expand Down Expand Up @@ -278,6 +291,7 @@ func clean_dialogs() -> void:

current_dialogs.erase(n)


# use to add/register dialog
# func_name is name of func that is going to be use as dialog
func add_dialog(node: Node, func_name: String) -> void:
Expand All @@ -295,7 +309,11 @@ func add_dialog(node: Node, func_name: String) -> void:
# or parse bbcode with {vars} if mode == "bbcode"
# default mode = Rakugo.markup
func text_passer(text: String, mode := markup):
return TextPasser.text_passer(text, variables, mode, theme.links_color.to_html())
var links_color := Color.aqua.to_html()
if theme:
links_color = theme.links_color.to_html()

return TextPasser.text_passer(text, variables, mode, links_color)


# add/overwrite global variable that Rakugo will see
Expand Down Expand Up @@ -597,6 +615,14 @@ func _get_story_state() -> int:
return get_value("story_state")


func _set_in_game_gui(can_show: bool) -> void:
define("can_show_in_game_gui", can_show)


func _get_in_game_gui() -> bool:
return get_value("can_show_in_game_gui")


# it starts Rakugo
func start(after_load := false) -> void:
load_global_history()
Expand Down Expand Up @@ -642,6 +668,9 @@ func debug(some_text = []) -> void:
if not debug_on:
return

if not started:
return

if typeof(some_text) == TYPE_ARRAY:
var new_text = ""

Expand Down
2 changes: 1 addition & 1 deletion addons/Rakugo/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Rakugo"
description="Rakugo is framework for story driven games"
author="Jeremi Biernacki, MelodicStream, Matías Muñoz Espinoza, Deep Gaurav"
version="2.1.05"
version="2.1.06"
script="plugin.gd"
12 changes: 2 additions & 10 deletions addons/Rakugo/tools/RakugoTools.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ func _on_menu(id:int) -> void:
# ScenesLinks Tool
1:
$SceneLinksEditor.popup_centered()

# Rakugo Docs
2:
OS.shell_open("https://rakugo.readthedocs.io/en/latest/")


# About Rakugo
3:
5:
$AboutDialog.popup_centered()

# Rakugo Website:
4:
OS.shell_open("https://rakugoteam.github.io/")
9 changes: 9 additions & 0 deletions addons/Rakugo/tools/about/AboutDialog.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tool
extends AcceptDialog

func _on_WebSiteButton_pressed():
OS.shell_open("https://rakugoteam.github.io/")


func _on_BugButton_pressed():
OS.shell_open("https://github.com/rakugoteam/Rakugo/labels/bug")
Loading

0 comments on commit 7ea9816

Please sign in to comment.