Page 5 of 14

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 3:42 am
by CHOPJZL
Seems conversation actor is not always the right answer, either. At last I followed the way of StandardUIResponseMenuControls did.

Code: Select all

var menuActor = GetActorTransformFromID(responses[0].destinationEntry.ActorID);

private Transform GetActorTransformFromID(int actorID)
    {
        var actor = DialogueManager.masterDatabase.GetActor(actorID);
        if (actor != null)
        {
            var actorTransform = PixelCrushers.DialogueSystem.CharacterInfo.GetRegisteredActorTransform(actor.Name);
            if (actorTransform == null)
            {
                var actorGO = GameObject.Find(actor.Name);
                if (actorGO != null) actorTransform = actorGO.transform;
            }
            if (actorTransform != null) return actorTransform;
        }
        return DialogueManager.currentActor;
    }
I still don't understand why it is opposite between SubtitleControls and ResponseMenuControls on GetPanel() method. In SubtitleControls it first check the ActorID dictionary, then the transform dictionary. While the ResponseMenuControls check "m_actorIdPanelCache" at the end. And this breaks the usage of OverrideActorMenuPanel(Actor actor, MenuPanelNumber menuPanelNumber, StandardUIMenuPanel customPanel).

May I suggest you to modify ResponseMenuControls to work like SubtitleControls? If it has to be in this way, I need some detailed example.

By the way, I saw the Close() method in StandardUIResponseMenuControls

Code: Select all

	     if (m_actorIdPanelCache.Count > 0)
            {
                var cachedPanels = new List<StandardUIMenuPanel>(m_actorIdPanelCache.Values);
                foreach (var kvp in m_actorIdPanelCache)
                {
                    var panel = kvp.Value;
                    if (panel != null && !m_builtinPanels.Contains(panel) && !cachedPanels.Contains(panel)) panel.Close();
                }
            }
Isn't it doing nothing at all?

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 8:56 am
by Tony Li
Hi,
CHOPJZL wrote: Sat Mar 13, 2021 3:42 amSeems conversation actor is not always the right answer, either.
I don't understand. That looks correct to me.
CHOPJZL wrote: Sat Mar 13, 2021 3:42 amI still don't understand why it is opposite between SubtitleControls and ResponseMenuControls on GetPanel() method.
This has to do with the way Dialogue Actor > Use Menu Panel For > Me / Response To Me works. However, since both scripts' GetPanel() methods are virtual, you can change it in your subclasses.
CHOPJZL wrote: Sat Mar 13, 2021 3:42 amBy the way, I saw the Close() method in StandardUIResponseMenuControls... Isn't it doing nothing at all?
I'll check that code for the next update. It may be handling an edge case.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 9:45 am
by CHOPJZL
I don't understand. That looks correct to me.
When the default Conversation Actor is Player and the Dialogue Actor of Player exist, If I set the Conversation Actor to other Actor such as Blue, The currentActor is Blue, but GetPanel returns Player's MenuPanel
This has to do with the way Dialogue Actor > Use Menu Panel For > Me / Response To Me works.
Could you explain more about this feature? It's better to have an example.
you can change it in your subclasses.
What worries me is that subclass these control classes will have to modify the files belongs to the DS package. Then many modifycations will be recovered when I update or open new project.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 10:02 am
by Tony Li
If you write subclasses, you shouldn't have to make any modifications to the original scripts. That's the purpose of writing a subclass. If there are any cases where you would need to modify the original script, please let me know. I'll make it so you can override it in a subclass instead.

Let's take this from the top. What are your requirements? Let's just figure out how to set it up to work the way you need.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 10:20 am
by CHOPJZL
If I want to use a subclass of StandardUIResponseMenuControls, Shouldn't I modify the Private Variables of StandardUIDialogueControls?

My requirement is that no matter what situation, I can set a custom menu panel assigned by entry's field and put it into use, so basically I will need to do this in OnConversationResponseMenu(Response[] responses), and I will manage to fetch the custom menu panel by myself.

Still I need to know more about the "Use Menu Panel For > Me / Response To Me" feature. My requirement maybe change base on this

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 10:51 am
by Tony Li
CHOPJZL wrote: Sat Mar 13, 2021 10:20 amIf I want to use a subclass of StandardUIResponseMenuControls, Shouldn't I modify the Private Variables of StandardUIDialogueControls?
That's not necessary. You only need to replace the StandardUIMenuPanel/StandardUISubtitlePanel components with your custom subclasses. To replace them in-place, change the Inspector to Debug mode. Then drag your subclass script into the component's Script field. This way you won't have to reassign the panels to the StandardDialogueUI component.
CHOPJZL wrote: Sat Mar 13, 2021 10:20 amMy requirement is that no matter what situation, I can set a custom menu panel assigned by entry's field and put it into use...
Which entry will have the field? The subtitle entry that appears before the menu?
CHOPJZL wrote: Sat Mar 13, 2021 10:20 amStill I need to know more about the "Use Menu Panel For > Me / Response To Me" feature. My requirement maybe change base on this
This may not apply. It only applies when using Dialogue Actor components. When it's set to Me and is on a player, it will only use the custom menu panel when that player is showing a menu. When it's set to Me And Responses To Me, then it can be on an NPC's Dialogue Actor. If the player is replying to that NPC, it will use the custom panel.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 11:09 am
by CHOPJZL
Which entry will have the field? The subtitle entry that appears before the menu?
No, it's the entry of the response. As I use OnConversationResponseMenu(Response[] responses), I can only get responses[0].destinationEntry
That's not necessary. You only need to replace the StandardUIMenuPanel/StandardUISubtitlePanel components with your custom subclasses.
I still don't understand, then where to set my subclass of StandardUIResponseMenuControls?

I will be here 10 hours later :D

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 8:53 pm
by Tony Li
Hi,

Don't make a subclass of StandardUIResponseMenuControls or StandardUISubtitleControls. Make subclasses of StandardDialogueUI, StandardUIMenuPanel, and/or StandardUISubtitlePanel.

I checked the edge cases and updated StandardUIResponseMenuControls. Here's an updated patch:

DS_SubtitleMenuPanelPatch_2021-03-13.unitypackage

If will check if the actor's transform has an override panel. If not, it will check if the actor (by ID) has an override panel. I tested it with this line of your test script:

Code: Select all

ui.OverrideActorMenuPanel(DialogueManager.masterDatabase.GetActor("Player"), MenuPanelNumber.Custom,theMenuPanel);
So in your OnConversationResponseMenu() method, you can use a line similar to that.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 9:37 pm
by CHOPJZL
Don't make a subclass of StandardUIResponseMenuControls or StandardUISubtitleControls.
So as I said we can't override GetPanel on our own?
I checked the edge cases and updated StandardUIResponseMenuControls. Here's an updated patch:
It's not the point but the edge case seems unchanged at all.

The OverrideActorMenuPanel is still not right, it fails when there is a Dialogue Actor component of Player exist in the scene.

Maybe I didn't make myself clear. I mean I'd like to set a custom menu panel and use it immediately. No matter which Actor has Dialogue Actor component in scene or not, no matter any Dialogue Actor component has set a custom Panel or not.

Re: About Dialogue Actor component

Posted: Sat Mar 13, 2021 9:58 pm
by Tony Li
CHOPJZL wrote: Sat Mar 13, 2021 9:37 pmSo as I said we can't override GetPanel on our own?
I'll add a way to do that if necessary.
CHOPJZL wrote: Sat Mar 13, 2021 9:37 pmThe OverrideActorMenuPanel is still not right, it fails when there is a Dialogue Actor component of Player exist in the scene.

Maybe I didn't make myself clear. I mean I'd like to set a custom menu panel and use it immediately. No matter which Actor has Dialogue Actor component in scene or not, no matter any Dialogue Actor component has set a custom Panel or not.
Dialogue Actor always takes priority. When you set the menu panel, can you set the panel by Dialogue Actor if there is one, and otherwise set the panel by actor ID?