Ceci est une ancienne révision du document !
Cette section liste les fonctions et propriétés communes à tous les types de contrôles GUI.
Chaque type de contrôle (Button, ListBox, etc.) possède également sa section spécifique.
(Anciennement GetGUIObjectAt, désormais obsolète)
static GUIControl* GUIControl.GetAtScreenXY(int x, int y)
Checks whether there is a GUI control at screen co-ordinates (X,Y). Returns
the control object if there is, or null if there is not. You probably
want to use this in conjunction with GetGUIAtLocation.
Exemple :
GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y); if (theControl == lstSaveGames) { Display("The mouse is over the Save Games list box."); } else if (theControl == null) { Display("The mouse is not over a control."); } else { GUI *onGui = theControl.OwningGUI; Display("The mouse is over control %d on GUI %d.", theControl.ID, onGui.ID); }
will display what control the mouse is over.
Voir aussi : GUI.GetAtScreenXY
Button* GUIControl.AsButton; InvWindow* GUIControl.AsInvWindow; Label* GUIControl.AsLabel; ListBox* GUIControl.AsListBox; Slider* GUIControl.AsSlider; TextBox* GUIControl.AsTextBox;Converts a generic GUIControl* pointer into a variable of the correct type, and returns it. If the control is not of the requested type, returns null .
Button *theButton = gIconbar.Controls[2].AsButton; if (theButton == null) { Display("Control 2 is not a button!!!!"); } else { theButton.NormalGraphic = 44; }
attempts to set Button 2 on GUI ICONBAR to have NormalGraphic 44, but if that
control is not a button, prints a message.
Voir aussi : GUI.Controls
GUIControl.BringToFront()Brings this control to the front of the Z-order. This allows you to rearrange the display order of controls within the GUI.
btnBigButton.BringToFront();
will move the btnBigButton button to be in front of all other controls on the GUI.
Voir aussi : GUIControl.SendToBack
bool GUIControl.ClickableGets/sets whether the GUI control is clickable.
btnSaveGame.Clickable = false;
will make the btnSaveGame button non-clickable.
Voir aussi : GUIControl.Enabled
(Anciennement SetGUIObjectEnabled, désormais obsolète)
bool GUIControl.Enabled
Enables or disables a GUI control.
Normally, all your GUI controls (such as buttons, sliders, etc) are enabled at all times
except during a cutscene, when they are disabled. This command allows you to explicitly
disable a control at your script's discretion.
If you set this to true, the control will be enabled; set to false to disable it.
Whether you set it as enabled or not, it will always be disabled during a blocking
cutscene, along with all the other controls.
While a control is disabled, it will not respond to mouse clicks. If it is a button, its
mouseover and pushed pictures will not be shown. The control will be drawn according to
the game “When GUI Disabled” settings, as usual.
S'applique à
Hérité par Button, InvWindow, Label, ListBox, Slider and TextBox.
Exemple :
btnSaveGame.Enabled = false;
will disable the btnSaveGame button.
Voir aussi : GUIControl.Clickable,
GUIControl.Visible
int GUIControl.Height;Gets/sets the height of the GUI control. This allows you to dynamically resize GUI controls while the game is running.
btnConfirm.Height = 20;
makes the btnConfirm button 20 pixels high.
Voir aussi : GUIControl.SetSize,
GUIControl.Width
readonly int GUIControl.IDGets the GUI control's ID number. This is the control's object number from the GUI editor, and is useful if you need to interoperate with legacy code that uses the control's number rather than object name.
SetGUIObjectEnabled(lstSaves.OwningGUI.ID, lstSaves.ID, 1); lstSaves.Enabled = false;
uses the obsolete SetGUIObjectEnabled function to enable the lstSaves list box,
and then uses the equivalent modern property to disable it.
Voir aussi : GUIControl.OwningGUI, GUI.ID
readonly GUI* GUIControl.OwningGUIGets the GUI control's owning GUI, which is the GUI that contains the control.
GUI *thegui = lstSaves.OwningGUI; thegui.Visible = false; lstSaves.OwningGUI.Visible = true;
turns off the GUI that contains the lstSaves list box, then turns it on again using
the niftier full pathing approach.
Voir aussi : GUIControl.ID, GUI.ID
GUIControl.SendToBack()Sends this control to the back of the Z-order. This allows you to rearrange the display order of controls within the GUI.
btnBigButton.SendToBack();
will move the btnBigButton button to be behind all other controls on the GUI.
Voir aussi : GUIControl.BringToFront
(Anciennement SetGUIObjectPosition, désormais obsolète)
GUIControl.SetPosition(int x, int y)
Moves the top-left corner of the GUI control to be at (X,Y). These co-ordinates
are relative to the GUI which contains the control.
This allows you to dynamically move GUI controls around on the screen while the
game is running, and this may well be useful in conjunction with GUI.SetSize if you
want to create dynamically resizable GUIs.
S'applique à
Hérité par Button, InvWindow, Label, ListBox, Slider and TextBox.
Exemple :
btnConfirm.SetPosition(40, 10);
will move the btnConfirm button to be positioned at (40,10) within the GUI.
Voir aussi : GUIControl.Enabled,
GUI.SetPosition, GUIControl.SetSize,
GUIControl.X, GUIControl.Y
(Anciennement SetGUIObjectSize, désormais obsolète)
GUIControl.SetSize(int width, int height)
Adjusts the specified GUI control to have the new size WIDTH x HEIGHT.
This allows you to dynamically resize GUI controls on the screen while the
game is running, and this may well be useful in conjunction with GUI.SetSize and
GUIControl.SetPosition if you want to create dynamically resizable GUIs.
S'applique à
Hérité par Button, InvWindow, Label, ListBox, Slider and TextBox.
Exemple :
invMain.SetSize(160, 100);
will resize the invMain control to have a size of 160 x 100.
Voir aussi : GUIControl.Height,
GUIControl.SetPosition,
GUI.SetSize,
GUIControl.Width,
bool GUIControl.VisibleGets/sets whether the GUI control is visible. This is true by default, but you can set it to false in order to temporarily remove the GUI control from the GUI.
btnSaveGame.Visible = false;
will make the btnSaveGame button invisible.
Voir aussi : GUIControl.Enabled
int GUIControl.Width;Gets/sets the width of the GUI control. This allows you to dynamically resize GUI controls while the game is running.
btnConfirm.Width = 110;
makes the btnConfirm button 110 pixels wide.
Voir aussi : GUIControl.Height,
GUIControl.SetSize
int GUIControl.X;Gets/sets the X position of the GUI control. This specifies its left edge, and is relative to the GUI which contains the control.
btnConfirm.X = 10;
will move the btnConfirm button to be positioned 10 pixels from the left of its GUI.
Voir aussi : GUIControl.SetPosition,
GUIControl.Y
int GUIControl.Y;Gets/sets the Y position of the GUI control. This specifies its top edge, and is relative to the GUI which contains the control.
btnConfirm.Y = 20;
will move the btnConfirm button to be positioned 20 pixels from the top of its GUI.
Voir aussi : GUIControl.SetPosition,
GUIControl.X