naev 0.11.5
land_outfits.c File Reference

Handles all the landing menus and actions. More...

#include "land_outfits.h"
#include "array.h"
#include "cond.h"
#include "dialogue.h"
#include "equipment.h"
#include "hook.h"
#include "log.h"
#include "map.h"
#include "map_find.h"
#include "nstring.h"
#include "nlua.h"
#include "outfit.h"
#include "pilot_outfit.h"
#include "player.h"
#include "player_gui.h"
#include "slots.h"
#include "space.h"
#include "toolkit.h"
#include "utf8.h"

Go to the source code of this file.

Data Structures

struct  LandOutfitData
 Data for handling the widget. More...
 

Macros

#define OUTFITS_IAR   "iarOutfits"
 
#define OUTFITS_TAB   "tabOutfits"
 
#define OUTFITS_FILTER   "inpFilterOutfits"
 
#define OUTFITS_NTABS   7
 

Functions

static void outfits_getSize (unsigned int wid, int *w, int *h, int *iw, int *ih, int *bw, int *bh)
 Gets the size of the outfits window.
 
static void outfits_buy (unsigned int wid, const char *str)
 Attempts to buy the outfit that is selected.
 
static void outfits_sell (unsigned int wid, const char *str)
 Attempts to sell the selected outfit the player has.
 
static int outfits_getMod (void)
 Gets the current modifier status.
 
static void outfits_rmouse (unsigned int wid, const char *widget_name)
 Player right-clicks on an outfit.
 
static void outfits_find (unsigned int wid, const char *str)
 Starts the map find with outfit search selected.
 
static const char * outfit_getPrice (const Outfit *outfit, credits_t *price, int *canbuy, int *cansell)
 Returns the price of an outfit (subject to quantity modifier)
 
static void outfit_Popdown (unsigned int wid, const char *str)
 
static void outfits_genList (unsigned int wid)
 Generates the outfit list.
 
static void outfits_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 void outfits_onClose (unsigned int wid, const char *str)
 For when the widget closes.
 
static void outfit_modifiers (unsigned int wid)
 
static int outfit_events (unsigned int wid, SDL_Event *evt)
 
void outfits_open (unsigned int wid, const Outfit **outfits, int blackmarket)
 Opens the outfit exchange center window.
 
void outfits_regenList (unsigned int wid, const char *str)
 Regenerates the outfit list.
 
static int outfitLand_filter (const Outfit *o)
 
static int outfitLand_filterWeapon (const Outfit *o)
 
static int outfitLand_filterUtility (const Outfit *o)
 
static int outfitLand_filterStructure (const Outfit *o)
 
static int outfitLand_filterCore (const Outfit *o)
 
void outfits_update (unsigned int wid, const char *str)
 Updates the outfits in the outfit window.
 
void outfits_updateEquipmentOutfits (void)
 Updates the outfitter and equipment outfit image arrays.
 
int outfits_filter (const Outfit **outfits, int n, int(*filter)(const Outfit *), const char *name)
 Applies a filter function and string to a list of outfits.
 
int outfit_altText (char *buf, int n, const Outfit *o, const Pilot *plt)
 Computes the alt text for an outfit.
 
ImageArrayCell * outfits_imageArrayCells (const Outfit **outfits, int *noutfits, const Pilot *p, int store)
 Generates image array cells corresponding to outfits.
 
static void outfit_PopdownSelect (unsigned int wid, const char *str)
 
static void outfit_PopdownActivate (unsigned int wid, const char *str)
 
static int outfit_isSold (const Outfit *outfit, int wid)
 
int outfit_canBuy (const Outfit *outfit, int wid)
 Checks to see if the player can buy the outfit.
 
int outfit_canSell (const Outfit *outfit)
 Checks to see if the player can sell the selected outfit.
 
void outfits_cleanup (void)
 Cleans up outfit globals.
 

Variables

static iar_data_t iar_data [OUTFITS_NTABS]
 
static Outfit ** iar_outfits [OUTFITS_NTABS]
 
static int outfit_Mode = 0
 
static PlayerOutfit_toutfits_sold = NULL
 
static int outfits_mod = 1
 

Detailed Description

Handles all the landing menus and actions.

Definition in file land_outfits.c.

Macro Definition Documentation

◆ OUTFITS_FILTER

#define OUTFITS_FILTER   "inpFilterOutfits"

Definition at line 40 of file land_outfits.c.

◆ OUTFITS_IAR

#define OUTFITS_IAR   "iarOutfits"

Definition at line 38 of file land_outfits.c.

◆ OUTFITS_NTABS

#define OUTFITS_NTABS   7

Definition at line 41 of file land_outfits.c.

◆ OUTFITS_TAB

#define OUTFITS_TAB   "tabOutfits"

Definition at line 39 of file land_outfits.c.

Function Documentation

◆ outfit_altText()

int outfit_altText ( char * buf,
int n,
const Outfit * o,
const Pilot * plt )

Computes the alt text for an outfit.

Definition at line 730 of file land_outfits.c.

◆ outfit_canBuy()

int outfit_canBuy ( const Outfit * outfit,
int wid )

Checks to see if the player can buy the outfit.

Parameters
outfitOutfit to buy.
widWindow ID of the outfitter (or -1 to ignore).

Definition at line 890 of file land_outfits.c.

◆ outfit_canSell()

int outfit_canSell ( const Outfit * outfit)

Checks to see if the player can sell the selected outfit.

Parameters
outfitOutfit to try to sell.

Definition at line 1082 of file land_outfits.c.

◆ outfit_events()

static int outfit_events ( unsigned int wid,
SDL_Event * evt )
static

Used to force rerenders.

Definition at line 127 of file land_outfits.c.

◆ outfit_getPrice()

static const char * outfit_getPrice ( const Outfit * outfit,
credits_t * price,
int * canbuy,
int * cansell )
static

Returns the price of an outfit (subject to quantity modifier)

Definition at line 693 of file land_outfits.c.

◆ outfit_isSold()

static int outfit_isSold ( const Outfit * outfit,
int wid )
static

Definition at line 868 of file land_outfits.c.

◆ outfit_modifiers()

static void outfit_modifiers ( unsigned int wid)
static

Definition at line 103 of file land_outfits.c.

◆ outfit_Popdown()

static void outfit_Popdown ( unsigned int wid,
const char * str )
static

Definition at line 838 of file land_outfits.c.

◆ outfit_PopdownActivate()

static void outfit_PopdownActivate ( unsigned int wid,
const char * str )
static

Definition at line 832 of file land_outfits.c.

◆ outfit_PopdownSelect()

static void outfit_PopdownSelect ( unsigned int wid,
const char * str )
static

Functions for the popdown menu (filter outfits by size)

Definition at line 822 of file land_outfits.c.

◆ outfitLand_filter()

static int outfitLand_filter ( const Outfit * o)
static

Ad-hoc filter functions.

Definition at line 287 of file land_outfits.c.

◆ outfitLand_filterCore()

static int outfitLand_filterCore ( const Outfit * o)
static

Definition at line 334 of file land_outfits.c.

◆ outfitLand_filterStructure()

static int outfitLand_filterStructure ( const Outfit * o)
static

Definition at line 331 of file land_outfits.c.

◆ outfitLand_filterUtility()

static int outfitLand_filterUtility ( const Outfit * o)
static

Definition at line 328 of file land_outfits.c.

◆ outfitLand_filterWeapon()

static int outfitLand_filterWeapon ( const Outfit * o)
static

Definition at line 325 of file land_outfits.c.

◆ outfits_buy()

static void outfits_buy ( unsigned int wid,
const char * str )
static

Attempts to buy the outfit that is selected.

Parameters
widWindow buying outfit from.
strUnused.

Definition at line 994 of file land_outfits.c.

◆ outfits_changeTab()

static void outfits_changeTab ( unsigned int wid,
const char * wgt,
int old,
int tab )
static

Ensures the tab's selected item is reflected in the ship slot list.

Parameters
widUnused.
wgtUnused.
oldTab changed from.
tabTab changed to.

Definition at line 620 of file land_outfits.c.

◆ outfits_cleanup()

void outfits_cleanup ( void )

Cleans up outfit globals.

Definition at line 1229 of file land_outfits.c.

◆ outfits_filter()

int outfits_filter ( const Outfit ** outfits,
int n,
int(* filter )(const Outfit *),
const char * name )

Applies a filter function and string to a list of outfits.

Parameters
outfitsArray of outfits to filter.
nNumber of outfits in the array.
filterFilter function to run on each outfit.
nameName fragment that each outfit name must contain.
Returns
Number of outfits.

Definition at line 654 of file land_outfits.c.

◆ outfits_find()

static void outfits_find ( unsigned int wid,
const char * str )
static

Starts the map find with outfit search selected.

Parameters
widWindow buying outfit from.
strUnused.

Definition at line 684 of file land_outfits.c.

◆ outfits_genList()

static void outfits_genList ( unsigned int wid)
static

Generates the outfit list.

Parameters
widWindow to generate the list on.

Definition at line 343 of file land_outfits.c.

◆ outfits_getMod()

static int outfits_getMod ( void )
static

Gets the current modifier status.

Returns
The amount modifier when buying or selling outfits.

Definition at line 1215 of file land_outfits.c.

◆ outfits_getSize()

static void outfits_getSize ( unsigned int wid,
int * w,
int * h,
int * iw,
int * ih,
int * bw,
int * bh )
static

Gets the size of the outfits window.

Definition at line 79 of file land_outfits.c.

◆ outfits_imageArrayCells()

ImageArrayCell * outfits_imageArrayCells ( const Outfit ** outfits,
int * noutfits,
const Pilot * p,
int store )

Generates image array cells corresponding to outfits.

Definition at line 763 of file land_outfits.c.

◆ outfits_onClose()

static void outfits_onClose ( unsigned int wid,
const char * str )
static

For when the widget closes.

Definition at line 138 of file land_outfits.c.

◆ outfits_open()

void outfits_open ( unsigned int wid,
const Outfit ** outfits,
int blackmarket )

Opens the outfit exchange center window.

Parameters
widWindow ID to open at.
outfitsArray (array.h): Outfits to sell. Will be freed. Set to NULL if this is the landed player store.
blackmarketWhether or not the outfit seller is a black market.

Definition at line 156 of file land_outfits.c.

◆ outfits_regenList()

void outfits_regenList ( unsigned int wid,
const char * str )

Regenerates the outfit list.

Parameters
widWindow to generate the list on.
strUnused.

Definition at line 250 of file land_outfits.c.

◆ outfits_rmouse()

static void outfits_rmouse ( unsigned int wid,
const char * widget_name )
static

Player right-clicks on an outfit.

Parameters
widWindow player is buying ship from.
widget_nameName of the window. (unused)

Definition at line 984 of file land_outfits.c.

◆ outfits_sell()

static void outfits_sell ( unsigned int wid,
const char * str )
static

Attempts to sell the selected outfit the player has.

Parameters
widWindow selling outfits from.
strUnused.

Definition at line 1129 of file land_outfits.c.

◆ outfits_update()

void outfits_update ( unsigned int wid,
const char * str )

Updates the outfits in the outfit window.

Parameters
widWindow to update the outfits in.
strUnused.

Definition at line 463 of file land_outfits.c.

◆ outfits_updateEquipmentOutfits()

void outfits_updateEquipmentOutfits ( void )

Updates the outfitter and equipment outfit image arrays.

Definition at line 596 of file land_outfits.c.

Variable Documentation

◆ iar_data

iar_data_t iar_data[OUTFITS_NTABS]
static

Stored image array positions.

Definition at line 50 of file land_outfits.c.

◆ iar_outfits

Outfit** iar_outfits[OUTFITS_NTABS]
static

C-array of Arrays: Outfits associated with the image array cells.

Definition at line 51 of file land_outfits.c.

◆ outfit_Mode

int outfit_Mode = 0
static

Outfit mode for filtering.

Definition at line 52 of file land_outfits.c.

◆ outfits_mod

int outfits_mod = 1
static

Definition at line 56 of file land_outfits.c.

◆ outfits_sold

PlayerOutfit_t* outfits_sold = NULL
static

List of the outfits the player sold so they can buy them back.

Definition at line 53 of file land_outfits.c.