Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ShinjinNakamura on Sat 22/06/2013 17:04:41

Title: [Use GUI for dialog options] not working
Post by: ShinjinNakamura on Sat 22/06/2013 17:04:41
Salam,

I've checked the [Use GUI for dialog options] under general settings by inputting 1 (because the ID for the custom made gui I want to use is 1),
and made sure under the gui options to enable (PopupYPos). When I run the game, it doesn't appear.

I even tried enabling [Custom Text-Window GUI] under general settings by inputting 1. Still doesn't appear.
By the way Iam using lucasart style.

So I thought I would go script my own, using the manual's example as a template.
---------------------------------------------------------------------
Code (ags) Select

function dialog_options_get_dimensions(DialogOptionsRenderingInfo *info)
{
  info.X = 335;
  info.Y = 312;
  info.Width = 200;
  info.Height = 600;
}

function dialog_options_render(DialogOptionsRenderingInfo *info)
{
DrawingSurface.DrawImage(335,  312, 13)};
}

--------------------------------------------------------------------------
Problem here is that when inputting the SpriteSlot number, the one I want to use is no. 13, the following error message appears:
GlobalScript.asc(12): Error (line 12): must have an instance of the struct to access a non-static member

If I could use the former easier method, that would be great. But I don't mind the latter scripting method either.

Please kindly help,
Thanks in Advance.
Title: Re: [Use GUI for dialog options] not working
Post by: Ryan Timothy B on Sat 22/06/2013 19:14:15
I have to work in just a moment so this will be very brief. You're using DrawImage and DrawingSurface wrong. From the manual, this is what it shows for DrawImage and DrawingSurface:
QuoteDrawImage
Code (ags) Select
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(100, 100, oDoor.Graphic, 40);
surface.Release();


Then under the manual for getting a drawing surface for an existing sprite:
Quote
GetDrawingSurface (dynamic sprite)
Code (ags) Select
DynamicSprite *sprite = DynamicSprite.CreateFromExistingSprite(object[0].Graphic);
DrawingSurface *surface = sprite.GetDrawingSurface();
surface.DrawingColor = 13;
surface.DrawLine(0, 0, 20, 20);
surface.Release();
object[0].Graphic = sprite.Graphic;
Wait(40);
sprite.Delete();


I'm still not sure what you're trying to do. Assigning sprite 13 as the GUI's background sprite? And then you're also adjusting the width/height and position in dialog_options_get_dimensions. Since it's a GUI, why not just adjust that stuff within the GUI editor?

I don't have time to explain how to use a custom GUI, but the previous should help you understand what your error is.
Title: Re: [Use GUI for dialog options] not working
Post by: ShinjinNakamura on Sun 23/06/2013 03:18:55
Sprite No. 13 is a text bubble (non-dynamic). I tried to use it as a background image for the custom GUI I intended to use for dialog.
But like I said, under general settings the [Use GUI for dialog options] was not working.

As far as the script is concerned, in DrawImage:
surface.DrawImage (100, 100, oDoor.Graphic, 40);
where oDoor.Graphic is placed, how do I signify an object as a graphic? I assumed any object/picture/character we use always takes the form of a sprite.
Title: Re: [Use GUI for dialog options] not working
Post by: Ryan Timothy B on Sun 23/06/2013 06:15:40
I was a little confused earlier. I had forgot how AGS's dialog_options_render worked. I was thinking "info" was your GUI. My apologies.

Quote from: ShinjinNakamura on Sun 23/06/2013 03:18:55
surface.DrawImage (100, 100, oDoor.Graphic, 40);
Where oDoor.Graphic is placed, how do I signify an object as a graphic? I assumed any object/picture/character we use always takes the form of a sprite.
For instance, in the case of your bubble graphic, you would simply use:
Code (ags) Select
surface.DrawImage (100, 100, 13);
oDoor.Graphic simply points to the sprite or dynamic sprite number that the object is using. I personally think it's a little misleading as it should've been named oDoor.SpriteID or oDoor.SpriteIndex, or something along those lines.


If you want the dialog options to be drawn over the cloud bubble sprite (13), simply do this (assuming your sprite isn't an alpha channel image). Mostly copying from the manual:
Code (ags) Select
function dialog_options_render(DialogOptionsRenderingInfo *info)
{
  info.Surface.Clear(COLOR_TRANSPARENT);    // Clear the area transparent
  info.Surface.DrawImage(0, 0, 13);    // Draws your cloud sprite behind the custom dialog render
 
  int i = 1,  ypos = 0;
  while (i <= info.DialogToRender.OptionCount)    // Render all the options that are enabled
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      if (info.ActiveOptionID == i) info.Surface.DrawingColor = 13;
      else info.Surface.DrawingColor = 4;
      info.Surface.DrawStringWrapped(5, ypos, info.Width - 10, eFontFont0, eAlignLeft, info.DialogToRender.GetOptionText(i));
      ypos += GetTextHeight(info.DialogToRender.GetOptionText(i), eFontFont0, info.Width - 10);
    }
    i++;
  }


This code along with the one you posted that adjusts the X, Y, Width and Height.

Now if your speech bubble is an alpha channel image, then an actual GUI is likely the route you'll need to go. Let me know.
Title: Re: [Use GUI for dialog options] not working
Post by: ShinjinNakamura on Sun 23/06/2013 11:29:01
Aaah, Iam a little more clear on the script now.

Yes Iam afraid the image Iam using is alpha channel. So I would have to do it via GUI.
(By the way I tried the whole new script on a non alpha channel image. Unfortunately it didn't work.)
Title: Re: [Use GUI for dialog options] not working
Post by: Ryan Timothy B on Sun 23/06/2013 17:22:14
Quote from: ShinjinNakamura on Sun 23/06/2013 11:29:01
By the way I tried the whole new script on a non alpha channel image. Unfortunately it didn't work.
Hmm. Out of curiousity... Did you end up putting the dialog_options_get_dimensions function that you had in? Is it possible the X and Y of the DrawImage was off the boundaries of this dialog?
What part of the dialog_options_render didn't work - just the drawImage or the text as well? Did you try changing the option text color, did that work? If not then it sounds like more of an issue than just your image not drawing.
Title: Re: [Use GUI for dialog options] not working
Post by: ShinjinNakamura on Sun 23/06/2013 19:30:09
Text appears fine, the image on which its supposed to render doesn't appear (the bubble). Tried changing option text color too, and checked if x/y coordinates were correct, still no change.
This is my script.
------------------------------------------------------------------------
Code (ags) Select

function dialog_options_get_dimensions(DialogOptionsRenderingInfo *info)
{
  info.X = 300;
  info.Y = 300;
  info.Width = 245;
  info.Height = 561;
}
function dialog_options_render(DialogOptionsRenderingInfo *info)
{
  info.Surface.Clear(COLOR_TRANSPARENT);    // Clear the area transparent
  info.Surface.DrawImage(0, 0, 25);    // Draws your cloud sprite behind the custom dialog render
 
  int i = 1,  ypos = 0;
  while (i <= info.DialogToRender.OptionCount)    // Render all the options that are enabled
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      if (info.ActiveOptionID == i) info.Surface.DrawingColor = 13;
      else info.Surface.DrawingColor = 4;
      info.Surface.DrawStringWrapped(5, ypos, info.Width - 10, eFontFont0, eAlignLeft, info.DialogToRender.GetOptionText(i));
      ypos += GetTextHeight(info.DialogToRender.GetOptionText(i), eFontFont0, info.Width - 10);
    }
    i++;
  }
}

---------------------------------------------------------------
The sprite ID is 25 because Iam using a non alpha channel image. Oh and I placed this under the global script.
Here is an image of the scene, as you can see only the text appears above the head.
Scene Image (http://postimg.org/image/q6gnszn9f/)