Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Mon 26/11/2018 08:49:29

Title: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: bx83 on Mon 26/11/2018 08:49:29
And there it is. I just want to make a transparent GUI for use in a custom dialogue system - at the moment, it shows as white (BackgroundColour/BackgroundColourNumber etc. are all 0's).
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: Khris on Mon 26/11/2018 09:18:00
Given that you want to use it for Dialogs, did you create it as TextWindow GUI? If so, have you assigned any images to the 4 corners / 4 edges / background?
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: Crimson Wizard on Mon 26/11/2018 09:34:53
Transparent is 0, so there might be something else involved here.
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: bx83 on Mon 26/11/2018 10:39:13
This is it. (ignore the cursor)

(http://redrom.ltd/img/dialoggui.png)
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: bx83 on Mon 26/11/2018 10:41:43
And this is the window in game (down the bottom).
I'd like for it be translucent (instead of solid white) so I can see what's behind it.

(http://redrom.ltd/img/convowindow.png)
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: bx83 on Mon 26/11/2018 10:45:15
And here is the code in GlobalScript:



//----------------------------------------------------------------------------------------------------------------------
// DIALOG
//----------------------------------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Get Dimensions
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_get_dimensions(DialogOptionsRenderingInfo* info)
{

// Create a 1024x64 dialog options area at (0,704)

  info.X = 0;
  info.Y = 704;
  info.Width = 1366;
  info.Height = 64;
}

//----------------------------------------------------------------------------------------------------------------------
// Draw Dialog Options
//----------------------------------------------------------------------------------------------------------------------

function DrawDialogOptions(DrawingSurface* ds, DialogOptionsRenderingInfo* info)
{
  int i = 1, ypos = 0, xpos = 0;
  ds.Clear(15);
  while (i <= info.DialogToRender.OptionCount)
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      String str = info.DialogToRender.GetOptionText(i);
      int cur_img = str.AsInt;
      ds.DrawImage(xpos, ypos, cur_img);
      xpos += 64;
    }
    i++;
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Render
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_render(DialogOptionsRenderingInfo* info)
{
  DrawDialogOptions(info.Surface, info);
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Repeat Exec
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_repexec(DialogOptionsRenderingInfo* info)
{
  int i = 1, xpos = 0;
  while (i <= info.DialogToRender.OptionCount)
  {
    if (info.DialogToRender.GetOptionState(i) == eOptionOn)
    {
      if (mouse.y >= info.Y && mouse.x >= xpos && mouse.x <= xpos+64)
      {
        info.ActiveOptionID = i;
        return;
      }
      xpos += 64;
    }
    i++;
  }
}

//----------------------------------------------------------------------------------------------------------------------
// Dialog Options Mouse Click
//----------------------------------------------------------------------------------------------------------------------

function dialog_options_mouse_click(DialogOptionsRenderingInfo* info, MouseButton button)
{
  if (info.ActiveOptionID > 0)
  {
    MyDynamicSpriteForTheFakeGUI = DynamicSprite.Create(info.Width, info.Height, true);
    DrawingSurface* ds = MyDynamicSpriteForTheFakeGUI.GetDrawingSurface();
    DrawDialogOptions(ds, info);
    ds.Release();

    gFakeDialogOptions.BackgroundGraphic = MyDynamicSpriteForTheFakeGUI.Graphic;
    gFakeDialogOptions.Visible = true;
    info.RunActiveOption();
  }
}

// END DIALOG FUNCTIONS


The dialog was originally for 1024x768 backgrounds, now 1366x768.
It's used with 64x64 conversation images.
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: Khris on Mon 26/11/2018 10:55:12
You have
ds.Clear(15);

15 is white. Use 0 instead, or COLOR_TRANSPARENT.
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: selmiak on Tue 27/11/2018 06:54:24
That screenshot looks pretty cool and reminds me of some timetraveling adventures :)
Title: Re: What BackgroundColourNumber should I use to make a transparent GUI?
Post by: bx83 on Tue 27/11/2018 11:05:10
Thanks Khris :)
Selmiak, I have no idea what you're takling about ;)