Author Topic: Scrolling GUI elements sideways [Solved]  (Read 2071 times)

AnasAbdin

  • Peace, Love and AGS
Scrolling GUI elements sideways [Solved]
« on: 07 Aug 2014, 13:31 »
Hello all,
I created an icon based dialog GUI like The Dig. I'm trying to figure out how to scroll the topic icons sideways when the corresponding arrows are clicked. I have come to the idea that only the topics could be placed inside an InventoryWindow element. This means I'll have to create 100s of inventory items... unless I can put a button inside an InventoryWindow. I am thinking about using an InventoryWindow because of its elements queuing advantage (for adding/deleting dialog topics...)

My first question is mainly am I on the right track here or are there any other suggestions?

Then while trying to implement this method, I got stuck trying to scroll a single-item-height-InventoryWindow sideways.

I hope I'm explaining my case here clearly, also here's a png for better understanding:
(I've tinted the area where I'm thinking an InventoryWindow would exist)

« Last Edit: 07 Aug 2014, 22:10 by AnasAbdin »

Re: Scrolling GUI elements sideways
« Reply #1 on: 07 Aug 2014, 14:39 »
I'm new to AGS so my comments will probably be superseded by better suggestions.

Just an thought but if I were tackling this I'd change the Button.NormalGraphic. Id have a function with something like..

if (button.NormalGraphic==1)
{
    //do whatever it is image 1 corresponds to
}
else if (button.NormalGraphic==2)
{
    //do whatever it is image 2 corresponds to
}
etc

Perhaps have an array storing the image sprite numbers, then when you click 'left' load each buttons image with the sprites one down the list, 'right' one up.

You could change the array to reflect the dialog options available, or have a second array of boolean values to say whether each option is available.

I'm probably not making myself clear but I hope you see the approach I'm thinking of.
This has been a 'Mouse fetishist' approved message.

AnasAbdin

  • Peace, Love and AGS
Re: Scrolling GUI elements sideways
« Reply #2 on: 07 Aug 2014, 15:03 »
Thanks Dadalus. I appreciate your suggestion. Scrolling through sprite numbers occurred to me but I'm afraid it won't help my case for many reasons starting with the fact that the sprite numbers for the dialog topics are not consecutive.

Re: Scrolling GUI elements sideways
« Reply #3 on: 07 Aug 2014, 17:09 »
Would a struct help?

Code: Adventure Game Studio
  1. Struct DialogOpt {
  2.     int OptionNumber;
  3.     int SpriteNUmber;
  4.     bool OptionOn;
  5. }
  6.  

that way it doesn't matter what your sprite numbers are. A simple function to return the option number from the sprite number would be all thats needed.

No problems with you not using my suggestion, like I said I'm new to AGS so this feels a bit like dipping my toe in the deep end.

Good luck with your game (looks good).

This has been a 'Mouse fetishist' approved message.

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Scrolling GUI elements sideways
« Reply #4 on: 07 Aug 2014, 17:54 »
You can rearrange the buttons yourself. It looks like there are three fixed buttons (<, >, OK) and the others are supposed to scroll.
When a scroll arrow is clicked, you change a variable (first_button, initially 3), then reposition buttons:
Code: Adventure Game Studio
  1.   int i = 3;
  2.   GUIControl *gc;
  3.   while (i < gDialog.ControlCount) {
  4.     gc = gDialog.Controls[i];
  5.     if (i < first_button) gc.Y = -60;  // don't show
  6.     else {
  7.       gc.X = (i - first_button) * 30 + 20; // first button at x = 20, next at x = 50, etc.
  8.       gc.Y = 10;
  9.     }
  10.     i++;
  11.   }

AnasAbdin

  • Peace, Love and AGS
Re: Scrolling GUI elements sideways
« Reply #5 on: 07 Aug 2014, 19:02 »
Thanks Dadalus for the kind words and thanks again for the code support ;-D

Khris thanks! I think I found a little trick to try this evening :-D
I'll create two GUIs, one containing the (<,>, and OK) buttons, and another containing only the topic icons.
My concern is finding a way to add/delete topic icons into the queue. But I'll see what I can do when I get to my PC.

Edit:
Actually, 'locked' topics are just invisible icons. So all the buttons (locked and unlocked) are already created but some are visible and some are not. So every time I call the GUI visible, I can iterate through the GUI's buttons, assign a location for the visible buttons only...

Edit 2: Solved
I created 2 GUIs as I suggested. One with the ( <, >, ok ) buttons and another with the topic icons. Clicking each arrow moves the icons a step (a number of pixels) as long as there are visible icons outside the GUIs borders (which still can't be seen despite being visible). I will upload a video of the process as soon as I clean up the icons and stuff 8-)
« Last Edit: 07 Aug 2014, 22:10 by AnasAbdin »

AnasAbdin

  • Peace, Love and AGS
Re: Scrolling GUI elements sideways [Solved]
« Reply #6 on: 10 Aug 2014, 07:45 »
Ok no bump since this is already top :-[
Here's the result, 2 GUIs, the topic icons hide behind their GUI's borders.
Everytime a new topic is added or an old one is removed, the locations of the GUI buttons are updated as well.

[embed=640,390]http://www.youtube.com/watch?v=FMbqkMfhj9E[/embed]

Please if anyone wants to discuss code or mechanics then do it here, otherwise PM me  :)

I've also updated the GiP thread for tidiness.

« Last Edit: 10 Aug 2014, 08:46 by AnasAbdin »