Merge branch 'master' into jgrpp

# Conflicts:
#	src/group_cmd.cpp
#	src/lang/korean.txt
#	src/lang/simplified_chinese.txt
#	src/script/api/script_rail.cpp
#	src/tunnelbridge_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2023-01-23 19:10:07 +00:00
79 changed files with 181 additions and 237 deletions

View File

@@ -139,6 +139,23 @@ private:
this->SetWidgetDirty(WID_BBS_BRIDGE_LIST);
}
/**
* Get the StringID to draw in the selection list and set the appropriate DParams.
* @param bridge_data the bridge to get the StringID of.
* @return the StringID.
*/
StringID GetBridgeSelectString(const BuildBridgeData &bridge_data) const
{
SetDParam(0, bridge_data.spec->material);
SetDParam(1, bridge_data.spec->speed);
SetDParam(2, bridge_data.cost);
/* If the bridge has no meaningful speed limit, don't display it. */
if (bridge_data.spec->speed == UINT16_MAX) {
return _game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_INFO_NAME : STR_SELECT_BRIDGE_INFO_NAME_COST;
}
return _game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED : STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST;
}
public:
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(desc),
start_tile(start),
@@ -191,14 +208,9 @@ public:
case WID_BBS_BRIDGE_LIST: {
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
Dimension text_dim = {0, 0}; // Biggest text dimension
for (int i = 0; i < (int)this->bridges->size(); i++) {
const BridgeSpec *b = this->bridges->at(i).spec;
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
SetDParam(2, this->bridges->at(i).cost);
SetDParam(1, b->speed);
SetDParam(0, b->material);
text_dim = maxdim(text_dim, GetStringBoundingBox(_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO));
for (const BuildBridgeData &bridge_data : *this->bridges) {
sprite_dim = maxdim(sprite_dim, GetSpriteSize(bridge_data.spec->sprite));
text_dim = maxdim(text_dim, GetStringBoundingBox(GetBridgeSelectString(bridge_data)));
}
sprite_dim.height++; // Sprite is rendered one pixel down in the matrix field.
text_dim.height++; // Allowing the bottom row pixels to be rendered on the edge of the matrix field.
@@ -232,15 +244,10 @@ public:
case WID_BBS_BRIDGE_LIST: {
Rect tr = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
const BridgeSpec *b = this->bridges->at(i).spec;
SetDParam(2, this->bridges->at(i).cost);
SetDParam(1, b->speed);
SetDParam(0, b->material);
const BuildBridgeData &bridge_data = this->bridges->at(i);
const BridgeSpec *b = bridge_data.spec;
DrawSprite(b->sprite, b->pal, tr.left, tr.bottom - GetSpriteSize(b->sprite).height);
DrawStringMultiLine(tr.Indent(this->bridgetext_offset, false),
_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO);
DrawStringMultiLine(tr.Indent(this->bridgetext_offset, false), GetBridgeSelectString(bridge_data));
tr = tr.Translate(0, this->resize.step_height);
}
break;