Skip to content

Commit 395a56e

Browse files
authored
features/patch 3 (#3)
* Refactor example, add more documentation to readme * Update after opening in engine * Dont need default_env * Remove unused section * Add list with quest names * Good enough basic example
1 parent e90b512 commit 395a56e

14 files changed

+128
-119
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
.#*
33
*~
4+
example/addons
Binary file not shown.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
11
# godot-quest-system
22
Godot Engine (v3.0) Quest System
3+
4+
## Running the example
5+
6+
Copy addons folder to example folder, then open the example folder in Godot. The example folder acts as the base project folder.
7+
8+
## Design considerations
9+
10+
I am attempting to apply Domain-Driven Design principles, with repositories acting as adapters to various underlying infrastructure concerns (database, file, api).
11+
12+
## Persistence implementations
13+
14+
This is probably the biggest problem to solve, how to persist the data. I haven't read up yet on JSON and file read/write in Godot.
15+
16+
If implementing a file-based quest_repository, I suspect you would read in the file, then loop over each line and use it to create a quest.
17+
18+
This could also be implemented via a REST API probably using the HTTP functions.
19+
20+
### Status of SQLite
21+
22+
Broken. When I first started to dive into this, I had no clue what I was doing and was basing the work off of another project.
23+
24+
I think what needs to happen is you would need to bind to a sqlite library via cpp, and then compile a dynamic library for Windows, Linux, and Mac.
25+
26+
### File-based
27+
28+
For a local game, you might implement a file repository. This could be a file-per-quest that you open and read, and maybe an index file to lookup.
29+
30+
### REST-based
31+
32+
Exposing an API, you could have a network/internet/API implementation to find and read quests.
33+
34+
### RDBM-based
35+
36+
It's possible that you could create bindings for Godot server to communicate with an actual RDBM server (mysql, pgsql).
File renamed without changes.

default_env.tres

Lines changed: 0 additions & 99 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.
Loading

icon.png.import renamed to example/icon.png.import

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ importer="texture"
44
type="StreamTexture"
55
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
66

7+
[deps]
8+
9+
source_md5="c3558f79862e8e00c74fb188280dd8ef"
10+
711
[params]
812

913
compress/mode=0
@@ -21,3 +25,4 @@ process/HDR_as_SRGB=false
2125
stream=false
2226
size_limit=0
2327
detect_3d=true
28+
svg/scale=1.0
File renamed without changes.

example/main.gd

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
extends Node2D
1+
extends Node
22

3-
const Quest = preload("res://addons/com.brandonlamb.quest/domain/quest.gd")
4-
const QuestRepo = preload("res://addons/com.brandonlamb.quest/memory/quest_repository.gd")
5-
const QuestFactory = preload("res://addons/com.brandonlamb.quest/memory/quest_factory.gd")
3+
const Quest = preload("res://addons/godot-quest-system/domain/quest.gd")
4+
const QuestRepo = preload("res://addons/godot-quest-system/memory/quest_repository.gd")
5+
const QuestFactory = preload("res://addons/godot-quest-system/memory/quest_factory.gd")
6+
7+
var quest_repo
68

79
func _ready():
8-
var questRepo = QuestRepo.new(QuestFactory.create_from_static())
9-
var quests = questRepo.find_all()
10+
quest_repo = QuestRepo.new(QuestFactory.create_from_static())
11+
var quests = quest_repo.find_all()
1012

1113
for i in quests:
1214
i.connect("started", self, "_on_quest_started")
1315
i.start()
1416

15-
var quest = questRepo.find_by_id(1)
17+
var quest = quest_repo.find_by_id(1)
1618
quest.status = "finished"
1719
print(quest.to_string())
1820
print("quest.to_string()=", quest.to_string())
@@ -21,6 +23,11 @@ func _ready():
2123

2224
for i in quests:
2325
print(i.to_string())
26+
$ui/quests.add_item(i.name)
2427

2528
func _on_quest_started(e):
2629
print("_on_quest_started: ", e.name)
30+
31+
func _on_quests_item_selected( index ):
32+
var quests = quest_repo.find_all()
33+
$ui/quest_info.text = str("Quest: ", quests[index].description)

example/main.tscn

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,56 @@
11
[gd_scene load_steps=2 format=2]
22

3-
[ext_resource path="res://example/main.gd" type="Script" id=1]
3+
[ext_resource path="res://main.gd" type="Script" id=1]
44

5-
[node name="main" type="Node2D"]
5+
[node name="main" type="Node"]
66

77
script = ExtResource( 1 )
88

9+
[node name="ui" type="CanvasLayer" parent="."]
10+
11+
layer = 1
12+
offset = Vector2( 0, 0 )
13+
rotation = 0.0
14+
scale = Vector2( 1, 1 )
15+
16+
[node name="quests" type="ItemList" parent="ui"]
17+
18+
anchor_left = 0.5
19+
anchor_top = 0.0
20+
anchor_right = 0.5
21+
anchor_bottom = 0.0
22+
margin_left = -150.0
23+
margin_top = 50.0
24+
margin_right = 150.0
25+
margin_bottom = 150.0
26+
rect_pivot_offset = Vector2( 0, 0 )
27+
mouse_filter = 0
28+
size_flags_horizontal = 1
29+
size_flags_vertical = 1
30+
items = [ ]
31+
select_mode = 0
32+
max_text_lines = 5
33+
auto_height = true
34+
icon_mode = 1
35+
36+
[node name="quest_info" type="Label" parent="ui"]
37+
38+
anchor_left = 0.5
39+
anchor_top = 1.0
40+
anchor_right = 0.5
41+
anchor_bottom = 1.0
42+
margin_left = -150.0
43+
margin_top = -500.0
44+
margin_right = 150.0
45+
rect_pivot_offset = Vector2( 0, 0 )
46+
rect_clip_content = false
47+
mouse_filter = 2
48+
size_flags_horizontal = 1
49+
size_flags_vertical = 4
50+
percent_visible = 1.0
51+
lines_skipped = 0
52+
max_lines_visible = -1
53+
54+
[connection signal="item_selected" from="ui/quests" to="." method="_on_quests_item_selected"]
55+
956

example/project.godot

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; Engine configuration file.
2+
; It's best edited using the editor UI and not directly,
3+
; since the parameters that go here are not all obvious.
4+
;
5+
; Format:
6+
; [section] ; section goes between []
7+
; param=value ; assign values to parameters
8+
9+
config_version=3
10+
11+
[application]
12+
13+
config/name="godot-quest-system"
14+
run/main_scene="res://main.tscn"
15+
config/icon="res://icon.png"
16+
17+
[display]
18+
19+
window/size/width=360
20+
window/size/height=720
21+
window/size/resizable=false
22+
23+
[gdnative]
24+
25+
singletons=[ ]

project.godot

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

0 commit comments

Comments
 (0)