mirror of https://github.com/OpenTTD/OpenTTD
Change: Sort cargo list in industry view window.
parent
4c06769ff2
commit
c8883baf24
|
@ -880,8 +880,15 @@ public:
|
||||||
const int label_indent = WidgetDimensions::scaled.hsep_normal + this->cargo_icon_size.width;
|
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);
|
bool stockpiling = HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS);
|
||||||
|
|
||||||
for (const auto &a : i->accepted) {
|
/* Use map to sort industry's accepted cargo list. */
|
||||||
if (!IsValidCargoID(a.cargo)) continue;
|
std::map<CargoID, const Industry::AcceptedCargo &, CargoIDComparator> sorted_accepted;
|
||||||
|
for (auto it = std::begin(i->accepted); it != std::end(i->accepted); ++it) {
|
||||||
|
if (!IsValidCargoID(it->cargo)) continue;
|
||||||
|
sorted_accepted.emplace(it->cargo, *it);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &pair : sorted_accepted) {
|
||||||
|
const auto &a = pair.second;
|
||||||
has_accept = true;
|
has_accept = true;
|
||||||
if (first) {
|
if (first) {
|
||||||
DrawString(ir, STR_INDUSTRY_VIEW_REQUIRES);
|
DrawString(ir, STR_INDUSTRY_VIEW_REQUIRES);
|
||||||
|
@ -925,8 +932,16 @@ public:
|
||||||
int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2;
|
int text_y_offset = (line_height - GetCharacterHeight(FS_NORMAL)) / 2;
|
||||||
int button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2;
|
int button_y_offset = (line_height - SETTING_BUTTON_HEIGHT) / 2;
|
||||||
first = true;
|
first = true;
|
||||||
for (const auto &p : i->produced) {
|
|
||||||
if (!IsValidCargoID(p.cargo)) continue;
|
/* Use map to sort industry's produced cargo list. */
|
||||||
|
std::map<CargoID, const Industry::ProducedCargo &, CargoIDComparator> sorted_produced;
|
||||||
|
for (auto it = std::begin(i->produced); it != std::end(i->produced); ++it) {
|
||||||
|
if (!IsValidCargoID(it->cargo)) continue;
|
||||||
|
sorted_produced.emplace(it->cargo, *it);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &pair : sorted_produced) {
|
||||||
|
const auto &p = pair.second;
|
||||||
if (first) {
|
if (first) {
|
||||||
if (has_accept) ir.top += WidgetDimensions::scaled.vsep_wide;
|
if (has_accept) ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||||
DrawString(ir, TimerGameEconomy::UsingWallclockUnits() ? STR_INDUSTRY_VIEW_PRODUCTION_LAST_MINUTE_TITLE : STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
|
DrawString(ir, TimerGameEconomy::UsingWallclockUnits() ? STR_INDUSTRY_VIEW_PRODUCTION_LAST_MINUTE_TITLE : STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE);
|
||||||
|
|
Loading…
Reference in New Issue