Crossfire Client, Trunk  R20507
Functions | Variables
map.c File Reference

Handles map related code in terms of allocation, insertion of new objects, and actual rendering (although the sdl rendering is in the sdl file. More...

#include "client.h"
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "gtk2proto.h"
Include dependency graph for map.c:

Go to the source code of this file.

Functions

void display_map_doneupdate (int redraw, int notice)
 This is called after the map has been all digested. More...
 
int display_mapscroll (int dx, int dy)
 
void draw_map (gboolean redraw)
 Draw the map window using the appropriate backend. More...
 
static void draw_pixmap (cairo_t *cr, PixmapInfo *pixmap, int ax, int ay)
 Draw a pixmap to the given map tile on screen. More...
 
static void drawsmooth (cairo_t *cr, int mx, int my, int layer, int picx, int picy)
 Draw anything in adjacent squares that could smooth on given square. More...
 
static void gtk_map_redraw (gboolean redraw)
 Redraw the entire map using GTK. More...
 
static gboolean map_button_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 Handle a mouse event in the drawing area. More...
 
static void map_check_resize ()
 Calculate and set desired map size based on map window size. More...
 
static void map_draw_layer (cairo_t *cr, int layer)
 Draw a single map layer to the given cairo context. More...
 
static gboolean map_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
 
void map_init (GtkWidget *window_root)
 This initializes the stuff we need for the map. More...
 
static void mapcell_draw_darkness (cairo_t *cr, int ax, int ay, int mx, int my)
 Draw darkness layer to a location on screen. More...
 
static int relative_direction (int dx, int dy)
 Given a relative tile coordinate, determine its compass direction. More...
 
void resize_map_window (int x, int y)
 Resize_map_window is a NOOP for the time being - not sure if it will in fact need to do something, since there are scrollbars for the map window now. More...
 

Variables

static GtkWidget * map_drawing_area
 
int map_image_half_size = DEFAULT_IMAGE_SIZE / 2
 
int map_image_size = DEFAULT_IMAGE_SIZE
 
GtkWidget * map_notebook
 
static gboolean map_updated = FALSE
 
PlayerPosition pl_pos
 
gboolean time_map_redraw = FALSE
 

Detailed Description

Handles map related code in terms of allocation, insertion of new objects, and actual rendering (although the sdl rendering is in the sdl file.

Definition in file map.c.

Function Documentation

void display_map_doneupdate ( int  redraw,
int  notice 
)

This is called after the map has been all digested.

this should perhaps be removed, and left to being done from from the main event loop.

Parameters
redrawIf set, force redraw of all tiles.
noticeIf set, another call will follow soon.

Definition at line 493 of file map.c.

References map_updated.

Referenced by Map2Cmd(), map_scrollCmd(), and MapExtendedCmd().

Here is the caller graph for this function:

int display_mapscroll ( int  dx,
int  dy 
)

Definition at line 122 of file map.c.

References CFG_DM_SDL, CONFIG_DISPLAYMODE, sdl_mapscroll(), and use_config.

Referenced by mapdata_scroll().

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_map ( gboolean  redraw)

Draw the map window using the appropriate backend.

Parameters
redrawIf true, the entire screen must be redrawn.

Definition at line 383 of file map.c.

References CFG_DM_OPENGL, CFG_DM_SDL, CONFIG_DISPLAYMODE, gtk_map_redraw(), opengl_gen_map(), sdl_gen_map(), time_map_redraw, and use_config.

Referenced by map_expose_event(), and resize_map_window().

Here is the call graph for this function:

Here is the caller graph for this function:

static void draw_pixmap ( cairo_t *  cr,
PixmapInfo pixmap,
int  ax,
int  ay 
)
static

Draw a pixmap to the given map tile on screen.

Parameters
axMap cell on-screen x-coordinate
ayMap cell on-screen y-coordinate

Definition at line 116 of file map.c.

References PixmapInfo::map_image, and map_image_size.

Referenced by drawsmooth(), and map_draw_layer().

Here is the caller graph for this function:

static void drawsmooth ( cairo_t *  cr,
int  mx,
int  my,
int  layer,
int  picx,
int  picy 
)
static

Draw anything in adjacent squares that could smooth on given square.

Parameters
mx
mySquare to smooth on. You should not call this function to smooth on a 'completely black' square.
layerLayer to examine (we smooth only one layer at a time)
picx
picyPlace on the map_drawing_area->window to draw

Definition at line 141 of file map.c.

References draw_pixmap(), MapCellLayer::face, MapCell::heads, mapdata_can_smooth(), mapdata_cell(), mapdata_contains(), pixmaps, MapCell::smooth, and PixmapInfo::smooth_face.

Referenced by map_draw_layer().

Here is the call graph for this function:

Here is the caller graph for this function:

static void gtk_map_redraw ( gboolean  redraw)
static

Redraw the entire map using GTK.

Definition at line 320 of file map.c.

References CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, height, map_draw_layer(), map_drawing_area, map_updated, mapcell_draw_darkness(), mapdata_cell(), MAXLAYERS, MapCell::need_resmooth, MapCell::need_update, use_config, width, PlayerPosition::x, and PlayerPosition::y.

Referenced by draw_map().

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean map_button_event ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

Handle a mouse event in the drawing area.

Definition at line 454 of file map.c.

References clear_fire(), CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, fire_dir(), look_at(), map_image_size, relative_direction(), run_dir(), stop_run(), and use_config.

Referenced by map_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void map_check_resize ( )
static

Calculate and set desired map size based on map window size.

Definition at line 55 of file map.c.

References client_mapsize(), CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, map_drawing_area, map_image_size, MAP_MAX_SIZE, and want_config.

Referenced by map_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void map_draw_layer ( cairo_t *  cr,
int  layer 
)
static

Draw a single map layer to the given cairo context.

Definition at line 271 of file map.c.

References CONFIG_FOGWAR, CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, CONFIG_SMOOTH, draw_pixmap(), drawsmooth(), map_image_size, mapdata_cell(), mapdata_face_info(), pixmaps, use_config, PlayerPosition::x, and PlayerPosition::y.

Referenced by gtk_map_redraw().

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean map_expose_event ( GtkWidget *  widget,
GdkEventExpose *  event,
gpointer  user_data 
)
static

Definition at line 415 of file map.c.

References draw_map().

Referenced by map_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void map_init ( GtkWidget *  window_root)

This initializes the stuff we need for the map.

Parameters
window_rootThe client's main playing window.

Definition at line 75 of file map.c.

References CFG_DM_OPENGL, CFG_DM_SDL, CONFIG_DISPLAYMODE, init_opengl(), init_SDL(), map_button_event(), map_check_resize(), map_drawing_area, map_expose_event(), map_notebook, use_config, and window_xml.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

static void mapcell_draw_darkness ( cairo_t *  cr,
int  ax,
int  ay,
int  mx,
int  my 
)
static

Draw darkness layer to a location on screen.

Definition at line 303 of file map.c.

References CONFIG_FOGWAR, MapCell::darkness, map_image_size, mapdata_cell(), and use_config.

Referenced by gtk_map_redraw().

Here is the call graph for this function:

Here is the caller graph for this function:

static int relative_direction ( int  dx,
int  dy 
)
static

Given a relative tile coordinate, determine its compass direction.

Parameters
dxRelative 'x' coordinate
dyRelative 'y' coordinate
Returns
0 if x and y are both zero, 1-8 for each compass direction

Definition at line 427 of file map.c.

Referenced by map_button_event().

Here is the caller graph for this function:

void resize_map_window ( int  x,
int  y 
)

Resize_map_window is a NOOP for the time being - not sure if it will in fact need to do something, since there are scrollbars for the map window now.

Note - this is note a window resize request, but rather process the size (in spaces) of the map - is received from server.

Definition at line 371 of file map.c.

References draw_map(), and map_drawing_area.

Referenced by SetupCmd().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

GtkWidget* map_drawing_area
static

Definition at line 42 of file map.c.

Referenced by gtk_map_redraw(), map_check_resize(), map_init(), and resize_map_window().

int map_image_half_size = DEFAULT_IMAGE_SIZE / 2

Definition at line 40 of file map.c.

Referenced by config_check().

int map_image_size = DEFAULT_IMAGE_SIZE
GtkWidget* map_notebook

Definition at line 44 of file map.c.

Referenced by do_timeout(), draw_magic_map(), and map_init().

gboolean map_updated = FALSE
static

Definition at line 29 of file map.c.

Referenced by display_map_doneupdate(), and gtk_map_redraw().

gboolean time_map_redraw = FALSE

Definition at line 50 of file map.c.

Referenced by draw_map().