Defines | Functions | Variables

gui/player_shop.c File Reference

#include <include.h>

Go to the source code of this file.

Defines

#define COINS_ARRAY_SIZE   (int) (sizeof(coins) / sizeof(coins_struct))

Functions

static void shop_add_button (int x, int y, const char *text)
void widget_show_shop (widgetdata *widget)
void shop_open ()
void shop_buy_item ()
void initialize_shop (int shop_state)
void clear_shop (int send_to_server)
void shop_add_close_button (int x, int y)
int shop_put_item (int x, int y)
void shop_object_remove (sint32 tag)
int check_shop_keys (SDL_KeyboardEvent *key)
char * shop_show_input (char *text, struct _Font *font, int wlen, int append_underscore)
int shop_price2int (char *text)
char * shop_int2price (int value)

Variables

_shop_gui_structshop_gui = NULL
coins_struct coins []

Detailed Description

Handles the player shop GUI code.

Definition in file player_shop.c.


Define Documentation

#define COINS_ARRAY_SIZE   (int) (sizeof(coins) / sizeof(coins_struct))

Size of the coin types array

Definition at line 47 of file player_shop.c.


Function Documentation

int check_shop_keys ( SDL_KeyboardEvent *  key  ) 

Handle key presses if shop widget is open.

Parameters:
key SDL Keyboard event
Returns:
1 if we did something with the keypress and do not want the caller function to do any other handling for the event, 0 otherwise

Definition at line 736 of file player_shop.c.

void clear_shop ( int  send_to_server  ) 

Clear and deinitialize shop GUI.

Parameters:
send_to_server Whether to send a command to the server to free and close the shop.

Definition at line 415 of file player_shop.c.

void initialize_shop ( int  shop_state  ) 

Initialize the shop GUI.

Parameters:
shop_state Shop state. See shop state declarations for possible values.

Definition at line 376 of file player_shop.c.

static void shop_add_button ( int  x,
int  y,
const char *  text 
) [static]

Add a button in the shop GUI.

Parameters:
x X position of the button
y Y position of the button
text Text of the button

Definition at line 500 of file player_shop.c.

void shop_add_close_button ( int  x,
int  y 
)

Add a close button.

Parameters:
x X position of the button
y Y position of the button

Definition at line 455 of file player_shop.c.

void shop_buy_item (  ) 

Buy a shop item.

Definition at line 331 of file player_shop.c.

char* shop_int2price ( int  value  ) 

Does the reverse of shop_price2int().

Parameters:
value Integer value to parse
Returns:
String representation of the given integer value

Definition at line 1079 of file player_shop.c.

void shop_object_remove ( sint32  tag  ) 

Remove an item from the linked list of shop items.

Parameters:
tag Tag of the item to remove.

Definition at line 688 of file player_shop.c.

void shop_open (  ) 

Open the player shop.

Definition at line 275 of file player_shop.c.

int shop_price2int ( char *  text  ) 

Parse a price string from the shop interface to an integer.

For example, the string

10 m 15 g 90 s 40 c

would become

100159040
Parameters:
text The string to parse
Returns:
An integer representation of the price string.

Definition at line 1020 of file player_shop.c.

int shop_put_item ( int  x,
int  y 
)

Put an item to the shop GUI. Called when dropping a dragged item.

Parameters:
x X position of the item
y Y position of the item
Returns:
1 if the XY positions were within the shop GUI, 0 otherwise

Definition at line 573 of file player_shop.c.

char* shop_show_input ( char *  text,
struct _Font font,
int  wlen,
int  append_underscore 
)

Show shop input text and calculate the maximum width the string can have so the text doesn't overflow the input area.

Parameters:
text The input text
font Font used to display the text
wlen Maximum width of the text
append_underscore Whether to append underscore at the end of the input text.
Returns:
Char pointer to the string to display

Definition at line 957 of file player_shop.c.

void widget_show_shop ( widgetdata widget  ) 

Show the shop GUI widget.

Parameters:
x X position of the widget
y Y position of the widget

Definition at line 55 of file player_shop.c.


Variable Documentation

Initial value:
{
    {"m",   10000000},
    {"g",   10000},
    {"s",   100},
    {"c",   1},
}

Array of all possible coin types, including the coin value and name. Used by shop_int2price() and shop_price2int().

Definition at line 38 of file player_shop.c.

The shop GUI.

Definition at line 33 of file player_shop.c.