Skip to content

Commit

Permalink
ADD: divided by class option for the waiting cargo list
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranran-the-JuicyPork committed Feb 13, 2024
1 parent 24855bc commit adb318b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
18 changes: 16 additions & 2 deletions gui/line_waiting_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#include "../simworld.h"


gui_halt_waiting_catg_t::gui_halt_waiting_catg_t(halthandle_t h, uint8 catg)
gui_halt_waiting_catg_t::gui_halt_waiting_catg_t(halthandle_t h, uint8 catg, bool yesno)
{
halt = h;
catg_index = catg;
divide_by_class = yesno;
set_table_layout(1,0);
update();
}
Expand Down Expand Up @@ -52,7 +53,20 @@ void gui_halt_waiting_catg_t::update()
PIXVAL goods_color = wtyp->get_color();
new_component<gui_colorbox_t>(goods_color)->set_size(GOODS_COLOR_BOX_SIZE);
gui_label_buf_t *lb = new_component<gui_label_buf_t>(overcrowded ? SYSCOL_OVERCROWDED : SYSCOL_TEXT);
lb->buf().printf("%s %d", translator::translate(wtyp->get_name()), sum);
const uint8 number_of_classes = wtyp->get_number_of_classes();
if (divide_by_class && number_of_classes>1) {
bool got_one_class = false;
for (uint8 wealth = 0; wealth<number_of_classes; wealth++) {
if (const uint32 csum = halt->get_ware_summe(wtyp, wealth)) {
if (got_one_class) lb->buf().append(", ");
lb->buf().printf("%s %d", goods_manager_t::get_translated_wealth_name(catg_index,wealth), csum);
got_one_class = true;
}
}
}
else {
lb->buf().printf("%s %d", translator::translate(wtyp->get_name()), sum);
}
lb->update();

got_one = true;
Expand Down
5 changes: 4 additions & 1 deletion gui/line_waiting_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class gui_halt_waiting_catg_t : public gui_aligned_container_t

// for update flag.
uint32 update_seed = 0;
bool divide_by_class;

public:
gui_halt_waiting_catg_t(halthandle_t h, uint8 catg);
gui_halt_waiting_catg_t(halthandle_t h, uint8 catg, bool divide_by_class = true);

void update();

Expand All @@ -39,6 +40,7 @@ class gui_line_waiting_status_t : public gui_aligned_container_t
schedule_t *schedule;

bool show_name=true;
bool divide_by_class = false;

public:
gui_line_waiting_status_t(linehandle_t line);
Expand All @@ -48,6 +50,7 @@ class gui_line_waiting_status_t : public gui_aligned_container_t
// for reload from the save
void set_line(linehandle_t line_) { line = line_; init(); }
void set_show_name(bool yesno) { show_name = yesno; init(); }
void set_divided_by_class(bool yesno) { divide_by_class = yesno; init(); }

void draw(scr_coord offset) OVERRIDE;
};
Expand Down
36 changes: 28 additions & 8 deletions gui/schedule_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,27 @@ schedule_list_gui_t::schedule_list_gui_t(player_t *player_) :
info_tabs.add_tab(&scroll_times_history, translator::translate("times_history"));

cont_tab_haltlist.set_table_layout(1,0);
bt_show_halt_name.init(button_t::square_state, "show station names");
bt_show_halt_name.set_tooltip("helptxt_show_station_name");
bt_show_halt_name.pressed=true;
bt_show_halt_name.add_listener(this);
cont_tab_haltlist.add_component(&bt_show_halt_name);
cont_tab_haltlist.add_table(4,1);
{
bt_hw_show_halt_name.init(button_t::square_state, "show station names");
bt_hw_show_halt_name.set_tooltip("helptxt_show_station_name");
bt_hw_show_halt_name.pressed=true;
bt_hw_show_halt_name.add_listener(this);
cont_tab_haltlist.add_component(&bt_hw_show_halt_name);

cont_tab_haltlist.new_component<gui_margin_t>(LINEASCENT);

bt_hw_divided_class.init(button_t::square_state, "Divided by class");
bt_hw_divided_class.set_tooltip("Waiting cargoes are displayed separately for each class.");
bt_hw_divided_class.pressed = true;
bt_hw_divided_class.add_listener(this);
cont_tab_haltlist.add_component(&bt_hw_divided_class);

cont_tab_haltlist.new_component<gui_fill_t>();
}
cont_tab_haltlist.end_table();


cont_tab_haltlist.add_component(&cont_haltlist);
info_tabs.add_tab(&scroll_halt_waiting, translator::translate("waiting_status"));

Expand Down Expand Up @@ -744,9 +760,13 @@ bool schedule_list_gui_t::action_triggered( gui_action_creator_t *comp, value_t
filter_btn_all_freights.pressed = line_type_flags & (1 << simline_t::all_freight);
build_line_list(tabs.get_active_tab_index());
}
else if (comp == &bt_show_halt_name) {
bt_show_halt_name.pressed = !bt_show_halt_name.pressed;
cont_haltlist.set_show_name( bt_show_halt_name.pressed );
else if (comp == &bt_hw_show_halt_name) {
bt_hw_show_halt_name.pressed = !bt_hw_show_halt_name.pressed;
cont_haltlist.set_show_name( bt_hw_show_halt_name.pressed );
}
else if (comp == &bt_hw_divided_class) {
bt_hw_divided_class.pressed = !bt_hw_divided_class.pressed;
cont_haltlist.set_divided_by_class(bt_hw_divided_class.pressed);
}
else if (comp == &reset_all_pass_button) {
cbuffer_t buf;
Expand Down
3 changes: 2 additions & 1 deletion gui/schedule_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class schedule_list_gui_t : public gui_frame_t, public action_listener_t

static const char *sort_text[SORT_MODES];

button_t bt_new_line, bt_edit_line, bt_delete_line, bt_withdraw_line, bt_mode_convois, bt_show_halt_name;
button_t bt_new_line, bt_edit_line, bt_delete_line, bt_withdraw_line, bt_mode_convois;
button_t bt_hw_show_halt_name, bt_hw_divided_class;
button_t sort_order;
button_t bt_access_minimap, bt_line_color_editor, bt_replace;
button_t reset_all_pass_button, reset_all_mail_button;
Expand Down
2 changes: 2 additions & 0 deletions simutrans/text/en.tab
Original file line number Diff line number Diff line change
Expand Up @@ -6000,6 +6000,8 @@ Divided by class
Divided by class
Waiting bars are displayed separately for each class.
Waiting bars are displayed separately for each class.
Waiting cargoes are displayed separately for each class.
Waiting cargoes are displayed separately for each class.
Unified
Unified
Divided by category
Expand Down
2 changes: 2 additions & 0 deletions simutrans/text/ja.tab
Original file line number Diff line number Diff line change
Expand Up @@ -3961,6 +3961,8 @@ Divided by class
クラス毎に分割表示
Waiting bars are displayed separately for each class.
待機バーを各クラス毎に分割して表示します。
Waiting cargoes are displayed separately for each class.
待機数を各クラス毎に分割して表示します。
Unified
全ての貨物をまとめて表示
Divided by category
Expand Down

0 comments on commit adb318b

Please sign in to comment.