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
2 changes: 2 additions & 0 deletions language/en/interface.json
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,8 @@
"catchupminfps_descr": " ",
"widgetselector": "Widget selector interface",
"widgetselector_descr": "Allow the toggling of the widget selector interface (via F11)",
"windows_hideinterface": "Windows hide the interface",
"windows_hideinterface_descr": "While a window such as Settings, Keys or Stats is open, hide the rest of the interface and block its input. The top bar menu buttons, chat, votes and the pause overlay stay.",
"devmode": "Developer UI",
"devmode_descr": "Toggle between how a developer or player see the UI",
"customwidgets": "Allow custom widgets",
Expand Down
75 changes: 60 additions & 15 deletions luaui/Widgets/gfx_guishader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function widget:GetInfo()
license = "GNU GPL, v2 or later",
layer = -990000, -- other widgets can be run earlier (lower layer) and thus guishader blur are will lag behind a frame, (like tooltip screenblur)
enabled = true,
modalExempt = true, -- the blur behind an open window is this widget's work
}
end

Expand Down Expand Up @@ -70,6 +71,16 @@ local guishaderScreenDlists = {}
local updateStencilTexture = false
local updateStencilTextureScreen = false

-- Which widget registered each region, when it said so (name -> widget). Used only while
-- a modal window hides the interface: a hidden widget's region would otherwise stay on
-- screen as a blurred patch of map. A region with no owner is treated as hidden then.
local rectOwners = {}
local dlistOwners = {}
local screenRectOwners = {}
local screenDlistOwners = {}
local lastModalActive = false
local lastModalRevision = -1

local oldvs = 0
local vsx, vsy, vpx, vpy = spGetViewGeometry()
local blurScale = 1
Expand Down Expand Up @@ -152,22 +163,30 @@ local function DrawStencilTexture(world, fullscreen)
glTranslate(-1, -1, 0)
glScale(2 / vsx, 2 / vsy, 0)
if world then
for _, rect in pairs(guishaderRects) do
glRect(rect[1], rect[2], rect[3], rect[4])
for name, rect in pairs(guishaderRects) do
if widgetHandler:ModalAllows(rectOwners[name]) then
glRect(rect[1], rect[2], rect[3], rect[4])
end
end
for _, dlist in pairs(guishaderDlists) do
glColor(1, 1, 1, 1)
glCallList(dlist)
for name, dlist in pairs(guishaderDlists) do
if widgetHandler:ModalAllows(dlistOwners[name]) then
glColor(1, 1, 1, 1)
glCallList(dlist)
end
end
elseif fullscreen then
glRect(0, 0, vsx, vsy)
else
for _, rect in pairs(guishaderScreenRects) do
glRect(rect[1], rect[2], rect[3], rect[4])
for name, rect in pairs(guishaderScreenRects) do
if widgetHandler:ModalAllows(screenRectOwners[name]) then
glRect(rect[1], rect[2], rect[3], rect[4])
end
end
for _, dlist in pairs(guishaderScreenDlists) do
glColor(1, 1, 1, 1)
glCallList(dlist)
for name, dlist in pairs(guishaderScreenDlists) do
if widgetHandler:ModalAllows(screenDlistOwners[name]) then
glColor(1, 1, 1, 1)
glCallList(dlist)
end
end
end
glPopMatrix()
Expand Down Expand Up @@ -370,6 +389,18 @@ function widget:Shutdown()
end

function widget:DrawScreenEffects() -- This blurs the world underneath UI elements
-- Before the early returns on purpose: when a modal window starts or stops hiding the
-- interface, which regions belong in the stencil changes even though no widget
-- registered or removed one, and the quit dialog's fullscreen blur skips the rest.
local modalActive = widgetHandler:IsModalActive()
local modalRevision = widgetHandler:GetModalRevision()
if modalActive ~= lastModalActive or modalRevision ~= lastModalRevision then
lastModalActive = modalActive
lastModalRevision = modalRevision
updateStencilTexture = true
updateStencilTextureScreen = true
end

if spIsGUIHidden() or uiOpacity > 0.99 then
return
end
Expand Down Expand Up @@ -509,16 +540,22 @@ function widget:Initialize()
self:UpdateCallIns()

WG.guishader = {}
WG.guishader.InsertDlist = function(dlist, name, force)
if force or guishaderDlists[name] ~= dlist then
-- The trailing `owner` argument of the Insert functions is optional and only matters
-- when a modal window hides the interface: pass the registering `widget` and the
-- region follows that widget's visibility, otherwise it is dropped while a window is
-- open. See the "Modal windows" block in barwidgets.lua.
WG.guishader.InsertDlist = function(dlist, name, force, owner)
if force or guishaderDlists[name] ~= dlist or dlistOwners[name] ~= owner then
guishaderDlists[name] = dlist
dlistOwners[name] = owner
updateStencilTexture = true
end
end
WG.guishader.RemoveDlist = function(name)
local found = guishaderDlists[name] ~= nil
if found then
guishaderDlists[name] = nil
dlistOwners[name] = nil
updateStencilTexture = true
end
return found
Expand All @@ -528,30 +565,35 @@ function widget:Initialize()
if found then
deleteDlistQueue[#deleteDlistQueue + 1] = guishaderDlists[name]
guishaderDlists[name] = nil
dlistOwners[name] = nil
updateStencilTexture = true
end
return found
end
WG.guishader.InsertRect = function(left, top, right, bottom, name)
WG.guishader.InsertRect = function(left, top, right, bottom, name, owner)
guishaderRects[name] = { left, top, right, bottom }
rectOwners[name] = owner
updateStencilTexture = true
end
WG.guishader.RemoveRect = function(name)
local found = guishaderRects[name] ~= nil
if found then
guishaderRects[name] = nil
rectOwners[name] = nil
updateStencilTexture = true
end
return found
end
WG.guishader.InsertScreenDlist = function(dlist, name)
WG.guishader.InsertScreenDlist = function(dlist, name, owner)
guishaderScreenDlists[name] = dlist
screenDlistOwners[name] = owner
updateStencilTextureScreen = true
end
WG.guishader.RemoveScreenDlist = function(name)
local found = guishaderScreenDlists[name] ~= nil
if found then
guishaderScreenDlists[name] = nil
screenDlistOwners[name] = nil
updateStencilTextureScreen = true
end
return found
Expand All @@ -561,17 +603,20 @@ function widget:Initialize()
if found then
deleteDlistQueue[#deleteDlistQueue + 1] = guishaderScreenDlists[name]
guishaderScreenDlists[name] = nil
screenDlistOwners[name] = nil
end
return found
end
WG.guishader.InsertScreenRect = function(left, top, right, bottom, name)
WG.guishader.InsertScreenRect = function(left, top, right, bottom, name, owner)
guishaderScreenRects[name] = { left, top, right, bottom }
screenRectOwners[name] = owner
updateStencilTextureScreen = true
end
WG.guishader.RemoveScreenRect = function(name)
local found = guishaderScreenRects[name] ~= nil
if found then
guishaderScreenRects[name] = nil
screenRectOwners[name] = nil
updateStencilTextureScreen = true
end
return found
Expand Down
7 changes: 6 additions & 1 deletion luaui/Widgets/gui_changelog_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ function widget:DrawScreen()
backgroundGuishader = glCreateList(function()
RectRound(screenX, screenY - screenHeight, screenX + screenWidth, screenY, elementCorner, 1, 1, 1, 1)
end)
WG.guishader.InsertDlist(backgroundGuishader, "changelog")
WG.guishader.InsertDlist(backgroundGuishader, "changelog", nil, widget)
end
showOnceMore = false

Expand Down Expand Up @@ -604,6 +604,11 @@ function widget:Initialize()
return
end

-- lets the handler hide the rest of the interface while the panel is open
widgetHandler:RegisterModalWindow(function()
return show == true
end)

WG.changelog = {}
WG.changelog.toggle = function(state)
if state ~= nil then
Expand Down
17 changes: 11 additions & 6 deletions luaui/Widgets/gui_chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function widget:GetInfo()
layer = -95000,
enabled = true,
handler = true,
modalExempt = true, -- chat stays readable and usable while a window is open
}
end

Expand Down Expand Up @@ -1186,7 +1187,7 @@ function state.updateChatInputGuishader(left, bottom, right, top)
RectRound(left, bottom, right, top, elementCorner)
end)
WG.guishader.RemoveDlist("chatinput")
WG.guishader.InsertDlist(state.chatInputGuishaderDlist, "chatinput")
WG.guishader.InsertDlist(state.chatInputGuishaderDlist, "chatinput", nil, widget)
end

function state.drawEmojiPickerButton(rect, iconSize)
Expand Down Expand Up @@ -1245,7 +1246,7 @@ function state.drawEmojiPickerGrid(inputAlpha, inputFontSize)
glColor(0, 0, 0, inputAlpha * 1.12)
RectRound(pickerLeft, pickerBottom, pickerRight, pickerTop, elementCorner * 0.7, 0, 0, 1, 1)
if WG.guishader then
WG.guishader.InsertRect(pickerLeft, pickerBottom, pickerRight, pickerTop, "chatinputemojipicker")
WG.guishader.InsertRect(pickerLeft, pickerBottom, pickerRight, pickerTop, "chatinputemojipicker", widget)
end
for i = 1, #emojiAutocompleteAliases do
local col = (i - 1) % pickerColumns
Expand Down Expand Up @@ -1728,7 +1729,9 @@ local function processAddConsoleLine(gameFrame, line, orgLineID, reprocessID)
end
end

line = colorConsoleStr .. lineColor .. line
if string.byte(line, 1) ~= 255 then
line = (lineColor ~= "" and lineColor or colorConsoleStr) .. line
end
end

if not bypassThisMessage then
Expand Down Expand Up @@ -2534,7 +2537,8 @@ drawChatInput = function()
yPos - height,
x2 - elementPadding,
yPos,
"chatinputautocomplete"
"chatinputautocomplete",
widget
)
end
local addHeight = floor((inputFontSize * scale) * 1.35) - autocLineHeight
Expand Down Expand Up @@ -2587,7 +2591,7 @@ drawChatInput = function()
"o"
)
if WG.guishader then
WG.guishader.InsertRect(infoLeft, infoBottom, infoRight, infoTop, "chatinputinfo")
WG.guishader.InsertRect(infoLeft, infoBottom, infoRight, infoTop, "chatinputinfo", widget)
end
else
if WG.guishader then
Expand Down Expand Up @@ -2985,7 +2989,8 @@ function widget:DrawScreen()
activationArea[2] + chatlogHeightDiff,
activationArea[3],
activationArea[4],
"chat"
"chat",
widget
)
end

Expand Down
7 changes: 6 additions & 1 deletion luaui/Widgets/gui_gameinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ function widget:DrawScreen()
backgroundGuishader = glCreateList(function()
RectRound(screenX, screenY - screenHeight, screenX + screenWidth, screenY, elementCorner, 1, 1, 1, 1)
end)
WG.guishader.InsertDlist(backgroundGuishader, "gameinfo")
WG.guishader.InsertDlist(backgroundGuishader, "gameinfo", nil, widget)
end
showOnceMore = false

Expand Down Expand Up @@ -2239,6 +2239,11 @@ function widget:Initialize()
end
end, nil, "p")

-- lets the handler hide the rest of the interface while the panel is open
widgetHandler:RegisterModalWindow(function()
return show == true
end)

WG.gameinfo = {}
WG.gameinfo.toggle = function(state)
if state == nil then
Expand Down
7 changes: 6 additions & 1 deletion luaui/Widgets/gui_keybind_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function widget:DrawScreen()
backgroundGuishader = glCreateList(function()
RectRound(screenX, screenY - screenHeight, screenX + screenWidth, screenY, elementCorner, 0, 1, 1, 1)
end)
WG.guishader.InsertDlist(backgroundGuishader, "keybindinfo")
WG.guishader.InsertDlist(backgroundGuishader, "keybindinfo", nil, widget)
end
showOnceMore = false

Expand Down Expand Up @@ -359,6 +359,11 @@ function widget:Initialize()
end
end)

-- lets the handler hide the rest of the interface while the panel is open
widgetHandler:RegisterModalWindow(function()
return show == true
end)

WG.keybinds = {}
WG.keybinds.toggle = function(state)
local wanted = state
Expand Down
8 changes: 7 additions & 1 deletion luaui/Widgets/gui_mission_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function widget:DrawScreen()
RectRound(titleRect[1], titleRect[2], titleRect[3], titleRect[4], elementCorner, 1, 1, 0, 0)
end)
dlistcreated = true
WG.guishader.InsertDlist(backgroundGuishader, "missiontext")
WG.guishader.InsertDlist(backgroundGuishader, "missiontext", nil, widget)
end
showOnceMore = false

Expand Down Expand Up @@ -468,6 +468,12 @@ function widget:Initialize()

totalTextLines = #textLines

-- lets the handler hide the rest of the interface while the panel is open.
-- Reads `show` alone: justClosedFromPress is a one-frame lie told to the top bar.
widgetHandler:RegisterModalWindow(function()
return show == true
end)

WG.missioninfo = {}
WG.missioninfo.toggle = function(state)
local wasVisible = show
Expand Down
Loading
Loading