Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-3.0/unitselect.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
unitselect.c File Reference
`#include <gtk/gtk.h>`
`#include "fcintl.h"`
`#include "fc_types.h"`
`#include "game.h"`
`#include "player.h"`
`#include "unit.h"`
`#include "unitlist.h"`
`#include "unittype.h"`
`#include "client_main.h"`
`#include "control.h"`
`#include "goto.h"`
`#include "tilespec.h"`
`#include "unitselect_common.h"`
`#include "graphics.h"`
`#include "gui_stuff.h"`
`#include "gui_main.h"`
`#include "unitselect.h"`

Go to the source code of this file.

## Data Structures

struct | unit_select_dialog

## Macros

#define | USDLG_COLUMNS_DEFAULT 3
#define | USDLG_COL_UTID USDLG_COLUMNS_DEFAULT + 0 /* Unit type ID */
#define | USDLG_COL_UID USDLG_COLUMNS_DEFAULT + 1 /* Unit ID */
#define | USDLG_COL_LOCATION USDLG_COLUMNS_DEFAULT + 2 /* Unit location */
#define | USDLG_COL_ACTIVITY USDLG_COLUMNS_DEFAULT + 3 /* Unit activity */
#define | USDLG_COL_ROW_TYPE USDLG_COLUMNS_DEFAULT + 4 /* Row type */
#define | USDLG_COLUMNS_DEBUG USDLG_COLUMNS_DEFAULT + 5
#define | USDLG_COL_STYLE USDLG_COLUMNS_DEBUG + 0
#define | USDLG_COL_WEIGHT USDLG_COLUMNS_DEBUG + 1
#define | USDLG_COLUMNS_ALL USDLG_COLUMNS_DEBUG + 2
#define | USDLG_COLUMNS_SHOW USDLG_COLUMNS_DEFAULT

## Enumerations

enum | usdlg_column_types { COL_PIXBUF , COL_TEXT , COL_INT }
enum | usdlg_row_types { ROW_UNITTYPE , ROW_ACTIVITY , ROW_UNIT , ROW_UNIT_TRANSPORTED }
enum | usdlg_cmd { USDLG_CMD_SELECT , USDLG_CMD_DESELECT , USDLG_CMD_READY , USDLG_CMD_SENTRY , USDLG_CMD_CENTER , USDLG_CMD_FOCUS , USDLG_CMD_LAST }

## Functions

static struct unit_select_dialog * | usdlg_get (bool create)
static struct unit_select_dialog * | usdlg_create (void)
static void | usdlg_destroy (void)
static void | usdlg_destroy_callback (GObject *object, gpointer data)
static void | usdlg_tile (struct unit_select_dialog *pdialog, struct tile *ptile)
static void | usdlg_refresh (struct unit_select_dialog *pdialog)
static void | usdlg_tab_select (struct unit_select_dialog *pdialog, const char *title, enum unit_select_location_mode loc)
static GtkTreeStore * | usdlg_tab_store_new (void)
static bool | usdlg_tab_update (struct unit_select_dialog *pdialog, struct usdata_hash *ushash, enum unit_select_location_mode loc)
static void | usdlg_tab_append_utype (GtkTreeStore *store, enum unit_select_location_mode loc, const struct unit_type *putype, GtkTreeIter *it)
static void | usdlg_tab_append_activity (GtkTreeStore *store, enum unit_select_location_mode loc, const struct unit_type *putype, enum unit_activity act, int count, GtkTreeIter *it, GtkTreeIter *parent)
static void | usdlg_tab_append_units (struct unit_select_dialog *pdialog, enum unit_select_location_mode loc, enum unit_activity act, const struct unit *punit, bool transported, GtkTreeIter *it, GtkTreeIter *parent)
static void | usdlg_cmd_ready (GObject *object, gpointer data)
static void | usdlg_cmd_sentry (GObject *object, gpointer data)
static void | usdlg_cmd_select (GObject *object, gpointer data)
static void | usdlg_cmd_deselect (GObject *object, gpointer data)
static void | usdlg_cmd_exec (GObject *object, gpointer mode_data, enum usdlg_cmd cmd)
static void | usdlg_cmd_exec_unit (struct unit *punit, enum usdlg_cmd cmd)
static void | usdlg_cmd_center (GObject *object, gpointer data)
static void | usdlg_cmd_focus (GObject *object, gpointer data)
static void | usdlg_cmd_focus_real (GtkTreeView *view)
static void | usdlg_cmd_row_activated (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
static void | usdlg_cmd_cursor_changed (GtkTreeView *view, gpointer data)
void | unit_select_dialog_popup_main (struct tile *ptile, bool create)
void | unit_select_dialog_popdown (void)
GdkPixbuf * | usdlg_get_unit_image (const struct unit *punit)
const char * | usdlg_get_unit_descr (const struct unit *punit)

## Variables

enum usdlg_column_types | usdlg_col_types [USDLG_COLUMNS_ALL]
static const char * | usdlg_col_titles [USDLG_COLUMNS_ALL]
static struct unit_select_dialog * | unit_select_dlg = NULL

## Macro Definition Documentation

## ◆ USDLG_COL_ACTIVITY

#define USDLG_COL_ACTIVITY USDLG_COLUMNS_DEFAULT + 3 /* Unit activity */

Definition at line 67 of file unitselect.c.

## ◆ USDLG_COL_LOCATION

#define USDLG_COL_LOCATION USDLG_COLUMNS_DEFAULT + 2 /* Unit location */

Definition at line 66 of file unitselect.c.

## ◆ USDLG_COL_ROW_TYPE

#define USDLG_COL_ROW_TYPE USDLG_COLUMNS_DEFAULT + 4 /* Row type */

Definition at line 68 of file unitselect.c.

## ◆ USDLG_COL_STYLE

#define USDLG_COL_STYLE USDLG_COLUMNS_DEBUG + 0

Definition at line 71 of file unitselect.c.

## ◆ USDLG_COL_UID

#define USDLG_COL_UID USDLG_COLUMNS_DEFAULT + 1 /* Unit ID */

Definition at line 65 of file unitselect.c.

## ◆ USDLG_COL_UTID

#define USDLG_COL_UTID USDLG_COLUMNS_DEFAULT + 0 /* Unit type ID */

Definition at line 64 of file unitselect.c.

## ◆ USDLG_COL_WEIGHT

#define USDLG_COL_WEIGHT USDLG_COLUMNS_DEBUG + 1

Definition at line 72 of file unitselect.c.

## ◆ USDLG_COLUMNS_ALL

#define USDLG_COLUMNS_ALL USDLG_COLUMNS_DEBUG + 2

Definition at line 73 of file unitselect.c.

## ◆ USDLG_COLUMNS_DEBUG

#define USDLG_COLUMNS_DEBUG USDLG_COLUMNS_DEFAULT + 5

Definition at line 69 of file unitselect.c.

## ◆ USDLG_COLUMNS_DEFAULT

#define USDLG_COLUMNS_DEFAULT 3

Definition at line 62 of file unitselect.c.

## ◆ USDLG_COLUMNS_SHOW

#define USDLG_COLUMNS_SHOW USDLG_COLUMNS_DEFAULT

Definition at line 78 of file unitselect.c.

## Enumeration Type Documentation

## ◆ usdlg_cmd

enum usdlg_cmd

Enumerator
USDLG_CMD_SELECT |
USDLG_CMD_DESELECT |
USDLG_CMD_READY |
USDLG_CMD_SENTRY |
USDLG_CMD_CENTER |
USDLG_CMD_FOCUS |
USDLG_CMD_LAST |

Definition at line 107 of file unitselect.c.

## ◆ usdlg_column_types

enum usdlg_column_types

Enumerator
COL_PIXBUF |
COL_TEXT |
COL_INT |

Definition at line 48 of file unitselect.c.

## ◆ usdlg_row_types

enum usdlg_row_types

Enumerator
ROW_UNITTYPE |
ROW_ACTIVITY |
ROW_UNIT |
ROW_UNIT_TRANSPORTED |

Definition at line 54 of file unitselect.c.

## Function Documentation

## ◆ unit_select_dialog_popdown()

static void unit_select_dialog_popdown | ( | void |  | ) |

Popdown the unit selection dialog.

Popdown a dialog window to select units on a particular tile.

Definition at line 214 of file unitselect.c.

Referenced by exit_unit_select_callback(), popdown_all_game_dialogs(), and unit_select_callback().

## ◆ unit_select_dialog_popup_main()

void unit_select_dialog_popup_main | ( | struct tile * | ptile,
|  | bool | create
| ) |  |

Popup the unit selection dialog.

Definition at line 193 of file unitselect.c.

Referenced by unit_select_dialog_popup(), and unit_select_dialog_update_real().

## ◆ usdlg_cmd_center()

static void usdlg_cmd_center | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the center button.

Definition at line 1083 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_cursor_changed()

static void usdlg_cmd_cursor_changed | ( | GtkTreeView * | view,
|  | gpointer | data
| ) |  |

static

Callback if the row is changed.

Definition at line 1180 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_deselect()

static void usdlg_cmd_deselect | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the deselect button.

Definition at line 925 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_exec()

static void usdlg_cmd_exec | ( | GObject * | object,
|  | gpointer | mode_data,
|  | enum usdlg_cmd | cmd
| ) |  |

static

Main function for the callbacks.

Definition at line 933 of file unitselect.c.

Referenced by usdlg_cmd_deselect(), usdlg_cmd_ready(), usdlg_cmd_select(), and usdlg_cmd_sentry().

## ◆ usdlg_cmd_exec_unit()

static void usdlg_cmd_exec_unit | ( | struct unit * | punit,
|  | enum usdlg_cmd | cmd
| ) |  |

static

Update one unit (select/deselect/ready/sentry).

Definition at line 1044 of file unitselect.c.

Referenced by usdlg_cmd_exec().

## ◆ usdlg_cmd_focus()

static void usdlg_cmd_focus | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the focus button.

Definition at line 1122 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_focus_real()

static void usdlg_cmd_focus_real | ( | GtkTreeView * | view | ) |

static

Focus to the currently selected unit.

Definition at line 1146 of file unitselect.c.

Referenced by usdlg_cmd_focus(), and usdlg_cmd_row_activated().

## ◆ usdlg_cmd_ready()

static void usdlg_cmd_ready | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the ready button.

Definition at line 901 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_row_activated()

static void usdlg_cmd_row_activated | ( | GtkTreeView * | view,
|  | GtkTreePath * | path,
|  | GtkTreeViewColumn * | col,
|  | gpointer | data
| ) |  |

static

Callback if a row is activated.

Definition at line 1137 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_select()

static void usdlg_cmd_select | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the select button.

Definition at line 917 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_cmd_sentry()

static void usdlg_cmd_sentry | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the sentry button.

Definition at line 909 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_create()

static struct unit_select_dialog * usdlg_create | ( | void |  | ) |

static

Create a new unit selection dialog.

Definition at line 241 of file unitselect.c.

Referenced by usdlg_get().

## ◆ usdlg_destroy()

static void usdlg_destroy | ( | void |  | ) |

static

Destroy a unit selection dialog.

Definition at line 293 of file unitselect.c.

Referenced by unit_select_dialog_popdown(), usdlg_cmd_focus_real(), and usdlg_destroy_callback().

## ◆ usdlg_destroy_callback()

static void usdlg_destroy_callback | ( | GObject * | object,
|  | gpointer | data
| ) |  |

static

Callback for the destruction of the dialog.

Definition at line 305 of file unitselect.c.

Referenced by usdlg_create().

## ◆ usdlg_get()

static struct unit_select_dialog * usdlg_get | ( | bool | create | ) |

static

Get the current unit selection dialog. Create it if needed and 'create' is TRUE.

Definition at line 223 of file unitselect.c.

Referenced by unit_select_dialog_popup_main(), usdlg_cmd_center(), usdlg_cmd_cursor_changed(), usdlg_cmd_exec(), and usdlg_cmd_focus().

## ◆ usdlg_get_unit_descr()

const char * usdlg_get_unit_descr | ( | const struct unit * | punit | ) |

Get an unit selection list item suitable description of the specified unit.

Definition at line 786 of file unitselect.c.

Referenced by select_tgt_unit(), and usdlg_tab_append_units().

## ◆ usdlg_get_unit_image()

GdkPixbuf * usdlg_get_unit_image | ( | const struct unit * | punit | ) |

Get an unit selection list item suitable image of the specified unit.

Caller is responsible for getting rid of the returned image after use.

Definition at line 765 of file unitselect.c.

Referenced by select_tgt_unit(), and usdlg_tab_append_units().

## ◆ usdlg_refresh()

static void usdlg_refresh | ( | struct unit_select_dialog * | pdialog | ) |

static

Refresh the dialog.

Definition at line 338 of file unitselect.c.

Referenced by unit_select_dialog_popup_main(), and usdlg_cmd_exec().

## ◆ usdlg_tab_append_activity()

static void usdlg_tab_append_activity | ( | GtkTreeStore * | store,
|  | enum unit_select_location_mode | loc,
|  | const struct unit_type * | putype,
|  | enum unit_activity | act,
|  | int | count,
|  | GtkTreeIter * | it,
|  | GtkTreeIter * | parent
| ) |  |

static

Append the unit activity.

Definition at line 727 of file unitselect.c.

Referenced by usdlg_tab_update().

## ◆ usdlg_tab_append_units()

static void usdlg_tab_append_units | ( | struct unit_select_dialog * | pdialog,
|  | enum unit_select_location_mode | loc,
|  | enum unit_activity | act,
|  | const struct unit * | punit,
|  | bool | transported,
|  | GtkTreeIter * | it,
|  | GtkTreeIter * | parent
| ) |  |

static

Append units (recursively).

Definition at line 828 of file unitselect.c.

Referenced by usdlg_tab_append_units(), and usdlg_tab_update().

## ◆ usdlg_tab_append_utype()

static void usdlg_tab_append_utype | ( | GtkTreeStore * | store,
|  | enum unit_select_location_mode | loc,
|  | const struct unit_type * | putype,
|  | GtkTreeIter * | it
| ) |  |

static

Append the data for one unit type.

Definition at line 678 of file unitselect.c.

Referenced by usdlg_tab_update().

## ◆ usdlg_tab_select()

static void usdlg_tab_select | ( | struct unit_select_dialog * | pdialog,
|  | const char * | title,
|  | enum unit_select_location_mode | loc
| ) |  |

static

+-----------------------------—+ | +--------------—+-------—+ | | | (unit list) | select | |

|  | deselect |
--- | --- | --- | ---
|  | center |
|  | focus |

| +--------------—+-------—+ | | | tabs | ... | | | close | +-----------------------------—+

Definition at line 387 of file unitselect.c.

Referenced by usdlg_create().

## ◆ usdlg_tab_store_new()

static GtkTreeStore * usdlg_tab_store_new | ( | void |  | ) |

static

Create a player dialog store.

Definition at line 540 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_tab_update()

static bool usdlg_tab_update | ( | struct unit_select_dialog * | pdialog,
|  | struct usdata_hash * | ushash,
|  | enum unit_select_location_mode | loc
| ) |  |

static

Update on tab of the dialog.

Definition at line 568 of file unitselect.c.

Referenced by usdlg_refresh().

## ◆ usdlg_tile()

static void usdlg_tile | ( | struct unit_select_dialog * | pdialog,
|  | struct tile * | ptile
| ) |  |

static

Set the reference tile.

Definition at line 313 of file unitselect.c.

Referenced by unit_select_dialog_popup_main().

## Variable Documentation

## ◆ unit_select_dlg

struct unit_select_dialog* unit_select_dlg = NULL

static

Definition at line 141 of file unitselect.c.

Referenced by usdlg_destroy(), and usdlg_get().

## ◆ usdlg_col_titles

const char* usdlg_col_titles[USDLG_COLUMNS_ALL]

static

Initial value:
= {
N_("Unit"),
N_("Description"),
N_("Count"),
"[Unittype]",
"[Unit ID]",
"[Location]",
"[Activity]",
"[Row type]",
"[Style]",
"[Width]"
}
N_
#define N_(String)
Definition fcintl.h:69

Definition at line 94 of file unitselect.c.

Referenced by usdlg_tab_select().

## ◆ usdlg_col_types

enum usdlg_column_types usdlg_col_types[USDLG_COLUMNS_ALL]

Initial value:
= {
COL_PIXBUF,
COL_TEXT,
COL_INT,
COL_INT,
COL_INT,
COL_INT,
COL_INT,
COL_INT,
COL_INT,
COL_INT
}
COL_INT
@ COL_INT
Definition unitselect.c:51
COL_TEXT
@ COL_TEXT
Definition unitselect.c:50
COL_PIXBUF
@ COL_PIXBUF
Definition unitselect.c:49

Definition at line 81 of file unitselect.c.

Referenced by usdlg_tab_select(), and usdlg_tab_store_new().