![]() |
naev 0.12.5
|
Handles equipping ships. More...
#include "equipment.h"#include "array.h"#include "conf.h"#include "debug.h"#include "dialogue.h"#include "escort.h"#include "gui.h"#include "hook.h"#include "info.h"#include "land.h"#include "land_outfits.h"#include "log.h"#include "ndata.h"#include "nlua.h"#include "nlua_tk.h"#include "nstring.h"#include "ntime.h"#include "pilot_outfit.h"#include "player.h"#include "player_fleet.h"#include "shipstats.h"#include "slots.h"#include "tk/toolkit_priv.h"#include "toolkit.h"
Go to the source code of this file.
Data Structures | |
| struct | ShipWidgetData |
Macros | |
| #define | EQUIPMENT_SHIPS "iarAvailShips" |
| #define | EQUIPMENT_OUTFIT_TAB "tabOutfits" |
| #define | EQUIPMENT_OUTFITS "iarAvailOutfits" |
| #define | EQUIPMENT_FILTER "inpFilterOutfits" |
| #define | OUTFIT_TABS 5 |
| #define | BUTTON_WIDTH 200 |
| #define | BUTTON_HEIGHT 40 |
| #define | EQ_COMP(cur, base, inv) |
| #define | EQ_COMP_I(cur, base, inv) |
Functions | |
| static void | equipment_getDim (unsigned int wid, int *w, int *h, int *sw, int *sh, int *ow, int *oh, int *ew, int *eh, int *cw, int *ch, int *bw, int *bh) |
| Gets the window dimensions. | |
| static void | equipment_genShipList (unsigned int wid) |
| Generates the ship list. | |
| static void | equipment_genOutfitList (unsigned int wid) |
| Generates the outfit list. | |
| static void | equipment_genLists (unsigned int wid) |
| Generates a new ship/outfit lists if needed. | |
| static void | equipment_toggleFav (unsigned int wid, const char *wgt) |
| Handles toggling of the favourite checkbox. | |
| static void | equipment_toggleDeploy (unsigned int wid, const char *wgt) |
| static void | equipment_renderColumn (double x, double y, double w, double h, const PilotOutfitSlot *lst, const char *txt, int selected, Outfit *o, Pilot *p, const CstSlotWidget *wgt) |
| Renders an outfit column. | |
| static void | equipment_renderSlots (double bx, double by, double bw, double bh, void *data) |
| Renders the equipment slots. | |
| static void | equipment_renderMisc (double bx, double by, double bw, double bh, void *data) |
| Renders the custom equipment widget. | |
| static void | equipment_renderOverlayColumn (double x, double y, double h, PilotOutfitSlot *lst, int mover, CstSlotWidget *wgt) |
| Renders an outfit column. | |
| static void | equipment_renderOverlaySlots (double bx, double by, double bw, double bh, void *data) |
| Renders the equipment overlay. | |
| static void | equipment_renderShip (double bx, double by, double bw, double bh, void *data) |
| Renders the ship in the equipment window. | |
| static void | equipment_freeShipData (unsigned int wid, const char *unused) |
| static int | equipment_mouseInColumn (const PilotOutfitSlot *lst, double y, double h, double my) |
| Handles a mouse press in column. | |
| static int | equipment_mouseSlots (unsigned int wid, const SDL_Event *event, double mx, double my, double bw, double bh, double rx, double ry, void *data) |
| Does mouse input for the custom equipment widget. | |
| static char | eq_qCol (double cur, double base, int inv) |
| Gets the colour for comparing a current value vs a ship base value. | |
| static int | equipment_swapSlot (unsigned int wid, Pilot *p, PilotOutfitSlot *slot) |
| Swaps an equipment slot. | |
| static void | equipment_sellShip (unsigned int wid, const char *str) |
| Player tries to sell a ship. | |
| static void | equipment_renameShip (unsigned int wid, const char *str) |
| Renames the selected ship. | |
| static void | equipment_shipMode (unsigned int wid, const char *str) |
| Toggles the ship visualization mode. | |
| static void | equipment_rightClickShips (unsigned int wid, const char *str) |
| Toggles deployed status. | |
| static void | equipment_transChangeShip (unsigned int wid, const char *str) |
| Changes ship. | |
| static void | equipment_changeShip (unsigned int wid) |
| Player attempts to change ship. | |
| static void | equipment_unequipShip (unsigned int wid, const char *str) |
| Unequips the player's ship. | |
| static void | equipment_autoequipShip (unsigned int wid, const char *str) |
| Does the autoequip magic on the player's ship. | |
| static void | equipment_filterOutfits (unsigned int wid, const char *str) |
| Handles text input in the filter input widget. | |
| static void | equipment_rightClickOutfits (unsigned int wid, const char *str) |
| Handles right-click on unequipped outfit. | |
| static void | equipment_outfitPopdown (unsigned int wid, const char *str) |
| static void | equipment_changeTab (unsigned int wid, const char *wgt, int old, int tab) |
| Ensures the tab's selected item is reflected in the ship slot list. | |
| static int | equipment_playerAddOutfit (const Outfit *o, int quantity) |
| Wrapper to only add unique outfits. | |
| static int | equipment_playerRmOutfit (const Outfit *o, int quantity) |
| Wrapper to only remove unique outfits. | |
| static int | equipment_filter (const Outfit *o) |
| static int | equipment_filterWeapon (const Outfit *o) |
| static int | equipment_filterUtility (const Outfit *o) |
| static int | equipment_filterStructure (const Outfit *o) |
| static int | equipment_filterCore (const Outfit *o) |
| void | equipment_open (unsigned int wid) |
| Opens the player's equipment window. | |
| void | equipment_slotWidget (unsigned int wid, double x, double y, double w, double h, CstSlotWidget *data) |
| Creates the slot widget and initializes it. | |
| static void | equipment_calculateSlots (const Pilot *p, double bw, double bh, double *w, double *h, int *n, int *m) |
| Calculates the size the slots need to be for a given window. | |
| static int | equipment_mouseColumn (unsigned int wid, const SDL_Event *event, double mx, double my, double y, double h, PilotOutfitSlot *os, Pilot *p, int selected, CstSlotWidget *wgt) |
| Handles a mouse press in a column. | |
| void | equipment_regenLists (unsigned int wid, int outfits, int ships) |
| Regenerates the equipment window lists. | |
| int | equipment_canSellPlayerShip (const char *shipname) |
| Makes sure it's valid to sell a ship. | |
| int | equipment_canSwapPlayerShip (const char *shipname) |
| Makes sure it's valid to change ships in the equipment view. | |
| void | equipment_addAmmo (void) |
| Adds all the ammo it can to the player. | |
| int | equipment_shipStats (char *buf, int max_len, const Pilot *s, int dpseps, int name) |
| Creates and allocates a string containing the ship stats. | |
| static const char * | eq_qSym (double cur, double base, int inv) |
| Gets the symbol for comparing a current value vs a ship base value. | |
| void | equipment_updateShips (unsigned int wid, const char *str) |
| Updates the player's ship window. | |
| void | equipment_updateOutfits (unsigned int wid, const char *str) |
| Updates the player's outfit list. | |
| static void | equipment_outfitPopdownSelect (unsigned int wid, const char *str) |
| static void | equipment_outfitPopdownActivate (unsigned int wid, const char *str) |
| void | equipment_cleanup (void) |
| Cleans up after the equipment stuff. | |
| void | equipment_slotDeselect (CstSlotWidget *wgt) |
| Deselects equipment stuff. | |
| void | equipment_slotSelect (CstSlotWidget *wgt, PlayerShip_t *p) |
Variables | |
| static CstSlotWidget | eq_wgt |
| static double | equipment_dir = 0. |
| static unsigned int | equipment_lastick = 0 |
| static unsigned int | equipment_wid = 0 |
| static int | equipment_creating = 0 |
| static int | ship_mode = 0 |
| static iar_data_t | iar_data [OUTFIT_TABS] |
| static Outfit ** | iar_outfits [OUTFIT_TABS] |
| static nlua_env | autoequip_env = LUA_NOREF |
| static int | equipment_outfitMode = 0 |
| static int(* | tabfilters [])(const Outfit *o) |
Handles equipping ships.
Definition in file equipment.c.
| #define BUTTON_HEIGHT 40 |
Default button height.
Definition at line 55 of file equipment.c.
| #define BUTTON_WIDTH 200 |
Default button width.
Definition at line 54 of file equipment.c.
| #define EQ_COMP | ( | cur, | |
| base, | |||
| inv ) |
Definition at line 1983 of file equipment.c.
| #define EQ_COMP_I | ( | cur, | |
| base, | |||
| inv ) |
Definition at line 1985 of file equipment.c.
| #define EQUIPMENT_FILTER "inpFilterOutfits" |
Definition at line 50 of file equipment.c.
| #define EQUIPMENT_OUTFIT_TAB "tabOutfits" |
Definition at line 48 of file equipment.c.
| #define EQUIPMENT_OUTFITS "iarAvailOutfits" |
Definition at line 49 of file equipment.c.
| #define EQUIPMENT_SHIPS "iarAvailShips" |
Definition at line 47 of file equipment.c.
| #define OUTFIT_TABS 5 |
Definition at line 51 of file equipment.c.
|
static |
Gets the colour for comparing a current value vs a ship base value.
Definition at line 1962 of file equipment.c.
|
static |
Gets the symbol for comparing a current value vs a ship base value.
Definition at line 1974 of file equipment.c.
| void equipment_addAmmo | ( | void | ) |
Adds all the ammo it can to the player.
Definition at line 1578 of file equipment.c.
|
static |
Does the autoequip magic on the player's ship.
Definition at line 2608 of file equipment.c.
|
static |
Calculates the size the slots need to be for a given window.
| p | Pilot to calculate the slots of. |
| bw | Base widget width. |
| bh | Base window height. |
| w | Width to use. |
| h | Height to use. |
| n | Number of columns. |
| m | Number of rows. |
Definition at line 598 of file equipment.c.
| int equipment_canSellPlayerShip | ( | const char * | shipname | ) |
Makes sure it's valid to sell a ship.
| shipname | Ship being sold. |
Definition at line 1500 of file equipment.c.
| int equipment_canSwapPlayerShip | ( | const char * | shipname | ) |
Makes sure it's valid to change ships in the equipment view.
| shipname | Ship being changed to. |
Definition at line 1516 of file equipment.c.
|
static |
Player attempts to change ship.
| wid | Window player is attempting to change ships in. |
Definition at line 2476 of file equipment.c.
|
static |
Ensures the tab's selected item is reflected in the ship slot list.
| wid | Unused. |
| wgt | Unused. |
| old | Tab changed from. |
| tab | Tab changed to. |
Definition at line 2395 of file equipment.c.
| void equipment_cleanup | ( | void | ) |
Cleans up after the equipment stuff.
Definition at line 2810 of file equipment.c.
|
static |
Definition at line 1789 of file equipment.c.
|
static |
Definition at line 1847 of file equipment.c.
|
static |
Handles text input in the filter input widget.
| wid | Window containing the widget. |
| str | Unused. |
Definition at line 2328 of file equipment.c.
|
static |
Definition at line 1843 of file equipment.c.
|
static |
Definition at line 1839 of file equipment.c.
|
static |
Definition at line 1835 of file equipment.c.
|
static |
Definition at line 1080 of file equipment.c.
|
static |
Generates a new ship/outfit lists if needed.
| wid | Parent window id. |
Definition at line 1683 of file equipment.c.
|
static |
Generates the outfit list.
| wid | Window to generate list on. |
Definition at line 1856 of file equipment.c.
|
static |
Generates the ship list.
| wid | Window to generate list on. |
Definition at line 1693 of file equipment.c.
|
static |
Gets the window dimensions.
Definition at line 286 of file equipment.c.
|
static |
Handles a mouse press in a column.
| wid | Parent window id. |
| event | Mouse input event. |
| mx | Mouse X event position. |
| my | Mouse Y event position. |
| y | Y position of the column. |
| h | Height of the column. |
| os | Array (array.h) of elements in the column. |
| p | Pilot to which the elements belong. |
| selected | Currently selected element. |
| wgt | Slot widget. |
Definition at line 1130 of file equipment.c.
|
static |
Handles a mouse press in column.
| lst | List of items in the column. |
| y | Y position of the column. |
| h | Height of column. |
| my | Mouse press position. |
Definition at line 1099 of file equipment.c.
|
static |
Does mouse input for the custom equipment widget.
| wid | Parent window id. |
| event | Mouse input event. |
| mx | Mouse X event position. |
| my | Mouse Y event position. |
| bw | Base window width. |
| bh | Base window height. |
| rx | Relative X movement (only valid for motion). |
| ry | Relative Y movement (only valid for motion). |
| data | Custom widget data. |
Definition at line 1244 of file equipment.c.
| void equipment_open | ( | unsigned int | wid | ) |
Opens the player's equipment window.
Definition at line 329 of file equipment.c.
|
static |
Definition at line 2355 of file equipment.c.
|
static |
Definition at line 2349 of file equipment.c.
|
static |
Functions for the popdown menu (filter outfits by size)
Definition at line 2338 of file equipment.c.
|
static |
Wrapper to only add unique outfits.
Definition at line 2789 of file equipment.c.
|
static |
Wrapper to only remove unique outfits.
Definition at line 2800 of file equipment.c.
| void equipment_regenLists | ( | unsigned int | wid, |
| int | outfits, | ||
| int | ships ) |
Regenerates the equipment window lists.
| wid | Window to regenerate lists. |
| outfits | Whether or not should regenerate outfits list. |
| ships | Whether or not to regenerate ships list. |
Definition at line 1429 of file equipment.c.
|
static |
Renames the selected ship.
| wid | Parent window id. |
| str | Unused. |
Definition at line 2748 of file equipment.c.
|
static |
Renders an outfit column.
Definition at line 478 of file equipment.c.
|
static |
Renders the custom equipment widget.
| bx | Base X position of the widget. |
| by | Base Y position of the widget. |
| bw | Width of the widget. |
| bh | Height of the widget. |
| data | Custom widget data. |
Definition at line 682 of file equipment.c.
|
static |
Renders an outfit column.
| x | X position to render at. |
| y | Y position to render at. |
| h | Height. |
| lst | Array (array.h) of elements. |
| mover | Slot for which mouseover is active |
| wgt | Widget rendering. |
Definition at line 772 of file equipment.c.
|
static |
Renders the equipment overlay.
| bx | Base X position of the widget. |
| by | Base Y position of the widget. |
| bw | Width of the widget. |
| bh | Height of the widget. |
| data | Custom widget data. |
Definition at line 859 of file equipment.c.
|
static |
Renders the ship in the equipment window.
| bx | Base X position of the widget. |
| by | Base Y position of the widget. |
| bw | Width of the widget. |
| bh | Height of the widget. |
| data | Unused. |
Definition at line 959 of file equipment.c.
|
static |
Renders the equipment slots.
| bx | Base X position of the widget. |
| by | Base Y position of the widget. |
| bw | Width of the widget. |
| bh | Height of the widget. |
| data | Custom widget data. |
Definition at line 629 of file equipment.c.
|
static |
Handles right-click on unequipped outfit.
| wid | Window to update. |
| str | Widget name. Must be EQUIPMENT_OUTFITS. |
Definition at line 150 of file equipment.c.
|
static |
Toggles deployed status.
Definition at line 2424 of file equipment.c.
|
static |
Player tries to sell a ship.
| wid | Window player is selling ships in. |
| str | Unused. |
Definition at line 2681 of file equipment.c.
|
static |
Toggles the ship visualization mode.
Definition at line 2780 of file equipment.c.
| int equipment_shipStats | ( | char * | buf, |
| int | max_len, | ||
| const Pilot * | s, | ||
| int | dpseps, | ||
| int | name ) |
Creates and allocates a string containing the ship stats.
| buf | Buffer to write to. |
| max_len | Maximum length of the string to allocate. |
| s | Pilot to get stats of. |
| dpseps | Whether or not to display dps and eps. |
| name | Whether or not to display the pilot name. |
Definition at line 1604 of file equipment.c.
| void equipment_slotDeselect | ( | CstSlotWidget * | wgt | ) |
Deselects equipment stuff.
Definition at line 2823 of file equipment.c.
| void equipment_slotSelect | ( | CstSlotWidget * | wgt, |
| PlayerShip_t * | p ) |
Definition at line 2834 of file equipment.c.
| void equipment_slotWidget | ( | unsigned int | wid, |
| double | x, | ||
| double | y, | ||
| double | w, | ||
| double | h, | ||
| CstSlotWidget * | data ) |
Creates the slot widget and initializes it.
| wid | Parent window id. |
| x | X position to put it at. |
| y | Y position to put it at. |
| w | Width. |
| h | Height; |
| data | Dataset to use. |
Definition at line 462 of file equipment.c.
|
static |
Swaps an equipment slot.
| wid | Parent window id. |
| p | Pilot swapping slots. |
| slot | Slot to swap. |
Definition at line 1319 of file equipment.c.
|
static |
Definition at line 1651 of file equipment.c.
|
static |
Handles toggling of the favourite checkbox.
Definition at line 1636 of file equipment.c.
|
static |
Changes ship.
| wid | Window player is attempting to change ships in. |
| str | Unused. |
Definition at line 2463 of file equipment.c.
|
static |
Unequips the player's ship.
| wid | Window id. |
| str | of widget. |
Definition at line 2532 of file equipment.c.
| void equipment_updateOutfits | ( | unsigned int | wid, |
| const char * | str ) |
Updates the player's outfit list.
| wid | Window to update. |
| str | Unused. |
Definition at line 2307 of file equipment.c.
| void equipment_updateShips | ( | unsigned int | wid, |
| const char * | str ) |
Updates the player's ship window.
| wid | Window to update. |
| str | Unused. |
Definition at line 1992 of file equipment.c.
|
static |
Definition at line 77 of file equipment.c.
|
static |
Equipment widget.
Definition at line 68 of file equipment.c.
|
static |
Whether or not creating.
Definition at line 72 of file equipment.c.
|
static |
Equipment dir.
Definition at line 69 of file equipment.c.
|
static |
Last tick.
Definition at line 70 of file equipment.c.
|
static |
Outfit mode for filtering.
Definition at line 78 of file equipment.c.
|
static |
Global wid.
Definition at line 71 of file equipment.c.
|
static |
Stored image array positions.
Definition at line 74 of file equipment.c.
|
static |
Outfits associated with the image array cells.
Definition at line 75 of file equipment.c.
|
static |
Ship mode.
Definition at line 73 of file equipment.c.
Definition at line 140 of file equipment.c.