fodev.net

FOnline Development => Questions and Answers => Topic started by: KingR on March 02, 2025, 11:49:57 PM

Title: Dialog
Post by: KingR on March 02, 2025, 11:49:57 PM
Hi everyone!

I put back the original dialog window, and it works fine.

Only, I have two things I would like to do:

- First, and this is the most important thing, I would like center the screen on the player when the dialog window is called, do you have any ideas to do that?

- And optionally,, I would like to be able to display an image in addition to the dialog window, which would depend on the npc. In fact I was thinking of putting a still image of the "talking head", while waiting to be able to put the original animations. (big work later on that). I noticed that there was an "avatar" field in dialogEditor, but it doesn't work.

Thanks for help !
Title: Re: Dialog
Post by: Trapper Luke on March 03, 2025, 10:05:09 AM
Adding avatars is possible, but doesn't work just like that. You have to go into coding, this way https://github.com/TheGreatDoc/fode/blob/master/Server/scripts/client_screen_dialog.fos
Title: Re: Dialog
Post by: KingR on March 09, 2025, 05:16:25 PM
Ok thank you very much. I will try this
Title: Re: Dialog
Post by: KingR on March 25, 2025, 03:06:08 AM
I found an alternative solution. With this:

void _DialogImage(int x, int y, int imageId, string@, array<int>@)

It gives a frozen image, but it's already very good

Thanks to all
Title: Re: Dialog
Post by: Thatgun on April 02, 2025, 12:20:12 AM
i do the same in client_io.fos
put png file in client folder

(https://postimg.cc/GTD84W6s)
(https://postimg.cc/svKHnbMr)

(https://postimg.cc/vDwPGfkD)
Title: Re: Dialog
Post by: Thatgun on April 02, 2025, 12:22:55 AM
client_io.fos -> mouse_down()
IGUIElementImageOpt@ avatar;
@avatar = GUI_AddImage(CLIENT_SCREEN_DIALOG, STR_NPC_AVATAR(dlgId)+".png", PT_ART_CRITTERS, 30, 60);

Title: Re: Dialog
Post by: Thatgun on April 02, 2025, 12:29:49 AM
some img for my post

https://postimg.cc/GTD84W6s
https://postimg.cc/svKHnbMr

https://postimg.cc/vDwPGfkD
Title: Re: Dialog
Post by: KingR on September 21, 2025, 11:01:03 AM
Thanks for the tips !

But I wanted this result:

https://image.noelshack.com/fichiers/2025/38/7/1758445204-talking-head.png
Title: Re: Dialog
Post by: KingR on January 11, 2026, 01:20:40 AM
Hi everyone! I managed to center the screen on the player when the dialog box appears:

In client_interface.fos, i added this :

void CenterPlayerOnScreenDialog() // Le téléport, marche
{
    CritterCl@ player = GetChosen();
    if (valid(player)) {
        RunServerScriptUnsafe("dev_menu@unsafe_TeleportPlayer", 0, player.HexX, player.HexY, null, null);
    }
}

And changed this :

void screen_change(bool show, int screen, int p0, int p1, int p2)
{
    if(show && screen == CLIENT_SCREEN_DIALOG) //Here
    {
        CenterPlayerOnScreenDialog();
    }

    if(DialogImage.Exists() && recheckDialogImage &&
       show && screen != CLIENT_SCREEN_DIALOG &&
       !(screen == CLIENT_SCREEN_BARTER || screen == CLIENT_SCREEN_SAY))
    {
        DialogImage.Unset();
        recheckDialogImage = false;
    }

    if(!show && DialogImage.Exists() && screen == CLIENT_SCREEN_DIALOG)
    {
        recheckDialogImage = true;
    }

    if(show)
        GUI_ShowScreen(screen, p0, p1, p2);
    else
        GUI_HideScreen(screen, p0, p1, p2);
}

And in dev_menu.fos :

void unsafe_TeleportPlayer(Critter& player, int dummy, int x, int y, string@ param3, array<int>@ param4)
{
    Map@ map = player.GetMap();
    if (valid(map)) {
        uint16 hexX = player.HexX;
        uint16 hexY = player.HexY;
        player.TransitToHex(hexX + 1, hexY, 0xff); // Téléporte le joueur sur une case voisine
        player.TransitToHex(hexX, hexY, 0xff); // Téléporte le joueur sur sa case d'origine
    }
}

It's really not clean, but it works!  ;D