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

Enable Python access to plLayer and ImageLibMod textures. #1360

Merged
merged 21 commits into from
Nov 11, 2024

Conversation

Deledrius
Copy link
Member

@Deledrius Deledrius commented Mar 11, 2023

In order to facilitate the expansion of existing Ages as well as adding new Fan Ages, this PR provides a way to modify textures dynamically through Python scripts. It is especially ideal for otherwise-identical meshes whose appearance can be easily changed with only a texture swap. Book covers and Linking Panels are the primary intended targets.

Planned uses:

  • Random selection of backdrop images on the StartUp menu screen, showcasing Ages from interesting perspectives.
  • Adding new books to the Nexus with minimal modifications. Currently, to add a new Age to the Nexus, an entire new copy of the book mesh and animations is required, with extensive and error-prone wiring and material duplication. This PR allows the entire book machine jumble to be simplified into a single book and an ImageLibMod containing the linking panels which can then be assigned based on the current selection.
  • Adding new books to Relto with minimal modifications. The Relto Bookshelf's selection of books is currently hard coded, making it difficult to add, remove, or change books. This PR would allow dummy books to be skinned with different covers depending on dynamic conditions (player-vault-based data, for instance).
  • Adding new books to Chiso with minimal modifications. Chiso Preniv's many books could likewise be more easily assigned and updated with only a minor script update and a new image added to an ImageLibMod, simplifying new-Age-related updates.

This PR:

  • Adds Python access to plLayer textures.
  • Adds Python access to ImageLibMods through their plSceneObject.
  • Adds a new ptAttrib for assigning plLayers in PlasmaMax PFMs.
  • Provides a small demonstration function added to the StartUp Age to show the simplicity of using the new features. (Draft only, not intended for merge outside of Gehn).

Questions for reviewers:

  • Is this the best way to accomplish these goals? Is this safe?
  • Is this sufficiently complete? More access to the plLayer is possible, though more would not necessarily be useful.

@Deledrius Deledrius added Client Enhancement Non-critical feature addition labels Mar 11, 2023
@Deledrius Deledrius requested review from dpogue, zrax and Hoikas March 11, 2023 11:25
Copy link
Member

@Hoikas Hoikas left a comment

Choose a reason for hiding this comment

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

I think we should probably toss the whole BUILDING_PYPLASMA thing from the new code. It makes things hard to follow.

Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibModGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pySceneObject.cpp Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plModifier/plImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plModifier/plImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plModifier/plImageLibMod.h Outdated Show resolved Hide resolved
Sources/Tools/MaxComponent/plAutoUIBase.cpp Outdated Show resolved Hide resolved
@Deledrius
Copy link
Member Author

I think we should probably toss the whole BUILDING_PYPLASMA thing from the new code. It makes things hard to follow.

I agree, and was thinking the same thing (which is why I asked about it in the chat last week). It's useless to us, unfortunately, and just makes everything harder to read. I'll remove it from this one.

Doing all of pfPython was going to affect a lot of files though, so I haven't done it yet. Will probably open a separate PR for that.

@Deledrius Deledrius force-pushed the pyLayer branch 3 times, most recently from 83844be to 9dfe1fd Compare March 12, 2023 07:00
@Deledrius Deledrius marked this pull request as ready for review April 9, 2023 23:25
Scripts/Python/stupStartUp.py Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayerGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp Outdated Show resolved Hide resolved
@Deledrius Deledrius force-pushed the pyLayer branch 3 times, most recently from b6477bd to 5c46d85 Compare June 28, 2023 21:16
Hoikas
Hoikas previously requested changes Jul 17, 2023
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibModGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pySceneObjectGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayerGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plModifier/plImageLibMod.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibModGlue.cpp Outdated Show resolved Hide resolved
Scripts/Python/stupStartUp.py Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayer.h Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayerGlue.cpp Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyLayerGlue.cpp Outdated Show resolved Hide resolved
Scripts/Python/stupStartUp.py Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/pyImageLibMod.cpp Outdated Show resolved Hide resolved
@Hoikas
Copy link
Member

Hoikas commented Oct 15, 2023

What is the status here?

@Deledrius
Copy link
Member Author

What is the status here?

Working on a few things to get it finished up, but my time has been limited. I hope we can finish this one soon. :)

This isn't needed because the layer will do it once the new reference is
delivered by the resmgr.
Maybe the previous code worked, but it wasn't the correct way to handle
old style function call argument parsing.
Yas, another helper.
@Hoikas
Copy link
Member

Hoikas commented Nov 11, 2024

@Deledrius I've done a pass on everything to fix a few nits. I also added two new helpers: PtFindImage and PtFindLayer to help in the case of layer attributes not being present. I was able to successfully test the branch by adding this to the startup python file:

            layer = PtFindLayer("Map #38", age="GUI", page="GUIDialog04a")
            tex = PtFindImage("xavatarcustom")
            PtDebugPrint(f"hello {layer=}, {tex=}")
            layer.setTexture(next(iter(tex)))

Let me know if you have any concerns. I'm OK with merging the start up changes as-is without a corresponding assets PR.

@Hoikas Hoikas merged commit 06e46e4 into H-uru:master Nov 11, 2024
18 checks passed
@Deledrius Deledrius deleted the pyLayer branch November 12, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Enhancement Non-critical feature addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants