src/build_vehicle_gui.cpp
branchgamebalance
changeset 9910 0b2aebc8283e
parent 9907 3b068c3a1c74
child 9911 0b8b245a2391
equal deleted inserted replaced
9909:dce9a6923bb7 9910:0b2aebc8283e
   340 	&EngineIntroDateSorter,
   340 	&EngineIntroDateSorter,
   341 	&EngineNameSorter,
   341 	&EngineNameSorter,
   342 	&TrainEngineRunningCostSorter,
   342 	&TrainEngineRunningCostSorter,
   343 	&TrainEnginePowerVsRunningCostSorter,
   343 	&TrainEnginePowerVsRunningCostSorter,
   344 	&EngineReliabilitySorter,
   344 	&EngineReliabilitySorter,
   345 },{
   345 }, {
   346 	/* Road vehicles */
   346 	/* Road vehicles */
   347 	&EngineNumberSorter,
   347 	&EngineNumberSorter,
   348 	&EngineIntroDateSorter,
   348 	&EngineIntroDateSorter,
   349 	&EngineNameSorter,
   349 	&EngineNameSorter,
   350 	&EngineReliabilitySorter,
   350 	&EngineReliabilitySorter,
   351 },{
   351 }, {
   352 	/* Ships */
   352 	/* Ships */
   353 	&EngineNumberSorter,
   353 	&EngineNumberSorter,
   354 	&EngineIntroDateSorter,
   354 	&EngineIntroDateSorter,
   355 	&EngineNameSorter,
   355 	&EngineNameSorter,
   356 	&EngineReliabilitySorter,
   356 	&EngineReliabilitySorter,
   357 },{
   357 }, {
   358 	/* Aircraft */
   358 	/* Aircraft */
   359 	&EngineNumberSorter,
   359 	&EngineNumberSorter,
   360 	&AircraftEngineCostSorter,
   360 	&AircraftEngineCostSorter,
   361 	&AircraftEngineSpeedSorter,
   361 	&AircraftEngineSpeedSorter,
   362 	&EngineIntroDateSorter,
   362 	&EngineIntroDateSorter,
   376 	STR_SORT_BY_DROPDOWN_NAME,
   376 	STR_SORT_BY_DROPDOWN_NAME,
   377 	STR_ENGINE_SORT_RUNNING_COST,
   377 	STR_ENGINE_SORT_RUNNING_COST,
   378 	STR_ENGINE_SORT_POWER_VS_RUNNING_COST,
   378 	STR_ENGINE_SORT_POWER_VS_RUNNING_COST,
   379 	STR_SORT_BY_RELIABILITY,
   379 	STR_SORT_BY_RELIABILITY,
   380 	INVALID_STRING_ID
   380 	INVALID_STRING_ID
   381 },{
   381 }, {
   382 	/* Road vehicles */
   382 	/* Road vehicles */
   383 	STR_ENGINE_SORT_ENGINE_ID,
   383 	STR_ENGINE_SORT_ENGINE_ID,
   384 	STR_ENGINE_SORT_INTRO_DATE,
   384 	STR_ENGINE_SORT_INTRO_DATE,
   385 	STR_SORT_BY_DROPDOWN_NAME,
   385 	STR_SORT_BY_DROPDOWN_NAME,
   386 	STR_SORT_BY_RELIABILITY,
   386 	STR_SORT_BY_RELIABILITY,
   387 	INVALID_STRING_ID
   387 	INVALID_STRING_ID
   388 },{
   388 }, {
   389 	/* Ships */
   389 	/* Ships */
   390 	STR_ENGINE_SORT_ENGINE_ID,
   390 	STR_ENGINE_SORT_ENGINE_ID,
   391 	STR_ENGINE_SORT_INTRO_DATE,
   391 	STR_ENGINE_SORT_INTRO_DATE,
   392 	STR_SORT_BY_DROPDOWN_NAME,
   392 	STR_SORT_BY_DROPDOWN_NAME,
   393 	STR_SORT_BY_RELIABILITY,
   393 	STR_SORT_BY_RELIABILITY,
   394 	INVALID_STRING_ID
   394 	INVALID_STRING_ID
   395 },{
   395 }, {
   396 	/* Aircraft */
   396 	/* Aircraft */
   397 	STR_ENGINE_SORT_ENGINE_ID,
   397 	STR_ENGINE_SORT_ENGINE_ID,
   398 	STR_ENGINE_SORT_COST,
   398 	STR_ENGINE_SORT_COST,
   399 	STR_SORT_BY_MAX_SPEED,
   399 	STR_SORT_BY_MAX_SPEED,
   400 	STR_ENGINE_SORT_INTRO_DATE,
   400 	STR_ENGINE_SORT_INTRO_DATE,
   420 	y += 10;
   420 	y += 10;
   421 
   421 
   422 	/* Wagon speed limit, displayed if above zero */
   422 	/* Wagon speed limit, displayed if above zero */
   423 	if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
   423 	if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
   424 		SetDParam(0, rvi->max_speed * 10 / 16);
   424 		SetDParam(0, rvi->max_speed * 10 / 16);
   425 		DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0);
   425 		DrawString(x, y, STR_PURCHASE_INFO_SPEED, 0);
   426 		y += 10;
   426 		y += 10;
   427 	}
   427 	}
   428 	return y;
   428 	return y;
   429 }
   429 }
   430 
   430 
   434 	int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
   434 	int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
   435 
   435 
   436 	/* Purchase Cost - Engine weight */
   436 	/* Purchase Cost - Engine weight */
   437 	SetDParam(0, rvi->base_cost * (_eco->GetPrice(CEconomy::BUILD_RAILVEHICLE) >> 3) >> 5);
   437 	SetDParam(0, rvi->base_cost * (_eco->GetPrice(CEconomy::BUILD_RAILVEHICLE) >> 3) >> 5);
   438 	SetDParam(1, rvi->weight << multihead);
   438 	SetDParam(1, rvi->weight << multihead);
   439 	DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0);
   439 	DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, 0);
   440 	y += 10;
   440 	y += 10;
   441 
   441 
   442 	/* Max speed - Engine power */
   442 	/* Max speed - Engine power */
   443 	SetDParam(0, rvi->max_speed * 10 / 16);
   443 	SetDParam(0, rvi->max_speed * 10 / 16);
   444 	SetDParam(1, rvi->power << multihead);
   444 	SetDParam(1, rvi->power << multihead);
   445 	DrawString(x,y, STR_PURCHASE_INFO_SPEED_POWER, 0);
   445 	DrawString(x, y, STR_PURCHASE_INFO_SPEED_POWER, 0);
   446 	y += 10;
   446 	y += 10;
   447 
   447 
   448 	/* Max tractive effort - not applicable if old acceleration or maglev */
   448 	/* Max tractive effort - not applicable if old acceleration or maglev */
   449 	if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
   449 	if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
   450 		SetDParam(0, ((rvi->weight << multihead) * 10 * rvi->tractive_effort) / 256);
   450 		SetDParam(0, ((rvi->weight << multihead) * 10 * rvi->tractive_effort) / 256);
   461 		case 2: cost_class = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
   461 		case 2: cost_class = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
   462 	}
   462 	}
   463 
   463 
   464 	/* Running cost */
   464 	/* Running cost */
   465 	SetDParam(0, (rvi->running_cost_base * cost_class >> 8) << multihead);
   465 	SetDParam(0, (rvi->running_cost_base * cost_class >> 8) << multihead);
   466 	DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
   466 	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
   467 	y += 10;
   467 	y += 10;
   468 
   468 
   469 	/* Powered wagons power - Powered wagons extra weight */
   469 	/* Powered wagons power - Powered wagons extra weight */
   470 	if (rvi->pow_wag_power != 0) {
   470 	if (rvi->pow_wag_power != 0) {
   471 		SetDParam(0, rvi->pow_wag_power);
   471 		SetDParam(0, rvi->pow_wag_power);
   472 		SetDParam(1, rvi->pow_wag_weight);
   472 		SetDParam(1, rvi->pow_wag_weight);
   473 		DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0);
   473 		DrawString(x, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0);
   474 		y += 10;
   474 		y += 10;
   475 	};
   475 	};
   476 
   476 
   477 	return y;
   477 	return y;
   478 }
   478 }
   507 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
   507 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
   508 {
   508 {
   509 	/* Purchase cost - Max speed */
   509 	/* Purchase cost - Max speed */
   510 	SetDParam(0, svi->base_cost * (_eco->GetPrice(CEconomy::SHIP_BASE) >> 3) >> 5);
   510 	SetDParam(0, svi->base_cost * (_eco->GetPrice(CEconomy::SHIP_BASE) >> 3) >> 5);
   511 	SetDParam(1, svi->max_speed * 10 / 32);
   511 	SetDParam(1, svi->max_speed * 10 / 32);
   512 	DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0);
   512 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
   513 	y += 10;
   513 	y += 10;
   514 
   514 
   515 	/* Cargo type + capacity */
   515 	/* Cargo type + capacity */
   516 	SetDParam(0, svi->cargo_type);
   516 	SetDParam(0, svi->cargo_type);
   517 	SetDParam(1, svi->capacity);
   517 	SetDParam(1, svi->capacity);
   518 	SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
   518 	SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
   519 	DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0);
   519 	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
   520 	y += 10;
   520 	y += 10;
   521 
   521 
   522 	/* Running cost */
   522 	/* Running cost */
   523 	SetDParam(0, svi->running_cost * _eco->GetPrice(CEconomy::SHIP_RUNNING) >> 8);
   523 	SetDParam(0, svi->running_cost * _eco->GetPrice(CEconomy::SHIP_RUNNING) >> 8);
   524 	DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
   524 	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
   525 	y += 10;
   525 	y += 10;
   526 
   526 
   527 	return y;
   527 	return y;
   528 }
   528 }
   529 
   529 
   597 
   597 
   598 				SetDParam(0, rvi->cargo_type);
   598 				SetDParam(0, rvi->cargo_type);
   599 				SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
   599 				SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
   600 				SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
   600 				SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
   601 			}
   601 			}
   602 			DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0);
   602 			DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
   603 			y += 10;
   603 			y += 10;
   604 		}
   604 		}
   605 			break;
   605 			break;
   606 		case VEH_ROAD:
   606 		case VEH_ROAD:
   607 			y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number));
   607 			y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number));
  1038 	bv->sort_criteria         = _last_sort_criteria[type];
  1038 	bv->sort_criteria         = _last_sort_criteria[type];
  1039 	bv->descending_sort_order = _last_sort_order[type];
  1039 	bv->descending_sort_order = _last_sort_order[type];
  1040 
  1040 
  1041 	switch (type) {
  1041 	switch (type) {
  1042 		case VEH_TRAIN:
  1042 		case VEH_TRAIN:
  1043 			WP(w,buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile);
  1043 			WP(w, buildvehicle_d).filter.railtype = (tile == 0) ? RAILTYPE_END : GetRailType(tile);
  1044 			ResizeWindow(w, 0, 16);
  1044 			ResizeWindow(w, 0, 16);
  1045 			break;
  1045 			break;
  1046 		case VEH_ROAD:
  1046 		case VEH_ROAD:
  1047 			ResizeWindow(w, 0, 16);
  1047 			ResizeWindow(w, 0, 16);
  1048 		case VEH_SHIP:
  1048 		case VEH_SHIP: