How to script Technobabylon's slide out GUI?

Started by , Thu 21/05/2015 08:47:35

Previous topic - Next topic

Saren

I can't figure out how to script the sliding inventory GUI like the one in Technobabylon, please help. I've searched this forum and there was no other thread explaining it.

LostTrainDude

#1
Sorry if this is a cheap answer :)

Just off the top of my head, I think that it may be using the great Tween Module which works fine also on GUIs, as far as I can remember and tell from the documentation. :D

I don't remember right now if the Inventory GUI it's just "sliding out" or "unraveling" like a carpet.

In the first case, this should be the reference code that should be implemented whenever you want it to happen:
Code: ags
GUI.TweenPosition(float timing, int toX, int toY, optional TweenEasingType, optional TweenStyle, optional startDelay, optional timingType)


In the latter, I think that the GUI may have a "tiled background" so that it doesn't "break" when tweening is applied to increase its width.
Code: ags
GUI.TweenSize(float timing, int toWidth, int toHeight, optional TweenEasingType, optional TweenStyle, optional startDelay, optional timingType)


The module lets you change sizes and position of every element in the GUI - Label, Button, TextBox, ListBox, Slider and InvWindow - so probably it's just a matter of prototyping until you get what you're looking for. Nothing that's necessarily hard to do.
"We do not stop playing because we grow old, we grow old because we stop playing."

Khris

The basic idea is to track whether the mouse is over the GUI in repeatedly_execute. When the mouse moves on top of the GUI (which is only showing it's left edge at the bottom right corner), it's supposed to move over; when the mouse leaves the GUI, it's supposed to slide back.

Code: ags
GUI* wasUnderMouse;
int guiTargetX = 305;

void handleInvGUI() {
  GUI* isUnderMouse = GUI.GetAtScreenXY(mouse.x, mouse.y);
 
  if (wasUnderMouse == null && isUnderMouse == gInventory) {
    // mouse moved on top of it, slide in
    guiTargetX = 10;
  }
  else if (wasUnderMouse == gInventory && isUnderMouse == null) {
    // mouse moved off, slide out
    guiTargetX = 305;
  }
 
  // move GUI
  int dx = guiTargetX - gInventory.X;
  if (dx) {
    if (dx < -5 || dx > 5) dx = dx / 2;
    gInventory.X += dx;
  }
  
  wasUnderMouse = isUnderMouse; // track for next game loop
}

// add this to repeatedly_execute:
  handleInvGUI();

Saren

So I don't need to install any module or plugin? I can just type in the code for the GUI?


Saren

Thanks! I'll try it and come back if I need more help.

SMF spam blocked by CleanTalk