28#ifdef SDL2_PLAIN_INCLUDE
132 if (VUT_IMPROVEMENT ==
editor->worklist_copy.entries[i].kind) {
134 if (VUT_IMPROVEMENT ==
editor->worklist_copy.entries[j].kind
135 &&
editor->worklist_copy.entries[i].value.building ==
136 editor->worklist_copy.entries[j].value.building) {
145 if (VUT_IMPROVEMENT ==
editor->currently_building.kind) {
147 if (VUT_IMPROVEMENT ==
editor->worklist_copy.entries[i].kind
148 &&
editor->worklist_copy.entries[i].value.building ==
149 editor->currently_building.value.building) {
219 && VUT_IMPROVEMENT == prod.
kind
229 if (VUT_IMPROVEMENT == prod.
kind
238 if (VUT_UTYPE == prod.
kind) {
259 if (
editor->work->begin_active_widget_list) {
260 dock =
editor->work->begin_active_widget_list;
272 editor->work->scroll->up_left_button->size.h + 1,
274 editor->work->end_widget_list);
310 if (VUT_IMPROVEMENT == one->
kind) {
338 editor->currently_building = *prod;
401 if (VUT_UTYPE == prod.
kind) {
419 case SDL_BUTTON_LEFT:
426 case SDL_BUTTON_MIDDLE:
429 case SDL_BUTTON_RIGHT:
461 if (
item->data.ptr) {
465 if (
buf !=
editor->work->begin_active_widget_list) {
468 *((
int *)
buf->data.ptr) = *((
int *)
buf->data.ptr) - 1;
469 }
while (
buf !=
editor->work->begin_active_widget_list);
485 if (
buf !=
editor->work->begin_active_widget_list) {
488 *((
int *)
buf->data.ptr) = *((
int *)
buf->data.ptr) - 1;
489 }
while (
buf !=
editor->work->begin_active_widget_list);
502 editor->work->end_widget_list);
534 bool changed =
FALSE;
537 if (
item ==
editor->work->begin_active_widget_list) {
542 text =
item->string_utf8->text;
546 if (
item->data.ptr) {
548 int row = *((
int *)
item->data.ptr);
550 tmp =
editor->worklist_copy.entries[row];
551 editor->worklist_copy.entries[row] =
editor->worklist_copy.entries[row + 1];
552 editor->worklist_copy.entries[row + 1] = tmp;
563 item->string_utf8->text =
item->prev->string_utf8->text;
566 item->prev->string_utf8->text = text;
589 char *text =
item->string_utf8->text;
590 Uint16
id =
item->id;
591 bool changed =
FALSE;
595 if (
item ==
editor->work->end_active_widget_list) {
602 if (
item->data.ptr && *((
int *)
item->data.ptr) > 0) {
604 int row = *((
int *)
item->data.ptr);
606 tmp =
editor->worklist_copy.entries[row];
607 editor->worklist_copy.entries[row] =
editor->worklist_copy.entries[row - 1];
608 editor->worklist_copy.entries[row - 1] = tmp;
613 tmp =
editor->currently_building;
615 editor->worklist_copy.entries[0] = tmp;
621 item->string_utf8->text =
item->next->string_utf8->text;
624 item->next->string_utf8->text = text;
643 case SDL_BUTTON_LEFT:
646 case SDL_BUTTON_MIDDLE:
649 case SDL_BUTTON_RIGHT:
674 int count, firstfree;
726 buf,
editor->work->begin_active_widget_list,
783 if (buf !=
editor->work->begin_active_widget_list) {
785 if (buf !=
editor->work->begin_active_widget_list) {
789 }
while (buf !=
editor->work->begin_active_widget_list);
805 if (VUT_UTYPE == target.
kind) {
824 *((
int *)buf->
data.
ptr) = count;
827 buf,
editor->work->begin_active_widget_list,
FALSE,
855 case SDL_BUTTON_LEFT:
858 case SDL_BUTTON_MIDDLE:
861 case SDL_BUTTON_RIGHT:
887 if (VUT_UTYPE == prod.
kind) {
902 SDL_Surface *icon = NULL;
909 *progress = ((float)stock /
cost) * 100.0;
910 if (!
width && stock) {
922 SDL_Rect dst = {2,1,0,0};
947 if (VUT_IMPROVEMENT ==
editor->currently_building.kind && gold_prod) {
951 PL_(
"%s\n%d gold per turn",
952 "%s\n%d gold per turn", gold),
962 name, turns,
PL_(
"turn",
"turns", turns));
973 editor->production_name->size.x =
editor->end_widget_list->area.x +
977 area.x =
editor->end_widget_list->area.x;
978 area.y =
editor->production_name->size.y;
980 area.h =
editor->production_name->size.h;
991 editor->production_progress->theme =
1013 if (
editor->pcity != NULL) {
1019 PL_(
"( %d entry )",
"( %d entries )",
len),
len);
1025 editor->worklist_counter->size.x =
editor->end_widget_list->area.x +
1035 area.x =
editor->end_widget_list->area.x;
1036 area.y =
editor->worklist_counter->size.y;
1038 area.h =
editor->worklist_counter->size.h;
1052 SDL_Color bg_color = {255,255,255,128};
1053 SDL_Color bg_color2 = {255,255,255,136};
1054 int count = 0, turns;
1055 int widget_w = 0, widget_h = 0;
1066 bool can_build, can_eventually_build;
1079 editor->global_worklist_id = -1;
1085 }
else if (gwl != NULL) {
1096 advanced_tech = (pcity == NULL);
1101 SDL_FillRect(main_surf, NULL,
map_rgba(main_surf->format, bg_color));
1104 0, 0, main_surf->w - 1, main_surf->h - 1,
1114 editor->end_widget_list = pwindow;
1116 area = pwindow->area;
1136 PL_(
"( %d entry )",
"( %d entries )",
len),
len);
1138 pstr->
bgcol = (SDL_Color) {0, 0, 0, 0};
1140 editor->worklist_counter = buf;
1157 PL_(
"%s\n%d gold per turn",
1158 "%s\n%d gold per turn", gold),
1167 name, turns,
PL_(
"turn",
"turns", turns));
1177 editor->production_name = buf;
1195 editor->production_progress = buf;
1213 buf->
key = SDLK_RETURN;
1223 buf->
key = SDLK_ESCAPE;
1240 editor->work->scroll->count = 0;
1242 editor->work->scroll->step = 1;
1263 editor->work->end_widget_list = buf;
1264 editor->work->begin_widget_list = buf;
1265 editor->work->end_active_widget_list =
editor->work->end_widget_list;
1266 editor->work->begin_active_widget_list =
editor->work->begin_widget_list;
1267 editor->work->scroll->count++;
1278 if (VUT_UTYPE == prod.kind) {
1283 prod.value.building),
1294 *((
int *)buf->
data.
ptr) = count;
1300 if (count >
editor->work->scroll->active - 1) {
1308 editor->work->end_widget_list = last->prev;
1309 editor->work->end_active_widget_list =
editor->work->end_widget_list;
1311 editor->work->begin_widget_list = buf;
1312 editor->work->begin_active_widget_list =
editor->work->begin_widget_list;
1315 editor->work->end_widget_list = last;
1317 editor->work->begin_widget_list = last;
1322 editor->work->active_widget_list =
editor->work->end_active_widget_list;
1329 if (count <= editor->work->scroll->active + 1) {
1342 editor->work->scroll->count += count;
1343 last =
editor->work->begin_widget_list;
1370 editor->global->end_widget_list = last->prev;
1371 editor->global->end_active_widget_list =
editor->global->end_widget_list;
1372 editor->global->begin_widget_list =
buf;
1373 editor->global->begin_active_widget_list =
editor->global->begin_widget_list;
1376 editor->global->active_widget_list =
editor->global->end_active_widget_list;
1380 editor->global->scroll->down_right_button->size.w =
adj_size(122);
1390 last =
editor->global->begin_widget_list;
1429 state =
_(
"Obsolete");
1434 state =
_(
"Destroyed");
1436 state =
_(
"Great Wonder");
1442 state =
_(
"Small Wonder");
1458 fc_snprintf(cbuf,
sizeof(cbuf),
_(
"(%s)\n%d/%d %s\n%s"),
1460 PL_(
"shield",
"shields",
cost),
1465 PL_(
"shield",
"shields",
cost),
_(
"never"));
1469 fc_snprintf(cbuf,
sizeof(cbuf),
_(
"(%s)\n%d/%d %s\n%d %s"),
1471 PL_(
"shield",
"shields",
cost),
1472 turns,
PL_(
"turn",
"turns", turns));
1476 PL_(
"shield",
"shields",
cost),
1477 turns,
PL_(
"turn",
"turns", turns));
1485 "%d gold per turn", gold),
1496 PL_(
"shield",
"shields",
cost));
1500 PL_(
"shield",
"shields",
cost));
1503 fc_snprintf(cbuf,
sizeof(cbuf),
_(
"shields into gold"));
1508 pstr->
style &= ~TTF_STYLE_BOLD;
1509 pstr->
style &= ~TTF_STYLE_STRIKETHROUGH;
1516 zoomed = zoomSurface(zoomed,
DEFAULT_ZOOM * ((
float)54 / zoomed->w),
1518 dst.x = (icon->w - zoomed->w) / 2;
1519 dst.y = (icon->h/2 - zoomed->h) / 2;
1520 alphablit(zoomed, NULL, icon, &dst, 255);
1524 dst.x = (icon->w - text_name->w) / 2;
1525 dst.y += ((icon->h - dst.y) - (text_name->h + text->h)) / 2;
1526 alphablit(text_name, NULL, icon, &dst, 255);
1528 dst.x = (icon->w - text->w) / 2;
1529 dst.y += text_name->h;
1539 widget_w =
MAX(widget_w, buf->
size.w);
1540 widget_h =
MAX(widget_h, buf->
size.h);
1557 can_eventually_build =
1563 can_eventually_build = can_eventually_build
1567 if ((advanced_tech && can_eventually_build)
1568 || (!advanced_tech && can_build)) {
1577 pstr->
style |= TTF_STYLE_BOLD;
1588 _(
"(%d/%d/%s)\n%d/%d %s\nnever"),
1593 PL_(
"shield",
"shields",
cost));
1596 _(
"(%d/%d/%s)\n%d/%d %s\n%d %s"),
1601 PL_(
"shield",
"shields",
cost),
1602 turns,
PL_(
"turn",
"turns", turns));
1608 _(
"(%d/%d/%s)\n%d %s"),
1613 PL_(
"shield",
"shields",
cost));
1617 pstr->
style &= ~TTF_STYLE_BOLD;
1622 dst.x = (icon->w - zoomed->w) / 2;
1623 dst.y = (icon->h / 2 - zoomed->h) / 2;
1624 alphablit(zoomed, NULL, icon, &dst, 255);
1627 dst.x = (icon->w - text_name->w) / 2;
1628 dst.y = icon->h / 2 + (icon->h / 2 - (text_name->h + text->h)) / 2;
1629 alphablit(text_name, NULL, icon, &dst, 255);
1631 dst.x = (icon->w - text->w) / 2;
1632 dst.y += text_name->h;
1642 widget_w =
MAX(widget_w, buf->
size.w);
1643 widget_h =
MAX(widget_h, buf->
size.h);
1659 editor->targets->end_widget_list = last->prev;
1660 editor->targets->begin_widget_list = buf;
1661 editor->targets->end_active_widget_list =
editor->targets->end_widget_list;
1662 editor->targets->begin_active_widget_list =
editor->targets->begin_widget_list;
1663 editor->targets->active_widget_list =
editor->targets->end_active_widget_list;
1674 editor->begin_widget_list =
editor->targets->begin_widget_list;
1682 (pwindow->size.w - pwindow->area.w) + area.w,
1683 (pwindow->size.h - pwindow->area.h) + area.h)) {
1687 area = pwindow->area;
1695 SDL_FillRect(pwindow->theme, &dst,
1700 dst.x, dst.y, dst.w - 1, dst.h - 1,
1703 dst.x + 2, dst.y + 2, dst.w - 5, dst.h - 5,
1713 dst.x, dst.y, dst.w - 1, dst.h - 1,
1720 dst.h = pwindow->size.h - dst.y -
adj_size(4);
1722 SDL_FillRect(pwindow->theme, &dst,
1727 dst.x, dst.y, dst.w - 1, dst.h - 1,
1740 buf = pwindow->
prev;
1784 editor->work->end_widget_list);
1797 (
editor->global->scroll ?
1798 editor->global->scroll->up_left_button->size.h + 1 : 0),
1800 editor->global->end_widget_list);
1802 if (
editor->global->scroll) {
1814 0, 0,
editor->targets->begin_widget_list,
1815 editor->targets->end_widget_list);
1817 if (
editor->targets->scroll) {
1840 editor->end_widget_list);
struct canvas int int struct sprite int int int width
int city_turns_to_build(const struct city *pcity, const struct universal *target, bool include_shield_stock)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
int city_production_build_shield_cost(const struct city *pcity)
const char * city_name_get(const struct city *pcity)
bool can_city_build_later(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
bool can_city_build_improvement_now(const struct city *pcity, const struct impr_type *pimprove)
int city_production_turns_to_build(const struct city *pcity, bool include_shield_stock)
int city_change_production_penalty(const struct city *pcity, const struct universal *target)
bool can_city_build_unit_now(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
bool can_city_build_improvement_later(const struct city *pcity, const struct impr_type *pimprove)
bool can_city_build_unit_later(const struct civ_map *nmap, const struct city *pcity, const struct unit_type *punittype)
const char * city_production_name_translation(const struct city *pcity)
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
int city_change_production(struct city *pcity, struct universal *target)
cid cid_encode_building(const struct impr_type *pimprove)
cid cid_encode(struct universal target)
struct universal cid_decode(cid id)
cid cid_encode_unit(const struct unit_type *punittype)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
static struct editor_state * editor
#define PL_(String1, String2, n)
struct global_worklist * global_worklist_by_id(int id)
bool global_worklist_set(struct global_worklist *pgwl, const struct worklist *pwl)
const char * global_worklist_name(const struct global_worklist *pgwl)
int global_worklist_id(const struct global_worklist *pgwl)
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
void global_worklist_set_name(struct global_worklist *pgwl, const char *name)
#define global_worklists_iterate(pgwl)
#define global_worklists_iterate_end
bool city_dialog_is_open(struct city *pcity)
void update_worklist_report_dialog(void)
void enable_city_dlg_widgets(void)
SDL_Color * get_theme_color(enum theme_color themecolor)
int main_window_width(void)
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
struct sdl2_data main_data
SDL_Surface * create_surf(int width, int height, Uint32 flags)
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
int main_window_height(void)
#define map_rgba(format, color)
#define PRESSED_EVENT(event)
void popup_impr_info(Impr_type_id impr)
void popup_unit_info(Unit_type_id type_id)
void dirty_sdl_rect(SDL_Rect *Rect)
static void get_target_help_data(struct widget *target)
static void add_target_to_worklist(struct widget *target)
static void set_global_worklist(struct widget *pwidget)
static bool are_prods_same_class(const struct universal *one, const struct universal *two)
static const char * get_production_name(struct city *pcity, struct universal prod, int *cost)
static int window_worklist_editor_callback(struct widget *pwidget)
static void add_target_to_production(struct widget *target)
static void swap_item_down_from_worklist(struct widget *item)
static int popdown_worklist_editor_callback(struct widget *pwidget)
static int ok_worklist_editor_callback(struct widget *pwidget)
static SDL_Surface * get_progress_icon(int stock, int cost, int *progress)
void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
static void remove_item_from_worklist(struct widget *item)
static void refresh_worklist_count_label(void)
static int worklist_editor_item_callback(struct widget *pwidget)
static int global_worklist_callback(struct widget *pwidget)
void popdown_worklist_editor(void)
static int worklist_editor_targets_callback(struct widget *pwidget)
static void add_global_worklist(struct widget *pwidget)
static void swap_item_up_from_worklist(struct widget *item)
static int rename_worklist_editor_callback(struct widget *pwidget)
static void change_production(struct universal *prod)
static void refresh_production_label(int stock)
utf8_str * copy_chars_to_utf8_str(utf8_str *pstr, const char *pchars)
SDL_Surface * create_text_surf_from_utf8(utf8_str *pstr)
utf8_str * create_utf8_str_fonto(char *in_text, size_t n_alloc, enum font_origin origin)
SDL_Surface * create_text_surf_smaller_than_w(utf8_str *pstr, int w)
#define FREEUTF8STR(pstr)
#define create_utf8_from_char_fonto(string_in, fonto)
static SDL_Surface * get_building_surface(const struct impr_type *pimprove)
static SDL_Surface * get_unittype_surface(const struct unit_type *punittype, enum direction8 facing)
bool great_wonder_is_built(const struct impr_type *pimprove)
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
bool can_player_build_improvement_later(const struct player *p, const struct impr_type *pimprove)
bool great_wonder_is_destroyed(const struct impr_type *pimprove)
bool can_player_build_improvement_now(const struct player *p, struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool small_wonder_is_built(const struct player *pplayer, const struct impr_type *pimprove)
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
bool improvement_has_flag(const struct impr_type *pimprove, enum impr_flag_id flag)
const char * improvement_name_translation(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert_ret_val(condition, val)
#define fc_calloc(n, esz)
const char * move_points_text(int mp, bool reduce)
int universal_build_shield_cost(const struct city *pcity, const struct universal *target)
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
struct universal production
struct worklist worklist_copy
struct widget * end_widget_list
struct advanced_dialog * work
struct widget * begin_widget_list
struct widget * production_name
struct widget * worklist_counter
char worklist_name[MAX_LEN_NAME]
struct advanced_dialog * targets
struct advanced_dialog * global
struct universal currently_building
struct widget * production_progress
struct universal entries[MAX_LEN_WORKLIST]
int fc_snprintf(char *str, size_t n, const char *format,...)
#define sz_strlcpy(dest, src)
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
@ COLOR_THEME_WLDLG_FRAME
struct theme * active_theme
const struct unit_type * utype
const struct impr_type * building
Unit_type_id utype_number(const struct unit_type *punittype)
bool can_player_build_unit_later(const struct player *p, const struct unit_type *punittype)
int utype_build_shield_cost(const struct city *pcity, const struct player *pplayer, const struct unit_type *punittype)
bool can_player_build_unit_now(const struct player *p, const struct unit_type *punittype)
const char * utype_name_translation(const struct unit_type *punittype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end
void worklist_advance(struct worklist *pwl)
void worklist_copy(struct worklist *dst, const struct worklist *src)
void worklist_init(struct worklist *pwl)
bool worklist_peek_ith(const struct worklist *pwl, struct universal *prod, int idx)
bool worklist_is_empty(const struct worklist *pwl)
bool worklist_append(struct worklist *pwl, const struct universal *prod)
void worklist_remove(struct worklist *pwl, int idx)
int worklist_length(const struct worklist *pwl)
#define worklist_iterate_end
#define worklist_iterate(_list, _p)