Skip to content

Commit

Permalink
draw some ui and props and stuff, rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Oct 7, 2024
1 parent ea9dc68 commit bcbcf09
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 17 deletions.
3 changes: 2 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from .fast64_internal.mk64 import MK64_Properties, mk64_register, mk64_unregister

from .fast64_internal.f3d import f3d_register, f3d_unregister
from .fast64_internal.f3d import f3d_register, f3d_unregister, F3D_Properties
from .fast64_internal.f3d.f3d_material import F3D_MAT_CUR_VERSION, check_or_ask_color_management
from .fast64_internal.f3d_material_converter import upgrade_f3d_version_all_meshes

Expand Down Expand Up @@ -156,6 +156,7 @@ class Fast64_Properties(bpy.types.PropertyGroup):
sm64: bpy.props.PointerProperty(type=SM64_Properties, name="SM64 Properties")
oot: bpy.props.PointerProperty(type=OOT_Properties, name="OOT Properties")
mk64: bpy.props.PointerProperty(type=MK64_Properties, name="MK64 Properties")
f3d: bpy.props.PointerProperty(type=F3D_Properties, name="F3D Properties")
settings: bpy.props.PointerProperty(type=Fast64Settings_Properties, name="Fast64 Settings")
renderSettings: bpy.props.PointerProperty(type=Fast64RenderSettings_Properties, name="Fast64 Render Settings")

Expand Down
24 changes: 20 additions & 4 deletions fast64_internal/f3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import bpy
from bpy.utils import register_class, unregister_class
from bpy.props import PointerProperty
from bpy.types import PropertyGroup

from ... import addon_updater_ops
from ..utility_anim import ArmatureApplyWithMeshOperator
Expand All @@ -11,7 +13,12 @@
from .f3d_parser import f3d_parser_register, f3d_parser_unregister
from .flipbook import flipbook_register, flipbook_unregister
from .op_largetexture import op_largetexture_register, op_largetexture_unregister, ui_oplargetexture
from .bsdf_converter import bsdf_converter_register, bsdf_converter_unregister, bsdf_converter_panel_draw
from .bsdf_converter import (
bsdf_converter_register,
bsdf_converter_unregister,
bsdf_converter_panel_draw,
F3D_BSDFConverterProperties,
)


class F3D_GlobalSettingsPanel(bpy.types.Panel):
Expand Down Expand Up @@ -81,7 +88,16 @@ def draw(self, context):
addon_updater_ops.update_notice_box_ui(self, context)


classes = tuple()
class F3D_Properties(PropertyGroup):
"""
Properties in scene.fast64.f3d.
All new scene f3d properties should be children of this property group.
"""

bsdf_converter: PointerProperty(name="BSDF Converter", type=F3D_BSDFConverterProperties)


classes = (F3D_Properties,)
panel_classes = (F3D_GlobalSettingsPanel, Fast64_GlobalToolsPanel)


Expand All @@ -98,8 +114,6 @@ def f3d_panel_unregister():
def f3d_register(register_panels: bool):
from ..f3d_material_converter import mat_updater_register

for cls in classes:
register_class(cls)
mat_register()
render_engine_register()
mat_updater_register()
Expand All @@ -108,6 +122,8 @@ def f3d_register(register_panels: bool):
f3d_parser_register()
op_largetexture_register()
bsdf_converter_register()
for cls in classes:
register_class(cls)

if register_panels:
f3d_panel_register()
Expand Down
3 changes: 3 additions & 0 deletions fast64_internal/f3d/bsdf_converter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from .operators import bsdf_converter_ops_register, bsdf_converter_ops_unregister
from .ui import bsdf_converter_panel_draw
from .properties import F3D_BSDFConverterProperties, bsdf_converter_props_register, bsdf_converter_props_unregister


def bsdf_converter_register():
bsdf_converter_ops_register()
bsdf_converter_props_register()


def bsdf_converter_unregister():
bsdf_converter_ops_unregister()
bsdf_converter_props_unregister()
11 changes: 0 additions & 11 deletions fast64_internal/f3d/bsdf_converter/classes.py

This file was deleted.

20 changes: 20 additions & 0 deletions fast64_internal/f3d/bsdf_converter/converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from bpy.types import Object

import dataclasses


@dataclasses.dataclass
class SimpleN64Texture:
name: str


@dataclasses.dataclass
class SimpleN64Material:
name: str


def obj_to_f3d(obj: Object):
print(f"Converting BSDF materials in {obj.name}")

def obj_to_bsdf(obj: Object):
print(f"Converting F3D materials in {obj.name}")
28 changes: 28 additions & 0 deletions fast64_internal/f3d/bsdf_converter/operators.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
from bpy.utils import register_class, unregister_class
from bpy.props import EnumProperty
from bpy.types import Context

from ...operators import OperatorBase

from .converter import obj_to_f3d, obj_to_bsdf

converter_enum = [("Object", "Selected Objects", "Object"), ("Scene", "Scene", "Scene")]


class F3D_ConvertF3DToBSDF(OperatorBase):
bl_idname = "scene.f3d_convert_to_bsdf"
bl_label = "Convert F3D to BSDF"
bl_options = {"REGISTER", "UNDO", "PRESET"}
icon = "MATERIAL"

converter_type: EnumProperty(items=converter_enum)

def execute_operator(self, context: Context):
if self.converter_type == "Object":
for obj in context.selected_objects:
obj_to_f3d(obj)
elif self.converter_type == "Scene":
for obj in context.scene.objects:
obj_to_f3d(obj)
self.report({"INFO"}, "Done.")


class F3D_ConvertBSDFToF3D(OperatorBase):
bl_idname = "scene.bsdf_convert_to_f3d"
bl_label = "Convert BSDF to F3D"
bl_options = {"REGISTER", "UNDO", "PRESET"}
icon = "NODE_MATERIAL"

converter_type: EnumProperty(items=converter_enum)

def execute_operator(self, context: Context):
if self.converter_type == "Object":
for obj in context.selected_objects:
obj_to_bsdf(obj)
elif self.converter_type == "Scene":
for obj in context.scene.objects:
obj_to_bsdf(obj)
self.report({"INFO"}, "Done.")


classes = (F3D_ConvertF3DToBSDF, F3D_ConvertBSDFToF3D)

Expand Down
31 changes: 31 additions & 0 deletions fast64_internal/f3d/bsdf_converter/properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from bpy.utils import register_class, unregister_class
from bpy.types import PropertyGroup, UILayout
from bpy.props import EnumProperty

from ...utility import prop_split, multilineLabel


class F3D_BSDFConverterProperties(PropertyGroup):
"""
Properties in scene.fast64.f3d.bsdf_converter
"""

converter_type: EnumProperty(items=[("Object", "Selected Objects", "Object"), ("Scene", "Scene", "Scene")])

def draw_props(self, layout: UILayout):
col = layout.column()
prop_split(col, self, "converter_type", "Converter Type")



classes = (F3D_BSDFConverterProperties,)


def bsdf_converter_props_register():
for cls in classes:
register_class(cls)


def bsdf_converter_props_unregister():
for cls in reversed(classes):
unregister_class(cls)
3 changes: 2 additions & 1 deletion fast64_internal/f3d/bsdf_converter/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from .operators import F3D_ConvertF3DToBSDF, F3D_ConvertBSDFToF3D


def bsdf_converter_panel_draw(layout: UILayout, _context: Context):
def bsdf_converter_panel_draw(layout: UILayout, context: Context):
col = layout.column()
context.scene.fast64.f3d.bsdf_converter.draw_props(col)
F3D_ConvertF3DToBSDF.draw_props(col)
F3D_ConvertBSDFToF3D.draw_props(col)

0 comments on commit bcbcf09

Please sign in to comment.