-
-
Save andythenorth/237c6062748a21de30d7fe28f9db5fa9 to your computer and use it in GitHub Desktop.
Train Length - correct lengths + UI zoom support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp | |
index 47eefc65e..4e655dd27 100644 | |
--- a/src/depot_gui.cpp | |
+++ b/src/depot_gui.cpp | |
@@ -297,9 +297,9 @@ struct DepotWindow : Window { | |
this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over); | |
/* Length of consist in tiles with 1 fractional digit (rounded up) */ | |
- SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE)); | |
- SetDParam(1, 1); | |
- DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter | |
+ //SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE)); | |
+ //SetDParam(1, 1); | |
+ //DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter | |
break; | |
} | |
@@ -332,6 +332,23 @@ struct DepotWindow : Window { | |
} | |
} | |
+ void DrawTrainLengthCounter(const Rect &r) const | |
+ { | |
+ if (this->type != VEH_TRAIN) return; | |
+ | |
+ bool rtl = _current_text_dir == TD_RTL; | |
+ int column = 0; | |
+ | |
+ /* show train length grid (1 tile = 16/8 of vehicles) */ | |
+ for (int w = r.left + this->header_width - this->hscroll->GetPosition(); w <= r.right + this->hscroll->GetPosition(); w += ScaleGUITrad(TILE_SIZE) * 4) { | |
+ GfxDrawLine(w, r.top, w, r.bottom, 7, 1, 1); | |
+ | |
+ SetDParam(0, column++); | |
+ | |
+ DrawString(rtl ? left + WD_FRAMERECT_LEFT : w - this->count_width, rtl ? w + this->count_width : w - WD_FRAMERECT_RIGHT, r.bottom - (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_GRAY, TC_FROMSTRING, SA_RIGHT); // Draw the tile counter | |
+ } | |
+ } | |
+ | |
void DrawWidget(const Rect &r, int widget) const | |
{ | |
if (widget != WID_D_MATRIX) return; | |
@@ -342,6 +359,8 @@ struct DepotWindow : Window { | |
const NWidgetCore *wid = this->GetWidget<NWidgetCore>(WID_D_MATRIX); | |
uint16 rows_in_display = wid->current_y / wid->resize_y; | |
+ this->DrawTrainLengthCounter(r); | |
+ | |
uint16 num = this->vscroll->GetPosition() * this->num_columns; | |
int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * this->num_columns)); | |
int y; | |
diff --git a/src/lang/english.txt b/src/lang/english.txt | |
index 198f38c4c..88901fbdf 100644 | |
--- a/src/lang/english.txt | |
+++ b/src/lang/english.txt | |
@@ -5002,6 +5002,7 @@ STR_ORANGE_STRING1_LTBLUE :{ORANGE}{STRING | |
STR_TINY_BLACK_HEIGHT :{TINY_FONT}{BLACK}{HEIGHT} | |
STR_TINY_BLACK_VEHICLE :{TINY_FONT}{BLACK}{VEHICLE} | |
STR_TINY_RIGHT_ARROW :{TINY_FONT}{RIGHT_ARROW} | |
+STR_TINY_GRAY :{TINY_FONT}{GRAY}{NUM} | |
STR_BLACK_1 :{BLACK}1 | |
STR_BLACK_2 :{BLACK}2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment