Merge branch 'master' into jgrpp
# Conflicts: # regression/regression/result.txt # src/autoreplace_cmd.cpp # src/industry_gui.cpp # src/landscape.cpp # src/network/network_content.cpp # src/newgrf_roadstop.cpp # src/pathfinder/yapf/yapf_ship.cpp # src/road_gui.cpp # src/saveload/ai_sl.cpp # src/saveload/saveload.h # src/saveload/vehicle_sl.cpp # src/station.cpp # src/station_gui.cpp # src/video/cocoa/cocoa_ogl.h # src/video/sdl2_opengl_v.h # src/video/video_driver.hpp # src/video/win32_v.h # src/widget_type.h # src/widgets/dropdown.cpp # src/widgets/dropdown_type.h # src/window.cpp
This commit is contained in:
@@ -831,6 +831,7 @@ class IndustryViewWindow : public Window
|
||||
IL_RATE2, ///< Production rate of cargo 2
|
||||
};
|
||||
|
||||
Dimension cargo_icon_size; ///< Largest cargo icon dimension.
|
||||
Editability editable; ///< Mode for changing production
|
||||
InfoLine editbox_line; ///< The line clicked to open the edit box
|
||||
InfoLine clicked_line; ///< The line of the button that has been clicked
|
||||
@@ -859,6 +860,7 @@ public:
|
||||
{
|
||||
/* This only used when the cheat to alter industry production is enabled */
|
||||
this->cheat_line_height = std::max(SETTING_BUTTON_HEIGHT + WidgetDimensions::scaled.vsep_normal, GetCharacterHeight(FS_NORMAL));
|
||||
this->cargo_icon_size = GetLargestCargoIconSize();
|
||||
}
|
||||
|
||||
void OnPaint() override
|
||||
@@ -876,6 +878,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void DrawCargoIcon(const Rect &r, CargoID cid) const
|
||||
{
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
SpriteID icon = CargoSpec::Get(cid)->GetCargoIcon();
|
||||
Dimension d = GetSpriteSize(icon);
|
||||
Rect ir = r.WithWidth(this->cargo_icon_size.width, rtl).WithHeight(GetCharacterHeight(FS_NORMAL));
|
||||
DrawSprite(icon, PAL_NONE, CenterBounds(ir.left, ir.right, d.width), CenterBounds(ir.top, ir.bottom, this->cargo_icon_size.height));
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text in the #WID_IV_INFO panel.
|
||||
* @param r Rectangle of the panel.
|
||||
@@ -897,6 +908,8 @@ public:
|
||||
|
||||
CargoSuffix cargo_suffix[lengthof(i->accepts_cargo)];
|
||||
GetAllCargoSuffixes(CARGOSUFFIX_IN, CST_VIEW, i, i->type, ind, i->accepts_cargo, cargo_suffix);
|
||||
|
||||
const int label_indent = WidgetDimensions::scaled.hsep_normal + this->cargo_icon_size.width;
|
||||
bool stockpiling = HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS);
|
||||
|
||||
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||
@@ -907,6 +920,9 @@ public:
|
||||
ir.top += GetCharacterHeight(FS_NORMAL);
|
||||
first = false;
|
||||
}
|
||||
|
||||
DrawCargoIcon(ir, i->accepts_cargo[j]);
|
||||
|
||||
SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);
|
||||
SetDParam(1, i->accepts_cargo[j]);
|
||||
SetDParam(2, i->incoming_cargo_waiting[j]);
|
||||
@@ -930,7 +946,7 @@ public:
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent, rtl), str);
|
||||
DrawString(ir.Indent(label_indent, rtl), str);
|
||||
ir.top += GetCharacterHeight(FS_NORMAL);
|
||||
}
|
||||
|
||||
@@ -949,14 +965,16 @@ public:
|
||||
first = false;
|
||||
}
|
||||
|
||||
DrawCargoIcon(ir, i->accepts_cargo[j]);
|
||||
|
||||
SetDParam(0, i->produced_cargo[j]);
|
||||
SetDParam(1, i->last_month_production[j]);
|
||||
SetDParamStr(2, cargo_suffix[j].text);
|
||||
SetDParam(3, ToPercent8(i->last_month_pct_transported[j]));
|
||||
DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent + (this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_normal : 0), rtl).Translate(0, text_y_offset), STR_INDUSTRY_VIEW_TRANSPORTED);
|
||||
DrawString(ir.Indent(label_indent + (this->editable == EA_RATE ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_normal : 0), rtl).Translate(0, text_y_offset), STR_INDUSTRY_VIEW_TRANSPORTED);
|
||||
/* Let's put out those buttons.. */
|
||||
if (this->editable == EA_RATE) {
|
||||
DrawArrowButtons(ir.Indent(WidgetDimensions::scaled.hsep_indent, rtl).WithWidth(SETTING_BUTTON_WIDTH, rtl).left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
|
||||
DrawArrowButtons(ir.Indent(label_indent, rtl).WithWidth(SETTING_BUTTON_WIDTH, rtl).left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0,
|
||||
i->production_rate[j] > 0, i->production_rate[j] < 255);
|
||||
}
|
||||
ir.top += line_height;
|
||||
@@ -970,8 +988,8 @@ public:
|
||||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
this->production_offset_y = ir.top;
|
||||
SetDParam(0, RoundDivSU(i->prod_level * 100, PRODLEVEL_DEFAULT));
|
||||
DrawString(ir.Indent(WidgetDimensions::scaled.hsep_indent + SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_normal, rtl).Translate(0, text_y_offset), STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
|
||||
DrawArrowButtons(ir.Indent(WidgetDimensions::scaled.hsep_indent, rtl).WithWidth(SETTING_BUTTON_WIDTH, rtl).left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
|
||||
DrawString(ir.Indent(label_indent + SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_normal, rtl).Translate(0, text_y_offset), STR_INDUSTRY_VIEW_PRODUCTION_LEVEL);
|
||||
DrawArrowButtons(ir.Indent(label_indent, rtl).WithWidth(SETTING_BUTTON_WIDTH, rtl).left, ir.top + button_y_offset, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0,
|
||||
i->prod_level > PRODLEVEL_MINIMUM, i->prod_level < PRODLEVEL_MAXIMUM);
|
||||
ir.top += line_height;
|
||||
}
|
||||
@@ -1049,7 +1067,7 @@ public:
|
||||
if (line == IL_NONE) return;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect).Indent(WidgetDimensions::scaled.hsep_indent, rtl);
|
||||
Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect).Indent(this->cargo_icon_size.width + WidgetDimensions::scaled.hsep_normal, rtl);
|
||||
|
||||
if (r.WithWidth(SETTING_BUTTON_WIDTH, rtl).Contains(pt)) {
|
||||
/* Clicked buttons, decrease or increase production */
|
||||
@@ -2018,6 +2036,9 @@ struct CargoesField {
|
||||
static int industry_width;
|
||||
static uint max_cargoes;
|
||||
|
||||
using Cargoes = uint16_t;
|
||||
static_assert(std::numeric_limits<Cargoes>::digits >= MAX_CARGOES);
|
||||
|
||||
CargoesFieldType type; ///< Type of field.
|
||||
union {
|
||||
struct {
|
||||
@@ -2027,10 +2048,10 @@ struct CargoesField {
|
||||
} industry; ///< Industry data (for #CFT_INDUSTRY).
|
||||
struct {
|
||||
CargoID vertical_cargoes[MAX_CARGOES]; ///< Cargoes running from top to bottom (cargo ID or #INVALID_CARGO).
|
||||
Cargoes supp_cargoes; ///< Cargoes in \c vertical_cargoes entering from the left.
|
||||
Cargoes cust_cargoes; ///< Cargoes in \c vertical_cargoes leaving to the right.
|
||||
uint8_t num_cargoes; ///< Number of cargoes.
|
||||
CargoID supp_cargoes[MAX_CARGOES]; ///< Cargoes entering from the left (index in #vertical_cargoes, or #INVALID_CARGO).
|
||||
uint8_t top_end; ///< Stop at the top of the vertical cargoes.
|
||||
CargoID cust_cargoes[MAX_CARGOES]; ///< Cargoes leaving to the right (index in #vertical_cargoes, or #INVALID_CARGO).
|
||||
uint8_t bottom_end; ///< Stop at the bottom of the vertical cargoes.
|
||||
} cargo; ///< Cargo data (for #CFT_CARGO).
|
||||
struct {
|
||||
@@ -2084,11 +2105,11 @@ struct CargoesField {
|
||||
if (column < 0) return -1;
|
||||
|
||||
if (producer) {
|
||||
assert(this->u.cargo.supp_cargoes[column] == INVALID_CARGO);
|
||||
this->u.cargo.supp_cargoes[column] = column;
|
||||
assert(!HasBit(this->u.cargo.supp_cargoes, column));
|
||||
SetBit(this->u.cargo.supp_cargoes, column);
|
||||
} else {
|
||||
assert(this->u.cargo.cust_cargoes[column] == INVALID_CARGO);
|
||||
this->u.cargo.cust_cargoes[column] = column;
|
||||
assert(!HasBit(this->u.cargo.cust_cargoes, column));
|
||||
SetBit(this->u.cargo.cust_cargoes, column);
|
||||
}
|
||||
return column;
|
||||
}
|
||||
@@ -2101,11 +2122,7 @@ struct CargoesField {
|
||||
{
|
||||
assert(this->type == CFT_CARGO);
|
||||
|
||||
for (uint i = 0; i < MAX_CARGOES; i++) {
|
||||
if (this->u.cargo.supp_cargoes[i] != INVALID_CARGO) return true;
|
||||
if (this->u.cargo.cust_cargoes[i] != INVALID_CARGO) return true;
|
||||
}
|
||||
return false;
|
||||
return this->u.cargo.supp_cargoes != 0 || this->u.cargo.cust_cargoes != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2133,8 +2150,8 @@ struct CargoesField {
|
||||
std::fill(insert, std::end(this->u.cargo.vertical_cargoes), INVALID_CARGO);
|
||||
this->u.cargo.top_end = top_end;
|
||||
this->u.cargo.bottom_end = bottom_end;
|
||||
std::fill(std::begin(this->u.cargo.supp_cargoes), std::end(this->u.cargo.supp_cargoes), INVALID_CARGO);
|
||||
std::fill(std::begin(this->u.cargo.cust_cargoes), std::end(this->u.cargo.cust_cargoes), INVALID_CARGO);
|
||||
this->u.cargo.supp_cargoes = 0;
|
||||
this->u.cargo.cust_cargoes = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2262,7 +2279,7 @@ struct CargoesField {
|
||||
colpos += 1 + CargoesField::cargo_space.width;
|
||||
}
|
||||
|
||||
const CargoID *hor_left, *hor_right;
|
||||
Cargoes hor_left, hor_right;
|
||||
if (_current_text_dir == TD_RTL) {
|
||||
hor_left = this->u.cargo.cust_cargoes;
|
||||
hor_right = this->u.cargo.supp_cargoes;
|
||||
@@ -2272,8 +2289,8 @@ struct CargoesField {
|
||||
}
|
||||
ypos += CargoesField::cargo_border.height + vert_inter_industry_space / 2 + (GetCharacterHeight(FS_NORMAL) - CargoesField::cargo_line.height) / 2;
|
||||
for (uint i = 0; i < MAX_CARGOES; i++) {
|
||||
if (hor_left[i] != INVALID_CARGO) {
|
||||
int col = hor_left[i];
|
||||
if (HasBit(hor_left, i)) {
|
||||
int col = i;
|
||||
int dx = 0;
|
||||
const CargoSpec *csp = CargoSpec::Get(this->u.cargo.vertical_cargoes[col]);
|
||||
for (; col > 0; col--) {
|
||||
@@ -2283,8 +2300,8 @@ struct CargoesField {
|
||||
}
|
||||
DrawHorConnection(xpos, cargo_base - dx, ypos, csp);
|
||||
}
|
||||
if (hor_right[i] != INVALID_CARGO) {
|
||||
int col = hor_right[i];
|
||||
if (HasBit(hor_right, i)) {
|
||||
int col = i;
|
||||
int dx = 0;
|
||||
const CargoSpec *csp = CargoSpec::Get(this->u.cargo.vertical_cargoes[col]);
|
||||
for (; col < this->u.cargo.num_cargoes - 1; col++) {
|
||||
@@ -2348,7 +2365,7 @@ struct CargoesField {
|
||||
|
||||
/* row = 0 -> at first horizontal row, row = 1 -> second horizontal row, 2 = 3rd horizontal row. */
|
||||
if (col == 0) {
|
||||
if (this->u.cargo.supp_cargoes[row] != INVALID_CARGO) return this->u.cargo.vertical_cargoes[this->u.cargo.supp_cargoes[row]];
|
||||
if (HasBit(this->u.cargo.supp_cargoes, row)) return this->u.cargo.vertical_cargoes[row];
|
||||
if (left != nullptr) {
|
||||
if (left->type == CFT_INDUSTRY) return left->u.industry.other_produced[row];
|
||||
if (left->type == CFT_CARGO_LABEL && !left->u.cargo_label.left_align) return left->u.cargo_label.cargoes[row];
|
||||
@@ -2356,7 +2373,7 @@ struct CargoesField {
|
||||
return INVALID_CARGO;
|
||||
}
|
||||
if (col == this->u.cargo.num_cargoes) {
|
||||
if (this->u.cargo.cust_cargoes[row] != INVALID_CARGO) return this->u.cargo.vertical_cargoes[this->u.cargo.cust_cargoes[row]];
|
||||
if (HasBit(this->u.cargo.cust_cargoes, row)) return this->u.cargo.vertical_cargoes[row];
|
||||
if (right != nullptr) {
|
||||
if (right->type == CFT_INDUSTRY) return right->u.industry.other_accepted[row];
|
||||
if (right->type == CFT_CARGO_LABEL && right->u.cargo_label.left_align) return right->u.cargo_label.cargoes[row];
|
||||
@@ -2368,15 +2385,11 @@ struct CargoesField {
|
||||
* Since the horizontal connection is made in the same order as the vertical list, the above condition
|
||||
* ensures we are left-below the main diagonal, thus at the supplying side.
|
||||
*/
|
||||
if (this->u.cargo.supp_cargoes[row] == INVALID_CARGO) return INVALID_CARGO;
|
||||
return this->u.cargo.vertical_cargoes[this->u.cargo.supp_cargoes[row]];
|
||||
} else {
|
||||
/* Clicked at a customer connection. */
|
||||
if (this->u.cargo.cust_cargoes[row] == INVALID_CARGO) return INVALID_CARGO;
|
||||
return this->u.cargo.vertical_cargoes[this->u.cargo.cust_cargoes[row]];
|
||||
if (HasBit(this->u.cargo.supp_cargoes, row)) return this->u.cargo.vertical_cargoes[row];
|
||||
return INVALID_CARGO;
|
||||
}
|
||||
/* Clicked at a customer connection. */
|
||||
if (IsValidCargoID(this->u.cargo.cust_cargoes[row])) return this->u.cargo.vertical_cargoes[this->u.cargo.cust_cargoes[row]];
|
||||
if (HasBit(this->u.cargo.cust_cargoes, row)) return this->u.cargo.vertical_cargoes[row];
|
||||
return INVALID_CARGO;
|
||||
}
|
||||
|
||||
@@ -2466,7 +2479,7 @@ struct CargoesRow {
|
||||
|
||||
/* Allocate other cargoes in the empty holes of the horizontal cargo connections. */
|
||||
for (uint i = 0; i < CargoesField::max_cargoes && other_count > 0; i++) {
|
||||
if (cargo_fld->u.cargo.supp_cargoes[i] == INVALID_CARGO) ind_fld->u.industry.other_produced[i] = others[--other_count];
|
||||
if (HasBit(cargo_fld->u.cargo.supp_cargoes, i)) ind_fld->u.industry.other_produced[i] = others[--other_count];
|
||||
}
|
||||
} else {
|
||||
/* Houses only display cargo that towns produce. */
|
||||
@@ -2525,7 +2538,7 @@ struct CargoesRow {
|
||||
|
||||
/* Allocate other cargoes in the empty holes of the horizontal cargo connections. */
|
||||
for (uint i = 0; i < CargoesField::max_cargoes && other_count > 0; i++) {
|
||||
if (cargo_fld->u.cargo.cust_cargoes[i] == INVALID_CARGO) ind_fld->u.industry.other_accepted[i] = others[--other_count];
|
||||
if (!HasBit(cargo_fld->u.cargo.cust_cargoes, i)) ind_fld->u.industry.other_accepted[i] = others[--other_count];
|
||||
}
|
||||
} else {
|
||||
/* Houses only display what is demanded. */
|
||||
|
Reference in New Issue
Block a user