• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

UIMiniWindow:onDragLeave BUG

tiothiago

New Member
Joined
Jan 8, 2020
Messages
26
Reaction score
3
I've changed this code at modules/corelib/ui/uiminiwindow.lua

Lua:
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)

if self.movedWidget then
          self.setMovedChildMargin(self.movedOldMargin or 0)
          self.movedWidget = nil
          self.setMovedChildMargin = nil
          self.movedOldMargin = nil
          self.movedIndex = nil
        end

  UIWindow:onDragLeave(self, droppedWidget, mousePos)
  self:saveParent(self:getParent())

end

TO THIS CODE, BASED UPON THIS MOD: [MOD] Windows (BP, EQ, Battle etc.) can be dragged only to 'panels' (right/left) (https://otland.net/threads/mod-windows-bp-eq-battle-etc-can-be-dragged-only-to-panels-right-left.233809/)

Lua:
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)

  local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
  local dropInPanel = 0
  for i=1,#children do
    local child = children[i]
    if child:getId() == 'leftPanel1' or child:getId() == 'rightPanel1' then
      dropInPanel = 1
    end
  end
  if dropInPanel == 0 then
    tmpp = self
    if (modules.game_interface.getLeftPanel():isVisible()) then
     if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then
       addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end)
     else
       addEvent(function() tmpp:setParent(modules.game_interface.getLeftPanel()) end)
     end
    else
      addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end)
    end
  end

  UIWindow:onDragLeave(self, droppedWidget, mousePos)
  self:saveParent(self:getParent())

end

And now, when I move windows arround sometimes apears empty spaces... any ideias to solve it? thx in advance :)

1617163717679.png
 
Last edited:
I fix it:
Fix problem with positioning when "Move windows to panels"

Code:
Lua:
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
    if self.movedWidget then
        self.setMovedChildMargin(self.movedOldMargin or 0)
        self.movedWidget = nil
        self.setMovedChildMargin = nil
        self.movedOldMargin = nil
        self.movedIndex = nil
    end

    local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
    local dropInPanel = 0

    for i=1,#children do
        local child = children[i]
        if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then
            dropInPanel = 1
        end
    end

    if dropInPanel == 0 then
        if(modules.game_interface.getLeftPanel():isVisible()) then
            if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then
                self:setParent(modules.game_interface.getRightPanel())
            else
                self:setParent(modules.game_interface.getLeftPanel())
            end
        else
            self:setParent(modules.game_interface.getRightPanel())
        end
    end

    self:saveParent(self:getParent())
end
 
Back
Top