Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow an exporter to be opened without an object selected #620

Merged
merged 2 commits into from
Aug 18, 2024

Conversation

StandingPadAnimations
Copy link
Collaborator

This fixes an edge case where a user may want to open an exporter from MCprep without an object selected, such as in a startup file without the default cube.

Copy link
Member

@TheDuckCow TheDuckCow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base change, looks good. I realize we can still end up with mismatches since we're specifying a fallback, but we know those fallbacks aren't likely for valid MC common obj exports anyways, so seems safe to me.

I'm suggesting we go slightly further though to ensure the UI remains consistent, as indeed this UI is weird to see.

See my suggested patch, not committing to avoid messing up your git branch in case you have anything locally:

diff --git a/MCprep_addon/mcprep_ui.py b/MCprep_addon/mcprep_ui.py
index 418fe4a..651f705 100644
--- a/MCprep_addon/mcprep_ui.py
+++ b/MCprep_addon/mcprep_ui.py
@@ -788,7 +788,9 @@ class MCPREP_PT_world_imports(bpy.types.Panel):
                if context.mode == "OBJECT":
                        col.operator("mcprep.meshswap", text=env._("Mesh Swap"))
                        exporter = world_tools.get_exporter(context)
-                       if exporter is None or exporter is world_tools.WorldExporter.Unknown:
+                       if not context.object and not context.selected_objects:
+                               # Ops will return nothing selected anyways, don't show warning
+                               pass
+                       elif exporter is None or exporter is world_tools.WorldExporter.Unknown:
                                col.label(text=env._("Select exporter!"), icon='ERROR')
                if context.mode == 'EDIT_MESH':
                        col.operator("mcprep.scale_uv")

If you can add that change in, I'd be good to merge this one too.

@StandingPadAnimations StandingPadAnimations merged commit 96ac13e into dev Aug 18, 2024
1 check passed
@StandingPadAnimations StandingPadAnimations deleted the open-exporter-fix branch August 18, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants