Add addons

This commit is contained in:
Joey Yakimowich-Payne 2023-01-03 16:53:53 -07:00
commit 3367bad24f
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
527 changed files with 36197 additions and 0 deletions

View file

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.9645 2.62927L12.8459 5.22444C12.6271 5.04546 12.3835 4.89134 12.1151 4.76208C11.8565 4.62287 11.5881 4.55327 11.3097 4.55327C11.0909 4.55327 10.8821 4.59802 10.6832 4.68751C10.4943 4.77699 10.3203 4.89631 10.1612 5.04546C10.0021 5.19461 9.86293 5.36364 9.74361 5.55256C9.6243 5.73154 9.52486 5.91052 9.44532 6.08949L9.14702 6.93964C9.35583 7.37714 9.55966 7.79475 9.75853 8.19248C9.92756 8.53055 10.1016 8.87359 10.2805 9.2216C10.4595 9.55966 10.6087 9.82813 10.728 10.027C10.9169 10.3153 11.1058 10.6136 11.2948 10.9219C11.4837 11.2202 11.6925 11.4936 11.9212 11.7422C12.0206 11.8516 12.1399 11.9261 12.2791 11.9659C12.4283 11.9957 12.5625 12.0107 12.6818 12.0107C12.8707 12.0107 13.0497 11.9858 13.2188 11.9361C13.3878 11.8864 13.5469 11.8217 13.696 11.7422L14.0689 12.2195C13.9297 12.4382 13.7607 12.657 13.5618 12.8757C13.3629 13.0945 13.1442 13.2933 12.9055 13.4723C12.6769 13.6513 12.4283 13.7955 12.1598 13.9048C11.9013 14.0242 11.6378 14.0838 11.3693 14.0838C11.1307 14.0838 10.9169 14.044 10.728 13.9645C10.549 13.8949 10.3849 13.8004 10.2358 13.6811C10.0867 13.5519 9.94745 13.4027 9.81819 13.2337C9.68893 13.0646 9.55469 12.8906 9.41549 12.7117C9.30611 12.5426 9.1868 12.3388 9.05753 12.1001C8.93822 11.8516 8.81393 11.598 8.68466 11.3395C8.5554 11.081 8.42614 10.8324 8.29688 10.5938C8.16762 10.3452 8.04333 10.1364 7.92401 9.96734C7.8743 10.1364 7.82955 10.3054 7.78978 10.4744C7.75001 10.6136 7.70526 10.7578 7.65555 10.907C7.60583 11.0561 7.56109 11.1705 7.52131 11.25C7.37216 11.5682 7.18324 11.8963 6.95455 12.2344C6.72586 12.5724 6.46236 12.8807 6.16407 13.1591C5.87572 13.4276 5.55753 13.6513 5.20952 13.8303C4.86151 13.9993 4.49361 14.0838 4.10583 14.0838C3.75782 14.0838 3.41975 14.0142 3.09162 13.875C2.7635 13.7457 2.46023 13.5717 2.18182 13.353L3.12145 10.8771C3.43964 11.076 3.78765 11.255 4.16549 11.4141C4.54333 11.5632 4.92117 11.6378 5.29901 11.6378C5.41833 11.6378 5.54262 11.6278 5.67188 11.608C5.80114 11.5781 5.92543 11.5384 6.04475 11.4886C6.17401 11.429 6.28836 11.3594 6.38779 11.2798C6.48722 11.1903 6.5618 11.0859 6.61151 10.9666C6.68111 10.8374 6.75569 10.6683 6.83523 10.4595C6.91478 10.2507 6.99432 10.0419 7.07387 9.8331C7.16336 9.59447 7.25285 9.34091 7.34234 9.07245L4.53836 4.5831C4.4091 4.43395 4.25001 4.31464 4.06109 4.22515C3.88211 4.12572 3.69319 4.076 3.49432 4.076C3.32529 4.076 3.1662 4.1108 3.01705 4.1804C2.8679 4.24006 2.72373 4.32458 2.58452 4.43395L2.18182 3.91194C2.32103 3.70313 2.48509 3.4993 2.67401 3.30043C2.87287 3.09162 3.08665 2.90768 3.31535 2.74859C3.54404 2.57955 3.78765 2.44532 4.04617 2.34589C4.30469 2.23651 4.56819 2.18182 4.83665 2.18182C5.16478 2.18182 5.46805 2.26634 5.74645 2.43537C6.02486 2.59447 6.28339 2.79333 6.52202 3.03197C6.76066 3.2706 6.97941 3.52912 7.17827 3.80753C7.37714 4.08594 7.55611 4.34447 7.7152 4.5831C7.79475 4.69248 7.87927 4.83168 7.96876 5.00072C8.06819 5.15981 8.16265 5.3189 8.25214 5.47799C8.36151 5.65697 8.46591 5.85086 8.56535 6.05966C8.66478 5.82103 8.76918 5.58239 8.87856 5.34376C8.96805 5.14489 9.05753 4.94106 9.14702 4.73225C9.24645 4.5135 9.33594 4.32458 9.41549 4.16549C9.56464 3.88708 9.73367 3.62856 9.92259 3.38992C10.1115 3.15128 10.3203 2.94248 10.549 2.7635C10.7876 2.58452 11.0462 2.44532 11.3246 2.34589C11.603 2.23651 11.9063 2.18182 12.2344 2.18182C12.5426 2.18182 12.8409 2.2216 13.1293 2.30114C13.4176 2.38069 13.696 2.49006 13.9645 2.62927Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://580n3xtnq3ru"
path="res://.godot/imported/definition.svg-031b12c360f1060f573315dfb3d273d8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Events/Glossary/definition.svg"
dest_files=["res://.godot/imported/definition.svg-031b12c360f1060f573315dfb3d273d8.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View file

@ -0,0 +1,43 @@
@tool
class_name DialogicGlossaryEvent
extends DialogicEvent
## Event that does nothing right now.
################################################################################
## EXECUTE
################################################################################
func _execute() -> void:
pass
################################################################################
## INITIALIZE
################################################################################
func _init() -> void:
event_name = "Glossary"
set_default_color('Color6')
event_category = Category.AudioVisual
event_sorting_index = 0
expand_by_default = false
################################################################################
## SAVING/LOADING
################################################################################
func get_shortcode() -> String:
return "glossary"
func get_shortcode_parameters() -> Dictionary:
return {
}
################################################################################
## EDITOR REPRESENTATION
################################################################################
func build_event_editor():
pass

View file

@ -0,0 +1,11 @@
class_name DialogicGlossary
extends Resource
## Resource used to store glossary entries. Can be saved to disc and used as a glossary.
## Add/create glossaries fom the settings
## Stores all entry information
@export var entries :Dictionary = {}
## If false, no entries from this glossary will be shown
@export var enabled :bool = true

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b6wqvg2qcjxs"
path="res://.godot/imported/icon.png-624eb6dbf7e3ab27845a397653fa2fbb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Events/Glossary/icon.png"
dest_files=["res://.godot/imported/icon.png-624eb6dbf7e3ab27845a397653fa2fbb.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,13 @@
@tool
extends DialogicIndexer
func _get_events() -> Array:
return [this_folder.path_join('event_glossary.gd')]
func _get_subsystems() -> Array:
return [{'name':'Glossary', 'script':this_folder.path_join('subsystem_glossary.gd')}]
func _get_settings_pages() -> Array:
return [this_folder.path_join('settings_glossary.tscn')]

View file

@ -0,0 +1,210 @@
@tool
extends VBoxContainer
var current_glossary :DialogicGlossary = null
var current_entry_name := ""
################################################################################
## BASICS
################################################################################
func _ready() -> void:
%AddGlossaryFile.icon = get_theme_icon('Add', 'EditorIcons')
%LoadGlossaryFile.icon = get_theme_icon('Folder', 'EditorIcons')
%DeleteGlossaryFile.icon = get_theme_icon('Remove', 'EditorIcons')
%DeleteGlossaryEntry.icon = get_theme_icon('Remove', 'EditorIcons')
%AddGlossaryEntry.icon = get_theme_icon('Add', 'EditorIcons')
%GlossaryList.item_selected.connect(_on_GlossaryList_item_selected)
%EntryList.item_selected.connect(_on_EntryList_item_selected)
%DefaultColor.color_changed.connect(set_setting.bind('dialogic/glossary/default_color'))
%DefaultCaseSensitive.toggled.connect(set_setting.bind('dialogic/glossary/default_case_sensitive'))
func set_setting(value, setting:String) -> void:
ProjectSettings.set_setting(setting, value)
ProjectSettings.save()
func refresh() -> void:
%DefaultColor.color = DialogicUtil.get_project_setting('dialogic/glossary/default_color', Color.POWDER_BLUE)
%DefaultCaseSensitive.button_pressed = DialogicUtil.get_project_setting('dialogic/glossary/default_case_sensitive', true)
%GlossaryList.clear()
var idx := 0
for file in DialogicUtil.get_project_setting('dialogic/glossary/glossary_files', []):
if FileAccess.file_exists(file):
%GlossaryList.add_item(DialogicUtil.pretty_name(file), get_theme_icon('FileList', 'EditorIcons'))
else:
%GlossaryList.add_item(DialogicUtil.pretty_name(file), get_theme_icon('FileDead', 'EditorIcons'))
%GlossaryList.set_item_tooltip(idx, file)
idx += 1
%EntryList.clear()
if %GlossaryList.item_count != 0:
%GlossaryList.select(0)
_on_GlossaryList_item_selected(0)
else:
current_glossary = null
hide_entry_editor()
################################################################################
## GLOSSARY LIST
################################################################################
func _on_GlossaryList_item_selected(idx:int) -> void:
%EntryList.clear()
if FileAccess.file_exists(%GlossaryList.get_item_tooltip(idx)):
current_glossary = load(%GlossaryList.get_item_tooltip(idx))
if not current_glossary is DialogicGlossary:
return
for entry in current_glossary.entries:
%EntryList.add_item(entry)
if %EntryList.item_count != 0:
%EntryList.select(0)
_on_EntryList_item_selected(0)
else:
hide_entry_editor()
func _on_add_glossary_file_pressed() -> void:
find_parent('EditorView').godot_file_dialog(create_new_glossary_file, '*.tres', EditorFileDialog.FILE_MODE_SAVE_FILE, 'Create new glossary resource')
func create_new_glossary_file(path:String) -> void:
var glossary := DialogicGlossary.new()
glossary.resource_path = path
ResourceSaver.save(glossary, path)
load_glossary_file(path)
func _on_load_glossary_file_pressed() -> void:
find_parent('EditorView').godot_file_dialog(load_glossary_file, '*.tres', EditorFileDialog.FILE_MODE_OPEN_FILE, 'Select glossary resource')
func load_glossary_file(path:String) -> void:
var list :Array= DialogicUtil.get_project_setting('dialogic/glossary/glossary_files', [])
if not path in list:
list.append(path)
ProjectSettings.set_setting('dialogic/glossary/glossary_files', list)
ProjectSettings.save()
%GlossaryList.add_item(DialogicUtil.pretty_name(path), get_theme_icon('FileList', 'EditorIcons'))
%GlossaryList.set_item_tooltip(%GlossaryList.item_count-1, path)
%GlossaryList.select(%GlossaryList.item_count-1)
_on_GlossaryList_item_selected(%GlossaryList.item_count-1)
func _on_delete_glossary_file_pressed() -> void:
if len(%GlossaryList.get_selected_items()) != 0:
var list :Array = DialogicUtil.get_project_setting('dialogic/glossary/glossary_files', [])
list.erase(%GlossaryList.get_item_tooltip(
%GlossaryList.get_selected_items()[0]))
ProjectSettings.set_setting('dialogic/glossary/glossary_files', list)
ProjectSettings.save()
refresh()
################################################################################
## ENTRY LIST
################################################################################
func _on_EntryList_item_selected(idx:int) -> void:
current_entry_name = %EntryList.get_item_text(idx)
var entry_info = current_glossary.entries[current_entry_name]
%EntryEditorTitle.text = "Edit entry"
%EntrySettings.show()
%EntryName.text = current_entry_name
%EntryCaseSensitive.button_pressed = entry_info.get('case_sensitive', %DefaultCaseSensitive.button_pressed)
var alts = ""
for i in entry_info.get('alternatives', []):
alts += i+", "
%EntryAlternatives.text = alts
%EntryTitle.text = entry_info.get('title', '')
%EntryText.text = entry_info.get('text', '')
%EntryExtra.text = entry_info.get('extra', '')
%EntryEnabled.button_pressed = entry_info.get('enabled', true)
%EntryColor.color = entry_info.get('color', %DefaultColor.color)
%EntryCustomColor.button_pressed = entry_info.has('color')
%EntryColor.disabled = !entry_info.has('color')
func _on_add_glossary_entry_pressed() -> void:
if !current_glossary:
return
var new_name := "New Entry"
if new_name in current_glossary.entries:
var count := 2
while new_name + " " +str(count) in current_glossary.entries:
count += 1
new_name += " " + str(count)
current_glossary.entries[new_name] = {}
ResourceSaver.save(current_glossary)
%EntryList.add_item(new_name)
%EntryList.select(%EntryList.item_count-1)
_on_EntryList_item_selected(%EntryList.item_count-1)
func _on_delete_glossary_entry_pressed() -> void:
if len(%EntryList.get_selected_items()) != 0:
if current_glossary:
current_glossary.entries.erase(%EntryList.get_item_text(
%EntryList.get_selected_items()[0]))
%EntryList.remove_item(%EntryList.get_selected_items()[0])
################################################################################
## ENTRY EDITOR
################################################################################
func hide_entry_editor() -> void:
%EntrySettings.hide()
%EntryEditorTitle.text = "No entry selected."
func _on_entry_name_text_changed(new_text:String) -> void:
if current_entry_name != new_text.strip_edges():
if new_text.strip_edges().is_empty() or new_text.strip_edges() in current_glossary.entries.keys():
%EntryList.set_item_custom_bg_color(%EntryList.get_selected_items()[0],
get_theme_color("warning_color", "Editor").darkened(0.8))
%EntryList.set_item_text(%EntryList.get_selected_items()[0], new_text.strip_edges() + " (invalid name)")
return
else:
%EntryList.set_item_custom_bg_color(%EntryList.get_selected_items()[0],
Color.TRANSPARENT)
var info :Dictionary = current_glossary.entries[current_entry_name]
current_glossary.entries.erase(current_entry_name)
current_glossary.entries[new_text.strip_edges()] = info
%EntryList.set_item_text(%EntryList.get_selected_items()[0], new_text.strip_edges())
current_entry_name = new_text.strip_edges()
ResourceSaver.save(current_glossary)
func _on_entry_case_sensitive_toggled(button_pressed:bool) -> void:
current_glossary.entries[current_entry_name]['case_sensitive'] = button_pressed
ResourceSaver.save(current_glossary)
func _on_entry_alternatives_text_changed(new_text:String) -> void:
var alts := []
for i in new_text.split(',', false):
alts.append(i.strip_edges())
current_glossary.entries[current_entry_name]['alternatives'] = alts
ResourceSaver.save(current_glossary)
func _on_entry_title_text_changed(new_text:String) -> void:
current_glossary.entries[current_entry_name]['title'] = new_text
ResourceSaver.save(current_glossary)
func _on_entry_text_text_changed() -> void:
current_glossary.entries[current_entry_name]['text'] = %EntryText.text
ResourceSaver.save(current_glossary)
func _on_entry_extra_text_changed() -> void:
current_glossary.entries[current_entry_name]['extra'] = %EntryExtra.text
ResourceSaver.save(current_glossary)
func _on_entry_enabled_toggled(button_pressed:bool) -> void:
current_glossary.entries[current_entry_name]['enabled'] = button_pressed
ResourceSaver.save(current_glossary)
func _on_entry_custom_color_toggled(button_pressed:bool) -> void:
%EntryColor.disabled = !button_pressed
if !button_pressed:
current_glossary.entries[current_entry_name].erase('color')
else:
current_glossary.entries[current_entry_name]['color'] = %EntryColor.color
func _on_entry_color_color_changed(color:Color) -> void:
current_glossary.entries[current_entry_name]['color'] = color
ResourceSaver.save(current_glossary)

View file

@ -0,0 +1,370 @@
[gd_scene load_steps=5 format=3]
[ext_resource type="Script" path="res://addons/dialogic/Events/Glossary/settings_glossary.gd" id="1_tf3p1"]
[ext_resource type="StyleBox" uid="uid://dmsjhgv22dns8" path="res://addons/dialogic/Editor/Common/TitleBgStylebox.tres" id="2_kj6gm"]
[sub_resource type="Image" id="Image_ruhry"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}
[sub_resource type="ImageTexture" id="ImageTexture_mi8la"]
image = SubResource("Image_ruhry")
[node name="GlossaryEditor" type="VBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource("1_tf3p1")
[node name="Entries" type="HBoxContainer" parent="."]
offset_right = 1024.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Settings" type="VBoxContainer" parent="Entries"]
offset_right = 371.0
offset_bottom = 600.0
size_flags_horizontal = 3
[node name="Title" type="Label" parent="Entries/Settings"]
offset_right = 371.0
offset_bottom = 36.0
size_flags_horizontal = 3
theme_override_styles/normal = ExtResource("2_kj6gm")
text = "Glossary Settings"
[node name="DefColor" type="HBoxContainer" parent="Entries/Settings"]
offset_top = 40.0
offset_right = 371.0
offset_bottom = 66.0
[node name="Label" type="Label" parent="Entries/Settings/DefColor"]
offset_right = 317.0
offset_bottom = 26.0
size_flags_horizontal = 3
text = "Default color"
[node name="DefaultColor" type="ColorPickerButton" parent="Entries/Settings/DefColor"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 0)
offset_left = 321.0
offset_right = 371.0
offset_bottom = 26.0
size_flags_horizontal = 8
[node name="DefCaseSensitive" type="HBoxContainer" parent="Entries/Settings"]
offset_top = 70.0
offset_right = 371.0
offset_bottom = 96.0
[node name="Label" type="Label" parent="Entries/Settings/DefCaseSensitive"]
offset_right = 343.0
offset_bottom = 26.0
size_flags_horizontal = 3
text = "Default case sensitive"
[node name="DefaultCaseSensitive" type="CheckBox" parent="Entries/Settings/DefCaseSensitive"]
unique_name_in_owner = true
offset_left = 347.0
offset_right = 371.0
offset_bottom = 26.0
[node name="FileList" type="VBoxContainer" parent="Entries/Settings"]
offset_top = 100.0
offset_right = 371.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
size_flags_stretch_ratio = 0.69
[node name="HBox" type="HBoxContainer" parent="Entries/Settings/FileList"]
offset_right = 371.0
offset_bottom = 36.0
[node name="Title2" type="Label" parent="Entries/Settings/FileList/HBox"]
offset_right = 218.0
offset_bottom = 36.0
size_flags_horizontal = 3
theme_override_styles/normal = ExtResource("2_kj6gm")
text = "Active Files"
[node name="LoadGlossaryFile" type="Button" parent="Entries/Settings/FileList/HBox"]
unique_name_in_owner = true
offset_left = 222.0
offset_right = 284.0
offset_bottom = 36.0
text = "Load"
icon = SubResource("ImageTexture_mi8la")
[node name="AddGlossaryFile" type="Button" parent="Entries/Settings/FileList/HBox"]
unique_name_in_owner = true
offset_left = 288.0
offset_right = 343.0
offset_bottom = 36.0
text = "Add"
icon = SubResource("ImageTexture_mi8la")
[node name="DeleteGlossaryFile" type="Button" parent="Entries/Settings/FileList/HBox"]
unique_name_in_owner = true
offset_left = 347.0
offset_right = 371.0
offset_bottom = 36.0
icon = SubResource("ImageTexture_mi8la")
[node name="ScrollContainer" type="ScrollContainer" parent="Entries/Settings/FileList"]
offset_top = 40.0
offset_right = 371.0
offset_bottom = 500.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="GlossaryList" type="ItemList" parent="Entries/Settings/FileList/ScrollContainer"]
unique_name_in_owner = true
offset_right = 371.0
offset_bottom = 460.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VSeparator2" type="VSeparator" parent="Entries"]
offset_left = 375.0
offset_right = 379.0
offset_bottom = 600.0
[node name="EntryList" type="VBoxContainer" parent="Entries"]
offset_left = 383.0
offset_right = 640.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.69
[node name="HBox" type="HBoxContainer" parent="Entries/EntryList"]
offset_right = 257.0
offset_bottom = 36.0
[node name="Title3" type="Label" parent="Entries/EntryList/HBox"]
offset_right = 125.0
offset_bottom = 36.0
size_flags_horizontal = 3
theme_override_styles/normal = ExtResource("2_kj6gm")
text = "Entries"
[node name="AddGlossaryEntry" type="Button" parent="Entries/EntryList/HBox"]
unique_name_in_owner = true
offset_left = 129.0
offset_right = 229.0
offset_bottom = 36.0
text = "Add Entry"
icon = SubResource("ImageTexture_mi8la")
[node name="DeleteGlossaryEntry" type="Button" parent="Entries/EntryList/HBox"]
unique_name_in_owner = true
offset_left = 233.0
offset_right = 257.0
offset_bottom = 36.0
icon = SubResource("ImageTexture_mi8la")
[node name="ScrollContainer" type="ScrollContainer" parent="Entries/EntryList"]
offset_top = 40.0
offset_right = 257.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="EntryList" type="ItemList" parent="Entries/EntryList/ScrollContainer"]
unique_name_in_owner = true
offset_right = 257.0
offset_bottom = 560.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VSeparator" type="VSeparator" parent="Entries"]
offset_left = 644.0
offset_right = 648.0
offset_bottom = 600.0
[node name="EntryEditor" type="ScrollContainer" parent="Entries"]
offset_left = 652.0
offset_right = 1024.0
offset_bottom = 600.0
size_flags_horizontal = 3
horizontal_scroll_mode = 0
metadata/_edit_layout_mode = 1
[node name="VBox" type="VBoxContainer" parent="Entries/EntryEditor"]
offset_right = 372.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="EntryEditorTitle" type="Label" parent="Entries/EntryEditor/VBox"]
unique_name_in_owner = true
offset_right = 372.0
offset_bottom = 36.0
size_flags_horizontal = 3
theme_override_styles/normal = ExtResource("2_kj6gm")
text = "Entries"
[node name="EntrySettings" type="GridContainer" parent="Entries/EntryEditor/VBox"]
unique_name_in_owner = true
offset_top = 40.0
offset_right = 372.0
offset_bottom = 600.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/h_separation = 13
columns = 2
[node name="Label2" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_right = 94.0
offset_bottom = 26.0
size_flags_vertical = 0
text = "Name"
[node name="HBoxContainer" type="HBoxContainer" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_left = 107.0
offset_right = 372.0
offset_bottom = 31.0
[node name="EntryName" type="LineEdit" parent="Entries/EntryEditor/VBox/EntrySettings/HBoxContainer"]
unique_name_in_owner = true
offset_right = 87.7656
offset_bottom = 31.0
size_flags_horizontal = 0
placeholder_text = "MyEntry"
expand_to_text_length = true
caret_blink = true
caret_blink_speed = 0.5
[node name="EntryCaseSensitive" type="CheckBox" parent="Entries/EntryEditor/VBox/EntrySettings/HBoxContainer"]
unique_name_in_owner = true
offset_left = 91.0
offset_right = 228.0
offset_bottom = 31.0
text = "Case sensitive"
[node name="Label3" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 35.0
offset_right = 94.0
offset_bottom = 61.0
size_flags_vertical = 0
text = "Alternatives"
[node name="EntryAlternatives" type="LineEdit" parent="Entries/EntryEditor/VBox/EntrySettings"]
unique_name_in_owner = true
offset_left = 107.0
offset_top = 35.0
offset_right = 372.0
offset_bottom = 66.0
size_flags_horizontal = 3
caret_blink = true
caret_blink_speed = 0.5
[node name="Label4" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 70.0
offset_right = 94.0
offset_bottom = 96.0
size_flags_vertical = 0
text = "Title"
[node name="EntryTitle" type="LineEdit" parent="Entries/EntryEditor/VBox/EntrySettings"]
unique_name_in_owner = true
offset_left = 107.0
offset_top = 70.0
offset_right = 372.0
offset_bottom = 101.0
size_flags_horizontal = 3
caret_blink = true
caret_blink_speed = 0.5
[node name="Label5" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 105.0
offset_right = 94.0
offset_bottom = 131.0
size_flags_vertical = 0
text = "Text"
[node name="EntryText" type="TextEdit" parent="Entries/EntryEditor/VBox/EntrySettings"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 100)
offset_left = 107.0
offset_top = 105.0
offset_right = 372.0
offset_bottom = 205.0
focus_next = NodePath("../EntryExtra")
wrap_mode = 1
[node name="Label6" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 209.0
offset_right = 94.0
offset_bottom = 235.0
size_flags_vertical = 0
text = "Extra"
[node name="EntryExtra" type="TextEdit" parent="Entries/EntryEditor/VBox/EntrySettings"]
unique_name_in_owner = true
custom_minimum_size = Vector2(0, 50)
offset_left = 107.0
offset_top = 209.0
offset_right = 372.0
offset_bottom = 259.0
wrap_mode = 1
[node name="Label8" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 263.0
offset_right = 94.0
offset_bottom = 289.0
size_flags_vertical = 0
text = "Enabled"
[node name="EntryEnabled" type="CheckBox" parent="Entries/EntryEditor/VBox/EntrySettings"]
unique_name_in_owner = true
offset_left = 107.0
offset_top = 263.0
offset_right = 372.0
offset_bottom = 289.0
button_pressed = true
[node name="Label7" type="Label" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_top = 293.0
offset_right = 94.0
offset_bottom = 319.0
size_flags_vertical = 0
text = "Color"
[node name="HBox" type="HBoxContainer" parent="Entries/EntryEditor/VBox/EntrySettings"]
offset_left = 107.0
offset_top = 293.0
offset_right = 372.0
offset_bottom = 319.0
[node name="EntryCustomColor" type="CheckBox" parent="Entries/EntryEditor/VBox/EntrySettings/HBox"]
unique_name_in_owner = true
offset_right = 24.0
offset_bottom = 26.0
[node name="EntryColor" type="ColorPickerButton" parent="Entries/EntryEditor/VBox/EntrySettings/HBox"]
unique_name_in_owner = true
offset_left = 28.0
offset_right = 265.0
offset_bottom = 26.0
size_flags_horizontal = 3
[connection signal="pressed" from="Entries/Settings/FileList/HBox/LoadGlossaryFile" to="." method="_on_load_glossary_file_pressed"]
[connection signal="pressed" from="Entries/Settings/FileList/HBox/AddGlossaryFile" to="." method="_on_add_glossary_file_pressed"]
[connection signal="pressed" from="Entries/Settings/FileList/HBox/DeleteGlossaryFile" to="." method="_on_delete_glossary_file_pressed"]
[connection signal="pressed" from="Entries/EntryList/HBox/AddGlossaryEntry" to="." method="_on_add_glossary_entry_pressed"]
[connection signal="pressed" from="Entries/EntryList/HBox/DeleteGlossaryEntry" to="." method="_on_delete_glossary_entry_pressed"]
[connection signal="text_changed" from="Entries/EntryEditor/VBox/EntrySettings/HBoxContainer/EntryName" to="." method="_on_entry_name_text_changed"]
[connection signal="toggled" from="Entries/EntryEditor/VBox/EntrySettings/HBoxContainer/EntryCaseSensitive" to="." method="_on_entry_case_sensitive_toggled"]
[connection signal="text_changed" from="Entries/EntryEditor/VBox/EntrySettings/EntryAlternatives" to="." method="_on_entry_alternatives_text_changed"]
[connection signal="text_changed" from="Entries/EntryEditor/VBox/EntrySettings/EntryTitle" to="." method="_on_entry_title_text_changed"]
[connection signal="text_changed" from="Entries/EntryEditor/VBox/EntrySettings/EntryText" to="." method="_on_entry_text_text_changed"]
[connection signal="text_changed" from="Entries/EntryEditor/VBox/EntrySettings/EntryExtra" to="." method="_on_entry_extra_text_changed"]
[connection signal="toggled" from="Entries/EntryEditor/VBox/EntrySettings/EntryEnabled" to="." method="_on_entry_enabled_toggled"]
[connection signal="toggled" from="Entries/EntryEditor/VBox/EntrySettings/HBox/EntryCustomColor" to="." method="_on_entry_custom_color_toggled"]
[connection signal="color_changed" from="Entries/EntryEditor/VBox/EntrySettings/HBox/EntryColor" to="." method="_on_entry_color_color_changed"]

View file

@ -0,0 +1,76 @@
extends DialogicSubsystem
## Subsystem that handles glossaries.
## List of glossary resources that are used.
var glossaries := []
## If false, no parsing will be done.
var enabled := true
####################################################################################################
## STATE
####################################################################################################
func clear_game_state() -> void:
glossaries = []
for path in DialogicUtil.get_project_setting('dialogic/glossary/glossary_files', []):
add_glossary(path)
####################################################################################################
## MAIN METHODS
####################################################################################################
func parse_glossary(text:String) -> String:
if !enabled: return text
var def_case_sensitive :bool = DialogicUtil.get_project_setting('dialogic/glossary/default_case_sensitive', true)
var def_color : Color= DialogicUtil.get_project_setting('dialogic/glossary/default_color', Color.POWDER_BLUE)
var regex := RegEx.new()
for glossary in glossaries:
if !glossary.enabled:
continue
for entry in glossary.entries.keys():
if !glossary.entries[entry].get('enabled', true):
continue
var pattern :String = '(?<=\\W|^)(?<word>'+glossary.entries[entry].get('regopts', entry)+')(?!])(?=\\W|$)'
if glossary.entries[entry].get('case_sensitive', def_case_sensitive):
regex.compile(pattern)
else:
regex.compile('(?i)'+pattern)
text = regex.sub(text,
'[url=' + entry + ']' +
'[color=' + glossary.entries[entry].get('color', def_color).to_html() + ']${word}[/color]' +
'[/url]', true
)
return text
func add_glossary(path:String) -> void:
if FileAccess.file_exists(path):
var x = load(path)
if x is DialogicGlossary:
glossaries.append(x)
for entry in x.entries.keys():
var regopts :String = entry
for i in x.entries[entry].get('alternatives', []):
regopts += '|'+i
x.entries[entry]['regopts'] = regopts
else:
printerr('[Dialogic] The glossary file "' + path + '" is missing. Make sure it exists.')
func get_entry(name:String, parse_variables:bool = true) -> Dictionary:
for glossary in glossaries:
if name in glossary.entries:
var info:Dictionary = glossary.entries[name].duplicate()
if parse_variables and Dialogic.has_subsystem('VAR'):
for key in info.keys():
if typeof(info[key]) == TYPE_STRING:
info[key] = Dialogic.VAR.parse_variables(info[key])
return info
return {}
func set_entry(name: String, value: Dictionary) -> bool:
return false