diff options
author | rubidium <rubidium@openttd.org> | 2009-07-07 16:51:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-07-07 16:51:20 +0000 |
commit | 3086383cdc7087b46ebcd9320c300ea6ba67ec7a (patch) | |
tree | a455fb825d1db26aaa259eaae03ac95b000f0fca /src/viewport.cpp | |
parent | fbb2fb97206771cc3d54a3e2f43f6fc098f0c557 (diff) | |
download | openttd-3086383cdc7087b46ebcd9320c300ea6ba67ec7a.tar.xz |
(svn r16761) -Codechange: make UpdateViewportSignPos(ition) a class function of ViewportSign
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index bf3014bde..fa1f746a6 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1279,23 +1279,26 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi) } } -void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str) +/** + * Update the position of the viewport sign. + * @param center the (preferred) center of the viewport sign + * @param top the new top of the sign + * @param str the string to show in the sign + */ +void ViewportSign::UpdatePosition(int center, int top, StringID str) { - char buffer[256]; - uint w; + this->top = top; - sign->top = top; + char buffer[DRAW_STRING_BUFFER]; GetString(buffer, str, lastof(buffer)); - w = GetStringBoundingBox(buffer).width + 3; - sign->width_1 = w; - sign->left = left - w / 2; + this->width_1 = GetStringBoundingBox(buffer).width + 3; + this->left = center - this->width_1 / 2; /* zoomed out version */ _cur_fontsize = FS_SMALL; - w = GetStringBoundingBox(buffer).width + 3; + this->width_2 = GetStringBoundingBox(buffer).width + 3; _cur_fontsize = FS_NORMAL; - sign->width_2 = w; } |