Page 3 of 4

Re: Qustion on GUI Buttons in Max

Posted: Fri Dec 09, 2011 7:36 pm
by TheMagician
That's because if you read the tutorial, you'll notice I don't have you set up a "click off panel".
I must admit I can't follow you, Andy. From what I read in your tutorial you actually DO set up an invisible "click off panel".
Using Modal Enabled, you do not need a click off panel. The player can simply click on the GUI pop up and it will go down
I think this needs more clarification because it doesn't work right out of the box. If you want this behaviour you have to assign a GUIButton component to the main GUI panel (in your example the note) as well as a TagID component with a value of 99 (if you use xDialogToggle). Only then the GUI will close down when you click on it.
Actually you are supposed to be able to exit xDialogToggle by keyboard input as well.
In my last post I forgot to add information on this and to be more specific.
GUIs that have 'modal' enabled never trigger OnControlKeyEvent. However, there obviously is another way to exit a 'modal' GUI by pressing the ESCAPE key (or the backspace key). For this to work you have to add the following lines in your OnGUINotify:

Code: Select all

if (event == kExitMode):
            # trigger the closing of the dialog here
These lines get triggered when you hit ESC or BACKSPACE even if the GUI is set to modal.
However, to repeat it one more time: OnControlKeyEvent is never called for modal GUIs (at least that's my conclusion from all the information I've gathered).
Using debug print commands I've found out that even in Cyan's xDialogToggle file the OnControlKeyEvent section is never called when the GUI is set to modal, not even when pressing ESCAPE.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 4:09 am
by Christopher
But if you disable Modal, don't forget to disable the avatar movement when the GUI goes up. If you don't do this your avatar can move when the dialog is up...

Christopher

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 4:30 am
by TheMagician
But if you disable Modal, don't forget to disable the avatar movement when the GUI goes up
What's the Python function to do that?

Also, while we're at the topic, is there actually a way to disable (and later enable again) the user from moving the avatar that you can set within 3D Max (perhaps via responders)?
For a short cutscene I'd like to have my avatar stand still and not move. I haven't found a way to do that in Max.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 4:44 am
by D'Lanor
TheMagician wrote: However, to repeat it one more time: OnControlKeyEvent is never called for modal GUIs (at least that's my conclusion from all the information I've gathered).
Using debug print commands I've found out that even in Cyan's xDialogToggle file the OnControlKeyEvent section is never called when the GUI is set to modal, not even when pressing ESCAPE.
Yes, you are right. xDialogToggle captures the escape key under OnGUINotify() at the line "elif (event == kExitMode):". Riddle solved. :)
TheMagician wrote:
But if you disable Modal, don't forget to disable the avatar movement when the GUI goes up
What's the Python function to do that?

Also, while we're at the topic, is there actually a way to disable (and later enable again) the user from moving the avatar that you can set within 3D Max (perhaps via responders)?
For a short cutscene I'd like to have my avatar stand still and not move. I haven't found a way to do that in Max.
There are several functions for it in Python.
  • PtDisableMouseMovement() / PtEnableMouseMovement() comes in handy when your GUI has clickables. This makes sure the avatar does not walk when he/she misses a clickable (and that happens more often than you'd expect).
  • Then there is PtDisableMovementKeys() / PtEnableMovementKeys() which disables movement by keyboard input. If I remember correctly it still lets the actual control key event pass to be captured by OnControlKeyEvent but you'll have to verify that.
  • If you just want to disable forward movement you can use PtDisableForwardMovement() / PtEnableForwardMovement().
  • You can even do this for jumping only: PtDisableAvatarJump() / PtEnableAvatarJump()
Edit: I've never seen this done through a responder and probably with good reason, because within a netpropagated responder it would freeze all avatars in the age. The Python functions always apply to the local avatar.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 5:38 am
by TheMagician
Once again: thank you so much for all the valuable information :)
It's funny how you all talk about 'best practice' and coding tips here and there ... feels like your knowledge comes directly from Cyan :D

Of course this wouldn't be a proper GUI button thread if we didn' talk about GUI button sounds ;)
I didn't find a tutorial on this and analyzing Cyan's age files didn't yield any results.

For testing purposes I use two sounds from URU (tldnPeriscopeButtonDn01.ogg and tldnPeriscopeButtonUp01.ogg).
I've created 2 GUISound components and assigned them to my GUI button object. In the component rollout I've assigned the .ogg files to the components.
Then, in the GUIButton component I ticked 'Play snd on mouse down' and 'Play snd on mouse up' and pointed them to the 2 GUISound components.

Everything exports fine but the button is silent when I click it.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 6:18 am
by andylegate
@TheMagician: Oh goodness, you're right. I need to rewrite the tutorial. Also: yes, I know you still have to attach the components to the GUI panel, and that is what I did to make the screen shots I provided: moved the components to the GUI panel and completely deleted the clickoff panel.

It is possible to control the player movement using Multi Behavior Mod, one of the animations you can use is "idle". However as D'Lanor said, you have to be careful how you use the responders as it can affect all the players that are in the age (and is why you do not use the SubWorld commands in a responder, else you'll have all the players in the Age falling through the floor). Think of Python as the "Multiplayer Friendly Solution". You do use responders that are triggered by Python all the time, but when it comes to controlling the player, it's better to use Python directly if possible. You are doing good looking at how Cyan did that with many of their Ages, it's just a matter of understanding what the python does.

Just remember that people like D'Lanor, Hoikas, Branan and others I've failed to mention, are here and can help you with anything python related. They have been working with it in Uru for so long, they'll know what something does, and how it does it, and how to use it.

Your sound problem: sorry, never got around to messing with that. Hope you figure it out. Post a tutorial once you do!

Now I'm going to head back to the Hammer editor in the Source SDK for Team Fortress 2. Tomala challenged me to do something, and I'm trying to see if I can't make it work, heheheheheheh.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 6:20 am
by Christopher
well, I am not sure hwo to use this,but maybe you can take a look in the KI-source which is released by cyan. I know it's a huge file but,maybe you can find something in the componentmgr. I don't know if you already know it, but doubleclick on the component select all objects which has this component assigned. I think I saw a Sound component in this source...

If you can't find something, can also make an responder which plays the sound when the button is pressed.
Christopher

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 12:31 pm
by GPNMilano
I think I can help with the sound issue. I don't have the time right now but when I get home tonight I'll fire up 3dsMax and see what I did to get sounds for the various guis from Chloe's Hood Office when I was converting it from blender to max export.

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 12:46 pm
by Christopher
I think this would be easyer as my solution. :D

Re: Qustion on GUI Buttons in Max

Posted: Sat Dec 10, 2011 4:59 pm
by TheMagician
That's great GPNMilano. I'm looking forward to it :)

When we've collected all these points about GUIs I'll try and put them into comprehensive video tutorials. However, with Python scripting this is not going to be an easy task because I don't have as much experience.

I'm still trying to get sliders to work in 3D Max. Looking at the Ercana oven GUIs this seems to be done using the GUI knob control component. Unfortunately, as soon as I assign this component to a GUI element Drizzle (v29) doesn't convert the age anymore giving an error message (Moul isn't listed as having type: 0xb1).