feat(blenvy): experimenting with new combined tooling

This commit is contained in:
kaosat.dev 2024-05-12 12:09:11 +02:00
parent 0432769bda
commit e42719daf7
7 changed files with 181 additions and 3 deletions

View File

@ -52,6 +52,10 @@ from .blueprints.operators import OT_select_blueprint
from .helpers.generate_complete_preferences_dict import generate_complete_preferences_dict_gltf
from .blenvy.ui import BLENVY_PT_SidePanel
from .blenvy.blenvy_manager import BlenvyManager
from .blenvy.operators import OT_switch_bevy_tooling
######################################################
"""
@ -126,6 +130,14 @@ classes = [
GLTF_PT_auto_export_SidePanel,
AutoExportTracker,
BlenvyManager,
OT_switch_bevy_tooling,
BLENVY_PT_SidePanel,
AssetsRegistry,
OT_add_bevy_asset,
OT_remove_bevy_asset,
@ -134,7 +146,6 @@ classes = [
BlueprintsRegistry,
OT_select_blueprint,
GLTF_PT_auto_export_blueprints_list,
]
def glTF2_pre_export_callback(data):

View File

@ -4,9 +4,13 @@ class GLTF_PT_auto_export_assets(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Assets"
bl_parent_id = "GLTF_PT_auto_export_SidePanel"
bl_parent_id = "BLENVY_PT_SidePanel"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.window_manager.blenvy.mode == 'ASSETS'
def draw(self, context):
layout = self.layout
layout.use_property_split = True

View File

@ -0,0 +1,32 @@
import bpy
import json
import os
import uuid
from pathlib import Path
from bpy_types import (PropertyGroup)
from bpy.props import (StringProperty, BoolProperty, FloatProperty, FloatVectorProperty, IntProperty, IntVectorProperty, EnumProperty, PointerProperty, CollectionProperty)
class BlenvyManager(PropertyGroup):
mode: EnumProperty(
items=(
('COMPONENTS', "Components", ""),
('BLUEPRINTS', "Blueprints", ""),
('ASSETS', "Assets", ""),
('SETTINGS', "Settings", ""),
)
) # type: ignore
@classmethod
def register(cls):
bpy.types.WindowManager.blenvy = PointerProperty(type=BlenvyManager)
@classmethod
def unregister(cls):
del bpy.types.WindowManager.blenvy
def add_asset(self, name, type, path, internal): # internal means it cannot be edited by the user, aka auto generated
pass

View File

@ -0,0 +1,28 @@
import os
import bpy
from bpy_types import (Operator)
from bpy.props import (StringProperty, EnumProperty)
class OT_switch_bevy_tooling(Operator):
"""Switch bevy tooling"""
bl_idname = "bevy.tooling_switch"
bl_label = "Switch bevy tooling"
bl_options = {"UNDO"}
tool: EnumProperty(
items=(
('COMPONENTS', "Components", ""),
('BLUEPRINTS', "Blueprints", ""),
('ASSETS', "Assets", ""),
('SETTINGS', "Settings", ""),
)
) # type: ignore
def execute(self, context):
context.window_manager.blenvy.mode = self.tool
return {'FINISHED'}

View File

@ -0,0 +1,99 @@
import bpy
import json
######################################################
## ui logic & co
# side panel
class BLENVY_PT_SidePanel(bpy.types.Panel):
bl_idname = "BLENVY_PT_SidePanel"
bl_label = ""
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Bevy"
bl_context = "objectmode"
def draw_header(self, context):
layout = self.layout
layout.label(text="Blenvy")
def draw(self, context):
layout = self.layout
row = layout.row()
blenvy = context.window_manager.blenvy
active_mode = blenvy.mode
world_scene_active = False
library_scene_active = False
current_auto_settings = bpy.data.texts[".gltf_auto_export_settings"] if ".gltf_auto_export_settings" in bpy.data.texts else None
current_gltf_settings = bpy.data.texts[".gltf_auto_export_gltf_settings"] if ".gltf_auto_export_gltf_settings" in bpy.data.texts else None
if current_auto_settings is not None:
current_auto_settings = json.loads(current_auto_settings.as_string())
print("current_auto_settings", current_auto_settings)
main_scene_names = current_auto_settings["main_scene_names"]
library_scene_names = current_auto_settings["library_scene_names"]
world_scene_active = context.scene.name in main_scene_names
library_scene_active = context.scene.name in library_scene_names
# Now to actual drawing of the UI
target = row.box() if active_mode == 'COMPONENTS' else row
tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="PROPERTIES")
tool_switch_components.tool = "COMPONENTS"
target = row.box() if active_mode == 'BLUEPRINTS' else row
tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="PACKAGE")
tool_switch_components.tool = "BLUEPRINTS"
target = row.box() if active_mode == 'ASSETS' else row
tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="ASSET_MANAGER")
tool_switch_components.tool = "ASSETS"
target = row.box() if active_mode == 'SETTINGS' else row
tool_switch_components = target.operator(operator="bevy.tooling_switch", text="", icon="TOOL_SETTINGS")
tool_switch_components.tool = "SETTINGS"
"""row.label(text="", icon="PROPERTIES")
row.label(text="", icon="PACKAGE")
row.label(text="", icon="ASSET_MANAGER")
row.label(text="", icon="TOOL_SETTINGS")"""
layout.label(text="World scene active: "+ str(world_scene_active))
layout.label(text="Library scene active: "+ str(library_scene_active))
layout.label(text=blenvy.mode)
if blenvy.mode == "SETTINGS":
header, panel = layout.panel("auto_export", default_closed=False)
header.label(text="Auto Export")
if panel:
layout = panel
layout.label(text="MAKE SURE TO KEEP 'REMEMBER EXPORT SETTINGS' TOGGLED !!")
op = layout.operator("EXPORT_SCENE_OT_gltf", text='Gltf Settings')#'glTF 2.0 (.glb/.gltf)')
#op.export_format = 'GLTF_SEPARATE'
op.use_selection=True
op.will_save_settings=True
op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip.
op.use_renderable=True
op.use_active_collection = True
op.use_active_collection_with_nested=True
op.use_active_scene = True
op.filepath="____dummy____"
op.gltf_export_id = "gltf_auto_export" # we specify that we are in a special case
op = layout.operator("EXPORT_SCENES_OT_auto_gltf", text="Auto Export Settings")
op.auto_export = True
header, panel = layout.panel("components", default_closed=False)
header.label(text="Components")
if panel:
panel.label(text="YOOO")

View File

@ -4,9 +4,13 @@ class GLTF_PT_auto_export_blueprints_list(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Blueprints"
bl_parent_id = "GLTF_PT_auto_export_SidePanel"
bl_parent_id = "BLENVY_PT_SidePanel"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
return context.window_manager.blenvy.mode == 'BLUEPRINTS'
def draw(self, context):
layout = self.layout
layout.use_property_split = True