summaryrefslogtreecommitdiff
path: root/news_gui.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2005-04-05 21:03:30 +0000
committerdarkvater <darkvater@openttd.org>2005-04-05 21:03:30 +0000
commit648fa7c97d817e218722f2b54db0a6e49c72ddc9 (patch)
tree7641c6fce22d5b8a61b5207f3a67097bcde54343 /news_gui.c
parent4b3f20f4842dc6bda9088b5e72363b094e23f390 (diff)
downloadopenttd-648fa7c97d817e218722f2b54db0a6e49c72ddc9.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.c26
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: {