TBTR: Clip drawing of template vehicles.

This fixes long templates running off the side of the window and/or
obscuring the train length text.
pull/6/merge
Jonathan G Rennison 8 years ago
parent 4f052d3cad
commit cf638e836a

@ -679,7 +679,7 @@ public:
}
/* Draw the template */
DrawTemplate(v, left + ScaleGUITrad(50), right, y);
DrawTemplate(v, left + ScaleGUITrad(36), right - ScaleGUITrad(24), y);
/* Draw a notification string for chains that are not runnable */
if (v->IsFreeWagonChain()) {

@ -119,16 +119,26 @@ void DrawTemplate(const TemplateVehicle *tv, int left, int right, int y)
{
if (!tv) return;
DrawPixelInfo tmp_dpi, *old_dpi;
int max_width = right - left + 1;
int height = ScaleGUITrad(14);
if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return;
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
const TemplateVehicle *t = tv;
int offset = left;
int offset = 0;
while (t) {
PaletteID pal = GetEnginePalette(t->engine_type, _current_company);
DrawSprite(t->cur_image, pal, offset, y + ScaleGUITrad(11));
DrawSprite(t->cur_image, pal, offset + t->image_width / 2, ScaleGUITrad(11));
offset += t->image_width;
t = t->Next();
}
_cur_dpi = old_dpi;
}
// copy important stuff from the virtual vehicle to the template

Loading…
Cancel
Save