Skip to content

Commit 115e71c

Browse files
committed
Add support for custom extensions: tests + docs + CI update
1 parent a17bf8e commit 115e71c

File tree

9 files changed

+129
-15
lines changed

9 files changed

+129
-15
lines changed

.github/workflows/pandora-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
fail-fast: false
4040
max-parallel: 10
4141
matrix:
42-
godot-version: ["4.3", "4.4"]
42+
godot-version: ["4.4", "4.5.1"]
4343

4444
name: "🤖 CI on Godot ${{ matrix.godot-version }}"
4545
steps:

docs/_sidebar.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@
55
- [🔹 Editor Interface](/concepts/editor.md "🧩 Editor Interface")
66
- [🔹 Categories and Entities](/concepts/entities.md "🧩 Categories and Entities")
77
- [🔹 Properties](/concepts/properties/ "🧩 Properties")
8-
- [🔹 String](/concepts/properties/string.md "🧩 String")
9-
- [🔹 Integer](/concepts/properties/integer.md "🧩 Integer")
10-
- [🔹 Float](/concepts/properties/float.md "🧩 Float")
11-
- [🔹 Bool](/concepts/properties/bool.md "🧩 Bool")
12-
- [🔹 Vector2i](/concepts/properties/vector2i.md "🧩 Vector2i")
13-
- [🔹 Vector2](/concepts/properties/vector2.md "🧩 Vector2")
14-
- [🔹 Vector3i](/concepts/properties/vector3i.md "🧩 Vector3i")
15-
- [🔹 Vector3](/concepts/properties/vector3.md "🧩 Vector3")
16-
- [🔹 Color](/concepts/properties/color.md "🧩 Color")
17-
- [🔹 Reference](/concepts/properties/reference.md "🧩 Reference")
18-
- [🔹 Resource](/concepts/properties/resource.md "🧩 Resource")
19-
- [🔹 Array](/concepts/properties/array.md "🧩 Array")
8+
- [🔹 String](/concepts/properties/string.md "🧩 String")
9+
- [🔹 Integer](/concepts/properties/integer.md "🧩 Integer")
10+
- [🔹 Float](/concepts/properties/float.md "🧩 Float")
11+
- [🔹 Bool](/concepts/properties/bool.md "🧩 Bool")
12+
- [🔹 Vector2i](/concepts/properties/vector2i.md "🧩 Vector2i")
13+
- [🔹 Vector2](/concepts/properties/vector2.md "🧩 Vector2")
14+
- [🔹 Vector3i](/concepts/properties/vector3i.md "🧩 Vector3i")
15+
- [🔹 Vector3](/concepts/properties/vector3.md "🧩 Vector3")
16+
- [🔹 Color](/concepts/properties/color.md "🧩 Color")
17+
- [🔹 Reference](/concepts/properties/reference.md "🧩 Reference")
18+
- [🔹 Resource](/concepts/properties/resource.md "🧩 Resource")
19+
- [🔹 Array](/concepts/properties/array.md "🧩 Array")
2020
- [🔌 GDScript API](/api/)
2121
- [🔹 Accessing Data](/api/access.md "🔌 Accessing Data")
2222
- [🔹 Entity Instancing](/api/instancing.md "🔌 Entity Instancing")
2323
- [🔹 Saving and Loading](/api/saveload.md "🔌 Saving and Loading")
2424
- [🧠 Mastery](/mastery/)
2525
- [🔹 Generating ID Constants](/mastery/id-constants.md "🧠 Generating ID Constants")
2626
- [🔹 Custom Scripts](/mastery/custom-scripts.md "🧠 Custom Scripts")
27+
- [🔹 Custom Extensions](/mastery/custom_extensions.md "🧠 Custom Extensions")
2728
- [🔥 Ignis: The Flame Master's Story](/ignis/)
2829
- [🔹 Crafting Fire Spells](/ignis/spells.md "🔥 Crafting Fire Spells")
2930
- [🔹 Designing the Quest](/ignis/quest.md "🔥 Designing the Quest")
46.5 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://bo47l766jex2a"
6+
path="res://.godot/imported/project_settings_pandora_extensions.png-06f78ae3e4eb3da1bbfe02745f33c5b2.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://docs/assets/project_settings_pandora_extensions.png"
14+
dest_files=["res://.godot/imported/project_settings_pandora_extensions.png-06f78ae3e4eb3da1bbfe02745f33c5b2.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
23+
compress/hdr_compression=1
24+
compress/normal_map=0
25+
compress/channel_pack=0
26+
mipmaps/generate=false
27+
mipmaps/limit=-1
28+
roughness/mode=0
29+
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
34+
process/fix_alpha_border=true
35+
process/premult_alpha=false
36+
process/normal_map_invert_y=false
37+
process/hdr_as_srgb=false
38+
process/hdr_clamp_exposure=false
39+
process/size_limit=0
40+
detect_3d/compress_to=1

docs/assets/test_property.png

26.7 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://eti3nl7vgxa8"
6+
path="res://.godot/imported/test_property.png-1080ebd719ad5d4f9efab45fb62e8bce.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://docs/assets/test_property.png"
14+
dest_files=["res://.godot/imported/test_property.png-1080ebd719ad5d4f9efab45fb62e8bce.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
23+
compress/hdr_compression=1
24+
compress/normal_map=0
25+
compress/channel_pack=0
26+
mipmaps/generate=false
27+
mipmaps/limit=-1
28+
roughness/mode=0
29+
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
34+
process/fix_alpha_border=true
35+
process/premult_alpha=false
36+
process/normal_map_invert_y=false
37+
process/hdr_as_srgb=false
38+
process/hdr_clamp_exposure=false
39+
process/size_limit=0
40+
detect_3d/compress_to=1

docs/mastery/custom-scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ func get_item(id:String) -> Item:
3434
with which you could change the previous code to:
3535
```gdscript
3636
var texture = ItemRepository.get_item(Items.PICKAXE).get_item_texture()
37-
```
37+
```

docs/mastery/custom_extensions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Custom Extensions
2+
3+
Pandora allows you to extend its property system with your own custom property types.
4+
This can be useful when you want to define specific data structures for your game,
5+
such as recipes, drops, or status effects.
6+
7+
## Registering a Custom Extension
8+
To register a new custom property, create a new folder within the **pandora/extensions** folder with the following structure:
9+
_pandora/extensions/new_custom_property_:
10+
- **icons**: This folder is <u>optional</u>, but it could be useful if you want to add icons. The name of this folder is not mandatory; it could also be called assets.
11+
- **model**: This is a required folder. The name must match this one. Inside it, you will create a .gd file that will represent the data model used within and outside of Pandora's ecosystem.
12+
- **types**: Inside the model folder, the types folder must be created. Inside it, you will create a .gd file that <u>extends PandoraPropertyType</u>, which contains the settings, serialization, and deserialization of the new property.
13+
- **property_button**: This is a required folder where you will create a file called property_button.tscn, which will be a <u>PandoraPropertyButton</u> that can be used by the Pandora bar.
14+
- **ui_component**: Mandatory folder, here you will create the scene that will be displayed when you want to use the new custom property.
15+
16+
Once your extension is registered, it will automatically appear in the Pandora property selector, allowing you to use it in your entities and access it at runtime like any other Pandora property.
17+
18+
**NOTE**: If you want to add or change the extensions folder, just go to **Project/Project Settings/Pandora/Config** and set _Extensions_ array:
19+
![custom_extensions](../assets/pandora_settings_custom_extensions.png)
20+
21+
## Example
22+
For a complete and working example of a custom property, take a look at **pandora/extensions/test_property**
23+
![test_property](../assets/test_property.png)

test/settings/pandora_settings_test.gd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ const __source = 'res://addons/pandora/settings/pandora_settings.gd'
1010
const TEST_DIR = "testdata"
1111

1212
const IDType := PandoraSettings.IDType
13+
const EXTENSION_NAME := "test_property"
1314

1415
const SETTING_ID_TYPE := PandoraSettings.SETTING_ID_TYPE
1516
const SETTING_PANDORA_DATA_PATH := PandoraSettings.SETTING_PANDORA_DATA_PATH
16-
17+
const SETTINGS_PANDORA_EXTENSIONS_DIR := PandoraSettings.SETTINGS_PANDORA_EXTENSIONS_DIR
1718

1819
func test_initialize() -> void:
1920
ProjectSettings.clear(SETTING_ID_TYPE)
@@ -96,3 +97,12 @@ func test_set_data_path() -> void:
9697

9798
Pandora._clear()
9899
Pandora.load_data()
100+
101+
func test_compare_with_extensions_models() -> void:
102+
ProjectSettings.clear(SETTINGS_PANDORA_EXTENSIONS_DIR)
103+
PandoraSettings.init_setting(
104+
SETTINGS_PANDORA_EXTENSIONS_DIR, ["res://pandora/extensions"],
105+
TYPE_ARRAY, PROPERTY_HINT_DIR
106+
)
107+
var actual := PandoraSettings.compare_with_extensions_models(EXTENSION_NAME)
108+
assert_bool(actual).is_equal(true)

0 commit comments

Comments
 (0)