Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions
text.c File Reference
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "astring.h"
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "calendar.h"
#include "citizens.h"
#include "clientutils.h"
#include "combat.h"
#include "culture.h"
#include "fc_types.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "nation.h"
#include "research.h"
#include "traderoutes.h"
#include "unitlist.h"
#include "client_main.h"
#include "climap.h"
#include "climisc.h"
#include "control.h"
#include "goto.h"
#include "helpdata.h"
#include "text.h"

Go to the source code of this file.

Macros

#define FAR_CITY_SQUARE_DIST   (2*(6*6))
 

Functions

static int get_bulbs_per_turn (int *pours, bool *pteam, int *ptheirs)
 
static const charformat_duration (int duration)
 
const charget_tile_output_text (const struct tile *ptile)
 
static void get_full_username (char *buf, int buflen, const struct player *pplayer)
 
static void get_full_nation (char *buf, int buflen, const struct player *pplayer)
 
const charpopup_info_text (struct tile *ptile)
 
const charget_nearest_city_text (struct city *pcity, int sq_dist)
 
const charunit_description (struct unit *punit)
 
const charget_airlift_text (const struct unit_list *punits, const struct city *pdest)
 
static int turns_to_research_done (const struct research *presearch, int per_turn)
 
static int turns_per_advance (const struct research *presearch, int per_turn)
 
static int turns_to_tech_loss (const struct research *presearch, int per_turn)
 
const charscience_dialog_text (void)
 
const charget_science_target_text (double *percent)
 
const charget_science_goal_text (Tech_type_id goal)
 
const charget_info_label_text (bool moreinfo)
 
const charget_info_label_text_popup (void)
 
const charget_unit_info_label_text1 (struct unit_list *punits)
 
const charget_unit_info_label_text2 (struct unit_list *punits, int linebreaks)
 
bool get_units_upgrade_info (char *buf, size_t bufsz, struct unit_list *punits)
 
bool get_units_disband_info (char *buf, size_t bufsz, struct unit_list *punits)
 
const charget_bulb_tooltip (void)
 
const charget_global_warming_tooltip (void)
 
const charget_nuclear_winter_tooltip (void)
 
const charget_government_tooltip (void)
 
const charget_spaceship_descr (struct player_spaceship *pship)
 
const charget_timeout_label_text (void)
 
const charget_ping_time_text (const struct player *pplayer)
 
const charget_score_text (const struct player *pplayer)
 
const charget_report_title (const char *report_name)
 
const charget_act_sel_action_custom_text (struct action *paction, const struct act_prob prob, const struct unit *actor_unit, const struct city *target_city)
 
const charact_sel_action_tool_tip (const struct action *paction, const struct act_prob prob)
 
const chartext_happiness_buildings (const struct city *pcity)
 
const chartext_happiness_nationality (const struct city *pcity)
 
const chartext_happiness_wonders (const struct city *pcity)
 
const chartext_happiness_cities (const struct city *pcity)
 
const chartext_happiness_units (const struct city *pcity)
 
const chartext_happiness_luxuries (const struct city *pcity)
 
const charproduction_help (const struct universal *uni, char *buf, size_t bufsize)
 
const charscore_tooltip (const struct player *pplayer, int score)
 

Macro Definition Documentation

◆ FAR_CITY_SQUARE_DIST

#define FAR_CITY_SQUARE_DIST   (2*(6*6))

Definition at line 435 of file text.c.

Function Documentation

◆ act_sel_action_tool_tip()

const char * act_sel_action_tool_tip ( const struct action paction,
const struct act_prob  prob 
)

Get information about starting the action in the current situation. Suitable for a tool tip for the button that starts it.

Not re-entrant

Returns
an explanation of a tool tip button suitable for a tool tip

Definition at line 1789 of file text.c.

Referenced by action_entry(), action_entry(), action_entry_update(), and action_entry_update().

◆ format_duration()

static const char * format_duration ( int  duration)
static

Format a duration, in seconds, so it comes up in minutes or hours if that would be more meaningful.

(English original 7 characters, maximum. Enough for, e.g., "99h 59m".)

Not re-entrant

Definition at line 1590 of file text.c.

Referenced by get_timeout_label_text().

◆ get_act_sel_action_custom_text()

const char * get_act_sel_action_custom_text ( struct action paction,
const struct act_prob  prob,
const struct unit actor_unit,
const struct city target_city 
)

Returns custom part of the action selection dialog button text for the specified action (given that the action is possible).

Not re-entrant

Definition at line 1710 of file text.c.

Referenced by action_entry(), action_selection_refresh(), and popup_action_selection().

◆ get_airlift_text()

const char * get_airlift_text ( const struct unit_list *  punits,
const struct city pdest 
)

Describe the airlift capacity of a city for the given units (from their current positions). If pdest is non-NULL, describe its capacity as a destination, otherwise describe the capacity of the city the unit's currently in (if any) as a source. (If the units in the list are in different cities, this will probably not give a useful result in this case.) If not all of the listed units can be airlifted, return the description for those that can. Returns NULL if an airlift is not possible for any of the units.

Not re-entrant

Definition at line 545 of file text.c.

Referenced by goto_dialog::fill_tab(), refresh_airlift_column(), and update_source_label().

◆ get_bulb_tooltip()

const char * get_bulb_tooltip ( void  )

Get a tooltip text for the info panel research indicator. See client_research_sprite().

Not re-entrant

Definition at line 1367 of file text.c.

Referenced by update_info_label().

◆ get_bulbs_per_turn()

static int get_bulbs_per_turn ( int pours,
bool pteam,
int ptheirs 
)
static

Return total expected bulbs.

Definition at line 649 of file text.c.

Referenced by get_bulb_tooltip(), get_info_label_text_popup(), get_science_goal_text(), get_science_target_text(), and science_dialog_text().

◆ get_full_nation()

static void get_full_nation ( char buf,
int  buflen,
const struct player pplayer 
)
inlinestatic

Fill the buffer with the player's nation name (in adjective form) and optionally add the player's team name.

Definition at line 120 of file text.c.

Referenced by popup_info_text().

◆ get_full_username()

static void get_full_username ( char buf,
int  buflen,
const struct player pplayer 
)
inlinestatic

For AIs, fill the buffer with their player name prefixed with "AI". For humans, just fill it with their username.

Definition at line 96 of file text.c.

Referenced by popup_info_text().

◆ get_global_warming_tooltip()

const char * get_global_warming_tooltip ( void  )

Get a tooltip text for the info panel global warning indicator. See also client_warming_sprite().

Not re-entrant

Definition at line 1424 of file text.c.

Referenced by update_info_label().

◆ get_government_tooltip()

const char * get_government_tooltip ( void  )

Get a tooltip text for the info panel government indicator. See also government_by_number(...)->sprite.

Not re-entrant

Definition at line 1478 of file text.c.

Referenced by update_info_label().

◆ get_info_label_text()

const char * get_info_label_text ( bool  moreinfo)

Return the text for the label on the info panel. (This is traditionally shown to the left of the mapview.)

Clicking on this text should bring up the get_info_label_text_popup() text.

Not re-entrant

Definition at line 917 of file text.c.

Referenced by update_info_label(), and fc_client::update_sidebar_tooltips().

◆ get_info_label_text_popup()

const char * get_info_label_text_popup ( void  )

Return the text for the popup label on the info panel. (This is traditionally done as a popup whenever the regular info text is clicked on.)

Not re-entrant

Definition at line 969 of file text.c.

Referenced by show_info_popup(), show_info_popup(), and fc_client::update_sidebar_tooltips().

◆ get_nearest_city_text()

const char * get_nearest_city_text ( struct city pcity,
int  sq_dist 
)

Returns the text describing the city and its distance.

Not re-entrant

Definition at line 441 of file text.c.

Referenced by create_present_supported_units_widget_list(), and unit_description().

◆ get_nuclear_winter_tooltip()

const char * get_nuclear_winter_tooltip ( void  )

Get a tooltip text for the info panel nuclear winter indicator. See also client_cooling_sprite().

Not re-entrant

Definition at line 1451 of file text.c.

Referenced by update_info_label().

◆ get_ping_time_text()

const char * get_ping_time_text ( const struct player pplayer)

Return text giving the ping time for the player. This is generally used in the playerdlg. This should only be used in plrdlg_common.c.

Not re-entrant

Definition at line 1621 of file text.c.

◆ get_report_title()

const char * get_report_title ( const char report_name)

Get the title for a "report". This may include the city, economy, military, trade, player, etc., reports. Some clients may generate the text themselves to get a better GUI layout.

Not re-entrant

Definition at line 1672 of file text.c.

◆ get_science_goal_text()

const char * get_science_goal_text ( Tech_type_id  goal)

Set the science-goal-label text as if we're researching the given goal.

Not re-entrant

Definition at line 866 of file text.c.

Referenced by real_science_report_dialog_update(), science_report_update(), and science_report::update_report().

◆ get_science_target_text()

const char * get_science_target_text ( double percent)

Get the short science-target text. This is usually shown directly in the progress bar.

5/28 - 3 turns

The "percent" value, if given, will be set to the completion percentage of the research target (actually it's a [0,1] scale not a percent).

Not re-entrant

Definition at line 820 of file text.c.

Referenced by get_info_label_text_popup(), real_science_report_dialog_update(), science_report_update(), and science_report::update_report().

◆ get_score_text()

const char * get_score_text ( const struct player pplayer)

Return text giving the score of the player. This should only be used in plrdlg_common.c.

Not re-entrant

Definition at line 1650 of file text.c.

◆ get_spaceship_descr()

const char * get_spaceship_descr ( struct player_spaceship pship)

Returns a description of the given spaceship. If there is no spaceship (pship is NULL) then text with dummy values is returned.

Not re-entrant

Definition at line 1500 of file text.c.

Referenced by create_spaceship_dialog(), popup_spaceship_dialog(), refresh_spaceship_dialog(), spaceship_dialog_update_info(), and ss_report::update_report().

◆ get_tile_output_text()

const char * get_tile_output_text ( const struct tile ptile)

Return a (static) string with a tile's food/prod/trade

Not re-entrant

Definition at line 63 of file text.c.

Referenced by popup_info_text(), popup_terrain_info(), and redraw_unit_info_label().

◆ get_timeout_label_text()

const char * get_timeout_label_text ( void  )

Get the text showing the timeout. This is generally displayed on the info panel.

Not re-entrant

Definition at line 1557 of file text.c.

Referenced by qtg_update_timeout_label(), and update_timeout_label().

◆ get_unit_info_label_text1()

const char * get_unit_info_label_text1 ( struct unit_list *  punits)

Return the title text for the unit info shown in the info panel.

Not re-entrant

FIXME: this should be renamed.

Definition at line 1054 of file text.c.

Referenced by update_unit_info_label().

◆ get_unit_info_label_text2()

const char * get_unit_info_label_text2 ( struct unit_list *  punits,
int  linebreaks 
)

Return the text body for the unit info shown in the info panel.

Not re-entrant

FIXME: this should be renamed.

Definition at line 1079 of file text.c.

Referenced by redraw_unit_info_label(), and update_unit_info_label().

◆ get_units_disband_info()

bool get_units_disband_info ( char buf,
size_t  bufsz,
struct unit_list *  punits 
)

Fill buffer with text about disbanding units on the list.

Returns TRUE iff any units can be disbanded.

Definition at line 1323 of file text.c.

Referenced by popup_disband_dialog(), and popup_unit_disband_dlg().

◆ get_units_upgrade_info()

bool get_units_upgrade_info ( char buf,
size_t  bufsz,
struct unit_list *  punits 
)

Fill buffer with text about upgrading units on the list.

Returns TRUE iff any units can be upgraded.

Definition at line 1257 of file text.c.

Referenced by popup_upgrade_dialog().

◆ popup_info_text()

const char * popup_info_text ( struct tile ptile)

Text to popup on a middle-click in the mapview.

Not re-entrant

Definition at line 147 of file text.c.

Referenced by info_tile::calc_size(), popit(), popit(), popup_terrain_info_dialog(), and hud_units::update_actions().

◆ production_help()

const char * production_help ( const struct universal uni,
char buf,
size_t  bufsize 
)

Fill provided buffer with relatively short (not full) helptext of the universal.

Definition at line 2089 of file text.c.

Referenced by drag_drop(), menu_item_callback(), menu_item_callback(), and refresh_worklist().

◆ science_dialog_text()

const char * science_dialog_text ( void  )

Returns the text to display in the science dialog.

Not re-entrant

Definition at line 741 of file text.c.

Referenced by real_science_report_dialog_update(), science_report_update(), show_new_turn_info(), science_report::update_report(), and fc_client::update_sidebar_tooltips().

◆ score_tooltip()

const char * score_tooltip ( const struct player pplayer,
int  score 
)

Tooltip for the player row on reports. Negative score is not shown.

Not re-entrant

Definition at line 2126 of file text.c.

Referenced by endgame_report_dialog_player(), and fill_row().

◆ text_happiness_buildings()

const char * text_happiness_buildings ( const struct city pcity)

Describe buildings that affect happiness.

Not re-entrant

Definition at line 1800 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), and city_dialog::update_citizens().

◆ text_happiness_cities()

const char * text_happiness_cities ( const struct city pcity)

Describe city factors that affect happiness.

Not re-entrant

Definition at line 1900 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), city_dialog::update_citizens(), and fc_client::update_sidebar_tooltips().

◆ text_happiness_luxuries()

const char * text_happiness_luxuries ( const struct city pcity)

Describe luxuries that affect happiness.

Not re-entrant

Definition at line 2072 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), and city_dialog::update_citizens().

◆ text_happiness_nationality()

const char * text_happiness_nationality ( const struct city pcity)

Describe nationality effects that affect happiness.

Not re-entrant

Definition at line 1828 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), and city_dialog::update_citizens().

◆ text_happiness_units()

const char * text_happiness_units ( const struct city pcity)

Describe units that affect happiness.

Not re-entrant

Definition at line 2034 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), and city_dialog::update_citizens().

◆ text_happiness_wonders()

const char * text_happiness_wonders ( const struct city pcity)

Describe wonders that affect happiness.

Not re-entrant

Definition at line 1870 of file text.c.

Referenced by show_happiness_popup(), show_happiness_popup(), and city_dialog::update_citizens().

◆ turns_per_advance()

static int turns_per_advance ( const struct research presearch,
int  per_turn 
)
static

Return turns per advance (based on currently researched advance). -1 for no progress.

Definition at line 708 of file text.c.

Referenced by science_dialog_text().

◆ turns_to_research_done()

static int turns_to_research_done ( const struct research presearch,
int  per_turn 
)
static

Return turns until research complete. -1 for never.

Definition at line 693 of file text.c.

Referenced by get_bulb_tooltip(), and get_science_target_text().

◆ turns_to_tech_loss()

static int turns_to_tech_loss ( const struct research presearch,
int  per_turn 
)
static

Return turns until an advance is lost due to tech upkeep. -1 if we're not on the way to losing an advance.

Definition at line 721 of file text.c.

Referenced by get_bulb_tooltip(), get_science_target_text(), and science_dialog_text().

◆ unit_description()

const char * unit_description ( struct unit punit)

Returns a unit description. Used in e.g. city report tooltips.

Not re-entrant

Definition at line 475 of file text.c.

Referenced by city_dialog_update_present_units(), city_dialog_update_supported_units(), unit_item::unit_item(), and units_orders_city_dlg_callback().