![]() |
naev 0.10.4
|
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 "map.h"#include "mission.h"#include "ndata.h"#include "nstring.h"#include "nlua.h"#include "nlua_tk.h"#include "ntime.h"#include "player.h"#include "player_fleet.h"#include "pilot_outfit.h"#include "shipstats.h"#include "slots.h"#include "tk/toolkit_priv.h"#include "toolkit.h"Go to the source code of this file.
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) eq_qCol( cur, base, inv ), eq_qSym( cur, base, inv ), cur |
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. More... | |
| static void | equipment_genShipList (unsigned int wid) |
| Generates the ship list. More... | |
| static void | equipment_genOutfitList (unsigned int wid) |
| Generates the outfit list. More... | |
| static void | equipment_genLists (unsigned int wid) |
| Generates a new ship/outfit lists if needed. More... | |
| static void | equipment_toggleFav (unsigned int wid, const char *wgt) |
| Handles toggling of the favourite checkbox. More... | |
| static void | equipment_toggleDeploy (unsigned int wid, const char *wgt) |
| static void | equipment_renderColumn (double x, double y, double w, double h, PilotOutfitSlot *lst, const char *txt, int selected, Outfit *o, Pilot *p, CstSlotWidget *wgt) |
| Renders an outfit column. More... | |
| static void | equipment_renderSlots (double bx, double by, double bw, double bh, void *data) |
| Renders the equipment slots. More... | |
| static void | equipment_renderMisc (double bx, double by, double bw, double bh, void *data) |
| Renders the custom equipment widget. More... | |
| static void | equipment_renderOverlayColumn (double x, double y, double h, PilotOutfitSlot *lst, int mover, CstSlotWidget *wgt) |
| Renders an outfit column. More... | |
| static void | equipment_renderOverlaySlots (double bx, double by, double bw, double bh, void *data) |
| Renders the equipment overlay. More... | |
| static void | equipment_renderShip (double bx, double by, double bw, double bh, void *data) |
| Renders the ship in the equipment window. More... | |
| static int | equipment_mouseInColumn (double y, double h, int n, double my) |
| Handles a mouse press in column. More... | |
| static int | equipment_mouseSlots (unsigned int wid, 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. More... | |
| static char | eq_qCol (double cur, double base, int inv) |
| Gets the colour for comparing a current value vs a ship base value. More... | |
| static int | equipment_swapSlot (unsigned int wid, Pilot *p, PilotOutfitSlot *slot) |
| Swaps an equipment slot. More... | |
| static void | equipment_sellShip (unsigned int wid, const char *str) |
| Player tries to sell a ship. More... | |
| static void | equipment_renameShip (unsigned int wid, const char *str) |
| Renames the selected ship. More... | |
| static void | equipment_shipMode (unsigned int wid, const char *str) |
| Toggles the ship visualization mode. More... | |
| static void | equipment_rightClickShips (unsigned int wid, const char *str) |
| Toggles deployed status. More... | |
| static void | equipment_transChangeShip (unsigned int wid, const char *str) |
| Changes ship. More... | |
| static void | equipment_changeShip (unsigned int wid) |
| Player attempts to change ship. More... | |
| static void | equipment_unequipShip (unsigned int wid, const char *str) |
| Unequips the player's ship. More... | |
| static void | equipment_autoequipShip (unsigned int wid, const char *str) |
| Does the autoequip magic on the player's ship. More... | |
| static void | equipment_filterOutfits (unsigned int wid, const char *str) |
| Handles text input in the filter input widget. More... | |
| static void | equipment_rightClickOutfits (unsigned int wid, const char *str) |
| Handles right-click on unequipped outfit. More... | |
| 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. More... | |
| static int | equipment_playerAddOutfit (const Outfit *o, int quantity) |
| Wrapper to only add unique outfits. More... | |
| static int | equipment_playerRmOutfit (const Outfit *o, int quantity) |
| Wrapper to only remove unique outfits. More... | |
| void | equipment_open (unsigned int wid) |
| Opens the player's equipment window. More... | |
| void | equipment_slotWidget (unsigned int wid, double x, double y, double w, double h, CstSlotWidget *data) |
| Creates the slot widget and initializes it. More... | |
| 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. More... | |
| static int | equipment_mouseColumn (unsigned int wid, 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. More... | |
| void | equipment_regenLists (unsigned int wid, int outfits, int ships) |
| Regenerates the equipment window lists. More... | |
| void | equipment_addAmmo (void) |
| Adds all the ammo it can to the player. More... | |
| int | equipment_shipStats (char *buf, int max_len, const Pilot *s, int dpseps, int name) |
| Creates and allocates a string containing the ship stats. More... | |
| 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) |
| static const char * | eq_qSym (double cur, double base, int inv) |
| Gets the symbol for comparing a current value vs a ship base value. More... | |
| void | equipment_updateShips (unsigned int wid, const char *str) |
| Updates the player's ship window. More... | |
| void | equipment_updateOutfits (unsigned int wid, const char *str) |
| Updates the player's outfit list. More... | |
| 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. More... | |
| void | equipment_slotDeselect (CstSlotWidget *wgt) |
| Deselects equipment stuff. More... | |
Variables | |
| static CstSlotWidget | eq_wgt |
| static double | equipment_dir = 0. |
| static unsigned int | equipment_lastick = 0 |
| static unsigned int | equipment_wid = 0 |
| static int | ship_mode = 0 |
| static iar_data_t * | iar_data = NULL |
| static Outfit *** | iar_outfits = NULL |
| static nlua_env | autoequip_env = LUA_NOREF |
| static int | equipment_outfitMode = 0 |
Handles equipping ships.
Definition in file equipment.c.
| #define BUTTON_HEIGHT 40 |
Default button height.
Definition at line 56 of file equipment.c.
| #define BUTTON_WIDTH 200 |
Default button width.
Definition at line 55 of file equipment.c.
Definition at line 1691 of file equipment.c.
| #define EQUIPMENT_FILTER "inpFilterOutfits" |
Definition at line 51 of file equipment.c.
| #define EQUIPMENT_OUTFIT_TAB "tabOutfits" |
Definition at line 49 of file equipment.c.
| #define EQUIPMENT_OUTFITS "iarAvailOutfits" |
Definition at line 50 of file equipment.c.
| #define EQUIPMENT_SHIPS "iarAvailShips" |
Definition at line 48 of file equipment.c.
| #define OUTFIT_TABS 5 |
Definition at line 52 of file equipment.c.
|
static |
Gets the colour for comparing a current value vs a ship base value.
Definition at line 1670 of file equipment.c.
|
static |
Gets the symbol for comparing a current value vs a ship base value.
Definition at line 1682 of file equipment.c.
| void equipment_addAmmo | ( | void | ) |
Adds all the ammo it can to the player.
Definition at line 1301 of file equipment.c.
|
static |
Does the autoequip magic on the player's ship.
Definition at line 2210 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 539 of file equipment.c.
|
static |
Player attempts to change ship.
| wid | Window player is attempting to change ships in. |
Definition at line 2083 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 1999 of file equipment.c.
| void equipment_cleanup | ( | void | ) |
Cleans up after the equipment stuff.
Definition at line 2396 of file equipment.c.
|
static |
Definition at line 1507 of file equipment.c.
|
static |
Definition at line 1556 of file equipment.c.
|
static |
Handles text input in the filter input widget.
| wid | Window containing the widget. |
| str | Unused. |
Definition at line 1934 of file equipment.c.
|
static |
Definition at line 1553 of file equipment.c.
|
static |
Definition at line 1550 of file equipment.c.
|
static |
Definition at line 1547 of file equipment.c.
|
static |
Generates a new ship/outfit lists if needed.
| wid | Parent window id. |
Definition at line 1401 of file equipment.c.
|
static |
Generates the outfit list.
| wid | Window to generate list on. |
Definition at line 1564 of file equipment.c.
|
static |
Generates the ship list.
| wid | Window to generate list on. |
Definition at line 1418 of file equipment.c.
|
static |
Gets the window dimensions.
Definition at line 255 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 1000 of file equipment.c.
|
static |
Handles a mouse press in column.
| y | Y position of the column. |
| h | Height of column. |
| n | Number of elements in column. |
| my | Mouse press position. |
Definition at line 976 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 1080 of file equipment.c.
| void equipment_open | ( | unsigned int | wid | ) |
Opens the player's equipment window.
Definition at line 298 of file equipment.c.
|
static |
Definition at line 1961 of file equipment.c.
|
static |
Definition at line 1955 of file equipment.c.
|
static |
Functions for the popdown menu (filter outfits by size)
Definition at line 1944 of file equipment.c.
|
static |
Wrapper to only add unique outfits.
Definition at line 2376 of file equipment.c.
|
static |
Wrapper to only remove unique outfits.
Definition at line 2386 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 1235 of file equipment.c.
|
static |
Renames the selected ship.
| wid | Parent window id. |
| str | Unused. |
Definition at line 2337 of file equipment.c.
|
static |
Renders an outfit column.
Definition at line 444 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 623 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 697 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 781 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 889 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 568 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 121 of file equipment.c.
|
static |
Toggles deployed status.
Definition at line 2031 of file equipment.c.
|
static |
Player tries to sell a ship.
| wid | Window player is selling ships in. |
| str | Unused. |
Definition at line 2281 of file equipment.c.
|
static |
Toggles the ship visualization mode.
Definition at line 2367 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 1327 of file equipment.c.
| void equipment_slotDeselect | ( | CstSlotWidget * | wgt | ) |
Deselects equipment stuff.
Definition at line 2414 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 427 of file equipment.c.
|
static |
Swaps an equipment slot.
| wid | Parent window id. |
| p | Pilot swapping slots. |
| slot | Slot to swap. |
Definition at line 1155 of file equipment.c.
|
static |
Definition at line 1369 of file equipment.c.
|
static |
Handles toggling of the favourite checkbox.
Definition at line 1353 of file equipment.c.
|
static |
Changes ship.
| wid | Window player is attempting to change ships in. |
| str | Unused. |
Definition at line 2070 of file equipment.c.
|
static |
Unequips the player's ship.
| wid | Window id. |
| str | of widget. |
Definition at line 2138 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 1913 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 1698 of file equipment.c.
|
static |
Definition at line 68 of file equipment.c.
|
static |
Equipment widget.
Definition at line 61 of file equipment.c.
|
static |
Equipment dir.
Definition at line 62 of file equipment.c.
|
static |
Last tick.
Definition at line 63 of file equipment.c.
|
static |
Outfit mode for filtering.
Definition at line 69 of file equipment.c.
|
static |
Global wid.
Definition at line 64 of file equipment.c.
|
static |
Stored image array positions.
Definition at line 66 of file equipment.c.
|
static |
Outfits associated with the image array cells.
Definition at line 67 of file equipment.c.
|
static |
Ship mode.
Definition at line 65 of file equipment.c.