mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
feat(Blenvy):
* migrated gltf settings handling to the new "generate_complete_settings_dict" helper * tweaks/fixed to the internals of that function to get the actual correct data * minor related tweaks & fixes
This commit is contained in:
parent
2470736f81
commit
2187fee4c8
@ -11,7 +11,6 @@ Auto export
|
|||||||
- blueprints/levels/blueprints path => relative to assets path
|
- blueprints/levels/blueprints path => relative to assets path
|
||||||
- [ ] add error handling for de/serialization of project, so that in case of error, the previous saved serialized project is thrown away
|
- [ ] add error handling for de/serialization of project, so that in case of error, the previous saved serialized project is thrown away
|
||||||
|
|
||||||
|
|
||||||
- move out some parameters from auto export to a higher level (as they are now used in multiple places)
|
- move out some parameters from auto export to a higher level (as they are now used in multiple places)
|
||||||
- [x] main/ library scene names
|
- [x] main/ library scene names
|
||||||
- [x] paths
|
- [x] paths
|
||||||
@ -97,3 +96,8 @@ General issues:
|
|||||||
- [x] auto_export
|
- [x] auto_export
|
||||||
- [x] components
|
- [x] components
|
||||||
- [ ] add handling of errors when trying to load settings
|
- [ ] add handling of errors when trying to load settings
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] force overwrite of settings files instead of partial updates ?
|
||||||
|
- [ ] add tests for disabled components
|
||||||
|
- [ ] fix auto export workflow
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import bpy
|
import bpy
|
||||||
from .helpers.generate_complete_preferences_dict import generate_complete_preferences_dict_gltf
|
from blenvy.settings import generate_complete_settings_dict
|
||||||
|
from io_scene_gltf2 import ExportGLTF2_Base
|
||||||
|
|
||||||
|
|
||||||
def cleanup_file():
|
def cleanup_file():
|
||||||
gltf_filepath = bpy.context.window_manager.auto_export_tracker.dummy_file_path
|
gltf_filepath = bpy.context.window_manager.auto_export_tracker.dummy_file_path
|
||||||
@ -36,7 +38,8 @@ def gltf_post_export_callback(data):
|
|||||||
# now write new settings
|
# now write new settings
|
||||||
gltf_export_settings.clear()
|
gltf_export_settings.clear()
|
||||||
|
|
||||||
current_gltf_settings = generate_complete_preferences_dict_gltf(dict(settings))
|
settings = dict(settings)
|
||||||
|
current_gltf_settings = generate_complete_settings_dict(settings, presets=ExportGLTF2_Base, ignore_list=["use_active_collection", "use_active_collection_with_nested", "use_active_scene", "use_selection", "will_save_settings", "gltf_export_id"], preset_defaults=True)
|
||||||
gltf_export_settings.write(json.dumps(current_gltf_settings))
|
gltf_export_settings.write(json.dumps(current_gltf_settings))
|
||||||
# now reset the original gltf_settings
|
# now reset the original gltf_settings
|
||||||
if gltf_settings_backup != "":
|
if gltf_settings_backup != "":
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
|
|
||||||
from io_scene_gltf2 import (ExportGLTF2_Base)
|
|
||||||
|
|
||||||
# given the input (actual) gltf settings, filters out any invalid/useless params & params that are equal to defaults
|
|
||||||
def generate_complete_preferences_dict_gltf(settings):
|
|
||||||
complete_preferences = {}
|
|
||||||
defaults = {}
|
|
||||||
gltf_parameters_to_ignore = ["use_active_collection", "use_active_collection_with_nested", "use_active_scene", "use_selection", "will_save_settings", "gltf_export_id"]
|
|
||||||
def filter_out(pair):
|
|
||||||
key, value = pair
|
|
||||||
if key in gltf_parameters_to_ignore:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
for k in ExportGLTF2_Base.__annotations__: # we use parameters from the base class of the standard gltf exporter, that contains all relevant parameters
|
|
||||||
item = ExportGLTF2_Base.__annotations__[k]
|
|
||||||
#print("item", item)
|
|
||||||
default = item.keywords.get('default', None)
|
|
||||||
#complete_preferences[k] = default
|
|
||||||
defaults[k] = default
|
|
||||||
|
|
||||||
for key in list(settings.keys()):
|
|
||||||
if key in defaults and settings[key] != defaults[key]: # only write out values different from defaults
|
|
||||||
complete_preferences[key] = settings[key]
|
|
||||||
|
|
||||||
complete_preferences = dict(filter(filter_out, dict(complete_preferences).items()))
|
|
||||||
return complete_preferences
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy_types import (PropertyGroup)
|
from bpy_types import (PropertyGroup)
|
||||||
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty)
|
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty)
|
||||||
from blenvy.settings import load_settings, upsert_settings, generate_complete_preferences_dict
|
from blenvy.settings import load_settings, upsert_settings, generate_complete_settings_dict
|
||||||
|
|
||||||
# list of settings we do NOT want to save
|
# list of settings we do NOT want to save
|
||||||
settings_black_list = ['settings_save_enabled', 'dry_run']
|
settings_black_list = ['settings_save_enabled', 'dry_run']
|
||||||
|
|
||||||
def save_settings(settings, context):
|
def save_settings(settings, context):
|
||||||
if settings.settings_save_enabled:
|
if settings.settings_save_enabled:
|
||||||
settings_dict = generate_complete_preferences_dict(settings, AutoExportSettings, [])
|
settings_dict = generate_complete_settings_dict(settings, AutoExportSettings, [])
|
||||||
print("save settings", settings, context, settings_dict)
|
print("save settings", settings, context, settings_dict)
|
||||||
upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ class OT_OpenSchemaFileBrowser(Operator, ImportHelper):
|
|||||||
|
|
||||||
blenvy = context.window_manager.blenvy
|
blenvy = context.window_manager.blenvy
|
||||||
blenvy.components.schema_path = relative_path
|
blenvy.components.schema_path = relative_path
|
||||||
upsert_settings(blenvy.settings_save_path, {"components_schemaPath": relative_path})
|
upsert_settings(blenvy.components.settings_save_path, {"schema_path": relative_path})
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy_types import (PropertyGroup)
|
from bpy_types import (PropertyGroup)
|
||||||
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty)
|
from bpy.props import (EnumProperty, PointerProperty, StringProperty, BoolProperty, CollectionProperty, IntProperty)
|
||||||
from blenvy.settings import load_settings, upsert_settings, generate_complete_preferences_dict
|
from blenvy.settings import load_settings, upsert_settings, generate_complete_settings_dict
|
||||||
from .propGroups.prop_groups import generate_propertyGroups_for_components
|
from .propGroups.prop_groups import generate_propertyGroups_for_components
|
||||||
from .components.metadata import ensure_metadata_for_all_items
|
from .components.metadata import ensure_metadata_for_all_items
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ settings_black_list = ['settings_save_enabled', 'watcher_active']
|
|||||||
|
|
||||||
def save_settings(settings, context):
|
def save_settings(settings, context):
|
||||||
if settings.settings_save_enabled:
|
if settings.settings_save_enabled:
|
||||||
settings_dict = generate_complete_preferences_dict(settings, ComponentsSettings, [])
|
settings_dict = generate_complete_settings_dict(settings, ComponentsSettings, [])
|
||||||
print("save settings", settings, context,settings_dict)
|
print("save settings", settings, context,settings_dict)
|
||||||
upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import bpy
|
|||||||
from bpy_types import (PropertyGroup)
|
from bpy_types import (PropertyGroup)
|
||||||
from bpy.props import (BoolProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty, IntProperty)
|
from bpy.props import (BoolProperty, EnumProperty, PointerProperty, StringProperty, CollectionProperty, IntProperty)
|
||||||
from .scene_helpers import SceneSelector
|
from .scene_helpers import SceneSelector
|
||||||
from ..settings import upsert_settings, load_settings, generate_complete_preferences_dict
|
from ..settings import upsert_settings, load_settings, generate_complete_settings_dict
|
||||||
import blenvy.add_ons.auto_export.settings as auto_export_settings
|
import blenvy.add_ons.auto_export.settings as auto_export_settings
|
||||||
import blenvy.add_ons.bevy_components.settings as component_settings
|
import blenvy.add_ons.bevy_components.settings as component_settings
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ settings_black_list = ['settings_save_enabled', 'main_scene_selector', 'main_sce
|
|||||||
|
|
||||||
def save_settings(settings, context):
|
def save_settings(settings, context):
|
||||||
if settings.settings_save_enabled:
|
if settings.settings_save_enabled:
|
||||||
settings_dict = generate_complete_preferences_dict(settings, BlenvyManager, [])
|
settings_dict = generate_complete_settings_dict(settings, BlenvyManager, [])
|
||||||
print("save settings", settings, context, settings_dict)
|
print("save settings", settings, context, settings_dict)
|
||||||
# upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
# upsert_settings(settings.settings_save_path, {key: settings_dict[key] for key in settings_dict.keys() if key not in settings_black_list})
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def load_settings(name):
|
|||||||
|
|
||||||
|
|
||||||
# given the input (actual) settings, filters out any invalid/useless params & params that are equal to defaults
|
# given the input (actual) settings, filters out any invalid/useless params & params that are equal to defaults
|
||||||
def generate_complete_preferences_dict(settings, presets, ignore_list=[], preset_defaults=True):
|
def generate_complete_settings_dict(settings, presets, ignore_list=[], preset_defaults=True):
|
||||||
complete_preferences = {}
|
complete_preferences = {}
|
||||||
defaults = {}
|
defaults = {}
|
||||||
|
|
||||||
@ -40,12 +40,18 @@ def generate_complete_preferences_dict(settings, presets, ignore_list=[], preset
|
|||||||
defaults[k] = default
|
defaults[k] = default
|
||||||
if preset_defaults:
|
if preset_defaults:
|
||||||
complete_preferences[k] = default
|
complete_preferences[k] = default
|
||||||
# print("defaults", defaults)
|
#print("defaults", defaults)
|
||||||
|
|
||||||
|
|
||||||
for key in list(settings.keys()):
|
for key in list(settings.keys()):
|
||||||
if key in defaults and settings[key] != defaults[key]: # only write out values different from defaults
|
if key in defaults and settings[key] != defaults[key]: # only write out values different from defaults
|
||||||
complete_preferences[key] = getattr(settings, key, None)
|
value = getattr(settings, key, None) # this is needed for most of our settings (PropertyGroups)
|
||||||
|
if value is None:
|
||||||
|
value = settings[key] # and this for ...gltf settings
|
||||||
|
complete_preferences[key] = value
|
||||||
|
#print("setting", key, value, settings[key], settings)
|
||||||
|
|
||||||
|
|
||||||
complete_preferences = dict(filter(filter_out, dict(complete_preferences).items()))
|
complete_preferences = dict(filter(filter_out, dict(complete_preferences).items()))
|
||||||
|
|
||||||
return complete_preferences
|
return complete_preferences
|
||||||
|
Loading…
Reference in New Issue
Block a user