NPCOfferLabel < Label
  anchors.left: prev.right
  anchors.top: prev.top
  margin-left: 5
  text-auto-resize: true

NPCItemBox < UICheckBox
  border-width: 1
  border-color: #000000
  color: #aaaaaa
  text-align: center
  text-offset: 0 30
  @onCheckChange: modules.game_npctrade.onItemBoxChecked(self)

  Item
    id: item
    phantom: true
    anchors.top: parent.top
    anchors.horizontalCenter: parent.horizontalCenter
    image-color: #ffffffff
    margin-top: 3

  $checked on:
    border-color: #ffffff

  $!checked:
    border-color: #000000

  $!on:
    image-color: #ffffff88
    color: #aaaaaa88

MainWindow
  id: npcWindow
  !text: tr('NPC Trade')
  size: 550 340
  @onEscape: modules.game_npctrade.closeNpcTrade()

  TabButton
    id: buyTab
    !tooltip: tr("List of items that you're able to buy")
    !text: tr('Buy')
    checked: true
    on: true
    anchors.left: parent.left
    anchors.right: parent.horizontalCenter
    anchors.top: parent.top
    margin-top: 0

  TabButton
    id: sellTab
    !tooltip: tr("List of items that you're able to sell")
    !text: tr('Sell')
    anchors.left: parent.horizontalCenter
    anchors.right: parent.right
    anchors.top: parent.top

  FlatPanel
    height: 150
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 5

    VerticalScrollBar
      id: itemsPanelListScrollBar
      anchors.top: parent.top
      anchors.bottom: parent.bottom
      anchors.right: parent.right
      step: 24
      pixels-scroll: true

    ScrollablePanel
      id: itemsPanel
      height: 200
      anchors.left: parent.left
      anchors.right: prev.left
      anchors.top: parent.top
      anchors.bottom: parent.bottom
      vertical-scrollbar: itemsPanelListScrollBar
      margin-left: 5
      margin-right: 5
      layout:
        type: grid
        cell-size: 160 90
        flow: true
        auto-spacing: true

  FlatPanel
    id: setupPanel
    height: 105
    enabled: false
    anchors.left: parent.left
    anchors.right: parent.horizontalCenter
    anchors.top: prev.bottom
    margin-top: 5
    margin-right: 5
    image-color: #ffffff88

    Label
      !text: tr('Name') .. ':'
      anchors.left: parent.left
      anchors.top: parent.top
      margin-top: 5
      margin-left: 5
      width: 85

    NPCOfferLabel
      id: name

    Label
      !text: tr('Id') .. ':'
      anchors.left: parent.left
      anchors.top: parent.top
      margin-top: 5
      margin-left: 5
      margin-left: 195
      width: 15

    NPCOfferLabel
      id: id

    Label
      !text: tr('Price') .. ':'
      anchors.left: parent.left
      anchors.top: prev.bottom
      margin-top: 3
      margin-left: 5
      width: 85

    NPCOfferLabel
      id: price

    Label
      !text: tr('Your Money') .. ':'
      anchors.left: parent.left
      anchors.top: prev.bottom
      margin-top: 3
      margin-left: 5
      width: 85

    NPCOfferLabel
      id: money

    Label
      id: weightDesc
      !text: tr('Weight') .. ':'
      anchors.left: parent.left
      anchors.top: prev.bottom
      margin-top: 3
      margin-left: 5
      width: 85

    NPCOfferLabel
      id: weight

    Label
      id: capacityDesc
      !text: tr('Your Capacity') .. ':'
      anchors.left: parent.left
      anchors.top: prev.bottom
      margin-top: 3
      margin-left: 5
      width: 85

    NPCOfferLabel
      id: capacity

    HorizontalScrollBar
      id: quantityScroll
      anchors.left: parent.left
      anchors.right: parent.right
      anchors.top: prev.bottom
      margin-top: 3
      margin-left: 5
      margin-right: 5
      show-value: true
      minimum: 1
      maximum: 100
      step: 1
      @onValueChange: modules.game_npctrade.onQuantityValueChange(self:getValue())

  FlatPanel
    id: buyOptions
    height: 80
    anchors.top: prev.top
    anchors.left: parent.horizontalCenter
    anchors.right: parent.right
    margin-left: 5
    image-color: #ffffff88

    Label
      id: searchLabel
      !text: tr('Search') .. ':'
      anchors.left: parent.left
      anchors.top: parent.top
      text-auto-resize: true
      margin-top: 7
      margin-left: 5

    TextEdit
      id: searchText
      anchors.left: prev.right
      anchors.top: prev.top
      anchors.right: parent.right
      margin-top: -2
      margin-left: 5
      margin-right: 5
      @onTextChange: modules.game_npctrade.onSearchTextChange()

    CheckBox
      id: buyWithBackpack
      !text: tr('Buy with backpack')
      anchors.top: searchText.bottom
      anchors.left: parent.left
      anchors.right: parent.right
      margin-left: 5
      margin-top: 3
      @onCheckChange: modules.game_npctrade.onBuyWithBackpackChange()

    CheckBox
      id: ignoreCapacity
      !text: tr('Ignore capacity')
      anchors.top: prev.bottom
      anchors.left: parent.left
      anchors.right: parent.right
      margin-left: 5
      margin-top: 3
      @onCheckChange: modules.game_npctrade.onIgnoreCapacityChange()

    CheckBox
      id: ignoreEquipped
      !text: tr('Ignore equipped')
      anchors.top: searchText.bottom
      anchors.left: parent.left
      anchors.right: parent.right
      margin-left: 5
      margin-top: 3
      visible: false
      checked: true
      @onCheckChange: modules.game_npctrade.onIgnoreEquippedChange()

    CheckBox
      id: showAllItems
      !text: tr('Show all items')
      anchors.top: prev.bottom
      anchors.left: parent.left
      anchors.right: parent.right
      margin-left: 5
      margin-top: 3
      visible: false
      checked: true
      @onCheckChange: modules.game_npctrade.onShowAllItemsChange()

  Button
    id: sellAllWithDelayButton
    !text: tr('Sell all with delay')
    width: 128
    anchors.right: next.left
    anchors.bottom: parent.bottom
    margin-right: 10
    visible: false
    @onClick: modules.game_npctrade.sellAll(true)

  Button
    id: sellAllButton
    !text: tr('Sell all')
    width: 64
    anchors.right: next.left
    anchors.bottom: parent.bottom
    margin-right: 10
    visible: false
    @onClick: modules.game_npctrade.sellAll()

  Button
    id: tradeButton
    !text: tr('Buy')
    width: 64
    anchors.right: next.left
    anchors.bottom: parent.bottom
    margin-right: 10
    @onClick: modules.game_npctrade.onTradeClick()

  Button
    !text: tr('Close')
    width: 64
    anchors.right: parent.right
    anchors.bottom: parent.bottom
    @onClick: modules.game_npctrade.closeNpcTrade()
