Skip to content

Commit

Permalink
Grammar Tables Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggyMantis committed Nov 1, 2024
1 parent ed90618 commit 32c19b2
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 71 deletions.
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config_version=5

config/name="Glossorola"
config/description="Glossorola is a desktop app for the creation of constructed languages. by GiggyMantis"
config/version="1.2.1-beta"
config/version="1.3.0-beta"
run/main_scene="res://scenes/control.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")
config/icon="res://icon.svg"
Expand Down
123 changes: 70 additions & 53 deletions scenes/control.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
[ext_resource type="Texture2D" uid="uid://b8nrxeivn87uy" path="res://textures/image.svg" id="4_ofq1y"]
[ext_resource type="Script" path="res://scripts/DictionaryContainer.gd" id="5_bcwqd"]
[ext_resource type="Script" path="res://scripts/PhonologyContainer.gd" id="6_0ik07"]
[ext_resource type="Script" path="res://scripts/GrammarContainer.gd" id="6_puf5r"]
[ext_resource type="PackedScene" uid="uid://ddlijlo3awa1" path="res://scenes/table/table.tscn" id="7_7j8ct"]
[ext_resource type="PackedScene" uid="uid://05awvkbxe17w" path="res://scenes/table/background.tscn" id="8_1jxy8"]
[ext_resource type="Script" path="res://scripts/SoundChangeTool.gd" id="8_3i30n"]
[ext_resource type="Script" path="res://scripts/DataFrame.gd" id="8_kierl"]
[ext_resource type="Script" path="res://scripts/IPAKeyboardTool.gd" id="9_f2pyp"]

[sub_resource type="Resource" id="Resource_628lb"]
script = ExtResource("8_kierl")
data = [["Hello"]]
columns = PackedStringArray("Test")

[node name="Control" type="Control" node_paths=PackedStringArray("open_file_button", "save_file_button", "new_project_button", "translation_settings", "part_of_speech_list")]
[node name="Control" type="Control" node_paths=PackedStringArray("open_file_button", "save_file_button", "new_project_button", "translation_settings", "part_of_speech_list", "grammar_tables")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
Expand All @@ -28,7 +24,8 @@ open_file_button = NodePath("TabManager/HOME_MENU/OPEN_FILE")
save_file_button = NodePath("TabManager/HOME_MENU/SAVE_FILE")
new_project_button = NodePath("TabManager/HOME_MENU/NEW_PROJECT")
translation_settings = NodePath("TabManager/HOME_MENU/TranslationSettings")
part_of_speech_list = NodePath("TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/PartOfSpeechList")
part_of_speech_list = NodePath("TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/PartOfSpeechList")
grammar_tables = NodePath("TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_TABLES/ScrollContainer/GrammarContainer")

[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
Expand Down Expand Up @@ -224,33 +221,34 @@ delete_button = NodePath("../../DictionaryRemove")
layout_mode = 2
metadata/_tab_index = 3

[node name="ScrollContainer" type="ScrollContainer" parent="TabManager/GRAMMAR_MODULE"]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.01
anchor_top = -4.054
anchor_right = 0.01
anchor_bottom = -4.054
offset_left = -11.52
offset_top = 61.486
offset_right = 1140.48
offset_bottom = 651.486
grow_horizontal = 2
grow_vertical = 2
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
[node name="TabContainer" type="TabContainer" parent="TabManager/GRAMMAR_MODULE"]
layout_mode = 0
offset_right = 1152.0
offset_bottom = 40.0
current_tab = 1

[node name="ScrollControl" type="Control" parent="TabManager/GRAMMAR_MODULE/ScrollContainer"]
custom_minimum_size = Vector2(0, 2000)
[node name="GRAMMAR_INFORMATION" type="Control" parent="TabManager/GRAMMAR_MODULE/TabContainer"]
visible = false
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
metadata/_tab_index = 0

[node name="PartOfSpeechList" type="TextEdit" parent="TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl"]
[node name="BriefGrammarbook" type="TextEdit" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION"]
layout_mode = 2
offset_left = 80.0
offset_right = 430.0
offset_bottom = 500.0
offset_left = 500.0
offset_top = 25.0
offset_right = 1130.0
offset_bottom = 555.0
tooltip_text = "BRIEF_GRAMMAR_OVERVIEW_TOOLTIP"
placeholder_text = "BRIEF_GRAMMAR_OVERVIEW_TOOLTIP"

[node name="PartOfSpeechList" type="TextEdit" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION"]
layout_mode = 2
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 35.0
offset_top = 25.0
offset_right = -687.0
offset_bottom = 546.0
tooltip_text = "ADD_WORD_CLASS"
text = "noun
adjective
Expand All @@ -263,13 +261,36 @@ pronoun
phrase"
placeholder_text = "ADD_WORD_CLASS"

[node name="BriefGrammarOverview" type="TextEdit" parent="TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl"]
[node name="GRAMMAR_TABLES" type="Control" parent="TabManager/GRAMMAR_MODULE/TabContainer"]
layout_mode = 2
offset_left = 500.0
offset_right = 1100.0
offset_bottom = 500.0
tooltip_text = "BRIEF_GRAMMAR_OVERVIEW_TOOLTIP"
placeholder_text = "BRIEF_GRAMMAR_OVERVIEW_TOOLTIP"
size_flags_horizontal = 3
size_flags_vertical = 3
metadata/_tab_index = 1

[node name="Lock" type="CheckButton" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_TABLES"]
layout_mode = 0
offset_left = 7.0
offset_top = 534.0
offset_right = 96.0
offset_bottom = 565.0
text = "LOCK"

[node name="NewTable" type="Button" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_TABLES"]
layout_mode = 0
offset_left = 108.0
offset_top = 534.0
offset_right = 126.0
offset_bottom = 565.0
text = "+"

[node name="ScrollContainer" type="ScrollContainer" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_TABLES"]
layout_mode = 0
offset_right = 1152.0
offset_bottom = 520.0

[node name="GrammarContainer" type="GridContainer" parent="TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_TABLES/ScrollContainer"]
layout_mode = 2
script = ExtResource("6_puf5r")

[node name="PHONOLOGY_MODULE" type="Control" parent="TabManager"]
visible = false
Expand All @@ -282,17 +303,15 @@ anchors_preset = 0
offset_bottom = 553.0
script = ExtResource("6_0ik07")

[node name="Background" type="Panel" parent="TabManager/PHONOLOGY_MODULE/Vowels"]
layout_mode = 1
offset_left = 37.0
offset_top = 71.0
offset_right = 562.0
offset_bottom = 571.0
[node name="Background" parent="TabManager/PHONOLOGY_MODULE/Vowels" instance=ExtResource("8_1jxy8")]
layout_mode = 0
offset_left = 35.0
offset_top = 50.0
offset_right = 485.0
offset_bottom = 500.0

[node name="Table" parent="TabManager/PHONOLOGY_MODULE/Vowels/Background" instance=ExtResource("7_7j8ct")]
layout_mode = 1
data = SubResource("Resource_628lb")
editable = true

[node name="Consonants" type="Control" parent="TabManager/PHONOLOGY_MODULE"]
layout_mode = 1
Expand All @@ -303,17 +322,15 @@ offset_bottom = 553.0
grow_horizontal = 2
script = ExtResource("6_0ik07")

[node name="Background" type="Panel" parent="TabManager/PHONOLOGY_MODULE/Consonants"]
layout_mode = 1
offset_left = 12.0
offset_top = 71.0
offset_right = 537.0
offset_bottom = 571.0
[node name="Background" parent="TabManager/PHONOLOGY_MODULE/Consonants" instance=ExtResource("8_1jxy8")]
layout_mode = 0
offset_left = 35.0
offset_top = 50.0
offset_right = 485.0
offset_bottom = 500.0

[node name="Table" parent="TabManager/PHONOLOGY_MODULE/Consonants/Background" instance=ExtResource("7_7j8ct")]
layout_mode = 1
data = SubResource("Resource_628lb")
editable = true

[node name="Lock" type="CheckButton" parent="TabManager/PHONOLOGY_MODULE"]
layout_mode = 0
Expand Down
8 changes: 8 additions & 0 deletions scenes/table/background.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_scene format=3 uid="uid://05awvkbxe17w"]

[node name="Background" type="Panel"]
custom_minimum_size = Vector2(250, 250)
offset_left = 37.0
offset_top = 71.0
offset_right = 562.0
offset_bottom = 571.0
58 changes: 58 additions & 0 deletions scripts/GrammarContainer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
extends GridContainer

const TABLE_SIZE := Vector2(1152, 500)

var table = preload("res://scenes/table/table.tscn")
var background = preload("res://scenes/table/background.tscn")
@onready var lock_button = get_node("../../Lock")
@onready var new_table_button = get_node("../../NewTable")

func _ready():
lock_button.pressed.connect(self.lock)
new_table_button.pressed.connect(self._add_new_table)
reload()

func get_data() -> Array[Dictionary]:
var ret: Array[Dictionary]
for child in get_children():
ret.append(child.get_child(0).data._to_dictionary())
return ret

func from_data(data) -> void:
for child in get_children():
child.queue_free()
for d in data:
var t = table.instantiate()
t.data = DataFrame._from_dictionary(d)
t.editable = not lock_button.button_pressed
t.render()
var b = background.instantiate()
b.custom_minimum_size = TABLE_SIZE
b.add_child(t)
add_child(b)

func lock():
for child in get_children():
child.get_child(0).editable = not lock_button.button_pressed
child.get_child(0).render()

func reload():
lock_button.button_pressed = false

for child in get_children():
child.queue_free()

func _add_new_table():
var columns = [TranslationServer.translate(&"NEW_GRAMMAR_TABLE") as String]
var data = [
[""]
]
var t = table.instantiate()
t.data = DataFrame.New(data, columns)
t.editable = not lock_button.button_pressed
t.render()
var b = background.instantiate()
b.custom_minimum_size = TABLE_SIZE
b.add_child(t)
add_child(b)

37 changes: 29 additions & 8 deletions scripts/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extends Control
@export var new_project_button: Button
@export var translation_settings: OptionButton
@export var part_of_speech_list: TextEdit
@export var grammar_tables: GridContainer

const DEFAULT_PARTS_OF_SPEECH = "noun
adjective
Expand Down Expand Up @@ -32,6 +33,9 @@ func _ready():
$TabManager.current_tab = 0


func get_grammar_tables():
return grammar_tables.get_data()

func get_parts_of_speech():
return part_of_speech_list.text.split("\n")

Expand Down Expand Up @@ -64,9 +68,10 @@ func _new_project():
$TabManager/PROJECT_MENU/NameOfLanguage.text = ""
$TabManager/PROJECT_MENU/Autonym.text = ""
$TabManager/PROJECT_MENU/Langtype.selected = 0
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/BriefGrammarOverview.text = ""
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text = ""
$TabManager/PHONOLOGY_MODULE/Vowels.reload()
$TabManager/PHONOLOGY_MODULE/Consonants.reload()
grammar_tables.reload()

_reload_parts_of_speech()
_reload_sound_changes()
Expand Down Expand Up @@ -139,7 +144,8 @@ func collate_data() -> Dictionary:
info["Project/LanguageType"] = $TabManager/PROJECT_MENU/Langtype.selected
info["Project/Dictionary"] = %DictionaryContainer.save_data()
info["Grammar/PartsOfSpeech"] = get_parts_of_speech()
info["Grammar/BriefGrammarbook"] = $TabManager/GRAMMAR_MODULE/BriefGrammarOverview.text
info["Grammar/BriefGrammarbook"] = $TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text
info["Grammar/Tables"] = get_grammar_tables()
info["SCA/Categories"] = $TabManager/SOUND_CHANGE_TOOL/Categories.text
info["SCA/Rewrite"] = $TabManager/SOUND_CHANGE_TOOL/RewriteRules.text
info["SCA/Rules"] = $TabManager/SOUND_CHANGE_TOOL/SoundChanges.text
Expand All @@ -153,13 +159,28 @@ func load_data(info: Dictionary):
var minor_version = info["Version"].substr(0,4)
if info["Version"].ends_with("-beta"):
match minor_version:
"1.3.":
$TabManager/PROJECT_MENU/NameOfLanguage.text = info["Project/LanguageName"]
$TabManager/PROJECT_MENU/Autonym.text = info["Project/Autonym"]
$TabManager/PROJECT_MENU/Langtype.selected = info["Project/LanguageType"]
%DictionaryContainer.reload(info["Project/Dictionary"])
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/PartOfSpeechList.text = "\n".join(info["Grammar/PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text = info["Grammar/BriefGrammarbook"]
grammar_tables.from_data(info["Grammar/Tables"])
$TabManager/SOUND_CHANGE_TOOL/Categories.text = info["SCA/Categories"]
$TabManager/SOUND_CHANGE_TOOL/RewriteRules.text = info["SCA/Rewrite"]
$TabManager/SOUND_CHANGE_TOOL/SoundChanges.text = info["SCA/Rules"]
$TabManager/SOUND_CHANGE_TOOL/RewriteOnOutput.button_pressed = info["SCA/RewriteOnOutput"]
$TabManager/PHONOLOGY_MODULE/Lock.button_pressed = info["Phonology/Lock"]
$TabManager/PHONOLOGY_MODULE/Vowels.from_data(info["Phonology/Vowels"])
$TabManager/PHONOLOGY_MODULE/Consonants.from_data(info["Phonology/Consonants"])
"1.2.":
$TabManager/PROJECT_MENU/NameOfLanguage.text = info["Project/LanguageName"]
$TabManager/PROJECT_MENU/Autonym.text = info["Project/Autonym"]
$TabManager/PROJECT_MENU/Langtype.selected = info["Project/LanguageType"]
%DictionaryContainer.reload(info["Project/Dictionary"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/PartOfSpeechList.text = "\n".join(info["Grammar/PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/BriefGrammarOverview.text = info["Grammar/BriefGrammarbook"]
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/PartOfSpeechList.text = "\n".join(info["Grammar/PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text = info["Grammar/BriefGrammarbook"]
$TabManager/SOUND_CHANGE_TOOL/Categories.text = info["SCA/Categories"]
$TabManager/SOUND_CHANGE_TOOL/RewriteRules.text = info["SCA/Rewrite"]
$TabManager/SOUND_CHANGE_TOOL/SoundChanges.text = info["SCA/Rules"]
Expand All @@ -172,8 +193,8 @@ func load_data(info: Dictionary):
$TabManager/PROJECT_MENU/Autonym.text = info["Project/Autonym"]
$TabManager/PROJECT_MENU/Langtype.selected = info["Project/LanguageType"]
%DictionaryContainer.reload(info["Project/Dictionary"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/PartOfSpeechList.text = "\n".join(info["Grammar/PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/BriefGrammarOverview.text = info["Grammar/BriefGrammarbook"]
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/PartOfSpeechList.text = "\n".join(info["Grammar/PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text = info["Grammar/BriefGrammarbook"]
$TabManager/SOUND_CHANGE_TOOL/Categories.text = info["SCA/Categories"]
$TabManager/SOUND_CHANGE_TOOL/RewriteRules.text = info["SCA/Rewrite"]
$TabManager/SOUND_CHANGE_TOOL/SoundChanges.text = info["SCA/Rules"]
Expand All @@ -183,8 +204,8 @@ func load_data(info: Dictionary):
$TabManager/PROJECT_MENU/Autonym.text = info["Autonym"]
$TabManager/PROJECT_MENU/Langtype.selected = info["LanguageType"]
%DictionaryContainer.reload(info["Dictionary"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/PartOfSpeechList.text = "\n".join(info["PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/ScrollContainer/ScrollControl/BriefGrammarOverview.text = ""
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/PartOfSpeechList.text = "\n".join(info["PartsOfSpeech"])
$TabManager/GRAMMAR_MODULE/TabContainer/GRAMMAR_INFORMATION/BriefGrammarbook.text = ""
else:
match minor_version:
_:
Expand Down
9 changes: 6 additions & 3 deletions scripts/PhonologyContainer.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
extends Node

@onready var lock_button = get_node("../Lock")

func _ready():
get_node("../Lock").pressed.connect(self.lock)
lock_button.pressed.connect(self.lock)
reload()

func get_data() -> Dictionary:
Expand All @@ -12,11 +14,11 @@ func from_data(data: Dictionary) -> void:
$Background/Table.render()

func lock():
$Background/Table.editable = not get_node("../Lock").button_pressed
$Background/Table.editable = not lock_button.button_pressed
$Background/Table.render()

func reload():
get_node("../Lock").button_pressed = false
lock_button.button_pressed = false

var columns = [name]
var data = [
Expand All @@ -25,3 +27,4 @@ func reload():

$Background/Table.data = DataFrame.New(data, columns)
$Background/Table.render()
$Background/Table.editable = not lock_button.button_pressed
Loading

0 comments on commit 32c19b2

Please sign in to comment.