mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
[UI] Option to choose where to open containers
At the bottom right of each panel, you can see a checkbox. When you tick it, new containers will be open there. Posibles TODOs: - Save selected panel (currently it will be lost when you restart the client) - Remove that checkbox, and add it at the options window
This commit is contained in:
parent
88c098a2e7
commit
22dc14f285
3 changed files with 82 additions and 4 deletions
|
|
@ -111,7 +111,7 @@ function onContainerOpen(container, previousContainer)
|
|||
else
|
||||
containerWindow = g_ui.createWidget('ContainerWindow',
|
||||
modules.game_interface
|
||||
.getRightPanel())
|
||||
.getSelectedPanel())
|
||||
end
|
||||
containerWindow:setId('container' .. container:getId())
|
||||
local containerPanel = containerWindow:getChildById('contentsPanel')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ gameMapPanel = nil
|
|||
gameRightPanel = nil
|
||||
gameRightExtraPanel = nil
|
||||
gameLeftPanel = nil
|
||||
gameSelectedPanel = nil
|
||||
panelsList = {}
|
||||
panelsRadioGroup = nil
|
||||
gameBottomPanel = nil
|
||||
showTopMenuButton = nil
|
||||
logoutButton = nil
|
||||
|
|
@ -50,6 +53,27 @@ function init()
|
|||
gameRightExtraPanel = gameRootPanel:getChildById('gameRightExtraPanel')
|
||||
gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
|
||||
gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
|
||||
|
||||
panelsList = {
|
||||
{
|
||||
panel = gameRightPanel,
|
||||
checkbox = gameRootPanel:getChildById('gameSelectRightColumn'),
|
||||
},{
|
||||
panel = gameRightExtraPanel,
|
||||
checkbox = gameRootPanel:getChildById('gameSelectRightExtraColumn'),
|
||||
},{
|
||||
panel = gameLeftPanel,
|
||||
checkbox = gameRootPanel:getChildById('gameSelectLeftColumn'),
|
||||
},
|
||||
}
|
||||
|
||||
panelsRadioGroup = UIRadioGroup.create()
|
||||
for k,v in pairs(panelsList) do
|
||||
panelsRadioGroup:addWidget(v.checkbox)
|
||||
connect(v.checkbox, { onCheckChange = onSelectPanel })
|
||||
end
|
||||
panelsRadioGroup:selectWidget(panelsList[1].checkbox)
|
||||
|
||||
connect(gameLeftPanel, {onVisibilityChange = onExtraPanelVisibilityChange})
|
||||
connect(gameRightExtraPanel, { onVisibilityChange = onExtraPanelVisibilityChange })
|
||||
|
||||
|
|
@ -68,6 +92,17 @@ function init()
|
|||
if g_game.isOnline() then show() end
|
||||
end
|
||||
|
||||
function onSelectPanel(self, checked)
|
||||
if checked then
|
||||
for k,v in pairs(panelsList) do
|
||||
if v.checkbox == self then
|
||||
gameSelectedPanel = v.panel
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function bindKeys()
|
||||
gameRootPanel:setAutoRepeatDelay(200)
|
||||
|
||||
|
|
@ -155,6 +190,10 @@ function terminate()
|
|||
disconnect(gameLeftPanel, {onVisibilityChange = onExtraPanelVisibilityChange})
|
||||
disconnect(gameRightExtraPanel, { onVisibilityChange = onExtraPanelVisibilityChange })
|
||||
|
||||
for k,v in pairs(panelsList) do
|
||||
disconnect(v.checkbox, { onCheckChange = onSelectPanel })
|
||||
end
|
||||
|
||||
logoutButton:destroy()
|
||||
gameRootPanel:destroy()
|
||||
end
|
||||
|
|
@ -959,14 +998,32 @@ function getLeftPanel() return gameLeftPanel end
|
|||
|
||||
function getRightExtraPanel() return gameRightExtraPanel end
|
||||
|
||||
function getSelectedPanel() return gameSelectedPanel end
|
||||
|
||||
function getBottomPanel() return gameBottomPanel end
|
||||
|
||||
function getShowTopMenuButton() return showTopMenuButton end
|
||||
|
||||
function onExtraPanelVisibilityChange(extraPanel, visible)
|
||||
if not visible and g_game.isOnline() then
|
||||
local children = extraPanel:getChildren()
|
||||
for i = 1, #children do children[i]:setParent(gameRightPanel) end
|
||||
if not visible then
|
||||
if g_game.isOnline() then
|
||||
local children = extraPanel:getChildren()
|
||||
for i = 1, #children do children[i]:setParent(gameRightPanel) end
|
||||
end
|
||||
|
||||
if extraPanel == getSelectedPanel() then
|
||||
panelsRadioGroup:selectWidget(panelsList[1].checkbox)
|
||||
end
|
||||
|
||||
if not gameRightExtraPanel:isVisible() and not gameLeftPanel:isVisible() then
|
||||
for k,v in pairs(panelsList) do
|
||||
v.checkbox:setVisible(false)
|
||||
end
|
||||
end
|
||||
else
|
||||
for k,v in pairs(panelsList) do
|
||||
v.checkbox:setVisible(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ GameSidePanel < UIMiniWindowContainer
|
|||
type: verticalBox
|
||||
//spacing: 1
|
||||
|
||||
SelectColumnButton < CheckBox
|
||||
visible: false
|
||||
opacity: 0.3
|
||||
$hover:
|
||||
opacity: 1
|
||||
|
||||
GameBottomPanel < Panel
|
||||
image-source: /images/ui/panel_bottom
|
||||
image-border: 4
|
||||
|
|
@ -80,6 +86,21 @@ UIWidget
|
|||
width: 0
|
||||
visible: false
|
||||
|
||||
SelectColumnButton
|
||||
id: gameSelectLeftColumn
|
||||
anchors.right: gameLeftPanel.right
|
||||
anchors.bottom: gameLeftPanel.bottom
|
||||
|
||||
SelectColumnButton
|
||||
id: gameSelectRightColumn
|
||||
anchors.right: gameRightPanel.right
|
||||
anchors.bottom: gameRightPanel.bottom
|
||||
|
||||
SelectColumnButton
|
||||
id: gameSelectRightExtraColumn
|
||||
anchors.right: gameRightExtraPanel.right
|
||||
anchors.bottom: gameRightExtraPanel.bottom
|
||||
|
||||
Splitter
|
||||
id: bottomSplitter
|
||||
anchors.left: gameLeftPanel.right
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue