• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[MOD] Windows (BP, EQ, Battle etc.) can be dragged only to 'panels' (right/left)

how to make it work using otcv8?

fixed:

you have to replace the whole
Code:
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
with this one:

Code:
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
        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

end
I have another issue with this system..
when i add more than 1 panel in each side, i cant drag windows to secondary panels :oops:
Screenshot_1.png
 
thats true blasphemy,
you've gotta do it for yourself,
following the code you get the instructions, we gotta verify if the extra panel is active :-)
 
thats true blasphemy,
you've gotta do it for yourself,
following the code you get the instructions, we gotta verify if the extra panel is active :)
nah.. just change a line
if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then
for this
if child:getId() == 'gameLeftPanels' or child:getId() == 'gameRightPanels' then
But now, I have the "space" error (im with otcv8)

apparently fixed:

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() == 'gameLeftPanels' or child:getId() == 'gameRightPanels' 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

  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

if some one can test? and please tell me if has errors, i actually dont, ty
 
Last edited:
how to make this work but with extra pnael? by the moment if i set this code in otcv8 can't draag things into extra panels
nah.. just change a line

for this

But now, I have the "space" error (im with otcv8)

apparently fixed:

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() == 'gameLeftPanels' or child:getId() == 'gameRightPanels' 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

  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

if some one can test? and please tell me if has errors, i actually dont, ty


worked thanks
 
Last edited:
For those who are using Mehah OTClient here is my approach.

In data/styles/30-miniwindow.otui
ADD
Code:
&canMoveToGameRootPanel: true

Should look like this
Code:
MiniWindow < UIMiniWindow
  font: verdana-11px-antialised
  icon-rect: 4 4 16 16
  width: 192
  height: 200
  text-offset: 24 5
  text-align: topLeft
  image-source: /images/ui/miniwindow
  image-border: 4
  image-border-top: 23
  image-border-bottom: 4
  focusable: false
  &minimizedHeight: 24
  color: #909090
  &canMoveToGameRootPanel: true


In modules/game_containers/containers.lua
Under function
Code:
function onContainerOpen(container, previousContainer)

Add
Code:
containerWindow.canMoveToGameRootPanel = false

Should look like this
Code:
function onContainerOpen(container, previousContainer)
    local containerWindow
    if previousContainer then
        containerWindow = previousContainer.window
        previousContainer.window = nil
        previousContainer.itemsPanel = nil
    else
        containerWindow = g_ui.createWidget('ContainerWindow')
    end
    containerWindow:setId('container' .. container:getId())
    local containerPanel = containerWindow:getChildById('contentsPanel')
    local containerItemWidget = containerWindow:getChildById('containerItemWidget')
    containerWindow.onClose = function()
        g_game.close(container)
        containerWindow:hide()
    end

    -- this disables scrollbar auto hiding
    local scrollbar = containerWindow:getChildById('miniwindowScrollBar')
    scrollbar:mergeStyle({
        ['$!on'] = {}
    })

    local upButton = containerWindow:getChildById('upButton')
    upButton.onClick = function()
        g_game.openParent(container)
    end
    upButton:setVisible(container:hasParent())

    local name = container:getName()
    name = name:sub(1, 1):upper() .. name:sub(2)

    if name:len() > 14 then
        name = name:sub(1, 14) .. "..."
    end

    containerWindow:setText(name)

    containerItemWidget:setItem(container:getContainerItem())
    containerItemWidget:setPhantom(true)

    containerPanel:destroyChildren()
    for slot = 0, container:getCapacity() - 1 do
        local itemWidget = g_ui.createWidget('Item', containerPanel)
        itemWidget:setId('item' .. slot)
        itemWidget:setItem(container:getItem(slot))
        ItemsDatabase.setRarityItem(itemWidget, container:getItem(slot))
        ItemsDatabase.setTier(itemWidget, container:getItem(slot))
        if modules.client_options.getOption('showExpiryInContainers') then
            ItemsDatabase.setCharges(itemWidget, container:getItem(slot))
            ItemsDatabase.setDuration(itemWidget, container:getItem(slot))
        end
        itemWidget:setMargin(0)
        itemWidget.position = container:getSlotPosition(slot)

        if not container:isUnlocked() then
            itemWidget:setBorderColor('red')
        end
    end

    container.window = containerWindow
    container.itemsPanel = containerPanel

    toggleContainerPages(containerWindow, container:hasPages())
    refreshContainerPages(container)

    local layout = containerPanel:getLayout()
    local cellSize = layout:getCellSize()
    containerWindow:setContentMinimumHeight(cellSize.height)
    containerWindow:setContentMaximumHeight(cellSize.height * layout:getNumLines() + 15)

    if not previousContainer then
        local panel = modules.game_interface.findContentPanelAvailable(containerWindow, cellSize.height)
        panel:addChild(containerWindow)

        if modules.client_options.getOption('openMaximized') then
            containerWindow:setContentHeight(cellSize.height * layout:getNumLines())
        else
            local filledLines = math.max(math.ceil(container:getItemsCount() / layout:getNumColumns()), 1)
            containerWindow:setContentHeight(filledLines * cellSize.height)
        end
    end
    containerWindow.canMoveToGameRootPanel = false
    containerWindow:setup()
end

In modules/corelib/ui/uiminiwindow.lua
Under function
Code:
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)


Change from this:
Code:
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
    
    -- Note: It seems to prevent the minimap, inventory, and health widgets from moving off the interface panel.
    if self.moveOnlyToMain or droppedWidget and droppedWidget.onlyPhantomDrop then
        if not (droppedWidget) or (self.moveOnlyToMain and not (droppedWidget.onlyPhantomDrop)) or
            (not (self.moveOnlyToMain) and droppedWidget.onlyPhantomDrop) then
            local virtualParent = self:getParent()
            virtualParent:removeChild(self)
            self.oldParentDrag:insertChild(self.oldParentDragIndex, self)
            self.movedWidget = nil
        end
    end
    return true
end

To this:
Code:
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 revertMove = self:getParent():getId() == "gameRootPanel" and not self.canMoveToGameRootPanel
    
    -- Note: It seems to prevent the minimap, inventory, and health widgets from moving off the interface panel.
    if revertMove or self.moveOnlyToMain or droppedWidget and droppedWidget.onlyPhantomDrop then
        if not (droppedWidget) or (self.moveOnlyToMain and not (droppedWidget.onlyPhantomDrop)) or
            (not (self.moveOnlyToMain) and droppedWidget.onlyPhantomDrop) then
            local virtualParent = self:getParent()
            virtualParent:removeChild(self)
            self.oldParentDrag:insertChild(self.oldParentDragIndex, self)
            self.movedWidget = nil
        end
    end
    return true
end
 
Back
Top