NMizu commited on
Commit
b9e9600
·
verified ·
1 Parent(s): 02923cf

Create mimgui-overlay.lua

Browse files
Files changed (1) hide show
  1. mimgui-overlay.lua +56 -0
mimgui-overlay.lua ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ script_name 'mimgui overlay example'
2
+
3
+ local imgui = require 'mimgui'
4
+ local vk = require 'vkeys'
5
+ local new = imgui.new
6
+
7
+ -- overlay
8
+ local overlay = {
9
+ show = new.bool(true),
10
+ offset = new.int(10),
11
+ position = new.int(1)
12
+ }
13
+ imgui.OnFrame(function() return overlay.show[0] and not isGamePaused() end,
14
+ function()
15
+ local io = imgui.GetIO()
16
+ local pos = overlay.position[0]
17
+ if pos > 0 then
18
+ x = (pos == 1 or pos == 3) and overlay.offset[0] or io.DisplaySize.x - overlay.offset[0]
19
+ y = (pos == 1 or pos == 2) and overlay.offset[0] or io.DisplaySize.y - overlay.offset[0]
20
+ local window_pos_pivot = imgui.ImVec2((pos == 1 or pos == 3) and 0 or 1, (pos == 1 or pos == 2) and 0 or 1)
21
+ imgui.SetNextWindowPos(imgui.ImVec2(x, y), imgui.Cond.Always, window_pos_pivot)
22
+ end
23
+ local flags = imgui.WindowFlags.NoDecoration + imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoSavedSettings
24
+ if pos ~= 0 then
25
+ flags = flags + imgui.WindowFlags.NoMove + imgui.WindowFlags.NoInputs
26
+ end
27
+ imgui.Begin('overlay', nil, flags)
28
+ imgui.Text('Simple overlay\nin the corner of the screen.\nPress key 2 to open settings menu')
29
+ imgui.Separator()
30
+ if imgui.IsMousePosValid() then
31
+ imgui.Text('Mouse Position: (%.1f, %.1f)', io.MousePos.x, io.MousePos.y)
32
+ else
33
+ imgui.Text('Mouse Position: <invalid>')
34
+ end
35
+ imgui.End()
36
+ end).HideCursor = true
37
+
38
+ -- settings window
39
+ local show_settings_window = new.bool()
40
+ imgui.OnFrame(function() return show_settings_window[0] end,
41
+ function()
42
+ imgui.Begin('Overlay settings', show_settings_window)
43
+ imgui.Checkbox('Show', overlay.show)
44
+ imgui.DragInt('Offset', overlay.offset, 1, 0, 200)
45
+ imgui.ComboStr('Position', overlay.position, 'Free\0Up-Left\0Up-Right\0Down-Left\0Down-Right\0\0')
46
+ imgui.End()
47
+ end)
48
+
49
+ function main()
50
+ while true do
51
+ wait(20)
52
+ if wasKeyPressed(vk.VK_2) then
53
+ show_settings_window[0] = not show_settings_window[0]
54
+ end
55
+ end
56
+ end