1 /* 2 * Copyright (c) 1997 - 2001 Hansj�rg Malthaner 3 * 4 * This file is part of the Simutrans project under the artistic licence. 5 * (see licence.txt) 6 */ 7 8 /* 9 * The depot window, where to buy convois 10 */ 11 12 #ifndef gui_depot_frame2_t_h 13 #define gui_depot_frame2_t_h 14 15 #include "gui_frame.h" 16 #include "components/gui_label.h" 17 #include "components/gui_image.h" 18 #include "components/gui_image_list.h" 19 #include "components/gui_textinput.h" 20 #include "components/gui_combobox.h" 21 #include "components/gui_divider.h" 22 #include "../tpl/ptrhashtable_tpl.h" 23 #include "../tpl/vector_tpl.h" 24 #include "components/gui_tab_panel.h" 25 #include "components/gui_button.h" 26 #include "components/action_listener.h" 27 #include "components/gui_scrollpane.h" 28 #include "components/gui_speedbar.h" 29 #include "../simtypes.h" 30 #include "../utils/cbuffer_t.h" 31 #include "../linehandle_t.h" 32 #include "../convoihandle_t.h" 33 34 class depot_t; 35 class vehicle_desc_t; 36 37 38 class depot_convoi_capacity_t : public gui_container_t 39 { 40 private: 41 uint32 total_pax; 42 uint32 total_mail; 43 uint32 total_goods; 44 public: 45 depot_convoi_capacity_t(); 46 void set_totals(uint32 pax, uint32 mail, uint32 goods); 47 void draw(scr_coord offset) OVERRIDE; 48 }; 49 50 51 /** 52 * Depot frame, handles all interaction with a vehicle depot. 53 * 54 * @author Hansj�rg Malthaner 55 * @date 22-Nov-01 56 */ 57 class depot_frame_t : public gui_frame_t, 58 public action_listener_t 59 { 60 private: 61 /** 62 * The depot to display 63 * @author Hansj�rg Malthaner 64 */ 65 depot_t *depot; 66 67 /** 68 * The current convoi to display. 69 * @author Volker Meyer 70 * @date 09.06.2003 71 */ 72 int icnv; 73 74 /* show retired vehicles (same for all depot) 75 * @author prissi 76 */ 77 static bool show_retired_vehicles; 78 79 /* show retired vehicles (same for all depot) 80 * @author prissi 81 */ 82 static bool show_all; 83 84 /** 85 * Gui elements 86 * @author Volker Meyer 87 * @date 09.06.2003 88 */ 89 gui_label_t lb_convois; 90 91 /// contains the current translation of "new convoi" 92 const char* new_convoy_text; 93 gui_combobox_t convoy_selector; 94 95 button_t line_button; // goto line ... 96 97 gui_label_t lb_convoi_count; 98 99 gui_label_t lb_convoi_number; 100 101 gui_label_t lb_convoi_speed; 102 gui_label_t lb_convoi_cost; 103 gui_label_t lb_convoi_value; 104 gui_label_t lb_convoi_power; 105 gui_label_t lb_convoi_weight; 106 gui_label_t lb_convoi_line; 107 108 depot_convoi_capacity_t cont_convoi_capacity; 109 110 gui_speedbar_t sb_convoi_length; 111 sint32 convoi_length_ok_sb, convoi_length_slower_sb, convoi_length_too_slow_sb, convoi_tile_length_sb, new_vehicle_length_sb; 112 113 button_t bt_start; 114 button_t bt_schedule; 115 button_t bt_destroy; 116 button_t bt_sell; 117 118 button_t bt_obsolete; 119 button_t bt_show_all; 120 121 gui_label_t lb_sort_by; 122 gui_combobox_t sort_by; 123 124 gui_label_t lb_name_filter_input; 125 static char name_filter_value[64]; 126 gui_textinput_t name_filter_input; 127 128 gui_tab_panel_t tabs; 129 gui_divider_t div_tabbottom; 130 gui_divider_t div_action_bottom; 131 132 gui_label_t lb_veh_action; 133 button_t bt_veh_action; 134 135 /** 136 * buttons for new route-management 137 * @author hsiegeln 138 */ 139 button_t bt_new_line; 140 button_t bt_change_line; 141 button_t bt_copy_convoi; 142 button_t bt_apply_line; 143 144 vector_tpl<gui_image_list_t::image_data_t*> convoi_pics; 145 gui_image_list_t convoi; 146 147 gui_container_t cont_convoi; 148 gui_scrollpane_t scrolly_convoi; 149 150 /// image list of passenger cars 151 vector_tpl<gui_image_list_t::image_data_t*> pas_vec; 152 /// image list of electrified passenger carrier units 153 vector_tpl<gui_image_list_t::image_data_t*> electrics_vec; 154 /// image list of all other powered vehicles (and vehicles without freight capacity) 155 vector_tpl<gui_image_list_t::image_data_t*> loks_vec; 156 /// image list of all other cars (freight, non-powered) 157 vector_tpl<gui_image_list_t::image_data_t*> waggons_vec; 158 159 gui_image_list_t pas; 160 gui_image_list_t electrics; 161 gui_image_list_t loks; 162 gui_image_list_t waggons; 163 gui_scrollpane_t scrolly_pas; 164 gui_scrollpane_t scrolly_electrics; 165 gui_scrollpane_t scrolly_loks; 166 gui_scrollpane_t scrolly_waggons; 167 168 /// contains the current translation of "<no schedule set>" 169 const char* no_schedule_text; 170 /// contains the current translation of "<clear schedule>" 171 const char* clear_schedule_text; 172 /// contains the current translation of "<individual schedule>" 173 const char* unique_schedule_text; 174 /// contains the current translation of "<create new line>" 175 const char* new_line_text; 176 /// contains the current translation of "<promote to line>" 177 const char* promote_to_line_text; 178 /// "-----------" between header items and lines 179 const char* line_seperator; 180 181 gui_combobox_t line_selector; 182 183 gui_combobox_t vehicle_filter; 184 gui_label_t lb_vehicle_filter; 185 186 gui_image_t img_bolt; 187 188 linehandle_t selected_line, last_selected_line; 189 190 cbuffer_t txt_convois; 191 192 cbuffer_t txt_convoi_count; 193 cbuffer_t txt_convoi_number; 194 cbuffer_t txt_convoi_value; 195 cbuffer_t txt_convoi_speed; 196 cbuffer_t txt_convoi_cost; 197 cbuffer_t txt_convoi_power; 198 cbuffer_t txt_convoi_weight; 199 200 scr_coord_val second_column_x; // x position of the second text column 201 scr_coord_val second_column_w; 202 203 enum { va_append, va_insert, va_sell }; 204 uint8 veh_action; 205 206 /** 207 * A helper map to update loks_vec and waggons_Vec. All entries from 208 * loks_vec and waggons_vec are referenced here. 209 * @author Volker Meyer 210 * @date 09.06.2003 211 */ 212 typedef ptrhashtable_tpl<vehicle_desc_t const*, gui_image_list_t::image_data_t*> vehicle_image_map; 213 vehicle_image_map vehicle_map; 214 215 /** 216 * Draw the info text for the vehicle the mouse is over - if any. 217 * @author Volker Meyer, Hj. Malthaner 218 * @date 09.06.2003 219 * @update 09-Jan-04 220 */ 221 void draw_vehicle_info_text(scr_coord pos); 222 223 /** 224 * Calculate the values of the vehicles of the given type owned by the 225 * player. 226 * @author Volker Meyer 227 * @date 09.06.2003 228 */ 229 sint64 calc_restwert(const vehicle_desc_t *veh_type); 230 231 /** 232 * Does this window need a min size button in the title bar? 233 * @return true if such a button is needed 234 * @author Hj. Malthaner 235 */ has_min_sizer()236 bool has_min_sizer() const OVERRIDE {return true;} 237 238 // true if already stored here 239 bool is_in_vehicle_list(const vehicle_desc_t *info); 240 241 // add a single vehicle (helper function) 242 void add_to_vehicle_list(const vehicle_desc_t *info); 243 244 // for convoi image 245 void image_from_convoi_list(uint nr, bool to_end); 246 247 void image_from_storage_list(gui_image_list_t::image_data_t *image_data); 248 249 // initialize everything 250 void init(depot_t *depot); 251 252 public: 253 // sorting categories 254 enum { 255 sb_name, 256 sb_capacity, 257 sb_price, 258 sb_cost, 259 sb_cost_per_unit, 260 sb_speed, sb_power, 261 sb_weight, 262 sb_intro_date, 263 sb_retire_date, 264 sb_length 265 }; 266 267 // the next two are only needed for depot_t update notifications 268 void activate_convoi( convoihandle_t cnv ); 269 get_icnv()270 int get_icnv() const { return icnv; } 271 272 /** 273 * Do the dynamic dialog layout 274 * @author Volker Meyer 275 * @date 18.06.2003 276 */ 277 void layout(scr_size *); 278 279 /** 280 * Update texts, image lists and buttons according to the current state. 281 * @author Volker Meyer 282 * @date 09.06.2003 283 */ 284 void update_data(); 285 286 // more general functions ... 287 depot_frame_t(depot_t* depot = NULL); 288 289 ~depot_frame_t(); 290 291 /** 292 * Set the window size 293 * @author (Mathew Hounsell) 294 * @date 11-Mar-2003 295 */ 296 void set_windowsize(scr_size size) OVERRIDE; 297 298 /** 299 * Create and fill loks_vec and waggons_vec. 300 * @author Volker Meyer 301 * @date 09.06.2003 302 */ 303 void build_vehicle_lists(); 304 305 /* 306 * Will update the tabs (don't show empty ones). 307 * @author Gerd Wachsmuth 308 * @date 08.05.2009 309 */ 310 void update_tabs(); 311 312 /** 313 * Set the window associated helptext 314 * @return the filename for the helptext, or NULL 315 * @author Hj. Malthaner 316 */ get_help_filename()317 const char * get_help_filename() const OVERRIDE {return "depot.txt";} 318 319 /** 320 * Does this window need a next button in the title bar? 321 * @return true if such a button is needed 322 * @author Volker Meyer 323 */ has_next()324 bool has_next() const OVERRIDE {return true;} 325 326 koord3d get_weltpos(bool) OVERRIDE; 327 bool is_weltpos() OVERRIDE; 328 329 /** 330 * Open dialog for schedule entry. 331 * @author Hj. Malthaner 332 */ 333 void open_schedule_editor(); 334 335 bool infowin_event(event_t const*) OVERRIDE; 336 337 /** 338 * Draw the Frame 339 * @author Hansj�rg Malthaner 340 */ 341 void draw(scr_coord pos, scr_size size) OVERRIDE; 342 343 // @author hsiegeln 344 void apply_line(); 345 set_selected_line(linehandle_t line)346 void set_selected_line(linehandle_t line) { selected_line = line; } 347 348 bool action_triggered(gui_action_creator_t*, value_t) OVERRIDE; 349 350 uint32 get_rdwr_id() OVERRIDE; 351 352 void rdwr( loadsave_t * ) OVERRIDE; 353 }; 354 355 #endif 356