From 356a23345ca81b7335494a5fbd6b6bbd522f2c6d Mon Sep 17 00:00:00 2001 From: hreintke Date: Wed, 8 Sep 2021 14:34:03 +0200 Subject: [PATCH] Multiline halt/goods info in line gui --- gui/halt_list_stats.cc | 10 +++++----- gui/halt_list_stats.h | 5 ++++- simhalt.cc | 21 ++++++++++++--------- simhalt.h | 2 +- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/gui/halt_list_stats.cc b/gui/halt_list_stats.cc index b51c13b53..5857d3147 100644 --- a/gui/halt_list_stats.cc +++ b/gui/halt_list_stats.cc @@ -85,9 +85,9 @@ halt_list_stats_t::halt_list_stats_t(halthandle_t h) img_enabled[1].set_rigid(true); img_enabled[2].set_rigid(true); - add_component(&label_cargo); - halt->get_short_freight_info( label_cargo.buf() ); - label_cargo.update(); + add_component(&text_cargo); + cargobuf.clear(); + halt->get_short_freight_info( cargobuf, true ); } end_table(); } @@ -112,8 +112,8 @@ void halt_list_stats_t::draw(scr_coord offset) label_name.set_color(halt->get_status_farbe()); label_name.set_shadow(SYSCOL_TEXT,true); - halt->get_short_freight_info( label_cargo.buf() ); - label_cargo.update(); + cargobuf.clear(); + halt->get_short_freight_info( cargobuf, true); set_size(get_size()); gui_aligned_container_t::draw(offset); diff --git a/gui/halt_list_stats.h b/gui/halt_list_stats.h index 6dbebf56f..3f9427775 100644 --- a/gui/halt_list_stats.h +++ b/gui/halt_list_stats.h @@ -15,6 +15,7 @@ #include "components/gui_image.h" #include "components/gui_label.h" #include "components/gui_scrolled_list.h" +#include "components/gui_textarea.h" #include "../halthandle_t.h" class gui_halt_type_images_t; @@ -26,7 +27,9 @@ private: halthandle_t halt; public: - gui_label_buf_t label_name, label_cargo; + cbuffer_t cargobuf; + gui_label_buf_t label_name; + gui_textarea_t text_cargo { &cargobuf }; gui_image_t img_enabled[3]; gui_halt_type_images_t *img_types; gui_colorbox_t indicator; diff --git a/simhalt.cc b/simhalt.cc index bbded4d90..db763b7ec 100644 --- a/simhalt.cc +++ b/simhalt.cc @@ -2508,7 +2508,7 @@ void haltestelle_t::get_freight_info(cbuffer_t & buf) -void haltestelle_t::get_short_freight_info(cbuffer_t & buf) const +void haltestelle_t::get_short_freight_info(cbuffer_t & buf, bool multiline) const { bool got_one = false; @@ -2521,7 +2521,12 @@ void haltestelle_t::get_short_freight_info(cbuffer_t & buf) const if(summe>0) { if(got_one) { - buf.append(", "); + if (multiline) { + buf.append("\n"); + } + else { + buf.append(", "); + } } int max = get_capacity( i>2?2:i ); @@ -2532,19 +2537,17 @@ void haltestelle_t::get_short_freight_info(cbuffer_t & buf) const } } - if(got_one) { - buf.append(" "); - buf.append(translator::translate("waiting")); + if (!got_one) { + buf.append(translator::translate("no goods waiting")); buf.append("\n"); } - else { - buf.append(translator::translate("no goods waiting")); + else if (!multiline) { + buf.append(" "); + buf.append(translator::translate("waiting")); buf.append("\n"); } } - - void haltestelle_t::open_info_window() { create_win( new halt_info_t(self), w_info, magic_halt_info + self.get_id() ); diff --git a/simhalt.h b/simhalt.h index de161955e..159a0f3d9 100644 --- a/simhalt.h +++ b/simhalt.h @@ -693,7 +693,7 @@ public: /** * @param[out] buf short list of the waiting goods (i.e. 110 Wood, 15 Coal) */ - void get_short_freight_info(cbuffer_t & buf) const; + void get_short_freight_info(cbuffer_t & buf, bool multiline = false) const; /** * Opens an information window for this station. -- 2.20.1.windows.1