GUI won't open from other GUI

Started by Krum, Sat 30/04/2005 05:30:40

Previous topic - Next topic

Krum

Ok, I am having a problem with my Invetory.

I want my Invetory to start and stay in the bottom left hand corner (like sam and max) and pop up into a useable bigger invatory (also like sam and max).

I have the Object in the corner, but I can't get it to respond when I click on it.

I can't get the bigger window to do anything at all, I want it so I can look at objects in my invetory, use objects with other objects, scroll, and etc... and I also need it so that when I scroll my mouse to the edge the GUI closes and I keep what I have as one of my changeable Icons.

I know it's alot, but I just need some examples and I can go from there....It's how I learn everything.

PLZ... help me I beg of you...

DoorKnobHandle

Did you check that you checked the "Clickable" option, or am I misunderstanding you?

Then you could use those statements in your rep_ex function:

[AGS 2.62 script style!]

Code: ags

if ( mouse.x > LEFT_GUI_EDGE && mouse.x < RIGHT_GUI_EDGE )
Ã,  Ã, if ( mouse.y > TOP_GUI_EDGE && mouse.y < BOTTOM_GUI_EDGE )
Ã,  Ã,  Ã,  // do whatever you want if the player is hovering over the gui here...


I just wrote that without checking in AGS, but I'm pretty sure this works.

Just replace LEFT_GUI_EDGE, RIGHT_, TOP_ and BOTTOM_ with the values from your gui. If your gui is at position ( 170, 10 ) and has width of 20 and height of 20, then LEFT_GUI_EDGE would be 10, RIGHT_GUI_EDGE would be 30, TOP_GUI_EDGE would be 170 and BOTTOM_GUI_EDGE would be 190.

Got it? If not feel free to ask again and try to explain what you want more clearly.

EDIT: I just re-read your post and I think I completely misunderstood you... Anyways...

strazer

QuoteI have the Object in the corner, but I can't get it to respond when I click on it.

You mean a GUI with a GUI Button on it? Is the button set to "Run script"?
If that's not it, please post the contents of your interface_click function.

Ashen

starzer posted while I was typing, but...

What script do you have so far?
Not much help, I know, but it's useful for anyone trying to help you to know what you've already tried, so they can tell you what's right or wrong about it. (What strazer said.)

Anyway, hope this helps:
Suppose your little GUI (LITTLEGUI) has one button (button 0), which opens the main GUI (BIGGUI). BIGGUI has three buttons to select cursor mode (buttons 0, 1, 2) a button to close itself (button 3 which you might not need, since it closes on mouse off), the Inventory window, and scroll buttons (not covered, you can get the script for them from the existing INVENTORY code). Make sure all the buttons are set to 'Run Script'. Your script should be something like:

Code: ags

function interface_click (int interface, int button) {
  if (interface == LITTLEGUI) {
    if (button == 0) {
      GUIOff (LITTLEGUI);
      GUIOn (BIGGUI);
    }
  }
  if (interface == BIGGUI) {
    if (button == 0) SetCursorMode (MODE_LOOK);
    if (button == 1) SetCursorMode (MODE_USE);
    if (button == 2) SetCursorMode (MODE_TALK);
    if (button == 3) {
      GUIOff (BIGGUI);
      GUIOn (LITTLEGUI);
    }
    //Script for Inventory scroll buttons.
  }
  // Script for other GUIs
}


NOTE: You could set BIGGUI buttons 0-2 to 'Set Cursor Mode', instead of using scripting.

Now, you also need something in repeatedly_execute, to close BIGGUI when you move your mouse off it. You could use [...]'s script, but change all the '<'s to '>' and all the '>'s to '<', but it's probably easier to use something like this:
Code: ags

function repeatedly_execute () {
  if (IsGUIOn (BIGGUI) && GetGUIAT (mouse.x, mouse.y) != BIGGUI) {
    //BIGGUI is on, but the mouse isn't over it
    GUIOff (BIGGUI);
    GUIOn (LITTLEGUI);
  }
  //Any other stuff you want in rep_ex
}


And, like [...] said, ask again if there's something you don't get, or if I've misunderstood your problem.
I know what you're thinking ... Don't think that.

Krum

Sry for the confusion, I have a GUI in the corner it is clickable, but I can't add buttons and I try everything to make it so that when I click on the small GUI(0) that it opens the big GUI(1).

GUI(1) will be set up so that as you get Objects it will show up in order that you get them in. Also to leave GUI(1) "the big one", you will simply put your mouse at the very edge of the screen or just a certian amount (Just like sam and max).

I'm messing with the scripts you guys suggested now, but no success... I hope this helps....Oh and BTW can you tell me where to enter some scripts also...thx

Ashen

#5
I got what you meant - the script I gave you should produce something like the Sam & Max style.
What do you mean by you can't add buttons to the small GUI?

QuoteBTW can you tell me where to enter some scripts also...thx
It depends on what you want them to do, and when. Check out the BFAQ, particularly the one about placing code.
Unless you meant how to get into the script, in which case 'Edit Script from the 'Script' menu, or Ctrl-G, for teh global script, and the 'Edit Script' button ( with the two braces '{}') on the Room 'Setting' window, or Cotrl-E, for the Room script.
I know what you're thinking ... Don't think that.

Krum

Yea I tried your script and it didn't work I get an error on undefined symbol 'GetGUIAT'

Ashen

That would be because I was typing too fast. Change it to GetGUIAt instead.
I know what you're thinking ... Don't think that.

Krum

#8
Quote from: Ashen on Sun 01/05/2005 01:52:05
That would be because I was typing too fast. Change it to GetGUIAt instead.

Oh ok I didn't know it was case sensative, ok well it goes off now thanks but I still can't add buttons unless it's a "textwindow" but I have it as a clickable..... I tried textwindow alos but I can't del the buttons with Del....

Edit: I'm an idiot! I figured it out thx.

Ashen

'Textwindow' GUIs are used as backgrounds for displaying text, like the standard 'white box with black border', and can't be used as actual GUIs the way you need. I'm still not getting why you can't add buttons. Is it just that one GUI? What are you doing, and how isn't it working?
I know what you're thinking ... Don't think that.

Krum

#10
Ok now I have the window popping up just fine :-D, I just have one more problem with the inv. how would I go about making it so I can re-arange any of my "buttons" or objects.

and also you know how sam and max objects in the inv. are files before you pick them up and then they dissapear? How would I also go about doing that? THX A MILLION

oh and to awnser your question I wasn't dragging the button option like a friggin idiot :-P

Edit: oh! how can I make it so I can also right click to change cursors also during the inv?

Ashen

#11
Quotehow would I go about making it so I can re-arange any of my "buttons" or objects.
Not sure what you mean. You can re-arrange things in the editor just by dragging them. It's possible to move things in game, but complicated, so I won't go into it until I know that's what you meant. I don't think you can alter the order of items in the inventory.

Quoteand also you know how sam and max objects in the inv. are files before you pick them up and then they dissapear? How would I also go about doing that?
! If I understand the question, it's one of the first things covered in the tutorial that comes with AGS. It's also on-line here.

Quotehow can I make it so I can also right click to change cursors also during the inv?
You need to use the on_event function. By default, it doesn't exist, so you'll have to make it first. Open the Global Script, and paste this code anywhere - but make sure it's not inside any of the existing functions:
Code: ags

function on_event (int event, int data) {
  if ((event == GUI_MUP) && (data == BIGGUI)) SetNextCursorMode ();
}

(You'll need to change 'BIGGUI' to whatever you've called the big GUI.)

QuoteI'm an idiot! I figured it out thanks.
That's usually the problem I have, as well. "Why isn't this working? Oh, because I'm an idiot, of course," and then I fix the obvious mistake, and it works.
I know what you're thinking ... Don't think that.

Krum

Ok, I read the manual on the there (and have read it before), it doesnt help my problem...let me be more detailed on what I want, to clear things up  ;D.

For some reason It wont add any objects to my invatory It will make it dissapear but wont add it to my invatory. I even tried making my player start with an invatory (didn't show up either.)

----------------------------------------------------------------------------------------------------

By re-arranging I mean like have spots all over the inv where I could put any object I want so if I wanted to put my money next to my toy car I could, and I would leave a space. Like-a-so...

From this:

[Functions (wont move ever)] [Money]
[Toy Car] [Empty] [Empty] [Empty]
[Empty] [Empty] [Empty] [Empty]

Move to this:

[Functions (wont move ever)] [Empty]
[Toy Car] [Money] [Empty]
[Empty] [Empty] [Empty] [Empty]

(so you pick up the money (as Icon) then drop Icon in empty spot)

Or any variations....

----------------------------------------------------------------------------------------------------

Ok the cursor change worked like a charm thx :-D


Ashen

You're going to have to be more detailed than that.
Tell us exactly what you've done - how your GUI is set up (most importantly), what script you're using (or what Interaction Editor commands, if you're using that) to add inventory, etc.
If you've done what it says in that tutorial, it should be working. Since you can't get an item to show up when the player starts with it, it's most likely to do with how the GUI is set up.

Quote from: MeI don't think you can alter the order of items in the inventory.
AFAIK, the inventory is sorted based on the order you pick items up or, if you run UpdateInventory() the item number, from the editor. I don't think what you want is possible, without essentially scripting a custom Inventory interface from scratch - which is possible, but you might want to get more familiar with the basics, before you jump into that.

I'm glad the cursor thing worked, though. 1/3 is something, at least.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk