author | rubidium |
Thu, 18 Dec 2008 12:23:08 +0000 | |
changeset 10436 | 8d3a9fbe8f19 |
parent 10208 | 72c00af5c95d |
permissions | -rw-r--r-- |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8976
diff
changeset
|
3 |
/** @file statusbar_gui.cpp The GUI for the bottom status bar. */ |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
4 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
6 |
#include "openttd.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
7 |
#include "settings_type.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
8 |
#include "date_func.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
9 |
#include "gfx_func.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
10 |
#include "news_func.h" |
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10207
diff
changeset
|
11 |
#include "company_func.h" |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
12 |
#include "string_func.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
13 |
#include "strings_func.h" |
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10207
diff
changeset
|
14 |
#include "company_base.h" |
9148
ba0f18cfc795
(svn r13010) -Codechange: move the tree building GUI out of misc_gui.cpp.
rubidium
parents:
9142
diff
changeset
|
15 |
#include "tilehighlight_func.h" |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
16 |
#include "news_gui.h" |
10208
72c00af5c95d
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents:
10207
diff
changeset
|
17 |
#include "company_gui.h" |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
18 |
#include "window_gui.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
19 |
#include "variables.h" |
9117
87f472043e9e
(svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium
parents:
9116
diff
changeset
|
20 |
#include "window_func.h" |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
21 |
#include "statusbar_gui.h" |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
22 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
23 |
#include "table/strings.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
24 |
#include "table/sprites.h" |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
25 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
26 |
static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width) |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
27 |
{ |
9199
ce9fbdff6581
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium
parents:
9165
diff
changeset
|
28 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
ce9fbdff6581
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium
parents:
9165
diff
changeset
|
29 |
StringID str = ni->string_id; |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
30 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
31 |
char buf[512]; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
32 |
GetString(buf, str, lastof(buf)); |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
33 |
const char *s = buf; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
34 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
35 |
char buffer[256]; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
36 |
char *d = buffer; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
37 |
const char *last = lastof(buffer); |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
38 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
39 |
for (;;) { |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
40 |
WChar c = Utf8Consume(&s); |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
41 |
if (c == 0) { |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
42 |
break; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
43 |
} else if (c == 0x0D) { |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
44 |
if (d + 4 >= last) break; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
45 |
d[0] = d[1] = d[2] = d[3] = ' '; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
46 |
d += 4; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
47 |
} else if (IsPrintable(c)) { |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
48 |
if (d + Utf8CharLen(c) >= last) break; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
49 |
d += Utf8Encode(d, c); |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
50 |
} |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
51 |
} |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
52 |
*d = '\0'; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
53 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
54 |
DrawPixelInfo tmp_dpi; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
55 |
if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
56 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
57 |
DrawPixelInfo *old_dpi = _cur_dpi; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
58 |
_cur_dpi = &tmp_dpi; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
59 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
60 |
int x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE); |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
61 |
_cur_dpi = old_dpi; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
62 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
63 |
return x > 0; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
64 |
} |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
65 |
|
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
66 |
struct StatusBarWindow : Window { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
67 |
bool saving; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
68 |
int ticker_scroll; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
69 |
int reminder_timeout; |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
70 |
|
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
71 |
StatusBarWindow(const WindowDesc *desc) : Window(desc) |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
72 |
{ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
73 |
CLRBITS(this->flags4, WF_WHITE_BORDER_MASK); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
74 |
this->ticker_scroll = -1280; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
75 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
76 |
this->FindWindowPlacementAndResize(desc); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
77 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
78 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
79 |
virtual void OnPaint() |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
80 |
{ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
81 |
const Company *c = (_local_company == COMPANY_SPECTATOR) ? NULL : GetCompany(_local_company); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
82 |
|
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9250
diff
changeset
|
83 |
this->DrawWidgets(); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
84 |
SetDParam(0, _date); |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9354
diff
changeset
|
85 |
DrawStringCentered(70, 1, (_pause_game || _settings_client.gui.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
86 |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
87 |
if (c != NULL) { |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
88 |
/* Draw company money */ |
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
89 |
SetDParam(0, c->money); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
90 |
DrawStringCentered(this->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
91 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
92 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
93 |
/* Draw status bar */ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
94 |
if (this->saving) { // true when saving is active |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
95 |
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
96 |
} else if (_do_autosave) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
97 |
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
98 |
} else if (_pause_game) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
99 |
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
100 |
} else if (this->ticker_scroll > -1280 && FindWindowById(WC_NEWS_WINDOW, 0) == NULL && _statusbar_news_item.string_id != 0) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
101 |
/* Draw the scrolling news text */ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
102 |
if (!DrawScrollingStatusText(&_statusbar_news_item, this->ticker_scroll, this->widget[1].right - this->widget[1].left - 2)) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
103 |
this->ticker_scroll = -1280; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
104 |
if (c != NULL) { |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
105 |
/* This is the default text */ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
106 |
SetDParam(0, c->index); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
107 |
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
108 |
} |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
109 |
} |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
110 |
} else { |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
111 |
if (c != NULL) { |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
112 |
/* This is the default text */ |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
113 |
SetDParam(0, c->index); |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
114 |
DrawStringCenteredTruncated(this->widget[1].left + 1, this->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
115 |
} |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
116 |
} |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
117 |
|
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
118 |
if (this->reminder_timeout > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, this->widget[1].right - 11, 2); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
119 |
} |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
120 |
|
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
121 |
virtual void OnInvalidateData(int data) |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
122 |
{ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
123 |
switch (data) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
124 |
default: NOT_REACHED(); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
125 |
case SBI_SAVELOAD_START: this->saving = true; break; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
126 |
case SBI_SAVELOAD_FINISH: this->saving = false; break; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
127 |
case SBI_SHOW_TICKER: this->ticker_scroll = 360; break; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
128 |
case SBI_SHOW_REMINDER: this->reminder_timeout = 91; break; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
129 |
} |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
130 |
} |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
131 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
132 |
virtual void OnClick(Point pt, int widget) |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
133 |
{ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
134 |
switch (widget) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
135 |
case 1: ShowLastNewsMessage(); break; |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9778
diff
changeset
|
136 |
case 2: if (_local_company != COMPANY_SPECTATOR) ShowCompanyFinances(_local_company); break; |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
137 |
default: ResetObjectToPlace(); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
138 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
139 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
140 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
141 |
virtual void OnTick() |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
142 |
{ |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
143 |
if (_pause_game) return; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
144 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
145 |
if (this->ticker_scroll > -1280) { // Scrolling text |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
146 |
this->ticker_scroll -= 2; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
147 |
this->InvalidateWidget(1); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
148 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
149 |
|
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
150 |
if (this->reminder_timeout > 0) { // Red blot to show there are new unread newsmessages |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
151 |
this->reminder_timeout -= 2; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
152 |
} else if (this->reminder_timeout < 0) { |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
153 |
this->reminder_timeout = 0; |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
154 |
this->InvalidateWidget(1); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
155 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
156 |
} |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
157 |
}; |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
158 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
159 |
static const Widget _main_status_widgets[] = { |
9778
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9413
diff
changeset
|
160 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 139, 0, 11, 0x0, STR_NULL}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9413
diff
changeset
|
161 |
{ WWT_PUSHBTN, RESIZE_RIGHT, COLOUR_GREY, 140, 179, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS}, |
c5dd94ed7c16
(svn r13919) -Codechange: Replace numbers with Colours enum on osk(forgot 2 assignations), statusbar, subsidy, terraform, timetable, toolbar, town, tree and vehicle guis.
belugas
parents:
9413
diff
changeset
|
162 |
{ WWT_PUSHBTN, RESIZE_LR, COLOUR_GREY, 180, 319, 0, 11, 0x0, STR_NULL}, |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
163 |
{ WIDGETS_END}, |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
164 |
}; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
165 |
|
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
166 |
static WindowDesc _main_status_desc = { |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
167 |
WDP_CENTER, 0, 320, 12, 640, 12, |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
168 |
WC_STATUS_BAR, WC_NONE, |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
169 |
WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
170 |
_main_status_widgets, |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
171 |
}; |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
172 |
|
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
173 |
/** |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
174 |
* Checks whether the news ticker is currently being used. |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
175 |
*/ |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
176 |
bool IsNewsTickerShown() |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
177 |
{ |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
178 |
const StatusBarWindow *w = dynamic_cast<StatusBarWindow*>(FindWindowById(WC_STATUS_BAR, 0)); |
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
179 |
return w != NULL && w->ticker_scroll > -1280; |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
180 |
} |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9199
diff
changeset
|
181 |
|
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
182 |
void ShowStatusBar() |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
183 |
{ |
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
184 |
_main_status_desc.top = _screen.height - 12; |
9250
320a11aa0c69
(svn r13116) -Codechange: make a window class of the statusbar window.
rubidium
parents:
9248
diff
changeset
|
185 |
new StatusBarWindow(&_main_status_desc); |
8976
1a8367713b73
(svn r12768) -Codechange: move the statusbar GUI to it's own file.
rubidium
parents:
diff
changeset
|
186 |
} |