diff --git a/gui/depot_frame.cc b/gui/depot_frame.cc index f73344f..8e3eb50 100644 --- a/gui/depot_frame.cc +++ b/gui/depot_frame.cc @@ -10,6 +10,7 @@ */ #include +#include #include "../simunits.h" #include "../simworld.h" @@ -55,6 +56,8 @@ #include "../boden/wege/weg.h" +char depot_frame_t::name_filter_value[64] = ""; + static const char* engine_type_names[9] = { "unknown", @@ -70,6 +73,7 @@ static const char* engine_type_names[9] = bool depot_frame_t::show_retired_vehicles = false; bool depot_frame_t::show_all = true; +bool depot_frame_t::name_filter = false; depot_frame_t::depot_frame_t(depot_t* depot) : @@ -211,6 +215,12 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g bt_veh_action.set_tooltip("Choose operation executed on clicking stored/new vehicles"); add_component(&bt_veh_action); + bt_name_filter.set_typ(button_t::square); + bt_name_filter.set_text(""); + bt_name_filter.add_listener(this); + bt_name_filter.set_tooltip("Toggle name filter"); + add_component(&bt_name_filter); + bt_show_all.set_typ(button_t::square); bt_show_all.set_text("Show all"); bt_show_all.add_listener(this); @@ -349,7 +359,7 @@ void depot_frame_t::layout(scr_size *size) * [Start][Schedule][Destroy][Sell] * [new Route][change Route][delete Route] */ - const scr_coord_val ACTIONS_WIDTH = D_DEFAULT_WIDTH; + const scr_coord_val ACTIONS_WIDTH = D_DEFAULT_WIDTH + 110; // because depot has a text input frame for search const scr_coord_val ACTIONS_HEIGHT = D_BUTTON_HEIGHT; /* @@ -541,6 +551,15 @@ void depot_frame_t::layout(scr_size *size) lb_veh_action.align_to(&bt_veh_action, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_CENTER_V, scr_coord(D_V_SPACE,0)); + bt_name_filter.set_pos(scr_coord(180, INFO_VSTART + D_BUTTON_HEIGHT + 1 )); + bt_name_filter.pressed = name_filter; + + name_filter_input.set_text(name_filter_value, 60); + name_filter_input.set_size(scr_size(120, 14)); + name_filter_input.set_pos(scr_coord(180 + 15, INFO_VSTART + D_BUTTON_HEIGHT + 1)); + name_filter_input.add_listener(this); + add_component(&name_filter_input); + bt_show_all.set_pos(scr_coord(D_MARGIN_LEFT, INFO_VSTART + D_BUTTON_HEIGHT + 1)); bt_show_all.pressed = show_all; @@ -709,7 +728,10 @@ void depot_frame_t::build_vehicle_lists() } } if(append) { - add_to_vehicle_list( info ); + // name filter. Try to check both object name and translation name. + if( !name_filter || strstr(info->get_name(), name_filter_value) || strstr(translator::translate(info->get_name()), name_filter_value)) { + add_to_vehicle_list( info ); + } } } } @@ -1077,6 +1099,13 @@ bool depot_frame_t::action_triggered( gui_action_creator_t *comp, value_t p) show_all = (show_all == 0); depot_t::update_all_win(); } + else if( comp == &bt_name_filter ) { + name_filter = (name_filter == 0); + depot_t::update_all_win(); + } + else if( comp == &name_filter_input ) { + depot_t::update_all_win(); + } else if( comp == &bt_veh_action ) { if( veh_action == va_sell ) { veh_action = va_append; @@ -1469,6 +1498,7 @@ void depot_frame_t::draw(scr_coord pos, scr_size size) bt_obsolete.pressed = show_retired_vehicles; // otherwise the button would not show depressed bt_show_all.pressed = show_all; // otherwise the button would not show depressed + bt_name_filter.pressed = name_filter; // otherwise the button would not show depressed gui_frame_t::draw(pos, size); draw_vehicle_info_text(pos); diff --git a/gui/depot_frame.h b/gui/depot_frame.h index a6cc964..7441838 100644 --- a/gui/depot_frame.h +++ b/gui/depot_frame.h @@ -79,6 +79,10 @@ private: */ static bool show_all; + /* filter by name + */ + static bool name_filter; + /** * Gui elements * @author Volker Meyer @@ -112,6 +116,10 @@ private: button_t bt_obsolete; button_t bt_show_all; + button_t bt_name_filter; + + static char name_filter_value[64]; + gui_textinput_t name_filter_input; gui_tab_panel_t tabs; gui_divider_t div_tabbottom;