Connected Database to Toolset Dialog Editor.

This commit is contained in:
PersonGuyGit 2022-09-04 12:44:57 -06:00
parent 935da98638
commit 7b00653248
3 changed files with 102 additions and 6 deletions

View File

@ -4,18 +4,29 @@ const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var db # Database object var db # Database object
var db_name = "res://DataStorage/database" var db_name = "res://DataStorage/database"
onready var only_once : bool = true
onready var textEntry = get_node("VBoxContainer/LineEdit")
onready var convoID = get_node("VBoxContainer/HBoxContainer/labelConvoID/LineEdit")
onready var layerID = get_node("VBoxContainer/HBoxContainer/labelLayerID/LineEdit")
onready var branchID = get_node("VBoxContainer/HBoxContainer/labelBranchID/LineEdit")
onready var saveButton = get_node("saveButton")
func CommitDataToDB(): func CommitDataToDB():
db = SQLite.new() db = SQLite.new()
db.path = db_name db.path = db_name
db.open_db() db.open_db()
var tableName = "DataStorage" var tableName = "DataStorage"
var dict : Dictionary = Dictionary() var dict : Dictionary = Dictionary()
dict["ConvoID"] = 1 dict["ConvoID"] = int(convoID.text)
dict["LayerID"] = 1 dict["LayerID"] = int(layerID.text)
dict["BranchID"] = 1 dict["BranchID"] = int(branchID.text)
dict["Text"] = "The best riff from Freebird plays at 202 dB." dict["Text"] = textEntry.text
db.insert_row(tableName,dict) db.insert_row(tableName,dict)
print("Done with SQL commit")
func readFromDB(): func readFromDB():
db = SQLite.new() db = SQLite.new()
@ -39,5 +50,11 @@ func DeleteFromDBByID(idNum):
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
DeleteFromDBByID(1) pass
func _process(delta):
if saveButton.pressed == true && only_once == true:
only_once = false
CommitDataToDB()

View File

@ -2,5 +2,84 @@
[ext_resource path="res://MainSystem.gd" type="Script" id=1] [ext_resource path="res://MainSystem.gd" type="Script" id=1]
[node name="Node2D" type="Node2D"] [node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Panel" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Label" type="Label" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -40.5
margin_right = 40.5
margin_bottom = 14.0
text = "Dialog Editor"
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -200.0
margin_top = 100.0
margin_right = 200.0
margin_bottom = 200.0
[node name="Label" type="Label" parent="VBoxContainer"]
margin_right = 400.0
margin_bottom = 14.0
text = "Dialog Text"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer"]
margin_top = 18.0
margin_right = 400.0
margin_bottom = 42.0
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 46.0
margin_right = 400.0
margin_bottom = 60.0
custom_constants/separation = 4
[node name="labelConvoID" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_right = 58.0
margin_bottom = 14.0
text = "Convo ID"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer/labelConvoID"]
margin_top = 20.0
margin_right = 58.0
margin_bottom = 24.0
[node name="labelLayerID" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_left = 62.0
margin_right = 115.0
margin_bottom = 14.0
text = "Layer ID"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer/labelLayerID"]
margin_top = 20.0
margin_right = 58.0
margin_bottom = 24.0
[node name="labelBranchID" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_left = 119.0
margin_right = 182.0
margin_bottom = 14.0
text = "Branch ID"
[node name="LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer/labelBranchID"]
margin_top = 20.0
margin_right = 58.0
margin_bottom = 24.0
[node name="saveButton" type="Button" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -49.5
margin_top = 250.0
margin_right = 49.5
margin_bottom = 20.0
text = "Commit Entry"