diff options
author | smatz <smatz@openttd.org> | 2010-06-04 09:47:55 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2010-06-04 09:47:55 +0000 |
commit | c49436c2d1da9d5d7029f4e8880ae5bbdc54495e (patch) | |
tree | 2c25e5a328dba314024459ed06e8170822353f3e /src | |
parent | 6be760645a7fd2087348ab67932a4732c6d0ae41 (diff) | |
download | openttd-c49436c2d1da9d5d7029f4e8880ae5bbdc54495e.tar.xz |
(svn r19921) -Fix [FS#3865]: closing chatbox could cause glitches when news message was shown
Diffstat (limited to 'src')
-rw-r--r-- | src/news_gui.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 9b2a5dcb5..d90b8eb3a 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -490,24 +490,35 @@ struct NewsWindow : Window { virtual void OnInvalidateData(int data) { /* The chatbar has notified us that is was either created or closed */ + int newtop = this->top + this->chat_height - data; this->chat_height = data; + this->SetWindowTop(newtop); } virtual void OnTick() { /* Scroll up newsmessages from the bottom in steps of 4 pixels */ - int y = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height); - if (y == this->top) return; + int newtop = max(this->top - 4, _screen.height - this->height - this->status_height - this->chat_height); + this->SetWindowTop(newtop); + } - if (this->viewport != NULL) this->viewport->top += y - this->top; +private: + /** + * Moves the window so #newtop is new 'top' coordinate. Makes screen dirty where needed. + * @param newtop new top coordinate + */ + void SetWindowTop(int newtop) + { + if (this->top == newtop) return; - int diff = Delta(this->top, y); - this->top = y; + int mintop = min(newtop, this->top); + int maxtop = max(newtop, this->top); + if (this->viewport != NULL) this->viewport->top += newtop - this->top; + this->top = newtop; - SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height + diff); + SetDirtyBlocks(this->left, mintop, this->left + this->width, maxtop + this->height); } -private: StringID GetCompanyMessageString() const { switch (this->ni->subtype) { |