diff options
author | darkvater <darkvater@openttd.org> | 2005-04-05 21:03:30 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2005-04-05 21:03:30 +0000 |
commit | 22d36985cd7e1e16c008bfaecc7d98fde6e09d5d (patch) | |
tree | 7641c6fce22d5b8a61b5207f3a67097bcde54343 /news_gui.c | |
parent | 4aa7cf8e9fe09781de385ff964d234c4a83ac419 (diff) | |
download | openttd-22d36985cd7e1e16c008bfaecc7d98fde6e09d5d.tar.xz |
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
- CodeChange: Introduction of SendWindowMessage() where a window can send another window a message (ala windows style msg, wparam, lparam). Messages can be sent by windowclass and by windowpointer.
- CodeChange: IsVitalWindow() simplifies a lot of checks for window handling that need to know what windows it can close, or be on top of, etc.
Diffstat (limited to 'news_gui.c')
-rw-r--r-- | news_gui.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/news_gui.c b/news_gui.c index 1f22f6078..889cf15b9 100644 --- a/news_gui.c +++ b/news_gui.c @@ -98,6 +98,11 @@ void DrawNewsBorder(const Window *w) static void NewsWindowProc(Window *w, WindowEvent *e) { switch (e->event) { + case WE_CREATE: { /* If chatbar is open at creation time, we need to go above it */ + const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0); + w->message.msg = (w1 != NULL) ? w1->height : 0; + } break; + case WE_PAINT: { const NewsItem *ni = WP(w, news_d).ni; ViewPort *vp; @@ -184,17 +189,26 @@ static void NewsWindowProc(Window *w, WindowEvent *e) } break; - case WE_TICK: { - int y = max(w->top - 4, _screen.height - w->height); - if (y == w->top) - return; + case WE_MESSAGE: /* The chatbar has notified us that is was either created or closed */ + switch (e->message.msg) { + case WE_CREATE: w->message.msg = e->message.wparam; break; + case WE_DESTROY: w->message.msg = 0; break; + break; + } + break; + + case WE_TICK: { /* Scroll up newsmessages from the bottom in steps of 4 pixels */ + int diff; + int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg); + if (y == w->top) return; if (w->viewport != NULL) w->viewport->top += y - w->top; + diff = abs(w->top - y); w->top = y; - SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height + 4); + SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height); } break; } } @@ -339,7 +353,7 @@ static void ShowNewspaper(NewsItem *ni) if (sound != 0) SndPlayFx(sound); - top = _screen.height - 4; + top = _screen.height; switch (ni->display_mode) { case NM_NORMAL: case NM_CALLBACK: { |