Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Gold Dragon on Mon 19/05/2008 23:05:11

Title: Custom Txt Box doesn't display over Inventory Gui
Post by: Gold Dragon on Mon 19/05/2008 23:05:11
ok I wrote my own custom Txt Box Code


function SpriteFont::display(String Txt,  int x,  int y){
.
.
(creates txt box)
.
.
Overlay *displayOverlay = Overlay.CreateGraphical(x, y, sprite.Graphic, false); // create our overlay
  sprite.Delete(); // delete our temporary sprite
  while (!WaitMouseKey(1)) {} // returns 0 if the time has elapsed, 1 if a mouse button or key was pressed
  displayOverlay.Remove();

}


Works perfect for to display text on background. But when I call it to in inventory



function iDullAxe_Look(){
  FontDk.display("A Fine Axe but it looks a bit dull from all the chopping.");
}


Incase your going to ask.. yes FontDk is created and imported as a SpriteFont class/struct

My Guess is that the over lay is being writen over the background which the Gui is written on top of that in this order...

Background...
Overlay text Box..
Inventory Gui..

How do I make it...

Background..
Inventory Gui..
Overlay Text box

Any Ideas?
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Pumaman on Mon 19/05/2008 23:11:34
Currently overlays are always drawn behind GUIs, so this isn't possible -- you'd need to use a GUI Button to display your sprite, or a GUI textbox instead.

There is an outstanding feature request on my to-do list to allow custom z-ordering between overlays and GUIs.

Have you considered using a GUI instead of an overlay for your custom text box? It might be more appropriate.
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Gold Dragon on Tue 20/05/2008 03:56:45
Sure I would if there was a way to dynamically build the GUI like I do with sprites.. I use 9 Text box tile sprites and A-Z, a-z, 0-9,  graphic sprite tiles.. is there a way to dynamically create a GUI using these tiles as I do with the Dynamicsprite class/struct??
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Pumaman on Tue 20/05/2008 20:09:32
Well, you can always construct your dynamic sprite the same way that you are doing already, but then set it onto a GUI.BackgroundGraphic rather than creating is as an overlay.

If that doesn't work perhaps you could provide more detail about what you're trying to do.
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Gold Dragon on Wed 21/05/2008 02:15:15
Thanks I'll give that a shot  ;D ;D ;D
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Gold Dragon on Thu 22/05/2008 23:46:32
Quote
Well, you can always construct your dynamic sprite the same way that you are doing already, but then set it onto a GUI.BackgroundGraphic rather than creating is as an overlay.

If that doesn't work perhaps you could provide more detail about what you're trying to do.

GUI.BackgroundGraphic gets and set the graphic with a sprite number. At least what I can find in the manual. Is there a way to give a DynamicSprite a number to be use for GUI.BackgroundGraphic?  :(
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: GarageGothic on Fri 23/05/2008 00:22:49
Quote from: Gold Dragon on Thu 22/05/2008 23:46:32GUI.BackgroundGraphic gets and set the graphic with a sprite number. At least what I can find in the manual. Is there a way to give a DynamicSprite a number to be use for GUI.BackgroundGraphic?  :(

DynamicSprites actually do have sprite slot numbers. Just use DynamicSprite.Graphic (so if you have a GUI names gTextBox and a DynamicSprite called TextBoxSprite, you would write "gTextBox.BackgroundGraphic = TextBoxSprite.Graphic;"
Title: Re: Custom Txt Box doesn't display over Inventory Gui
Post by: Gold Dragon on Fri 23/05/2008 01:07:32
AWWW SWEET!!!!! THX  ;D ;D ;D ;D

EDIT:

I have successfully implemented it. Works like a charm thanks guys!! Also Pumaman I noticed you added a similar thing that can be done in RC 1 with Text Window Gui's. VERY NICE!!

Now here is just another big problem I have....

Which one do I use!!  :o   LOL!!!   ;D ;D