Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
367
src/town_gui.cpp
367
src/town_gui.cpp
@@ -57,7 +57,7 @@ struct CargoX {
|
||||
int from;
|
||||
};
|
||||
void ShowCBTownWindow(uint town);
|
||||
static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bool show_house_states_info=false);
|
||||
static void DrawExtraTownInfo (Rect &r, Town *town, uint line, bool show_house_states_info=false);
|
||||
|
||||
bool TownExecuteAction(const Town *town, uint action){
|
||||
if(!(action == HK_STATUE && HasBit(town->statues, _current_company))){ //don't built statue when there is one
|
||||
@@ -77,16 +77,13 @@ static const NWidgetPart _nested_town_authority_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TA_CAPTION), SetDataTip(STR_LOCAL_AUTHORITY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TA_ZONE_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_LOCAL_AUTHORITY_ZONE, STR_LOCAL_AUTHORITY_ZONE_TOOLTIP),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TA_ZONE_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical() + 2), SetDataTip(STR_LOCAL_AUTHORITY_ZONE, STR_LOCAL_AUTHORITY_ZONE_TOOLTIP),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_RATING_INFO), SetMinimalSize(317, 92), SetResize(1, 1), EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_COMMAND_LIST), SetMinimalSize(305, 52), SetResize(1, 0), SetDataTip(0x0, STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP), SetScrollbar(WID_TA_SCROLLBAR), EndContainer(),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_TA_SCROLLBAR),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_COMMAND_LIST), SetMinimalSize(317, 52), SetResize(1, 0), SetDataTip(0x0, STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_ACTION_INFO), SetMinimalSize(317, 52), SetResize(1, 0), EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TA_EXECUTE), SetMinimalSize(317, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_LOCAL_AUTHORITY_DO_IT_BUTTON, STR_LOCAL_AUTHORITY_DO_IT_TOOLTIP),
|
||||
@@ -99,22 +96,25 @@ struct TownAuthorityWindow : Window {
|
||||
private:
|
||||
Town *town; ///< Town being displayed.
|
||||
int sel_index; ///< Currently selected town action, \c 0 to \c TACT_COUNT-1, \c -1 means no action selected.
|
||||
Scrollbar *vscroll;
|
||||
uint displayed_actions_on_previous_painting; ///< Actions that were available on the previous call to OnPaint()
|
||||
TownActions enabled_actions; ///< Actions that are enabled in settings.
|
||||
TownActions available_actions; ///< Actions that are available to execute for the current company.
|
||||
|
||||
Dimension icon_size; ///< Dimensions of company icon
|
||||
Dimension exclusive_size; ///< Dimensions of exlusive icon
|
||||
|
||||
/**
|
||||
* Get the position of the Nth set bit.
|
||||
*
|
||||
* If there is no Nth bit set return -1
|
||||
*
|
||||
* @param bits The value to search in
|
||||
* @param n The Nth set bit from which we want to know the position
|
||||
* @return The position of the Nth set bit
|
||||
* @return The position of the Nth set bit, or -1 if no Nth bit set.
|
||||
*/
|
||||
static int GetNthSetBit(uint32 bits, int n)
|
||||
int GetNthSetBit(int n)
|
||||
{
|
||||
if (n >= 0) {
|
||||
for (uint i : SetBitIterator(bits)) {
|
||||
for (uint i : SetBitIterator(this->enabled_actions)) {
|
||||
n--;
|
||||
if (n < 0) return i;
|
||||
}
|
||||
@@ -122,94 +122,127 @@ private:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all town authority actions enabled in settings.
|
||||
*
|
||||
* @return Bitmask of actions enabled in the settings.
|
||||
*/
|
||||
static TownActions GetEnabledActions()
|
||||
{
|
||||
TownActions enabled = TACT_ALL;
|
||||
|
||||
if (!_settings_game.economy.fund_roads) CLRBITS(enabled, TACT_ROAD_REBUILD);
|
||||
if (!_settings_game.economy.fund_buildings) CLRBITS(enabled, TACT_FUND_BUILDINGS);
|
||||
if (!_settings_game.economy.exclusive_rights) CLRBITS(enabled, TACT_BUY_RIGHTS);
|
||||
if (!_settings_game.economy.bribe) CLRBITS(enabled, TACT_BRIBE);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public:
|
||||
TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0)
|
||||
TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0), available_actions(TACT_NONE)
|
||||
{
|
||||
this->town = Town::Get(window_number);
|
||||
this->enabled_actions = GetEnabledActions();
|
||||
this->InitNested(window_number);
|
||||
this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR);
|
||||
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
|
||||
}
|
||||
|
||||
void OnPaint() override
|
||||
{
|
||||
int numact;
|
||||
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
|
||||
if (buttons != displayed_actions_on_previous_painting) this->SetDirty();
|
||||
displayed_actions_on_previous_painting = buttons;
|
||||
|
||||
this->vscroll->SetCount(numact + 1);
|
||||
|
||||
if (this->sel_index != -1 && !HasBit(buttons, this->sel_index)) {
|
||||
this->sel_index = -1;
|
||||
}
|
||||
this->available_actions = GetMaskOfTownActions(_local_company, this->town);
|
||||
if (this->available_actions != displayed_actions_on_previous_painting) this->SetDirty();
|
||||
displayed_actions_on_previous_painting = this->available_actions;
|
||||
|
||||
this->SetWidgetLoweredState(WID_TA_ZONE_BUTTON, this->town->show_zone);
|
||||
this->SetWidgetDisabledState(WID_TA_EXECUTE, this->sel_index == -1);
|
||||
this->SetWidgetDisabledState(WID_TA_EXECUTE, (this->sel_index == -1) || !HasBit(this->available_actions, this->sel_index));
|
||||
|
||||
this->DrawWidgets();
|
||||
if (!this->IsShaded()) this->DrawRatings();
|
||||
if (!this->IsShaded())
|
||||
{
|
||||
this->DrawRatings();
|
||||
this->DrawActions();
|
||||
}
|
||||
}
|
||||
|
||||
/** Draw the contents of the ratings panel. May request a resize of the window if the contents does not fit. */
|
||||
void DrawRatings()
|
||||
{
|
||||
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO);
|
||||
uint left = nwid->pos_x + WD_FRAMERECT_LEFT;
|
||||
uint right = nwid->pos_x + nwid->current_x - 1 - WD_FRAMERECT_RIGHT;
|
||||
Rect r = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
uint y = nwid->pos_y + WD_FRAMERECT_TOP;
|
||||
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
int icon_y_offset = (this->resize.step_height - this->icon_size.height) / 2;
|
||||
int exclusive_y_offset = (this->resize.step_height - this->exclusive_size.height) / 2;
|
||||
|
||||
DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
Dimension icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
int icon_width = icon_size.width;
|
||||
int icon_y_offset = (FONT_HEIGHT_NORMAL - icon_size.height) / 2;
|
||||
|
||||
Dimension exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
|
||||
int exclusive_width = exclusive_size.width;
|
||||
int exclusive_y_offset = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
|
||||
DrawString(r.left, r.right, r.top + text_y_offset, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
|
||||
r.top += this->resize.step_height;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
uint text_left = left + (rtl ? 0 : icon_width + exclusive_width + 4);
|
||||
uint text_right = right - (rtl ? icon_width + exclusive_width + 4 : 0);
|
||||
uint icon_left = rtl ? right - icon_width : left;
|
||||
uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
|
||||
Rect icon = r.WithWidth(this->icon_size.width, rtl);
|
||||
Rect exclusive = r.Indent(this->icon_size.width + WidgetDimensions::scaled.hsep_normal, rtl).WithWidth(this->exclusive_size.width, rtl);
|
||||
Rect text = r.Indent(this->icon_size.width + WidgetDimensions::scaled.hsep_normal + this->exclusive_size.width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
|
||||
/* Draw list of companies */
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
|
||||
DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
|
||||
DrawCompanyIcon(c->index, icon.left, text.top + icon_y_offset);
|
||||
|
||||
SetDParam(0, c->index);
|
||||
SetDParam(1, c->index);
|
||||
|
||||
int r = this->town->ratings[c->index];
|
||||
int rating = this->town->ratings[c->index];
|
||||
StringID str = STR_CARGO_RATING_APPALLING;
|
||||
if (r > RATING_APPALLING) str++;
|
||||
if (r > RATING_VERYPOOR) str++;
|
||||
if (r > RATING_POOR) str++;
|
||||
if (r > RATING_MEDIOCRE) str++;
|
||||
if (r > RATING_GOOD) str++;
|
||||
if (r > RATING_VERYGOOD) str++;
|
||||
if (r > RATING_EXCELLENT) str++;
|
||||
if (rating > RATING_APPALLING) str++;
|
||||
if (rating > RATING_VERYPOOR) str++;
|
||||
if (rating > RATING_POOR) str++;
|
||||
if (rating > RATING_MEDIOCRE) str++;
|
||||
if (rating > RATING_GOOD) str++;
|
||||
if (rating > RATING_VERYGOOD) str++;
|
||||
if (rating > RATING_EXCELLENT) str++;
|
||||
|
||||
SetDParam(2, str);
|
||||
SetDParam(3, this->town->ratings[c->index]);
|
||||
if (this->town->exclusivity == c->index) {
|
||||
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, y + exclusive_y_offset);
|
||||
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive.left, text.top + exclusive_y_offset);
|
||||
}
|
||||
|
||||
DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING_NUM);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
DrawString(text.left, text.right, text.top + text_y_offset, STR_LOCAL_AUTHORITY_COMPANY_RATING_NUM);
|
||||
text.top += this->resize.step_height;
|
||||
}
|
||||
}
|
||||
|
||||
y = y + WD_FRAMERECT_BOTTOM - nwid->pos_y; // Compute needed size of the widget.
|
||||
if (y > nwid->current_y) {
|
||||
text.bottom = text.top - 1;
|
||||
if (text.bottom > r.bottom) {
|
||||
/* If the company list is too big to fit, mark ourself dirty and draw again. */
|
||||
ResizeWindow(this, 0, y - nwid->current_y, false);
|
||||
ResizeWindow(this, 0, text.bottom - r.bottom, false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Draws the contents of the actions panel. May re-initialise window to resize panel, if the list does not fit. */
|
||||
void DrawActions()
|
||||
{
|
||||
Rect r = this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
DrawString(r, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
|
||||
r.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
/* Draw list of actions */
|
||||
for (int i = 0; i < TACT_COUNT; i++) {
|
||||
/* Don't show actions if disabled in settings. */
|
||||
if (!HasBit(this->enabled_actions, i)) continue;
|
||||
|
||||
/* Set colour of action based on ability to execute and if selected. */
|
||||
TextColour action_colour = TC_GREY | TC_NO_SHADE;
|
||||
if (HasBit(this->available_actions, i)) action_colour = TC_ORANGE;
|
||||
if (this->sel_index == i) action_colour = TC_WHITE;
|
||||
|
||||
DrawString(r, STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, action_colour);
|
||||
r.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,33 +256,15 @@ public:
|
||||
switch (widget) {
|
||||
case WID_TA_ACTION_INFO:
|
||||
if (this->sel_index != -1) {
|
||||
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[this->sel_index] >> 8);
|
||||
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
|
||||
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
|
||||
Money action_cost = _price[PR_TOWN_ACTION] * _town_action_costs[this->sel_index] >> 8;
|
||||
bool affordable = action_cost < Company::GetIfValid(_local_company)->money;
|
||||
|
||||
SetDParam(0, action_cost);
|
||||
DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect),
|
||||
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index,
|
||||
affordable ? TC_YELLOW : TC_RED);
|
||||
}
|
||||
break;
|
||||
case WID_TA_COMMAND_LIST: {
|
||||
int numact;
|
||||
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
|
||||
int y = r.top + WD_FRAMERECT_TOP;
|
||||
int pos = this->vscroll->GetPosition();
|
||||
|
||||
if (--pos < 0) {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
for (int i = 0; buttons; i++, buttons >>= 1) {
|
||||
if (pos <= -5) break; ///< Draw only the 5 fitting lines
|
||||
|
||||
if ((buttons & 1) && --pos < 0) {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y,
|
||||
STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,31 +273,29 @@ public:
|
||||
switch (widget) {
|
||||
case WID_TA_ACTION_INFO: {
|
||||
assert(size->width > padding.width && size->height > padding.height);
|
||||
size->width -= WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
Dimension d = {0, 0};
|
||||
for (int i = 0; i < TACT_COUNT; i++) {
|
||||
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8);
|
||||
d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size));
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_TA_COMMAND_LIST:
|
||||
size->height = WD_FRAMERECT_TOP + 5 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
||||
size->height = (TACT_COUNT + 1) * FONT_HEIGHT_NORMAL + padding.height;
|
||||
size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
|
||||
for (uint i = 0; i < TACT_COUNT; i++ ) {
|
||||
size->width = std::max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width);
|
||||
}
|
||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->width += padding.width;
|
||||
break;
|
||||
|
||||
case WID_TA_RATING_INFO:
|
||||
resize->height = FONT_HEIGHT_NORMAL;
|
||||
size->height = WD_FRAMERECT_TOP + 9 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
||||
resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)FONT_HEIGHT_NORMAL});
|
||||
size->height = 9 * resize->height + padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -303,14 +316,14 @@ public:
|
||||
}
|
||||
|
||||
case WID_TA_COMMAND_LIST: {
|
||||
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL);
|
||||
if (!IsInsideMM(y, 0, 5)) return;
|
||||
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL) - 1;
|
||||
|
||||
y = GetNthSetBit(GetMaskOfTownActions(nullptr, _local_company, this->town), y + this->vscroll->GetPosition() - 1);
|
||||
y = GetNthSetBit(y);
|
||||
if (y >= 0) {
|
||||
this->sel_index = y;
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
/* When double-clicking, continue */
|
||||
if (click_count == 1 || y < 0) break;
|
||||
FALLTHROUGH;
|
||||
@@ -327,13 +340,23 @@ public:
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
this->enabled_actions = this->GetEnabledActions();
|
||||
if (!HasBit(this->enabled_actions, this->sel_index)) {
|
||||
this->sel_index = -1;
|
||||
}
|
||||
}
|
||||
|
||||
virtual EventState OnHotkey(int hotkey)
|
||||
{
|
||||
TownExecuteAction(this->town, hotkey);
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
static HotkeyList hotkeys;
|
||||
};
|
||||
|
||||
static Hotkey town_hotkeys[] = {
|
||||
@@ -424,23 +447,26 @@ public:
|
||||
{
|
||||
if (widget != WID_TV_INFO) return;
|
||||
|
||||
uint y = r.top + WD_FRAMERECT_TOP;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
SetDParam(0, this->town->cache.population);
|
||||
SetDParam(1, this->town->cache.num_houses);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_VIEW_POPULATION_HOUSES);
|
||||
DrawString(tr, STR_TOWN_VIEW_POPULATION_HOUSES);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
SetDParam(0, 1 << CT_PASSENGERS);
|
||||
SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act);
|
||||
SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
||||
DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
SetDParam(0, 1 << CT_MAIL);
|
||||
SetDParam(1, this->town->supplied[CT_MAIL].old_act);
|
||||
SetDParam(2, this->town->supplied[CT_MAIL].old_max);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
||||
DrawString(tr, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
DrawExtraTownInfo(r, y, this->town, FONT_HEIGHT_NORMAL, true); //CB
|
||||
DrawExtraTownInfo(tr, this->town, FONT_HEIGHT_NORMAL, true); //CB
|
||||
|
||||
bool first = true;
|
||||
for (int i = TE_BEGIN; i < TE_END; i++) {
|
||||
@@ -449,13 +475,12 @@ public:
|
||||
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
|
||||
|
||||
if (first) {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
|
||||
DrawString(tr, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
first = false;
|
||||
}
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
|
||||
uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
|
||||
|
||||
const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i);
|
||||
assert(cargo != nullptr);
|
||||
@@ -485,26 +510,30 @@ public:
|
||||
SetDParam(2, cargo->Index());
|
||||
SetDParam(3, this->town->goal[i]);
|
||||
}
|
||||
DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, string);
|
||||
DrawString(tr.Indent(20, rtl), string);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
if (HasBit(this->town->flags, TOWN_IS_GROWING)) {
|
||||
SetDParam(0, RoundDivSU(this->town->growth_rate + 1, DAY_TICKS));
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
|
||||
DrawString(tr, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
} else {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
|
||||
DrawString(tr, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
/* only show the town noise, if the noise option is activated. */
|
||||
if (_settings_game.economy.station_noise_level) {
|
||||
SetDParam(0, this->town->noise_reached);
|
||||
SetDParam(1, this->town->MaxTownNoise());
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_NOISE_IN_TOWN);
|
||||
DrawString(tr, STR_TOWN_VIEW_NOISE_IN_TOWN);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
if (!this->town->text.empty()) {
|
||||
SetDParamStr(0, this->town->text);
|
||||
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
tr.top = DrawStringMultiLine(tr, STR_JUST_RAW_STRING, TC_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,11 +589,8 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_TV_INFO:
|
||||
size->height = GetDesiredInfoHeight(size->width);
|
||||
size->height = GetDesiredInfoHeight(size->width) + padding.height;
|
||||
break;
|
||||
// case WID_TV_CB:
|
||||
// if(this->wcb_disable || !CB_Enabled()) size->width = 0;
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +600,7 @@ public:
|
||||
*/
|
||||
uint GetDesiredInfoHeight(int width) const
|
||||
{
|
||||
uint aimed_height = 8 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
uint aimed_height = 8 * FONT_HEIGHT_NORMAL;
|
||||
|
||||
bool first = true;
|
||||
for (int i = TE_BEGIN; i < TE_END; i++) {
|
||||
@@ -594,7 +620,7 @@ public:
|
||||
|
||||
if (!this->town->text.empty()) {
|
||||
SetDParamStr(0, this->town->text);
|
||||
aimed_height += GetStringHeight(STR_JUST_RAW_STRING, width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT);
|
||||
aimed_height += GetStringHeight(STR_JUST_RAW_STRING, width - WidgetDimensions::scaled.framerect.Horizontal());
|
||||
}
|
||||
|
||||
return aimed_height;
|
||||
@@ -919,18 +945,17 @@ public:
|
||||
|
||||
case WID_TD_LIST: {
|
||||
int n = 0;
|
||||
int y = r.top + WD_FRAMERECT_TOP;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
if (this->towns.size() == 0) { // No towns available.
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
|
||||
DrawString(tr, STR_TOWN_DIRECTORY_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* At least one town available. */
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
|
||||
int text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
|
||||
int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
|
||||
int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
|
||||
int icon_x = tr.WithWidth(icon_size.width, rtl).left;
|
||||
tr = tr.Indent(icon_size.width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
|
||||
for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) {
|
||||
const Town *t = this->towns[i];
|
||||
@@ -938,12 +963,12 @@ public:
|
||||
|
||||
/* Draw rating icon. */
|
||||
if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
|
||||
DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
|
||||
DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, tr.top + (this->resize.step_height - icon_size.height) / 2);
|
||||
} else {
|
||||
SpriteID icon = SPR_TOWN_RATING_APALLING;
|
||||
if (t->ratings[_local_company] > RATING_VERYPOOR) icon = SPR_TOWN_RATING_MEDIOCRE;
|
||||
if (t->ratings[_local_company] > RATING_GOOD) icon = SPR_TOWN_RATING_GOOD;
|
||||
DrawSprite(icon, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
|
||||
DrawSprite(icon, PAL_NONE, icon_x, tr.top + (this->resize.step_height - icon_size.height) / 2);
|
||||
}
|
||||
|
||||
SetDParam(0, t->index);
|
||||
@@ -951,9 +976,10 @@ public:
|
||||
SetDParam(2, t->cm.real_population);
|
||||
SetDParam(3, t->cache.num_houses);
|
||||
/* CITIES DIFFERENT COLOUR*/
|
||||
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, t->larger_town ? STR_TOWN_DIRECTORY_CITY_COLOUR : STR_TOWN_DIRECTORY_TOWN_COLOUR);
|
||||
DrawString(tr.left, tr.right, tr.top + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, t->larger_town ? STR_TOWN_DIRECTORY_CITY_COLOUR : STR_TOWN_DIRECTORY_TOWN_COLOUR);
|
||||
|
||||
y += this->resize.step_height;
|
||||
|
||||
tr.top += this->resize.step_height;
|
||||
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
|
||||
}
|
||||
break;
|
||||
@@ -998,8 +1024,8 @@ public:
|
||||
d.height = std::max(d.height, icon_size.height);
|
||||
resize->height = d.height;
|
||||
d.height *= 5;
|
||||
d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
break;
|
||||
}
|
||||
@@ -1036,7 +1062,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_TD_LIST: { // Click on Town Matrix
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
if (id_v >= this->towns.size()) return; // click out of town bounds
|
||||
|
||||
const Town *t = this->towns[id_v];
|
||||
@@ -1172,7 +1198,9 @@ static const NWidgetPart _nested_found_town_widgets[] = {
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_RANDOM_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_MANY_RANDOM_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
|
||||
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 1, 2),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_EXPAND_ALL_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_FOUND_TOWN_EXPAND_ALL_TOWNS, STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
|
||||
/* Town name selection. */
|
||||
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(156, 14), SetPadding(0, 2, 0, 2), SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_TF_TOWN_NAME_EDITBOX), SetMinimalSize(156, 12), SetPadding(0, 2, 3, 2),
|
||||
@@ -1266,7 +1294,7 @@ public:
|
||||
void UpdateButtons(bool check_availability)
|
||||
{
|
||||
if (check_availability && _game_mode != GM_EDITOR) {
|
||||
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_EXPAND_ALL_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT,
|
||||
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END);
|
||||
if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout;
|
||||
@@ -1333,6 +1361,12 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_TF_EXPAND_ALL_TOWNS:
|
||||
for (Town *t : Town::Iterate()) {
|
||||
Command<CMD_EXPAND_TOWN>::Do(DC_EXEC, t->index, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
|
||||
this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
|
||||
this->UpdateButtons(false);
|
||||
@@ -1394,11 +1428,12 @@ void InitializeTownGui()
|
||||
}
|
||||
|
||||
//CB
|
||||
static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bool show_house_states_info) {
|
||||
static void DrawExtraTownInfo (Rect &r, Town *town, uint line, bool show_house_states_info) {
|
||||
//real pop and rating
|
||||
SetDParam(0, town->cm.real_population);
|
||||
SetDParam(1, town->ratings[_current_company]);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_REALPOP_RATE);
|
||||
DrawString(r, STR_TOWN_VIEW_REALPOP_RATE);
|
||||
r.top += line;
|
||||
//town stats
|
||||
// int grow_rate = 0;
|
||||
// if(town->growth_rate == TOWN_GROW_RATE_CUSTOM_NONE) grow_rate = 0;
|
||||
@@ -1411,13 +1446,15 @@ static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bo
|
||||
SetDParam(3, town->time_until_rebuild);
|
||||
SetDParam(4, HasBit(town->flags, TOWN_IS_GROWING) ? 1 : 0);
|
||||
SetDParam(5, town->fund_buildings_months);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_GROWTH);
|
||||
DrawString(r, STR_TOWN_VIEW_GROWTH);
|
||||
r.top += line;
|
||||
|
||||
if (show_house_states_info) {
|
||||
SetDParam(0, town->cm.houses_constructing);
|
||||
SetDParam(1, town->cm.houses_reconstructed_last_month);
|
||||
SetDParam(2, town->cm.houses_demolished_last_month);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_HOUSE_STATE);
|
||||
DrawString(r, STR_TOWN_VIEW_HOUSE_STATE);
|
||||
r.top += line;
|
||||
}
|
||||
|
||||
///houses stats
|
||||
@@ -1427,7 +1464,8 @@ static void DrawExtraTownInfo (const Rect &r, uint &y, Town *town, uint line, bo
|
||||
SetDParam(3, town->cm.cs_last_month);
|
||||
SetDParam(4, town->cm.hr_total);
|
||||
SetDParam(5, town->cm.hr_last_month);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += line, STR_TOWN_VIEW_GROWTH_TILES);
|
||||
DrawString(r, STR_TOWN_VIEW_GROWTH_TILES);
|
||||
r.top += line;
|
||||
}
|
||||
|
||||
bool CB_sortCargoesByFrom(CargoX first, CargoX second){
|
||||
@@ -1578,21 +1616,28 @@ public:
|
||||
void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
static const uint EXP_LINESPACE = FONT_HEIGHT_NORMAL + 2;
|
||||
uint y = r.top + WD_FRAMERECT_TOP;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
switch(widget){
|
||||
case WID_CB_DETAILS:{
|
||||
//growing
|
||||
if(this->town->cb.growth_state == TownGrowthState::GROWING) DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_GROWING );
|
||||
else DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_NOT_GROWING );
|
||||
//population
|
||||
// growing
|
||||
if(this->town->cb.growth_state == TownGrowthState::GROWING)
|
||||
DrawString(tr, STR_TOWN_CB_GROWING );
|
||||
else DrawString(tr, STR_TOWN_CB_NOT_GROWING );
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
// population
|
||||
SetDParam(0, this->town->cache.population);
|
||||
SetDParam(1, this->town->cache.num_houses);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += EXP_LINESPACE, STR_TOWN_VIEW_POPULATION_HOUSES);
|
||||
DrawString(tr, STR_TOWN_VIEW_POPULATION_HOUSES);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
DrawExtraTownInfo(r, y, this->town, EXP_LINESPACE, false);
|
||||
//regular funding
|
||||
DrawExtraTownInfo(tr, this->town, EXP_LINESPACE, false);
|
||||
|
||||
// regular funding
|
||||
if(this->town->fund_regularly != 0){
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += EXP_LINESPACE, STR_CB_FUNDED_REGULARLY);
|
||||
DrawString(tr, STR_CB_FUNDED_REGULARLY);
|
||||
tr.top += EXP_LINESPACE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1603,10 +1648,8 @@ public:
|
||||
if (g->company != company->index)
|
||||
continue;
|
||||
SetDParamStr(0, g->text);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT,
|
||||
r.right - WD_FRAMERECT_RIGHT,
|
||||
y, STR_GOALS_TEXT);
|
||||
y += EXP_LINESPACE;
|
||||
DrawString(tr, STR_GOALS_TEXT);
|
||||
tr.top += EXP_LINESPACE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1630,12 +1673,13 @@ public:
|
||||
for (it2 = cargoes2.begin(); it2 != cargoes2.end(); ++it2) {
|
||||
CargoX cargox;
|
||||
cargox = *it2;
|
||||
if (it2 == cargoes2.begin()) { //header
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT + 14, r.right - WD_FRAMERECT_LEFT, y,
|
||||
if (it2 == cargoes2.begin()) { // header
|
||||
// FIXME rtl support
|
||||
DrawString(tr.Shrink(ScaleGUITrad(14), 0, 0, 0),
|
||||
(STR_TOWN_GROWTH_HEADER_CARGO + widget - WID_CB_CARGO_NAME), TC_FROMSTRING,
|
||||
(widget == WID_CB_CARGO_NAME) ? SA_LEFT : SA_RIGHT);
|
||||
|
||||
y += (FONT_HEIGHT_NORMAL + 2);
|
||||
tr.top += EXP_LINESPACE;
|
||||
}
|
||||
|
||||
const CargoSpec *cargos = CargoSpec::Get(cargox.id);
|
||||
@@ -1643,15 +1687,14 @@ public:
|
||||
if (!cargos->IsValid() || CB_GetReq(cargos->Index()) == 0) continue;
|
||||
|
||||
from = CB_GetFrom(cargos->Index());
|
||||
|
||||
switch(widget) {
|
||||
case WID_CB_CARGO_NAME: {
|
||||
int rect_x = (r.left + WD_FRAMERECT_LEFT);
|
||||
GfxFillRect(rect_x, y + 1, rect_x + 8, y + 6, 0);
|
||||
GfxFillRect(rect_x + 1, y + 2, rect_x + 7, y + 5, cargos->legend_colour);
|
||||
// FIXME scaling
|
||||
GfxFillRect(tr.left, tr.top + 1, tr.left + 8, tr.top + 6, 0);
|
||||
GfxFillRect(tr.left + 1, tr.top + 2, tr.left + 7, tr.top + 5, cargos->legend_colour);
|
||||
|
||||
SetDParam(0, cargos->name);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT + 14, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_CB_CARGO_NAME);
|
||||
DrawString(tr.Shrink(ScaleGUITrad(14), 0, 0, 0), STR_TOWN_CB_CARGO_NAME);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_AMOUNT: {
|
||||
@@ -1667,7 +1710,7 @@ public:
|
||||
//when not required -> all faded
|
||||
else string_to_draw = STR_TOWN_CB_CARGO_AMOUNT_NOT;
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_REQ: {
|
||||
@@ -1675,7 +1718,7 @@ public:
|
||||
SetDParam(0, requirements);
|
||||
//when required
|
||||
string_to_draw = (this->town->cache.population >= from) ? STR_TOWN_CB_CARGO_REQ_YES : STR_TOWN_CB_CARGO_REQ_NOT;
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_PREVIOUS: {
|
||||
@@ -1689,7 +1732,7 @@ public:
|
||||
}
|
||||
else string_to_draw = STR_TOWN_CB_CARGO_PREVIOUS_NOT;
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_STORE: {
|
||||
@@ -1700,7 +1743,7 @@ public:
|
||||
else string_to_draw = STR_TOWN_CB_CARGO_STORE_NOT;
|
||||
}
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_STORE_PCT: {
|
||||
@@ -1712,20 +1755,20 @@ public:
|
||||
else string_to_draw = STR_TOWN_CB_CARGO_STORE_PCT_NOT;
|
||||
}
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
case WID_CB_CARGO_FROM: {
|
||||
SetDParam(0, from);
|
||||
string_to_draw = (this->town->cache.population >= from) ? STR_TOWN_CB_CARGO_FROM_YES : STR_TOWN_CB_CARGO_FROM_NOT; //when required
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
DrawString(tr, string_to_draw, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
//last case
|
||||
}
|
||||
//switch
|
||||
y += (FONT_HEIGHT_NORMAL + 2);
|
||||
tr.top += EXP_LINESPACE;
|
||||
//cargo needed?
|
||||
}
|
||||
//for cycle
|
||||
|
||||
Reference in New Issue
Block a user