Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - CharleeMK

#1
Well, I finally got something that works. I'm sure there's a better solution but I think this one simple and you know, if it works better not to touch it.

Here's what I did:

I used the Custom dialog options rendering template to render the dialog options how I wanted and also I made another GUI with the buttons for the dialog; in my case it was a REWIND button to go to the previous dialog and a STOP button to end the dialog. I specified the placement of the buttons within the dialog_options_repexec function to create the mouse over and click button effects but also to set the active dialog with info.ActiveOptionID. Then I created two dialog options that are not shown or said, one to go-to previous and the other one to stop dialog (I did this cause even that I managed to call the GUI button to do the Dialog.Stop, it wasn't possible to add any dialog that way).


I think that for starters like me this is an easy way to do it. I hope it helps.

Code: ags
int dlg_color_main = 44917;
int dlg_color_select = 57307;

function dialog_options_get_dimensions(DialogOptionsRenderingInfo *info)
{
  info.X = 3;
  info.Y = 105;
  info.Width = 274;
  info.Height = 75;
  info.HasAlphaChannel = true;
}

function dialog_options_render(DialogOptionsRenderingInfo *info)
{
  gDialogBUTTONS.Visible = true;
  info.Surface.DrawImage(0, 0, 414);
  int ypos = 7;
  for (int vdialognumber = 1; vdialognumber <= info.DialogToRender.OptionCount; vdialognumber++)
  {
    if (info.DialogToRender.GetOptionState(vdialognumber) == eOptionOn)
    {
      if (info.ActiveOptionID == vdialognumber)
      {
        info.Surface.DrawingColor = dlg_color_select;
      }
      else info.Surface.DrawingColor = dlg_color_main;
      info.Surface.DrawStringWrapped(9, ypos, 269, eFontFont0, eAlignLeft, info.DialogToRender.GetOptionText(vdialognumber));
      ypos += GetTextHeight(info.DialogToRender.GetOptionText(vdialognumber), eFontFont0, info.Width - 10) - 5;
    }
  }
}

function dialog_options_repexec(DialogOptionsRenderingInfo *info)
{
  info.ActiveOptionID = 0;
  if (mouse.y < info.Y || mouse.y >= info.Y + info.Height)
  {
    return;
  }
  int ypos = -3;
  int xpos = 0;
  for (int vdialognumber = 1; vdialognumber <= info.DialogToRender.OptionCount; vdialognumber++)
  {
    if (info.DialogToRender.GetOptionState(vdialognumber) == eOptionOn)
    {
      ypos += GetTextHeight(info.DialogToRender.GetOptionText(vdialognumber), eFontFont0, info.Width) - 5;
      if ((mouse.y - info.Y) >= ypos && (mouse.x - info.X) >= 8 && mouse.x < info.Width - 20)
      {
        info.ActiveOptionID = vdialognumber;
      }
    }
  }
  //ACTIVATE DIALOG OPTION & MOUSE OVER AND CLICK EFFECTS
  if (mouse.x <= 301 && mouse.x >= 279 && mouse.y <= 135 && mouse.y >= 123)
  {
    info.ActiveOptionID = 9;
    if (mouse.IsButtonDown(eMouseLeft) == true)
    {
      bDialogREW.NormalGraphic = 413;
      bDialogSTOP.NormalGraphic = 415;
    }
    else if (mouse.IsButtonDown(eMouseLeft) == false)
    {
      bDialogREW.NormalGraphic = 412;
      bDialogSTOP.NormalGraphic = 415;
    }
  }
  else if (mouse.x <= 315 && mouse.x >= 303 && mouse.y <= 135 && mouse.y >= 123)
  {
    info.ActiveOptionID = 10;
    if (mouse.IsButtonDown(eMouseLeft) == true)
    {
      bDialogSTOP.NormalGraphic = 417;
      bDialogREW.NormalGraphic = 411;
    }
    else if (mouse.IsButtonDown(eMouseLeft) == false)
    {
      bDialogSTOP.NormalGraphic = 416;
      bDialogREW.NormalGraphic = 411;
    }
  }
  else
  {
    bDialogSTOP.NormalGraphic = 415;
    bDialogREW.NormalGraphic = 411;
  }
}

function dialog_options_mouse_click(DialogOptionsRenderingInfo *info, MouseButton button)
{
   if (info.ActiveOptionID > 0 && mouse.IsButtonDown(eMouseLeft))
   {    
     info.RunActiveOption();
   }
}

function dialog_options_close(DialogOptionsRenderingInfo *info)
{
  gDialogBUTTONS.Visible = false;
  bDialogSTOP.NormalGraphic = 415;
  bDialogREW.NormalGraphic = 411;
}
#2
I already tried with two GUIs, one for the Dialog and another for the buttons but when the dialog is running any other GUI won't work. My initial thinking was to try to enable player interface when dialog is on or the GUI with the buttons but I couldn't find the way to do neither of those things. I think I'll try the custom dialog rendering so I'm reading the whole scripting tutorial to understand better how to do it.

Also I saw that the Custom Dialog GUI module may achieve what I'm looking for but again, I think I need to understand much better the script to know what might suit my needs and what not, so back to the manual.

Thanks so much for all the help. Now I have a lot of reading and learning to do but whenever I make this thing work properly I think I'll post the script here in a way other noobs like me can understand it.
#3
I want one button to stop the dialog an another to go back to the previous dialog, that's it, no scrolling or fancy stuff. I know that the easiest way is using the dialog options for that but I wanted to include those buttons for design reasons.
#4
Thanks so much for the quick response. Yes, I saw both solutions that you mention but I was hoping for a easier one cause I couldn't believe that such a "simple" feature wasn't built in the engine. Also as I don't have any programming background at all I saw them a little too complicated to implement due to my absence of skills. Well, I guess that if I want those damn buttons I'll have to earn them by learning.

Thanks again Crimson Wizard, I'll follow your advice
#5
I'm sure this is totally a noob question but I'm getting crazy trying to have working buttons with my dialog. Is there any chance to enable another GUI while the Dialog is on?
SMF spam blocked by CleanTalk