Fix battlelist square bug / Cleanup
This commit is contained in:
parent
b96be291bb
commit
f23e70ff08
|
@ -214,38 +214,35 @@ function onChangeSortType(comboBox, option)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onChangeSortOrder(comboBox, option)
|
function onChangeSortOrder(comboBox, option)
|
||||||
setSortOrder(option:lower():gsub('[.]', '')) -- Replace dot in option name
|
-- Replace dot in option name
|
||||||
|
setSortOrder(option:lower():gsub('[.]', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
function checkCreatures()
|
function checkCreatures()
|
||||||
removeAllCreatures()
|
removeAllCreatures()
|
||||||
|
|
||||||
local spectators = {}
|
if not g_game.isOnline() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local player = g_game.getLocalPlayer()
|
local player = g_game.getLocalPlayer()
|
||||||
if g_game.isOnline() then
|
local spectators = g_map.getSpectators(player:getPosition(), false)
|
||||||
creatures = g_map.getSpectators(player:getPosition(), false)
|
for _, creature in ipairs(spectators) do
|
||||||
for i, creature in ipairs(creatures) do
|
if doCreatureFitFilters(creature) then
|
||||||
if creature ~= player and doCreatureFitFilters(creature) then
|
addCreature(creature)
|
||||||
table.insert(spectators, creature)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, v in pairs(spectators) do
|
|
||||||
addCreature(v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function doCreatureFitFilters(creature)
|
function doCreatureFitFilters(creature)
|
||||||
local localPlayer = g_game.getLocalPlayer()
|
if creature:isLocalPlayer() then
|
||||||
if creature == localPlayer then
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos = creature:getPosition()
|
local pos = creature:getPosition()
|
||||||
if not pos then return false end
|
if not pos then return false end
|
||||||
|
|
||||||
|
local localPlayer = g_game.getLocalPlayer()
|
||||||
if pos.z ~= localPlayer:getPosition().z or not creature:canBeSeen() then return false end
|
if pos.z ~= localPlayer:getPosition().z or not creature:canBeSeen() then return false end
|
||||||
|
|
||||||
local hidePlayers = hidePlayersButton:isChecked()
|
local hidePlayers = hidePlayersButton:isChecked()
|
||||||
|
@ -293,8 +290,8 @@ function onCreaturePositionChange(creature, newPos, oldPos)
|
||||||
-- Distance will change when moving, recalculate and move to correct index
|
-- Distance will change when moving, recalculate and move to correct index
|
||||||
if getSortType() == 'distance' then
|
if getSortType() == 'distance' then
|
||||||
local distanceList = {}
|
local distanceList = {}
|
||||||
for id, creatureButton in pairs(battleButtonsByCreaturesList) do
|
for _, battleButton in pairs(battleButtonsByCreaturesList) do
|
||||||
table.insert(distanceList, {distance = getDistanceBetween(newPos, creatureButton.creature:getPosition()), widget = creatureButton})
|
table.insert(distanceList, {distance = getDistanceBetween(newPos, battleButton.creature:getPosition()), widget = battleButton})
|
||||||
end
|
end
|
||||||
|
|
||||||
if isSortAsc() then
|
if isSortAsc() then
|
||||||
|
@ -308,8 +305,8 @@ function onCreaturePositionChange(creature, newPos, oldPos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for id, creatureButton in pairs(battleButtonsByCreaturesList) do
|
for _, battleButton in pairs(battleButtonsByCreaturesList) do
|
||||||
addCreature(creatureButton.creature)
|
addCreature(battleButton.creature)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -335,6 +332,12 @@ function onCreatureOutfitChange(creature, outfit, oldOutfit)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onCreatureAppear(creature)
|
function onCreatureAppear(creature)
|
||||||
|
if creature:isLocalPlayer() then
|
||||||
|
addEvent(function()
|
||||||
|
updateStaticSquare()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
if doCreatureFitFilters(creature) then
|
if doCreatureFitFilters(creature) then
|
||||||
addCreature(creature)
|
addCreature(creature)
|
||||||
end
|
end
|
||||||
|
@ -454,8 +457,8 @@ end
|
||||||
|
|
||||||
function removeAllCreatures()
|
function removeAllCreatures()
|
||||||
creatureAgeList = {}
|
creatureAgeList = {}
|
||||||
for i, v in pairs(battleButtonsByCreaturesList) do
|
for _, battleButton in pairs(battleButtonsByCreaturesList) do
|
||||||
removeCreature(v.creature)
|
removeCreature(battleButton.creature)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -500,10 +503,10 @@ function onBattleButtonMouseRelease(self, mousePosition, mouseButton)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function onBattleButtonHoverChange(widget, hovered)
|
function onBattleButtonHoverChange(battleButton, hovered)
|
||||||
if widget.isBattleButton then
|
if battleButton.isBattleButton then
|
||||||
widget.isHovered = hovered
|
battleButton.isHovered = hovered
|
||||||
updateBattleButton(widget)
|
updateBattleButton(battleButton)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -523,6 +526,14 @@ function onFollow(creature)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function updateStaticSquare()
|
||||||
|
for _, battleButton in pairs(battleButtonsByCreaturesList) do
|
||||||
|
if battleButton.isTarget then
|
||||||
|
battleButton:update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function updateCreatureSkull(creature, skullId)
|
function updateCreatureSkull(creature, skullId)
|
||||||
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
local battleButton = battleButtonsByCreaturesList[creature:getId()]
|
||||||
if battleButton then
|
if battleButton then
|
||||||
|
|
Loading…
Reference in New Issue