Page 1 of 1

[Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Wed Jan 13, 2021 1:54 am
by digiwombat
Hey again.

Simple one this time!

Currently the inline markup tag for changing portraits [pic=<index>] uses its own logic that requires the use of the portrait indexes (unless I missed a function call somewhere). It would be mighty fine if the [pic] markup tag used the SetPortrait logic so that we could use portraits from the resources folder or by name.

Re: [Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Wed Jan 13, 2021 8:35 am
by Tony Li
Thanks for the suggestion! To maintain compatibility with Chat Mapper, [pic=#] will remain unchanged. Can you get by with SetPortrait()?

Re: [Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Thu Jan 14, 2021 12:12 pm
by digiwombat
SetPortrait() should actually be enough. I think I made an assumption about the inline command that wasn't true. I was imagining something that would allow mid-dialogue shifting like so:
Bob: [pic=Happy]Hey, I didn't think you'd-- [pic=Concerned]Oh... it's you.
But thinking about the code I was looking at, it just sets things during the text formatting phase and only uses that.

In which case, I'd like to amend my request slightly to be the ability to include a tag or have a bool to set a node to "Append to Previous" which would allow for things like that unless there is currently a way to achieve that that I don't know about.

Re: [Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Thu Jan 14, 2021 1:57 pm
by Tony Li
There are currently two ways you can do it:

1. Use RPGMaker codes:
  • Dialogue Text 1: "[pic=Happy]Hey, I didn't think you'd --"
  • Dialogue Text 2: "[pic=Concerned]\>Hey, I didn't think you'd --\< Oh... it's you."
2. Or use SetPortrait() in the Sequence field:
  • DialogueText: "Hey, I didn't think you'd -- Oh... it's you."
  • Sequence: {{default}}; SetPortrait(Happy); SetPortrait(Concerned)@0.6

Re: [Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Thu Jan 14, 2021 9:09 pm
by digiwombat
The first option would work okay except I'm using SuperTextMesh and it uses its own reader code. As such, I've got a request in for a solution for that with Kai.

Though STM does allow inline event firing so I can actually just run an event to handle it I think via <e=String>. So STM might actually have a solution for this particular issue for me.

Re: [Feature Request] Change [pic=] markup to use SetPortrait logic

Posted: Fri Jan 15, 2021 8:25 am
by Tony Li
Since you're using STM, inline event firing is a good way to go. You can configure the event to call:

DialogueManager.instance.SetActorPortraitSprite(actorName, sprite);

A simple example if your portraits are in a Resources folder:

Code: Select all

var sprite = Resources.Load<Sprite>("Happy");
DialogueManager.instance.SetActorPortraitSprite("Player, sprite);
If you're using addressables, they load asynchronously, so it's a little more complicated. Example:

Code: Select all

DialogueManager.LoadAsset("Happy", typeof(Sprite),
    (asset) =>
    {
        var sprite = asset as Sprite;
        DialogueManager.instance.SetActorPortraitSprite("Player", sprite);
    }