Merge branch 'town-rating-label' into jgrpp
Conflicts: src/lang/english.txt src/town_cmd.cpp
This commit is contained in:
@@ -576,6 +576,8 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
|||||||
AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
|
AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
|
||||||
Game::NewEvent(new ScriptEventCompanyNew(c->index));
|
Game::NewEvent(new ScriptEventCompanyNew(c->index));
|
||||||
|
|
||||||
|
if (!is_ai) UpdateAllTownVirtCoords();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1289,7 +1289,7 @@ STR_CONFIG_SETTING_HOVER_DELAY :Show tooltips:
|
|||||||
STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT :Delay before tooltips are displayed when hovering the mouse over some interface element. Alternatively tooltips are bound to the right mouse button when this value is set to 0.
|
STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT :Delay before tooltips are displayed when hovering the mouse over some interface element. Alternatively tooltips are bound to the right mouse button when this value is set to 0.
|
||||||
STR_CONFIG_SETTING_HOVER_DELAY_VALUE :Hover for {COMMA} millisecond{P 0 "" s}
|
STR_CONFIG_SETTING_HOVER_DELAY_VALUE :Hover for {COMMA} millisecond{P 0 "" s}
|
||||||
STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :Right click
|
STR_CONFIG_SETTING_HOVER_DELAY_DISABLED :Right click
|
||||||
STR_CONFIG_SETTING_POPULATION_IN_LABEL :Show town population in the town name label: {STRING2}
|
STR_CONFIG_SETTING_POPULATION_IN_LABEL :Show extra information in the town name label: {STRING2}
|
||||||
STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Display the population of towns in their label on the map
|
STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Display the population of towns in their label on the map
|
||||||
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS :Thickness of lines in graphs: {STRING2}
|
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS :Thickness of lines in graphs: {STRING2}
|
||||||
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Width of the line in the graphs. A thin line is more precisely readable, a thicker line is easier to see and colours are easier to distinguish
|
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Width of the line in the graphs. A thin line is more precisely readable, a thicker line is easier to see and colours are easier to distinguish
|
||||||
@@ -5328,10 +5328,18 @@ STR_VIEWPORT_SHOW_VEHICLE_ROUTE_STEP_WAYPOINT :{GRAY}WP
|
|||||||
STR_VIEWPORT_SHOW_VEHICLE_ROUTE_STEP_IMPLICIT :{GRAY}IM
|
STR_VIEWPORT_SHOW_VEHICLE_ROUTE_STEP_IMPLICIT :{GRAY}IM
|
||||||
STR_VIEWPORT_SHOW_VEHICLE_ROUTE_STEP_DEPOT :{RED}DE
|
STR_VIEWPORT_SHOW_VEHICLE_ROUTE_STEP_DEPOT :{RED}DE
|
||||||
|
|
||||||
|
STR_VIEWPORT_TOWN_POP_VERY_POOR_RATING :{WHITE}{TOWN} {RED}({COMMA})
|
||||||
|
STR_VIEWPORT_TOWN_POP_MEDIOCRE_RATING :{WHITE}{TOWN} {ORANGE}({COMMA})
|
||||||
|
STR_VIEWPORT_TOWN_POP_GOOD_RATING :{WHITE}{TOWN} {YELLOW}({COMMA})
|
||||||
STR_VIEWPORT_TOWN_POP :{WHITE}{TOWN} ({COMMA})
|
STR_VIEWPORT_TOWN_POP :{WHITE}{TOWN} ({COMMA})
|
||||||
|
STR_VIEWPORT_TOWN_POP_EXCELLENT_RATING :{WHITE}{TOWN} {GREEN}({COMMA})
|
||||||
STR_VIEWPORT_TOWN :{WHITE}{TOWN}
|
STR_VIEWPORT_TOWN :{WHITE}{TOWN}
|
||||||
STR_VIEWPORT_TOWN_TINY_BLACK :{TINY_FONT}{BLACK}{TOWN}
|
STR_VIEWPORT_TOWN_TINY_BLACK :{TINY_FONT}{BLACK}{TOWN}
|
||||||
STR_VIEWPORT_TOWN_TINY_WHITE :{TINY_FONT}{WHITE}{TOWN}
|
STR_VIEWPORT_TOWN_TINY_WHITE :{TINY_FONT}{WHITE}{TOWN}
|
||||||
|
STR_VIEWPORT_TOWN_TINY_VERY_POOR_RATING :{TINY_FONT}{RED}{TOWN}
|
||||||
|
STR_VIEWPORT_TOWN_TINY_MEDIOCRE_RATING :{TINY_FONT}{ORANGE}{TOWN}
|
||||||
|
STR_VIEWPORT_TOWN_TINY_GOOD_RATING :{TINY_FONT}{YELLOW}{TOWN}
|
||||||
|
STR_VIEWPORT_TOWN_TINY_EXCELLENT_RATING :{TINY_FONT}{GREEN}{TOWN}
|
||||||
|
|
||||||
STR_VIEWPORT_SIGN_SMALL_BLACK :{TINY_FONT}{BLACK}{SIGN}
|
STR_VIEWPORT_SIGN_SMALL_BLACK :{TINY_FONT}{BLACK}{SIGN}
|
||||||
STR_VIEWPORT_SIGN_SMALL_WHITE :{TINY_FONT}{WHITE}{SIGN}
|
STR_VIEWPORT_SIGN_SMALL_WHITE :{TINY_FONT}{WHITE}{SIGN}
|
||||||
|
28
src/town.h
28
src/town.h
@@ -18,6 +18,9 @@
|
|||||||
#include "newgrf_storage.h"
|
#include "newgrf_storage.h"
|
||||||
#include "cargotype.h"
|
#include "cargotype.h"
|
||||||
#include "tilematrix_type.hpp"
|
#include "tilematrix_type.hpp"
|
||||||
|
#include "openttd.h"
|
||||||
|
#include "table/strings.h"
|
||||||
|
#include "company_func.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -75,6 +78,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
|||||||
CompanyByte exclusivity; ///< which company has exclusivity
|
CompanyByte exclusivity; ///< which company has exclusivity
|
||||||
uint8 exclusive_counter; ///< months till the exclusivity expires
|
uint8 exclusive_counter; ///< months till the exclusivity expires
|
||||||
int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town
|
int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town
|
||||||
|
StringID town_label; ///< Label dependent on _local_company rating.
|
||||||
|
|
||||||
TransportedCargoStat<uint32> supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo.
|
TransportedCargoStat<uint32> supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo.
|
||||||
TransportedCargoStat<uint16> received[NUM_TE]; ///< Cargo statistics about received cargotypes.
|
TransportedCargoStat<uint16> received[NUM_TE]; ///< Cargo statistics about received cargotypes.
|
||||||
@@ -113,6 +117,30 @@ struct Town : TownPool::PoolItem<&_town_pool> {
|
|||||||
|
|
||||||
void InitializeLayout(TownLayout layout);
|
void InitializeLayout(TownLayout layout);
|
||||||
|
|
||||||
|
void UpdateLabel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the correct town label, based on rating.
|
||||||
|
*/
|
||||||
|
inline StringID Label() const{
|
||||||
|
if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
|
||||||
|
return STR_VIEWPORT_TOWN_POP_VERY_POOR_RATING + this->town_label;
|
||||||
|
} else {
|
||||||
|
return _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the correct town small label, based on rating.
|
||||||
|
*/
|
||||||
|
inline StringID SmallLabel() const{
|
||||||
|
if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) {
|
||||||
|
return STR_VIEWPORT_TOWN_TINY_VERY_POOR_RATING + this->town_label;
|
||||||
|
} else {
|
||||||
|
return STR_VIEWPORT_TOWN_TINY_WHITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the max town noise.
|
* Calculate the max town noise.
|
||||||
* The value is counted using the population divided by the content of the
|
* The value is counted using the population divided by the content of the
|
||||||
|
@@ -162,6 +162,26 @@ void Town::InitializeLayout(TownLayout layout)
|
|||||||
return Town::Get(index);
|
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
|
* Get the cost for removing this house
|
||||||
* @return the cost (inflation corrected etc)
|
* @return the cost (inflation corrected etc)
|
||||||
@@ -457,12 +477,11 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
|
|||||||
*/
|
*/
|
||||||
void Town::UpdateVirtCoord()
|
void Town::UpdateVirtCoord()
|
||||||
{
|
{
|
||||||
|
this->UpdateLabel();
|
||||||
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
||||||
SetDParam(0, this->index);
|
SetDParam(0, this->index);
|
||||||
SetDParam(1, this->cache.population);
|
SetDParam(1, this->cache.population);
|
||||||
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE,
|
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, this->Label(), STR_VIEWPORT_TOWN);
|
||||||
_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN,
|
|
||||||
STR_VIEWPORT_TOWN);
|
|
||||||
|
|
||||||
SetWindowDirty(WC_TOWN_VIEW, this->index);
|
SetWindowDirty(WC_TOWN_VIEW, this->index);
|
||||||
}
|
}
|
||||||
@@ -3161,6 +3180,7 @@ static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
|
|||||||
*/
|
*/
|
||||||
if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) {
|
if (t->ratings[_current_company] > RATING_BRIBE_DOWN_TO) {
|
||||||
t->ratings[_current_company] = RATING_BRIBE_DOWN_TO;
|
t->ratings[_current_company] = RATING_BRIBE_DOWN_TO;
|
||||||
|
t->UpdateVirtCoord();
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -3293,6 +3313,7 @@ static void UpdateTownRating(Town *t)
|
|||||||
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
|
t->ratings[i] = Clamp(t->ratings[i], RATING_MINIMUM, RATING_MAXIMUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t->UpdateVirtCoord();
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3544,6 +3565,7 @@ void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
|
|||||||
} else {
|
} else {
|
||||||
SetBit(t->have_ratings, _current_company);
|
SetBit(t->have_ratings, _current_company);
|
||||||
t->ratings[_current_company] = rating;
|
t->ratings[_current_company] = rating;
|
||||||
|
t->UpdateVirtCoord();
|
||||||
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
SetWindowDirty(WC_TOWN_AUTHORITY, t->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1287,8 +1287,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
|
|||||||
const Town *t;
|
const Town *t;
|
||||||
FOR_ALL_TOWNS(t) {
|
FOR_ALL_TOWNS(t) {
|
||||||
ViewportAddString(dpi, ZOOM_LVL_OUT_16X, &t->cache.sign,
|
ViewportAddString(dpi, ZOOM_LVL_OUT_16X, &t->cache.sign,
|
||||||
_settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN,
|
t->Label(), t->SmallLabel(), STR_VIEWPORT_TOWN_TINY_BLACK,
|
||||||
STR_VIEWPORT_TOWN_TINY_WHITE, STR_VIEWPORT_TOWN_TINY_BLACK,
|
|
||||||
t->index, t->cache.population);
|
t->index, t->cache.population);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user