diff --git a/Global.gd b/Global.gd index 81fe161..a9ae229 100644 --- a/Global.gd +++ b/Global.gd @@ -2,6 +2,13 @@ extends Node2D var ShowInventory = 0 var LeftClick = 0 +var player_inventory_items = [] + +func LoadSave(): + Database.OpenConnection() func _input(event): pass + +func _ready(): + pass diff --git a/KinematicBody2D.gd b/KinematicBody2D.gd index 627a3f3..76c6045 100644 --- a/KinematicBody2D.gd +++ b/KinematicBody2D.gd @@ -47,3 +47,5 @@ func _input(event): if Input.is_action_pressed("map_interaction"): pass +func _ready(): + Global.player_inventory_items = Database.GetInventoryItems() diff --git a/Menu.gd b/Menu.gd index 9534bf6..54d3a76 100644 --- a/Menu.gd +++ b/Menu.gd @@ -4,4 +4,5 @@ func _ready(): pass # Replace with function body. func _on_Btn_PlayGame_pressed(): + Global.LoadSave() get_tree().change_scene("res://river_intersection_home2.tscn") diff --git a/MiscCodes/Slot.gd b/MiscCodes/Slot.gd index 068245f..3364baf 100644 --- a/MiscCodes/Slot.gd +++ b/MiscCodes/Slot.gd @@ -10,14 +10,23 @@ var empty_style: StyleBoxTexture = null var ItemClass = preload("res://MiscScenes/Item.tscn") var item = null +var id = 0 +#onready var id = int(self.name[4:0]) func _ready(): + if self.name.length() == 5: + self.id = int(self.name.right(1)) - 1 + else: + self.id = int(self.name.right(2)) - 1 default_style = StyleBoxTexture.new() empty_style = StyleBoxTexture.new() #default_style.texture = default_tex #empty_style.texture = empty_tex - - if randi() % 2 == 0: +# print(self.get) +# if randi() % 2 == 0: + print(Global.player_inventory_items) + print(Global.player_inventory_items[self.id]) + if Global.player_inventory_items[self.id] != null: item = ItemClass.instance() add_child(item) # refresh_style() diff --git a/Storage/Database.gd b/Storage/Database.gd new file mode 100644 index 0000000..7e10788 --- /dev/null +++ b/Storage/Database.gd @@ -0,0 +1,31 @@ +extends Node +const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") + +var path = "res://Storage/World1.db" +var db_name = "RingOfRaces" +var db = null +var verbose = true + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +func OpenConnection(): + self.db = SQLite.new() + self.db.path = path + self.db.verbose_mode = verbose + self.db.open_db() + +func OpenConnectionIfClosed(): + if self.db == null: + OpenConnection() + +func GetInventoryItems(): + OpenConnectionIfClosed() + var ret = [] + for x in range(40): + ret.append([x, "test"]) + return ret +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Storage/World1.db b/Storage/World1.db new file mode 100644 index 0000000..e69de29 diff --git a/TouchScreenButton.gd b/TouchScreenButton.gd index 891cfea..05fcf91 100644 --- a/TouchScreenButton.gd +++ b/TouchScreenButton.gd @@ -1,6 +1,6 @@ extends TouchScreenButton -onready var ShowInventory = get_node("res://Global.gd") +onready var ShowInventory = Global.ShowInventory func _input(always): ShowInventory = 1; diff --git a/addons/godot-sqlite/LICENSE.md b/addons/godot-sqlite/LICENSE.md new file mode 100644 index 0000000..fc16969 --- /dev/null +++ b/addons/godot-sqlite/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present Piet Bronders & Jeroen De Geeter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/addons/godot-sqlite/bin/gdsqlite.gdnlib b/addons/godot-sqlite/bin/gdsqlite.gdnlib new file mode 100644 index 0000000..83d71ce --- /dev/null +++ b/addons/godot-sqlite/bin/gdsqlite.gdnlib @@ -0,0 +1,19 @@ +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" +reloadable=false + +[entry] + +X11.64="res://addons/godot-sqlite/bin/x11/libgdsqlite.so" +Server="res://addons/godot-sqlite/bin/x11/libgdsqlite.so" +Windows.64="res://addons/godot-sqlite/bin/win64/libgdsqlite.dll" +OSX.64="res://addons/godot-sqlite/bin/osx/libgdsqlite.dylib" + +[dependencies] +X11.64=[ ] +Server=[ ] +Windows.64=[ ] +OSX.64=[ ] \ No newline at end of file diff --git a/addons/godot-sqlite/bin/gdsqlite.gdns b/addons/godot-sqlite/bin/gdsqlite.gdns new file mode 100644 index 0000000..2f01a53 --- /dev/null +++ b/addons/godot-sqlite/bin/gdsqlite.gdns @@ -0,0 +1,8 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://addons/godot-sqlite/bin/gdsqlite.gdnlib" type="GDNativeLibrary" id=1] + +[resource] +resource_name = "gdsqlite" +class_name = "SQLite" +library = ExtResource( 1 ) \ No newline at end of file diff --git a/addons/godot-sqlite/bin/osx/libgdsqlite.dylib b/addons/godot-sqlite/bin/osx/libgdsqlite.dylib new file mode 100644 index 0000000..3428f01 Binary files /dev/null and b/addons/godot-sqlite/bin/osx/libgdsqlite.dylib differ diff --git a/addons/godot-sqlite/bin/win64/libgdsqlite.dll b/addons/godot-sqlite/bin/win64/libgdsqlite.dll new file mode 100644 index 0000000..935c898 Binary files /dev/null and b/addons/godot-sqlite/bin/win64/libgdsqlite.dll differ diff --git a/addons/godot-sqlite/bin/x11/libgdsqlite.so b/addons/godot-sqlite/bin/x11/libgdsqlite.so new file mode 100644 index 0000000..51e5852 Binary files /dev/null and b/addons/godot-sqlite/bin/x11/libgdsqlite.so differ diff --git a/addons/godot-sqlite/godot-sqlite.gd b/addons/godot-sqlite/godot-sqlite.gd new file mode 100644 index 0000000..60196ec --- /dev/null +++ b/addons/godot-sqlite/godot-sqlite.gd @@ -0,0 +1,14 @@ +# ############################################################################ # +# Copyright © 2019-present Piet Bronders & Jeroen De Geeter +# Licensed under the MIT License. +# See LICENSE in the project root for license information. +# ############################################################################ # + +tool +extends EditorPlugin + +func _enter_tree(): + pass + +func _exit_tree(): + pass \ No newline at end of file diff --git a/addons/godot-sqlite/plugin.cfg b/addons/godot-sqlite/plugin.cfg new file mode 100644 index 0000000..4984347 --- /dev/null +++ b/addons/godot-sqlite/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Godot SQLite" +description="GDNative wrapper for SQLite (Godot 3.1+), making it possible to use SQLite databases as data storage in all your future games." +author="Piet Bronders & Jeroen De Geeter" +version="1.7" +script="godot-sqlite.gd" \ No newline at end of file diff --git a/background_script.gd b/background_script.gd index 3254d73..4c4cb3d 100644 --- a/background_script.gd +++ b/background_script.gd @@ -1,10 +1,10 @@ extends TileMap - onready var player = get_node("/root/Map1/Player") # Called when the node enters the scene tree for the first time. func _ready(): + pass # Replace with function body. func _get_cell_size(): diff --git a/project.godot b/project.godot index 4f5693b..8ff733a 100644 --- a/project.godot +++ b/project.godot @@ -21,7 +21,8 @@ config/icon="res://pictures/gui/buttons/delete_ringofraces.png" [autoload] -Global="*res://Global.tscn" +Global="*res://Global.gd" +Database="*res://Storage/Database.gd" [display]