Skip to content

Commit ac5d880

Browse files
committed
fix-cooldown-search
1 parent 470d9d7 commit ac5d880

File tree

6 files changed

+257
-26
lines changed

6 files changed

+257
-26
lines changed

modules/corelib/ui/uiwidget.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,35 @@ local parseEvents = function(widget, eventName, callStr, controller, NODE_STR)
298298
controller:registerUIEvents(widget, data)
299299
end
300300

301+
function UIWidget:onClick(mousePos)
302+
-- handle click in searchText box
303+
if self and type(self.onClick) == "table" then
304+
for _, func in pairs(self.onClick) do
305+
if type(func) == "function" and func ~= UIWidget.onClick then
306+
func(self, mousePos)
307+
end
308+
end
309+
end
310+
311+
-- handle click outsite of the widge
312+
local focusedWidgets = modules.game_interface.focusReason
313+
if not focusedWidgets or table.empty(focusedWidgets) then
314+
return true
315+
end
316+
317+
local clickedWidget = g_ui.getRootWidget():recursiveGetChildByPos(mousePos, false)
318+
if not clickedWidget then
319+
return true
320+
end
321+
322+
local ignorableWidgets = { "searchText" }
323+
if table.contains(ignorableWidgets, clickedWidget:getId()) then
324+
return true
325+
end
326+
327+
return true
328+
end
329+
301330
function UIWidget:onCreateByHTML(tagName, attrs, controllerName, NODE_STR)
302331
local controller = G_CONTROLLER_CALLED[controllerName]
303332
for attr, v in pairs(attrs) do

modules/game_analyser/classes/BossCooldown.lua

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,65 @@ function BossCooldown.create()
9494
if cl then
9595
cl.onMouseWheel = scrollUIPanel
9696
end
97+
98+
-- Set up the event handlers for the search text
99+
local searchText = BossCooldown.window.contentsPanel.searchText
100+
if searchText then
101+
-- Store original handlers
102+
BossCooldown.originalOnKeyPress = searchText.onKeyPress
103+
BossCooldown.originalOnTextChange = searchText.onTextChange
104+
105+
-- Override onKeyPress to unbind movement keys immediately when typing
106+
searchText.onKeyPress = function(widget, keyCode, keyboardModifiers)
107+
-- Unbind movement keys when user starts typing
108+
local gameWalk = modules.game_walk
109+
if gameWalk then
110+
gameWalk.unbindWalkKey('W')
111+
gameWalk.unbindWalkKey('D')
112+
gameWalk.unbindWalkKey('S')
113+
gameWalk.unbindWalkKey('A')
114+
gameWalk.unbindWalkKey('E')
115+
gameWalk.unbindWalkKey('Q')
116+
gameWalk.unbindWalkKey('C')
117+
gameWalk.unbindWalkKey('Z')
118+
gameWalk.unbindTurnKey('Ctrl+W')
119+
gameWalk.unbindTurnKey('Ctrl+D')
120+
gameWalk.unbindTurnKey('Ctrl+S')
121+
gameWalk.unbindTurnKey('Ctrl+A')
122+
end
123+
124+
-- Handle Escape key to clear focus and restore movement
125+
if keyCode == KeyEscape then
126+
-- Re-bind movement keys
127+
local gameWalk = modules.game_walk
128+
if gameWalk then
129+
gameWalk.bindWalkKey('W', North)
130+
gameWalk.bindWalkKey('D', East)
131+
gameWalk.bindWalkKey('S', South)
132+
gameWalk.bindWalkKey('A', West)
133+
gameWalk.bindWalkKey('E', NorthEast)
134+
gameWalk.bindWalkKey('Q', NorthWest)
135+
gameWalk.bindWalkKey('C', SouthEast)
136+
gameWalk.bindWalkKey('Z', SouthWest)
137+
gameWalk.bindTurnKey('Ctrl+W', North)
138+
gameWalk.bindTurnKey('Ctrl+D', East)
139+
gameWalk.bindTurnKey('Ctrl+S', South)
140+
gameWalk.bindTurnKey('Ctrl+A', West)
141+
end
142+
widget:clearFocus()
143+
return false
144+
end
145+
146+
-- Call original handler if it exists
147+
if BossCooldown.originalOnKeyPress then
148+
return BossCooldown.originalOnKeyPress(widget, keyCode, keyboardModifiers)
149+
end
150+
return false
151+
end
152+
153+
-- Set up focus change handler
154+
searchText.onFocusChange = onBossSearchFocusChange
155+
end
97156
end
98157

99158
function BossCooldown:reset()
@@ -315,6 +374,61 @@ function checkBossSearch(text)
315374
else
316375
BossCooldown.search = text
317376
end
377+
378+
-- Immediately apply the search filter
379+
if BossCooldown.window and BossCooldown.window.contentsPanel and BossCooldown.window.contentsPanel.bosses then
380+
local layout = BossCooldown.window.contentsPanel.bosses:getLayout()
381+
if layout then
382+
layout:enableUpdates()
383+
for _, widget in ipairs(BossCooldown.widgets) do
384+
if BossCooldown.search == '' or string.find(widget.name:lower(), BossCooldown.search:lower()) then
385+
widget:setVisible(true)
386+
else
387+
widget:setVisible(false)
388+
end
389+
end
390+
layout:disableUpdates()
391+
layout:update()
392+
end
393+
end
394+
end
395+
396+
function onBossSearchFocusChange(widget, focused)
397+
if focused then
398+
-- When gaining focus, unbind movement keys
399+
local gameWalk = modules.game_walk
400+
if gameWalk then
401+
gameWalk.unbindWalkKey('W')
402+
gameWalk.unbindWalkKey('D')
403+
gameWalk.unbindWalkKey('S')
404+
gameWalk.unbindWalkKey('A')
405+
gameWalk.unbindWalkKey('E')
406+
gameWalk.unbindWalkKey('Q')
407+
gameWalk.unbindWalkKey('C')
408+
gameWalk.unbindWalkKey('Z')
409+
gameWalk.unbindTurnKey('Ctrl+W')
410+
gameWalk.unbindTurnKey('Ctrl+D')
411+
gameWalk.unbindTurnKey('Ctrl+S')
412+
gameWalk.unbindTurnKey('Ctrl+A')
413+
end
414+
else
415+
-- When losing focus, bind movement keys back
416+
local gameWalk = modules.game_walk
417+
if gameWalk then
418+
gameWalk.bindWalkKey('W', North)
419+
gameWalk.bindWalkKey('D', East)
420+
gameWalk.bindWalkKey('S', South)
421+
gameWalk.bindWalkKey('A', West)
422+
gameWalk.bindWalkKey('E', NorthEast)
423+
gameWalk.bindWalkKey('Q', NorthWest)
424+
gameWalk.bindWalkKey('C', SouthEast)
425+
gameWalk.bindWalkKey('Z', SouthWest)
426+
gameWalk.bindTurnKey('Ctrl+W', North)
427+
gameWalk.bindTurnKey('Ctrl+D', East)
428+
gameWalk.bindTurnKey('Ctrl+S', South)
429+
gameWalk.bindTurnKey('Ctrl+A', West)
430+
end
431+
end
318432
end
319433
function clearSearch()
320434
BossCooldown.search = ''
@@ -354,15 +468,50 @@ function toggleBossCDFocus(visible)
354468
widget:setPhantom(true)
355469
elseif widget then
356470
widget:setPhantom(false)
357-
widget.onClick = function()
358-
toggleBossCDFocus(not visible)
471+
widget.onClick = function()
472+
modules.game_interface.toggleInternalFocus();
473+
toggleBossCDFocus(not visible)
359474
end
360475
end
361476

477+
modules.game_interface.toggleFocus(visible, "bosscooldown")
478+
362479
if visible then
363480
local text = BossCooldown.window.contentsPanel.searchText
364481
text:focus()
482+
-- Immediately unbind movement keys when search becomes active
483+
local gameWalk = modules.game_walk
484+
if gameWalk then
485+
gameWalk.unbindWalkKey('W')
486+
gameWalk.unbindWalkKey('D')
487+
gameWalk.unbindWalkKey('S')
488+
gameWalk.unbindWalkKey('A')
489+
gameWalk.unbindWalkKey('E')
490+
gameWalk.unbindWalkKey('Q')
491+
gameWalk.unbindWalkKey('C')
492+
gameWalk.unbindWalkKey('Z')
493+
gameWalk.unbindTurnKey('Ctrl+W')
494+
gameWalk.unbindTurnKey('Ctrl+D')
495+
gameWalk.unbindTurnKey('Ctrl+S')
496+
gameWalk.unbindTurnKey('Ctrl+A')
497+
end
365498
else
499+
-- Re-bind movement keys when search becomes inactive
500+
local gameWalk = modules.game_walk
501+
if gameWalk then
502+
gameWalk.bindWalkKey('W', North)
503+
gameWalk.bindWalkKey('D', East)
504+
gameWalk.bindWalkKey('S', South)
505+
gameWalk.bindWalkKey('A', West)
506+
gameWalk.bindWalkKey('E', NorthEast)
507+
gameWalk.bindWalkKey('Q', NorthWest)
508+
gameWalk.bindWalkKey('C', SouthEast)
509+
gameWalk.bindWalkKey('Z', SouthWest)
510+
gameWalk.bindTurnKey('Ctrl+W', North)
511+
gameWalk.bindTurnKey('Ctrl+D', East)
512+
gameWalk.bindTurnKey('Ctrl+S', South)
513+
gameWalk.bindTurnKey('Ctrl+A', West)
514+
end
366515
BossCooldown.window:setBorderWidth(0)
367516
end
368517
end

modules/game_analyser/styles/boss.otui

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ MiniWindow
9999
margin-top: 2
100100
box-text-padding: 27
101101
@onTextChange: modules.game_analyser.checkBossSearch(self:getText())
102+
@onFocusChange: modules.game_analyser.onBossSearchFocusChange(self, focused)
102103
!placeholder: tr('Type to search')
103104

104105
Button

modules/game_console/console.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ function selectAll(consoleBuffer)
339339
end
340340

341341
function toggleChat()
342+
if modules.game_interface.isInternalLocked() then
343+
return
344+
end
345+
342346
consoleToggleChat.isChecked = not consoleToggleChat.isChecked
343347
if consoleToggleChat.isChecked then
344348
consoleToggleChat:setText(tr('Chat Off'))

modules/game_interface/gameinterface.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ leftDecreaseSidePanels = nil
2626
rightIncreaseSidePanels = nil
2727
rightDecreaseSidePanels = nil
2828
hookedMenuOptions = {}
29+
focusReason = {}
2930
local lastStopAction = 0
3031
local mobileConfig = {
3132
mobileWidthJoystick = 0,
@@ -125,6 +126,13 @@ function init()
125126
logoutButton = modules.client_topmenu.addTopRightToggleButton('logoutButton', tr('Exit'), '/images/topbuttons/logout',
126127
tryLogout, true)
127128

129+
gameMapPanel.onClick = toggleInternalFocus
130+
gameRightPanel.onClick = toggleInternalFocus
131+
gameRightExtraPanel.onClick = toggleInternalFocus
132+
gameLeftExtraPanel.onClick = toggleInternalFocus
133+
gameLeftPanel.onClick = toggleInternalFocus
134+
gameBottomPanel.onClick = toggleInternalFocus
135+
128136
showTopMenuButton = gameMapPanel:getChildById('showTopMenuButton')
129137
showTopMenuButton.onClick = function()
130138
modules.client_topmenu.toggle()
@@ -1759,3 +1767,43 @@ function testExtendedView(mode)
17591767
modules.game_mainpanel.toggleExtendedViewButtons(extendedView)
17601768
end)
17611769
end
1770+
1771+
function toggleInternalFocus()
1772+
for reason, _ in pairs(focusReason) do
1773+
if reason == 'bosscooldown' then
1774+
modules.game_analyser.toggleBossCDFocus(false)
1775+
end
1776+
end
1777+
end
1778+
1779+
function isInternalLocked()
1780+
if not focusReason or table.empty(focusReason) then
1781+
return false
1782+
end
1783+
return true
1784+
end
1785+
1786+
function toggleFocus(value, reason)
1787+
if not reason then
1788+
reason = ''
1789+
end
1790+
if not value then
1791+
getBottomPanel():focus()
1792+
if not reason then
1793+
reason = ''
1794+
end
1795+
1796+
focusReason[reason] = nil
1797+
else
1798+
focusReason[reason] = true
1799+
end
1800+
1801+
if not value and #focusReason ~= 0 then
1802+
return
1803+
end
1804+
1805+
gameRightPanel:setFocusable(value)
1806+
gameLeftPanel:setFocusable(value)
1807+
gameRightExtraPanel:setFocusable(value)
1808+
gameLeftExtraPanel:setFocusable(value)
1809+
end

src/client/uigraph.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,44 +94,44 @@ void UIGraph::drawSelf(const DrawPoolType drawPane)
9494
Point maxPoint(dest.left() - 10, dest.top() + 0);
9595
g_drawPool.rotate(maxPoint, rotationAngle);
9696
Rect maxRect(maxPoint.x - 50, maxPoint.y - 8, 100, 16);
97-
m_font->drawText(m_maxValue, Rect(maxRect.x()-1, maxRect.y()-1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
98-
m_font->drawText(m_maxValue, Rect(maxRect.x()+1, maxRect.y()-1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
99-
m_font->drawText(m_maxValue, Rect(maxRect.x()-1, maxRect.y()+1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
100-
m_font->drawText(m_maxValue, Rect(maxRect.x()+1, maxRect.y()+1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
101-
m_font->drawText(m_maxValue, Rect(maxRect.x(), maxRect.y()-1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
102-
m_font->drawText(m_maxValue, Rect(maxRect.x(), maxRect.y()+1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
103-
m_font->drawText(m_maxValue, Rect(maxRect.x()-1, maxRect.y(), maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
104-
m_font->drawText(m_maxValue, Rect(maxRect.x()+1, maxRect.y(), maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
97+
m_font->drawText(m_maxValue, Rect(maxRect.x() - 1, maxRect.y() - 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
98+
m_font->drawText(m_maxValue, Rect(maxRect.x() + 1, maxRect.y() - 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
99+
m_font->drawText(m_maxValue, Rect(maxRect.x() - 1, maxRect.y() + 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
100+
m_font->drawText(m_maxValue, Rect(maxRect.x() + 1, maxRect.y() + 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
101+
m_font->drawText(m_maxValue, Rect(maxRect.x(), maxRect.y() - 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
102+
m_font->drawText(m_maxValue, Rect(maxRect.x(), maxRect.y() + 1, maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
103+
m_font->drawText(m_maxValue, Rect(maxRect.x() - 1, maxRect.y(), maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
104+
m_font->drawText(m_maxValue, Rect(maxRect.x() + 1, maxRect.y(), maxRect.width(), maxRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
105105
m_font->drawText(m_maxValue, maxRect, Color::lightGray, Fw::AlignCenter);
106106
g_drawPool.popTransformMatrix();
107107

108108
g_drawPool.pushTransformMatrix();
109109
Point minPoint(dest.left() - 10, dest.bottom() - 0);
110110
g_drawPool.rotate(minPoint, rotationAngle);
111111
Rect minRect(minPoint.x - 50, minPoint.y - 8, 100, 16);
112-
m_font->drawText(m_minValue, Rect(minRect.x()-1, minRect.y()-1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
113-
m_font->drawText(m_minValue, Rect(minRect.x()+1, minRect.y()-1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
114-
m_font->drawText(m_minValue, Rect(minRect.x()-1, minRect.y()+1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
115-
m_font->drawText(m_minValue, Rect(minRect.x()+1, minRect.y()+1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
116-
m_font->drawText(m_minValue, Rect(minRect.x(), minRect.y()-1, minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
117-
m_font->drawText(m_minValue, Rect(minRect.x(), minRect.y()+1, minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
118-
m_font->drawText(m_minValue, Rect(minRect.x()-1, minRect.y(), minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
119-
m_font->drawText(m_minValue, Rect(minRect.x()+1, minRect.y(), minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
112+
m_font->drawText(m_minValue, Rect(minRect.x() - 1, minRect.y() - 1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
113+
m_font->drawText(m_minValue, Rect(minRect.x() + 1, minRect.y() - 1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
114+
m_font->drawText(m_minValue, Rect(minRect.x() - 1, minRect.y() + 1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
115+
m_font->drawText(m_minValue, Rect(minRect.x() + 1, minRect.y() + 1, minRect.width(), minRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
116+
m_font->drawText(m_minValue, Rect(minRect.x(), minRect.y() - 1, minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
117+
m_font->drawText(m_minValue, Rect(minRect.x(), minRect.y() + 1, minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
118+
m_font->drawText(m_minValue, Rect(minRect.x() - 1, minRect.y(), minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
119+
m_font->drawText(m_minValue, Rect(minRect.x() + 1, minRect.y(), minRect.width(), minRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
120120
m_font->drawText(m_minValue, minRect, Color::lightGray, Fw::AlignCenter);
121121
g_drawPool.popTransformMatrix();
122122

123123
g_drawPool.pushTransformMatrix();
124124
Point avgPoint(dest.left() - 10, dest.verticalCenter());
125125
g_drawPool.rotate(avgPoint, rotationAngle);
126126
Rect avgRect(avgPoint.x - 50, avgPoint.y - 8, 100, 16);
127-
m_font->drawText(m_avgValue, Rect(avgRect.x()-1, avgRect.y()-1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
128-
m_font->drawText(m_avgValue, Rect(avgRect.x()+1, avgRect.y()-1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
129-
m_font->drawText(m_avgValue, Rect(avgRect.x()-1, avgRect.y()+1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
130-
m_font->drawText(m_avgValue, Rect(avgRect.x()+1, avgRect.y()+1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
131-
m_font->drawText(m_avgValue, Rect(avgRect.x(), avgRect.y()-1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
132-
m_font->drawText(m_avgValue, Rect(avgRect.x(), avgRect.y()+1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
133-
m_font->drawText(m_avgValue, Rect(avgRect.x()-1, avgRect.y(), avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
134-
m_font->drawText(m_avgValue, Rect(avgRect.x()+1, avgRect.y(), avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
127+
m_font->drawText(m_avgValue, Rect(avgRect.x() - 1, avgRect.y() - 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
128+
m_font->drawText(m_avgValue, Rect(avgRect.x() + 1, avgRect.y() - 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
129+
m_font->drawText(m_avgValue, Rect(avgRect.x() - 1, avgRect.y() + 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
130+
m_font->drawText(m_avgValue, Rect(avgRect.x() + 1, avgRect.y() + 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 200), Fw::AlignCenter);
131+
m_font->drawText(m_avgValue, Rect(avgRect.x(), avgRect.y() - 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
132+
m_font->drawText(m_avgValue, Rect(avgRect.x(), avgRect.y() + 1, avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
133+
m_font->drawText(m_avgValue, Rect(avgRect.x() - 1, avgRect.y(), avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
134+
m_font->drawText(m_avgValue, Rect(avgRect.x() + 1, avgRect.y(), avgRect.width(), avgRect.height()), Color(0, 0, 0, 150), Fw::AlignCenter);
135135
m_font->drawText(m_avgValue, avgRect, Color::lightGray, Fw::AlignCenter);
136136
g_drawPool.popTransformMatrix();
137137
}

0 commit comments

Comments
 (0)