summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-07-16 10:26:13 +0000
committeralberth <alberth@openttd.org>2009-07-16 10:26:13 +0000
commitc00ce644585beb5348565a25c03373ad5b68d8a8 (patch)
treee398442eba54d18720d96541e483c04d14e7b457 /src/widget.cpp
parent594070194f62cd336ff25b51dd603d24f1368d17 (diff)
downloadopenttd-c00ce644585beb5348565a25c03373ad5b68d8a8.tar.xz
(svn r16843) -Codechange: More documentation for the WWT_MATRIX widget, and better variable names in matrix rendering function.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 1f5a8b9e5..b3585a844 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -330,43 +330,43 @@ static inline void DrawInset(const Rect &r, Colours colour, StringID str)
* @param r Rectangle of the matrix background.
* @param colour Colour of the background.
* @param clicked Matrix is rendered lowered.
- * @param data Data of the widget.
+ * @param data Data of the widget, number of rows and columns of the widget.
*/
static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16 data)
{
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
- int c = GB(data, 0, 8);
- int amt1 = (r.right - r.left + 1) / c;
+ int num_columns = GB(data, 0, 8); // Lower 8 bits of the widget data: Number of columns in the matrix.
+ int column_width = (r.right - r.left + 1) / num_columns; // Width of a single column in the matrix.
- int d = GB(data, 8, 8);
- int amt2 = (r.bottom - r.top + 1) / d;
+ int num_rows = GB(data, 8, 8); // Upper 8 bits of the widget data: Number of rows in the matrix.
+ int row_height = (r.bottom - r.top + 1) / num_rows; // Height of a single row in the matrix.
int col = _colour_gradient[colour & 0xF][6];
int x = r.left;
- for (int ctr = c; ctr > 1; ctr--) {
- x += amt1;
+ for (int ctr = num_columns; ctr > 1; ctr--) {
+ x += column_width;
GfxFillRect(x, r.top + 1, x, r.bottom - 1, col);
}
x = r.top;
- for (int ctr = d; ctr > 1; ctr--) {
- x += amt2;
+ for (int ctr = num_rows; ctr > 1; ctr--) {
+ x += row_height;
GfxFillRect(r.left + 1, x, r.right - 1, x, col);
}
col = _colour_gradient[colour & 0xF][4];
x = r.left - 1;
- for (int ctr = c; ctr > 1; ctr--) {
- x += amt1;
+ for (int ctr = num_columns; ctr > 1; ctr--) {
+ x += column_width;
GfxFillRect(x, r.top + 1, x, r.bottom - 1, col);
}
x = r.top - 1;
- for (int ctr = d; ctr > 1; ctr--) {
- x += amt2;
+ for (int ctr = num_rows; ctr > 1; ctr--) {
+ x += row_height;
GfxFillRect(r.left + 1, x, r.right - 1, x, col);
}
}