diff --git a/gui/depot_frame.cc b/gui/depot_frame.cc index 1e3b0ad87..83a7acf98 100644 --- a/gui/depot_frame.cc +++ b/gui/depot_frame.cc @@ -83,8 +83,6 @@ depot_frame_t::depot_frame_t(depot_t* depot) : depot(depot), icnv(depot->convoi_count()-1), lb_convoi_line("Serves Line:", SYSCOL_TEXT, gui_label_t::left), - lb_sort_by("Sort by:", SYSCOL_TEXT, gui_label_t::right), - lb_name_filter_input("Search:", SYSCOL_TEXT, gui_label_t::right), lb_veh_action("Fahrzeuge:", SYSCOL_TEXT, gui_label_t::right), convoi_pics(depot->get_max_convoi_length()), convoi(&convoi_pics), @@ -97,6 +95,8 @@ depot_frame_t::depot_frame_t(depot_t* depot) : scrolly_electrics(&cont_electrics), scrolly_loks(&cont_loks), scrolly_waggons(&cont_waggons), + lb_sort_by("Sort by:", SYSCOL_TEXT, gui_label_t::right), + lb_name_filter("Search:", SYSCOL_TEXT, gui_label_t::right), lb_vehicle_filter("Filter:", SYSCOL_TEXT, gui_label_t::right) { scr_size size = scr_size(0,0); @@ -220,8 +220,9 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g add_component(&div_tabbottom); add_component(&lb_veh_action); add_component(&lb_sort_by); + add_component(&lb_name_filter); add_component(&lb_vehicle_filter); - add_component(&lb_name_filter_input); + add_component(&div_action_bottom); veh_action = va_append; bt_veh_action.set_typ(button_t::roundbox); @@ -260,11 +261,8 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g build_vehicle_lists(); // text will be translated by ourselves (after update data)! - lb_convois.set_text_pointer(txt_convois); - - lb_convoi_count.set_text_pointer(txt_convoi_count); - lb_convoi_number.set_text_pointer(txt_convoi_number); - + lb_convois.set_text_pointer( txt_convois ); + lb_convoi_number.set_text_pointer( txt_convoi_number ); lb_convoi_count.set_text_pointer( txt_convoi_count ); lb_convoi_speed.set_text_pointer( txt_convoi_speed ); lb_convoi_cost.set_text_pointer( txt_convoi_cost ); @@ -587,34 +585,37 @@ void depot_frame_t::layout(scr_size *size) /* * [BOTTOM] */ + + //1st line bt_veh_action.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*3, INFO_VSTART)); bt_veh_action.set_size(scr_size(BUTTON_WIDTH_DEPOT, D_BUTTON_HEIGHT)); - lb_veh_action.align_to(&bt_veh_action, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_CENTER_V, scr_coord(D_H_SPACE, 0)); - vehicle_filter.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*3, INFO_VSTART + D_BUTTON_HEIGHT + D_V_SPACE)); + //2nd line + vehicle_filter.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*2 - proportional_string_width(translator::translate("Search:")), INFO_VSTART + D_BUTTON_HEIGHT + D_V_SPACE)); vehicle_filter.set_size(scr_size(BUTTON_WIDTH_DEPOT, D_BUTTON_HEIGHT)); vehicle_filter.set_max_size(scr_size(D_BUTTON_WIDTH, LINESPACE*7)); + lb_vehicle_filter.align_to(&vehicle_filter, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(2,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); - lb_vehicle_filter.align_to(&vehicle_filter, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(D_H_SPACE,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); - - bt_show_all.set_pos(scr_coord(D_MARGIN_LEFT, INFO_VSTART + D_BUTTON_HEIGHT + D_V_SPACE)); - bt_show_all.align_to(&vehicle_filter, ALIGN_CENTER_V); - + name_filter_input.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*3, INFO_VSTART + D_BUTTON_HEIGHT + D_V_SPACE)); name_filter_input.set_size( scr_size( BUTTON_WIDTH_DEPOT, D_EDIT_HEIGHT ) ); - name_filter_input.set_pos( vehicle_filter.get_pos()+scr_coord(0,D_V_SPACE+D_BUTTON_HEIGHT) ); - lb_name_filter_input.align_to(&name_filter_input, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(D_H_SPACE,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); + lb_name_filter.align_to(&name_filter_input, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(D_H_SPACE,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); bt_obsolete.set_pos(scr_coord(D_MARGIN_LEFT, INFO_VSTART + (D_BUTTON_HEIGHT + D_V_SPACE)*2)); bt_obsolete.align_to(&name_filter_input, ALIGN_CENTER_V); - int y = name_filter_input.get_pos().y + name_filter_input.get_size().h + D_V_SPACE; - - sort_by.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*3, y)); + //3rd line + sort_by.set_pos(scr_coord(D_MARGIN_LEFT + (BUTTON_WIDTH_DEPOT+D_H_SPACE)*3, INFO_VSTART + (D_BUTTON_HEIGHT + D_V_SPACE)*2)); sort_by.set_size(scr_size(BUTTON_WIDTH_DEPOT, D_BUTTON_HEIGHT)); sort_by.set_max_size(scr_size(D_BUTTON_WIDTH, LINESPACE * 7)); lb_sort_by.align_to(&sort_by, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(D_H_SPACE,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); + bt_show_all.set_pos(scr_coord(D_MARGIN_LEFT, INFO_VSTART + (D_BUTTON_HEIGHT + D_V_SPACE)*2)); + bt_show_all.align_to(&sort_by, ALIGN_CENTER_V); + + div_action_bottom.set_pos(scr_coord(0, INFO_VSTART + (D_BUTTON_HEIGHT + D_V_SPACE) * 3)); + div_action_bottom.set_width(win_size.w); + const scr_coord_val margin = 4; img_bolt.set_pos(scr_coord(get_windowsize().w - skinverwaltung_t::electricity->get_image(0)->get_pic()->w - margin, margin)); @@ -725,10 +726,7 @@ static int compare_engine(const vehicle_desc_t* a, const vehicle_desc_t* b) } static int compare_price(const vehicle_desc_t* a, const vehicle_desc_t* b) {return a->get_price() - b->get_price();} static int compare_cost(const vehicle_desc_t* a, const vehicle_desc_t* b) {return a->get_running_cost() - b->get_running_cost();} -static int compare_cost_per_unit(const vehicle_desc_t* a, const vehicle_desc_t* b) -{ - return a->get_running_cost()*b->get_capacity() - b->get_running_cost()*a->get_capacity(); -} +static int compare_cost_per_unit(const vehicle_desc_t* a, const vehicle_desc_t* b){return a->get_running_cost()*b->get_capacity() - b->get_running_cost()*a->get_capacity();} static int compare_topspeed(const vehicle_desc_t* a, const vehicle_desc_t* b) {return a->get_topspeed() - b->get_topspeed();} static int compare_power(const vehicle_desc_t* a, const vehicle_desc_t* b) {return (a->get_power() == 0 ? 0x7FFFFFF : a->get_power()) - (b->get_power() == 0 ? 0x7FFFFFF : b->get_power());} static int compare_weight(const vehicle_desc_t* a, const vehicle_desc_t* b) {return a->get_weight() - b->get_weight();} @@ -747,6 +745,9 @@ static bool compare_vehicles(const vehicle_desc_t* a, const vehicle_desc_t* b) case sb_price: cmp = compare_price(a, b); if (cmp != 0) return cmp < 0; + cmp = compare_cost(a, b); + if (cmp != 0) return cmp < 0; + break; case sb_cost: cmp = compare_cost(a, b); if (cmp != 0) return cmp < 0; @@ -772,6 +773,9 @@ static bool compare_vehicles(const vehicle_desc_t* a, const vehicle_desc_t* b) case sb_intro_date: cmp = compare_intro_year_month(a, b); if (cmp != 0) return cmp < 0; + cmp = compare_retire_year_month(a, b); + if (cmp != 0) return cmp < 0; + break; case sb_retire_date: cmp = compare_retire_year_month(a, b); if (cmp != 0) return cmp < 0; @@ -877,12 +881,12 @@ void depot_frame_t::build_vehicle_lists() } } } + DBG_DEBUG("depot_frame_t::build_vehicle_lists()","finally %i passenger vehicle, %i engines, %i good wagons",pas_vec.get_count(),loks_vec.get_count(),waggons_vec.get_count()); update_data(); update_tabs(); } - static void get_line_list(const depot_t* depot, vector_tpl* lines) { depot->get_owner()->simlinemgmt.get_lines(depot->get_line_type(), lines); @@ -1787,44 +1791,60 @@ void depot_frame_t::draw_vehicle_info_text(scr_coord pos) buf.append( "\n" ); } + buf.printf( "%s %3d km/h\n", translator::translate("Max. speed:"), veh_type->get_topspeed() ); + if( veh_type->get_power() > 0 ) { // LOCO - buf.printf( translator::translate("Power: %4d kW\n"), veh_type->get_power() ); - } - else { - buf.append( "\n" ); + if( veh_type->get_gear() != 64 ){ + buf.printf( "%s %4d kW (x%0.2f)\n", translator::translate("Power:"), veh_type->get_power(), veh_type->get_gear() / 64.0 ); + } + else { + buf.printf( translator::translate("Power: %4d kW\n"), veh_type->get_power() ); + } } - buf.printf( "%s %4.1ft\n", translator::translate("Weight:"), veh_type->get_weight() / 1000.0 ); - buf.printf( "%s %3d km/h", translator::translate("Max. speed:"), veh_type->get_topspeed() ); - - int yyy = pos.y + D_TITLEBAR_HEIGHT + sort_by.get_pos().y + sort_by.get_size().h - - LINESPACE; + int yyy = pos.y + D_TITLEBAR_HEIGHT + div_action_bottom.get_pos().y + div_action_bottom.get_size().h + 2; display_multiline_text_rgb( pos.x + D_MARGIN_LEFT, yyy, buf, SYSCOL_TEXT); // column 2 buf.clear(); - buf.printf( "%s %s %04d\n", - translator::translate("Intro. date:"), - translator::get_month_name( veh_type->get_intro_year_month() % 12 ), - veh_type->get_intro_year_month() / 12 - ); - - if( veh_type->get_retire_year_month() != DEFAULT_RETIRE_DATE * 12 ) { - buf.printf( "%s %s %04d\n", - translator::translate("Retire. date:"), - translator::get_month_name( veh_type->get_retire_year_month() % 12 ), - veh_type->get_retire_year_month() / 12 - ); - } - else { - buf.append( "\n" ); + buf.printf( "%s %4.1ft\n", translator::translate("Weight:"), veh_type->get_weight() / 1000.0 ); + switch (env_t::show_month) { + case env_t::DATE_FMT_JAPANESE: + case env_t::DATE_FMT_JAPANESE_NO_SEASON: + buf.printf( "%s %04d/%02d", translator::translate("Available:"), veh_type->get_intro_year_month() / 12, veh_type->get_intro_year_month() % 12 + 1 ); + break; + case env_t::DATE_FMT_GERMAN: + case env_t::DATE_FMT_GERMAN_NO_SEASON: + buf.printf( "%s %02d.%04d", translator::translate("Available:"), veh_type->get_intro_year_month() % 12 + 1, veh_type->get_intro_year_month() / 12 ); + break; + case env_t::DATE_FMT_US: + case env_t::DATE_FMT_US_NO_SEASON: + default: + buf.printf( "%s %02d/%04d", translator::translate("Available:"), veh_type->get_intro_year_month() % 12 + 1, veh_type->get_intro_year_month() / 12 ); + break; } - if( veh_type->get_power() > 0 && veh_type->get_gear() != 64 ) { - buf.printf( "%s %0.2f : 1\n", translator::translate("Gear:"), veh_type->get_gear() / 64.0 ); + buf.printf(" - "); + + if( veh_type->get_retire_year_month() != DEFAULT_RETIRE_DATE * 12 ) { + switch (env_t::show_month) { + case env_t::DATE_FMT_JAPANESE: + case env_t::DATE_FMT_JAPANESE_NO_SEASON: + buf.printf( "%04d/%02d\n", veh_type->get_retire_year_month() / 12, veh_type->get_retire_year_month() % 12 + 1 ); + break; + case env_t::DATE_FMT_GERMAN: + case env_t::DATE_FMT_GERMAN_NO_SEASON: + buf.printf( "%02d.%04d\n", veh_type->get_retire_year_month() % 12 + 1, veh_type->get_retire_year_month() / 12 ); + break; + case env_t::DATE_FMT_US: + case env_t::DATE_FMT_US_NO_SEASON: + default: + buf.printf( "%02d/%04d\n", veh_type->get_retire_year_month() % 12 + 1, veh_type->get_retire_year_month() / 12 ); + break; + } } else { - buf.append( "\n" ); + buf.append( "*\n" ); } if( char const* const copyright = veh_type->get_copyright() ) { diff --git a/gui/depot_frame.h b/gui/depot_frame.h index 8160fafdf..522a1bc73 100644 --- a/gui/depot_frame.h +++ b/gui/depot_frame.h @@ -119,12 +119,13 @@ private: gui_label_t lb_sort_by; gui_combobox_t sort_by; - gui_label_t lb_name_filter_input; + gui_label_t lb_name_filter; static char name_filter_value[64]; gui_textinput_t name_filter_input; gui_tab_panel_t tabs; gui_divider_t div_tabbottom; + gui_divider_t div_action_bottom; gui_label_t lb_veh_action; button_t bt_veh_action; diff --git a/gui/depot_frame.h.gch b/gui/depot_frame.h.gch new file mode 100644 index 000000000..93dc2be95 Binary files /dev/null and b/gui/depot_frame.h.gch differ diff --git a/simdepot.h.gch b/simdepot.h.gch new file mode 100644 index 000000000..8cd06cb3d Binary files /dev/null and b/simdepot.h.gch differ