[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make styles require style.cfg to be detected. #1585

Merged
merged 4 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://ptlnkdsl67tf"
path="res://.godot/imported/default_layout.png-a47640974316a5f7b34cacd043d7a869.ctex"
path="res://.godot/imported/preview.png-1f03b89100d0ad1c91555207cc3d6207.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/dialogic/Modules/DefaultStyles/default_layout.png"
dest_files=["res://.godot/imported/default_layout.png-a47640974316a5f7b34cacd043d7a869.ctex"]
source_file="res://addons/dialogic/Modules/DefaultStyles/Default/preview.png"
dest_files=["res://.godot/imported/preview.png-1f03b89100d0ad1c91555207cc3d6207.ctex"]

[params]

Expand Down
5 changes: 5 additions & 0 deletions addons/dialogic/Modules/DefaultStyles/Default/style.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[style]
name = "Visual Novel"
author = "Jowan Spooner"
description = "The default scene. Supports all events and settings."
scene = "DialogicDefaultLayout.tscn"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bnc5unptt5uod"
path="res://.godot/imported/rpg_box1.png-f258532cdd277aa34caa0fdfca595504.ctex"
path="res://.godot/imported/preview.png-26e1db82aeba4ab35313659ee348c2e8.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/dialogic/Modules/DefaultStyles/rpg_box1.png"
dest_files=["res://.godot/imported/rpg_box1.png-f258532cdd277aa34caa0fdfca595504.ctex"]
source_file="res://addons/dialogic/Modules/DefaultStyles/RPG_BoxPortrait/preview.png"
dest_files=["res://.godot/imported/preview.png-26e1db82aeba4ab35313659ee348c2e8.ctex"]

[params]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[style]
name = "RPG Single Portrait"
author = "Jowan Spooner"
description = "An example RPG layout. Comes with only 1 portrait position (intended to be used with RPG-portrait mode)."
scene = "DialogicRPGLayout.tscn"
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bf4h16wsj1gc5"
path="res://.godot/imported/textbubble.png-f64e193c29d4a1327329c2b111d7f1ff.ctex"
path="res://.godot/imported/preview.png-af64fc5a61a1152f3e800d52664a3106.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/dialogic/Modules/DefaultStyles/textbubble.png"
dest_files=["res://.godot/imported/textbubble.png-f64e193c29d4a1327329c2b111d7f1ff.ctex"]
source_file="res://addons/dialogic/Modules/DefaultStyles/TextBubble/preview.png"
dest_files=["res://.godot/imported/preview.png-af64fc5a61a1152f3e800d52664a3106.ctex"]

[params]

Expand Down
5 changes: 5 additions & 0 deletions addons/dialogic/Modules/DefaultStyles/TextBubble/style.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[style]
name = "Text Bubble"
author = "Jowan Spooner"
description = "An example textbubble. Only supports basic text and choice interactions (no portraits, text input, etc.)."
scene = "DialogicTextBubbleLayout.tscn"
27 changes: 1 addition & 26 deletions addons/dialogic/Modules/DefaultStyles/index.gd
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
extends DialogicIndexer

func _get_layout_scenes() -> Array[Dictionary]:
return [
{
'name': 'Visual Novel',
'path': this_folder.path_join('/Default/DialogicDefaultLayout.tscn'),
'author': 'Jowan Spooner',
'description': "The default scene. Supports all events and settings.",
'preview_image': [this_folder.path_join('default_layout.png')],
'folder_to_copy': this_folder.path_join('/Default'),
},
{
'name': 'Text Bubble',
'path': this_folder.path_join('TextBubble/DialogicTextBubbleLayout.tscn'),
'author': 'Jowan Spooner',
'description': "An example textbubble. Only supports basic text and choice interactions (no portraits, text input, etc.).",
'preview_image': [this_folder.path_join('textbubble.png')],
'folder_to_copy': this_folder.path_join('/TextBubble'),
},
{
'name': 'RPG Single Portrait',
'path': this_folder.path_join('RPG_BoxPortrait/DialogicRPGLayout.tscn'),
'author': 'Jowan Spooner',
'description': "An example RPG layout. Comes with only 1 portrait position (intended to be used with RPG-portrait mode).",
'preview_image': [this_folder.path_join('rpg_box1.png')],
'folder_to_copy': this_folder.path_join('/RPG_BoxPortrait'),
},
]
return scan_for_layouts()
29 changes: 29 additions & 0 deletions addons/dialogic/Other/index_class.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,32 @@ func _get_text_effects() -> Array[Dictionary]:
## Should return array of dictionaries with the same arguments as _get_text_effects()
func _get_text_modifiers() -> Array[Dictionary]:
return []


## Helper that allows scanning sub directories that might be styles
func scan_for_layouts() -> Array[Dictionary]:
var dir := DirAccess.open(this_folder)
var style_list :Array[Dictionary] = []
if !dir:
return style_list
dir.list_dir_begin()
var dir_name := dir.get_next()
while dir_name != "":
if !dir.current_is_dir() or !dir.file_exists(dir_name.path_join('style.cfg')):
dir_name = dir.get_next()
continue
var config := ConfigFile.new()
var config_path: String = this_folder.path_join(dir_name).path_join('style.cfg')
var default_image_path: String = this_folder.path_join(dir_name).path_join('preview.png')
config.load(config_path)
style_list.append(
{
'name': config.get_value('style', 'name', 'Unnamed Layout'),
'path': this_folder.path_join(dir_name).path_join(config.get_value('style', 'scene')),
'author': config.get_value('style', 'author', 'Anonymous'),
'description': config.get_value('style', 'descriptin', 'No description'),
'preview_image': [config.get_value('style', 'image', default_image_path)]
})
dir_name = dir.get_next()

return style_list