Skip to content

Commit

Permalink
feat: split applicable util ops into dedicated scene and export menus
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Sep 12, 2022
1 parent ecd49d9 commit 6422a49
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 8 deletions.
4 changes: 4 additions & 0 deletions interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from . import utils_menu
from . import fast_menu
from . import boolean_menu
from . import export_menu
from . import scene_menu
from . import bevel_menu
from . import simplify_menu
from . import extrude_menu
Expand All @@ -43,6 +45,8 @@
utils_menu,
fast_menu,
boolean_menu,
export_menu,
scene_menu,
bevel_menu,
simplify_menu,
extrude_menu,
Expand Down
42 changes: 42 additions & 0 deletions interface/export_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ███╗ ██╗██████╗
# ████╗ ██║██╔══██╗
# ██╔██╗ ██║██║ ██║
# ██║╚██╗██║██║ ██║
# ██║ ╚████║██████╔╝
# ╚═╝ ╚═══╝╚═════╝
#
# “Commons Clause” License Condition v1.0
#
# See LICENSE for license details. If you did not receive a copy of the license,
# it may be obtained at https://github.com/hugemenace/nd/blob/main/LICENSE.
#
# Software: ND Blender Addon
# License: MIT
# Licensor: T.S. & I.J. (HugeMenace)
#
# ---
# Contributors: Tristo (HM)
# ---

import bpy
from . import ops
from . common import render_ops


class ND_MT_export_menu(bpy.types.Menu):
bl_label = "Export"
bl_idname = "ND_MT_export_menu"


def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
render_ops(ops.export_ops, layout, new_row=False, use_separator=True)


def register():
bpy.utils.register_class(ND_MT_export_menu)


def unregister():
bpy.utils.unregister_class(ND_MT_export_menu)
2 changes: 2 additions & 0 deletions interface/main_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def draw(self, context):
layout.menu("ND_MT_replicate_menu", icon='MOD_ARRAY')
layout.menu("ND_MT_deform_menu", icon='MOD_SIMPLEDEFORM')
layout.menu("ND_MT_simplify_menu", icon='MOD_REMESH')
layout.menu("ND_MT_scene_menu", icon='SCENE_DATA')
layout.menu("ND_MT_export_menu", icon='OUTLINER_COLLECTION')
layout.separator()
layout.menu("ND_MT_utils_menu", text="Utils", icon='PLUGIN')
layout.menu("ND_MT_viewport_menu", text="Viewport", icon='RESTRICT_VIEW_OFF')
Expand Down
8 changes: 7 additions & 1 deletion interface/main_ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
("Replicate", ops.replicate_ops, "replicate", [("nd.array_cubed", None), ("nd.circular_array", None), ("nd.mirror", None)]),
("Deform", ops.deform_ops, "deform", [("nd.lattice", None), ("nd.simple_deform", None)]),
("Simplify", ops.simplify_ops, "simplify", [("nd.decimate", None), ("nd.weld", None)]),
("Utils", ops.util_ops, "utils", [("nd.snap_align", None), ("nd.clean_utils", None), ("nd.flare", None)]),
("Scene", ops.scene_ops, "scene", [("nd.flare", None)]),
("Export", ops.export_ops, "export", [("nd.set_lod_suffix", "LOW"), ("nd.set_lod_suffix", "HIGH"), ("nd.triangulate", None)]),
("Utils", ops.util_ops, "utils", [("nd.set_origin", None), ("nd.snap_align", None)]),
("Viewport", ops.viewport_ops, "viewport", [("nd.toggle_wireframes", None), ("nd.toggle_utils_collection", None), ("nd.toggle_clear_view", None)]),
]

Expand All @@ -63,6 +65,8 @@ class MainUIPanelProps(bpy.types.PropertyGroup):
replicate: BoolProperty(default=False)
deform: BoolProperty(default=False)
simplify: BoolProperty(default=False)
scene: BoolProperty(default=False)
export: BoolProperty(default=False)
utils: BoolProperty(default=False)
viewport: BoolProperty(default=False)

Expand All @@ -88,6 +92,8 @@ def execute(self, context):
props.replicate = toggle
props.deform = toggle
props.simplify = toggle
props.scene = toggle
props.export = toggle
props.utils = toggle
props.viewport = toggle

Expand Down
21 changes: 14 additions & 7 deletions interface/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,30 @@
("nd.weld", 'AUTOMERGE_ON', None, None, False),
]

util_ops = [
export_ops = [
("nd.name_sync", 'FILE_REFRESH', None, None, False),
("nd.set_lod_suffix", 'ALIASED', "Low LOD", 'LOW', False),
("nd.set_lod_suffix", 'ANTIALIASED', "High LOD", 'HIGH', False),
None, # Separator
("nd.set_origin", 'TRANSFORM_ORIGINS', None, None, False),
("nd.snap_align", 'SNAP_ON', None, None, False),
None, # Separator
("nd.smooth", 'MOD_SMOOTH', None, None, False),
("nd.seams", 'UV_DATA', None, None, False),
("nd.triangulate", 'MOD_TRIANGULATE', None, None, False),
None, # Separator
("nd.apply_modifiers", 'ORPHAN_DATA', None, None, False),
("nd.clean_utils", 'MOD_FLUIDSIM', None, None, False),
None, # Separator
("nd.clean_utils", 'MOD_FLUIDSIM', None, None, False),
]

scene_ops = [
("nd.flare", 'LIGHT_AREA', "Flare (Lighting)", None, False),
]

util_ops = [
("nd.set_origin", 'TRANSFORM_ORIGINS', None, None, False),
("nd.snap_align", 'SNAP_ON', None, None, False),
None, # Separator
("nd.smooth", 'MOD_SMOOTH', None, None, False),
]

viewport_ops = [
("nd.toggle_wireframes", 'MOD_WIREFRAME', None, None, False),
("nd.toggle_face_orientation", "ORIENTATION_NORMAL", None, None, False),
Expand All @@ -109,7 +116,7 @@

def build_icon_lookup_table():
icon_lookup = {}
for op in standalone_ops + sketch_ops + boolean_ops + bevel_ops + extrusion_ops + replicate_ops + deform_ops + simplify_ops + util_ops + viewport_ops:
for op in standalone_ops + sketch_ops + boolean_ops + bevel_ops + extrusion_ops + replicate_ops + deform_ops + simplify_ops + scene_ops + export_ops + util_ops + viewport_ops:
if op is None:
continue

Expand Down
42 changes: 42 additions & 0 deletions interface/scene_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ███╗ ██╗██████╗
# ████╗ ██║██╔══██╗
# ██╔██╗ ██║██║ ██║
# ██║╚██╗██║██║ ██║
# ██║ ╚████║██████╔╝
# ╚═╝ ╚═══╝╚═════╝
#
# “Commons Clause” License Condition v1.0
#
# See LICENSE for license details. If you did not receive a copy of the license,
# it may be obtained at https://github.com/hugemenace/nd/blob/main/LICENSE.
#
# Software: ND Blender Addon
# License: MIT
# Licensor: T.S. & I.J. (HugeMenace)
#
# ---
# Contributors: Tristo (HM)
# ---

import bpy
from . import ops
from . common import render_ops


class ND_MT_scene_menu(bpy.types.Menu):
bl_label = "Scene"
bl_idname = "ND_MT_scene_menu"


def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_DEFAULT'
render_ops(ops.scene_ops, layout, new_row=False, use_separator=True)


def register():
bpy.utils.register_class(ND_MT_scene_menu)


def unregister():
bpy.utils.unregister_class(ND_MT_scene_menu)

0 comments on commit 6422a49

Please sign in to comment.