Freeciv-3.3
Loading...
Searching...
No Matches
Functions | Variables
mapview.c File Reference
#include <stdio.h>
#include <gtk/gtk.h>
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "rand.h"
#include "support.h"
#include "timing.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "nation.h"
#include "player.h"
#include "client_main.h"
#include "climap.h"
#include "climisc.h"
#include "colors.h"
#include "control.h"
#include "editor.h"
#include "options.h"
#include "overview_common.h"
#include "tilespec.h"
#include "text.h"
#include "zoom.h"
#include "citydlg.h"
#include "editgui.h"
#include "graphics.h"
#include "gui_main.h"
#include "gui_stuff.h"
#include "mapctrl.h"
#include "repodlgs.h"
#include "wldlg.h"
#include "mapview.h"

Go to the source code of this file.

Functions

void update_turn_done_button (bool do_restore)
 
void update_timeout_label (void)
 
void update_info_label (void)
 
static gboolean anim_cursor_cb (gpointer data)
 
void update_mouse_cursor (enum cursor_type new_cursor_type)
 
void update_unit_info_label (struct unit_list *punits)
 
GdkPixbufget_thumb_pixbuf (int onoff)
 
void set_indicator_icons (struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
 
void get_overview_area_dimensions (int *width, int *height)
 
void overview_size_changed (void)
 
struct canvasget_overview_window (void)
 
void overview_canvas_draw (GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
 
void mapview_freeze (void)
 
void mapview_thaw (void)
 
bool mapview_is_frozen (void)
 
void map_canvas_resize (GtkWidget *w, int width, int height, gpointer data)
 
void map_canvas_size_refresh (void)
 
void map_canvas_draw (GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
 
void dirty_rect (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
 
void dirty_all (void)
 
void flush_dirty (void)
 
void gui_flush (void)
 
void update_city_descriptions (void)
 
void put_unit_picture (struct unit *punit, GtkPicture *p, int height)
 
void put_unit_picture_city_overlays (struct unit *punit, GtkPicture *p, int height, int *upkeep_cost, int happy_cost)
 
void pixmap_put_overlay_tile (GdkSurface *pixmap, float zoom, int canvas_x, int canvas_y, struct sprite *ssprite)
 
void pixmap_put_overlay_tile_draw (struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *ssprite, bool fog)
 
void put_cross_overlay_tile (struct tile *ptile)
 
void update_overview_scroll_window_pos (int x, int y)
 
void update_map_canvas_scrollbars (void)
 
void update_map_canvas_scrollbars_size (void)
 
void scrollbar_jump_callback (GtkAdjustment *adj, gpointer hscrollbar)
 
void draw_selection_rectangle (int canvas_x, int canvas_y, int w, int h)
 
void tileset_changed (void)
 
void start_turn (void)
 

Variables

static GtkAdjustmentmap_hadj
 
static GtkAdjustmentmap_vadj
 
static int cursor_timer_id = 0
 
static int cursor_type = -1
 
static int cursor_frame = 0
 
static int mapview_frozen_level = 0
 
static int mc_actual_width = -1
 
static int mc_actual_height = -1
 

Function Documentation

◆ anim_cursor_cb()

static gboolean anim_cursor_cb ( gpointer  data)
static

This function is used to animate the mouse cursor.

Definition at line 234 of file mapview.c.

◆ dirty_all()

void dirty_all ( void  )

Mark the entire screen area as "dirty" so that we can flush it later.

Definition at line 457 of file mapview.c.

◆ dirty_rect()

void dirty_rect ( int  canvas_x,
int  canvas_y,
int  pixel_width,
int  pixel_height 
)

Mark the rectangular region as "dirty" so that we know to flush it later.

Definition at line 448 of file mapview.c.

◆ draw_selection_rectangle()

void draw_selection_rectangle ( int  canvas_x,
int  canvas_y,
int  w,
int  h 
)

Draws a rectangle with top left corner at (canvas_x, canvas_y), and width 'w' and height 'h'. It is drawn using the 'selection_gc' context, so the pixel combining function is XOR. This means that drawing twice in the same place will restore the image to its original state.

NB: A side effect of this function is to set the 'selection_gc' color to COLOR_MAPVIEW_SELECTION.

Definition at line 753 of file mapview.c.

◆ flush_dirty()

void flush_dirty ( void  )

Flush all regions that have been previously marked as dirty. See dirty_rect() and dirty_all(). This function is generally called after we've processed a batch of drawing operations.

Definition at line 469 of file mapview.c.

◆ get_overview_area_dimensions()

void get_overview_area_dimensions ( int width,
int height 
)

Return the maximum dimensions of the area (container widget) for the overview. Due to the fact that the scaling factor is at least 1, the real size could be larger. The calculation in calculate_overview_dimensions() limit it to the smallest possible size.

Definition at line 320 of file mapview.c.

◆ get_overview_window()

struct canvas * get_overview_window ( void  )

Return a canvas that is the overview window.

Definition at line 340 of file mapview.c.

◆ get_thumb_pixbuf()

GdkPixbuf * get_thumb_pixbuf ( int  onoff)

Get sprite for treaty acceptance or rejection.

Definition at line 295 of file mapview.c.

◆ gui_flush()

void gui_flush ( void  )

Do any necessary synchronization to make sure the screen is up-to-date. The canvas should have already been flushed to screen via flush_dirty - all this function does is make sure the hardware has caught up.

Definition at line 478 of file mapview.c.

◆ map_canvas_draw()

void map_canvas_draw ( GtkDrawingArea w,
cairo_t cr,
int  width,
int  height,
gpointer  data 
)

Redraw map canvas.

Definition at line 429 of file mapview.c.

◆ map_canvas_resize()

void map_canvas_resize ( GtkWidget w,
int  width,
int  height,
gpointer  data 
)

Update on canvas widget size change

Definition at line 408 of file mapview.c.

◆ map_canvas_size_refresh()

void map_canvas_size_refresh ( void  )

Refresh map canvas size information

Definition at line 420 of file mapview.c.

◆ mapview_freeze()

void mapview_freeze ( void  )

Freeze the drawing of the map.

Definition at line 378 of file mapview.c.

◆ mapview_is_frozen()

bool mapview_is_frozen ( void  )

Return whether the map should be drawn or not.

Definition at line 400 of file mapview.c.

◆ mapview_thaw()

void mapview_thaw ( void  )

Thaw the drawing of the map.

Definition at line 386 of file mapview.c.

◆ overview_canvas_draw()

void overview_canvas_draw ( GtkDrawingArea w,
cairo_t cr,
int  width,
int  height,
gpointer  data 
)

Redraw overview canvas

Definition at line 361 of file mapview.c.

◆ overview_size_changed()

void overview_size_changed ( void  )

Size of overview changed

Definition at line 329 of file mapview.c.

◆ pixmap_put_overlay_tile()

void pixmap_put_overlay_tile ( GdkSurface pixmap,
float  zoom,
int  canvas_x,
int  canvas_y,
struct sprite ssprite 
)

Put overlay tile to pixmap

Definition at line 541 of file mapview.c.

◆ pixmap_put_overlay_tile_draw()

void pixmap_put_overlay_tile_draw ( struct canvas pcanvas,
int  canvas_x,
int  canvas_y,
struct sprite ssprite,
bool  fog 
)

Only used for isometric view.

Definition at line 566 of file mapview.c.

◆ put_cross_overlay_tile()

void put_cross_overlay_tile ( struct tile ptile)

Draws a cross-hair overlay on a tile

Definition at line 643 of file mapview.c.

◆ put_unit_picture()

void put_unit_picture ( struct unit punit,
GtkPicture p,
int  height 
)

Fill picture with unit gfx

Definition at line 494 of file mapview.c.

◆ put_unit_picture_city_overlays()

void put_unit_picture_city_overlays ( struct unit punit,
GtkPicture p,
int  height,
int upkeep_cost,
int  happy_cost 
)

FIXME: For now only two food, two gold one shield and two masks can be drawn per unit, the proper way to do this is probably something like what Civ II does. (One food/shield/mask drawn N times, possibly one top of itself. – SKi

Definition at line 519 of file mapview.c.

◆ scrollbar_jump_callback()

void scrollbar_jump_callback ( GtkAdjustment adj,
gpointer  hscrollbar 
)

Scrollbar has moved

Definition at line 725 of file mapview.c.

◆ set_indicator_icons()

void set_indicator_icons ( struct sprite bulb,
struct sprite sol,
struct sprite flake,
struct sprite gov 
)

Set information for the indicator icons typically shown in the main client window. The parameters tell which sprite to use for the indicator.

Definition at line 305 of file mapview.c.

◆ start_turn()

void start_turn ( void  )

New turn callback

Definition at line 799 of file mapview.c.

◆ tileset_changed()

void tileset_changed ( void  )

This function is called when the tileset has changed.

Definition at line 779 of file mapview.c.

◆ update_city_descriptions()

void update_city_descriptions ( void  )

Update display of descriptions associated with cities on the main map.

Definition at line 486 of file mapview.c.

◆ update_info_label()

void update_info_label ( void  )

Refresh info label

Definition at line 141 of file mapview.c.

◆ update_map_canvas_scrollbars()

void update_map_canvas_scrollbars ( void  )

Refresh map canvas scrollbars

Definition at line 683 of file mapview.c.

◆ update_map_canvas_scrollbars_size()

void update_map_canvas_scrollbars_size ( void  )

Refresh map canvas scrollbar as canvas size changes

Definition at line 698 of file mapview.c.

◆ update_mouse_cursor()

void update_mouse_cursor ( enum cursor_type  new_cursor_type)

This function will change the current mouse cursor.

Definition at line 260 of file mapview.c.

◆ update_overview_scroll_window_pos()

void update_overview_scroll_window_pos ( int  x,
int  y 
)

Sets the position of the overview scroll window based on mapview position.

Definition at line 659 of file mapview.c.

◆ update_timeout_label()

void update_timeout_label ( void  )

Timeout label requires refreshing

Definition at line 121 of file mapview.c.

◆ update_turn_done_button()

void update_turn_done_button ( bool  do_restore)

If do_restore is FALSE it will invert the turn done button style. If called regularly from a timer this will give a blinking turn done button. If do_restore is TRUE this will reset the turn done button to the default style.

Definition at line 79 of file mapview.c.

◆ update_unit_info_label()

void update_unit_info_label ( struct unit_list *  punits)

Update the information label which gives info on the current unit and the square under the current unit, for specified unit. Note that in practice punit is always the focus unit. Clears label if punit is NULL. Also updates the cursor for the map_canvas (this is related because the info label includes a "select destination" prompt etc). Also calls update_unit_pix_label() to update the icons for units on this square.

Definition at line 278 of file mapview.c.

Variable Documentation

◆ cursor_frame

int cursor_frame = 0
static

Definition at line 67 of file mapview.c.

◆ cursor_timer_id

int cursor_timer_id = 0
static

Definition at line 67 of file mapview.c.

◆ cursor_type

int cursor_type = -1
static

Definition at line 67 of file mapview.c.

◆ map_hadj

GtkAdjustment* map_hadj
static

Definition at line 66 of file mapview.c.

◆ map_vadj

GtkAdjustment * map_vadj
static

Definition at line 66 of file mapview.c.

◆ mapview_frozen_level

int mapview_frozen_level = 0
static

Definition at line 68 of file mapview.c.

◆ mc_actual_height

int mc_actual_height = -1
static

Definition at line 71 of file mapview.c.

◆ mc_actual_width

int mc_actual_width = -1
static

Definition at line 70 of file mapview.c.