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

[SM64] Combined Export Panel & Behavior Script Exporting #284

Merged
merged 30 commits into from
Jul 28, 2024

Conversation

jesusyoshi54
Copy link
Collaborator

This PR aims to streamline exporting for SM64 all into one panel. This PR is made for C exclusively, and binary features should remain unchanged.

image

  • Move Level, Geo, and Collision exporting all into the same panel
  • Share properties for all types of exporting so that exports are more streamlined
  • Exports of collision, geo layout objects and armatures all from a single button
  • Exports of graphics data automatically write level script loads in the correct respective script.c file
  • Exports of graphics data will also create a model ID define in model_ids.h
  • Exports can have a separate defined collision and graphics object, or export from the shared selected object
  • Support for exporting multiple objects at once. All exported objects will export using the name of the blend object
  • Fixed level scripts erasing data from other scripts linked inside the existing previous level script

Along with all of the above improvements to exporting. I have also added in behavior script exporting.
Behavior scripts will be exported using the same properties as above, and they also have the option to inherit the following properties from the exported object:

  • collision name
  • model ID

Behavior scripts come with several preset behaviors and support adding, deleting and editing args of all the existing original sm64 behavior script cmds.

Copy link
Collaborator

@Lilaa3 Lilaa3 left a comment

Choose a reason for hiding this comment

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

Export level SHOULD NOT be in the same panel as combined object exports, especially if the name of the panel is "SM64 Combined Object Exporter", the positioning of the level prop and the fact that this will cause confusion while exporting for both actor exports and level exports.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Jan 9, 2024

I'm unsure if I like stuff like "Export behavior" and "Export collision" to be on by default
Let's say someone is just trying to do a mario export, they maybe watch a tutorial from 1 year ago for 2 minutes and then download fast64 and open up the mario blend and then oops! Behavior must have more than 0 commands?? What does that mean??? And oh no here comes 10 people asking about the same thing on discord!
You will have people exporting collision when they don´t want to on accident too. And this will happen even if you are exporting an armature. People with older files (and even with new files) will have to pay attention and turn off these toggles, it's pretty inconvenient. Just let the users toggle it themselves.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Jan 9, 2024

All behavior scripts should start with a BEGIN command, maybe don´t make the user add those manually and just add an enum for the object list? Also maybe adding a warning for when the behavior script doesn´t contain an END_LOOP, BREAK, DEACTIVATE, GOTO or RETURN could be a neat addition (only a warning because the user could have their own custom command which exits out of the behavior script). And if you are willing to step into feature creep territory, having toggles for common vanilla object flags would be very convenient. I don´t know what else could be done to help the user not mess up the behaviors.
Adding error checks for empty arguments could be another good addition but to be fair the user will just get a compilation error if they mess up their arguments so it is not really necessary

Comment on lines 2079 to 2081
prop_split(col, self, "collision_object", "Collision Obj")
if self.export_gfx and not self.export_all_selected:
prop_split(col, self, "graphics_object", "Geo Layout Obj")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to abbreviate these?
Also fast64 uses "Geolayout" instead of "Geo Layout" everywhere else

insert_line = 0
alt_insert_line = 0
match_line = 0
for j, line in enumerate(file_lines):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any reason you use j over i for loops? Typically you use j for a second index and i for the first index

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

habits from electrical studies no real reason


def export_group_script_load(self, script_path, props):
if not script_path.exists():
PluginError(f"could not find {script_path.stem}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of your plugin errors start with lower case, but some of yours and all others in fast64 use normal casing.

return {"CANCELLED"}

props.context_obj = None
# you've done it!~
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this comment necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No

Copy link
Collaborator

Choose a reason for hiding this comment

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

true

Comment on lines 1798 to 1801
if props.export_all_selected:
return
else:
raise Exception(e)
Copy link
Collaborator

@Lilaa3 Lilaa3 Jan 9, 2024

Choose a reason for hiding this comment

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

Why not just do if not props.export_all_selected:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unresolving this, but also I personally do this in these kinds of exceptions as much as possible, in here it may seem less useful but having a full traceback is usually good, pylint warns for it

Suggested change
if props.export_all_selected:
return
else:
raise Exception(e)
except Exception as exc:
# pass on multiple export, throw on singular
if not props.export_all_selected:
raise Exception(exc) from exc

fast64_internal/sm64/sm64_level_writer.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_constants.py Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_collision.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_constants.py Outdated Show resolved Hide resolved
fast64_internal/sm64/__init__.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_geolayout_writer.py Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_level_writer.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_level_writer.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_level_writer.py Outdated Show resolved Hide resolved
@jesusyoshi54
Copy link
Collaborator Author

The latest commit should address all the review concerns and also added extra control over object naming.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented May 12, 2024

The big issue with this is hackersm64, what are your plans to address enum model ids and level scripts being included in the actors folder (was reverted for the time being but is still planned afaik, fazana said grep could be an easy solution for this one)

@jesusyoshi54
Copy link
Collaborator Author

I have no plans to address a change not yet implemented in a specific repo. All features of this panel can be enabled/disabled independently, if a specific repo does not work with a feature, they can turn it off.
If you turn off the Export Script Loads feature, there will be no model ID or level script export, and only the geo.inc.c and collision.inc.c files will be exported, as would be done with the current existing panel.

If there is support for specific repos and versions of repos I may address this but I don't believe I have any measure currently to handle this.

fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/__init__.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_geolayout_writer.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_level_writer.py Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
@Lilaa3
Copy link
Collaborator

Lilaa3 commented May 31, 2024

bump #284

A lot of your plugin errors start with lower case, but some of yours and all others in fast64 use normal casing.

Copy link
Contributor

@Reonu Reonu left a comment

Choose a reason for hiding this comment

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

You forgot to add common1 to groups_obj_export.

Also, the Custom option doesn't actually work. It ignores that you type in, and tries to export to a group called Custom instead.

fast64_internal/sm64/sm64_constants.py Show resolved Hide resolved
Copy link
Contributor

@Reonu Reonu left a comment

Choose a reason for hiding this comment

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

I've been using this PR extensively and everything seems to work well!

Copy link
Collaborator

@Lilaa3 Lilaa3 left a comment

Choose a reason for hiding this comment

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

Went over all the code again, aside from updating to main these are the last things (I'm sorry for dragging this out but I swear I don´t think I missed anything this time, I re-read all the changes and see no issues and I tested all types of exports one more time, so after this I will accept and any leftover issues will be on me lol)

fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_objects.py Outdated Show resolved Hide resolved
fast64_internal/sm64/__init__.py Outdated Show resolved Hide resolved
fast64_internal/sm64/sm64_collision.py Outdated Show resolved Hide resolved
fast64_internal/sm64/settings/properties.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Lilaa3 Lilaa3 left a comment

Choose a reason for hiding this comment

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

Small quick thing, see if you agree (everything else works)

fast64_internal/sm64/settings/properties.py Outdated Show resolved Hide resolved
fast64_internal/sm64/settings/properties.py Outdated Show resolved Hide resolved
@Lilaa3
Copy link
Collaborator

Lilaa3 commented Jul 26, 2024

@Reonu im gonna merge in like 2 days max, if you wanna test anymore do it soon please

@Reonu
Copy link
Contributor

Reonu commented Jul 26, 2024

Since my last comment I've tested exporting behaviors and collision, it all worked fine. My only complaint is that the behavior scripts exported by fast64 are indented differently than the vanilla scripts (no extra indentation after BEGIN_LOOP)

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Jul 26, 2024

I don´t see an issue with that honestly, fast64 doesn´t always stick to what vanilla does for identation

@gheskett
Copy link

It matters more for behavior script exports than geos because people actually still have good reasons to interface with the behavior script file directly. Geos are exported to their own files and are less necessary to adhere to matching formatting.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Jul 26, 2024

@jesusyoshi54 do you wanna address this before merging?

@jesusyoshi54
Copy link
Collaborator Author

image
It is done

Copy link
Contributor

@Reonu Reonu left a comment

Choose a reason for hiding this comment

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

based!

Copy link
Collaborator

@Lilaa3 Lilaa3 left a comment

Choose a reason for hiding this comment

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

tested and it works even with broken behaviors (multiple end loops for example)

@jesusyoshi54 jesusyoshi54 merged commit 3bef410 into Fast-64:main Jul 28, 2024
1 check passed
@jesusyoshi54 jesusyoshi54 deleted the combined_object_export branch July 28, 2024 23:40
@Reonu
Copy link
Contributor

Reonu commented Jul 30, 2024

I was about to tell you to merge this and then I realized it was already merged

Then I was going to tell you to fix wiseguy decals but then I realized you already did

Thank you lila

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.

5 participants