Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
wldlg.c File Reference
#include <stdlib.h>
#include <SDL2/SDL.h>
#include "fcintl.h"
#include "log.h"
#include "game.h"
#include "movement.h"
#include "unit.h"
#include "client_main.h"
#include "climisc.h"
#include "global_worklist.h"
#include "citydlg.h"
#include "colors.h"
#include "graphics.h"
#include "gui_id.h"
#include "gui_main.h"
#include "gui_tilespec.h"
#include "helpdlg.h"
#include "mapview.h"
#include "sprite.h"
#include "themespec.h"
#include "widget.h"
#include "wldlg.h"

Go to the source code of this file.

Data Structures

struct  wl_editor
 

Macros

#define TARGETS_COL   4
 
#define TARGETS_ROW   4
 

Functions

static int worklist_editor_item_callback (struct widget *pwidget)
 
static SDL_Surfaceget_progress_icon (int stock, int cost, int *progress)
 
static const charget_production_name (struct city *pcity, struct universal prod, int *cost)
 
static void refresh_worklist_count_label (void)
 
static void refresh_production_label (int stock)
 
static int window_worklist_editor_callback (struct widget *pwidget)
 
static int popdown_worklist_editor_callback (struct widget *pwidget)
 
static int ok_worklist_editor_callback (struct widget *pwidget)
 
static int rename_worklist_editor_callback (struct widget *pwidget)
 
static void add_target_to_worklist (struct widget *target)
 
static bool are_prods_same_class (const struct universal *one, const struct universal *two)
 
static void change_production (struct universal *prod)
 
static void add_target_to_production (struct widget *target)
 
static void get_target_help_data (struct widget *target)
 
static int worklist_editor_targets_callback (struct widget *pwidget)
 
static void remove_item_from_worklist (struct widget *item)
 
static void swap_item_down_from_worklist (struct widget *item)
 
static void swap_item_up_from_worklist (struct widget *item)
 
static void add_global_worklist (struct widget *pwidget)
 
static void set_global_worklist (struct widget *pwidget)
 
static int global_worklist_callback (struct widget *pwidget)
 
void popup_worklist_editor (struct city *pcity, struct global_worklist *gwl)
 
void popdown_worklist_editor (void)
 

Variables

struct wl_editoreditor = NULL
 

Macro Definition Documentation

◆ TARGETS_COL

#define TARGETS_COL   4

Definition at line 63 of file wldlg.c.

◆ TARGETS_ROW

#define TARGETS_ROW   4

Definition at line 64 of file wldlg.c.

Function Documentation

◆ add_global_worklist()

static void add_global_worklist ( struct widget pwidget)
static

Add global worklist to city worklist starting from last free entry. Add only avilable targets in current game state. If global worklist have more targets that city worklist have free entries then we adding only first part of global worklist.

Definition at line 670 of file wldlg.c.

Referenced by global_worklist_callback().

◆ add_target_to_production()

static void add_target_to_production ( struct widget target)
static

Change production of city but only in Editor. You must commit this changes by exit editor via OK button (commit function).

This function don't remove double imprv./wonder target entry from worklist and allow more entry of such target (In Production and worklist - this is fixed by commit function).

Definition at line 350 of file wldlg.c.

Referenced by worklist_editor_targets_callback().

◆ add_target_to_worklist()

static void add_target_to_worklist ( struct widget target)
static

Add target to worklist.

Definition at line 206 of file wldlg.c.

Referenced by worklist_editor_targets_callback().

◆ are_prods_same_class()

static bool are_prods_same_class ( const struct universal one,
const struct universal two 
)
static

Find if two targets are the same class (unit, imprv. , wonder). This is needed by calculation of change production shields penalty. [similar to are_universals_equal()]

Definition at line 303 of file wldlg.c.

Referenced by change_production().

◆ change_production()

static void change_production ( struct universal prod)
static

Change production in editor shell, calculate production shields penalty and refresh production progress label

Definition at line 325 of file wldlg.c.

Referenced by add_target_to_production(), remove_item_from_worklist(), swap_item_down_from_worklist(), and swap_item_up_from_worklist().

◆ get_production_name()

static const char * get_production_name ( struct city pcity,
struct universal  prod,
int cost 
)
static

Return full unit/imprv. name and build cost in "cost" pointer.

Definition at line 880 of file wldlg.c.

Referenced by add_target_to_production(), and refresh_production_label().

◆ get_progress_icon()

static SDL_Surface * get_progress_icon ( int  stock,
int  cost,
int progress 
)
static

Return progress icon (bar) of current production state stock - current shields stocks cost - unit/imprv. cost function return in "progress" pointer (0 - 100 %) progress in numbers

Definition at line 900 of file wldlg.c.

Referenced by popup_worklist_editor(), and refresh_production_label().

◆ get_target_help_data()

static void get_target_help_data ( struct widget target)
static

Get Help Info about target

Definition at line 388 of file wldlg.c.

Referenced by worklist_editor_targets_callback().

◆ global_worklist_callback()

static int global_worklist_callback ( struct widget pwidget)
static

Global worklist callback left mouse button -> add global worklist to current city list right mouse button -> clear city worklist and copy here global worklist.

There are problems with imprv./wonder targets because those can't be doubled on worklist and adding/setting can give you situation that global worklist have imprv./wonder entry that exist on city worklist or in building state. I don't make such check here and allow this "functionality" because doubled imprv./wonder entry are removed from city worklist during "commit" phase.

Definition at line 851 of file wldlg.c.

Referenced by popup_worklist_editor().

◆ ok_worklist_editor_callback()

static int ok_worklist_editor_callback ( struct widget pwidget)
static

Commit changes to city/global worklist. In City Mode Remove Double entry of Imprv/Woder Targets from list.

Definition at line 124 of file wldlg.c.

Referenced by add_target_to_production(), and popup_worklist_editor().

◆ popdown_worklist_editor()

void popdown_worklist_editor ( void  )

Close worklist from view.

Definition at line 1870 of file wldlg.c.

Referenced by ok_worklist_editor_callback(), popdown_all_game_dialogs(), and popdown_worklist_editor_callback().

◆ popdown_worklist_editor_callback()

static int popdown_worklist_editor_callback ( struct widget pwidget)
static

Popdwon Worklist Editor

Definition at line 111 of file wldlg.c.

Referenced by popup_worklist_editor().

◆ popup_worklist_editor()

void popup_worklist_editor ( struct city pcity,
struct global_worklist gwl 
)

Global/City worklist editor. if pcity == NULL then function takes worklist as global worklist. worklist must be not NULL.

Definition at line 1061 of file wldlg.c.

Referenced by button_up_on_map(), change_prod_dlg_callback(), change_production_callback(), edit_worklist_callback(), and popup_worklist_from_city_report_callback().

◆ refresh_production_label()

static void refresh_production_label ( int  stock)
static

Update and redraw production name label in worklist editor. stock - pcity->shields_stock or current stock after change production lost.

Definition at line 937 of file wldlg.c.

Referenced by change_production().

◆ refresh_worklist_count_label()

static void refresh_worklist_count_label ( void  )
static

Update and redraw worklist length counter in worklist editor

Definition at line 1018 of file wldlg.c.

Referenced by add_global_worklist(), add_target_to_worklist(), remove_item_from_worklist(), and set_global_worklist().

◆ remove_item_from_worklist()

static void remove_item_from_worklist ( struct widget item)
static

Remove element from worklist or remove currently building imprv/unit and change production to first worklist element (or Capitalizations if worklist is empty)

Definition at line 454 of file wldlg.c.

Referenced by swap_item_down_from_worklist(), swap_item_up_from_worklist(), and worklist_editor_item_callback().

◆ rename_worklist_editor_callback()

static int rename_worklist_editor_callback ( struct widget pwidget)
static

Rename Global Worklist

Definition at line 183 of file wldlg.c.

Referenced by popup_worklist_editor().

◆ set_global_worklist()

static void set_global_worklist ( struct widget pwidget)
static

Clear city worklist and copy here global worklist. Copy only available targets in current game state. If all targets are unavilable then leave city worklist untouched.

Definition at line 749 of file wldlg.c.

Referenced by global_worklist_callback().

◆ swap_item_down_from_worklist()

static void swap_item_down_from_worklist ( struct widget item)
static

Swap worklist entries DOWN. Fuction swap current element with next element of worklist.

If item is last widget or there is only one widget on widgets list fuction remove this widget from widget list and target from worklist

In City mode, when item is first worklist element, function make change production (currently building is moved to first element of worklist and first element of worklist is build).

Definition at line 530 of file wldlg.c.

Referenced by worklist_editor_item_callback().

◆ swap_item_up_from_worklist()

static void swap_item_up_from_worklist ( struct widget item)
static

Swap worklist entries UP. Fuction swap current element with prev. element of worklist.

If item is first widget on widgets list fuction remove this widget from widget list and target from worklist (global mode) or from production (city mode)

In City mode, when item is first worklist element, function make change production (currently building is moved to first element of worklist and first element of worklist is build).

Definition at line 587 of file wldlg.c.

Referenced by worklist_editor_item_callback().

◆ window_worklist_editor_callback()

static int window_worklist_editor_callback ( struct widget pwidget)
static

Worklist Editor Window Callback

Definition at line 103 of file wldlg.c.

Referenced by popup_worklist_editor().

◆ worklist_editor_item_callback()

static int worklist_editor_item_callback ( struct widget pwidget)
static

worklist callback left mouse button -> swap entries up. middle mouse button -> remove element from list right mouse button -> swap entries down.

Definition at line 639 of file wldlg.c.

Referenced by add_global_worklist(), add_target_to_worklist(), popup_worklist_editor(), and set_global_worklist().

◆ worklist_editor_targets_callback()

static int worklist_editor_targets_callback ( struct widget pwidget)
static

Targets callback left mouse button -> In city mode change production to target. In global mode add target to worklist. middle mouse button -> get target "help" right mouse button -> add target to worklist.

Definition at line 415 of file wldlg.c.

Referenced by popup_worklist_editor().

Variable Documentation

◆ editor

struct wl_editor * editor = NULL