The trade panel of a vendor (fl_vendor_trade) and the panels it is made of. The panel is a frame with two lists (fl_vendor_list) of rows (fl_vendor_row): what the vendor sells, with prices and stock, and the items of the local player that the vendor buys, with what it pays for them. The buttons of the rows ask the server to buy or to sell one item; the server answers with fresh contents for the panel, and tells the other customers of the vendor what has changed. Removing the panel tells the server that the trade is over.

A theme can draw the rows and the lists itself with PaintVendorRow(panel, w, h) and PaintVendorList(panel, w, h): returning anything but nil replaces the default drawing.

Summary

Methods

Adds a row to the end of the list.
Applies what a trade of another customer has changed, without rebuilding the lists: the money pool of the vendor and the stock of one item.
clear()client
Removes every row of the list.
Removes the panel.
Returns how far the list is scrolled down.
Returns the line below the name of an item that the vendor sells: its stock, or nothing if the stock is unlimited.
Returns the vendor that the panel trades with.
Init()client
Creates the icon and the button of the row.
Init()client
Creates the scroll panel that holds the rows.
Init()client
Creates the frame with the description of the vendor and the two lists.
Closes the panel when TAB or E is pressed, except right after it has opened, when the use key that opened it may still be held.
Tells the server that the trade is over, unless it was the server that closed the panel.
Draws the background of the row, the name of the item, the line below it and the price.
Draws the background and the title of the list, and a note in place of the rows if there are none.
Draws how much money the local player has and, if its money pool is finite, how much the vendor has.
Places the scroll panel below the title.
Places the description at the top and the two lists side by side below it, leaving room for the line about money at the bottom.
rebuild()client
Fills the list of what the vendor sells and the list of what it buys from the local player, where items of the same kind that fetch the same price share a row.
Makes the texts about the money of the local player and of the vendor again.
Replaces what the panel shows and rebuilds its lists.
Changes the line below the name.
Fills the row.
Scrolls the list.
Sets the title of the list and the note that is shown while it has no rows.
Sets the vendor that the panel trades with and what it shows.

Methods

Adds a row to the end of the list.

Parameters

  • data Map what the row shows, see the set_row function of fl_vendor_row

Returns

  • Panel the fl_vendor_row panel

PANEL:apply_change(money, item_id, stock)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:371

Applies what a trade of another customer has changed, without rebuilding the lists: the money pool of the vendor and the stock of one item.

Parameters

  • money Number/Boolean the money pool of the vendor, false if it is unlimited
  • item_id String optional, defaults to nil ID of the item whose stock has changed, nil if none has
  • stock Number/Boolean optional, defaults to nil the stock of that item, false if it is unlimited

Removes every row of the list.

Removes the panel.

Parameters

  • by_server Boolean optional, defaults to false true if the server has ended the trade, so that it is not told about it

Returns how far the list is scrolled down.

Returns

  • Number

PANEL:get_stock_text(entry)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:393

Returns the line below the name of an item that the vendor sells: its stock, or nothing if the stock is unlimited.

Parameters

  • entry Map the entry of the item in the trade data: id, price and stock

Returns

  • String

Returns the vendor that the panel trades with.

Returns

  • Entity

Creates the icon and the button of the row.

Creates the scroll panel that holds the rows.

Creates the frame with the description of the vendor and the two lists.

PANEL:OnKeyCodePressed(key)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:311

Closes the panel when TAB or E is pressed, except right after it has opened, when the use key that opened it may still be held.

Parameters

  • key Number KEY_ enumerator

Tells the server that the trade is over, unless it was the server that closed the panel.

Draws the background of the row, the name of the item, the line below it and the price.

Parameters

  • w Number
  • h Number

Draws the background and the title of the list, and a note in place of the rows if there are none.

Parameters

  • w Number
  • h Number

Draws how much money the local player has and, if its money pool is finite, how much the vendor has. The texts are made by refresh_money, not here.

Parameters

  • w Number
  • h Number

PANEL:PerformLayout(w, h)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:131

Places the scroll panel below the title.

Parameters

  • w Number
  • h Number

PANEL:PerformLayout(w, h)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:239

Places the description at the top and the two lists side by side below it, leaving room for the line about money at the bottom.

Parameters

  • w Number
  • h Number

Fills the list of what the vendor sells and the list of what it buys from the local player, where items of the same kind that fetch the same price share a row.

Makes the texts about the money of the local player and of the vendor again. Called when the panel gets new contents, when the money of the local player changes and when the language changes.

Replaces what the panel shows and rebuilds its lists.

Parameters

  • data Map trade data sent by the server, see set_vendor

Changes the line below the name.

Parameters

  • info String

Fills the row.

Parameters

  • data Map what the row shows: name, info (the line below the name) and price (String), tooltip (String), model (String) and skin (Number) of the icon, button_text (String) and on_click (Function called when the button is pressed)

Scrolls the list.

Parameters

  • offset Number

PANEL:set_texts(title, empty_text)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:173

Sets the title of the list and the note that is shown while it has no rows.

Parameters

  • title String text or language phrase
  • empty_text String text or language phrase

PANEL:set_vendor(vendor, data)

client plugins/vendors/plugin/views/cl_vendor_trade.lua:341

Sets the vendor that the panel trades with and what it shows.

Parameters

  • vendor Entity
  • data Map trade data sent by the server: name, description, currency, money, sells (List of { id, price, stock }) and buys (List of { instance_id, price })

Defined in