GUI description help

Started by Lasca, Thu 02/04/2015 08:39:37

Previous topic - Next topic

Lasca

So, I've found a couple of other topics regarding this, but non that completely solves my problems. That could either be because me 'ead 'urts when I read too much code, or because I'm doing something wrong ;)

Anyway, here's the problem.
In the room I'm working on there's a couple of photographs on the wall. When the player clicks these photos I want them to appear on screen zoomed in, taking up a piece of the screen but not all of it (so, they will not be a whole new room). I've so far done them as GUIs. Then I want the player to be able to examine these photos with cursor and interact with them, so I've placed invisible buttons on the photo GUI's. So far so good. No my trouble's begin. I'm using SSHs Description Module, and I want the buttons on the GUI photos to be described in the same way as all other objects and hotspots. I've managed to get the description to work, but that made the buttons become "un-pressable". So basicly, I want areas on my GUIs to behave the same way as hotspot. With description and handling events.
I would ask this in the module thread, but the same question has previously been asked there but without answer. Any ideas?
Also, there's no absolute need for me to keep the photos as GUIs. If there's any other way to accomplish the same thing I'm all up for it.
Thanks in advance!
Pascal

monkey0506

The module might reset it (so you might have to modify the module code), but it seems like the GUI.Clickable and Button.Clickable properties are being set to false, while you want them to be set to true if there is an image on the buttons. If you simply try setting them clickable again, does that work?

Code: ags
  // set the button graphics...then...
  gYOURGUIHERE.Clickable = true;
  btnYOURBUTTONHERE.Clickable = true;

Lasca

Actually the un-clickable issue wasn't with the description module, that part worked just fine until I tried to solve the description problem using this code, but I probably did something wrong with it.
I however worked around the whole issue now by using objects instead of GUIs, which presented a new problem, since I wanted the photos to disappear at any click outside the photos. I solved that to, in a very, very ugly way.
While coding I often feel like the dad building a tree house for his kids, using sticks and duct tape - it holds together, but just barely. And it ain't pretty!
Anyway, thanks for the help!
/Lasca

monkey0506

You said you solved the photos disappearing in an ugly way, but didn't post any code. Just for reference, here's how I'd do it:

Code: ags
function oPhotos_AnyClick()
{
  // do stuff
}

function on_mouse_click(MouseButton button)
{
  if (button == eMouseLeft) // TODO: modify this to prevent conflict with global on_mouse_click, etc.
  {
    if (Object.GetAtScreenXY(mouse.x, mouse.y) != oPhotos)
    {
      oPhotos.Visible = false;
    }
  }
}

function on_event(EventType event, int data)
{
  if ((event == eEventGUIMouseDown) || (event == eEventGUIMouseUp))
  {
    oPhotos.Visible = false;
  }
}


Not too messy, I think.

Lasca

Errr... Yes that would probably have worked ;)
My solution was not so much... code. I added a object covering the whole room, made it invisible and transparent. When I "open" the photos the object appears but transparent. Clicking on the transparent object "closes" both the photos and the invisible object. Tada!

SMF spam blocked by CleanTalk