diff --git a/src/building/barracks.c b/src/building/barracks.c index 72fafcd0a3..bf0755260c 100644 --- a/src/building/barracks.c +++ b/src/building/barracks.c @@ -40,6 +40,9 @@ int building_get_barracks_for_weapon(int x, int y, int resource, int road_networ if (b->resources[RESOURCE_WEAPONS] >= MAX_WEAPONS_BARRACKS) { continue; } + if (!b->accepted_goods[RESOURCE_WEAPONS]) { + continue; + } int dist = calc_maximum_distance(b->x, b->y, x, y); dist += 8 * b->resources[RESOURCE_WEAPONS]; if (dist < min_dist) { @@ -50,7 +53,8 @@ int building_get_barracks_for_weapon(int x, int y, int resource, int road_networ building *monument = building_first_of_type(BUILDING_GRAND_TEMPLE_MARS); if (monument && monument->monument.phase == MONUMENT_FINISHED && is_valid_destination(monument, road_network_id) && - (monument->resources[RESOURCE_WEAPONS] < MAX_WEAPONS_BARRACKS)) { + (monument->resources[RESOURCE_WEAPONS] < MAX_WEAPONS_BARRACKS) && + monument->accepted_goods[RESOURCE_WEAPONS]) { int dist = calc_maximum_distance(monument->x, monument->y, x, y); dist += 8 * monument->resources[RESOURCE_WEAPONS]; if (dist < min_dist) { @@ -78,7 +82,31 @@ static int get_closest_legion_needing_soldiers(const building *barracks) { int recruit_type = LEGION_RECRUIT_NONE; int min_formation_id = 0; + int min_formation_id_for_priority = 0; int min_distance = INFINITE; + int priority_recruitment = barracks->subtype.barracks_priority; + int required_recruitment = recruit_type; + + switch (priority_recruitment) { + case PRIORITY_FORT: + required_recruitment = LEGION_RECRUIT_LEGIONARY; + break; + case PRIORITY_FORT_JAVELIN: + required_recruitment = LEGION_RECRUIT_JAVELIN; + break; + case PRIORITY_FORT_MOUNTED: + required_recruitment = LEGION_RECRUIT_MOUNTED; + break; + case PRIORITY_FORT_AUXILIA_INFANTRY: + required_recruitment = LEGION_RECRUIT_INFANTRY; + break; + case PRIORITY_FORT_AUXILIA_ARCHERY: + // TODO Add archer case + default: + break; + } + + // find by recruitment priority for (int i = 1; i < formation_count(); i++) { formation *m = formation_get(i); if (!m->in_use || !m->is_legion) { @@ -92,14 +120,19 @@ static int get_closest_legion_needing_soldiers(const building *barracks) } building *fort = building_get(m->building_id); int dist = calc_maximum_distance(barracks->x, barracks->y, fort->x, fort->y); - if (m->legion_recruit_type > recruit_type || - (m->legion_recruit_type == recruit_type && dist < min_distance)) { + + // find closest one by priority + if (m->legion_recruit_type > recruit_type || (m->legion_recruit_type == recruit_type && dist < min_distance)) { + if (m->legion_recruit_type == required_recruitment) { + min_formation_id_for_priority = m->id; + } recruit_type = m->legion_recruit_type; - min_formation_id = m->id; min_distance = dist; + min_formation_id = m->id; } } - return min_formation_id; + + return min_formation_id_for_priority ? min_formation_id_for_priority : min_formation_id;; } static int get_closest_military_academy(const building *fort) @@ -170,11 +203,20 @@ static building *get_unmanned_tower_of_type(building_type type, building *barrac building *building_barracks_get_unmanned_tower(building *barracks, map_point *road) { - building *tower = get_unmanned_tower_of_type(BUILDING_TOWER, barracks, road); + int first_priority = BUILDING_TOWER; + int second_priority = BUILDING_WATCHTOWER; + + // invert priority + if (barracks->subtype.barracks_priority == PRIORITY_WATCHTOWER) { + first_priority = BUILDING_WATCHTOWER; + second_priority = BUILDING_TOWER; + } + + building *tower = get_unmanned_tower_of_type(first_priority, barracks, road); if (tower) { return tower; } - tower = get_unmanned_tower_of_type(BUILDING_WATCHTOWER, barracks, road); + tower = get_unmanned_tower_of_type(second_priority, barracks, road); return tower; } @@ -198,9 +240,17 @@ int building_barracks_create_tower_sentry(building *barracks, int x, int y) return 1; } -void building_barracks_toggle_priority(building *barracks) +void building_barracks_set_priority(building *barracks, int priority) +{ + // TODO remove when archery available + if (priority != 4) { + barracks->subtype.barracks_priority = priority; + } +} + +void building_barracks_toggle_delivery(building *barracks) { - barracks->subtype.barracks_priority = 1 - barracks->subtype.barracks_priority; + barracks->accepted_goods[RESOURCE_WEAPONS] ^= 1; } int building_barracks_get_priority(building *barracks) diff --git a/src/building/barracks.h b/src/building/barracks.h index 3c0b1ac04a..d3f8622d08 100644 --- a/src/building/barracks.h +++ b/src/building/barracks.h @@ -16,14 +16,21 @@ building *building_barracks_get_unmanned_tower(building *barracks, map_point *ro int building_barracks_create_tower_sentry(building *barracks, int x, int y); -void building_barracks_toggle_priority(building* barracks); +void building_barracks_set_priority(building* barracks, int priority); + +void building_barracks_toggle_delivery(building* barracks); int building_barracks_get_priority(building* barracks); typedef enum { - PRIORITY_TOWER = 0, - PRIORITY_FORT = 1, + PRIORITY_FORT = 0, + PRIORITY_FORT_JAVELIN = 1, + PRIORITY_FORT_MOUNTED = 2, + PRIORITY_FORT_AUXILIA_INFANTRY = 3, + PRIORITY_FORT_AUXILIA_ARCHERY = 4, + PRIORITY_TOWER = 5, + PRIORITY_WATCHTOWER = 6, } barracks_priority; #endif // BUILDING_BARRACKS_H diff --git a/src/building/construction_building.c b/src/building/construction_building.c index 094f3baeef..91610ca08f 100644 --- a/src/building/construction_building.c +++ b/src/building/construction_building.c @@ -260,6 +260,10 @@ static void add_to_map(int type, building *b, int size, int orientation, int wat case BUILDING_PANTHEON: map_tiles_update_area_roads(b->x, b->y, 9); building_monument_set_phase(b, MONUMENT_START); + if (type == BUILDING_GRAND_TEMPLE_MARS) { + b->accepted_goods[RESOURCE_WEAPONS] = 1; + b->accepted_goods[RESOURCE_NONE] = 1; + } break; case BUILDING_MESS_HALL: b->data.market.is_mess_hall = 1; @@ -295,6 +299,11 @@ static void add_to_map(int type, building *b, int size, int orientation, int wat case BUILDING_SHRINE_VENUS: b->subtype.orientation = building_rotation_get_rotation(); add_building(b); + break; + case BUILDING_BARRACKS: + b->accepted_goods[RESOURCE_WEAPONS] = 1; + b->accepted_goods[RESOURCE_NONE] = 1; + add_building(b); break; } diff --git a/src/building/figure.c b/src/building/figure.c index 65fcc0bf04..f03e534486 100644 --- a/src/building/figure.c +++ b/src/building/figure.c @@ -1130,7 +1130,11 @@ static void spawn_figure_grand_temple_mars(building *b) b->figure_spawn_delay = 0; map_has_road_access(b->x, b->y, b->size, &road); switch (b->subtype.barracks_priority) { - case PRIORITY_FORT: + case PRIORITY_FORT: + case PRIORITY_FORT_JAVELIN: + case PRIORITY_FORT_MOUNTED: + case PRIORITY_FORT_AUXILIA_INFANTRY: + case PRIORITY_FORT_AUXILIA_ARCHERY: if (!building_barracks_create_soldier(b, road.x, road.y)) { building_barracks_create_tower_sentry(b, road.x, road.y); } @@ -1570,6 +1574,10 @@ static void spawn_figure_barracks(building *b) map_has_road_access(b->x, b->y, b->size, &road); switch (b->subtype.barracks_priority) { case PRIORITY_FORT: + case PRIORITY_FORT_JAVELIN: + case PRIORITY_FORT_MOUNTED: + case PRIORITY_FORT_AUXILIA_INFANTRY: + case PRIORITY_FORT_AUXILIA_ARCHERY: if (!building_barracks_create_soldier(b, road.x, road.y)) { building_barracks_create_tower_sentry(b, road.x, road.y); } diff --git a/src/building/state.c b/src/building/state.c index 78fc44689f..326df7f687 100644 --- a/src/building/state.c +++ b/src/building/state.c @@ -673,6 +673,14 @@ void building_state_load_from_buffer(buffer *buf, building *b, int building_buf_ b->figure_id2 = 0; } + // Old save barracks and temple of mars should accept weapons by default + if (b->type == BUILDING_BARRACKS || b->type == BUILDING_GRAND_TEMPLE_MARS) { + if (!b->accepted_goods[RESOURCE_NONE]) { + b->accepted_goods[RESOURCE_NONE] = 1; // set RESOURCE_NONE to 1 to mark this as a new save compatibility + b->accepted_goods[RESOURCE_WEAPONS] = 1; + } + } + // The following code should only be executed if the savegame includes building information that is not // supported on this specific version of Augustus. The extra bytes in the buffer must be skipped in order // to prevent reading bogus data for the next building diff --git a/src/figure/formation.h b/src/figure/formation.h index 9d5ee8be50..12277c1743 100644 --- a/src/figure/formation.h +++ b/src/figure/formation.h @@ -14,7 +14,8 @@ enum { LEGION_RECRUIT_MOUNTED = 1, LEGION_RECRUIT_JAVELIN = 2, LEGION_RECRUIT_LEGIONARY = 3, - LEGION_RECRUIT_INFANTRY = 4 + LEGION_RECRUIT_INFANTRY = 4, + LEGION_RECRUIT_ARCHERY = 5 }; typedef enum { diff --git a/src/translation/english.c b/src/translation/english.c index 5ac6faacaa..dfe22d0bb3 100644 --- a/src/translation/english.c +++ b/src/translation/english.c @@ -1393,8 +1393,8 @@ static translation_string all_strings[] = { {TR_WINDOW_ADVISOR_MILITARY_INFANTRY, "Infantrymen"}, {TR_TOOLTIP_BUTTON_ROADBLOCK_ORDER_ACCEPT_ALL, "Accept all walkers"}, {TR_TOOLTIP_BUTTON_ROADBLOCK_ORDER_REJECT_ALL, "Refuse all walkers"}, - {TR_TOOLTIP_BUTTON_STORAGE_ORDER_ACCEPT_ALL, "Accept all goods" }, - {TR_TOOLTIP_BUTTON_STORAGE_ORDER_REJECT_ALL, "Refuse all goods" }, + {TR_TOOLTIP_BUTTON_STORAGE_ORDER_ACCEPT_ALL, "Accept all goods"}, + {TR_TOOLTIP_BUTTON_STORAGE_ORDER_REJECT_ALL, "Refuse all goods"}, {TR_FIGURE_TYPE_BEGGAR, "Beggar"}, {TR_BUILDING_ARMOURY, "Armory" }, {TR_BUILDING_ARMOURY_NO_EMPLOYEES, "Without access to employees, the armory cannot deliver weapons to our soldiers. May Mars protect us, because the unarmed legions certainly will not!"}, @@ -1427,6 +1427,18 @@ static translation_string all_strings[] = { {TR_EDITOR_CAESAR_SALARY, "Caesar's salary"}, {TR_CITY_MESSAGE_TEXT_CARAVANSERAI_COMPLETE, "The caravanserai is completed. New commercial horizons are emerging. Caravans from all over the world are eager to come and trade in your city."}, {TR_CONFIG_SHOW_DESIRABILITY_RANGE, "Show desirability when building mausoleums and nymphaeums"}, + {TR_WINDOW_BARRACKS_PRIORITY, "Recruitment Priority:"}, + {TR_WINDOW_BARRACKS_FORTS, "Forts"}, + {TR_WINDOW_BARRACKS_TOWERS, "Towers"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_FORT, "Prioritize Legionary training"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_JAVELIN, "Prioritize Javelin training"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_MOUNTED, "Prioritize Cavalery training"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_AUXINF, "Prioritize Infantryman training"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_AUXARCH, "Prioritize Archer training"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_TOWER, "Prioritize Towers delivery"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_WATCHTOWER, "Prioritize Watchtowers delivery"}, + {TR_TOOLTIP_BUTTON_REJECT_DELIVERY, "Stopping weapons delivery from Armory"}, + {TR_TOOLTIP_BUTTON_ACCEPT_DELIVERY, "Allowing weapons delivery from Armory"}, }; void translation_english(const translation_string **strings, int *num_strings) diff --git a/src/translation/french.c b/src/translation/french.c index 719c368f41..750644fe66 100644 --- a/src/translation/french.c +++ b/src/translation/french.c @@ -226,7 +226,7 @@ static translation_string all_strings[] = { {TR_BUILDING_PANTHEON_DESC_MODULE_1, "Pantheum Ara Maxima"}, {TR_BUILDING_PANTHEON_DESC_MODULE_2, "Pantheum Roma Aeterna"}, {TR_BUILDING_GRAND_TEMPLE_MENU, "Temple monumental"}, - {TR_BUILDING_WORK_CAMP, "Camp de travail"}, + {TR_BUILDING_WORK_CAMP, "Chantier de construction"}, {TR_BUILDING_WORK_CAMP_DESC, "Les ouvriers se rassemblent ici pour transporter les matériaux vers les chantiers de construction."}, {TR_BUILDING_DEPOT, "Dépôt de charrettes"}, {TR_BUILDING_CAT_DEPOT, "Dépôt de chat(rrettes)"}, @@ -1377,6 +1377,8 @@ static translation_string all_strings[] = { {TR_WINDOW_ADVISOR_MILITARY_INFANTRY, "Fantassins"}, {TR_TOOLTIP_BUTTON_ROADBLOCK_ORDER_ACCEPT_ALL, "Autoriser tous les marcheurs"}, {TR_TOOLTIP_BUTTON_ROADBLOCK_ORDER_REJECT_ALL, "Refuser tous les marcheurs"}, + {TR_TOOLTIP_BUTTON_STORAGE_ORDER_ACCEPT_ALL, "Autoriser toutes les marchandises"}, + {TR_TOOLTIP_BUTTON_STORAGE_ORDER_REJECT_ALL, "Refuser toutes les marchandises"}, {TR_FIGURE_TYPE_BEGGAR, "Mendiant"}, {TR_BUILDING_ARMOURY, "Armurerie" }, {TR_BUILDING_ARMOURY_NO_EMPLOYEES, "L'armurerie n'ayant pas de main-d'œuvre, aucune arme n'est livrée aux soldats. Puisse Mars nous protéger à la place de nos légions !"}, @@ -1409,6 +1411,18 @@ static translation_string all_strings[] = { {TR_EDITOR_CAESAR_SALARY, "Salaire de Caesar"}, {TR_CITY_MESSAGE_TEXT_CARAVANSERAI_COMPLETE, "Le caravanserail est achevé. De nouveaux horizons commerciaux se profilent. Les caravanes des quatre coins du monde sont enthousiastes à l'idée de venir commercer dans votre cité."}, {TR_CONFIG_SHOW_DESIRABILITY_RANGE , "Voir l'attrait des mausolées et des nymphées lors du placement"}, + {TR_WINDOW_BARRACKS_PRIORITY, "Priorité de recrutement:"}, + {TR_WINDOW_BARRACKS_FORTS, "Forts"}, + {TR_WINDOW_BARRACKS_TOWERS, "Tours"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_FORT, "Prioriser la formation des Légionnaires"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_JAVELIN, "Prioriser la formation des Javelines"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_MOUNTED, "Prioriser la formation des Cavaliers"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_AUXINF, "Prioriser la formation des Fantassins"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_AUXARCH, "Prioriser la formation des Archers"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_TOWER, "Prioriser la livraison des Tours"}, + {TR_TOOLTIP_BARRACKS_PRIORITY_WATCHTOWER, "Prioriser la livraison des Tours de guet"}, + {TR_TOOLTIP_BUTTON_REJECT_DELIVERY, "Refuser la livraison d'armes par les Armureries"}, + {TR_TOOLTIP_BUTTON_ACCEPT_DELIVERY, "Accepter la livraison d'armes par les Armureries"}, }; void translation_french(const translation_string **strings, int *num_strings) diff --git a/src/translation/translation.h b/src/translation/translation.h index 578d2be937..346a8600ee 100644 --- a/src/translation/translation.h +++ b/src/translation/translation.h @@ -1421,6 +1421,18 @@ typedef enum { TR_CONFIG_SHOW_DESIRABILITY_RANGE, TR_TOOLTIP_BUTTON_STORAGE_ORDER_ACCEPT_ALL, TR_TOOLTIP_BUTTON_STORAGE_ORDER_REJECT_ALL, + TR_WINDOW_BARRACKS_PRIORITY, + TR_WINDOW_BARRACKS_FORTS, + TR_WINDOW_BARRACKS_TOWERS, + TR_TOOLTIP_BARRACKS_PRIORITY_FORT, + TR_TOOLTIP_BARRACKS_PRIORITY_JAVELIN, + TR_TOOLTIP_BARRACKS_PRIORITY_MOUNTED, + TR_TOOLTIP_BARRACKS_PRIORITY_AUXINF, + TR_TOOLTIP_BARRACKS_PRIORITY_AUXARCH, + TR_TOOLTIP_BARRACKS_PRIORITY_TOWER, + TR_TOOLTIP_BARRACKS_PRIORITY_WATCHTOWER, + TR_TOOLTIP_BUTTON_REJECT_DELIVERY, + TR_TOOLTIP_BUTTON_ACCEPT_DELIVERY, TRANSLATION_MAX_KEY } translation_key; diff --git a/src/window/building/culture.c b/src/window/building/culture.c index 1990caad5a..e2379a8ec0 100644 --- a/src/window/building/culture.c +++ b/src/window/building/culture.c @@ -484,7 +484,7 @@ void window_building_draw_amphitheater(building_info_context *c) } else { lang_text_draw(71, 9, c->x_offset + 32, c->y_offset + 234, FONT_NORMAL_BROWN); } - window_building_draw_description_at(c, BLOCK_SIZE * c->height_blocks - 80, 71, 1); + window_building_draw_description_at(c, BLOCK_SIZE * c->height_blocks - 90, 71, 1); } static void draw_entertainment_school(building_info_context *c, const char *sound_file, int group_id) @@ -589,7 +589,7 @@ static void draw_grand_temple_mars_military(building_info_context *c) { int y = 60; data.building_id = c->building_id; - image_draw(resource_get_data(RESOURCE_WEAPONS)->image.icon, c->x_offset + 24, c->y_offset + y - 5, + image_draw(resource_get_data(RESOURCE_WEAPONS)->image.icon, c->x_offset + 25, c->y_offset + y - 5, COLOR_MASK_NONE, SCALE_NONE); building *b = building_get(c->building_id); if (b->resources[RESOURCE_WEAPONS] < 1) { @@ -598,9 +598,11 @@ static void draw_grand_temple_mars_military(building_info_context *c) lang_text_draw_amount(8, 10, b->resources[RESOURCE_WEAPONS], c->x_offset + 52, c->y_offset + y, FONT_NORMAL_BLACK); } - lang_text_draw(50, 21, c->x_offset + 236, c->y_offset + y, FONT_NORMAL_BLACK); // "Priority" - lang_text_draw(91, 0, c->x_offset + 326, c->y_offset + y, FONT_NORMAL_BLACK); // "Tower" - lang_text_draw(89, 0, c->x_offset + 326, c->y_offset + y + 20, FONT_NORMAL_BLACK); // "Fort" + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_PRIORITY, c->x_offset + 25, c->y_offset + 88, FONT_NORMAL_BLACK); // "Priority" + + inner_panel_draw(c->x_offset + 16, c->y_offset + 108, c->width_blocks - 2, 5); + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_FORTS, c->x_offset + 50, c->y_offset + 113, FONT_NORMAL_BROWN); // "Forts" + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_TOWERS, c->x_offset + 327, c->y_offset + 113, FONT_NORMAL_BROWN); // "Towers" } static void draw_temple(building_info_context *c, const char *sound_file, int group_id) @@ -752,7 +754,8 @@ void window_building_draw_grand_temple_foreground(building_info_context *c) 16 * (c->width_blocks - 10), FONT_NORMAL_BLACK, 0); } if (b->type == BUILDING_GRAND_TEMPLE_MARS) { - window_building_draw_priority_buttons(c->x_offset + 285, c->y_offset + 55); + window_building_draw_priority_buttons(c->x_offset + 50, c->y_offset + 133, b->id); + window_building_draw_delivery_buttons(c->x_offset + 408, c->y_offset + 40, b->id); } } @@ -799,7 +802,7 @@ void window_building_draw_grand_temple_mars(building_info_context *c) draw_grand_temple(c, "wavs/temple_war.wav", TR_BUILDING_GRAND_TEMPLE_MARS_DESC, TR_BUILDING_GRAND_TEMPLE_MARS_BONUS_DESC, assets_get_image_id("UI", "Mars L Banner"), - TR_BUILDING_MARS_TEMPLE_QUOTE, GOD_MARS, 50); + TR_BUILDING_MARS_TEMPLE_QUOTE, GOD_MARS, 150); } void window_building_draw_grand_temple_venus(building_info_context *c) diff --git a/src/window/building/military.c b/src/window/building/military.c index df25ff1480..5a8359c02e 100644 --- a/src/window/building/military.c +++ b/src/window/building/military.c @@ -26,7 +26,7 @@ static void button_return_to_fort(int param1, int param2); static void button_layout(int index, int param2); static void button_priority(int index, int param2); - +static void button_delivery(int index, int param2); static generic_button layout_buttons[] = { {19, 179, 84, 84, button_layout, button_none, 0, 0}, @@ -37,10 +37,18 @@ static generic_button layout_buttons[] = { }; static generic_button priority_buttons[] = { - {96, 0, 24, 24, button_priority, button_none, 0, 0}, - {96, 24, 24, 24, button_priority, button_none, 1, 0}, + {0, 0, 40, 40, button_priority, button_none, 0, 0}, + {56, 0, 40, 40, button_priority, button_none, 1, 0}, + {112, 0, 40, 40, button_priority, button_none, 2, 0}, + {168, 0, 40, 40, button_priority, button_none, 3, 0}, + {224, 0, 40, 40, button_priority, button_none, 4, 0}, + {280, 0, 40, 40, button_priority, button_none, 5, 0}, + {336, 0, 40, 40, button_priority, button_none, 6, 0}, }; +static generic_button delivery_buttons[] = { + {0, 0, 52, 52, button_delivery, button_none, 0, 0}, +}; static generic_button return_button[] = { {0, 0, 288, 32, button_return_to_fort, button_none, 0, 0}, @@ -49,24 +57,64 @@ static generic_button return_button[] = { static struct { int focus_button_id; int focus_priority_button_id; + int focus_delivery_button_id; int return_button_id; int building_id; building_info_context *context_for_callback; } data; -static void draw_priority_buttons(int x, int y, int buttons) +static void draw_priority_buttons(int x, int y, int buttons, int building_id) { - uint8_t permission_selection_text[] = { 'x', 0 }; + int base_priority_image_id = assets_get_image_id("UI", "Barracks_Priority_Legionaries_OFF"); + data.building_id = building_id; + for (int i = 0; i < buttons; i++) { + int has_focus = 0; + if (data.focus_priority_button_id) { + if (data.focus_priority_button_id - 1 == i) { + has_focus = 1; + } + } int x_adj = x + priority_buttons[i].x; int y_adj = y + priority_buttons[i].y; + building *barracks = building_get(data.building_id); int priority = building_barracks_get_priority(barracks); - button_border_draw(x_adj, y_adj, 20, 20, data.focus_priority_button_id == i + 1 ? 1 : 0); - if (priority == i) { - text_draw_centered(permission_selection_text, x_adj + 1, y_adj + 4, 20, FONT_NORMAL_BLACK, 0); - } + + // TODO remove when archery available + if (i != 4) { + if (has_focus || priority == i) { + button_border_draw(x_adj - 3, y_adj - 3, 46, 46, 1); + } + image_draw(base_priority_image_id + i * 2 + (i == priority ? 1 : 0), x_adj, y_adj, COLOR_MASK_NONE, SCALE_NONE); + } } + + window_request_refresh(); +} + +static void draw_delivery_buttons(int x, int y, int building_id) +{ + data.building_id = building_id; + + building *barracks = building_get(data.building_id); + + int accept_delivery = barracks->accepted_goods[RESOURCE_WEAPONS]; + + if (!accept_delivery) { + inner_panel_draw(x + 2, y + 2, 3, 3); + } + + image_draw(image_group(GROUP_FIGURE_CARTPUSHER_CART) + 104, x + 7, y + 7, COLOR_MASK_NONE, SCALE_NONE); + + if (!accept_delivery) { + image_draw(assets_get_image_id("UI", "Large_Widget_Cross"), x + 15, y + 15, + COLOR_MASK_NONE, SCALE_NONE); + } + + button_border_draw(x, y, 52, 52, data.focus_delivery_button_id || !accept_delivery ? 1 : 0); + + window_request_refresh(); } void window_building_draw_wall(building_info_context *c) @@ -116,22 +164,22 @@ void window_building_draw_barracks(building_info_context *c) window_building_play_sound(c, "wavs/barracks.wav"); outer_panel_draw(c->x_offset, c->y_offset, c->width_blocks, c->height_blocks); lang_text_draw_centered(136, 0, c->x_offset, c->y_offset + 10, BLOCK_SIZE * c->width_blocks, FONT_LARGE_BLACK); - image_draw(resource_get_data(RESOURCE_WEAPONS)->image.icon, c->x_offset + 64, c->y_offset + 38, + image_draw(resource_get_data(RESOURCE_WEAPONS)->image.icon, c->x_offset + 32, c->y_offset + 60, COLOR_MASK_NONE, SCALE_NONE); building *b = building_get(c->building_id); if (b->resources[RESOURCE_WEAPONS] < 1) { - lang_text_draw_amount(8, 10, 0, c->x_offset + 92, c->y_offset + 44, FONT_NORMAL_BLACK); + lang_text_draw_amount(8, 10, 0, c->x_offset + 60, c->y_offset + 66, FONT_NORMAL_BLACK); } else { - lang_text_draw_amount(8, 10, b->resources[RESOURCE_WEAPONS], c->x_offset + 92, c->y_offset + 44, FONT_NORMAL_BLACK); + lang_text_draw_amount(8, 10, b->resources[RESOURCE_WEAPONS], c->x_offset + 60, c->y_offset + 66, FONT_NORMAL_BLACK); } if (!c->has_road_access) { - window_building_draw_description_at(c, 70, 69, 25); + window_building_draw_description_at(c, 106, 69, 25); } else if (b->num_workers <= 0) { - window_building_draw_description_at(c, 70, 136, 3); + window_building_draw_description_at(c, 106, 136, 3); } else if (!c->barracks_soldiers_requested) { - window_building_draw_description_at(c, 70, 136, 4); + window_building_draw_description_at(c, 106, 136, 4); } else { int offset = 0; if (b->resources[RESOURCE_WEAPONS] > 0) { @@ -139,43 +187,54 @@ void window_building_draw_barracks(building_info_context *c) } if (city_data.mess_hall.food_stress_cumulative > 50) { text_draw_multiline(translation_for(TR_BUILDING_BARRACKS_FOOD_WARNING_2), - c->x_offset + 26, c->y_offset + 86, 16 * c->width_blocks - 30, FONT_NORMAL_BLACK, 0); + c->x_offset + 32, c->y_offset + 106, 16 * c->width_blocks - 30, FONT_NORMAL_BLACK, 0); } else if (city_data.mess_hall.food_stress_cumulative > 20) { text_draw_multiline(translation_for(TR_BUILDING_BARRACKS_FOOD_WARNING), - c->x_offset + 26, c->y_offset + 86, 16 * c->width_blocks - 30, FONT_NORMAL_BLACK, 0); + c->x_offset + 32, c->y_offset + 106, 16 * c->width_blocks - 30, FONT_NORMAL_BLACK, 0); } else if (c->worker_percentage >= 100) { - window_building_draw_description_at(c, 70, 136, 5 + offset); + window_building_draw_description_at(c, 106, 136, 5 + offset); } else if (c->worker_percentage >= 66) { - window_building_draw_description_at(c, 70, 136, 6 + offset); + window_building_draw_description_at(c, 106, 136, 6 + offset); } else if (c->worker_percentage >= 33) { - window_building_draw_description_at(c, 70, 136, 7 + offset); + window_building_draw_description_at(c, 106, 136, 7 + offset); } else { - window_building_draw_description_at(c, 70, 136, 8 + offset); + window_building_draw_description_at(c, 106, 136, 8 + offset); } } - inner_panel_draw(c->x_offset + 16, c->y_offset + 136, c->width_blocks - 2, 4); - window_building_draw_employment(c, 142); - window_building_draw_risks(c, c->x_offset + c->width_blocks * BLOCK_SIZE - 76, c->y_offset + 144); - lang_text_draw(50, 21, c->x_offset + 46, c->y_offset + 204, FONT_NORMAL_BLACK); // "Priority" - lang_text_draw(91, 0, c->x_offset + 46, c->y_offset + 224, FONT_NORMAL_BLACK); // "Tower" - lang_text_draw(89, 0, c->x_offset + 46, c->y_offset + 244, FONT_NORMAL_BLACK); // "Fort" + + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_PRIORITY, c->x_offset + 32, c->y_offset + 170, FONT_NORMAL_BLACK); // "Priority" + inner_panel_draw(c->x_offset + 16, c->y_offset + 188, c->width_blocks - 2, 5); + + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_FORTS, c->x_offset + 42, c->y_offset + 200, FONT_NORMAL_BROWN); // "Forts" + lang_text_draw(CUSTOM_TRANSLATION, TR_WINDOW_BARRACKS_TOWERS, c->x_offset + 324, c->y_offset + 200, FONT_NORMAL_BROWN); // "Towers" + + inner_panel_draw(c->x_offset + 16, c->y_offset + 290, c->width_blocks - 2, 4); + window_building_draw_employment(c, 294); + window_building_draw_risks(c, c->x_offset + c->width_blocks * BLOCK_SIZE - 76, c->y_offset + 298); } void window_building_draw_barracks_foreground(building_info_context *c) { - draw_priority_buttons(c->x_offset + 46, c->y_offset + 224, 2); + draw_priority_buttons(c->x_offset + 42, c->y_offset + 218, 7, data.building_id); + draw_delivery_buttons(c->x_offset + 392, c->y_offset + 40, data.building_id); +} +void window_building_draw_priority_buttons(int x, int y, int building_id) +{ + draw_priority_buttons(x, y, 7, building_id); } -void window_building_draw_priority_buttons(int x, int y) +void window_building_draw_delivery_buttons(int x, int y, int building_id) { - draw_priority_buttons(x, y, 2); + draw_delivery_buttons(x, y, building_id); } int window_building_handle_mouse_barracks(const mouse *m, building_info_context *c) { - if (generic_buttons_handle_mouse(m, c->x_offset + 46, c->y_offset + 224, - priority_buttons, 2, &data.focus_priority_button_id)) { + if (generic_buttons_handle_mouse(m, c->x_offset + 46, c->y_offset + 222, + priority_buttons, 7, &data.focus_priority_button_id) || + generic_buttons_handle_mouse(m, c->x_offset + 392, c->y_offset + 40, + delivery_buttons, 1, &data.focus_delivery_button_id)) { window_invalidate(); return 1; } @@ -185,8 +244,11 @@ int window_building_handle_mouse_barracks(const mouse *m, building_info_context int window_building_handle_mouse_grand_temple_mars(const mouse *m, building_info_context *c) { - if (generic_buttons_handle_mouse(m, c->x_offset + 285, c->y_offset + 55, - priority_buttons, 2, &data.focus_priority_button_id)) { + if (generic_buttons_handle_mouse(m, c->x_offset + 50, c->y_offset + 135, + priority_buttons, 7, &data.focus_priority_button_id) || + generic_buttons_handle_mouse(m, c->x_offset + 408, c->y_offset + 40, + delivery_buttons, 1, &data.focus_delivery_button_id) + ) { window_invalidate(); return 1; } @@ -338,13 +400,13 @@ void window_building_draw_legion_info(building_info_context *c) // food warnings if (m->mess_hall_max_morale_modifier < -20) { text_draw_centered(translation_for(TR_BUILDING_LEGION_FOOD_WARNING_2), - c->x_offset + 20, c->y_offset + 340, c->width_blocks * 16 - 40, FONT_NORMAL_PLAIN, COLOR_FONT_RED); + c->x_offset + 20, c->y_offset + 360, c->width_blocks * 16 - 40, FONT_NORMAL_PLAIN, COLOR_FONT_RED); } else if (m->mess_hall_max_morale_modifier < -5) { text_draw_centered(translation_for(TR_BUILDING_LEGION_FOOD_WARNING_1), - c->x_offset + 20, c->y_offset + 340, c->width_blocks * 16 - 40, FONT_NORMAL_BLACK, 0); + c->x_offset + 20, c->y_offset + 360, c->width_blocks * 16 - 40, FONT_NORMAL_BLACK, 0); } else if (m->mess_hall_max_morale_modifier > 0) { text_draw_centered(translation_for(TR_BUILDING_LEGION_FOOD_BONUS), - c->x_offset + 20, c->y_offset + 340, c->width_blocks * 16 - 40, FONT_NORMAL_BLACK, 0); + c->x_offset + 20, c->y_offset + 360, c->width_blocks * 16 - 40, FONT_NORMAL_BLACK, 0); } if (m->num_figures) { @@ -426,7 +488,8 @@ void window_building_draw_legion_info_foreground(building_info_context *c) } button_border_draw(c->x_offset + 19 + 85 * i, c->y_offset + 179, 84, 84, has_focus); } - inner_panel_draw(c->x_offset + 16, c->y_offset + 270, c->width_blocks - 2, 4); + + inner_panel_draw(c->x_offset + 16, c->y_offset + 270, c->width_blocks - 2, 5); int title_id; int text_id; @@ -527,6 +590,48 @@ int window_building_get_legion_info_tooltip_text(building_info_context *c) return data.focus_button_id ? 147 : 0; } +void window_building_barracks_get_tooltip_priority(int *translation) +{ + switch (data.focus_priority_button_id) { + case 1: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_FORT; + break; + case 2: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_JAVELIN; + break; + case 3: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_MOUNTED; + break; + case 4: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_AUXINF; + break; + case 5: + // TODO uncomment when archery available + // *translation = TR_TOOLTIP_BARRACKS_PRIORITY_AUXARCH; + break; + case 6: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_TOWER; + break; + case 7: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_WATCHTOWER; + break; + case 8: + *translation = TR_TOOLTIP_BARRACKS_PRIORITY_FORT; + break; + default: + break; + } + + if (data.focus_delivery_button_id) { + building *barracks = building_get(data.building_id); + if (barracks->accepted_goods[RESOURCE_WEAPONS]) { + *translation = TR_TOOLTIP_BUTTON_REJECT_DELIVERY; + } else { + *translation = TR_TOOLTIP_BUTTON_ACCEPT_DELIVERY; + } + } +} + static void button_return_to_fort(int param1, int param2) { formation *m = formation_get(data.context_for_callback->formation_id); @@ -581,9 +686,13 @@ static void button_layout(int index, int param2) static void button_priority(int index, int param2) { building *barracks = building_get(data.building_id); - if (index != barracks->subtype.barracks_priority) { - building_barracks_toggle_priority(barracks); - } + building_barracks_set_priority(barracks, index); +} + +static void button_delivery(int index, int param2) +{ + building *barracks = building_get(data.building_id); + building_barracks_toggle_delivery(barracks); } void window_building_draw_watchtower(building_info_context *c) diff --git a/src/window/building/military.h b/src/window/building/military.h index c0d0c3f1b1..8dffc2e432 100644 --- a/src/window/building/military.h +++ b/src/window/building/military.h @@ -10,7 +10,8 @@ void window_building_draw_tower(building_info_context *c); void window_building_draw_barracks(building_info_context *c); void window_building_draw_barracks_foreground(building_info_context *c); -void window_building_draw_priority_buttons(int x, int y); +void window_building_draw_priority_buttons(int x, int y, int building_id); +void window_building_draw_delivery_buttons(int x, int y, int building_id); int window_building_handle_mouse_barracks(const mouse *m, building_info_context *c); void window_building_draw_military_academy(building_info_context *c); @@ -21,6 +22,7 @@ void window_building_draw_legion_info(building_info_context *c); void window_building_draw_legion_info_foreground(building_info_context *c); int window_building_handle_mouse_legion_info(const mouse *m, building_info_context *c); int window_building_get_legion_info_tooltip_text(building_info_context *c); +void window_building_barracks_get_tooltip_priority (int *translation); int window_building_handle_mouse_grand_temple_mars(const mouse *m, building_info_context *c); void window_building_draw_watchtower(building_info_context *c); diff --git a/src/window/building_info.c b/src/window/building_info.c index 1ec9e7aa92..c399ddff46 100644 --- a/src/window/building_info.c +++ b/src/window/building_info.c @@ -178,7 +178,6 @@ static int get_height_id(void) case BUILDING_FOUNTAIN: return 2; - case BUILDING_BARRACKS: case BUILDING_LARGE_TEMPLE_CERES: case BUILDING_LARGE_TEMPLE_NEPTUNE: case BUILDING_LARGE_TEMPLE_MERCURY: @@ -198,7 +197,7 @@ static int get_height_id(void) case BUILDING_AMPHITHEATER: case BUILDING_ARENA: case BUILDING_CONCRETE_MAKER: - return 5; + return 5; case BUILDING_DOCK: case BUILDING_LIGHTHOUSE: @@ -207,12 +206,12 @@ static int get_height_id(void) case BUILDING_MESS_HALL: case BUILDING_CITY_MINT: + case BUILDING_BARRACKS: return 7; case BUILDING_GRAND_TEMPLE_CERES: case BUILDING_GRAND_TEMPLE_NEPTUNE: case BUILDING_GRAND_TEMPLE_MERCURY: - case BUILDING_GRAND_TEMPLE_MARS: case BUILDING_GRAND_TEMPLE_VENUS: case BUILDING_PANTHEON: case BUILDING_HIPPODROME: @@ -222,6 +221,9 @@ static int get_height_id(void) case BUILDING_GRANARY: return 9; + case BUILDING_GRAND_TEMPLE_MARS: + return 10; + default: return 0; } @@ -456,6 +458,7 @@ static void init(int grid_offset) case 7: context.height_blocks = 26; break; case 8: context.height_blocks = 40; context.width_blocks = 30; break; case 9: context.height_blocks = 20; break; + case 10: context.height_blocks = 47; context.width_blocks = 30; break; default: context.height_blocks = 22; break; } if (screen_height() <= 600) { @@ -1065,6 +1068,8 @@ static void get_tooltip(tooltip_context *c) } else if (!context.depot_selection.resource) { window_building_depot_get_tooltip_main(&translation); } + } else if (btype == BUILDING_BARRACKS || btype == BUILDING_GRAND_TEMPLE_MARS) { + window_building_barracks_get_tooltip_priority(&translation); } if (!text_id && !group_id && !translation && !precomposed_text) { if (building_is_farm(btype) || building_is_raw_resource_producer(btype) || building_is_workshop(btype)) {