Atrinik Client 2.5
Defines | Functions | Variables
gui/map.c File Reference
#include <global.h>

Go to the source code of this file.

Defines

#define MAP_NAME_FONT   FONT_SERIF14
#define MAX_STRETCH   8
#define MAX_STRETCH_DIAG   12

Functions

void load_mapdef_dat ()
void widget_show_mapname (widgetdata *widget)
void clear_map ()
void display_mapscroll (int dx, int dy)
void update_map_name (const char *name)
void update_map_weather (const char *weather)
void init_map_data (int xl, int yl, int px, int py)
static int calc_map_cell_height (int x, int y)
void align_tile_stretch (int x, int y)
void adjust_tile_stretch ()
void map_set_data (int x, int y, int layer, sint16 face, uint8 quick_pos, uint8 obj_flags, const char *name, const char *name_color, sint16 height, uint8 probe, sint16 zoom, sint16 align, uint8 draw_double, uint8 alpha, sint16 rotate, uint8 infravision)
void map_clear_cell (int x, int y)
void map_set_darkness (int x, int y, uint8 darkness)
static void draw_map_object (int x, int y, int layer, int player_height_offset)
void map_draw_map ()
void map_draw_one (int x, int y, _Sprite *sprite)
static void send_move_path (int tx, int ty)
static void send_target (int tx, int ty)
void widget_map_mevent (widgetdata *widget, SDL_Event *event)
static void menu_map_walk_here (widgetdata *widget, int x, int y)
static void menu_map_talk_to (widgetdata *widget, int x, int y)
void widget_map_render (widgetdata *widget)
int mouse_to_tile_coords (int mx, int my, int *tx, int *ty)

Variables

static struct Map the_map
static SDL_Surface * zoomed = NULL
_mapdata MapData
static _multi_part_obj MultiArchs [16]
static int old_map_mouse_x = 0
static int old_map_mouse_y = 0
static int right_click_ticks = -1
const char tile_off [MAP_TILE_YOFF][MAP_TILE_POS_XOFF]

Detailed Description

Map drawing.

Definition in file map.c.


Define Documentation

#define MAP_NAME_FONT   FONT_SERIF14

Font used for the map name.

Definition at line 33 of file map.c.


Function Documentation

void adjust_tile_stretch ( )

Adjust the tile stretch of a map.

Goes through the whole map and for each coordinate calls align_tile_stretch() in all directions. This is done to fix any inconsistencies, since the map command doesn't send us the whole map all over again, but only new/changes parts.

Definition at line 315 of file map.c.

void align_tile_stretch ( int  x,
int  y 
)

Align tile stretch based on X/Y.

Parameters:
xX position.
yY position.

Definition at line 216 of file map.c.

static int calc_map_cell_height ( int  x,
int  y 
) [static]

Calculate height of X/Y coordinate on ::the_map.

Checks for X/Y overflows.

Parameters:
xX position.
yY position.
Returns:
The height.

Definition at line 199 of file map.c.

void clear_map ( )

Clear the map.

Definition at line 99 of file map.c.

void display_mapscroll ( int  dx,
int  dy 
)

Scroll the map.

Parameters:
dxX.
dyY.

Definition at line 108 of file map.c.

static void draw_map_object ( int  x,
int  y,
int  layer,
int  player_height_offset 
) [static]

Draw a single object on the map.

Parameters:
xX position of the object.
yY position of the object.
kLayer.
player_height_offsetPlayer's height offset.

Definition at line 418 of file map.c.

void init_map_data ( int  xl,
int  yl,
int  px,
int  py 
)

Initialize map's data.

Parameters:
xlMap width.
ylMap height.
pxPlayer's X position.
pyPlayer's Y position.

Definition at line 164 of file map.c.

void map_clear_cell ( int  x,
int  y 
)

Clear map's cell.

Parameters:
xX of the cell.
yY of the cell.

Definition at line 381 of file map.c.

void map_draw_map ( )

Draw the map.

Definition at line 745 of file map.c.

void map_draw_one ( int  x,
int  y,
_Sprite sprite 
)

Draw one sprite on map.

Parameters:
xX position.
yY position.
spriteWhat to draw.

Definition at line 788 of file map.c.

void map_set_darkness ( int  x,
int  y,
uint8  darkness 
)

Set darkness for map's cell.

Parameters:
xX of the cell.
yY of the cell.
darknessDarkness to set.

Definition at line 407 of file map.c.

void map_set_data ( int  x,
int  y,
int  layer,
sint16  face,
uint8  quick_pos,
uint8  obj_flags,
const char *  name,
const char *  name_color,
sint16  height,
uint8  probe,
sint16  zoom,
sint16  align,
uint8  draw_double,
uint8  alpha,
sint16  rotate,
uint8  infravision 
)

Set data for map cell.

Parameters:
xX of the cell.
yY of the cell.
layerLayer we're doing this for.
faceFace to set.
quick_posIs this a multi-arch?
obj_flagsFlags.
namePlayer's name.
name_colorPlayer's name color.
heightZ position of the tile.
probeTarget's HP bar.
zoomHow much to zoom the face by.
alignX align.
rotateRotation in degrees.
infravisionWhether to show the object in red.

Definition at line 354 of file map.c.

static void menu_map_talk_to ( widgetdata widget,
int  x,
int  y 
) [static]

Press the "Talk To NPC" option in map widget menu.

Definition at line 910 of file map.c.

static void menu_map_walk_here ( widgetdata widget,
int  x,
int  y 
) [static]

Press the "Walk Here" option in map widget menu.

Definition at line 894 of file map.c.

int mouse_to_tile_coords ( int  mx,
int  my,
int *  tx,
int *  ty 
)

Transform mouse coordinates to tile coordinates on map.

Both 'tx' and 'ty' can be NULL, which is useful if you only want to check if the mouse is over a valid map tile.

Parameters:
mxMouse X.
myMouse Y.
[out]txWill contain tile X, unless function returns 0.
[out]tyWill contain tile Y, unless function returns 0.
Return values:
1Successfully transformed mouse coordinates into tile ones.
0Failed to transform the coordinates; 'tx' and 'ty' are left untouched.

Definition at line 1081 of file map.c.

static void send_move_path ( int  tx,
int  ty 
) [static]

Send a command to move the player to the specified square.

Parameters:
txSquare X position.
tySquare Y position.

Definition at line 810 of file map.c.

static void send_target ( int  tx,
int  ty 
) [static]

Send a command to target an NPC.

Parameters:
txNPC's X position.
tyNPC's Y position.

Definition at line 827 of file map.c.

void update_map_name ( const char *  name)

Update map's name.

Parameters:
nameNew map name.

Definition at line 134 of file map.c.

void update_map_weather ( const char *  weather)

Update map's weather.

Parameters:
weatherNew weather.

Definition at line 153 of file map.c.

void widget_map_mevent ( widgetdata widget,
SDL_Event *  event 
)

Handle mouse events inside the map widget.

Parameters:
widgetThe widget.
eventThe event to handle.

Definition at line 839 of file map.c.

void widget_map_render ( widgetdata widget)

Render the map widget.

Parameters:
widgetThe widget.

Definition at line 928 of file map.c.

void widget_show_mapname ( widgetdata widget)

Show map name widget.

Parameters:
xX position of the map name
yY position of the map name

Definition at line 88 of file map.c.


Variable Documentation

Current shown map: mapname, length, etc

Definition at line 39 of file map.c.

int old_map_mouse_x = 0 [static]

Holds coordinates of the last map square the mouse was over.

Definition at line 44 of file map.c.

int right_click_ticks = -1 [static]

When the right button was pressed on the map widget. -1 = not pressed.

Definition at line 48 of file map.c.

const char tile_off[MAP_TILE_YOFF][MAP_TILE_POS_XOFF]
Initial value:
{
    "000000000000000000000022221111111111111111111111",
    "000000000000000000002222222211111111111111111111",
    "000000000000000000222222222222111111111111111111",
    "000000000000000022222222222222221111111111111111",
    "000000000000002222222222222222222211111111111111",
    "000000000000222222222222222222222222111111111111",
    "000000000022222222222222222222222222221111111111",
    "000000002222222222222222222222222222222211111111",
    "000000222222222222222222222222222222222222111111",
    "000022222222222222222222222222222222222222221111",
    "002222222222222222222222222222222222222222222211",
    "222222222222222222222222222222222222222222222222",
    "332222222222222222222222222222222222222222222244",
    "333322222222222222222222222222222222222222224444",
    "333333222222222222222222222222222222222222444444",
    "333333332222222222222222222222222222222244444444",
    "333333333322222222222222222222222222224444444444",
    "333333333333222222222222222222222222444444444444",
    "333333333333332222222222222222222244444444444444",
    "333333333333333322222222222222224444444444444444",
    "333333333333333333222222222222444444444444444444",
    "333333333333333333332222222244444444444444444444",
    "333333333333333333333322224444444444444444444444"
}

Tile offsets used in mouse_to_tile_coords().

Definition at line 1042 of file map.c.