Skip to content

Commit f4ed34e

Browse files
committed
update feedback.
1 parent aa7207f commit f4ed34e

File tree

8 files changed

+35
-52
lines changed

8 files changed

+35
-52
lines changed

SConstruct

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target = "{}{}".format(
2121

2222
# tweak this if you want to use different folders, or more folders, to store your source code in.
2323
env.Append(CPPPATH=["src/"])
24-
sources = [Glob('src/*.cpp'), Glob('src/vfs/*.cpp'), 'src/sqlite/sqlite3.c']
24+
sources = [Glob('src/*.cpp'), Glob('src/vfs/*.cpp'), Glob('src/resource/*.cpp'), 'src/sqlite/sqlite3.c']
2525

2626
if env["platform"] == "macos":
2727
target = "{}.{}.{}.framework/{}.{}.{}".format(
@@ -40,4 +40,4 @@ else:
4040
)
4141

4242
library = env.SharedLibrary(target=target, source=sources)
43-
Default(library)
43+
Default(library)

demo/database.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func example_of_basic_database_querying():
7676
table_dict["salary"] = {"data_type":"real"}
7777

7878
db = SQLite.new()
79-
db.path = db_resource.resource_name
79+
db.path = db_resource.resource_path
8080
db.verbosity_level = verbosity_level
8181
# Open the database using the db_name found in the path variable
8282
db.open_db()

src/register_types.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,13 @@
88
#include <godot_cpp/godot.hpp>
99

1010
#include "gdsqlite.h"
11-
#include "resource_loader_sqlite.h"
12-
#include "resource_sqlite.h"
11+
#include "resource/resource_loader_sqlite.h"
12+
#include "resource/resource_sqlite.h"
1313

1414
using namespace godot;
1515

1616
static Ref<ResourceFormatLoaderSQLite> sqlite_loader;
17-
18-
void register_setting(
19-
const String &p_name,
20-
const Variant &p_value,
21-
PropertyHint p_hint,
22-
const String &p_hint_string,
23-
bool restart_if_changed) {
24-
ProjectSettings *project_settings = ProjectSettings::get_singleton();
25-
26-
if (!project_settings->has_setting(p_name)) {
27-
project_settings->set(p_name, p_value);
28-
}
29-
30-
Dictionary property_info;
31-
property_info["name"] = p_name;
32-
property_info["type"] = p_value.get_type();
33-
property_info["hint"] = p_hint;
34-
property_info["hint_string"] = p_hint_string;
35-
36-
project_settings->add_property_info(property_info);
37-
project_settings->set_initial_value(p_name, p_value);
38-
project_settings->set_restart_if_changed(p_name, true);
39-
}
17+
const char * DEFAULT_DB_NAME = "filesystem/import/sqlite/default_extension";
4018

4119
void initialize_sqlite_module(ModuleInitializationLevel p_level) {
4220
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
@@ -51,7 +29,19 @@ void initialize_sqlite_module(ModuleInitializationLevel p_level) {
5129
ResourceLoader::get_singleton()->add_resource_format_loader(sqlite_loader);
5230
PackedStringArray array;
5331
array.push_back("db");
54-
register_setting("filesystem/import/sqlite/default_extension", array, PROPERTY_HINT_NONE, {}, true);
32+
33+
ProjectSettings *project_settings = ProjectSettings::get_singleton();
34+
35+
if (!project_settings->has_setting(DEFAULT_DB_NAME)) {
36+
project_settings->set(DEFAULT_DB_NAME, "");
37+
}
38+
39+
Dictionary property_info;
40+
property_info["name"] = DEFAULT_DB_NAME;
41+
property_info["type"] = godot::Variant::Type::STRING;
42+
43+
project_settings->add_property_info(property_info);
44+
project_settings->set_initial_value(DEFAULT_DB_NAME, "db");
5545
}
5646

5747
void uninitialize_sqlite_module(ModuleInitializationLevel p_level) {
File renamed without changes.
File renamed without changes.

src/resource/resource_sqlite.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "resource_sqlite.h"
2+
#include <iostream>
3+
4+
#include <godot_cpp/classes/file_access.hpp>
5+
6+
7+
void SQLiteResource::set_file(const String &p_file) {
8+
file = p_file;
9+
emit_changed();
10+
}
11+
12+
String SQLiteResource::get_file() {
13+
return file;
14+
}

src/resource_sqlite.h renamed to src/resource/resource_sqlite.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,7 @@ class SQLiteResource : public Resource {
1313
String file;
1414

1515
public:
16-
void set_file(const String &p_file) {
17-
file = p_file;
18-
emit_changed();
19-
}
20-
21-
String get_file() {
22-
return file;
23-
}
24-
25-
PackedByteArray get_content();
26-
SQLiteResource() {}
27-
~SQLiteResource() {}
16+
void set_file(const String &p_file);
17+
String get_file();
2818
};
2919
#endif // SQLITE_RESOURCE_H

src/resource_sqlite.cpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)