Fixes to miniwindows
This commit is contained in:
parent
eec6114b2d
commit
39403e612f
|
@ -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
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ MiniWindow
|
|||
height: 166
|
||||
icon: battle.png
|
||||
@onClose: Battle.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
BattlePlayers
|
||||
|
|
|
@ -25,6 +25,7 @@ MiniWindow
|
|||
icon: combatcontrols.png
|
||||
height: 64
|
||||
@onClose: CombatControls.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
FightOffensiveBox
|
||||
|
|
|
@ -46,6 +46,7 @@ MiniWindow
|
|||
!text: tr('Health Bar')
|
||||
height: 86
|
||||
@onClose: HealthBar.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
HealthBar
|
||||
|
|
|
@ -4,6 +4,7 @@ MiniWindow
|
|||
icon: inventory.png
|
||||
height: 180
|
||||
@onClose: Inventory.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
Item
|
||||
|
|
|
@ -83,16 +83,19 @@ function Minimap.terminate()
|
|||
end
|
||||
|
||||
function Minimap.toggle()
|
||||
local visible = not minimapWindow:isExplicitlyVisible()
|
||||
if visible then
|
||||
minimapWindow:open()
|
||||
minimapButton:setOn(true)
|
||||
else
|
||||
if minimapButton:isOn() then
|
||||
minimapWindow:close()
|
||||
minimapButton:setOn(false)
|
||||
else
|
||||
minimapWindow:open()
|
||||
minimapButton:setOn(true)
|
||||
end
|
||||
end
|
||||
|
||||
function Minimap.onMiniWindowClose()
|
||||
minimapButton:setOn(false)
|
||||
end
|
||||
|
||||
function Minimap.reset()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if not player then return end
|
||||
|
|
|
@ -3,6 +3,8 @@ MiniWindow
|
|||
!text: tr('Minimap')
|
||||
height: 150
|
||||
icon: minimap.png
|
||||
@onClose: Minimap.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
padding: 3
|
||||
|
|
|
@ -36,6 +36,7 @@ MiniWindow
|
|||
height: 150
|
||||
icon: skills.png
|
||||
@onClose: Skills.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
anchors.fill: parent
|
||||
|
|
|
@ -9,6 +9,7 @@ MiniWindow
|
|||
height: 100
|
||||
icon: viplist.png
|
||||
@onClose: VipList.onMiniWindowClose()
|
||||
&save: true
|
||||
|
||||
MiniWindowContents
|
||||
layout: verticalBox
|
||||
|
|
Loading…
Reference in New Issue