Added dynamically loading for inventory

This commit is contained in:
Eljakim Herrewijnen 2021-05-26 22:59:30 +02:00
parent 8b8baeba87
commit 8f3e13e532
4 changed files with 21 additions and 14 deletions

View File

@ -11,6 +11,7 @@ var current_scene = null
var current_camera = null var current_camera = null
var dev_stats = true var dev_stats = true
var dbname = "storage.db" var dbname = "storage.db"
var mainscene = ""
func AddInventoryItem(itemid, amount): func AddInventoryItem(itemid, amount):
for x in range(40): for x in range(40):
@ -43,18 +44,20 @@ func GoToScene(scene):
current_scene = loadedscenes[scene] current_scene = loadedscenes[scene]
get_tree().get_root().add_child(loadedscenes[scene]) get_tree().get_root().add_child(loadedscenes[scene])
return return
match scene: else:
"river_intersection_home_2": print("Could not load scene " + scene)
current_scene = river_intersection_home_2 # match scene:
get_tree().get_root().add_child(river_intersection_home_2) # "river_intersection_home_2":
"inventory_screen": # current_scene = river_intersection_home_2
inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance() # get_tree().get_root().add_child(river_intersection_home_2)
current_scene = inventory_screen # "inventory_screen":
get_tree().get_root().add_child(inventory_screen) # inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
"loadgame_screen": # current_scene = inventory_screen
loadgame_screen = preload("res://MenuScenes/LoadGame_Menu.tscn").instance() # get_tree().get_root().add_child(inventory_screen)
current_scene = loadgame_screen # "loadgame_screen":
get_tree().get_root().add_child(loadgame_screen) # loadgame_screen = preload("res://MenuScenes/LoadGame_Menu.tscn").instance()
# current_scene = loadgame_screen
# get_tree().get_root().add_child(loadgame_screen)
func LoadSave(target="Storage.db"): func LoadSave(target="Storage.db"):
dbname = target dbname = target

View File

@ -33,4 +33,4 @@ func _input(event):
holding_item.global_position = get_global_mouse_position() holding_item.global_position = get_global_mouse_position()
func _on_TouchScreenButton_pressed(): func _on_TouchScreenButton_pressed():
Global.GoToScene("river_intersection_home_2") Global.GoToScene(Global.mainscene)

View File

@ -18,6 +18,9 @@ func _on_Btn_PlayGame_pressed():
game_data.init_map(150, 150, "res://omgeving/Floor.tres",map_data, "res://omgeving/Floor.tres", map_data, "res://omgeving/Floor.tres", map_data, "res://omgeving/Floor.tres", map_data) game_data.init_map(150, 150, "res://omgeving/Floor.tres",map_data, "res://omgeving/Floor.tres", map_data, "res://omgeving/Floor.tres", map_data, "res://omgeving/Floor.tres", map_data)
var game = load("res://base_tilemap/base_tilemap.tscn").instance() var game = load("res://base_tilemap/base_tilemap.tscn").instance()
game.load_scene(game_data) game.load_scene(game_data)
#set this scene as main
Global.mainscene = "startmap1"
Global.AddScene(game, "startmap1", true) Global.AddScene(game, "startmap1", true)
# get_tree().get_root().add_child(game) # get_tree().get_root().add_child(game)

View File

@ -18,4 +18,5 @@ func _unhandled_input(event):
set_cellv(pl_pos_tile, -1) set_cellv(pl_pos_tile, -1)
func _on_Inventory_pressed(): func _on_Inventory_pressed():
Global.GoToScene("inventory_screen") var inventory_screen = preload("res://MiscScenes/Inventory.tscn").instance()
Global.AddScene(inventory_screen, "inventory_screen", true)