Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-sdl2/mapview.c File Reference

Freeciv-3.2

Loading...
Searching...
No Matches
Functions | Variables
mapview.c File Reference
`#include <SDL2/SDL.h>`
`#include "astring.h"`
`#include "bugs.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "calendar.h"`
`#include "game.h"`
`#include "goto.h"`
`#include "government.h"`
`#include "movement.h"`
`#include "research.h"`
`#include "unitlist.h"`
`#include "citydlg_common.h"`
`#include "client_main.h"`
`#include "climisc.h"`
`#include "overview_common.h"`
`#include "pages_g.h"`
`#include "text.h"`
`#include "colors.h"`
`#include "dialogs.h"`
`#include "graphics.h"`
`#include "gui_id.h"`
`#include "gui_main.h"`
`#include "gui_mouse.h"`
`#include "gui_tilespec.h"`
`#include "mapctrl.h"`
`#include "sprite.h"`
`#include "themespec.h"`
`#include "widget.h"`
`#include "mapview.h"`

Go to the source code of this file.

## Functions

void | update_map_canvas_scrollbars_size (void)
static void | flush_mapcanvas (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
void | flush_rect (SDL_Rect *rect, bool force_flush)
void | unqueue_flush (void)
void | queue_flush (void)
void | dirty_rect (int canvas_x, int canvas_y, int pixel_width, int pixel_height)
void | dirty_sdl_rect (SDL_Rect *Rect)
void | dirty_all (void)
void | flush_all (void)
void | flush_dirty (void)
void | gui_flush (void)
void | set_indicator_icons (struct sprite *bulb, struct sprite *sol, struct sprite *flake, struct sprite *gov)
void | overview_size_changed (void)
void | update_info_label (void)
static int | focus_units_info_callback (struct widget *pwidget)
void | redraw_unit_info_label (struct unit_list *punitlist)
static bool | is_focus_anim_enabled (void)
void | set_unit_icon (int idx, struct unit *punit)
void | set_unit_icons_more_arrow (bool onoff)
void | real_focus_units_changed (void)
void | update_unit_info_label (struct unit_list *punitlist)
void | update_timeout_label (void)
void | update_turn_done_button (bool do_restore)
void | update_city_descriptions (void)
struct canvas * | get_overview_window (void)
void | get_overview_area_dimensions (int *width, int *height)
void | refresh_overview (void)
void | update_map_canvas_scrollbars (void)
void | put_cross_overlay_tile (struct tile *ptile)
void | draw_selection_rectangle (int canvas_x, int canvas_y, int w, int h)
void | tileset_changed (void)
void | city_map_canvas_free (void)
SDL_Surface * | create_city_map (struct city *pcity)
SDL_Surface * | get_terrain_surface (struct tile *ptile)
void | update_overview_scroll_window_pos (int x, int y)
void | start_turn (void)
void | map_canvas_size_refresh (void)

## Variables

SDL_Rect * | info_area
int | overview_start_x = 0
int | overview_start_y = 0
static struct canvas * | overview_canvas
static struct canvas * | city_map_canvas = NULL
static struct canvas * | terrain_canvas
static bool | is_flush_queued = FALSE

## Function Documentation

## ◆ city_map_canvas_free()

void city_map_canvas_free | ( | void |  | ) |

Free memory allocated for the city map canvas

Definition at line 1185 of file mapview.c.

Referenced by create_city_map(), and ui_main().

## ◆ create_city_map()

SDL_Surface * create_city_map | ( | struct city * | pcity | ) |

Create new city map surface.

Definition at line 1196 of file mapview.c.

Referenced by get_scaled_city_map().

## ◆ dirty_all()

void dirty_all | ( | void |  | ) |

Select entire screen area to "end" flush and block "save" new areas.

Definition at line 192 of file mapview.c.

## ◆ dirty_rect()

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

Save Flush area used by "end" flush.

Definition at line 170 of file mapview.c.

## ◆ dirty_sdl_rect()

void dirty_sdl_rect | ( | SDL_Rect * | Rect | ) |

Save Flush rect used by "end" flush.

Definition at line 181 of file mapview.c.

Referenced by arrange_widgets(), dirty_rect(), flush_rect(), option_dialog_worklist(), refresh_production_label(), refresh_worklist_count_label(), update_info_label(), widget_core_mark_dirty(), and widget_pressed_action().

## ◆ draw_selection_rectangle()

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

Area Selection

Definition at line 1159 of file mapview.c.

## ◆ flush_all()

void flush_all | ( | void |  | ) |

flush entire screen.

Definition at line 201 of file mapview.c.

Referenced by arrange_widgets(), notify_goto_dialog_update(), popup_join_game_dialog(), popup_new_user_passwd_dialog(), popup_user_passwd_dialog(), real_resize_window_callback(), redraw_unit_info_label(), and show_main_page().

## ◆ flush_dirty()

void flush_dirty | ( | void |  | ) |

Make "end" Flush "saved" parts/areas of the buffer(s) to the screen. Function is called in handle_procesing_finished and handle_thaw_hint

Definition at line 212 of file mapview.c.

## ◆ flush_mapcanvas()

static void flush_mapcanvas | ( | int | canvas_x,
|  | int | canvas_y,
|  | int | pixel_width,
|  | int | pixel_height
| ) |  |

static

Flush the mapcanvas part of the buffer(s) to the screen.

Definition at line 92 of file mapview.c.

Referenced by flush_dirty(), and flush_rect().

## ◆ flush_rect()

void flush_rect | ( | SDL_Rect * | rect,
|  | bool | force_flush
| ) |  |

Flush the given part of the buffer(s) to the screen.

Definition at line 103 of file mapview.c.

Referenced by draw_mouse_cursor(), unselect_widget_action(), and widget_core_flush().

## ◆ focus_units_info_callback()

static int focus_units_info_callback | ( | struct widget * | pwidget | ) |

static

User interacted with the focus units widget.

Definition at line 499 of file mapview.c.

Referenced by redraw_unit_info_label().

## ◆ get_overview_area_dimensions()

void get_overview_area_dimensions | ( | int * | width,
|  | int * | height
| ) |  |

Return the dimensions of the area (container widget; maximum size) for the overview.

Definition at line 1087 of file mapview.c.

## ◆ get_overview_window()

struct canvas * get_overview_window | ( | void |  | ) |

Return a canvas that is the overview window.

Definition at line 1078 of file mapview.c.

## ◆ get_terrain_surface()

SDL_Surface * get_terrain_surface | ( | struct tile * | ptile | ) |

Return surface containing terrain of the tile.

Definition at line 1212 of file mapview.c.

Referenced by popup_terrain_info_dialog().

## ◆ gui_flush()

void gui_flush | ( | void |  | ) |

This function is called when the map has changed.

Definition at line 287 of file mapview.c.

## ◆ is_focus_anim_enabled()

static bool is_focus_anim_enabled | ( | void |  | ) |

static

Is the focus animation enabled?

Definition at line 974 of file mapview.c.

Referenced by update_unit_info_label().

## ◆ map_canvas_size_refresh()

void map_canvas_size_refresh | ( | void |  | ) |

Refresh map canvas size information

Definition at line 1245 of file mapview.c.

## ◆ overview_size_changed()

void overview_size_changed | ( | void |  | ) |

Called when the map size changes. This may be used to change the size of the GUI element holding the overview canvas. The overview.width and overview.height are updated if this function is called.

Definition at line 383 of file mapview.c.

## ◆ put_cross_overlay_tile()

void put_cross_overlay_tile | ( | struct tile * | ptile | ) |

Draw a cross-hair overlay on a tile.

Definition at line 1151 of file mapview.c.

## ◆ queue_flush()

void queue_flush | ( | void |  | ) |

Called when a region is marked dirty, this function queues a flush event to be handled later by SDL. The flush may end up being done by freeciv before then, in which case it will be a wasted call.

Definition at line 152 of file mapview.c.

Referenced by dirty_all(), dirty_sdl_rect(), exit_meta_server_dlg_callback(), options_callback(), popdown_diplomat_dialog(), popup_connection_dialog(), popup_join_game_dialog(), popup_new_user_passwd_dialog(), popup_user_passwd_dialog(), and update_info_label().

## ◆ real_focus_units_changed()

void real_focus_units_changed | ( | void |  | ) |

Called when the set of units in focus (get_units_in_focus()) changes. Standard updates like update_unit_info_label() are handled in the platform- independent code, so some clients will not need to do anything here.

Definition at line 1006 of file mapview.c.

## ◆ redraw_unit_info_label()

void redraw_unit_info_label | ( | struct unit_list * | punitlist | ) |

Read Function Name :) FIXME: should use same method as client/text.c popup_info_text()

Definition at line 517 of file mapview.c.

Referenced by set_turn_done_button_state(), toggle_unit_info_window_callback(), and update_unit_info_label().

## ◆ refresh_overview()

void refresh_overview | ( | void |  | ) |

Refresh (update) the viewrect on the overview. This is the rectangle showing the area covered by the mapview.

Definition at line 1119 of file mapview.c.

Referenced by flush_dirty(), gui_flush(), real_set_client_page(), resize_minimap(), and toggle_map_window_callback().

## ◆ 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 301 of file mapview.c.

## ◆ set_unit_icon()

void set_unit_icon | ( | int | idx,
|  | struct unit * | punit
| ) |  |

Set one of the unit icons in the information area based on punit. NULL will be passed to clear the icon. idx == -1 will be passed to indicate this is the active unit, or idx in [0..num_units_below - 1] for secondary (inactive) units on the same tile.

Definition at line 985 of file mapview.c.

## ◆ set_unit_icons_more_arrow()

void set_unit_icons_more_arrow | ( | bool | onoff | ) |

Most clients use an arrow (e.g., sprites.right_arrow) to indicate when the units_below will not fit. This function is called to activate and deactivate the arrow.

Definition at line 996 of file mapview.c.

## ◆ start_turn()

void start_turn | ( | void |  | ) |

New turn callback

Definition at line 1239 of file mapview.c.

## ◆ tileset_changed()

void tileset_changed | ( | void |  | ) |

This function is called when the tileset is changed.

Definition at line 1170 of file mapview.c.

## ◆ unqueue_flush()

void unqueue_flush | ( | void |  | ) |

A callback invoked as a result of a FLUSH event, this function simply flushes the mapview canvas.

Definition at line 140 of file mapview.c.

Referenced by gui_event_loop().

## ◆ update_city_descriptions()

void update_city_descriptions | ( | void |  | ) |

Update (refresh) all of the city descriptions on the mapview.

Definition at line 1064 of file mapview.c.

## ◆ update_info_label()

void update_info_label | ( | void |  | ) |

Typically an info box is provided to tell the player about the state of their civilization. This function is called when the label is changed.

Definition at line 401 of file mapview.c.

## ◆ update_map_canvas_scrollbars()

void update_map_canvas_scrollbars | ( | void |  | ) |

Update (refresh) the locations of the mapview scrollbars (if it uses them).

Definition at line 1143 of file mapview.c.

## ◆ update_map_canvas_scrollbars_size()

void update_map_canvas_scrollbars_size | ( | void |  | ) |

Refresh map canvas scrollbar as canvas size changes

Update the size of the sliders on the scrollbars.

Definition at line 82 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 1231 of file mapview.c.

## ◆ update_timeout_label()

void update_timeout_label | ( | void |  | ) |

Refresh timeout label.

Definition at line 1044 of file mapview.c.

## ◆ update_turn_done_button()

void update_turn_done_button | ( | bool | do_restore | ) |

Refresh turn done button.

Definition at line 1052 of file mapview.c.

## ◆ update_unit_info_label()

void update_unit_info_label | ( | struct unit_list * | punitlist | ) |

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 punitlist is NULL or empty.

Typically also updates the cursor for the map_canvas (this is related because the info label may includes "select destination" prompt etc). And it may call update_unit_pix_label() to update the icons for units on this square.

Definition at line 1023 of file mapview.c.

## Variable Documentation

## ◆ city_map_canvas

struct canvas* city_map_canvas = NULL

static

Definition at line 77 of file mapview.c.

## ◆ info_area

SDL_Rect* info_area

extern

Definition at line 49 of file widget.c.

Referenced by flush_dirty().

## ◆ is_flush_queued

bool is_flush_queued = FALSE

static

Definition at line 87 of file mapview.c.

Referenced by flush_all(), flush_rect(), queue_flush(), and unqueue_flush().

## ◆ overview_canvas

struct canvas* overview_canvas

static

Definition at line 76 of file mapview.c.

## ◆ overview_start_x

int overview_start_x = 0

Definition at line 73 of file mapview.c.

Referenced by refresh_overview().

## ◆ overview_start_y

int overview_start_y = 0

Definition at line 74 of file mapview.c.

Referenced by refresh_overview().

## ◆ terrain_canvas

struct canvas* terrain_canvas

static

Definition at line 78 of file mapview.c.

Referenced by get_terrain_surface(), help_dialog::make_tree(), and help_widget::set_topic_terrain().