Changeset - r13436:8c37cd6574ae
[Not reviewed]
master
0 5 0
rubidium - 15 years ago 2009-11-02 16:07:09
rubidium@openttd.org
(svn r17955) -Codechange: s/SPR_PLAYER_ICON/SPR_COMPANY_ICON/
5 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -90,49 +90,49 @@ void SetLocalCompany(CompanyID new_compa
 
	assert(Company::IsValidID(new_company) || new_company == COMPANY_SPECTATOR || new_company == OWNER_NONE);
 

	
 
	/* Delete the chat window, if you were team chatting. */
 
	InvalidateWindowData(WC_SEND_NETWORK_MSG, DESTTYPE_TEAM, _local_company);
 

	
 
	_local_company = new_company;
 

	
 
	/* Delete any construction windows... */
 
	DeleteConstructionWindows();
 

	
 
	/* ... and redraw the whole screen. */
 
	MarkWholeScreenDirty();
 
}
 

	
 
uint16 GetDrawStringCompanyColour(CompanyID company)
 
{
 
	/* Get the colour for DrawString-subroutines which matches the colour
 
	 * of the company */
 
	if (!Company::IsValidID(company)) return _colour_gradient[COLOUR_WHITE][4] | IS_PALETTE_COLOUR;
 
	return (_colour_gradient[_company_colours[company]][4]) | IS_PALETTE_COLOUR;
 
}
 

	
 
void DrawCompanyIcon(CompanyID c, int x, int y)
 
{
 
	DrawSprite(SPR_PLAYER_ICON, COMPANY_SPRITE_COLOUR(c), x, y);
 
	DrawSprite(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(c), x, y);
 
}
 

	
 
/**
 
 * Checks whether a company manager's face is a valid encoding.
 
 * Unused bits are not enforced to be 0.
 
 * @param cmf the fact to check
 
 * @return true if and only if the face is valid
 
 */
 
bool IsValidCompanyManagerFace(CompanyManagerFace cmf)
 
{
 
	if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_GEN_ETHN, GE_WM)) return false;
 

	
 
	GenderEthnicity ge   = (GenderEthnicity)GetCompanyManagerFaceBits(cmf, CMFV_GEN_ETHN, GE_WM);
 
	bool has_moustache   = !HasBit(ge, GENDER_FEMALE) && GetCompanyManagerFaceBits(cmf, CMFV_HAS_MOUSTACHE,   ge) != 0;
 
	bool has_tie_earring = !HasBit(ge, GENDER_FEMALE) || GetCompanyManagerFaceBits(cmf, CMFV_HAS_TIE_EARRING, ge) != 0;
 
	bool has_glasses     = GetCompanyManagerFaceBits(cmf, CMFV_HAS_GLASSES, ge) != 0;
 

	
 
	if (!AreCompanyManagerFaceBitsValid(cmf, CMFV_EYE_COLOUR, ge)) return false;
 
	for (CompanyManagerFaceVariable cmfv = CMFV_CHEEKS; cmfv < CMFV_END; cmfv++) {
 
		switch (cmfv) {
 
			case CMFV_MOUSTACHE:   if (!has_moustache)   continue; break;
 
			case CMFV_LIPS:        // FALL THROUGH
 
			case CMFV_NOSE:        if (has_moustache)    continue; break;
 
			case CMFV_TIE_EARRING: if (!has_tie_earring) continue; break;
src/graph_gui.cpp
Show inline comments
 
@@ -1035,49 +1035,49 @@ struct PerformanceRatingDetailWindow : W
 
		 * (this is because _score_info is not saved to a savegame) */
 
		Company *c;
 
		FOR_ALL_COMPANIES(c) {
 
			UpdateCompanyRatingAndValue(c, false);
 
		}
 

	
 
		this->timeout = DAY_TICKS * 5;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* Draw standard stuff */
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		/* No need to draw when there's nothing to draw */
 
		if (this->company == INVALID_COMPANY) return;
 

	
 
		if (IsInsideMM(widget, PRW_COMPANY_FIRST, PRW_COMPANY_LAST + 1)) {
 
			if (this->IsWidgetDisabled(widget)) return;
 
			CompanyID cid = (CompanyID)(widget - PRW_COMPANY_FIRST);
 
			int offset = (cid == this->company) ? 1 : 0;
 
			Dimension sprite_size = GetSpriteSize(SPR_PLAYER_ICON);
 
			Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
			DrawCompanyIcon(cid, (r.left + r.right - sprite_size.width) / 2 + offset, (r.top + r.bottom - sprite_size.height) / 2 + offset);
 
			return;
 
		}
 

	
 
		if (!IsInsideMM(widget, PRW_SCORE_FIRST, PRW_SCORE_LAST + 1)) return;
 

	
 
		ScoreID score_type = (ScoreID)(widget - PRW_SCORE_FIRST);
 

	
 
			/* The colours used to show how the progress is going */
 
		int colour_done = _colour_gradient[COLOUR_GREEN][4];
 
		int colour_notdone = _colour_gradient[COLOUR_RED][4];
 

	
 
		/* Draw all the score parts */
 
		int val    = _score_part[company][score_type];
 
		int needed = _score_info[score_type].needed;
 
		int score  = _score_info[score_type].score;
 

	
 
		/* SCORE_TOTAL has his own rules ;) */
 
		if (score_type == SCORE_TOTAL) {
 
			for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) score += _score_info[i].score;
 
			needed = SCORE_MAX;
 
		}
 

	
 
		DrawString(7, 107, r.top + 6, STR_PERFORMANCE_DETAIL_VEHICLES + score_type);
 
@@ -1201,49 +1201,49 @@ static NWidgetBase *MakePerformanceDetai
 
	for (int widnum = PRW_SCORE_FIRST; widnum <= PRW_SCORE_LAST; widnum++) {
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		panel->SetMinimalSize(299, 20);
 
		panel->SetFill(false, false);
 
		panel->SetDataTip(0x0, performance_tips[widnum - PRW_SCORE_FIRST]);
 
		vert->Add(panel);
 
	}
 
	*biggest_index = PRW_SCORE_LAST;
 
	return vert;
 
}
 

	
 
/**
 
 * Make a number of rows with button-like graphics, for enabling/disabling each company.
 
 * @param biggest_index Storage for collecting the biggest index used in the returned tree.
 
 * @return Panel with rows of company buttons.
 
 * @postcond \c *biggest_index contains the largest used index in the tree.
 
 */
 
static NWidgetBase *MakeCompanyButtonRows(int *biggest_index)
 
{
 
	static const int MAX_LENGTH = 8; // Maximal number of company buttons in one row.
 
	NWidgetVertical *vert = NULL; // Storage for all rows.
 
	NWidgetHorizontal *hor = NULL; // Storage for buttons in one row.
 
	int hor_length = 0;
 

	
 
	Dimension sprite_size = GetSpriteSize(SPR_PLAYER_ICON);
 
	Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
 
	sprite_size.width  += WD_MATRIX_LEFT + WD_MATRIX_RIGHT;
 
	sprite_size.height += WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1; // 1 for the 'offset' of being pressed
 

	
 
	for (int widnum = PRW_COMPANY_FIRST; widnum <= PRW_COMPANY_LAST; widnum++) {
 
		/* Ensure there is room in 'hor' for another button. */
 
		if (hor_length == MAX_LENGTH) {
 
			if (vert == NULL) vert = new NWidgetVertical();
 
			vert->Add(hor);
 
			hor = NULL;
 
			hor_length = 0;
 
		}
 
		if (hor == NULL) {
 
			hor = new NWidgetHorizontal();
 
			hor_length = 0;
 
		}
 

	
 
		NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
 
		panel->SetMinimalSize(sprite_size.width, sprite_size.height);
 
		panel->SetFill(true, false);
 
		panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
 
		hor->Add(panel);
 
		hor_length++;
 
	}
 
	*biggest_index = PRW_COMPANY_LAST;
src/network/network_gui.cpp
Show inline comments
 
@@ -2017,49 +2017,49 @@ struct NetworkClientListWindow : Window 
 
		int num = 0;
 
		const NetworkClientInfo *ci;
 

	
 
		/* Should be replaced with a loop through all clients */
 
		FOR_ALL_CLIENT_INFOS(ci) {
 
			if (ci->client_playas != COMPANY_INACTIVE_CLIENT) num++;
 
		}
 

	
 
		num *= FONT_HEIGHT_NORMAL;
 

	
 
		int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget<NWidgetBase>(CLW_PANEL)->current_y);
 
		/* If height is changed */
 
		if (diff != 0) {
 
			ResizeWindow(this, 0, diff);
 
			return false;
 
		}
 
		return true;
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
 
	{
 
		if (widget != CLW_PANEL) return;
 

	
 
		this->server_client_width = max(GetStringBoundingBox(STR_NETWORK_SERVER).width, GetStringBoundingBox(STR_NETWORK_CLIENT).width) + WD_FRAMERECT_RIGHT;
 
		this->company_icon_width = GetSpriteSize(SPR_PLAYER_ICON).width + WD_FRAMERECT_LEFT;
 
		this->company_icon_width = GetSpriteSize(SPR_COMPANY_ICON).width + WD_FRAMERECT_LEFT;
 

	
 
		uint width = 200; // Default width
 
		const NetworkClientInfo *ci;
 
		FOR_ALL_CLIENT_INFOS(ci) {
 
			width = max(width, GetStringBoundingBox(ci->client_name).width);
 
		}
 

	
 
		size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + WD_FRAMERECT_RIGHT;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* Check if we need to reset the height */
 
		if (!this->CheckClientListHeight()) return;
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != CLW_PANEL) return;
 

	
 
		int y = r.top + WD_FRAMERECT_TOP;
 
		int left = r.left + WD_FRAMERECT_LEFT;
src/signs_gui.cpp
Show inline comments
 
@@ -142,51 +142,51 @@ struct SignListWindow : Window, SignList
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		if (widget == SLW_LIST) {
 
			uint id_v = (pt.y - this->GetWidget<NWidgetBase>(SLW_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height;
 

	
 
			if (id_v >= this->vscroll.GetCapacity()) return;
 
			id_v += this->vscroll.GetPosition();
 
			if (id_v >= this->vscroll.GetCount()) return;
 

	
 
			const Sign *si = this->signs[id_v];
 
			ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
 
		}
 
	}
 

	
 
	virtual void OnResize()
 
	{
 
		this->vscroll.SetCapacity((this->GetWidget<NWidgetBase>(SLW_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->resize.step_height);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
 
	{
 
		if (widget == SLW_LIST) {
 
			Dimension spr_dim = GetSpriteSize(SPR_PLAYER_ICON);
 
			Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
 
			this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
 
			resize->height = max<uint>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_PLAYER_ICON).height);
 
			resize->height = max<uint>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_COMPANY_ICON).height);
 
			Dimension d = {this->text_offset + MAX_LENGTH_SIGN_NAME_PIXELS + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
 
			*size = maxdim(*size, d);
 
		}
 
	}
 

	
 
	virtual void OnInvalidateData(int data)
 
	{
 
		if (data == 0) { // New or deleted sign.
 
			this->signs.ForceRebuild();
 
			this->BuildSignsList();
 
			this->SetWidgetDirty(SLW_CAPTION);
 
			this->vscroll.SetCount(this->signs.Length());
 
		} else { // Change of sign contents.
 
			this->signs.ForceResort();
 
		}
 

	
 
		this->SortSignsList();
 
	}
 
};
 

	
 
static const NWidgetPart _nested_sign_list_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY, SLW_CLOSEBOX),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, SLW_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
src/table/sprites.h
Show inline comments
 
@@ -233,49 +233,49 @@ enum Sprites {
 
	SPR_TRAMWAY_FRONT_WIRES_SLOPED   = SPR_TRAMWAY_BASE + 68,
 
	SPR_TRAMWAY_TUNNEL_WIRES         = SPR_TRAMWAY_BASE + 80,
 
	SPR_TRAMWAY_BRIDGE               = SPR_TRAMWAY_BASE + 107,
 
	TRAMWAY_SPRITE_COUNT = 113,
 

	
 
	/* One way road sprites */
 
	SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT,
 
	ONEWAY_SPRITE_COUNT = 6,
 

	
 
	/* Flags sprites (in same order as enum NetworkLanguage) */
 
	SPR_FLAGS_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT,
 
	FLAGS_SPRITE_COUNT = 36,
 

	
 
	/* Not really a sprite, but an empty bounding box. Used to construct bounding boxes, that help sorting the sprites, but do not have a sprite associated. */
 
	SPR_EMPTY_BOUNDING_BOX = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT,
 
	EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1,
 

	
 
	/* From where can we start putting NewGRFs? */
 
	SPR_NEWGRFS_BASE = SPR_EMPTY_BOUNDING_BOX + EMPTY_BOUNDING_BOX_SPRITE_COUNT,
 

	
 
	/* Manager face sprites */
 
	SPR_GRADIENT = 874, // background gradient behind manager face
 

	
 
	/* Icon showing company colour. */
 
	SPR_PLAYER_ICON = 747,
 
	SPR_COMPANY_ICON = 747,
 

	
 
	/* is itself no foundation sprite, because tileh 0 has no foundation */
 
	SPR_FOUNDATION_BASE = 989,
 

	
 
	/* Shadow cell */
 
	SPR_SHADOW_CELL = 1004,
 

	
 
	/* Unmovables spritenumbers */
 
	SPR_UNMOVABLE_TRANSMITTER   = 2601,
 
	SPR_UNMOVABLE_LIGHTHOUSE    = 2602,
 
	SPR_TINYHQ_NORTH            = 2603,
 
	SPR_TINYHQ_EAST             = 2604,
 
	SPR_TINYHQ_WEST             = 2605,
 
	SPR_TINYHQ_SOUTH            = 2606,
 
	SPR_SMALLHQ_NORTH           = 2607,
 
	SPR_SMALLHQ_EAST            = 2608,
 
	SPR_SMALLHQ_WEST            = 2609,
 
	SPR_SMALLHQ_SOUTH           = 2610,
 
	SPR_MEDIUMHQ_NORTH          = 2611,
 
	SPR_MEDIUMHQ_NORTH_WALL     = 2612,
 
	SPR_MEDIUMHQ_EAST           = 2613,
 
	SPR_MEDIUMHQ_EAST_WALL      = 2614,
 
	SPR_MEDIUMHQ_WEST           = 2615,
 
	SPR_MEDIUMHQ_WEST_WALL      = 2616, // very tiny piece of wall
0 comments (0 inline, 0 general)