Freeciv-3.3
Loading...
Searching...
No Matches
Functions | Variables
mapctrl_common.c File Reference
#include <stdlib.h>
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "combat.h"
#include "game.h"
#include "unitlist.h"
#include "agents.h"
#include "chatline_common.h"
#include "cityrep_g.h"
#include "client_main.h"
#include "climisc.h"
#include "cma_core.h"
#include "control.h"
#include "editor.h"
#include "goto.h"
#include "mapctrl_common.h"
#include "mapctrl_g.h"
#include "mapview_g.h"
#include "options.h"
#include "overview_common.h"
#include "tilespec.h"
#include "zoom.h"

Go to the source code of this file.

Functions

static void clipboard_send_production_packet (struct city *pcity)
 
static void define_tiles_within_rectangle (bool append)
 
void anchor_selection_rectangle (int canvas_x, int canvas_y)
 
void update_selection_rectangle (float canvas_x, float canvas_y)
 
void redraw_selection_rectangle (void)
 
void cancel_selection_rectangle (void)
 
bool is_city_hilited (struct city *pcity)
 
void cancel_tile_hiliting (void)
 
void release_right_button (int canvas_x, int canvas_y, bool shift)
 
void toggle_tile_hilite (struct tile *ptile)
 
void key_city_overlay (int canvas_x, int canvas_y)
 
bool clipboard_copy_production (struct tile *ptile)
 
void clipboard_paste_production (struct city *pcity)
 
void upgrade_canvas_clipboard (void)
 
void release_goto_button (int canvas_x, int canvas_y)
 
void maybe_activate_keyboardless_goto (int canvas_x, int canvas_y)
 
bool get_turn_done_button_state (void)
 
bool can_end_turn (void)
 
void scroll_mapview (enum direction8 gui_dir)
 
void action_button_pressed (int canvas_x, int canvas_y, enum quickselect_type qtype)
 
void wakeup_button_pressed (int canvas_x, int canvas_y)
 
void adjust_workers_button_pressed (int canvas_x, int canvas_y)
 
void recenter_button_pressed (int canvas_x, int canvas_y)
 
void update_turn_done_button_state (void)
 
void update_line (int canvas_x, int canvas_y)
 
void overview_update_line (int overview_x, int overview_y)
 
static int unit_list_compare (const void *a, const void *b)
 
void fill_tile_unit_list (const struct tile *ptile, struct unit **unit_list)
 

Variables

static float rec_anchor_x
 
static float rec_anchor_y
 
static struct tilerec_canvas_center_tile
 
static int rec_corner_x
 
static int rec_corner_y
 
static int rec_w
 
static int rec_h
 
bool rbutton_down = FALSE
 
bool rectangle_active = FALSE
 
bool tiles_hilited_cities = FALSE
 
struct universal clipboard
 
bool keyboardless_goto_button_down = FALSE
 
bool keyboardless_goto_active = FALSE
 
struct tilekeyboardless_goto_start_tile
 
struct citycity_workers_display = NULL
 

Function Documentation

◆ action_button_pressed()

void action_button_pressed ( int  canvas_x,
int  canvas_y,
enum quickselect_type  qtype 
)

Do some appropriate action when the "main" mouse button (usually left-click) is pressed. For more sophisticated user control use (or write) a different xxx_button_pressed function.

Definition at line 570 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), button_up_on_map(), finger_up_on_map(), left_butt_down_mapcanvas(), right_butt_down_mapcanvas(), map_view::shortcut_pressed(), and map_view::shortcut_released().

◆ adjust_workers_button_pressed()

void adjust_workers_button_pressed ( int  canvas_x,
int  canvas_y 
)

Adjust the position of city workers from the mapview.

Definition at line 597 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), left_butt_down_mapcanvas(), and map_view::shortcut_pressed().

◆ anchor_selection_rectangle()

void anchor_selection_rectangle ( int  canvas_x,
int  canvas_y 
)

Called when Right Mouse Button is depressed. Record the canvas coordinates of the center of the tile, which may be unreal. This anchor is not the drawing start point, but is used to calculate width, height. Also record the current mapview centering.

Definition at line 87 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), and right_butt_down_mapcanvas().

◆ can_end_turn()

bool can_end_turn ( void  )

Return TRUE iff client can end turn.

Definition at line 531 of file mapctrl_common.c.

Referenced by get_turn_done_button_state(), send_turn_done(), and update_turn_done_button_state().

◆ cancel_selection_rectangle()

void cancel_selection_rectangle ( void  )

Redraws the selection rectangle after a map flush.

Definition at line 287 of file mapctrl_common.c.

Referenced by enter_goto_state().

◆ cancel_tile_hiliting()

void cancel_tile_hiliting ( void  )

Remove hiliting from all tiles, but not from rows in the City List window.

Definition at line 309 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), define_tiles_within_rectangle(), key_cancel_action(), release_right_button(), and right_butt_down_mapcanvas().

◆ clipboard_copy_production()

bool clipboard_copy_production ( struct tile ptile)

Shift-Left-Click on owned city or any visible unit to copy. Returns whether it found anything to try to copy.

Definition at line 379 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), right_butt_down_mapcanvas(), and map_view::shortcut_pressed().

◆ clipboard_paste_production()

void clipboard_paste_production ( struct city pcity)

If City tiles are hilited, paste into all those cities. Otherwise paste into the one city under the mouse pointer.

Definition at line 424 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), right_butt_down_mapcanvas(), and map_view::shortcut_pressed().

◆ clipboard_send_production_packet()

static void clipboard_send_production_packet ( struct city pcity)
static

Send request to build production in clipboard to server.

Definition at line 453 of file mapctrl_common.c.

Referenced by clipboard_paste_production().

◆ define_tiles_within_rectangle()

static void define_tiles_within_rectangle ( bool  append)
static

Iterate over the pixel boundaries of the rectangle and pick the tiles whose center falls within. Axis pixel incrementation is half tile size to accomodate tilesets with varying tile shapes and proportions of X / Y.

These operations are performed on the tiles:

  • Make tiles that contain owned cities hilited on the map and hilited in the City List Window.

Later, I'll want to add unit hiliting for mass orders. -ali

NB: At the end of this function the current selection rectangle will be erased (by being redrawn).

Definition at line 114 of file mapctrl_common.c.

Referenced by release_right_button().

◆ fill_tile_unit_list()

void fill_tile_unit_list ( const struct tile ptile,
struct unit **  unit_list 
)

Fill and sort the list of units on the tile.

Definition at line 769 of file mapctrl_common.c.

◆ get_turn_done_button_state()

bool get_turn_done_button_state ( void  )

Return TRUE iff the turn done button should be enabled.

Definition at line 522 of file mapctrl_common.c.

Referenced by fc_game_tab_widget::resizeEvent(), update_turn_done_button(), and update_turn_done_button_state().

◆ is_city_hilited()

bool is_city_hilited ( struct city pcity)

Is city highlighted

Definition at line 301 of file mapctrl_common.c.

Referenced by buy_production_in_selected_cities(), clipboard_paste_production(), and hilite_cities_from_canvas().

◆ key_city_overlay()

void key_city_overlay ( int  canvas_x,
int  canvas_y 
)

The user pressed the overlay-city button (t) while the mouse was at the given canvas position.

Definition at line 359 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), right_butt_down_mapcanvas(), and map_view::shortcut_pressed().

◆ maybe_activate_keyboardless_goto()

void maybe_activate_keyboardless_goto ( int  canvas_x,
int  canvas_y 
)

The goto hover state is only activated when the mouse pointer moves beyond the tile where the button was depressed, to avoid mouse typos.

Definition at line 507 of file mapctrl_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), map_view::mouseMoveEvent(), move_mapcanvas(), and move_mapcanvas().

◆ overview_update_line()

void overview_update_line ( int  overview_x,
int  overview_y 
)

Update the goto/patrol line to the given overview canvas location.

Definition at line 697 of file mapctrl_common.c.

Referenced by create_line_at_mouse_pos(), move_overviewcanvas(), and move_overviewcanvas().

◆ recenter_button_pressed()

void recenter_button_pressed ( int  canvas_x,
int  canvas_y 
)

Recenter the map on the canvas location, on user request. Usually this is done with a right-click.

Definition at line 633 of file mapctrl_common.c.

Referenced by button_up_on_map(), editor_end_selection_rectangle(), map_view::keyPressEvent(), release_right_button(), and map_view::shortcut_pressed().

◆ redraw_selection_rectangle()

void redraw_selection_rectangle ( void  )

Redraws the selection rectangle after a map flush.

Definition at line 277 of file mapctrl_common.c.

Referenced by unqueue_flush().

◆ release_goto_button()

void release_goto_button ( int  canvas_x,
int  canvas_y 
)

Goto button has been released. Finish goto.

Definition at line 487 of file mapctrl_common.c.

Referenced by butt_release_mapcanvas(), left_butt_up_mapcanvas(), right_butt_up_mapcanvas(), and map_view::shortcut_released().

◆ release_right_button()

void release_right_button ( int  canvas_x,
int  canvas_y,
bool  shift 
)

Action depends on whether the mouse pointer moved a tile between press and release.

Definition at line 321 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), butt_release_mapcanvas(), right_butt_down_mapcanvas(), and right_butt_up_mapcanvas().

◆ scroll_mapview()

void scroll_mapview ( enum direction8  gui_dir)

Scroll the mapview half a screen in the given direction. This is a GUI direction; i.e., DIR8_NORTH is "up" on the mapview.

Definition at line 552 of file mapctrl_common.c.

Referenced by gui_event_loop(), gui_event_loop(), key_press_map_canvas(), and key_press_map_canvas().

◆ toggle_tile_hilite()

void toggle_tile_hilite ( struct tile ptile)

Left Mouse Button in Area Selection mode.

Definition at line 336 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), and left_butt_down_mapcanvas().

◆ unit_list_compare()

static int unit_list_compare ( const void a,
const void b 
)
static

We sort according to the following logic:

  • Transported units should immediately follow their transporter (note that transporting may be recursive).
  • Otherwise we sort by ID (which is what the list is originally sorted by).

Definition at line 736 of file mapctrl_common.c.

Referenced by fill_tile_unit_list(), and unit_list_compare().

◆ update_line()

void update_line ( int  canvas_x,
int  canvas_y 
)

Update the goto/patrol line to the given map canvas location.

Definition at line 665 of file mapctrl_common.c.

Referenced by create_line_at_mouse_pos(), main_mouse_motion_handler(), mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), map_view::mouseMoveEvent(), move_mapcanvas(), and move_mapcanvas().

◆ update_selection_rectangle()

void update_selection_rectangle ( float  canvas_x,
float  canvas_y 
)

Called when mouse pointer moves and rectangle is active.

Definition at line 201 of file mapctrl_common.c.

Referenced by mouse_scroll_mapcanvas(), mouse_scroll_mapcanvas(), move_mapcanvas(), move_mapcanvas(), and update_rect_at_mouse_pos().

◆ update_turn_done_button_state()

void update_turn_done_button_state ( void  )

◆ upgrade_canvas_clipboard()

void upgrade_canvas_clipboard ( void  )

A newer technology may be available for units. Also called from packhand.c.

Definition at line 469 of file mapctrl_common.c.

Referenced by clipboard_copy_production(), and handle_player_info().

◆ wakeup_button_pressed()

void wakeup_button_pressed ( int  canvas_x,
int  canvas_y 
)

Wakeup sentried units on the tile of the specified location.

Definition at line 585 of file mapctrl_common.c.

Referenced by butt_down_mapcanvas(), middle_butt_down_mapcanvas(), and map_view::shortcut_pressed().

Variable Documentation

◆ city_workers_display

struct city* city_workers_display = NULL

Definition at line 74 of file mapctrl_common.c.

Referenced by adjust_workers_button_pressed(), and city_packet_common().

◆ clipboard

struct universal clipboard
Initial value:
=
{ .kind = VUT_NONE,
.value = {.building = NULL}
}
char * incite_cost
Definition comments.c:76

Definition at line 63 of file mapctrl_common.c.

Referenced by clipboard_copy_production(), clipboard_paste_production(), clipboard_send_production_packet(), and upgrade_canvas_clipboard().

◆ keyboardless_goto_active

bool keyboardless_goto_active = FALSE

◆ keyboardless_goto_button_down

bool keyboardless_goto_button_down = FALSE

◆ keyboardless_goto_start_tile

struct tile* keyboardless_goto_start_tile

◆ rbutton_down

bool rbutton_down = FALSE

◆ rec_anchor_x

float rec_anchor_x
static

Definition at line 50 of file mapctrl_common.c.

Referenced by anchor_selection_rectangle(), and update_selection_rectangle().

◆ rec_anchor_y

float rec_anchor_y
static

Definition at line 50 of file mapctrl_common.c.

Referenced by anchor_selection_rectangle(), and update_selection_rectangle().

◆ rec_canvas_center_tile

struct tile* rec_canvas_center_tile
static

Definition at line 51 of file mapctrl_common.c.

Referenced by anchor_selection_rectangle(), and update_selection_rectangle().

◆ rec_corner_x

int rec_corner_x
static

◆ rec_corner_y

int rec_corner_y
static

◆ rec_h

int rec_h
static

◆ rec_w

int rec_w
static

◆ rectangle_active

bool rectangle_active = FALSE

◆ tiles_hilited_cities

bool tiles_hilited_cities = FALSE