Import town rating label patch

http://www.tt-forums.net/viewtopic.php?p=1118282#p1118282
This commit is contained in:
patch-import
2015-08-06 00:19:35 +01:00
committed by Jonathan G Rennison
parent 67f3c2a764
commit 33d395ad59
5 changed files with 65 additions and 5 deletions

View File

@@ -160,6 +160,26 @@ void Town::InitializeLayout(TownLayout layout)
return Town::Get(index);
}
/**
* Updates the town label of the town after changes in rating. The colour scheme is:
* Red: Appalling and Very poor ratings.
* Orange: Poor and mediocre ratings.
* Yellow: Good rating.
* White: Very good rating (standard).
* Green: Excellent and outstanding ratings.
*/
void Town::UpdateLabel()
{
if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
int r = this->ratings[_local_company];
(this->town_label = 0, r <= RATING_VERYPOOR) || // Appalling and Very Poor
(this->town_label++, r <= RATING_MEDIOCRE) || // Poor and Mediocre
(this->town_label++, r <= RATING_GOOD) || // Good
(this->town_label++, r <= RATING_VERYGOOD) || // Very Good
(this->town_label++, true); // Excellent and Outstanding
}
}
/**
* Get the cost for removing this house
* @return the cost (inflation corrected etc)
@@ -371,11 +391,11 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
*/
void Town::UpdateVirtCoord()
{
this->UpdateLabel();
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
SetDParam(0, this->index);
SetDParam(1, this->cache.population);
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE,
_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN);
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, this->Label());
SetWindowDirty(WC_TOWN_VIEW, this->index);
}
@@ -2911,6 +2931,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
*/
if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) {
t->ratings[_current_company] = RATING_BRIBE_DOWN_TO;
t->UpdateVirtCoord();
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
}
} else {
@@ -3043,6 +3064,7 @@ static void UpdateTownRating(Town *t)
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
}
t->UpdateVirtCoord();
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
}
@@ -3296,6 +3318,7 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
} else {
SetBit(t->have_ratings, _current_company);
t->ratings[_current_company] = rating;
t->UpdateVirtCoord();
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
}
}