mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
Fixes to miniwindows
This commit is contained in:
@@ -75,6 +75,8 @@ function UIMiniWindow:onSetup()
|
||||
end
|
||||
end
|
||||
|
||||
local oldParent = self:getParent()
|
||||
|
||||
local settings = Settings.getNode('MiniWindows')
|
||||
if settings then
|
||||
local selfSettings = settings[self:getId()]
|
||||
@@ -83,6 +85,7 @@ function UIMiniWindow:onSetup()
|
||||
local parent = rootWidget:recursiveGetChildById(selfSettings.parentId)
|
||||
if parent then
|
||||
if parent:getClassName() == 'UIMiniWindowContainer' and selfSettings.index and parent:isOn() then
|
||||
self.miniIndex = selfSettings.index
|
||||
parent:scheduleInsert(self, selfSettings.index)
|
||||
elseif selfSettings.position then
|
||||
self:setParent(parent)
|
||||
@@ -101,6 +104,17 @@ function UIMiniWindow:onSetup()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local newParent = self:getParent()
|
||||
|
||||
self.miniLoaded = true
|
||||
|
||||
if oldParent and oldParent:getClassName() == 'UIMiniWindowContainer' then
|
||||
oldParent:order()
|
||||
end
|
||||
if newParent and newParent:getClassName() == 'UIMiniWindowContainer' and newParent ~= oldParent then
|
||||
newParent:order()
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragEnter(mousePos)
|
||||
@@ -199,6 +213,8 @@ function UIMiniWindow:onFocusChange(focused)
|
||||
end
|
||||
|
||||
function UIMiniWindow:setSettings(data)
|
||||
if not self.save then return end
|
||||
|
||||
local settings = Settings.getNode('MiniWindows')
|
||||
if not settings then
|
||||
settings = {}
|
||||
|
@@ -54,29 +54,46 @@ function UIMiniWindowContainer:scheduleInsert(widget, index)
|
||||
if oldParent ~= self then
|
||||
oldParent:removeChild(widget)
|
||||
self:insertChild(index, widget)
|
||||
else
|
||||
self:swapInsert(widget, index)
|
||||
end
|
||||
|
||||
while true do
|
||||
local placed = false
|
||||
for nIndex,nWidget in pairs(self.scheduledWidgets) do
|
||||
if nIndex - 1 <= self:getChildCount() then
|
||||
self:insertChild(nIndex, nWidget)
|
||||
self.scheduledWidgets[nIndex] = nil
|
||||
placed = true
|
||||
break
|
||||
while true do
|
||||
local placed = false
|
||||
for nIndex,nWidget in pairs(self.scheduledWidgets) do
|
||||
if nIndex - 1 <= self:getChildCount() then
|
||||
self:insertChild(nIndex, nWidget)
|
||||
self.scheduledWidgets[nIndex] = nil
|
||||
placed = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not placed then break end
|
||||
end
|
||||
if not placed then break end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:order()
|
||||
local children = self:getChildren()
|
||||
for i=1,#children do
|
||||
if not children[i].miniLoaded then return end
|
||||
end
|
||||
|
||||
for i=1,#children do
|
||||
if children[i].miniIndex then
|
||||
self:swapInsert(children[i], children[i].miniIndex)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:saveChildren()
|
||||
local children = self:getChildren()
|
||||
local ignoreIndex = 0
|
||||
for i=1,#children do
|
||||
children[i]:saveParentIndex(self:getId(), i)
|
||||
if children[i].save then
|
||||
children[i]:saveParentIndex(self:getId(), i - ignoreIndex)
|
||||
else
|
||||
ignoreIndex = ignoreIndex + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user