8 Commits

Author SHA1 Message Date
a1f4a7cfe0 feat(block): add block texture types and sounds
Introduce BlockTextureType and BlockSound, parse texture and sound configs from block JSON, and add data() accessors to BlockManager.
2026-08-08 21:19:00 +08:00
bbba25e365 feat(gameplay): add creature manager for resource resolution
Introduce CreatureManager to load per-creature JSON definitions and centralize
model, animation, and collision resource locations. Refactor model and hitbox
managers to use CreatureManager lookups instead of hardcoded asset path
patterns. Also update ResourceLocation asset path helpers to return
std::filesystem::path and use shared JSON parsing utilities.
2026-08-08 18:33:32 +08:00
4268dc6047 refactor(block): migrate block data to JSON and resource locations
Replace TOML block definitions with JSON files loaded from asset locations. Block names are now ResourceLocation keys, IDs are resolved from registry.json, and reusable JSON parsing helpers were added.
2026-08-08 17:50:18 +08:00
cc95fb0f9d refactor(i18n): namespace item translation keys with cubed 2026-08-08 16:19:28 +08:00
10d2e4a813 feat(assets): add normal maps and item/creature definitions
Add normal map references to block JSONs, add creature definitions for pig and player, and create item definitions. Move models and normal textures into the cubed asset namespace, replacing legacy item files.
2026-08-08 15:50:55 +08:00
782c7c6092 refactor(cubed): migrate block definitions to JSON
Move block data from TOML to JSON under assets/cubed/blocks, add registry.json for block and item IDs, and relocate textures and sounds to the cubed namespace.
2026-08-08 15:35:40 +08:00
bc4bbe1ff2 refactor(tools): replace name_space parser with ResourceLocation 2026-08-08 14:56:52 +08:00
zhenyan121
1baa2d6672 feature: screenshot (#39)
* build: add stb image write lib

* feat(renderer): add screenshot capture with F2

* feat(screenshot): add screenshot viewer scene

Add SCREENSHOT scene and UI to browse screenshots from the main menu,
with localization for English and Chinese. Also allow image loading
by full path and replace scene-operation asserts with error logs.

* feat(ui): handle window resize in ScreenshotUI

* feat(ui): add ScrollView widget and dynamic layout on resize

Introduces a ScrollView widget with mouse wheel support and viewport clipping.
Credits and screenshot screens now use it and recompute layout on window resize.
Offset storage switched from ivec2 to vec2 with new accessors.

* feat(ui): add lightbox viewer for screenshots

Add a lightbox to preview screenshots on click. Introduce Button::set_texture for image-backed buttons, add widget getters for window size and visibility, and block background input while the lightbox is open. Close the lightbox with Escape or a left-click.

* feat(ui): add screenshot button to pause menu

Add a button to open the screenshot scene from the pause menu.
Also enable linear filtering on screenshot textures for smoother scaling.

* feat(ui): add show in file manager button to screenshot view

- Add Tools::open_file_manager helper with Windows and Linux support.
- Ensure screenshot directory is created before scanning.
- Add localization keys for en_US and zh_CN.

* feat(screenshot-ui): add newest/oldest sort selector

Add a combo button to the screenshot gallery to sort files by modification time (newest or oldest first). Store timestamp per image and rebuild layout when sort order changes. Include translations for en_US and zh_CN.

* fix: correct argument typo and path/error handling

Fix --enable-consolelog flag, screenshot filter bug, paths to C APIs, add includes and gitignore entries, and improve ShellExecuteW failure detection.

* fix(audio): improve source management and OpenAL diagnostics

Fix null deref when source pool is full, initialize m_using, and improve source state handling. Add OpenAL vendor/version/renderer logging and correct voice PCM span type.

* fix(client_entity_manager): store find result before assert

* fix(tools): switch datetime format to underscore-separated

Use %Y-%m-%d_%H-%M-%S instead of %F %T to avoid colons and spaces, making output suitable for file names.

* fix: initialize uninitialized member variables

Add default member initializers across various classes to prevent undefined behavior from uninitialized fields, and initialize the neighbor biome array in the chunk generator.

* feat(texture_manager): add check_exist option for image loading

Add a `check_exist` parameter to `get_image_texture` and `load_image_texture`, enabling callers to skip file existence checks. Log an error and return nullptr when image data fails to load. Update screenshot UI to support uppercase image extensions and gracefully ignore unreadable images.
2026-08-08 14:20:28 +08:00
249 changed files with 1309 additions and 478 deletions

1
.gitignore vendored
View File

@@ -14,6 +14,7 @@
*.pch
*.sbr
build/
build_debug/
Build/
bin/
Debug/

View File

@@ -0,0 +1,14 @@
{
"name": "air",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": true,
"is_passable": true,
"is_discard": true,
"is_blend": false,
"is_transitional": false,
"is_gas": true,
"roughness": 1.0
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "dirt",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": true,
"is_gas": false,
"roughness": 1.0
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/dirt",
"normal": "cubed:normals/blocks/dirt"
},
"sounds": {
"break": "cubed:sounds/blocks/dirt/break.ogg",
"place": "cubed:sounds/blocks/dirt/place.ogg",
"walk": "cubed:sounds/blocks/dirt/walk.ogg"
}
}

View File

@@ -0,0 +1,22 @@
{
"name": "grass",
"properties": {
"is_liquid": false,
"is_cross_plane": true,
"is_transparent": true,
"is_passable": true,
"is_discard": true,
"is_blend": false,
"is_transitional": false,
"is_gas": false,
"roughness": 0.9
},
"texture": {
"type": "cross",
"path": "cubed:textures/blocks/grass"
},
"sounds": {
"break": "cubed:sounds/blocks/grass/break.ogg",
"place": "cubed:sounds/blocks/grass/place.ogg"
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "grass_block",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": true,
"is_gas": false,
"roughness": 0.9
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/grass_block",
"normal": "cubed:normals/blocks/grass_block"
},
"sounds": {
"break": "cubed:sounds/blocks/grass_block/break.ogg",
"place": "cubed:sounds/blocks/grass_block/place.ogg",
"walk": "cubed:sounds/blocks/grass_block/walk.ogg"
}
}

View File

@@ -0,0 +1,23 @@
{
"name": "leaf",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": true,
"is_passable": false,
"is_discard": true,
"is_blend": false,
"is_transitional": false,
"is_gas": false,
"roughness": 0.7
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/leaf"
},
"sounds": {
"break": "cubed:sounds/blocks/leaf/break.ogg",
"place": "cubed:sounds/blocks/leaf/place.ogg",
"walk": "cubed:sounds/blocks/leaf/walk.ogg"
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "log",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": false,
"is_gas": false,
"roughness": 0.7
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/log",
"normal": "cubed:normals/blocks/log"
},
"sounds": {
"break": "cubed:sounds/blocks/log/break.ogg",
"place": "cubed:sounds/blocks/log/place.ogg",
"walk": "cubed:sounds/blocks/log/walk.ogg"
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "sand",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": true,
"is_gas": false,
"roughness": 0.8
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/sand",
"normal": "cubed:normals/blocks/sand"
},
"sounds": {
"break": "cubed:sounds/blocks/sand/break.ogg",
"place": "cubed:sounds/blocks/sand/place.ogg",
"walk": "cubed:sounds/blocks/sand/walk.ogg"
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "snowy_grass_block",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": true,
"is_gas": false,
"roughness": 0.9
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/snowy_grass_block",
"normal": "cubed:normals/blocks/snowy_grass_block"
},
"sounds": {
"break": "cubed:sounds/blocks/snowy_grass_block/break.ogg",
"place": "cubed:sounds/blocks/snowy_grass_block/place.ogg",
"walk": "cubed:sounds/blocks/snowy_grass_block/walk.ogg"
}
}

View File

@@ -0,0 +1,24 @@
{
"name": "stone",
"properties": {
"is_liquid": false,
"is_cross_plane": false,
"is_transparent": false,
"is_passable": false,
"is_discard": false,
"is_blend": false,
"is_transitional": true,
"is_gas": false,
"roughness": 0.75
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/stone",
"normal": "cubed:normals/blocks/stone"
},
"sounds": {
"break": "cubed:sounds/blocks/stone/break.ogg",
"place": "cubed:sounds/blocks/stone/place.ogg",
"walk": "cubed:sounds/blocks/stone/walk.ogg"
}
}

View File

@@ -0,0 +1,18 @@
{
"name": "water",
"properties": {
"is_liquid": true,
"is_cross_plane": false,
"is_transparent": true,
"is_passable": true,
"is_discard": false,
"is_blend": true,
"is_transitional": false,
"is_gas": false,
"roughness": 0.02
},
"texture": {
"type": "cuboid",
"path": "cubed:textures/blocks/water"
}
}

View File

@@ -0,0 +1,6 @@
{
"name": "pig",
"model": "cubed:models/creatures/pig/pig.glb",
"animation": "cubed:models/creatures/pig/animation.json",
"collision": "cubed:models/creatures/pig/collision.json"
}

View File

@@ -0,0 +1,5 @@
{
"name": "player",
"model": "cubed:models/creatures/player/player.glb",
"collision": "cubed:models/creatures/player/collision.json"
}

View File

@@ -0,0 +1,7 @@
{
"name": "air",
"type": "block",
"block": "cubed:air",
"texture": "cubed:textures/items/block/air.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "dirt",
"type": "block",
"block": "cubed:dirt",
"texture": "cubed:textures/items/block/dirt.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "grass",
"type": "block",
"block": "cubed:grass",
"texture": "cubed:textures/items/block/grass.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "grass_block",
"type": "block",
"block": "cubed:grass_block",
"texture": "cubed:textures/items/block/grass_block.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "leaf",
"type": "block",
"block": "cubed:leaf",
"texture": "cubed:textures/items/block/leaf.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "log",
"type": "block",
"block": "cubed:log",
"texture": "cubed:textures/items/block/log.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "pig_spawn_egg",
"type": "spawn_egg",
"creature": "cubed:pig",
"texture": "cubed:textures/items/spawn_egg/pig_spawn_egg.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "sand",
"type": "block",
"block": "cubed:sand",
"texture": "cubed:textures/items/block/sand.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "snowy_grass_block",
"type": "block",
"block": "cubed:snowy_grass_block",
"texture": "cubed:textures/items/block/snowy_grass_block.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "stone",
"type": "block",
"block": "cubed:stone",
"texture": "cubed:textures/items/block/stone.png",
"description": ""
}

View File

@@ -0,0 +1,7 @@
{
"name": "water",
"type": "block",
"block": "cubed:water",
"texture": "cubed:textures/items/block/water.png",
"description": ""
}

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 955 B

After

Width:  |  Height:  |  Size: 955 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 955 B

After

Width:  |  Height:  |  Size: 955 B

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,27 @@
{
"blocks": {
"air": 0,
"grass_block": 1,
"dirt": 2,
"stone": 3,
"sand": 4,
"log": 5,
"leaf": 6,
"water": 7,
"snowy_grass_block": 8,
"grass": 9
},
"items": {
"air": 0,
"grass_block": 1,
"dirt": 2,
"stone": 3,
"sand": 4,
"log": 5,
"leaf": 6,
"water": 7,
"snowy_grass_block": 8,
"grass": 9,
"pig_spawn_egg": 10
}
}

Some files were not shown because too many files have changed in this diff Show More