Skip to content

Commit

Permalink
fix: fix no predictions logic in the fast menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 25, 2022
1 parent dedcba6 commit 1819997
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions interface/fast_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

keys = []
icons = build_icon_lookup_table()

SECTION_COUNT = 1
NO_SECTION_COUNT = 0

class ND_MT_fast_menu(bpy.types.Menu):
bl_label = "ND v%s — Fast (Predict)" % ('.'.join([str(v) for v in bl_info['version']]))
Expand All @@ -38,19 +39,19 @@ class ND_MT_fast_menu(bpy.types.Menu):
def draw(self, context):
objs = context.selected_objects

if len(objs) == 0:
return self.draw_no_object_predictions(context)

if len(objs) == 1:
return self.draw_single_object_predictions(context)
total_sections = 0

if len(objs) == 2:
return self.draw_two_object_predictions(context)

if len(objs) > 2:
return self.draw_many_object_predictions(context)

return self.draw_no_predictions(context)
if len(objs) == 0:
total_sections += self.draw_no_object_predictions(context)
elif len(objs) == 1:
total_sections += self.draw_single_object_predictions(context)
elif len(objs) == 2:
total_sections += self.draw_two_object_predictions(context)
elif len(objs) > 2:
total_sections += self.draw_many_object_predictions(context)

if total_sections == 0:
return self.draw_no_predictions(context)


def draw_no_predictions(self, context):
Expand Down Expand Up @@ -93,7 +94,7 @@ def draw_two_object_predictions(self, context):
layout.operator("nd.hydrate", icon=icons['nd.hydrate'])
layout.operator("nd.swap_solver", text="Swap Solver (Booleans)", icon=icons['nd.swap_solver'])

return
return SECTION_COUNT

layout.operator("nd.bool_vanilla", text="Difference", icon=icons['nd.bool_vanilla+DIFFERENCE']).mode = 'DIFFERENCE'
layout.operator("nd.bool_vanilla", text="Union", icon=icons['nd.bool_vanilla+UNION']).mode = 'UNION'
Expand All @@ -105,6 +106,8 @@ def draw_two_object_predictions(self, context):
layout.operator("nd.circular_array", icon=icons['nd.circular_array'])
layout.operator("nd.snap_align", icon=icons['nd.snap_align'])

return SECTION_COUNT


def draw_single_object_predictions(self, context):
layout = self.layout
Expand Down Expand Up @@ -139,10 +142,10 @@ def draw_single_object_predictions(self, context):
self.draw_make_edge_face_ops(context)
made_prediction = True

if not made_prediction:
self.draw_no_predictions(context)

return
if made_prediction:
return SECTION_COUNT
return NO_SECTION_COUNT

if context.mode == 'OBJECT':
depsgraph = context.evaluated_depsgraph_get()
Expand Down Expand Up @@ -211,22 +214,22 @@ def draw_single_object_predictions(self, context):
layout.operator("nd.hydrate", icon=icons['nd.hydrate'])
layout.operator("nd.swap_solver", text="Swap Solver (Booleans)", icon=icons['nd.swap_solver'])

return
return SECTION_COUNT

if was_profile_extrude or self.sketch:
layout.operator("nd.solidify", icon=icons['nd.solidify']) if not has_mod_solidify else None
layout.separator()
layout.operator("nd.mirror", icon=icons['nd.mirror'])
layout.operator("nd.screw", icon=icons['nd.screw']) if not has_mod_screw else None

return
return SECTION_COUNT

if self.profile:
layout.operator("nd.profile_extrude", icon=icons['nd.profile_extrude']) if not has_mod_profile_extrude else None
layout.operator("nd.screw", icon=icons['nd.screw']) if not has_mod_screw else None
layout.operator("nd.mirror", icon=icons['nd.mirror'])

return
return SECTION_COUNT

if self.has_faces:
layout.separator()
Expand All @@ -241,8 +244,11 @@ def draw_single_object_predictions(self, context):
layout.operator("nd.geo_lift", icon=icons['nd.geo_lift'])
layout.operator("nd.view_align", icon=icons['nd.view_align'])

return
return SECTION_COUNT

return NO_SECTION_COUNT

return NO_SECTION_COUNT

def draw_many_object_predictions(self, context):
layout = self.layout
Expand All @@ -253,7 +259,7 @@ def draw_many_object_predictions(self, context):
layout.operator("nd.hydrate", icon=icons['nd.hydrate'])
layout.operator("nd.swap_solver", text="Swap Solver (Booleans)", icon=icons['nd.swap_solver'])

return
return SECTION_COUNT

layout.operator("nd.mirror", icon=icons['nd.mirror'])
layout.operator("nd.triangulate", icon=icons['nd.triangulate'])
Expand All @@ -262,6 +268,8 @@ def draw_many_object_predictions(self, context):
layout.operator("nd.set_lod_suffix", text="Low LOD", icon=icons['nd.set_lod_suffix+LOW']).mode = 'LOW'
layout.operator("nd.set_lod_suffix", text="High LOD", icon=icons['nd.set_lod_suffix+HIGH']).mode = 'HIGH'

return SECTION_COUNT


def register():
bpy.utils.register_class(ND_MT_fast_menu)
Expand Down

0 comments on commit 1819997

Please sign in to comment.