Scrolling GUI elements sideways [Solved]

Started by AnasAbdin, Thu 07/08/2014 13:31:21

Previous topic - Next topic

AnasAbdin

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)


Dadalus

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

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.

Dadalus

Would a struct help?

Code: ags

Struct DialogOpt {
    int OptionNumber;
    int SpriteNUmber;
    bool OptionOn;
}


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

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: ags
  int i = 3;
  GUIControl *gc;
  while (i < gDialog.ControlCount) {
    gc = gDialog.Controls[i];
    if (i < first_button) gc.Y = -60;  // don't show
    else {
      gc.X = (i - first_button) * 30 + 20; // first button at x = 20, next at x = 50, etc.
      gc.Y = 10;
    }
    i++;
  }

AnasAbdin

#5
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-)

AnasAbdin

#6
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.


SMF spam blocked by CleanTalk