• 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!

Hints to centre backpack slots(4) otcv8

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
964
Solutions
6
Reaction score
164
Location
Nowhere
Hello


I've since yesterday trying to figure out, i've managed to reduce game panels, that way only 4 slots are being displayed.
my trouble this is that i can't delete or remove an "invisible margen" that doesn't let' me move square inventory, containers slots nor buttons
as you can see in the picture there is a frame that is "bolded" in the right>, compared to the left panel <
i have edited only gameinterface.otui i have tried different numbers and this is the configuration that is more as i would like to.
Code:
GameSidePanel < UIMiniWindowContainer
  image-source: /images/ui/panel_side
  image-border: 6
  padding: 8
  padding-top: 24
  width: 178
  focusable: false
  on: true
  layout:
    type: verticalBox
  $mobile:
    padding: 0
    width: 200
 

GameMapPanel < UIGameMap
  padding: 4
  image-source: /images/ui/panel_map
  image-border: 4

  $on:
    padding: 0
  
GameAction < UIButton
  size: 9 9
  phantom: false
  
  UIButton
    id: image
    size: 6 6
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.verticalCenter: parent.verticalCenter
    phantom: true
    $checked:
      opacity: 1.0
      background: #00FF0033
    $!checked:
      opacity: 0.6
      background: alpha


UIWidget
  id: gameRootPanel
  anchors.fill: parent
 
  GameMapPanel
    id: gameMapPanel
    anchors.left: gameLeftPanels.right
    anchors.right: gameRightPanels.left
    anchors.top: parent.top
    anchors.bottom: gameBottomPanel.top
    focusable: false 
  
  Panel
    id: gameLeftActions
    focusable: false
    anchors.bottom: parent.bottom
    anchors.left: parent.left
    width: 64
  
    $!mobile:
      visible: false
      width: 0
  
    layout:
      type: verticalBox
      fit-children: true
    
    GameAction
      id: use
      @onSetup: self.image:setImageSource("/images/game/mobile/use")
    GameAction
      id: attack
      @onSetup: self.image:setImageSource("/images/game/mobile/attack")
    GameAction
      id: follow
      @onSetup: self.image:setImageSource("/images/game/mobile/follow")
    GameAction
      id: look
      @onSetup: self.image:setImageSource("/images/game/mobile/look")
    GameAction
      id: chat
      @onSetup: self.image:setImageSource("/images/game/mobile/chat")
  
  Panel
    id: gameLeftPanels
    focusable: false
    anchors.top: parent.top
    anchors.bottom: parent.bottom 
    $!mobile:
      anchors.left: parent.left
    $mobile:
      anchors.left: gameLeftActions.right

    layout:
      type: horizontalBox
      fit-children: true
      spacing: -3

  Panel
    id: gameLeftActionPanel
    phantom: true
    focusable: false
    anchors.top: gameTopBar.bottom
    anchors.left: gameLeftPanels.right
    anchors.bottom: bottomSplitter.top
    margin-top: 3

    $mobile:
      visible: false
    
    layout:
      type: horizontalBox
      fit-children: true
    
  Panel
    id: gameRightPanels
    anchors.right: parent.right
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    focusable: false
    layout:
      type: horizontalBox
      fit-children: true   
      spacing: -1

  Panel
    id: gameRightActionPanel
    phantom: true
    focusable: false
    anchors.top: gameTopBar.bottom
    anchors.right: gameRightPanels.left
    anchors.bottom: bottomSplitter.top
    margin-top: 3

    $mobile:
      visible: false
    
    layout:
      type: horizontalBox
      fit-children: true
  
  Splitter
    id: bottomSplitter
    anchors.left: gameLeftPanels.right
    anchors.right: gameRightPanels.left
    anchors.bottom: parent.bottom
    height: 5
    relative-margin: bottom
    margin-bottom: 200
    @canUpdateMargin: function(self, newMargin) if modules.client_options.getOption('dontStretchShrink') then return self:getMarginBottom() end return math.max(math.min(newMargin, self:getParent():getHeight() - 200),110) end
    @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 200, 110), self:getMarginBottom())) end
  
    $mobile:
      visible: false
    
  Panel
    id: gameBottomActionPanel
    phantom: true
    focusable: false

    $!mobile:
      anchors.left: bottomSplitter.left
      anchors.right: bottomSplitter.right
      anchors.top: bottomSplitter.top
      margin-top: 3

    $mobile:
      anchors.left: gameLeftPanels.right
      anchors.right: gameRightPanels.left
      anchors.bottom: gameBottomPanel.top 
    
    layout:
      type: verticalBox
      fit-children: true
  
  Panel
    id: gameBottomPanel 
    $!mobile:
      anchors.left: gameBottomActionPanel.left
      anchors.right: gameBottomActionPanel.right
      anchors.top: gameBottomActionPanel.bottom
      anchors.bottom: parent.bottom

    $mobile:
      anchors.left: gameLeftPanels.right
      anchors.right: gameRightPanels.left
      anchors.bottom: parent.bottom
    
  UIWidget
    id: mouseGrabber
    focusable: false
    visible: false

  Panel
    id: gameTopBar
    image-source: /images/ui/panel_bottom2
    anchors.top: parent.top
    anchors.left: gameBottomActionPanel.left
    anchors.right: gameBottomActionPanel.right
    focusable: false

    $mobile:
      height: 0

    layout:
      type: verticalBox
      fit-children: true

and containers.lua margin(0) changed to margin(1)
Lua:
local gameStart = 0

function init()
  connect(Container, { onOpen = onContainerOpen,
                       onClose = onContainerClose,
                       onSizeChange = onContainerChangeSize,
                       onUpdateItem = onContainerUpdateItem })
  connect(g_game, {
    onGameStart = markStart,
    onGameEnd = clean
  })

  reloadContainers()
end

function terminate()
  disconnect(Container, { onOpen = onContainerOpen,
                          onClose = onContainerClose,
                          onSizeChange = onContainerChangeSize,
                          onUpdateItem = onContainerUpdateItem })
  disconnect(g_game, {
    onGameStart = markStart,
    onGameEnd = clean
  })
end

function reloadContainers()
  clean()
  for _,container in pairs(g_game.getContainers()) do
    onContainerOpen(container)
  end
end

function clean()
  for containerid,container in pairs(g_game.getContainers()) do
    destroy(container)
  end
end

function markStart()
  gameStart = g_clock.millis()
end

function destroy(container)
  if container.window then
    container.window:destroy()
    container.window = nil
    container.itemsPanel = nil
  end
end

function refreshContainerItems(container)
  for slot=0,container:getCapacity()-1 do
    local itemWidget = container.itemsPanel:getChildById('item' .. slot)
    itemWidget:setItem(container:getItem(slot))
  end

  if container:hasPages() then
    refreshContainerPages(container)
  end
end

function toggleContainerPages(containerWindow, hasPages)
  if hasPages == containerWindow.pagePanel:isOn() then
    return
  end
  containerWindow.pagePanel:setOn(hasPages)
  if hasPages then
    containerWindow.miniwindowScrollBar:setMarginTop(containerWindow.miniwindowScrollBar:getMarginTop() + containerWindow.pagePanel:getHeight())
    containerWindow.contentsPanel:setMarginTop(containerWindow.contentsPanel:getMarginTop() + containerWindow.pagePanel:getHeight())
  else
    containerWindow.miniwindowScrollBar:setMarginTop(containerWindow.miniwindowScrollBar:getMarginTop() - containerWindow.pagePanel:getHeight())
    containerWindow.contentsPanel:setMarginTop(containerWindow.contentsPanel:getMarginTop() - containerWindow.pagePanel:getHeight())
  end
end

function refreshContainerPages(container)
  local currentPage = 1 + math.floor(container:getFirstIndex() / container:getCapacity())
  local pages = 1 + math.floor(math.max(0, (container:getSize() - 1)) / container:getCapacity())
  container.window:recursiveGetChildById('pageLabel'):setText(string.format('Page %i of %i', currentPage, pages))

  local prevPageButton = container.window:recursiveGetChildById('prevPageButton')
  if currentPage == 1 then
    prevPageButton:setEnabled(false)
  else
    prevPageButton:setEnabled(true)
    prevPageButton.onClick = function() g_game.seekInContainer(container:getId(), container:getFirstIndex() - container:getCapacity()) end
  end

  local nextPageButton = container.window:recursiveGetChildById('nextPageButton')
  if currentPage >= pages then
    nextPageButton:setEnabled(false)
  else
    nextPageButton:setEnabled(true)
    nextPageButton.onClick = function() g_game.seekInContainer(container:getId(), container:getFirstIndex() + container:getCapacity()) end
  end
end

function onContainerOpen(container, previousContainer)
  local containerWindow
  if previousContainer then
    containerWindow = previousContainer.window
    previousContainer.window = nil
    previousContainer.itemsPanel = nil
  else
    containerWindow = g_ui.createWidget('ContainerWindow', modules.game_interface.getContainerPanel())
  end
 
  containerWindow:setId('container' .. container:getId())
  if gameStart + 1000 < g_clock.millis() then
    containerWindow:clearSettings()
  end
 
  local containerPanel = containerWindow:getChildById('contentsPanel')
  local containerItemWidget = containerWindow:getChildById('containerItemWidget')
  containerWindow.onClose = function()
    g_game.close(container)
    containerWindow:hide()
  end
  containerWindow.onDrop = function(container, widget, mousePos)
    if containerPanel:getChildByPos(mousePos) then
      return false
    end
    local child = containerPanel:getChildByIndex(-1)
    if child then
      child:onDrop(widget, mousePos, true)     
    end
  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)
  containerWindow:setText(name)

  containerItemWidget:setItem(container:getContainerItem())

  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))
    itemWidget:setMargin(1) ---agregado cambio bps era 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())

  if container:hasPages() then
    local height = containerWindow.miniwindowScrollBar:getMarginTop() + containerWindow.pagePanel:getHeight()+17
    if containerWindow:getHeight() < height then
      containerWindow:setHeight(height)
    end
  end

  if not previousContainer then
    local filledLines = math.max(math.ceil(container:getItemsCount() / layout:getNumColumns()), 1)
    containerWindow:setContentHeight(filledLines*cellSize.height)
  end

  containerWindow:setup()
end

function onContainerClose(container)
  destroy(container)
end

function onContainerChangeSize(container, size)
  if not container.window then return end
  refreshContainerItems(container)
end

function onContainerUpdateItem(container, slot, item, oldItem)
  if not container.window then return end
  local itemWidget = container.itemsPanel:getChildById('item' .. slot)
  itemWidget:setItem(item)
end
this is how it's look also can't move icons dunno why i have reviewed 40-inventory.otui i know inventory slots are buggy but im trying to figure container slots first
 
Back
Top