src/industry_gui.cpp
branchgamebalance
changeset 9912 1ac8aac92385
parent 9911 0b8b245a2391
equal deleted inserted replaced
9911:0b8b245a2391 9912:1ac8aac92385
    37 	case WE_PAINT:
    37 	case WE_PAINT:
    38 		DrawWindowWidgets(w);
    38 		DrawWindowWidgets(w);
    39 		if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
    39 		if (_thd.place_mode == 1 && _thd.window_class == WC_BUILD_INDUSTRY) {
    40 			int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1];
    40 			int ind_type = _build_industry_types[_opt_ptr->landscape][WP(w, def_d).data_1];
    41 
    41 
    42 			SetDParam(0, (_eco->GetPrice(CEconomy::BUILD_INDUSTRY) >> 5) * GetIndustrySpec(ind_type)->cost_multiplier);
    42 			SetDParam(0, (_eco->GetPrice(CEconomy::BUILD_INDUSTRY) >> 8) * GetIndustrySpec(ind_type)->cost_multiplier);
    43 			DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
    43 			DrawStringCentered(85, w->height - 21, STR_482F_COST, 0);
    44 		}
    44 		}
    45 		break;
    45 		break;
    46 
    46 
    47 	case WE_CLICK: {
    47 	case WE_CLICK: {
   324 
   324 
   325 		if (ind->produced_cargo[0] != CT_INVALID) {
   325 		if (ind->produced_cargo[0] != CT_INVALID) {
   326 			DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
   326 			DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0);
   327 
   327 
   328 			SetDParam(0, ind->produced_cargo[0]);
   328 			SetDParam(0, ind->produced_cargo[0]);
   329 			SetDParam(1, i->total_production[0]);
   329 			SetDParam(1, i->last_month_production[0]);
   330 
   330 
   331 			SetDParam(2, i->pct_transported[0] * 100 >> 8);
   331 			SetDParam(2, i->last_month_pct_transported[0] * 100 >> 8);
   332 			DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
   332 			DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
   333 			/* Let's put out those buttons.. */
   333 			/* Let's put out those buttons.. */
   334 			if (IsProductionAlterable(i)) {
   334 			if (IsProductionAlterable(i)) {
   335 				DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0,
   335 				DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0,
   336 						!isProductionMinimum(i, 0), !isProductionMaximum(i, 0));
   336 						!isProductionMinimum(i, 0), !isProductionMaximum(i, 0));
   337 			}
   337 			}
   338 
   338 
   339 			if (ind->produced_cargo[1] != CT_INVALID) {
   339 			if (ind->produced_cargo[1] != CT_INVALID) {
   340 				SetDParam(0, ind->produced_cargo[1]);
   340 				SetDParam(0, ind->produced_cargo[1]);
   341 				SetDParam(1, i->total_production[1]);
   341 				SetDParam(1, i->last_month_production[1]);
   342 				SetDParam(2, i->pct_transported[1] * 100 >> 8);
   342 				SetDParam(2, i->last_month_pct_transported[1] * 100 >> 8);
   343 				DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
   343 				DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
   344 				/* Let's put out those buttons.. */
   344 				/* Let's put out those buttons.. */
   345 				if (IsProductionAlterable(i)) {
   345 				if (IsProductionAlterable(i)) {
   346 					DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0,
   346 					DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0,
   347 						!isProductionMinimum(i, 1), !isProductionMaximum(i, 1));
   347 						!isProductionMinimum(i, 1), !isProductionMaximum(i, 1));
   421 {
   421 {
   422 	const IndustrySpec *ind = GetIndustrySpec(i->type);
   422 	const IndustrySpec *ind = GetIndustrySpec(i->type);
   423 
   423 
   424 	for (byte j = 0; j < lengthof(ind->produced_cargo); j++) {
   424 	for (byte j = 0; j < lengthof(ind->produced_cargo); j++) {
   425 		if (ind->produced_cargo[j] != CT_INVALID) {
   425 		if (ind->produced_cargo[j] != CT_INVALID) {
   426 			i->total_production[j] = 8 * i->production_rate[j];
   426 			i->last_month_production[j] = 8 * i->production_rate[j];
   427 		}
   427 		}
   428 	}
   428 	}
   429 }
   429 }
   430 
   430 
   431 static const Widget _industry_view_widgets[] = {
   431 static const Widget _industry_view_widgets[] = {
   507 			} else {
   507 			} else {
   508 				if (ind_j->produced_cargo[0] == CT_INVALID) {
   508 				if (ind_j->produced_cargo[0] == CT_INVALID) {
   509 					r = 1;
   509 					r = 1;
   510 				} else {
   510 				} else {
   511 					r =
   511 					r =
   512 						(i->total_production[0] + i->total_production[1]) -
   512 						(i->last_month_production[0] + i->last_month_production[1]) -
   513 						(j->total_production[0] + j->total_production[1]);
   513 						(j->last_month_production[0] + j->last_month_production[1]);
   514 				}
   514 				}
   515 			}
   515 			}
   516 			break;
   516 			break;
   517 
   517 
   518 		case 3: /* Sort by transported fraction */
   518 		case 3: /* Sort by transported fraction */
   523 					r = 1;
   523 					r = 1;
   524 				} else {
   524 				} else {
   525 					int pi;
   525 					int pi;
   526 					int pj;
   526 					int pj;
   527 
   527 
   528 					pi = i->pct_transported[0] * 100 >> 8;
   528 					pi = i->last_month_pct_transported[0] * 100 >> 8;
   529 					if (ind_i->produced_cargo[1] != CT_INVALID) {
   529 					if (ind_i->produced_cargo[1] != CT_INVALID) {
   530 						int p = i->pct_transported[1] * 100 >> 8;
   530 						int p = i->last_month_pct_transported[1] * 100 >> 8;
   531 						if (p < pi) pi = p;
   531 						if (p < pi) pi = p;
   532 					}
   532 					}
   533 
   533 
   534 					pj = j->pct_transported[0] * 100 >> 8;
   534 					pj = j->last_month_pct_transported[0] * 100 >> 8;
   535 					if (ind_j->produced_cargo[1] != CT_INVALID) {
   535 					if (ind_j->produced_cargo[1] != CT_INVALID) {
   536 						int p = j->pct_transported[1] * 100 >> 8;
   536 						int p = j->last_month_pct_transported[1] * 100 >> 8;
   537 						if (p < pj) pj = p;
   537 						if (p < pj) pj = p;
   538 					}
   538 					}
   539 
   539 
   540 					r = pi - pj;
   540 					r = pi - pj;
   541 				}
   541 				}
   616 			const IndustrySpec *ind = GetIndustrySpec(i->type);
   616 			const IndustrySpec *ind = GetIndustrySpec(i->type);
   617 
   617 
   618 			SetDParam(0, i->index);
   618 			SetDParam(0, i->index);
   619 			if (ind->produced_cargo[0] != CT_INVALID) {
   619 			if (ind->produced_cargo[0] != CT_INVALID) {
   620 				SetDParam(1, ind->produced_cargo[0]);
   620 				SetDParam(1, ind->produced_cargo[0]);
   621 				SetDParam(2, i->total_production[0]);
   621 				SetDParam(2, i->last_month_production[0]);
   622 
   622 
   623 				if (ind->produced_cargo[1] != CT_INVALID) {
   623 				if (ind->produced_cargo[1] != CT_INVALID) {
   624 					SetDParam(3, ind->produced_cargo[1]);
   624 					SetDParam(3, ind->produced_cargo[1]);
   625 					SetDParam(4, i->total_production[1]);
   625 					SetDParam(4, i->last_month_production[1]);
   626 					SetDParam(5, i->pct_transported[0] * 100 >> 8);
   626 					SetDParam(5, i->last_month_pct_transported[0] * 100 >> 8);
   627 					SetDParam(6, i->pct_transported[1] * 100 >> 8);
   627 					SetDParam(6, i->last_month_pct_transported[1] * 100 >> 8);
   628 					DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0);
   628 					DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_TWO, 0);
   629 				} else {
   629 				} else {
   630 					SetDParam(3, i->pct_transported[0] * 100 >> 8);
   630 					SetDParam(3, i->last_month_pct_transported[0] * 100 >> 8);
   631 					DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0);
   631 					DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM, 0);
   632 				}
   632 				}
   633 			} else {
   633 			} else {
   634 				DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, 0);
   634 				DrawString(4, 28 + n * 10, STR_INDUSTRYDIR_ITEM_NOPROD, 0);
   635 			}
   635 			}