Fixed preloading of add on
This commit is contained in:
parent
0f6876f96f
commit
285ee79e16
@ -5,12 +5,12 @@
|
|||||||
[ext_resource path="res://MiscCodes/loading_ring.gd" type="Script" id=3]
|
[ext_resource path="res://MiscCodes/loading_ring.gd" type="Script" id=3]
|
||||||
[ext_resource path="res://pictures/gui/backgrounds/treesbackground1.png" type="Texture" id=5]
|
[ext_resource path="res://pictures/gui/backgrounds/treesbackground1.png" type="Texture" id=5]
|
||||||
|
|
||||||
[sub_resource type="DynamicFontData" id=2]
|
[sub_resource type="DynamicFontData" id=1]
|
||||||
font_path = "res://ring_of_races_font.ttf"
|
font_path = "res://ring_of_races_font.ttf"
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=2]
|
||||||
size = 30
|
size = 30
|
||||||
font_data = SubResource( 2 )
|
font_data = SubResource( 1 )
|
||||||
|
|
||||||
[node name="Main Menu" type="Node2D"]
|
[node name="Main Menu" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
@ -36,7 +36,7 @@ margin_left = 484.204
|
|||||||
margin_top = 100.226
|
margin_top = 100.226
|
||||||
margin_right = 679.204
|
margin_right = 679.204
|
||||||
margin_bottom = 153.226
|
margin_bottom = 153.226
|
||||||
custom_fonts/font = SubResource( 1 )
|
custom_fonts/font = SubResource( 2 )
|
||||||
text = "Play Game"
|
text = "Play Game"
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
36
MiscScenes/VBoxContainer.gd
Normal file
36
MiscScenes/VBoxContainer.gd
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
extends VBoxContainer
|
||||||
|
|
||||||
|
# Many thanks to Arkeve! https://github.com/arkeve
|
||||||
|
|
||||||
|
const SlotClass = preload("res://MiscCodes/Slot.gd")
|
||||||
|
onready var inventory_slots = $GridContainer
|
||||||
|
var holding_item = null
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
for inv_slot in inventory_slots.get_children():
|
||||||
|
inv_slot.connect("gui_input", self, "slot_gui_input", [inv_slot])
|
||||||
|
|
||||||
|
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
||||||
|
if event is InputEventMouseButton:
|
||||||
|
if event.button_index == BUTTON_LEFT && event.pressed:
|
||||||
|
if holding_item != null:
|
||||||
|
if !slot.item: # Place holding item to slot
|
||||||
|
slot.putIntoSlot(holding_item)
|
||||||
|
holding_item = null
|
||||||
|
else: # Swap holding item with item in slot
|
||||||
|
var temp_item = slot.item
|
||||||
|
slot.pickFromSlot()
|
||||||
|
temp_item.global_position = event.global_position
|
||||||
|
slot.putIntoSlot(holding_item)
|
||||||
|
holding_item = temp_item
|
||||||
|
elif slot.item:
|
||||||
|
holding_item = slot.item
|
||||||
|
slot.pickFromSlot()
|
||||||
|
holding_item.global_position = get_global_mouse_position()
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if holding_item:
|
||||||
|
holding_item.global_position = get_global_mouse_position()
|
||||||
|
|
||||||
|
func _on_TouchScreenButton_pressed():
|
||||||
|
Global.GoToScene("river_intersection_home_2")
|
@ -1,70 +1,74 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
|
||||||
var path = "user://storage.db"
|
|
||||||
var db_name = "RingOfRaces"
|
var path = "user://storage.db"
|
||||||
var db = null
|
var db_name = "RingOfRaces"
|
||||||
var verbose = true
|
var db = null
|
||||||
|
var verbose = true
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
var host = null
|
||||||
pass # Replace with function body.
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
func CreateWorldDatabase():
|
func _ready():
|
||||||
print("Creating new database")
|
host = OS.get_name()
|
||||||
var SQLite = load("user://gdsqlite.gdns")
|
|
||||||
var player_inventory : Dictionary = Dictionary()
|
func CreateWorldDatabase():
|
||||||
player_inventory["id"] = {"data_type":"int", "primary_key": true, "not_null": true} #slot id
|
print("Creating new database")
|
||||||
player_inventory["item_id"] = {"data_type":"int", "not_null": true} #item id
|
var SQLite = load("user://gdsqlite.gdns")
|
||||||
player_inventory["item_name"] = {"data_type":"text", "not_null": true} #item name
|
var player_inventory : Dictionary = Dictionary()
|
||||||
player_inventory["amount"] = {"data_type":"int", "not_null": true} #amount
|
player_inventory["id"] = {"data_type":"int", "primary_key": true, "not_null": true} #slot id
|
||||||
player_inventory["shortdesc"] = {"data_type":"char(80)", "not_null": true} #short description
|
player_inventory["item_id"] = {"data_type":"int", "not_null": true} #item id
|
||||||
db.create_table("player_inventory", player_inventory)
|
player_inventory["item_name"] = {"data_type":"text", "not_null": true} #item name
|
||||||
var items : Dictionary = Dictionary()
|
player_inventory["amount"] = {"data_type":"int", "not_null": true} #amount
|
||||||
for i in range(40):
|
player_inventory["shortdesc"] = {"data_type":"char(80)", "not_null": true} #short description
|
||||||
items["id"] = i
|
db.create_table("player_inventory", player_inventory)
|
||||||
items["item_id"] = 0
|
var items : Dictionary = Dictionary()
|
||||||
items["item_name"] = "No Item"
|
for i in range(40):
|
||||||
items["amount"] = 0
|
items["id"] = i
|
||||||
items["shortdesc"] = "No item here"
|
items["item_id"] = 0
|
||||||
|
items["item_name"] = "No Item"
|
||||||
# Insert a new row in the table
|
items["amount"] = 0
|
||||||
db.insert_row("player_inventory", items)
|
items["shortdesc"] = "No item here"
|
||||||
items.clear()
|
|
||||||
|
# Insert a new row in the table
|
||||||
func OpenConnection():
|
db.insert_row("player_inventory", items)
|
||||||
var SQLite = load("user://gdsqlite.gdns")
|
items.clear()
|
||||||
self.db = SQLite.new()
|
|
||||||
var file = File.new()
|
func OpenConnection():
|
||||||
self.db.path = path
|
if(str(OS.get_name()) == "X11"):
|
||||||
self.db.verbose_mode = verbose
|
path = "res://storage.db"
|
||||||
var create = false
|
self.db = SQLite.new()
|
||||||
print(path)
|
var file = File.new()
|
||||||
|
self.db.path = path
|
||||||
# This does not seem to work. The file is in the right place, but being recreated everytime. The file is findable in Res:// and C:/ .. But not after the user folder
|
self.db.verbose_mode = verbose
|
||||||
if !file.file_exists(path):
|
var create = false
|
||||||
print("File not existing, so creating new db")
|
print(path)
|
||||||
create = true
|
|
||||||
self.db.open_db()
|
# This does not seem to work. The file is in the right place, but being recreated everytime. The file is findable in Res:// and C:/ .. But not after the user folder
|
||||||
if create:
|
if !file.file_exists(path):
|
||||||
CreateWorldDatabase()
|
print("File not existing, so creating new db")
|
||||||
|
create = true
|
||||||
func OpenConnectionIfClosed():
|
self.db.open_db()
|
||||||
if self.db == null:
|
if create:
|
||||||
OpenConnection()
|
CreateWorldDatabase()
|
||||||
|
|
||||||
func GetInventoryItems():
|
func OpenConnectionIfClosed():
|
||||||
OpenConnectionIfClosed()
|
if self.db == null:
|
||||||
var ret = []
|
OpenConnection()
|
||||||
ret = db.select_rows("player_inventory", "",["*"])
|
|
||||||
return ret
|
func GetInventoryItems():
|
||||||
|
OpenConnectionIfClosed()
|
||||||
func SaveInventory(player_inventory_items):
|
var ret = []
|
||||||
print("Now on inventory save file")
|
ret = db.select_rows("player_inventory", "",["*"])
|
||||||
if(player_inventory_items == null or len(player_inventory_items) != 40):
|
return ret
|
||||||
Global.Log("Bad inventory save!", 3)
|
|
||||||
return
|
func SaveInventory(player_inventory_items):
|
||||||
OpenConnectionIfClosed()
|
print("Now on inventory save file")
|
||||||
|
if(player_inventory_items == null or len(player_inventory_items) != 40):
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
Global.Log("Bad inventory save!", 3)
|
||||||
#func _process(delta):
|
return
|
||||||
# pass
|
OpenConnectionIfClosed()
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
[ext_resource path="res://pictures/tileset_images/TilesetGodotVloer.png" type="Texture" id=1]
|
[ext_resource path="res://pictures/tileset_images/TilesetGodotVloer.png" type="Texture" id=1]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="ConcavePolygonShape2D" id=1]
|
[sub_resource type="ConcavePolygonShape2D" id=1]
|
||||||
segments = PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
segments = PoolVector2Array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
|
||||||
|
|
||||||
|
BIN
storage.db
Normal file
BIN
storage.db
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user