Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
wldlg.c File Reference
#include <stdlib.h>
#include <SDL3/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 59 of file wldlg.c.

◆ TARGETS_ROW

#define TARGETS_ROW   4

Definition at line 60 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 666 of file wldlg.c.

◆ 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 346 of file wldlg.c.

◆ add_target_to_worklist()

static void add_target_to_worklist ( struct widget target)
static

Add target to worklist.

Definition at line 202 of file wldlg.c.

◆ 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 299 of file wldlg.c.

◆ 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 321 of file wldlg.c.

◆ 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 876 of file wldlg.c.

◆ 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 896 of file wldlg.c.

◆ get_target_help_data()

static void get_target_help_data ( struct widget target)
static

Get Help Info about target

Definition at line 384 of file wldlg.c.

◆ 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 847 of file wldlg.c.

◆ 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 120 of file wldlg.c.

◆ popdown_worklist_editor()

void popdown_worklist_editor ( void  )

Close worklist from view.

Definition at line 1866 of file wldlg.c.

◆ popdown_worklist_editor_callback()

static int popdown_worklist_editor_callback ( struct widget pwidget)
static

Popdwon Worklist Editor

Definition at line 107 of file wldlg.c.

◆ 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 1057 of file wldlg.c.

◆ 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 933 of file wldlg.c.

◆ refresh_worklist_count_label()

static void refresh_worklist_count_label ( void  )
static

Update and redraw worklist length counter in worklist editor

Definition at line 1014 of file wldlg.c.

◆ 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 450 of file wldlg.c.

◆ rename_worklist_editor_callback()

static int rename_worklist_editor_callback ( struct widget pwidget)
static

Rename Global Worklist

Definition at line 179 of file wldlg.c.

◆ 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 745 of file wldlg.c.

◆ 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 526 of file wldlg.c.

◆ 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 583 of file wldlg.c.

◆ window_worklist_editor_callback()

static int window_worklist_editor_callback ( struct widget pwidget)
static

Worklist Editor Window Callback

Definition at line 99 of file wldlg.c.

◆ 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 635 of file wldlg.c.

◆ 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 411 of file wldlg.c.

Variable Documentation

◆ editor

struct wl_editor * editor = NULL