From 2d2e65d8ae6ca2873383e90016c1f86525dc8043 Mon Sep 17 00:00:00 2001 From: Luke Gebbink <48702026+PersonGuyGit@users.noreply.github.com> Date: Sun, 2 Jan 2022 12:56:55 -0700 Subject: [PATCH] Made some changes, modded a datetime object, and started defining some parent classes. --- .../MainMenu/GodotUserInterface_Luke/Actor.gd | 16 +++ .../CharacterCreation.gd | 16 +++ .../CharacterCreation.tscn | 5 + .../DataStore/database.db | Bin 24576 -> 36864 bytes .../MainMenu/GodotUserInterface_Luke/Date.gd | 101 ++++++++++++++++++ Godot/MainMenu/GodotUserInterface_Luke/Die.gd | 49 +++++++++ Godot/MainMenu/GodotUserInterface_Luke/GUI.gd | 37 +------ .../GodotUserInterface_Luke/Game.tscn | 5 +- .../MainMenu/GodotUserInterface_Luke/Menu.gd | 21 ++++ .../SaveAndLoadGame.gd | 58 ++++++++++ .../GodotUserInterface_Luke/Start Game.gd | 1 - .../GodotUserInterface_Luke/TestNode2D.gd | 14 +++ .../MainMenu/GodotUserInterface_Luke/World.gd | 46 ++++++++ .../GodotUserInterface_Luke/WorldObject.gd | 16 +++ .../GodotUserInterface_Luke/project.godot | 12 +++ 15 files changed, 360 insertions(+), 37 deletions(-) create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/Actor.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.tscn create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/Date.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/Die.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/Menu.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/SaveAndLoadGame.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/World.gd create mode 100644 Godot/MainMenu/GodotUserInterface_Luke/WorldObject.gd diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Actor.gd b/Godot/MainMenu/GodotUserInterface_Luke/Actor.gd new file mode 100644 index 0000000..1eccaec --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/Actor.gd @@ -0,0 +1,16 @@ +extends Node + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.gd b/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.gd new file mode 100644 index 0000000..1eccaec --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.gd @@ -0,0 +1,16 @@ +extends Node + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.tscn b/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.tscn new file mode 100644 index 0000000..293a455 --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/CharacterCreation.tscn @@ -0,0 +1,5 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Game.tscn" type="PackedScene" id=1] + +[node name="Game" instance=ExtResource( 1 )] diff --git a/Godot/MainMenu/GodotUserInterface_Luke/DataStore/database.db b/Godot/MainMenu/GodotUserInterface_Luke/DataStore/database.db index 9d3e4184cdef4191079a41c2b7f0932476eb125b..022749548d9eaec61be940189213f5ab58d55089 100644 GIT binary patch literal 36864 zcmeI)y>8n^00(eVBqdXpbw-esV^1p7T1`+S2#O3{D#?T*Sf(6_M&m33EuAeQG^vnO zTBDPVzC$0Qd$*!v7C%CVOqtrDoig-}{vc(%bE05$ve_Fy`NV|Ra#npBb859-j;tY z{XyQ4R_QJ;K!5-QAOHafKmY;|fB*zOR-j$V8~5(XQS9t`%nHWIp||>G!#1hiXm(9n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|+e@pFM~e#OB5hyNSU_E#X+K*44ihx7cCU+K#;U*LbRS String: + if("DD".is_subsequence_of(date_format)): + date_format = date_format.replace("DD", str(day()).pad_zeros(2)) + if("MM".is_subsequence_of(date_format)): + date_format = date_format.replace("MM", str(month()).pad_zeros(2)) + if("YYYY".is_subsequence_of(date_format)): + date_format = date_format.replace("YYYY", str(year())) + elif("YY".is_subsequence_of(date_format)): + date_format = date_format.replace("YY", str(year()).substr(2,3)) + return date_format + +func day() -> int: + return day + +func month() -> int: + return month + +func year() -> int: + return year + +func hour() -> int: + return hour + +func minute() -> int: + return minute + +func seconds() -> int: + return seconds + +func set_day(var _day : int): + day = _day + +func set_month(var _month : int): + month = _month + +func set_year(var _year : int): + year = _year + +func set_hour(var _hour : int): + hour = _hour + +func set_minute(var _minute : int): + minute = _minute + +func set_seconds(var _seconds : int): + seconds = _seconds + +func change_to_prev_month(): + var selected_month = month() + selected_month -= 1 + if(selected_month < 1): + set_month(12) + set_year(year() - 1) + else: + set_month(selected_month) + +func change_to_next_month(): + var selected_month = month() + selected_month += 1 + if(selected_month > 12): + set_month(1) + set_year(year() + 1) + else: + set_month(selected_month) + +func change_to_prev_year(): + set_year(year() - 1) + +func change_to_next_year(): + set_year(year() + 1) diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Die.gd b/Godot/MainMenu/GodotUserInterface_Luke/Die.gd new file mode 100644 index 0000000..ba8acc3 --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/Die.gd @@ -0,0 +1,49 @@ +extends Node +class_name Die + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +enum DieCategory{ + D4, + D6, + D8, + D10, + D12, + D00, + D20 +} + +var dieType = DieCategory +var numberOfFaces = 0 + +func SetNumberOfSides(): + var DSides = dieType + + + match DSides: + D4: + numberOfFaces = 4 + D6: + numberOfFaces = 6 + D8: + numberOfFaces = 8 + D10: + numberOfFaces = 10 + D12: + numberOfFaces = 12 + D00: + numberOfFaces = 100 + D20: + numberOfFaces = 20 + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Godot/MainMenu/GodotUserInterface_Luke/GUI.gd b/Godot/MainMenu/GodotUserInterface_Luke/GUI.gd index 12f04f8..ecce02f 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/GUI.gd +++ b/Godot/MainMenu/GodotUserInterface_Luke/GUI.gd @@ -1,38 +1,5 @@ extends MarginContainer -const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") -var db -var db_name = "res://DataStore/database" - func _ready(): - db = SQLite.new() - db.path = db_name - #commitDataToDB() - readFromDB() - getItemsByUserID(1) - -func commitDataToDB(): - db.open_db() - var tableName = "PlayerInfo" - var dict : Dictionary = Dictionary() - dict["Name"] = "This is a test user1" - dict["Score"] = 6000 - db.insert_row(tableName,dict) - print("Row Inserted") - -func readFromDB(): - db.open_db() - var tableName = "PlayerInfo" - db.query("select * from " + tableName + ";") - for i in range(0,db.query_result.size()): - print("Query results ", db.query_result[i]["Name"], db.query_result[i]) - -func getItemsByUserID(id): - db.open_db() - - #To Do, we should probably make this more generic, so it can query differnt tables - - db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id)) - for i in range(0, db.query_result.size()): - print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"]) - return db.query_result + var TimeTest = OS.get_datetime() + print(TimeTest) diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Game.tscn b/Godot/MainMenu/GodotUserInterface_Luke/Game.tscn index 32abb30..25a15c0 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/Game.tscn +++ b/Godot/MainMenu/GodotUserInterface_Luke/Game.tscn @@ -1,4 +1,6 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://GUI.gd" type="Script" id=1] [sub_resource type="StyleBoxFlat" id=1] bg_color = Color( 0.129412, 0.129412, 0.129412, 1 ) @@ -12,6 +14,7 @@ bg_color = Color( 0.309804, 0.305882, 0.305882, 1 ) [node name="Game" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Menu.gd b/Godot/MainMenu/GodotUserInterface_Luke/Menu.gd new file mode 100644 index 0000000..6ad19e4 --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/Menu.gd @@ -0,0 +1,21 @@ +extends Node + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +var isPaused = false + +func isPausedFunc(): + print("Status is " + isPaused) + return isPaused + +# Called when the node enters the scene tree for the first time. +func _ready(): + isPausedFunc() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Godot/MainMenu/GodotUserInterface_Luke/SaveAndLoadGame.gd b/Godot/MainMenu/GodotUserInterface_Luke/SaveAndLoadGame.gd new file mode 100644 index 0000000..70c61f0 --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/SaveAndLoadGame.gd @@ -0,0 +1,58 @@ +extends Node + +const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") +var db +var db_name = "res://DataStore/database" + +var isPaused = false + +func isPausedFunc(): + print(isPaused) + return isPaused + +func _ready(): + db = SQLite.new() + db.path = db_name + commitDataToDB() + #readFromDB() + getItemsByUserID(1) + isPausedFunc() + + +func onSaveGame(): + print() #Return World object + +func onLoadGame(): + print() #Return World object + + +func commitDataToDB(): + db.open_db() + var tableName = "PlayerInfo" + var dict : Dictionary = Dictionary() + dict["Name"] = "Elon Musk" + dict["Archetype"] = "The Best One" + dict["Culture"] = "South African" + dict["Desc"] = "One of the richest people alive" + dict["Bio"] = "A Rich Guy" + dict["Health"] = 100 + dict["Gold"] = 6000 + db.insert_row(tableName,dict) + print("Row Inserted") + +func readFromDB(): + db.open_db() + var tableName = "PlayerInfo" + db.query("select * from " + tableName + ";") + for i in range(0,db.query_result.size()): + print("Query results ", db.query_result[i]["Name"], db.query_result[i]) + +func getItemsByUserID(id): + db.open_db() + + #To Do, we should probably make this more generic, so it can query differnt tables + + db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id)) + for i in range(0, db.query_result.size()): + print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"]) + return db.query_result# pass diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Start Game.gd b/Godot/MainMenu/GodotUserInterface_Luke/Start Game.gd index ecb92f7..c6f2fc0 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/Start Game.gd +++ b/Godot/MainMenu/GodotUserInterface_Luke/Start Game.gd @@ -14,4 +14,3 @@ func _on_Start_Game_gui_input(event): print("Clicked Start Game") get_tree().change_scene("res://TestNode2D.tscn") # Start Game button opens a new node for that purpose - diff --git a/Godot/MainMenu/GodotUserInterface_Luke/TestNode2D.gd b/Godot/MainMenu/GodotUserInterface_Luke/TestNode2D.gd index ab3aef4..f82b950 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/TestNode2D.gd +++ b/Godot/MainMenu/GodotUserInterface_Luke/TestNode2D.gd @@ -5,11 +5,25 @@ extends Node2D # var a = 2 # var b = "text" var isPaused = false +var wantsNewGame = false # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. + +func CreateNewGame(): + print("Create World Object to save") + + + +func _wantsNewGame(): + if wantsNewGame == true: + print("Yes") + if wantsNewGame == false: + print("No") + return wantsNewGame + # Make this function return a boolean. func _isPaused(): if isPaused == true: diff --git a/Godot/MainMenu/GodotUserInterface_Luke/World.gd b/Godot/MainMenu/GodotUserInterface_Luke/World.gd new file mode 100644 index 0000000..d05d4bb --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/World.gd @@ -0,0 +1,46 @@ +extends MarginContainer + +const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") +var db +var db_name = "res://DataStore/database" + +var isPaused = false +var isGameOver = false + +func _ready(): + db = SQLite.new() + db.path = db_name + commitDataToDB() + #readFromDB() + getItemsByUserID(1) + +func commitDataToDB(): + db.open_db() + var tableName = "PlayerInfo" + var dict : Dictionary = Dictionary() + dict["Name"] = "Elon Musk" + dict["Archetype"] = "The Best One" + dict["Culture"] = "South African" + dict["Desc"] = "One of the richest people alive" + dict["Bio"] = "A Rich Guy" + dict["Health"] = 100 + dict["Gold"] = 6000 + db.insert_row(tableName,dict) + print("Row Inserted") + +func readFromDB(): + db.open_db() + var tableName = "PlayerInfo" + db.query("select * from " + tableName + ";") + for i in range(0,db.query_result.size()): + print("Query results ", db.query_result[i]["Name"], db.query_result[i]) + +func getItemsByUserID(id): + db.open_db() + + #To Do, we should probably make this more generic, so it can query differnt tables + + db.query("select playerinfo.name as pname, ItemIventory.name as iname from playerinfo left join ItemIventory on playerinfo.ID = ItemIventory.PlayerID where playerinfo.id = " + str(id)) + for i in range(0, db.query_result.size()): + print("Query results ", db.query_result[i]["pname"], db.query_result[i]["iname"]) + return db.query_result diff --git a/Godot/MainMenu/GodotUserInterface_Luke/WorldObject.gd b/Godot/MainMenu/GodotUserInterface_Luke/WorldObject.gd new file mode 100644 index 0000000..4b35b46 --- /dev/null +++ b/Godot/MainMenu/GodotUserInterface_Luke/WorldObject.gd @@ -0,0 +1,16 @@ +extends Node + +const date = preload("res://Date.gd") + +var isPaused = false +var isGameOver = false + +var Scene = SceneTree +# var players = Array or Similar for Actors +# var history = Array or Similar for Nodes +# var decisions = Array or Similar for ints +var DateTime = date.new() + +func _ready(): + var TimeTest = OS.get_datetime() + print(TimeTest) diff --git a/Godot/MainMenu/GodotUserInterface_Luke/project.godot b/Godot/MainMenu/GodotUserInterface_Luke/project.godot index f33cbb9..d3462f5 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/project.godot +++ b/Godot/MainMenu/GodotUserInterface_Luke/project.godot @@ -9,6 +9,16 @@ config_version=4 _global_script_classes=[ { +"base": "Node", +"class": "Date", +"language": "GDScript", +"path": "res://Date.gd" +}, { +"base": "Node", +"class": "Die", +"language": "GDScript", +"path": "res://Die.gd" +}, { "base": "Resource", "class": "SaveGame", "language": "GDScript", @@ -20,6 +30,8 @@ _global_script_classes=[ { "path": "res://SaveSystem/SceneObject.gd" } ] _global_script_class_icons={ +"Date": "", +"Die": "", "SaveGame": "", "WorldObject": "" }