diff --git a/gui/convoi_detail_t.cc b/gui/convoi_detail_t.cc index 2a52e8f3..06cd8baa 100644 --- a/gui/convoi_detail_t.cc +++ b/gui/convoi_detail_t.cc @@ -106,7 +106,7 @@ void convoi_detail_t::draw(scr_coord pos, scr_size size) offset_y += LINESPACE; buf.clear(); - buf.printf("%s %i", translator::translate("Station tiles:"), cnv->get_tile_length() ); + buf.printf("%s %i %s %i", translator::translate("Vehicle count:"), cnv->get_vehicle_count(), translator::translate("Station tiles:"), cnv->get_tile_length()); display_proportional_clip_rgb( pos.x+10, offset_y, buf, ALIGN_LEFT, SYSCOL_TEXT, true ); offset_y += LINESPACE; diff --git a/gui/depot_frame.cc b/gui/depot_frame.cc index d65d80a8..fb9823e6 100644 --- a/gui/depot_frame.cc +++ b/gui/depot_frame.cc @@ -91,6 +91,7 @@ depot_frame_t::depot_frame_t(depot_t* depot) : scrolly_electrics(&cont_electrics), scrolly_loks(&cont_loks), scrolly_waggons(&cont_waggons), + scrolly_convoi(&cont_convoi), lb_vehicle_filter("Filter:", SYSCOL_TEXT, gui_label_t::right) { scr_size size = scr_size(0,0); @@ -134,7 +135,11 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g convoi.set_player_nr(depot->get_player_nr()); convoi.add_listener(this); - add_component(&convoi); + cont_convoi.add_component(&lb_convoi_number); + cont_convoi.add_component(&convoi); + + // add_component(&convoi); + add_component(&lb_convoi_count); add_component(&lb_convoi_speed); add_component(&lb_convoi_cost); @@ -157,9 +162,14 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g sb_convoi_length.add_color_value(&convoi_length_ok_sb, color_idx_to_rgb(COL_GREEN)); sb_convoi_length.add_color_value(&convoi_length_slower_sb, color_idx_to_rgb(COL_ORANGE)); sb_convoi_length.add_color_value(&convoi_length_too_slow_sb, color_idx_to_rgb(COL_RED)); - add_component(&sb_convoi_length); + //add_component(&sb_convoi_length); + cont_convoi.add_component(&sb_convoi_length); } + scrolly_convoi.set_scrollbar_mode(scrollbar_t::show_disabled); + scrolly_convoi.set_size_corner(false); + add_component(&scrolly_convoi); + /* * [ACTIONS] */ @@ -240,7 +250,11 @@ 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_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_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 ); @@ -298,7 +312,7 @@ void depot_frame_t::layout(scr_size *size) scr_coord_val grid_dx; scr_coord_val placement_dx; - scr_size win_size = (size!=NULL)? *size : get_windowsize(); + scr_size win_size = (size != NULL) ? *size : get_windowsize(); /* * These parameter are adjusted to resolution. @@ -368,15 +382,16 @@ void depot_frame_t::layout(scr_size *size) /* * Total width is the max from [CONVOI] and [ACTIONS] width. */ - const scr_coord_val MIN_DEPOT_FRAME_WIDTH = max(CONVOI_WIDTH, ACTIONS_WIDTH); - const scr_coord_val DEPOT_FRAME_WIDTH = max(win_size.w, max(CONVOI_WIDTH, ACTIONS_WIDTH)); + const scr_coord_val MIN_DEPOT_FRAME_WIDTH = ACTIONS_WIDTH;//max(CONVOI_WIDTH, ACTIONS_WIDTH); + const scr_coord_val DEPOT_FRAME_WIDTH = max(win_size.w, ACTIONS_WIDTH);//max(win_size.w, max(CONVOI_WIDTH, ACTIONS_WIDTH)); /* * Now we can do the first vertical adjustment: + * タブ群までの個々の要素の位置を求める */ const scr_coord_val SELECT_VSTART = D_MARGIN_TOP; const scr_coord_val CONVOI_VSTART = SELECT_VSTART + SELECT_HEIGHT + LINESPACE; - const scr_coord_val CINFO_VSTART = CONVOI_VSTART + CLIST_HEIGHT; + const scr_coord_val CINFO_VSTART = CONVOI_VSTART + CLIST_HEIGHT + 16; const scr_coord_val ACTIONS_VSTART = CINFO_VSTART + CINFO_HEIGHT; const scr_coord_val PANEL_VSTART = ACTIONS_VSTART + ACTIONS_HEIGHT; @@ -387,8 +402,8 @@ void depot_frame_t::layout(scr_size *size) * Total width will be expanded to match complete columns in panel. */ const scr_coord_val total_h = PANEL_VSTART + VINFO_HEIGHT + D_TITLEBAR_HEIGHT + D_TAB_HEADER_HEIGHT + 2 * gui_image_list_t::BORDER + D_MARGIN_BOTTOM + 1; - scr_coord_val PANEL_ROWS = max(1, ((win_size.h-total_h)/grid.y) ); - if( size && size->h == 0 ) { + scr_coord_val PANEL_ROWS = max(1, ((win_size.h - total_h) / grid.y)); + if (size && size->h == 0) { PANEL_ROWS = 3; } const scr_coord_val PANEL_HEIGHT = PANEL_ROWS * grid.y + D_TAB_HEADER_HEIGHT + 2 * gui_image_list_t::BORDER; @@ -405,13 +420,13 @@ void depot_frame_t::layout(scr_size *size) * DONE with layout planning - now build everything. */ set_min_windowsize(scr_size(MIN_DEPOT_FRAME_WIDTH, MIN_TOTAL_HEIGHT)); - if( win_size.w < DEPOT_FRAME_WIDTH ) { - gui_frame_t::set_windowsize(scr_size(MIN_DEPOT_FRAME_WIDTH, max(win_size.h,MIN_TOTAL_HEIGHT) )); + if (win_size.w < DEPOT_FRAME_WIDTH) { + gui_frame_t::set_windowsize(scr_size(MIN_DEPOT_FRAME_WIDTH, max(win_size.h, MIN_TOTAL_HEIGHT))); } - if( size && size->w == 0 ) { + if (size && size->w == 0) { size->w = DEPOT_FRAME_WIDTH; } - if( size && size->h == 0 ) { + if (size && size->h == 0) { size->h = TOTAL_HEIGHT; } @@ -419,59 +434,74 @@ void depot_frame_t::layout(scr_size *size) const scr_coord_val second_column_w = DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - second_column_x; /* - * [SELECT]: - */ + * [SELECT]: + */ lb_convois.set_pos(scr_coord(D_MARGIN_LEFT, SELECT_VSTART + 3)); - lb_convois.set_width( selector_x - D_H_SPACE ); + lb_convois.set_width(selector_x - D_H_SPACE); convoy_selector.set_pos(scr_coord(D_MARGIN_LEFT + selector_x, SELECT_VSTART)); convoy_selector.set_size(scr_size(DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT - selector_x, D_BUTTON_HEIGHT)); convoy_selector.set_max_size(scr_size(DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT - selector_x, LINESPACE * 13 + 2 + 16)); /* - * [SELECT ROUTE]: - * @author hsiegeln - */ + * [SELECT ROUTE]: + * @author hsiegeln + */ line_button.set_pos(scr_coord(D_MARGIN_LEFT, SELECT_VSTART + D_BUTTON_HEIGHT + 3)); lb_convoi_line.set_pos(scr_coord(D_MARGIN_LEFT + line_button.get_size().w + 2, SELECT_VSTART + D_BUTTON_HEIGHT + 3)); - lb_convoi_line.set_width( selector_x - line_button.get_size().w - 2 - D_H_SPACE ); + lb_convoi_line.set_width(selector_x - line_button.get_size().w - 2 - D_H_SPACE); line_selector.set_pos(scr_coord(D_MARGIN_LEFT + selector_x, SELECT_VSTART + D_BUTTON_HEIGHT)); line_selector.set_size(scr_size(DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT - selector_x, D_BUTTON_HEIGHT)); line_selector.set_max_size(scr_size(DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT - selector_x, LINESPACE * 13 + 2 + 16)); /* - * [CONVOI] - */ + * [CONVOI] + */ convoi.set_grid(scr_coord(grid.x - grid_dx, grid.y)); convoi.set_placement(scr_coord(placement.x - placement_dx, placement.y)); - convoi.set_pos(scr_coord((DEPOT_FRAME_WIDTH-CLIST_WIDTH) / 2, CONVOI_VSTART)); + // convoi.set_pos(scr_coord((DEPOT_FRAME_WIDTH-CLIST_WIDTH) / 2, CONVOI_VSTART)); + convoi.set_pos(scr_coord(0, 0)); convoi.set_size(scr_size(CLIST_WIDTH, CLIST_HEIGHT)); - sb_convoi_length.set_pos(scr_coord((DEPOT_FRAME_WIDTH-CLIST_WIDTH) / 2 + 5,CONVOI_VSTART + grid.y + 5)); + // sb_convoi_length.set_pos(scr_coord((DEPOT_FRAME_WIDTH-CLIST_WIDTH) / 2 + 5,CONVOI_VSTART + grid.y + 5)); + sb_convoi_length.set_pos(scr_coord(5, grid.y + 5)); sb_convoi_length.set_size(scr_size(CLIST_WIDTH - 10, 4)); + cont_convoi.set_size(scr_size(CLIST_WIDTH, grid.y + 5 + 4)); + scrolly_convoi.set_size(scr_size(DEPOT_FRAME_WIDTH - 12, cont_convoi.get_size().h + 18)); + // scrolly_convoi.set_scroll_amount_x(grid.x); + scrolly_convoi.set_show_scroll_x(true); + scrolly_convoi.set_show_scroll_y(false); + scrolly_convoi.set_scroll_discrete_x(false); + scrolly_convoi.set_size_corner(false); + scrolly_convoi.set_pos(scr_coord(6, CONVOI_VSTART)); + + lb_convoi_number.set_width(30); + lb_convoi_number.set_color(COL_WHITE); + lb_convoi_count.set_pos(scr_coord(D_MARGIN_LEFT, CINFO_VSTART)); - lb_convoi_count.set_width( second_column_w - D_H_SPACE ); + lb_convoi_count.set_width(second_column_w - D_H_SPACE); + cont_convoi_capacity.set_pos(scr_coord(second_column_x, CINFO_VSTART)); cont_convoi_capacity.set_width(second_column_w); lb_convoi_cost.set_pos(scr_coord(D_MARGIN_LEFT, CINFO_VSTART + LINESPACE * 1)); - lb_convoi_cost.set_width( second_column_w - D_H_SPACE ); + lb_convoi_cost.set_width(second_column_w - D_H_SPACE); lb_convoi_value.set_pos(scr_coord(second_column_x, CINFO_VSTART + LINESPACE * 1)); lb_convoi_value.set_width(second_column_w); lb_convoi_power.set_pos(scr_coord(D_MARGIN_LEFT, CINFO_VSTART + LINESPACE * 2)); - lb_convoi_power.set_width( second_column_w - D_H_SPACE ); + lb_convoi_power.set_width(second_column_w - D_H_SPACE); lb_convoi_weight.set_pos(scr_coord(second_column_x, CINFO_VSTART + LINESPACE * 2)); lb_convoi_weight.set_width(second_column_w); lb_convoi_speed.set_pos(scr_coord(D_MARGIN_LEFT, CINFO_VSTART + LINESPACE * 3)); - lb_convoi_speed.set_width( DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT ); + lb_convoi_speed.set_width(DEPOT_FRAME_WIDTH - D_MARGIN_RIGHT - D_MARGIN_LEFT); /* - * [ACTIONS] - */ + * [ACTIONS] + */ bt_start.set_pos(scr_coord(D_MARGIN_LEFT, ACTIONS_VSTART)); bt_start.set_size(scr_size((DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) / 4 - 3, D_BUTTON_HEIGHT)); bt_start.set_text("Start"); @@ -496,9 +526,9 @@ void depot_frame_t::layout(scr_size *size) pas.set_grid(grid); pas.set_placement(placement); - pas.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH,0)); + pas.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH, 0)); pas.recalc_size(); - pas.set_pos(scr_coord(0,0)); + pas.set_pos(scr_coord(0, 0)); cont_pas.set_size(pas.get_size()); scrolly_pas.set_size(scrolly_pas.get_size()); scrolly_pas.set_scroll_amount_y(grid.y); @@ -507,9 +537,9 @@ void depot_frame_t::layout(scr_size *size) electrics.set_grid(grid); electrics.set_placement(placement); - electrics.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH,0)); + electrics.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH, 0)); electrics.recalc_size(); - electrics.set_pos(scr_coord(0,0)); + electrics.set_pos(scr_coord(0, 0)); cont_electrics.set_size(electrics.get_size()); scrolly_electrics.set_size(scrolly_electrics.get_size()); scrolly_electrics.set_scroll_amount_y(grid.y); @@ -518,9 +548,9 @@ void depot_frame_t::layout(scr_size *size) loks.set_grid(grid); loks.set_placement(placement); - loks.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH,0)); + loks.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH, 0)); loks.recalc_size(); - loks.set_pos(scr_coord(0,0)); + loks.set_pos(scr_coord(0, 0)); cont_loks.set_size(loks.get_size()); scrolly_loks.set_size(scrolly_loks.get_size()); scrolly_loks.set_scroll_amount_y(grid.y); @@ -529,16 +559,16 @@ void depot_frame_t::layout(scr_size *size) waggons.set_grid(grid); waggons.set_placement(placement); - waggons.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH,0)); + waggons.set_size(tabs.get_size() - scr_size(D_SCROLLBAR_WIDTH, 0)); waggons.recalc_size(); - waggons.set_pos(scr_coord(0,0)); + waggons.set_pos(scr_coord(0, 0)); cont_waggons.set_size(waggons.get_size()); scrolly_waggons.set_size(scrolly_waggons.get_size()); scrolly_waggons.set_scroll_amount_y(grid.y); scrolly_waggons.set_scroll_discrete_y(false); scrolly_waggons.set_size_corner(false); - div_tabbottom.set_pos(scr_coord(0,PANEL_VSTART + PANEL_HEIGHT)); + div_tabbottom.set_pos(scr_coord(0, PANEL_VSTART + PANEL_HEIGHT)); div_tabbottom.set_width(DEPOT_FRAME_WIDTH); /* @@ -547,16 +577,16 @@ void depot_frame_t::layout(scr_size *size) bt_veh_action.set_pos(scr_coord(D_MARGIN_LEFT + (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 + 3, INFO_VSTART)); bt_veh_action.set_size(scr_size((DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) - (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 - 3, D_BUTTON_HEIGHT)); - lb_veh_action.align_to(&bt_veh_action, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_CENTER_V, scr_coord(D_V_SPACE,0)); + lb_veh_action.align_to(&bt_veh_action, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_CENTER_V, scr_coord(D_V_SPACE, 0)); bt_show_all.set_pos(scr_coord(D_MARGIN_LEFT, INFO_VSTART + D_BUTTON_HEIGHT + 1)); const int w = max(72, bt_show_all.get_size().w); bt_obsolete.set_pos(scr_coord(D_MARGIN_LEFT + w + 4 + 6, INFO_VSTART + D_BUTTON_HEIGHT + 1)); - vehicle_filter.set_pos( scr_coord(D_MARGIN_LEFT + (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 + 3, INFO_VSTART + D_BUTTON_HEIGHT)); - vehicle_filter.set_size( scr_size((DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) - (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 - 3, D_BUTTON_HEIGHT)); - vehicle_filter.set_max_size( scr_size( D_BUTTON_WIDTH + 60, ((size && size->h>0) ? size->h : gui_frame_t::get_windowsize().h)-INFO_VSTART-D_BUTTON_HEIGHT-D_MARGIN_BOTTOM-D_TITLEBAR_HEIGHT ) ); + vehicle_filter.set_pos(scr_coord(D_MARGIN_LEFT + (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 + 3, INFO_VSTART + D_BUTTON_HEIGHT)); + vehicle_filter.set_size(scr_size((DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) - (DEPOT_FRAME_WIDTH - D_MARGIN_LEFT - D_MARGIN_RIGHT) * 3 / 4 - 3, D_BUTTON_HEIGHT)); + vehicle_filter.set_max_size(scr_size(D_BUTTON_WIDTH + 60, LINESPACE * 7)); lb_vehicle_filter.align_to(&vehicle_filter, ALIGN_RIGHT | ALIGN_EXTERIOR_H | ALIGN_TOP, scr_coord(0,D_GET_CENTER_ALIGN_OFFSET(LINESPACE,D_BUTTON_HEIGHT))); @@ -1055,7 +1085,7 @@ void depot_frame_t::update_data() convoi_tile_length_sb = convoi_length + (cnv->get_tile_length() * CARUNITS_PER_TILE - cnv->get_length()); txt_convoi_count.clear(); - txt_convoi_count.printf("%s %i",translator::translate("Station tiles:"), cnv->get_tile_length() ); + txt_convoi_count.printf("%s %i %s %i", translator::translate("Vehicle count:"), cnv->get_vehicle_count(), translator::translate("Station tiles:"), cnv->get_tile_length()); txt_convoi_speed.clear(); if( empty_kmh != (use_sel_weight ? sel_kmh : min_kmh) ) { @@ -1119,7 +1149,7 @@ void depot_frame_t::update_data() } else { txt_convoi_count.clear(); - txt_convoi_count.append( translator::translate("keine Fahrzeuge") ); + txt_convoi_count.append(translator::translate("keine Fahrzeuge")); txt_convoi_value.clear(); txt_convoi_cost.clear(); txt_convoi_power.clear(); @@ -1534,7 +1564,8 @@ void depot_frame_t::draw_vehicle_info_text(scr_coord pos) double resale_value = -1.0; const vehicle_desc_t *veh_type = NULL; bool new_vehicle_length_sb_force_zero = false; - scr_coord relpos = scr_coord( 0, ((gui_scrollpane_t *)tabs.get_aktives_tab())->get_scroll_y() ); + sint16 convoi_number = -1; + scr_coord relpos = scr_coord(0, ((gui_scrollpane_t *)tabs.get_aktives_tab())->get_scroll_y()); int sel_index = lst->index_at( pos + tabs.get_pos() - relpos, x, y - D_TITLEBAR_HEIGHT - D_TAB_HEADER_HEIGHT); if( (sel_index != -1) && (tabs.getroffen(x - pos.x, y - pos.y - D_TITLEBAR_HEIGHT)) ) { @@ -1551,7 +1582,9 @@ void depot_frame_t::draw_vehicle_info_text(scr_coord pos) } else { // cursor over a vehicle in the convoi - sel_index = convoi.index_at( pos , x, y - D_TITLEBAR_HEIGHT); + relpos = scr_coord(scrolly_convoi.get_scroll_x(), 0); + + convoi_number = sel_index = convoi.index_at(pos - relpos + scrolly_convoi.get_pos(), x, y - D_TITLEBAR_HEIGHT); if( sel_index != -1 ) { convoihandle_t cnv = depot->get_convoi( icnv ); veh_type = cnv->get_vehikel( sel_index )->get_desc(); @@ -1668,8 +1701,15 @@ void depot_frame_t::draw_vehicle_info_text(scr_coord pos) // update speedbar new_vehicle_length_sb = new_vehicle_length_sb_force_zero ? 0 : convoi_length_ok_sb + convoi_length_slower_sb + convoi_length_too_slow_sb + veh_type->get_length(); + + txt_convoi_number.clear(); + if (convoi_number>-1){ + txt_convoi_number.printf("%d", convoi_number + 1); + lb_convoi_number.set_pos(scr_coord(((depot->get_x_grid() * get_base_tile_raster_width() / 64 + 4) - (depot->get_x_grid() * get_base_tile_raster_width() / 64 / 2))*convoi_number + 4, 4)); + } } else { + txt_convoi_number.clear(); new_vehicle_length_sb = 0; } diff --git a/gui/depot_frame.h b/gui/depot_frame.h index a66e54f2..a88cd5a4 100644 --- a/gui/depot_frame.h +++ b/gui/depot_frame.h @@ -93,6 +93,9 @@ private: button_t line_button; // goto line ... gui_label_t lb_convoi_count; + + gui_label_t lb_convoi_number; + gui_label_t lb_convoi_speed; gui_label_t lb_convoi_cost; gui_label_t lb_convoi_value; @@ -134,6 +137,9 @@ private: vector_tpl convoi_pics; gui_image_list_t convoi; + gui_scrollpane_t scrolly_convoi; + gui_container_t cont_convoi; + /// image list of passenger cars vector_tpl pas_vec; /// image list of electrified passenger carrier units @@ -181,6 +187,7 @@ private: cbuffer_t txt_convois; cbuffer_t txt_convoi_count; + cbuffer_t txt_convoi_number; cbuffer_t txt_convoi_value; cbuffer_t txt_convoi_speed; cbuffer_t txt_convoi_cost; diff --git a/simconvoi.h b/simconvoi.h index 6805c267..11573387 100644 --- a/simconvoi.h +++ b/simconvoi.h @@ -55,7 +55,7 @@ public: /* Constants * @author prissi */ - enum { max_vehicle=4, max_rail_vehicle = 24 }; + enum { max_vehicle=8, max_rail_vehicle = 64 }; enum states {INITIAL, EDIT_SCHEDULE,