Skip to content

Commit ff20409

Browse files
author
s.kushnirenko
committed
fix: update draw_foreground function to use new context in orders
what: fix: update draw_warehouse_orders function to use new object_info struct members refactor: make is_advisor_available function accessible outside of file
1 parent 0ce842a commit ff20409

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

src/building/storage_yard.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -889,11 +889,14 @@ void building_storage_yard::spawn_figure() {
889889
}
890890

891891
void building_storage_yard::draw_warehouse_orders(object_info* c) {
892-
int y_offset = window_building_get_vertical_offset(c, 28 + 5);
893892
c->help_id = 4;
894-
outer_panel_draw(vec2i{c->offset.x, y_offset}, 29, 28 + 5);
895-
lang_text_draw_centered(99, 3, c->offset.x, y_offset + 10, 16 * c->width_blocks, FONT_LARGE_BLACK_ON_LIGHT);
896-
inner_panel_draw(c->offset.x + 16, y_offset + 42, c->width_blocks - 2, 21 + 5);
893+
c->subwnd_wblocks_num = 29;
894+
c->subwnd_hblocks_num = 33;
895+
int y_pos = window_building_get_vertical_offset(c, c->subwnd_hblocks_num);
896+
c->subwnd_y_offset = y_pos - c->offset.y;
897+
outer_panel_draw(vec2i{c->offset.x, y_pos}, c->subwnd_wblocks_num, c->subwnd_hblocks_num);
898+
lang_text_draw_centered(99, 3, c->offset.x, y_pos + 10, 16 * c->width_blocks, FONT_LARGE_BLACK_ON_LIGHT);
899+
inner_panel_draw(c->offset.x + 16, y_pos + 42, c->width_blocks - 2, 21 + 5);
897900
}
898901

899902
void building_storage_yard::draw_warehouse(object_info* c) {

src/city/object_info.h

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct object_info {
4848
int width_blocks;
4949
int height_blocks;
5050
int height_blocks_submenu;
51+
int subwnd_wblocks_num;
52+
int subwnd_hblocks_num;
53+
int subwnd_y_offset;
5154
int help_id;
5255
bool can_play_sound;
5356
int building_id;

src/window/advisors.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void set_advisor(int advisor) {
141141
advisor_buttons[advisor - 1].pressed = 1; // set button active when coming back to menu
142142
}
143143

144-
static bool is_advisor_available(int btn_id) {
144+
bool is_advisor_available(int btn_id) {
145145
return (mission_advisor_availability((e_advisor)btn_id, scenario_campaign_scenario_id() + 1) == AVAILABLE);
146146
}
147147

src/window/advisors.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct advisor_window_type {
1515
};
1616

1717
int window_advisors_get_advisor(void);
18-
18+
bool is_advisor_available(int btn_id);
1919
void window_advisors_draw_dialog_background(void);
2020

2121
void window_advisors_show(void);

src/window/window_building_info.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static void draw_foreground() {
745745
}
746746

747747
// general buttons
748-
int y_offset = (context.storage_show_special_orders) ? context.y_offset_submenu : 0;
748+
int y_offset = (context.storage_show_special_orders) ? context.subwnd_y_offset : 0;
749749
int height_blocks = (context.storage_show_special_orders) ? context.height_blocks_submenu : context.height_blocks;
750750

751751
ui::img_button(GROUP_CONTEXT_ICONS, vec2i(14, y_offset + 16 * height_blocks - 40), {28, 28}, 0)
@@ -769,31 +769,31 @@ static void draw_foreground() {
769769
}
770770
});
771771

772-
if (context.go_to_advisor.first) {
772+
if (!context.storage_show_special_orders && context.go_to_advisor.first && is_advisor_available(context.go_to_advisor.first)) {
773773
int img_offset = (context.go_to_advisor.left_a - 1) * 3;
774774
ui::img_button(GROUP_MESSAGE_ADVISOR_BUTTONS, vec2i(40, 16 * context.height_blocks - 40), {28, 28}, img_offset)
775775
.onclick([&context] (int, int) {
776776
window_advisors_show_advisor(context.go_to_advisor.first);
777777
});
778778
}
779779

780-
if (context.go_to_advisor.left_a) {
780+
if (!context.storage_show_special_orders && context.go_to_advisor.left_a && is_advisor_available(context.go_to_advisor.left_a)) {
781781
int img_offset = (context.go_to_advisor.left_a - 1) * 3;
782782
ui::img_button(GROUP_MESSAGE_ADVISOR_BUTTONS, vec2i(40, 16 * context.height_blocks - 40), {28, 28}, img_offset)
783783
.onclick([&context] (int, int) {
784784
window_advisors_show_advisor(context.go_to_advisor.left_a);
785785
});
786786
}
787787

788-
if (context.go_to_advisor.left_b) {
788+
if (!context.storage_show_special_orders && context.go_to_advisor.left_b && is_advisor_available(context.go_to_advisor.left_b)) {
789789
int img_offset = (context.go_to_advisor.left_b - 1) * 3;
790790
ui::img_button(GROUP_MESSAGE_ADVISOR_BUTTONS, vec2i(65, 16 * context.height_blocks - 40), {28, 28}, img_offset)
791791
.onclick([&context] (int, int) {
792792
window_advisors_show_advisor(context.go_to_advisor.left_b);
793793
});
794794
}
795795

796-
if (b) {
796+
if (!context.storage_show_special_orders && b) {
797797
int workers_needed = model_get_building(b->type)->laborers;
798798
if (workers_needed) {
799799
pcstr label = (b->state == BUILDING_STATE_VALID ? "x" : "");
@@ -809,7 +809,7 @@ static void draw_foreground() {
809809
}
810810
}
811811

812-
if (context.figure.draw_debug_path) {
812+
if (!context.storage_show_special_orders && context.figure.draw_debug_path) {
813813
figure* f = figure_get(context.figure.figure_ids[0]);
814814
pcstr label = (f->draw_debug_mode ? "P" : "p");
815815
ui::button(label, {400, 3 + 16 * context.height_blocks - 40}, {20, 20})
@@ -819,7 +819,7 @@ static void draw_foreground() {
819819
});
820820
}
821821

822-
if (context.show_overlay != OVERLAY_NONE) {
822+
if (!context.storage_show_special_orders && context.show_overlay != OVERLAY_NONE) {
823823
pcstr label = (game_state_overlay() != context.show_overlay ? "v" : "V");
824824
ui::button(label, {375, 3 + 16 * context.height_blocks - 40}, {20, 20})
825825
.onclick([&context] (int, int) {
@@ -831,7 +831,6 @@ static void draw_foreground() {
831831
window_invalidate();
832832
});
833833
}
834-
835834
}
836835

837836
static int handle_specific_building_info_mouse(const mouse *m) {

0 commit comments

Comments
 (0)