mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Updated GUI (markdown)
parent
4a414385aa
commit
b1a7921a71
60
GUI.md
60
GUI.md
@ -1,50 +1,52 @@
|
|||||||
To be done, here's a quick LUA script with GUI stuff though:
|
To be done, here's a quick LUA script with GUI stuff though, it'll add an 'options' button to the profile editor and show a window when that button is clicked.
|
||||||
|
|
||||||
Note that the window opens whenever the script is loaded, this is a bit annoying since scripts are reloaded whenever you un-focus the profile editor. Will add a way to add buttons to the profile editor so users can open windows when they want.
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
-------------------------------- Artemis LUA file --------------------------------
|
-------------------------------- Artemis LUA file --------------------------------
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
function openWindow()
|
||||||
|
local window = Gui.CreateWindow("Test", 1270, 720);
|
||||||
|
|
||||||
local window = Gui.CreateWindow("Test", 1270, 720);
|
-- Textbox
|
||||||
|
local textBox = window.CreateTextBox("", 5, 5, 200, 25);
|
||||||
|
local textBoxLabel = window.CreateLabel("Type something in the textbox", 210, 5);
|
||||||
|
|
||||||
-- Textbox
|
function textChangedHandler(textBox)
|
||||||
local textBox = window.CreateTextBox("", 5, 5, 200, 25);
|
|
||||||
local textBoxLabel = window.CreateLabel("Type something in the textbox", 210, 5);
|
|
||||||
|
|
||||||
function textChangedHandler(textBox)
|
|
||||||
textBoxLabel.Text = "You typed: " .. textBox.Text;
|
textBoxLabel.Text = "You typed: " .. textBox.Text;
|
||||||
end
|
end
|
||||||
textBox.TextChanged.add(textChangedHandler);
|
textBox.TextChanged.add(textChangedHandler);
|
||||||
|
|
||||||
-- Button
|
-- Button
|
||||||
local button = window.CreateButton("Press me :D", 5, 45, 200, 25);
|
local button = window.CreateButton("Press me :D", 5, 45, 200, 25);
|
||||||
local buttonLabel = window.CreateLabel("Press the button", 210, 43);
|
local buttonLabel = window.CreateLabel("Press the button", 210, 43);
|
||||||
local pressCount = 1;
|
local pressCount = 1;
|
||||||
function buttonClickHandler(button)
|
function buttonClickHandler(button)
|
||||||
buttonLabel.Text = "You pressed " .. pressCount .. " time(s)";
|
buttonLabel.Text = "You pressed " .. pressCount .. " time(s)";
|
||||||
pressCount = pressCount + 1;
|
pressCount = pressCount + 1;
|
||||||
end
|
end
|
||||||
button.Click.add(buttonClickHandler);
|
button.Click.add(buttonClickHandler);
|
||||||
|
|
||||||
-- ComboBox
|
-- ComboBox
|
||||||
local comboBox = window.CreateComboBox("Value 2", {"Value 1", "Value 2", "Value 3"}, 5, 85, 200, 25);
|
local comboBox = window.CreateComboBox("Value 2", {"Value 1", "Value 2", "Value 3"}, 5, 85, 200, 25);
|
||||||
local comboBoxLabel = window.CreateLabel("Select a value", 210, 83);
|
local comboBoxLabel = window.CreateLabel("Select a value", 210, 83);
|
||||||
function selectionChangedHandler(comboBox)
|
function selectionChangedHandler(comboBox)
|
||||||
comboBoxLabel.Text = "You selected: " .. comboBox.Value;
|
comboBoxLabel.Text = "You selected: " .. comboBox.Value;
|
||||||
end
|
end
|
||||||
comboBox.SelectionChanged.add(selectionChangedHandler);
|
comboBox.SelectionChanged.add(selectionChangedHandler);
|
||||||
|
|
||||||
-- CheckBox
|
-- CheckBox
|
||||||
local checkBox = window.CreateCheckBox("Checkbox label", true, 5, 125)
|
local checkBox = window.CreateCheckBox("Checkbox label", true, 5, 125)
|
||||||
local checkBoxLabel = window.CreateLabel("Uncheck the checkbox", 210, 120);
|
local checkBoxLabel = window.CreateLabel("Uncheck the checkbox", 210, 120);
|
||||||
function checkBoxClickHandler(checkBox)
|
function checkBoxClickHandler(checkBox)
|
||||||
if checkBox.IsChecked then
|
if checkBox.IsChecked then
|
||||||
checkBoxLabel.Text = "Checkbox is checked";
|
checkBoxLabel.Text = "Checkbox is checked";
|
||||||
else
|
else
|
||||||
checkBoxLabel.Text = "Checkbox is not checked";
|
checkBoxLabel.Text = "Checkbox is not checked";
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
checkBox.Click.add(checkBoxClickHandler);
|
||||||
end
|
end
|
||||||
checkBox.Click.add(checkBoxClickHandler);
|
|
||||||
|
Gui.AddEditorButton("Options", openWindow);
|
||||||
```
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user