Skip to content

Commit 2623209

Browse files
fixed redme
1 parent 6d7fcab commit 2623209

2 files changed

Lines changed: 74 additions & 135 deletions

File tree

README.md

Lines changed: 58 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ Terminator's Immediate-Mode Menu for Lmaobox
1212

1313
A GUI library for Lmaobox scripts, offering a convenient immediate-mode style API built on a retained-mode foundation. It's designed for light usage and rapid construction of in-game menus.
1414

15-
![image](https://github.com/user-attachments/assets/bf428a3c-02c8-465b-b1ce-3a8f1246f50f)
16-
17-
https://github.com/user-attachments/assets/7498dcd1-8b20-4347-bf32-6c1419b679c2
15+
[https://github.com/user-attachments/assets/7498dcd1-8b20-4347-bf32-6c1419b679c2](https://github.com/user-attachments/assets/7498dcd1-8b20-4347-bf32-6c1419b679c2)
1816

1917
## Installation
2018

@@ -23,179 +21,107 @@ To install, download the latest release using the badge at the top of this page,
2321
1. Unzip or extract the downloaded package.
2422
2. Copy `TimMenu.lua` into your Lmaobox scripts folder (e.g., `%localappdata%\Scripts`).
2523

26-
## Usage
27-
28-
Building a menu with TimMenu is like writing a document: widgets are added from left to right, and `TimMenu.NextLine()` moves the cursor to the beginning of the next line, ready for more widgets.
29-
30-
```lua
31-
local TimMenu = require("TimMenu")
32-
33-
local isChecked = false
34-
local sliderValue = 50
24+
## Standalone API Guide
3525

36-
local function OnDraw()
37-
if TimMenu.Begin("Example Window") then
38-
TimMenu.Text("Hello, Lmaobox!")
26+
TimMenu is now a **fully standalone** library. It does not require LNXlib or other external dependencies.
3927

40-
isChecked = TimMenu.Checkbox("Enable Feature", isChecked)
41-
TimMenu.NextLine()
28+
### Core Concepts
4229

43-
if TimMenu.Button("Click Me") then
44-
print("Button clicked!")
45-
end
46-
TimMenu.NextLine()
30+
- **Immediate Mode**: You define the UI every frame. If you stop calling a widget function, it disappears.
31+
- **Layout**: Widgets are placed left-to-right. Use `NextLine()` to move down.
32+
- **Volume Claim**: The menu handles "Hit Testing" by treating the window and its popups as a single volume. If a dropdown sticks out, it still belongs to that window, preventing clicks from falling through to background elements.
4733

48-
sliderValue = TimMenu.Slider("Value", sliderValue, 0, 100, 1)
49-
print("Current slider value:", sliderValue)
50-
51-
end
52-
end
53-
54-
callbacks.Register("Draw", "ExampleDraw", OnDraw)
55-
```
34+
---
5635

5736
## API Reference
5837

5938
### Window Management
6039

61-
- Begin: `bool = TimMenu.Begin(title, [visible, [id]])`
40+
- **Begin**: `bool = TimMenu.Begin(title, [visible, [id]])`
41+
- Starts a new window context. Returns true if the window is expanded.
6242

63-
### Layout
43+
### Layout Controls
6444

65-
- NextLine: `TimMenu.NextLine([spacing])`
66-
- Spacing: `TimMenu.Spacing(amount)`
67-
- Separator: `TimMenu.Separator([label])`
68-
- BeginSector: `TimMenu.BeginSector(label)`
69-
- EndSector: `TimMenu.EndSector()`
45+
| Function | Usage | Description |
46+
| ------------------------- | ------------------------------- | ----------------------------------------------- |
47+
| **`NextLine([spacing])`** | `TimMenu.NextLine(5)` | Moves the cursor to the next row. |
48+
| **`Spacing(amount)`** | `TimMenu.Spacing(10)` | Adds horizontal or vertical blank space. |
49+
| **`Separator([label])`** | `TimMenu.Separator("Settings")` | Draws a horizontal line with an optional label. |
50+
| **`BeginSector(label)`** | `TimMenu.BeginSector("Main")` | Starts a bordered group/panel. |
51+
| **`EndSector()`** | `TimMenu.EndSector()` | Closes the current group/panel. |
7052

7153
### Basic Widgets
7254

73-
**All widgets now use simplified single-return APIs:**
74-
75-
- Text: `TimMenu.Text(text)`
76-
- Button: `clicked = TimMenu.Button(label)`
77-
- Checkbox: `checked = TimMenu.Checkbox(label, checked)`
78-
- TextInput: `text = TimMenu.TextInput(label, text)`
79-
- Slider: `value = TimMenu.Slider(label, value, min, max, step)`
80-
- Selector: `selectedIndex = TimMenu.Selector(label, selectedIndex, options)`
81-
- Dropdown: `selectedIndex = TimMenu.Dropdown(label, selectedIndex, options)`
82-
- Combo: `selectedItems = TimMenu.Combo(label, selectedItems, options)`
83-
- TabControl: `selectedTab = TimMenu.TabControl(id, tabs, selectedTab)`
84-
- Keybind: `keyCode = TimMenu.Keybind(label, keyCode)`
85-
- ColorPicker: `color = TimMenu.ColorPicker(label, color)`
55+
**All widgets use simplified single-return APIs:**
8656

87-
### Advanced Widgets
88-
89-
- Image: `hovered, pressed, clicked = TimMenu.Image(texture, width, height, [raw_data])`
90-
- Tooltip: `TimMenu.Tooltip(text)` - Shows tooltip for the last widget
57+
- **Text**: `TimMenu.Text(text)`
58+
- **Button**: `clicked = TimMenu.Button(label)`
59+
- **Checkbox**: `checked = TimMenu.Checkbox(label, checked)`
60+
- **TextInput**: `text = TimMenu.TextInput(label, text)`
61+
- **Slider**: `value = TimMenu.Slider(label, value, min, max, step)`
62+
- **Selector**: `selectedIndex = TimMenu.Selector(label, index, options)`
63+
- **Dropdown**: `selectedIndex = TimMenu.Dropdown(label, index, options)`
64+
- **Combo**: `selectedItems = TimMenu.Combo(label, selectedTable, options)`
65+
- **TabControl**: `selectedTab = TimMenu.TabControl(id, tabs, selectedTab)`
66+
- **Keybind**: `keyCode = TimMenu.Keybind(label, keyCode)`
67+
- **ColorPicker**: `color = TimMenu.ColorPicker(label, color)`
9168

9269
### Customization
9370

94-
All colors and styles can be tweaked via the `Globals` module:
95-
9671
```lua
72+
-- Global style tweaks via the Globals module
9773
TimMenu.Globals.Colors.Window = {40, 40, 40, 255}
9874
TimMenu.Globals.Style.ItemPadding = 8
75+
9976
```
10077

101-
## Widget Usage Examples
78+
---
79+
80+
## Usage Examples
10281

103-
### Simple State Management
82+
### Simple Window Logic
10483

10584
```lua
106-
-- Each widget modifies and returns its value directly
107-
local volume = 50
108-
local enabled = true
109-
local selectedOption = 1
110-
local options = {"Low", "Medium", "High"}
85+
local TimMenu = require("TimMenu")
86+
87+
local isChecked = false
88+
local sliderValue = 50
11189

11290
local function OnDraw()
113-
if TimMenu.Begin("Settings") then
114-
enabled = TimMenu.Checkbox("Enable Audio", enabled)
91+
if TimMenu.Begin("Example Window") then
92+
isChecked = TimMenu.Checkbox("Enable Feature", isChecked)
93+
TimMenu.NextLine()
11594

116-
if enabled then
117-
volume = TimMenu.Slider("Volume", volume, 0, 100, 5)
118-
selectedOption = TimMenu.Dropdown("Quality", selectedOption, options)
95+
if TimMenu.Button("Reset Value") then
96+
sliderValue = 50
11997
end
120-
end
121-
end
122-
```
123-
124-
### Color Picker Example
125-
126-
```lua
127-
local backgroundColor = {30, 30, 30, 255} -- RGBA
98+
TimMenu.NextLine()
12899

129-
local function OnDraw()
130-
if TimMenu.Begin("Color Settings") then
131-
backgroundColor = TimMenu.ColorPicker("Background Color", backgroundColor)
132-
TimMenu.Text(string.format("RGB: %d, %d, %d, %d",
133-
backgroundColor[1], backgroundColor[2], backgroundColor[3], backgroundColor[4]))
100+
sliderValue = TimMenu.Slider("Value", sliderValue, 0, 100, 1)
134101
end
135102
end
136-
```
137103

138-
### Multi-Selection with Combo
139-
140-
```lua
141-
local features = {"Feature A", "Feature B", "Feature C"}
142-
local enabledFeatures = {true, false, true} -- Which features are enabled
104+
callbacks.Register("Draw", "ExampleDraw", OnDraw)
143105

144-
local function OnDraw()
145-
if TimMenu.Begin("Feature Selection") then
146-
enabledFeatures = TimMenu.Combo("Enabled Features", enabledFeatures, features)
147-
148-
-- Show which features are enabled
149-
for i, feature in ipairs(features) do
150-
if enabledFeatures[i] then
151-
TimMenu.Text("" .. feature .. " is enabled")
152-
end
153-
end
154-
end
155-
end
156106
```
157107

158-
## Tips
159-
160-
- Use `BeginSector`/`EndSector` to group widgets in bordered panels.
161-
- Sectors can be easily stacked horizontally and vertically
162-
- All widgets return their current value - no need to track "changed" flags
163-
- Values are automatically maintained between frames by the widget system
164-
165-
## Sector Grouping
166-
167-
Use `TimMenu.BeginSector(label)` and `TimMenu.EndSector()` to enclose widgets in a shaded, bordered panel. Nested sectors will automatically lighten the background more as depth increases.
168-
169-
Example:
108+
### Grouping with Sectors
170109

171110
```lua
172-
if TimMenu.Begin("Example Window") then
173-
-- Start a grouped panel
174-
TimMenu.BeginSector("Settings")
175-
-- Place widgets inside the sector
176-
local volume = TimMenu.Slider("Volume", 50, 0, 100, 1)
111+
if TimMenu.Begin("Settings") then
112+
TimMenu.BeginSector("Audio")
113+
local vol = TimMenu.Slider("Volume", 50, 0, 100, 1)
177114
TimMenu.EndSector()
178115
end
179-
```
180-
181-
## Changelog
182-
183-
### Simplified Widget APIs (Latest)
184-
185-
- **BREAKING CHANGE**: All widgets now return single values instead of value + changed pairs
186-
- Simplified API: `value = Widget("Label", value)` instead of `value, changed = Widget("Label", value)`
187-
- Removed confusing "changed" flags - just use the returned values directly
188-
- Updated all example code to use the new simplified patterns
189-
- Much cleaner and more intuitive widget usage
190116

191-
### Fixed Keybind Widget Lag
192-
193-
- Keybind widget now recalculates its display label immediately after a key press and dynamically computes its draw position inside the rendering callback, eliminating frame delay when dragging windows.
117+
```
194118

195-
### Fixed TabControl Header Lag
119+
## Tips
196120

197-
- Header-mode tabs now calculate their offsets relative to the window's current position at draw time, preventing one-frame lag during window movement.
121+
- Sectors can be nested; backgrounds lighten automatically as depth increases.
122+
- All widgets return their current value - no need to track "changed" flags manually.
123+
- The volume hit-testing ensures that popups sticking out of windows correctly capture focus.
198124

199125
## License
200126

201-
MIT License. See [LICENSE](LICENSE) for details.
127+
MIT License. See [LICENSE](https://www.google.com/search?q=LICENSE) for details.

TimMenu/Interaction.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,22 @@ function Interaction.IsHovered(win, bounds)
2525
return false
2626
end
2727

28-
-- Block if covered by higher windows (using shape-aware testing)
29-
if Utils.IsPointBlocked(TimMenuGlobal.order, TimMenuGlobal.windows, mX, mY, win.id) then
30-
return false
28+
-- Use unified hit detection: check if any window above this one claims the point
29+
local currentWindowIndex = 0
30+
for i, key in ipairs(TimMenuGlobal.order) do
31+
if key == win.id then
32+
currentWindowIndex = i
33+
break
34+
end
35+
end
36+
37+
-- Check windows above this one (top-to-bottom)
38+
for i = #TimMenuGlobal.order, currentWindowIndex + 1, -1 do
39+
local key = TimMenuGlobal.order[i]
40+
local higherWin = TimMenuGlobal.windows[key]
41+
if higherWin and higherWin.visible and higherWin:_HitTest(mX, mY) then
42+
return false -- Blocked by higher window
43+
end
3144
end
3245

3346
-- Check if element is within blocked regions (popups)

0 commit comments

Comments
 (0)