Skip to content

Adding :ui argument to hide #114

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

Open
aetiusluna opened this issue Apr 24, 2025 · 15 comments
Open

Adding :ui argument to hide #114

aetiusluna opened this issue Apr 24, 2025 · 15 comments

Comments

@aetiusluna
Copy link

I'm doing some stuff where I need to render UI to a texture, which breaks hide on panels since it wants to look for the panel in the ui of the current scene. Is there any reason not to do something like this: master...aetiusluna:trial:master

@Shinmera
Copy link
Member

If you use the ui-pass, it's always rendered to a texture already as part of the pass.

@Shinmera
Copy link
Member

Or in other words: rendering to a texture is orthogonal to the object being registered with the scene. You could also still register the UI with scene without entering it fully. So this seems like an unnecessary change.

As for why not let hide take keys, it seems a bit like a hack, doesn't it? I'm not sure when you'd ever really want to pass arguments otherwise.

@Shinmera
Copy link
Member

If you could describe in a bit more detail what you're trying to do I could figure out how to properly accommodate what you want.

@aetiusluna
Copy link
Author

I'm making a card game and I want to use Alloy to lay out the cards - essentially make a texture for each card, put that on a quad, and have the UI render to it. Occasionally the cards need to change, so I need to update the UI. The way I was trying to do this was by having a panel for each card that the UI goes on, removing that panel and adding a new one. Are panels just the wrong way to go about this?

@Shinmera
Copy link
Member

Panels encompass "layers" of UI. So the entire HUD would be a panel, the pause menu would be a panel, etc.

For the cards you'd probably not want to use Alloy at all, but rather a standard game entity, that way you can apply shaders and all the usual fun stuff. Simply combining textured-entity vertex-entity and transformed-entity should suffice. The vertex array you can create via a mesh asset that builds the mesh from make-rectangle-mesh that has the desired proportions.

@Shinmera
Copy link
Member

There is also the option to "bridge" back into Trial via a custom Alloy component that then renders via Trial's usual mechanisms, but I'm not yet sure why you want to use Alloy for the cards?

@aetiusluna
Copy link
Author

The cards can't have a static texture because I sometimes need to update text and icons on them dynamically in ways I can't necessarily predict in advance. So for example you could have a card in your hand that says "deal 5 damage" and another card that says "your cards deal double damage this turn," then I'd want to update the first card to show how much damage it's actually going to do (probably in green to indicate it's buffed, not the base damage). Alloy seemed like the obvious way to do stuff like this while having the text realign itself to still look good when the numbers get huge.

@Shinmera
Copy link
Member

I see, yes, if you need to do dynamic text drawing then Alloy is currently the only option.

I'm still not convinced you need to render to a texture, though. I'd probably try to represent the card as an Alloy layout-element and define necessary shapes to represent the card background and needed info. Then just... create the element and place it where you like.

You could then use a fixed-layout to leave positioning and sizing of cards entirely up to you so you can nicely animate them and implement dragging logic and so on.

@aetiusluna
Copy link
Author

Well, I'd like to have the cards exist in 3d space for effects reasons, like if I need to animate flipping a card over, or if there's a particle effect that I want to go in front of the card. I guess for the latter I could use a blend pass but it would still be cool if I could rotate the cards.

@Shinmera
Copy link
Member

Hmmm. Alloy does have a transforms system similar to Trial, but its transform matrix is restricted to 3x3 rather than 4x4, so it can't do 3D transformations of elements. I still think that rendering to a texture is far too restrictive and ultimately the wrong approach for this, but I don't have a good solution handy right now either I'm afraid.

@Shinmera
Copy link
Member

I'll work on a revision of Alloy that allows true 3D transforms, but it'll be a bit before that's ready.

@aetiusluna
Copy link
Author

The other common approach I've seen to do this kind of thing is to use a text mesh system, so the text is a translucent quad / bunch of quads hovering slightly over the main card mesh. This works but it means you can't use a bunch of the layout stuff that a proper UI system would allow, and it can sometimes look kind of janky when the card is rotated. I thought about doing something like that but it didn't seem worth implementing given the engine not having built-in support for it (unless I completely missed it in the code/docs).

@Shinmera
Copy link
Member

Alloy already works this way, and I see no point in adding a separate text system to Trial, given how insanely complicated text is.

@aetiusluna
Copy link
Author

Yeah, I brought it up on the off chance I had missed something that would have made it easy to do, but if there isn't it's probably not worth implementing.

@Shinmera
Copy link
Member

Trial does have the debug-text natively, but that's restricted to a particular pixel font and monospace layouting.

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

No branches or pull requests

2 participants