Changeset - r13283:7b4c57e2237c
[Not reviewed]
master
0 3 0
frosch - 15 years ago 2009-10-18 15:36:30
frosch@openttd.org
(svn r17802) -Feature(ette) [FS#1862]: [NewGRF] Textstack support for CB 37.
3 files changed with 60 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/industry_gui.cpp
Show inline comments
 
@@ -53,21 +53,49 @@ enum CargoSuffixType {
 
 * - 03 - first produced cargo type
 
 * - 04 - second produced cargo type
 
 * @param cst the cargo suffix type (for which window is it requested). @see CargoSuffixType
 
 * @param ind the industry (NULL if in fund window)
 
 * @param ind_type the industry type
 
 * @param indspec the industry spec
 
 * @return the string to display
 
 * @param suffix is filled with the string to display
 
 * @param suffix_last lastof(suffix)
 
 */
 
static StringID GetCargoSuffix(uint cargo, CargoSuffixType cst, Industry *ind, IndustryType ind_type, const IndustrySpec *indspec)
 
static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, char *suffix, const char *suffix_last)
 
{
 
	suffix[0] = '\0';
 
	if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) {
 
		uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, ind, ind_type, (cst != CST_FUND) ? ind->xy : INVALID_TILE);
 
		if (GB(callback, 0, 8) != 0xFF) return GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback);
 
		uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->xy : INVALID_TILE);
 
		if (GB(callback, 0, 8) != 0xFF) {
 
			PrepareTextRefStackUsage(6);
 
			GetString(suffix, GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback), suffix_last);
 
			StopTextRefStackUsage();
 
		}
 
	}
 
	return STR_EMPTY;
 
}
 

	
 
/**
 
 * Gets all strings to display after the cargos of industries (using callback 37)
 
 * @param cb_offset The offset for the cargo used in cb37, 0 for accepted cargos, 3 for produced cargos
 
 * @param cst the cargo suffix type (for which window is it requested). @see CargoSuffixType
 
 * @param ind the industry (NULL if in fund window)
 
 * @param ind_type the industry type
 
 * @param indspec the industry spec
 
 * @param cargos array with cargotypes. for CT_INVALID no suffix will be determined
 
 * @param suffixes is filled with the suffixes
 
 */
 
template <typename TC, typename TS>
 
static inline void GetAllCargoSuffixes(uint cb_offset, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargos, TS &suffixes)
 
{
 
	assert_compile(lengthof(cargos) <= lengthof(suffixes));
 
	for (uint j = 0; j < lengthof(cargos); j++) {
 
		if (cargos[j] != CT_INVALID) {
 
			GetCargoSuffix(cb_offset + j, cst, ind, ind_type, indspec, suffixes[j], lastof(suffixes[j]));
 
		} else {
 
			suffixes[j][0] = '\0';
 
		}
 
	}
 
}
 

	
 
/** Names of the widgets of the dynamic place industries gui */
 
enum DynamicPlaceIndustriesWidgets {
 
	DPIW_CLOSEBOX = 0,
 
	DPIW_CAPTION,
 
@@ -257,35 +285,38 @@ public:
 
			SetDParam(0, indsp->GetConstructionCost());
 
			DrawString(x_str, right, y_str, STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST);
 
			y_str += 11;
 
		}
 

	
 
		/* Draw the accepted cargos, if any. Otherwhise, will print "Nothing" */
 
		char cargo_suffix[3][512];
 
		GetAllCargoSuffixes(0, CST_FUND, NULL, this->selected_type, indsp, indsp->accepts_cargo, cargo_suffix);
 
		StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO;
 
		byte p = 0;
 
		SetDParam(0, STR_JUST_NOTHING);
 
		SetDParam(1, STR_EMPTY);
 
		SetDParamStr(1, "");
 
		for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
 
			if (indsp->accepts_cargo[j] == CT_INVALID) continue;
 
			if (p > 0) str++;
 
			SetDParam(p++, CargoSpec::Get(indsp->accepts_cargo[j])->name);
 
			SetDParam(p++, GetCargoSuffix(j, CST_FUND, NULL, this->selected_type, indsp));
 
			SetDParamStr(p++, cargo_suffix[j]);
 
		}
 
		DrawString(x_str, right, y_str, str);
 
		y_str += 11;
 

	
 
		/* Draw the produced cargos, if any. Otherwhise, will print "Nothing" */
 
		GetAllCargoSuffixes(3, CST_FUND, NULL, this->selected_type, indsp, indsp->produced_cargo, cargo_suffix);
 
		str = STR_INDUSTRY_VIEW_PRODUCES_CARGO;
 
		p = 0;
 
		SetDParam(0, STR_JUST_NOTHING);
 
		SetDParam(1, STR_EMPTY);
 
		SetDParamStr(1, "");
 
		for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
 
			if (indsp->produced_cargo[j] == CT_INVALID) continue;
 
			if (p > 0) str++;
 
			SetDParam(p++, CargoSpec::Get(indsp->produced_cargo[j])->name);
 
			SetDParam(p++, GetCargoSuffix(j + 3, CST_FUND, NULL, this->selected_type, indsp));
 
			SetDParamStr(p++, cargo_suffix[j]);
 
		}
 
		DrawString(x_str, right, y_str, str);
 
		y_str += 11;
 

	
 
		/* Get the additional purchase info text, if it has not already been */
 
		if (this->text[this->selected_index] == STR_NULL) {   // Have i been called already?
 
@@ -523,44 +554,48 @@ public:
 
	{
 
		Industry *i = Industry::Get(this->window_number);
 
		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
		int y = top + WD_FRAMERECT_TOP;
 
		bool first = true;
 
		bool has_accept = false;
 
		char cargo_suffix[3][512];
 

	
 
		if (HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) {
 
			GetAllCargoSuffixes(0, CST_VIEW, i, i->type, ind, i->accepts_cargo, cargo_suffix);
 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
				if (i->accepts_cargo[j] == CT_INVALID) continue;
 
				has_accept = true;
 
				if (first) {
 
					DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING);
 
					y += FONT_HEIGHT_NORMAL;
 
					first = false;
 
				}
 
				SetDParam(0, i->accepts_cargo[j]);
 
				SetDParam(1, i->incoming_cargo_waiting[j]);
 
				SetDParam(2, GetCargoSuffix(j, CST_VIEW, i, i->type, ind));
 
				SetDParamStr(2, cargo_suffix[j]);
 
				DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO);
 
				y += FONT_HEIGHT_NORMAL;
 
			}
 
		} else {
 
			GetAllCargoSuffixes(0, CST_VIEW, i, i->type, ind, i->accepts_cargo, cargo_suffix);
 
			StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO;
 
			byte p = 0;
 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
				if (i->accepts_cargo[j] == CT_INVALID) continue;
 
				has_accept = true;
 
				if (p > 0) str++;
 
				SetDParam(p++, CargoSpec::Get(i->accepts_cargo[j])->name);
 
				SetDParam(p++, GetCargoSuffix(j, CST_VIEW, i, i->type, ind));
 
				SetDParamStr(p++, cargo_suffix[j]);
 
			}
 
			if (has_accept) {
 
				DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, str);
 
				y += FONT_HEIGHT_NORMAL;
 
			}
 
		}
 

	
 
		GetAllCargoSuffixes(3, CST_VIEW, i, i->type, ind, i->produced_cargo, cargo_suffix);
 
		first = true;
 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
			if (i->produced_cargo[j] == CT_INVALID) continue;
 
			if (first) {
 
				if (has_accept) y += WD_PAR_VSEP_WIDE;
 
				DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
 
@@ -568,14 +603,13 @@ public:
 
				this->production_offset_y = y;
 
				first = false;
 
			}
 

	
 
			SetDParam(0, i->produced_cargo[j]);
 
			SetDParam(1, i->last_month_production[j]);
 
			SetDParam(2, GetCargoSuffix(j + 3, CST_VIEW, i, i->type, ind));
 

	
 
			SetDParamStr(2, cargo_suffix[j]);
 
			SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
 
			uint x = left + WD_FRAMETEXT_LEFT + (IsProductionAlterable(i) ? 30 : 0);
 
			DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_TRANSPORTED);
 
			/* Let's put out those buttons.. */
 
			if (IsProductionAlterable(i)) {
 
				DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == j + 1) ? this->clicked_button : 0,
 
@@ -906,18 +940,21 @@ protected:
 
		const IndustrySpec *indsp = GetIndustrySpec(i->type);
 
		byte p = 0;
 

	
 
		/* Industry name */
 
		SetDParam(p++, i->index);
 

	
 
		char cargo_suffix[lengthof(i->produced_cargo)][512];
 
		GetAllCargoSuffixes(3, CST_DIR, i, i->type, indsp, i->produced_cargo, cargo_suffix);
 

	
 
		/* Industry productions */
 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
			if (i->produced_cargo[j] == CT_INVALID) continue;
 
			SetDParam(p++, i->produced_cargo[j]);
 
			SetDParam(p++, i->last_month_production[j]);
 
			SetDParam(p++, GetCargoSuffix(j + 3, CST_DIR, const_cast<Industry *>(i), i->type, indsp));
 
			SetDParamStr(p++, cargo_suffix[j]);
 
		}
 

	
 
		/* Transported productions */
 
		for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
			if (i->produced_cargo[j] == CT_INVALID) continue;
 
			SetDParam(p++, ToPercent8(i->last_month_pct_transported[j]));
src/lang/english.txt
Show inline comments
 
@@ -2553,34 +2553,34 @@ STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_
 

	
 
STR_BUY_COMPANY_MESSAGE                                         :{WHITE}We are looking for a transport company to take-over our company.{}{}Do you want to purchase {COMPANY} for {CURRENCY}?
 

	
 
# Industry directory
 
STR_INDUSTRY_DIRECTORY_CAPTION                                  :{WHITE}Industries
 
STR_INDUSTRY_DIRECTORY_NONE                                     :{ORANGE}- None -
 
STR_INDUSTRY_DIRECTORY_ITEM                                     :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}{STRING}){YELLOW} ({COMMA}% transported)
 
STR_INDUSTRY_DIRECTORY_ITEM_TWO                                 :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}{STRING}/{CARGO}{STRING}){YELLOW} ({COMMA}%/{COMMA}% transported)
 
STR_INDUSTRY_DIRECTORY_ITEM                                     :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}{RAW_STRING}){YELLOW} ({COMMA}% transported)
 
STR_INDUSTRY_DIRECTORY_ITEM_TWO                                 :{ORANGE}{INDUSTRY}{BLACK} ({CARGO}{RAW_STRING}/{CARGO}{RAW_STRING}){YELLOW} ({COMMA}%/{COMMA}% transported)
 
STR_INDUSTRY_DIRECTORY_ITEM_NOPROD                              :{ORANGE}{INDUSTRY}
 
STR_INDUSTRY_DIRECTORY_LIST_CAPTION                             :{BLACK}Industry names - click on name to centre view on industry. Ctrl+Click opens a new viewport on industry location
 

	
 
# Industry view
 
STR_INDUSTRY_VIEW_CAPTION                                       :{WHITE}{INDUSTRY}
 
STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE                   :{BLACK}Production last month:
 
STR_INDUSTRY_VIEW_TRANSPORTED                                   :{YELLOW}{CARGO}{STRING}{BLACK} ({COMMA}% transported)
 
STR_INDUSTRY_VIEW_TRANSPORTED                                   :{YELLOW}{CARGO}{RAW_STRING}{BLACK} ({COMMA}% transported)
 
STR_INDUSTRY_VIEW_LOCATION_TOOLTIP                              :{BLACK}Centre the main view on industry location. Ctrl+Click opens a new viewport on industry location
 

	
 
############ range for requires starts
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO                                :{BLACK}Requires: {YELLOW}{STRING}{STRING}
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO                          :{BLACK}Requires: {YELLOW}{STRING}{STRING}, {STRING}{STRING}
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO_CARGO                    :{BLACK}Requires: {YELLOW}{STRING}{STRING}, {STRING}{STRING}, {STRING}{STRING}
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO                                :{BLACK}Requires: {YELLOW}{STRING}{RAW_STRING}
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO                          :{BLACK}Requires: {YELLOW}{STRING}{RAW_STRING}, {STRING}{RAW_STRING}
 
STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO_CARGO                    :{BLACK}Requires: {YELLOW}{STRING}{RAW_STRING}, {STRING}{RAW_STRING}, {STRING}{RAW_STRING}
 
############ range for requires ends
 

	
 
############ range for produces starts
 
STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING                        :{BLACK}Cargo waiting to be processed:
 
STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO                       :{YELLOW}{CARGO}{STRING}{BLACK}
 
STR_INDUSTRY_VIEW_PRODUCES_CARGO                                :{BLACK}Produces: {YELLOW}{STRING}{STRING}
 
STR_INDUSTRY_VIEW_PRODUCES_CARGO_CARGO                          :{BLACK}Produces: {YELLOW}{STRING}{STRING}, {STRING}{STRING}
 
STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO                       :{YELLOW}{CARGO}{RAW_STRING}{BLACK}
 
STR_INDUSTRY_VIEW_PRODUCES_CARGO                                :{BLACK}Produces: {YELLOW}{STRING}{RAW_STRING}
 
STR_INDUSTRY_VIEW_PRODUCES_CARGO_CARGO                          :{BLACK}Produces: {YELLOW}{STRING}{RAW_STRING}, {STRING}{RAW_STRING}
 
############ range for produces ends
 

	
 
STR_CONFIG_GAME_PRODUCTION                                      :{WHITE}Change production (multiple of 8, up to 2040)
 

	
 
# Vehicle lists
 
STR_VEHICLE_LIST_TRAIN_CAPTION                                  :{WHITE}{STRING1} - {COMMA} Train{P "" s}
src/newgrf_text.cpp
Show inline comments
 
@@ -68,13 +68,12 @@ StringID TTDPStringIDToOTTDStringIDMappi
 
	TEXTID_TO_STRINGID(0x200F, 0x201F, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1);
 
	TEXTID_TO_STRINGID(0x2036, 0x2041, STR_TOWN_BUILDING_NAME_COTTAGES_1);
 
	TEXTID_TO_STRINGID(0x2059, 0x205C, STR_TOWN_BUILDING_NAME_IGLOO_1);
 

	
 
	/* Same thing for industries */
 
	TEXTID_TO_STRINGID(0x4802, 0x4826, STR_INDUSTRY_NAME_COAL_MINE);
 
	TEXTID_TO_STRINGID(0x4827, 0x4829, STR_INDUSTRY_VIEW_REQUIRES_CARGO);
 
	TEXTID_TO_STRINGID(0x482D, 0x482E, STR_NEWS_INDUSTRY_CONSTRUCTION);
 
	TEXTID_TO_STRINGID(0x4832, 0x4834, STR_NEWS_INDUSTRY_CLOSURE_GENERAL);
 
	TEXTID_TO_STRINGID(0x4835, 0x4838, STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL);
 
	TEXTID_TO_STRINGID(0x4839, 0x483A, STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_GENERAL);
 

	
 
	switch (str) {
0 comments (0 inline, 0 general)