# RSInterface Controls This page is about controls on game interfaces. These can be buttons, scrollbars, dropdowns, checkboxes, etc. - - - ## TButton type The game has several types of buttons, {ref}`TButton` can be used for several of them but it's made specifically for buttons that have an "enabled" and "disabled" state: ```{figure} ../../images/Tbuttons.png ``` You can also use them very effectively for this type of buttons that are "linked" together: ```{figure} ../../images/linked_Tbuttons.png ``` With "linked", it means that enabling one, disabled the linked one(s). You can also use them for other types of buttons and imagination is the limit but in a lot of cases you won't be able to make use of the {ref}`TButton` methods. - - - ### TButton.Click ```pascal procedure TButton.Click(button: EMouseButton = EMouseButton.LEFT); ``` Clicks a {ref]`TButton` with the specified mouse `button` which by default is the left one. Example: ```pascal Button.Click(); ``` - - - ### TButton.Enabled ```pascal property TButton.Enabled: Boolean; property TButton.Enabled(value: Boolean); ``` Property to get/set a {ref}`TButton` `Enabled` state. Example: ```pascal WriteLn Button.Enabled; Button.Enabled := True; //or Button.Enabled[True]; WriteLn Button.Enabled; ``` - - - ### TButton.WaitEnabled ```pascal function TButton.WaitEnabled(time: Integer = TICK; interval: Integer = -1): Boolean; ``` Returns True if the button is enabled within `time` milliseconds. Example: ```pascal WriteLn Button.WaitEnabled(); ``` - - - ## TSlider type A record meant to handle sliders in the game interfaces: ```{figure} ../../images/sliders.png ``` - - - ### TSlider.GetLevel ```pascal function TSlider.GetLevel(): Integer; ``` Returns the slider level from 0 to 100. It's important to keep in mind that while we use a scale from 0 to 100, don't have that many "levels". For example, the brightness slider only have 5 or 6 possible positions. Example: ```pascal WriteLn slider.GetLevel(); ``` - - - ### TSlider.SetLevel ```pascal function TSlider.SetLevel(level: Integer): Boolean; ``` Attempts to set the slider to the specified `level`. Example: ```pascal WriteLn slider.SetLevel(60); ``` - - - (TScrollBar)= ## TScrollBar type Record to handle the game interface's scrollbars: ```{figure} ../../images/scrollbar.png ``` - - - ### TScrollBar.Setup ```pascal procedure TScrollBar.Setup(rightSide: Boolean = True); ``` Method used to setup several {ref}`TScrollBar` internal variables. When creating a {ref}`TScrollBar` you should first setup it's `Area` variable and then call this. Example: ```pascal scroll.Area.X1 := Bank.Bounds.X1 + 5; scroll.Area.Y1 := Bank.Bounds.Y1 + 78; scroll.Area.X2 := Bank.Bounds.X2 - 22; scroll.Area.Y2 := Bank.Bounds.Y2 - 44; scroll.Setup(); ``` - - - ### TScrollBar.IsVisible ```pascal function TScrollBar.IsVisible(): Boolean; ``` Returns True/False if the scrollbar is visible. Example: ```pascal WriteLn Bank.Scroll.IsVisible(); ``` - - - ### TScrollBar.Slider ```pascal property TScrollBar.Slider: TBox; ``` Returns a `TBox` of the scrollbar slider. Example: ```pascal ShowOnTarget(Bank.Scroll.Slider); ``` ```{figure} ../../images/scrollbar_slider.png ``` - - - ### TScrollBar.CanScroll ```pascal function TScrollBar.CanScroll(): Boolean; ``` Returns True/False if the scrollbar is "scrollable". A scrollbar is not scrollable if it's not visible or if the slider occupies the whole space available. Example: ```pascal WriteLn Chat.Scroll.CanScroll(); ``` - - - ### TScrollBar.GetLevel ```pascal function TScrollBar.GetLevel(): Integer; ``` Returns the level of the scrollbar. This is a percentage between the available space and the slider size. Example: ```pascal WriteLn Chat.Scroll.GetLevel(); ``` - - - ### TScrollBar.ScrollArea ```pascal property TScrollBar.ScrollArea: TBox; ``` Returns a area where you can scroll the mouse, using {ref}`TBiometrics` between `TScrollBar.Area` and `TScrollBar.Bounds`. Example: ```pascal ShowOnTarget(Chat.Scroll.ScrollArea); ``` - - - ### TScrollBar.SetLevel ```pascal function TScrollBar.SetLevel(value: Integer): Integer; ``` Attempts to set a scroll level on a scrollbar. Example: ```pascal WriteLn Chat.Scroll.SetLevel(50); ``` - - - ### TScrollBar.Scroll ```pascal function TScrollBar.Scroll(amount: Integer; down: Boolean): Boolean; ``` Scroll `amount` amount of times in a direction decided by `down`. Example: ```pascal WriteLn Chat.Scroll.Scroll(3, True); ``` - - - (TDropDownOption)= ## TDropDownOption type Helper record to handle {ref}`TDropDown` options. - - - (TDropDown)= ## TDropDown type Record to handle drop downs in the game interfaces: ```{figure} ../../images/dropdowns.png ``` - - - ### TDropDown.Setup ```pascal procedure TDropDown.Setup( options: TStringArray; constref font: TPixelFont; colors: TColorArray = [$1F98FF, $3FB8FF] ); ``` Sets up a {ref}`TDropDown` internal variables. This has to be used after the `TDropDown.Bounds` variable is already set. Example: ```pascal DropDown.Setup( [ 'Fixed - Classic layout', 'Resizable - Classic layout', 'Resizable - Modern layout' ] ); ``` - - - ### TDropDown.IsVisible ```pascal function TDropDown.IsVisible(): Boolean; ``` Returns true if a {ref}`TDropDown` is visible. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].IsVisible(); ``` - - - ### TDropDown.IsOpen ```pascal function TDropDown.IsOpen(): Boolean; ``` Returns true if a {ref}`TDropDown` is open. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].IsOpen(); ``` - - - ### TDropDown.WaitOpen ```pascal function TDropDown.WaitOpen(time: Integer = TICK; interval: Integer = -1): Boolean; ``` Returns true if {ref}`TDropDown.IsOpen` returns true within `time` milliseconds. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].WaitOpen(); ``` - - - ### TDropDown.Open ```pascal function TDropDown.Open(): Boolean; ``` Attempts to open a {ref}`TDropDown`. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].Open(); ``` - - - ### TDropDown.Close ```pascal function TDropDown.Close(): Boolean; ``` Attempts to close a {ref}`TDropDown`. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].Close(); ``` - - - ### TDropDown.GetSelected ```pascal function TDropDown.GetSelected(): Integer; ``` Returns the index of the currently selected option on a {ref}`TDropDown`. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].GetSelected(); ``` - - - ### TDropDown.Select ```pascal function TDropDown.Select(index: Integer): Boolean; function TDropDown.Select(option: String): Boolean; overload; ``` Attempts to select an option on a {ref}`TDropDown`. You can either use an option index or substring of an option. If you use a substring, the first match will be used. Example: ```pascal WriteLn Options.DropDowns[EOptionsDropDown.CLIENT_MODE].Select('Fixed'); ```