NMizu commited on
Commit
c801d2e
·
verified ·
1 Parent(s): bf78aee

Create mimgui-basic-example.lua

Browse files
Files changed (1) hide show
  1. mimgui-basic-example.lua +59 -0
mimgui-basic-example.lua ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ script_name 'mimgui basic example'
2
+
3
+ local imgui = require 'mimgui'
4
+ local new = imgui.new
5
+ local vk = require 'vkeys'
6
+
7
+ local imgui_example = {
8
+ show = false,
9
+ show_demo_window = new.bool(),
10
+ show_another_window = new.bool(),
11
+ f = new.float(0.0),
12
+ counter = new.int(0),
13
+ clear_color = new.float[3](0.45, 0.55, 0.60)
14
+ }
15
+ imgui.OnFrame(function() return imgui_example.show end,
16
+ function()
17
+ -- 1. Покажите большое демонстрационное окно (Большая часть кода примера находится в imgui.ShowDemoWindow()! Вы можете просмотреть его код, чтобы узнать больше о Dear ImGui!)
18
+ if imgui_example.show_demo_window[0] then
19
+ imgui.ShowDemoWindow(imgui_example.show_demo_window)
20
+ end
21
+
22
+ -- 2. Покажите простое окно, которое мы создаем сами. Мы используем пару Begin/End для создания именованного окна.
23
+ imgui.Begin("Hello, world!") -- Create a window called "Hello, world!" and append into it.
24
+
25
+ imgui.Text("This is some useful text.") -- Выведите на экран текст (можно также использовать строки форматирования)
26
+ imgui.Checkbox("Demo Window", imgui_example.show_demo_window) -- Редактируйте переменные, хранящие состояние открытия/закрытия нашего окна
27
+ imgui.Checkbox("Another Window", imgui_example.show_another_window)
28
+
29
+ imgui.SliderFloat("float", imgui_example.f, 0.0, 1.0) -- Редактирование 1 поплавка с помощью ползунка от 0,0 до 1,0
30
+ imgui.ColorEdit3("clear color", imgui_example.clear_color) -- Редактирование 3 плавающих точек, представляющих цвет
31
+
32
+ if imgui.Button("Button") then -- Кнопки возвращают true при нажатии (большинство виджетов возвращают true при редактировании/активации)
33
+ imgui_example.counter[0] = imgui_example.counter[0] + 1
34
+ end
35
+ imgui.SameLine()
36
+ imgui.Text("counter = %g", imgui_example.counter[0])
37
+
38
+ imgui.Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / imgui.GetIO().Framerate, imgui.GetIO().Framerate)
39
+ imgui.End()
40
+
41
+ -- 3. Show another simple window.
42
+ if imgui_example.show_another_window[0] then
43
+ imgui.Begin("Another Window", imgui_example.show_another_window) -- Передайте указатель на нашу переменную bool (в окне будет кнопка закрытия, при нажатии на которую bool будет очищаться).
44
+ imgui.Text("Hello from another window!")
45
+ if imgui.Button("Close Me") then
46
+ imgui_example.show_another_window[0] = false
47
+ end
48
+ imgui.End()
49
+ end
50
+ end)
51
+
52
+ function main()
53
+ while true do
54
+ wait(20)
55
+ if wasKeyPressed(vk.VK_1) then
56
+ imgui_example.show = not imgui_example.show
57
+ end
58
+ end
59
+ end