Skip to content

Commit cd96735

Browse files
committed
ModuleAssistant 2.0.0
* Added code preview for C++ * Refactoring code to have a more universal base between assistant features * Completely reorganized the GUI to be more organized yet compact * Beginning to add settings * Bump to Godot 4.3
1 parent 5006e60 commit cd96735

15 files changed

+527
-240
lines changed

header_label.tres

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_resource type="LabelSettings" format=3 uid="uid://bfq2fubl1lynw"]
2+
3+
[resource]
4+
font_size = 36
5+
shadow_color = Color(0, 0, 0, 1)
6+
shadow_offset = Vector2(3, 3)

project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config/name="Module Coding Assistant"
1414
config/description="A little tool that aids in writing C++ engine modules."
1515
config/tags=PackedStringArray("gui_tools")
1616
run/main_scene="res://scenes/gui.tscn"
17-
config/features=PackedStringArray("4.2", "GL Compatibility")
17+
config/features=PackedStringArray("4.3", "GL Compatibility")
1818
config/icon="res://icon.svg"
1919

2020
[rendering]

scenes/gdscript_to_cpp.tscn

Lines changed: 0 additions & 22 deletions
This file was deleted.

scenes/gui.gd

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
extends Control
2+
3+
class_name AppRoot
4+
5+
6+
class VariableData:
7+
extends Resource
8+
##The name of the variable
9+
var var_name:String
10+
#The numeric Variant.Type enum value
11+
var type:int
12+
##The type of the variable, eg. "int", "Node3D", etc.
13+
var type_string:String
14+
15+
var type_enum_string:String
16+
17+
var hint_type:int
18+
19+
var hint_string:String
20+
21+
var usage_bitfield:int
22+
23+
func _init(info:Dictionary = {}) -> void:
24+
type = info.get("type", 0)
25+
26+
pass
27+
28+
#literally 4 spaces
29+
const a_tab:String = " "
30+
31+
#Class things
32+
const class_filename:String = "{class_name_}.cpp"
33+
const class_declaration:String = "class {class_name_}: public {inherits}{"
34+
const class_var_get:String = " {var_type} get_{var_name}();\n"
35+
const class_var_set:String = " void set_{var_name}({var_type} new_{var_name}); \n"
36+
37+
#Variable setgets
38+
const var_setget_filename:String = "{class_name_}_set_gets.cpp"
39+
const var_setget_get:String = "{var_type} {class_name_}::get_{var_name}(){\n return {var_name};\n}\n"
40+
const var_setget_set:String = "void {class_name_}::set_{var_name}({var_type} new_{var_name}){\n {var_name} = new_{var_name};\n}\n"
41+
42+
#Variable bindings
43+
const var_bind_get:String = " ClassDB::bind_method(D_METHOD(\"get_{var_name}\"), &{class_name_}::get_{var_name});\n"
44+
const var_bind_set:String = " ClassDB::bind_method(D_METHOD(\"set_{var_name}\", \"{var_name}\"), &{class_name_}::set_{var_name});\n"
45+
const var_bind_filename:String = "{class_name_}_bindings.cpp"
46+
47+
#Functions
48+
const func_declaration:String = " {var_type} {func_name}({func_params});\n"
49+
const func_param:String = "{var_type} {var_name}"
50+
const func_bind_args:String = " ClassDB::bind_method(D_METHOD(\"{function_name}\", \"{func_args}\"), &{class_name_}::{function_name});\n"
51+
const func_bind_no_arg:String = " ClassDB::bind_method(D_METHOD(\"{function_name}\"), &{class_name_}::{function_name});\n"
52+
53+
const variant_enum_strings_commmon:Dictionary = {
54+
"bool": "BOOL",
55+
"int": "INT",
56+
"float": "REAL",
57+
"String": "STRING",
58+
"Color": "COLOR",
59+
"NodePath": "NODE_PATH",
60+
"Vector2": "VECTOR2",
61+
"Vector3": "VECTOR3",
62+
}
63+
64+
const variant_enum_strings_4:Dictionary = {
65+
"StringName": "STRING_NAME",
66+
"Vector2i": "VECTOR2I",
67+
68+
"PackedByteArray": "PACKED_BYTE_ARRAY",
69+
"PackedInt32Array": "PACKED_INT32_ARRAY",
70+
"PackedFloat32Array": "PACKED_FLOAT32_ARRAY",
71+
}
72+
73+
const variant_enum_strings_3:Dictionary = {
74+
"StringName": "STRING",
75+
"Vector2i": "VECTOR2",
76+
77+
"PackedByteArray": "POOL_BYTE_ARRAY",
78+
"PackedInt32Array": "POOL_INT_ARRAY",
79+
"PackedFloat32Array": "POOL_REAL_ARRAY",
80+
81+
82+
}
83+
84+
@onready var cpp_header:CodeEdit = $"VBoxContainer/Main/C++Column/C++Tabs/Header"
85+
@onready var cpp_code:CodeEdit = $"VBoxContainer/Main/C++Column/C++Tabs/Code"
86+
@onready var cpp_binding:CodeEdit = $"VBoxContainer/Main/C++Column/C++Tabs/ClassDB Binding"
87+
@onready var cpp_setgets:CodeEdit = $"VBoxContainer/Main/C++Column/C++Tabs/Set-Gets"
88+
89+
var settings:AppSettings = AppSettings.new()
90+
91+
#meta info about the currently parsed file
92+
var current_class_name:String
93+
var class_inherits:String
94+
95+
var process_context:Callable
96+
var input_load_context:Callable
97+
98+
func _ready() -> void:
99+
pass
100+
101+
func _on_load_input_pressed() -> void:
102+
if not input_load_context.is_null():
103+
input_load_context.call()
104+
105+
func _on_save_output_pressed() -> void:
106+
pass # Replace with function body.
107+
108+
func _on_open_output_pressed() -> void:
109+
OS.shell_open(settings.output_directory)
110+
111+
func _on_process_input_pressed() -> void:
112+
if not process_context.is_null():
113+
process_context.call()
114+
115+
func _on_open_settings_pressed() -> void:
116+
pass # Replace with function body.
117+
118+
func clear_data() -> void:
119+
current_class_name = ""
120+
process_context = Callable()
121+
input_load_context = Callable()
122+
123+
func generate_version_specific_var_enums() -> void:
124+
if settings.godot_3_mode:
125+
pass
126+
else:
127+
pass
128+
129+
func format_variant_enum(input:String) -> String:
130+
if variant_enum_strings_commmon.has(input):
131+
return variant_enum_strings_commmon.get(input)
132+
elif settings.godot_3_mode:
133+
return variant_enum_strings_3.get(input, "OBJECT")
134+
else:
135+
return variant_enum_strings_4.get(input, "OBJECT")

scenes/gui.tscn

Lines changed: 141 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
[gd_scene load_steps=3 format=3 uid="uid://d08ymwie64x78"]
1+
[gd_scene load_steps=5 format=3 uid="uid://d08ymwie64x78"]
22

3-
[ext_resource type="PackedScene" uid="uid://drsuhng36km7e" path="res://scenes/variable_helper.tscn" id="1_lo3s5"]
4-
[ext_resource type="PackedScene" uid="uid://cnphuecmmonpo" path="res://scenes/gdscript_to_cpp.tscn" id="2_stox0"]
3+
[ext_resource type="LabelSettings" uid="uid://bfq2fubl1lynw" path="res://header_label.tres" id="1_71wp5"]
4+
[ext_resource type="Script" path="res://scenes/gui.gd" id="1_qmrq7"]
5+
[ext_resource type="Script" path="res://scripts/variable_helper.gd" id="2_gl05c"]
6+
[ext_resource type="Script" path="res://scripts/gdscript_to_cpp.gd" id="3_7u2ky"]
57

68
[node name="Control" type="Control"]
79
layout_mode = 3
@@ -10,18 +12,151 @@ anchor_right = 1.0
1012
anchor_bottom = 1.0
1113
grow_horizontal = 2
1214
grow_vertical = 2
15+
script = ExtResource("1_qmrq7")
1316

14-
[node name="TabContainer" type="TabContainer" parent="."]
17+
[node name="VBoxContainer" type="VBoxContainer" parent="."]
1518
layout_mode = 1
1619
anchors_preset = 15
1720
anchor_right = 1.0
1821
anchor_bottom = 1.0
1922
grow_horizontal = 2
2023
grow_vertical = 2
2124

22-
[node name="Variable Helper" parent="TabContainer" instance=ExtResource("1_lo3s5")]
25+
[node name="Main" type="HBoxContainer" parent="VBoxContainer"]
2326
layout_mode = 2
27+
size_flags_vertical = 3
2428

25-
[node name="GDScript2C++" parent="TabContainer" instance=ExtResource("2_stox0")]
29+
[node name="GDScriptColumn" type="VBoxContainer" parent="VBoxContainer/Main"]
30+
layout_mode = 2
31+
size_flags_horizontal = 3
32+
33+
[node name="Label" type="Label" parent="VBoxContainer/Main/GDScriptColumn"]
34+
layout_mode = 2
35+
text = "GDScript"
36+
label_settings = ExtResource("1_71wp5")
37+
horizontal_alignment = 1
38+
39+
[node name="TabContainer" type="TabContainer" parent="VBoxContainer/Main/GDScriptColumn"]
40+
layout_mode = 2
41+
size_flags_vertical = 3
42+
tab_alignment = 1
43+
current_tab = 1
44+
45+
[node name="Variable Helper" type="VBoxContainer" parent="VBoxContainer/Main/GDScriptColumn/TabContainer"]
46+
visible = false
47+
layout_mode = 2
48+
script = ExtResource("2_gl05c")
49+
metadata/_tab_index = 0
50+
51+
[node name="class" type="LineEdit" parent="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper"]
52+
layout_mode = 2
53+
placeholder_text = "Your class' name here"
54+
55+
[node name="def_var" type="LineEdit" parent="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper"]
56+
layout_mode = 2
57+
placeholder_text = "Your default variable type here"
58+
59+
[node name="values" type="TextEdit" parent="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper"]
60+
layout_mode = 2
61+
size_flags_horizontal = 3
62+
size_flags_vertical = 3
63+
placeholder_text = "List your values by seperating them with commas. Variables may be typed individually by using GDScript's static type syntax. Otherwise, they will use whichever type is default."
64+
wrap_mode = 1
65+
66+
[node name="GDScript To C++" type="VBoxContainer" parent="VBoxContainer/Main/GDScriptColumn/TabContainer"]
67+
layout_mode = 2
68+
script = ExtResource("3_7u2ky")
69+
metadata/_tab_index = 1
70+
71+
[node name="GDScriptInput" type="Button" parent="VBoxContainer/Main/GDScriptColumn/TabContainer/GDScript To C++"]
72+
layout_mode = 2
73+
size_flags_vertical = 8
74+
text = "Pick GDScript file"
75+
76+
[node name="ScriptCode" type="CodeEdit" parent="VBoxContainer/Main/GDScriptColumn/TabContainer/GDScript To C++"]
77+
layout_mode = 2
78+
size_flags_vertical = 3
79+
placeholder_text = "Your GDScript script will appear here when loaded from a file. Or, you can copy your code and paste it into here."
80+
wrap_mode = 1
81+
82+
[node name="C++Column" type="VBoxContainer" parent="VBoxContainer/Main"]
83+
layout_mode = 2
84+
size_flags_horizontal = 3
85+
86+
[node name="Label" type="Label" parent="VBoxContainer/Main/C++Column"]
87+
layout_mode = 2
88+
text = "C++"
89+
label_settings = ExtResource("1_71wp5")
90+
horizontal_alignment = 1
91+
92+
[node name="C++Tabs" type="TabContainer" parent="VBoxContainer/Main/C++Column"]
93+
layout_mode = 2
94+
size_flags_vertical = 3
95+
tab_alignment = 1
96+
current_tab = 0
97+
deselect_enabled = true
98+
99+
[node name="Header" type="CodeEdit" parent="VBoxContainer/Main/C++Column/C++Tabs"]
100+
layout_mode = 2
101+
placeholder_text = "Header declarations for your class will show up here. You can manually edit code as needed before pressing \"output\". "
102+
wrap_mode = 1
103+
metadata/_tab_index = 0
104+
105+
[node name="Code" type="CodeEdit" parent="VBoxContainer/Main/C++Column/C++Tabs"]
106+
visible = false
107+
layout_mode = 2
108+
placeholder_text = "Source code for all your class' functions will show up here. You can manually edit code as needed before pressing \"output\". "
109+
wrap_mode = 1
110+
metadata/_tab_index = 1
111+
112+
[node name="ClassDB Binding" type="CodeEdit" parent="VBoxContainer/Main/C++Column/C++Tabs"]
113+
visible = false
114+
layout_mode = 2
115+
placeholder_text = "The function for binding variables to the ClassDB API will show up here. You can manually edit code as needed before pressing \"output\". "
116+
wrap_mode = 1
117+
metadata/_tab_index = 2
118+
119+
[node name="Set-Gets" type="CodeEdit" parent="VBoxContainer/Main/C++Column/C++Tabs"]
26120
visible = false
27121
layout_mode = 2
122+
placeholder_text = "Setter and getter functions for API-exposed variables will show up here. You can manually edit code as needed before pressing \"output\". "
123+
wrap_mode = 1
124+
metadata/_tab_index = 3
125+
126+
[node name="CommonButtons" type="HBoxContainer" parent="VBoxContainer"]
127+
layout_mode = 2
128+
129+
[node name="OpenSettings" type="Button" parent="VBoxContainer/CommonButtons"]
130+
layout_mode = 2
131+
size_flags_horizontal = 3
132+
text = "Open Settings"
133+
134+
[node name="LoadInput" type="Button" parent="VBoxContainer/CommonButtons"]
135+
layout_mode = 2
136+
size_flags_horizontal = 3
137+
text = "Load File"
138+
139+
[node name="ProcessInput" type="Button" parent="VBoxContainer/CommonButtons"]
140+
layout_mode = 2
141+
size_flags_horizontal = 3
142+
text = "Process Input"
143+
144+
[node name="SaveOutput" type="Button" parent="VBoxContainer/CommonButtons"]
145+
layout_mode = 2
146+
size_flags_horizontal = 3
147+
text = "Save C++ Files"
148+
149+
[node name="OpenOutput" type="Button" parent="VBoxContainer/CommonButtons"]
150+
layout_mode = 2
151+
size_flags_horizontal = 3
152+
text = "Open Output Folder"
153+
154+
[connection signal="visibility_changed" from="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper" to="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper" method="_on_visibility_changed"]
155+
[connection signal="text_changed" from="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper/class" to="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper" method="_on_class_text_changed"]
156+
[connection signal="text_changed" from="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper/def_var" to="VBoxContainer/Main/GDScriptColumn/TabContainer/Variable Helper" method="_on_def_var_text_changed"]
157+
[connection signal="pressed" from="VBoxContainer/Main/GDScriptColumn/TabContainer/GDScript To C++/GDScriptInput" to="VBoxContainer/Main/GDScriptColumn/TabContainer/GDScript To C++" method="_on_input_pressed"]
158+
[connection signal="pressed" from="VBoxContainer/CommonButtons/OpenSettings" to="." method="_on_open_settings_pressed"]
159+
[connection signal="pressed" from="VBoxContainer/CommonButtons/LoadInput" to="." method="_on_load_input_pressed"]
160+
[connection signal="pressed" from="VBoxContainer/CommonButtons/ProcessInput" to="." method="_on_process_input_pressed"]
161+
[connection signal="pressed" from="VBoxContainer/CommonButtons/SaveOutput" to="." method="_on_save_output_pressed"]
162+
[connection signal="pressed" from="VBoxContainer/CommonButtons/OpenOutput" to="." method="_on_open_output_pressed"]

scenes/settings.tscn

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[gd_scene format=3 uid="uid://c7x0mkwhx4f1s"]
2+
3+
[node name="Settings" type="Control"]
4+
layout_mode = 3
5+
anchors_preset = 15
6+
anchor_right = 1.0
7+
anchor_bottom = 1.0
8+
grow_horizontal = 2
9+
grow_vertical = 2
10+
11+
[node name="VBoxContainer" type="VBoxContainer" parent="."]
12+
layout_mode = 1
13+
anchors_preset = 15
14+
anchor_right = 1.0
15+
anchor_bottom = 1.0
16+
grow_horizontal = 2
17+
grow_vertical = 2
18+
19+
[node name="CheckButton" type="CheckButton" parent="VBoxContainer"]
20+
layout_mode = 2
21+
text = "Godot 3 Mode"
22+
23+
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
24+
layout_mode = 2
25+
26+
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
27+
layout_mode = 2
28+
size_flags_horizontal = 3
29+
text = "Some text"
30+
31+
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
32+
layout_mode = 2
33+
placeholder_text = "Raw text"
34+
expand_to_text_length = true
35+
36+
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer"]
37+
layout_mode = 2
38+
text = "Open Button"

0 commit comments

Comments
 (0)