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
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:371Applies 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
nilID of the item whose stock has changed, nil if none has - stock Number/Boolean optional, defaults to
nilthe 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
falsetrue 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
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.
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
Places the scroll panel below the title.
Parameters
- w Number
- h Number
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
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
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 })