Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@
"off": "Off"
},
"enabledonly": "Enabled only",
"errorsonly": "Errors only",
"byorder": "By load order",
"total": "total",
"defaulton": "default enabled",
Expand All @@ -766,6 +767,7 @@
"localdesc": "The widgets in your own LuaUI folder rather than the ones the game ships. They carry a local tag on the row too.",
"localonlydesc": "Show only the widgets in your own LuaUI folder, leaving out the ones the game ships.",
"enabledonlydesc": "Show only the widgets the config says to load - running or not - so what is off stays out of the way.",
"errorsonlydesc": "Show only the widgets that have raised an error this session - the ones tagged error - whether an error stopped them or they are running again.",
"byorderdesc": "Order the list the way the widgets load, which is the order their call-ins run in. Anything not running has no place in that order and follows at the end.",
"profilerdesc": "Show what each widget costs: processor time as a share of the frame, and memory allocated per second. Measuring it means timing every call-in of every widget, so this is only paid for while it is switched on.",
"byloaddesc": "Order the list by what each widget costs, heaviest first. The order stands still while the cursor is over the list, so nothing slides out from under a click, and catches up when the cursor leaves.",
Expand All @@ -774,6 +776,18 @@
"order": "Load order",
"cleardata": "Reset",
"showdata": "Show data",
"showdatadesc": "Everything this widget has saved, the way it is stored. Click to read all of it.",
"errorsloading": "while loading",
"errorsmore": "more",
"depsuses": "Uses",
"depsusedby": "Used by",
"depsoff": "off",
"depsrunningone": "running widget",
"depsrunning": "running widgets",
"depsunchecked": "never check it is there",
"depswarn": "%{count} running widgets use what %{name} provides without checking it is there, so switching it off will most likely break them:",
"depswarnone": "A running widget uses what %{name} provides without checking it is there, so switching it off will most likely break it:",
"depscause": "%{key} comes from %{provider}, which is off",
"close": "Close",
"cleardatatitle": "Clear saved settings",
"cleardatawarn": "Throws away everything %{name} has saved - its options, its window position, whatever it remembers - and it starts again from its defaults. Nothing else in the list is touched.",
Expand Down
8 changes: 8 additions & 0 deletions luaui/Include/keybind_dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
self.onSelect = opts.onSelect
self.selected = opts.selected or 1
self.placeholder = opts.placeholder
-- An outline to draw the text with, for a panel that pins its own. The font is shared with
-- every other widget and keeps whatever outline was set on it last; without one this takes
-- that, as it always has.
self.outline = opts.outline
self.open = false
self.rect = { 0, 0, 0, 0 }
self.optRects = {}
Expand Down Expand Up @@ -151,6 +155,9 @@
end

font:Begin()
if self.outline then

Check warning on line 158 in luaui/Include/keybind_dropdown.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `outline`.
font:SetOutlineColor(self.outline)

Check warning on line 159 in luaui/Include/keybind_dropdown.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `outline`.
end
local current = self.options[self.selected]
local label = self.placeholder or (current and optionLabel(current) or "")
-- A profile name is free text and can outrun the control, which is fixed width so the
Expand Down Expand Up @@ -180,6 +187,7 @@
end
end

-- Still the caption's outline: it was set on this same font a moment ago, in this draw.
font:Begin()
for i, opt in ipairs(self.options) do
local r = self.optRects[i]
Expand Down
64 changes: 64 additions & 0 deletions luaui/Include/keybind_editbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
self.placeholder = opts.placeholder or ""
self.maxChars = opts.maxChars or 127
self.onChange = opts.onChange
-- An outline to draw the text with, for a panel that pins its own. The font is shared with
-- every other widget and keeps whatever outline was set on it last; without one this takes
-- that, as it always has.
self.outline = opts.outline
-- A faint button at the right end that empties the field, shown while there is text. Asked
-- for rather than given: a field whose text is not a filter has nothing it should clear.
self.clearable = opts.clearable
self.rect = { 0, 0, 0, 0 }
self.fontSize = 14
self.pad = 6
Expand Down Expand Up @@ -266,12 +273,38 @@
return true
end

-- The clear button: a square the height of the field against its right end, inset like the
-- caret and the selection are.
local function clearRect(self)
local x2, y1, y2 = self.rect[3], self.rect[2], self.rect[4]
local inset = floor((y2 - y1) * 0.18)

return x2 - (y2 - y1) + inset, y1 + inset, x2 - inset, y2 - inset
end

local function overClear(self, x, y)
if not self.clearable or self.text == "" then
return false
end
local bx1, by1, bx2, by2 = clearRect(self)

return x >= bx1 and x <= bx2 and y >= by1 and y <= by2
end

-- Click to place the caret, or start a drag selection.
function Editbox:mousePress(x, y)
if x < self.rect[1] or x > self.rect[3] or y < self.rect[2] or y > self.rect[4] then
return false
end

-- Focus stays, so the next thing typed starts a new search.
if overClear(self, x, y) then
self:focus()
self:setText("")

return true
end

local _, _, _, shift = Spring.GetModKeyState()
local idx = self:indexFromX(x)

Expand Down Expand Up @@ -326,6 +359,30 @@

-- Held rather than built per draw: a colour table a frame is an allocation a frame.
local fieldFill = { 0, 0, 0, 0.35 }
local clearFill = { 1, 1, 1, 0.04 }

-- A thin cross, drawn as geometry rather than a glyph so it does not depend on the font
-- carrying one. The second bar is two halves either side of the first, so the middle is not
-- painted twice and does not show as a brighter dot.
local function drawClear(self, hot, cs)
local bx1, by1, bx2, by2 = clearRect(self)
WG.FlowUI.Draw.RectRound(bx1, by1, bx2, by2, cs, 1, 1, 1, 1, clearFill)
if hot then
WG.FlowUI.Draw.SelectHighlight(bx1, by1, bx2, by2, cs, hoverOpacity, white)
end

local arm = math.max(2, floor((bx2 - bx1) * 0.24))
local half = math.max(1, floor((bx2 - bx1) * 0.035 + 0.5))
gl.Color(1, 1, 1, hot and 0.75 or 0.32)
gl.PushMatrix()
gl.Translate(floor((bx1 + bx2) * 0.5), floor((by1 + by2) * 0.5), 0)
gl.Rotate(45, 0, 0, 1)
gl.Rect(-arm, -half, arm, half)
gl.Rect(-half, half, half, arm)
gl.Rect(-half, -arm, half, -half)
gl.PopMatrix()
gl.Color(1, 1, 1, 1)
end

function Editbox:draw()
update(self)
Expand Down Expand Up @@ -377,9 +434,16 @@
end

font:Begin()
if self.outline then

Check warning on line 437 in luaui/Include/keybind_editbox.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `outline`.
font:SetOutlineColor(self.outline)

Check warning on line 438 in luaui/Include/keybind_editbox.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `outline`.
end
font:Print(shown, tx, ty, self.fontSize, "o")
font:End()

if self.clearable and self.text ~= "" then

Check warning on line 443 in luaui/Include/keybind_editbox.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

undefined-field

Undefined field `clearable`.
drawClear(self, overClear(self, mx, my), cs)
end

if self.focused then
-- Sharp bar rather than a rounded one, sized and placed off the font like chat's:
-- a fixed span around the text's middle, so it does not stretch with the field.
Expand Down
6 changes: 5 additions & 1 deletion luaui/Include/keybind_editor_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,11 @@ local function ensureControls()
return
end

searchBox = Editbox.new({ placeholder = BAR.I18N("ui.keybinds.editor.search"), onChange = rebuildRows })
searchBox = Editbox.new({
placeholder = BAR.I18N("ui.keybinds.editor.search"),
clearable = true,
onChange = rebuildRows,
})
presetDropdown = Dropdown.new({ options = presetOptions, onSelect = switchToPreset })
nameBox = Editbox.new({ maxChars = 40 })
end
Expand Down
18 changes: 18 additions & 0 deletions luaui/Include/keybind_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,22 @@
return lines
end

-- Starts each line of wrapped text in the colour the line before it ended in. A tooltip prints its
-- text a line at a time, each line from the tooltip's own colour, so a colour set partway along one
-- line would otherwise stop where the line does - and wrapping ends lines wherever it has to.
function M.carryColors(str)
local out, current = {}, nil
for line in (str .. "\n"):gmatch("([^\n]*)\n") do
if current and line ~= "" and line:byte(1) ~= 255 then

Check warning on line 104 in luaui/Include/keybind_text.lua

View workflow job for this annotation

GitHub Actions / emmylua_check

unnecessary-if

Impossible `if` statement: this condition is always falsy
line = current .. line
end
for code in line:gmatch("\255...") do
current = code
end
out[#out + 1] = line
end

return table.concat(out, "\n")
end

return M
Loading
Loading