Added a force save all chunks button to TerrainWorld's inspector if a TerrainWorldChunkDataManager is set.

This commit is contained in:
Relintai 2025-04-07 17:37:26 +02:00
parent 9fefe64c3b
commit b7bfd13ec4
2 changed files with 16 additions and 0 deletions

View File

@ -1505,6 +1505,18 @@ void TerrainWorld::_generate_chunk(Ref<TerrainChunk> chunk) {
}
}
void TerrainWorld::_editor_button_property_pressed(const StringName &p_property) {
if (p_property == "force_save_all_chunks") {
force_save_all_chunks();
}
}
void TerrainWorld::_get_property_list(List<PropertyInfo> *p_list) const {
if (_world_chunk_data_manager.is_valid()) {
p_list->push_back(PropertyInfo(Variant::NIL, "force_save_all_chunks", PROPERTY_HINT_BUTTON, "_editor_button_property_pressed:Save/EditorIcons"));
}
}
void TerrainWorld::_validate_property(PropertyInfo &property) const {
if (property.name == "chunks") {
if (_world_chunk_data_manager.is_valid()) {
@ -1872,6 +1884,8 @@ void TerrainWorld::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_editor_camera"), &TerrainWorld::get_editor_camera);
ClassDB::bind_method(D_METHOD("_editor_button_property_pressed"), &TerrainWorld::_editor_button_property_pressed);
#ifdef MODULE_VERTEX_LIGHTS_3D_ENABLED
ClassDB::bind_method(D_METHOD("_on_vertex_lights_3d_map_changed"), &TerrainWorld::_on_vertex_lights_3d_map_changed);
#endif

View File

@ -240,6 +240,8 @@ protected:
virtual Ref<TerrainChunk> _create_chunk(int x, int z, Ref<TerrainChunk> p_chunk);
virtual int _get_channel_index_info(const ChannelTypeInfo channel_type);
void _editor_button_property_pressed(const StringName &p_property);
void _get_property_list(List<PropertyInfo> *p_list) const;
virtual void _validate_property(PropertyInfo &property) const;
virtual void _notification(int p_what);
static void _bind_methods();