dialog area - dynamic height

  • #1, by sebastianSaturday, 15. August 2015, 21:03 9 years ago
    Heyho,

    i have a question regarding the dialog box from the dialog area:

    how do i implement a dynamic height of the dialog box like seen in e.g. Goodbye Deponia.
    http://cl.ly/image/3i3D2W252X28/Image%202015-08-15%20at%209.02.16%20nachm..png
    http://cl.ly/image/0n1m06203f1t/Image%202015-08-15%20at%209.02.35%20nachm..png
    (sorry for the youtube player time bar above it, but i think with the screenshots it is more clear what i mean...)

    So when there are only 2 choosable options the dialog box is small and if there are more options it is big. Also everything is aligned to the bottom.
    I want to prevent scrolling via arrows.


    Any ideas how to implement these?


    kind regards
    Sebastian

    Thread Captain

    2346 Posts


  • #2, by sebastianSaturday, 15. August 2015, 22:10 9 years ago
    it has something to do with "DialogDialogParts" but i cant figure out how to count them.

    The following code counts the dialogs available for the npc, but i need the dialog parts inside a specific dialog. anyone who knows how i have to modify my script to do this?
      local dialogs = getObject("Characters[testnpc]"):getLinks(VCharacterDialogs)
      local count = 0
    
      for i = 1, #dialogs do -- iterate through the stored dialog options
        count = count+1
      end
      print(count);
    



    EDIT:
    Ok now i can grab the amount of dialog parts inside the "Start" dialog of "testnpc":
    function count_dialog_options()
      local dialog_options = getObject("Characters[testnpc].CharacterDialogs[Start]"):getLinks(VDialogDialogParts)
      local count = 0
      for i = 1, #dialog_options do -- iterate through the stored dialog options
    
           count = count+1
    
      end
      print(count);
    end
    
    

    Now i have 3 further problems:
    1: how can i make the character name dynmaically?
    2: how can i set the dialog part in which the script should look up the number of entries? For now he searches only in the root - dialog part for dialog "start".
    3: how do i count only dialog parts which are available right now ?

    any ideas?

    Thread Captain

    2346 Posts

  • #3, by sebastianSunday, 16. August 2015, 14:39 9 years ago
    ok, now i solved the issue 1 and 2 because there is an "active dialog" field which i can access: game.GameDialog

    now my function looks like this:
    function cdo() -- count dialog options 
      local dialog_options = game.GameDialog:getLinks(VDialogDialogParts)
      local count = 0
      for i = 1, #dialog_options do -- iterate through the stored dialog options
    
              count = count+1
    
      end
      print(count);
    end
    



    Now: Inside the for loop i have to create an condition which checks if the dialogpart which gets checked is (still) available and gets displayed.
    I tried a few times different solutions but i can't figure out what i really need to check.
    So a question directly to the devs:
    What do i need to check here from http://wiki.visionaire-tracker.net/wiki/Data_Structure#Dialo... for determining if the dialog part is visible for the player? (Maybe could you give some lua examples?)

    Thread Captain

    2346 Posts

  • #4, by sebastianSunday, 16. August 2015, 18:49 9 years ago
    I solved the struggle myself smile
    the entries now get counted correctly. Now i will write a function which updates the dialogbox height.
    When this is finished i will post the results grin
    .....
    EDIT:
    now everything seems to work fine. also updating the dialog area works.
    I registered a hook into the mainLoop, when the dialog starts and unregister it when it ends. The function checks the current available parts and sets a value on how much are available. Then another function gets called which updates the area coordinates via game.CurrentCharacter:setValue( VCharacterDialogArea,...).

    The only issue i have is that it doesn't update immediately but after the next shown dialog part :/ So i need a solution which a) realtime updates the box or b) checks the next available dialogparts after clicking on a dialog part and sets the correct hight only when clicking on it... Or c) i dont know :/

    Need some help here on how to get it working.





    Thread Captain

    2346 Posts

  • #5, by sebastianTuesday, 18. August 2015, 00:10 9 years ago

    Heureka


    I got it working! Just need to clean up the mess inside the lua script (tomorrow).

    The general Idea how my script works:
    1 function with 2 parameters (table id, object id) which accesses a specific dialog via these 2 parameters
    (Table: eDialogs (Id: 11) Id: 1 for example is the first saved dialog in the game. You can find out the different dialog ids by using the explorer and dump the dialog entry to the log)

    so instead of using
    getObject("Characters[mynpc].CharacterDialogs[start]"):getLinks(VDialogDialogParts)
    


    which returns all dialogparts of the "start" dialog of "mynpc"

    i use a shorter version:
    getObject("(" .. tableid .. "," .. id .. ")"):getLinks(VDialogDialogParts);
    


    to get the exact same dialog parts.
    Of course the above srcipt part uses the parameters from the function...

    using the function function csdo(table,id) (short for "count specific dialog options") i read out all dialogparts for the given dialog.
    for each dialogpart the counter goes only +1 if the dialogpart is still available and its condition is true (or if negated false).

    after this we have a number. This number is neccessary to call another function which changes the dialogarea of the currentcharacter.

    Because the changes which are made to the dialogarea only get visible after the next dialog is shown, we have to call all the csdo functions before the dialog is displayed.

    E.g. before the
    1. dialog starts count the parts from the first dialog, then start dialog.
    2. when in a subdialog and want to return to a level higher call the script for the above dialog in the executed action which runs when the selection is clicked.

    Things to condider:
    when having a subdialog with e.g. 3 dialog parts and all these get deleted after they are selected. The dialog jumps one level higher, when all 3 options are removed. Because of this we have to define a value which counts up on each of the dialog parts and when all 3 were selected run the script for the above level, else run it for the current level.







    Thread Captain

    2346 Posts

  • #6, by sebastianSunday, 22. May 2016, 20:45 8 years ago
    I scrolled a bit through the wiki and found an interesting part which may is useful for the dynamic dialog box height described above.

    My dialog box resizing works manually right now. Every time I have to run a script to check the correct dialog tree which should show up next.

    I found the following entry in the wiki which may would make it more automated, but i don't know how i can access the data:

    DialogPartReturn t_int

    Defines which dialog is shown if this dialog part is selected (and the dialog part does not have a dialog with active dialog parts below):
    '0' (eDialogReturnToSame): the same dialog will be shown again.
    '1' (eDialogReturnToUpper): the 'upper' dialog (which linked to the current dialog) will be shown.
    '2' (eDialogReturnToEnd): no dialog will be shown.


    Okay. Now these integers in this variable are defining what to do next after the actual dialog is finished.

    The problem here is that i don't know how to use them properly, because these are no links to the same/upper dialog. Only integers.
    How to i get the "dialog" which is saved behind the value 0 or 1 in DialogPartReturn, so i can count its dialog parts?

    kind regards
    Sebastian





    Thread Captain

    2346 Posts

  • #7, by afrlmeSunday, 22. May 2016, 21:44 8 years ago
    Damn, this is a thread of you just talking to yourself. Not really sure how I missed this thread, but it seems you've managed to sort out pretty much everything yourself.

    I know Daedalic tend to create custom dialog systems as I believe (like me) that they either don't like the default dialog system or find it too limiting.

    I've not read the entire thread (too much data / text for me to absorb in one go), but can you not automate it by starting the loop when you open up a dialog, set the initial dialog part value & then have it listen for changes & when the value changes call another function that adjusts the dialog background position accordingly? I do actually have the deponia ved on my hd (shh!), but I doubt they would appreciate it if I started sharing their methods & scripts, etc - actually I don't even use their stuff myself as I prefer to come up with my own solutions. For me, being able to figure something out myself is all part of the fun. wink

    Imperator

    7278 Posts

  • #8, by sebastianSunday, 22. May 2016, 21:57 8 years ago
    The problem is that i cant run the script in a loop to edit the current dialog because it doesnt get updated directly (only when dialog shows the next parts) and also doesn't know what the next shown dialog is (it only knows the current dialog or a dialog i tell them manually).

    So I have to add a an execute script in each dialog action part to check the next upcomming dialog part.

    BUT i have to edit its table id manually everytime because the script doesn't know what the next dialog part is (where from?).
    The Info i need is inside the part i described above i guess. I FEEL IT. XD

    But integers are not links to the dialog. So my question is: How does visionaire know the same dialog that will be shown when int = 0 or the 'upper' dialog (which linked to the current dialog) when int = 1.

    Thread Captain

    2346 Posts

  • #9, by sebastianSunday, 22. May 2016, 21:58 8 years ago
    Oh god my writing is horrible... The above makes hardly sense, but i hope someone is getting the right idea what i mean...

    Thread Captain

    2346 Posts

  • #10, by afrlmeSunday, 22. May 2016, 22:26 8 years ago
    haha. Nope, I've no clue. I've stayed away from the dialog system as much as possible. I will probably end up writing a custom one when it comes time to needing a dialog system. We didn't need one for the demo.

    My point about the loop was listening out for the amount of dialog choices listed & for when that value changes.

    Quick question: why do you iterate through the active dialog parts? Can you not use the # or table.maxn() to return the total index value?

    For me... (don't know if it would work without testing)
    local dlg = 0
    
    function init_dlg_loop()
     dlg = #(game.Dialog.DialogParts)
     -- code or function call that makes dialog background move
     registerEventHandler("mainLoop", "dlg_loop")
    end
    
    function dlg_loop()
     if #(game.Dialog.DialogParts) ~= dlg then
      dlg = #(game.Dialog.DialogParts)
      -- code or function call that makes dialog background move
     end
    end
    

    I have no idea how much use it is as I've not tested it, have no desire to test it & it's written off the top of my head.

    Imperator

    7278 Posts

  • #11, by sebastianSunday, 22. May 2016, 22:31 8 years ago
    I edited my post a bit to make it more clear smile

    EDIT:
    Quick question: why do you iterate through the active dialog parts? Can you not use the # or table.maxn() to return the total index value?


    i only have to count up if the dialog is still active. the table.maxn() counts every dialog part, even if its not available anymore...
    --------
    The main problem here is that the dialogbox height ajustment has to be done BEFORE the dialog is shown - so in the dialogs which are pointing to them.
    Thats because changing the dialogbox height doesnt have an effect until redrawing/loading the dialog again.
    The only chance to know the next dialog is
    a) doing it manually (script at the end of the dialog parts action part has specific attributes which point to the next dialog)

    b) getting to know what the next dialog is automatically via "DialogPartReturn" (script at the end of the dialog parts action part knows through the int where the next is)... but i cant use integers as a t_link to the dialog, right?

    Thread Captain

    2346 Posts