GUI help

Started by Candle, Mon 14/02/2005 00:56:47

Previous topic - Next topic

Candle

I want to use this image and have it just stick out a little so you can see the click part and them when clicked it shows the little buttons (have to make them yet) that have inv and exit etc .
How would I code that as I just can't get anything to work .


Anyone help ?

Ashen

What have you tried?

I think you need SetGUIPostion (GUI, x, y);, (or the OO equivalent, if you're using that). The problem is, in pre-beta versions, I don't think there's a way to get the GUi co-ords, so you'll probably have to use GetGuiAt (x,y);

Suppose the full GUI is called CLICKGUI, and is at 0, 50 when fully displayed (top left corner against the left of the screen, 50 pixels down), and is 200 wide. The 'Click' button is button 0, and 10 pixels wide.

You need to add SetGUIPosition (CLICKGUI, -190, 50); to game_start, since the editor doesn't seem to like negative numbers.
Then, in interface_click:
Code: ags

if (button == 0) {
  if (GetGUIAt (15, 55) != CLICKGUI) {// i.e. only the button is showing
    SetGUIPosition (CLICKGUI, 0, 50);
  }
  else { // Whole GUI is visible
    SetGUIPosition (CLICKGUI, -190, 50);
  }
}

This would make the GUI 'jump' out and back, but it'd be easy enough to make it scroll out if you wanted.

The OO version would be something like:
Code: ags

  if (gClickgui.X == -190) gClickGui.X = 0:
  else gClickgui.X = -190;
I know what you're thinking ... Don't think that.

Candle

#2
Well so far I have this but get the error of to many "if"
Code: ags
if (button == 0) {
  if (GetGUIAt (15, 55) != CLICKGUI) {// i.e. only the button is showing
    SetGUIPosition (CLICKGUI, 0, 50);
}

  else { // Whole GUI is visible
    SetGUIPosition (CLICKGUI, -190, 50);
function interface_click(int interface, int button) {
  if (interface == ICONBAR) {
    if (button == 4) {  // show inventory
      show_inventory_window();
    }
    else if (button == 5) {   // use selected inventory
      if (character[ GetPlayerCharacter() ].activeinv >= 0)
        SetCursorMode(4);
    } 
    else if (button == 6)    // save game
      SaveGameDialog();
    else if (button == 7)   // load game
      RestoreGameDialog();
    else if (button == 8)   // quit
      QuitGame(1);
    else if (button == 9)    // about
      Display("Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2003 Chris Jones");
  }  // end if interface ICONBAR

  if (interface == INVENTORY) {
    // They clicked a button on the Inventory GUI
    
    if (button == 1) {
      // They pressed SELECT, so switch to the Get cursor
      SetCursorMode (MODE_USE);
      // But, override the appearance to look like the arrow
      SetMouseCursor (6);
    }
    
    if (button == 2) {
      // They pressed LOOK, so switch to that mode
      SetActiveInventory(-1);
      SetCursorMode(MODE_LOOK);  
    }
    if (button == 3) {
      // They pressed the OK button, close the GUI
      GUIOff (INVENTORY);
      SetDefaultCursor();
    }

    if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
      // scroll down
      game.top_inv_item = game.top_inv_item + game.items_per_line;
    }
    if ((button == 5) && (game.top_inv_item > 0)){
      // scroll up
      game.top_inv_item = game.top_inv_item - game.items_per_line;
    }
  }
}




#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE


Maybe eazy to make a template so I can see it . lol

Ashen

#3
You've pasted it outside of interface_click, and missed out a few braces. It should be more like this:
Code: ags

function interface_click(int interface, int button) {
Ã,  if (interface == CLICKGUI) {
Ã,  Ã,  if (button == 0) {
Ã,  Ã,  Ã,  if (GetGUIAt (15, 55) != CLICKGUI) {// i.e. only the button is showing
Ã,  Ã,  Ã,  Ã,  SetGUIPosition (CLICKGUI, 0, 50);
Ã,  Ã,  Ã,  }
Ã,  Ã, Ã,  Ã, else { // Whole GUI is visible
Ã,  Ã,  Ã,  Ã,  SetGUIPosition (CLICKGUI, -190, 50);
Ã,  Ã, Ã,  Ã, }
Ã,  Ã,  }
Ã,  }
Ã,  if (interface == ICONBAR) {


Can knock up a template for you though, if you'd like?

EDIT:
Template is RIGHT HERE. Also includes a read me, with a bit of explanation. Let me know if there's anything you don't understand.
I know what you're thinking ... Don't think that.

Candle

If I can see it in the template that would be better for me . thank you .

SMF spam blocked by CleanTalk