12 #include <QApplication>
13 #include <QMouseEvent>
50 _(
"Build New City"), suggestname);
51 ask->setAttribute(Qt::WA_DeleteOnClose);
52 QObject::connect(ask, &hud_input_box::finished, [=](
int result) {
53 if (result == QDialog::Accepted) {
56 ask_bytes = ask->
input_edit.text().toLocal8Bit();
70 QPoint global_pos, local_pos;
73 global_pos = QCursor::pos();
97 Qt::KeyboardModifiers key_mod = QApplication::keyboardModifiers();
98 bool is_shift = key_mod.testFlag(Qt::ShiftModifier);
102 switch (
event->key()) {
112 switch (
event->key()) {
149 case Qt::Key_PageDown:
185 auto pos = mapFromGlobal(QCursor::pos()) /
scale();
188 auto pcity = ptile ?
tile_city(ptile) :
nullptr;
197 if (
king()->trade_gen.hover_city) {
204 if (
king()->rallies.hover_city) {
212 _(
"Selected city %s. Now choose rally point."),
222 if (
king()->rallies.hover_tile && ptile !=
nullptr) {
230 _(
"Tile %s set as rally point from city %s."),
235 _(
"Could not set rally point for city %s."),
245 if (
king()->menu_bar->delayed_order && ptile) {
253 if (
king()->menu_bar->quick_airlifting && ptile) {
271 if (pcity !=
nullptr && !
king()->menu_bar->delayed_order) {
278 if (ptile !=
nullptr && unit_list_size(ptile->units) > 0) {
284 if (ptile !=
nullptr) {
290 if (
queen()->battlelog_wdg !=
nullptr) {
296 if (pcity !=
nullptr) {
306 QPixmapCache::clear();
323 if (ptile !=
nullptr) {
329 if (pcity !=
nullptr) {
335 if (pcity !=
nullptr) {
354 if (ptile !=
nullptr) {
374 auto md = QApplication::keyboardModifiers();
375 auto pos = mapFromGlobal(QCursor::pos()) /
scale();
382 if (bt == sc.buttons && md == sc.modifiers) {
383 if (
king()->trade_gen.hover_city ||
king()->rallies.hover_city) {
void output_window_append(const struct ft_color color, const char *featured_text)
Add a line of text to the output ("chatline") window, like puts() would do it in the console.
int city_buy_production(struct city *pcity)
Buy the current production item in a given city.
trade_generator trade_gen
fc_shortcut get_shortcut(shortcut_id id) const
Returns shortcut for given id.
static fc_shortcuts * sc()
Returns given instance.
void maybe_route_mouse_shortcut(QMouseEvent *event, map_view *mapview)
If the mouse event corresponds to a registered shortcut, fire the corresponding action.
static bool shown()
Check if the info tile is currently shown.
void mouseReleaseEvent(QMouseEvent *event) override
Mouse release event for map_view.
void mousePressEvent(QMouseEvent *event) override
Mouse buttons handler for map_view.
void keyPressEvent(QKeyEvent *event) override
Keyboard handler for map_view.
void mouseMoveEvent(QMouseEvent *event) override
Mouse movement handler for map_view.
void shortcut_pressed(shortcut_id key)
Pressed mouse or keyboard.
void shortcut_released(Qt::MouseButton mb)
Released mouse buttons.
hud_battle_log * battlelog_wdg
void add_tile(struct tile *ptile)
Adds/removes tile to trade generator.
enum client_states client_state()
Return current client state.
struct player * client_player()
Either controlling or observing.
void set_auto_center_enabled(bool enabled)
Allows disabling automatic map recentering.
void key_cancel_action()
The 'Escape' key.
void key_unit_move(enum direction8 gui_dir)
Move the focus unit in the given direction.
void key_recall_previous_focus_unit()
Recall the previous focus unit(s).
enum cursor_hover_state hover_state
void key_end_turn()
Handle user 'end turn' input.
void finish_city(struct tile *ptile, const char *name)
All units ready to build city to the tile should now proceed.
void clear_hover_state()
Clear current hover state (go to HOVER_NONE).
void control_mouse_cursor(struct tile *ptile)
Determines which mouse cursor should be used, according to hover_state, and the information gathered ...
void cancel_city(struct tile *ptile)
Do not build city after all.
class fc_client * king()
Return fc_client instance.
const char * tile_link(const struct tile *ptile)
Get a text link to a tile.
const struct ft_color ftc_client
const char * city_link(const struct city *pcity)
Get a text link to a city.
bool goto_is_active()
Is goto state active?
bool send_rally_tile(struct city *pcity, struct tile *ptile)
Send rally orders for the city to move new units to the arbitrary tile.
void exit_goto_state()
Tidy up and deactivate goto state.
#define fc_assert_ret(condition)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Return the tile for the given index position.
void popup_newcity_dialog(struct unit *punit, const char *suggestname)
Popup a dialog to ask for the name of a new city.
void qload_lua_script()
Load and execute lua script.
void create_line_at_mouse_pos(void)
Draw a goto or patrol line at the current mouse position.
void update_rect_at_mouse_pos(void)
The Area Selection rectangle.
void qreload_lua_script()
Reload last lua script.
void update_line(int canvas_x, int canvas_y)
Update the goto/patrol line to the given map canvas location.
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 ...
void adjust_workers_button_pressed(int canvas_x, int canvas_y)
Adjust the position of city workers from the mapview.
void release_goto_button(int canvas_x, int canvas_y)
Goto button has been released.
void recenter_button_pressed(int canvas_x, int canvas_y)
Recenter the map on the canvas location, on user request.
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.
void wakeup_button_pressed(int canvas_x, int canvas_y)
Wakeup sentried units on the tile of the specified location.
bool keyboardless_goto_button_down
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.
bool keyboardless_goto_active
void clipboard_paste_production(struct city *pcity)
If City tiles are hilited, paste into all those cities.
bool clipboard_copy_production(struct tile *ptile)
Shift-Left-Click on owned city or any visible unit to copy.
client_options * gui_options
pageGame * queen()
Return game instandce.
char gui_qt_default_theme_name[512]
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
bool load_theme(const QString &theme_name)
Loads a theme with the given name.
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
bool tilespec_reread(const QString &name, bool game_fully_initialized)
Read a new tilespec in from scratch.
const char * tileset_basename(const struct tileset *t)
Return the name of the given tileset.
void toggle_unit_sel_widget(struct tile *ptile)
Shows/closes unit selection widget.
void popup_tile_info(struct tile *ptile)
Popups information label tile.
void popdown_tile_info()
Popdowns information label tile.
struct tile * canvas_pos_to_tile(float canvas_x, float canvas_y)
Finds the tile corresponding to pixel coordinates.