mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Added DB Browser and a basic SQLite DB for the project
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
extends Resource
|
||||
|
||||
# Authors Luke Gebbink
|
||||
# Last Changed 10/03/2021
|
||||
# found
|
||||
#
|
||||
|
||||
class_name SaveGame
|
||||
|
||||
export var game_version : String = ''
|
||||
export var data : Dictionary = {}
|
||||
|
||||
|
||||
# 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
|
@ -0,0 +1,36 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
var time_start = 0
|
||||
var time_now = 0
|
||||
|
||||
class_name WorldObject
|
||||
var Players: String = ''
|
||||
var Scene: Scene
|
||||
var History: = Array()
|
||||
var decisions:
|
||||
var totalTime:
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
time_start = OS.get_unix_time()
|
||||
set_process(true)
|
||||
|
||||
# Should we tie time to the save files or the application?
|
||||
# I would think the save files.
|
||||
|
||||
func _process(delta):
|
||||
time_now = OS.get_unix_time()
|
||||
var elapsed = time_now - time_start
|
||||
var minutes = elapsed / 60
|
||||
var seconds = elapsed % 60
|
||||
var str_elapsed = "%02d : %02d" % [minutes, seconds]
|
||||
print("elapsed : ", str_elapsed)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
@ -0,0 +1,43 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
const SaveGame = preload('res://SaveSystem/GameSave.gd')
|
||||
|
||||
var SAVE_FOLDER : String = "res://SaveSystem/SaveLocations"
|
||||
var SAVE_NAME_TEMPLATE : String = "save_%03D.tres"
|
||||
|
||||
func save(id : int):
|
||||
"""
|
||||
Passes a save game resource to all nodes to save data from and writes it to the disk
|
||||
Modfied from GDQuest's Godot Lesson Found Here: https://www.youtube.com/watch?v=ML-hiNytIqE
|
||||
"""
|
||||
var save_game := SaveGame.new()
|
||||
save_game.game_version = ProjectSettings.get_setting("application/config/version")
|
||||
for node in get_tree().get_nodes_in_group('save'):
|
||||
node.save(save_game)
|
||||
|
||||
var directory : Directory = Directory.new()
|
||||
if not directory.dir.exists(SAVE_FOLDER):
|
||||
directory.make_dir_recursive(SAVE_FOLDER)
|
||||
|
||||
var save_path = SAVE_FOLDER.plus_file(SAVE_NAME_TEMPLATE % id)
|
||||
var error : int = ResourceSaver.save(save_path, save_game)
|
||||
if error != OK:
|
||||
print('There was an issue writing the save %s to %s' % [id, save_path])
|
||||
|
||||
func load(id : int):
|
||||
var save_file_path : String = SAVE_FOLDER.plus_file(SAVE_NAME_TEMPLATE % id)
|
||||
var file : File = File.new()
|
||||
if not file.file_exists(save_file_path):
|
||||
print("Save file %s doesn't exist" % save_file_path)
|
||||
return
|
||||
|
||||
var save_game : Resource = load(save_file_path)
|
||||
for node in get_tree().get_nodes_in_group('save'):
|
||||
node.load(save_game)
|
||||
|
||||
|
Reference in New Issue
Block a user