247 static void AboutWindowProc(BaseWindow *w, WindowEvent *e) |
247 static void AboutWindowProc(BaseWindow *w, WindowEvent *e) |
248 { |
248 { |
249 switch (e->event) { |
249 switch (e->event) { |
250 case WE_CREATE: /* Set up window counter and start position of scroller */ |
250 case WE_CREATE: /* Set up window counter and start position of scroller */ |
251 WP(w, scroller_d).counter = 0; |
251 WP(w, scroller_d).counter = 0; |
252 WP(w, scroller_d).height = w->height - 40; |
252 WP(w, scroller_d).height = w->Height() - 40; |
253 break; |
253 break; |
254 case WE_PAINT: { |
254 case WE_PAINT: { |
255 uint i; |
255 uint i; |
256 int y = WP(w, scroller_d).height; |
256 int y = WP(w, scroller_d).height; |
257 w->DrawWidgets(); |
257 w->DrawWidgets(); |
260 DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0); |
260 DrawStringCentered(210, 17, STR_00B6_ORIGINAL_COPYRIGHT, 0); |
261 DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, 0); |
261 DrawStringCentered(210, 17 + 10, STR_00B7_VERSION, 0); |
262 |
262 |
263 // Show all scrolling credits |
263 // Show all scrolling credits |
264 for (i = 0; i < lengthof(credits); i++) { |
264 for (i = 0; i < lengthof(credits); i++) { |
265 if (y >= 50 && y < (w->height - 40)) { |
265 if (y >= 50 && y < (w->Height() - 40)) { |
266 DoDrawString(credits[i], 10, y, 0x10); |
266 DoDrawString(credits[i], 10, y, 0x10); |
267 } |
267 } |
268 y += 10; |
268 y += 10; |
269 } |
269 } |
270 |
270 |
271 // If the last text has scrolled start anew from the start |
271 // If the last text has scrolled start anew from the start |
272 if (y < 50) WP(w, scroller_d).height = w->height - 40; |
272 if (y < 50) WP(w, scroller_d).height = w->Height() - 40; |
273 |
273 |
274 DoDrawStringCentered(210, w->height - 25, "Website: http://www.openttd.org", 16); |
274 DoDrawStringCentered(210, w->Height() - 25, "Website: http://www.openttd.org", 16); |
275 DrawStringCentered(210, w->height - 15, STR_00BA_COPYRIGHT_OPENTTD, 0); |
275 DrawStringCentered(210, w->Height() - 15, STR_00BA_COPYRIGHT_OPENTTD, 0); |
276 } break; |
276 } break; |
277 case WE_MOUSELOOP: /* Timer to scroll the text and adjust the new top */ |
277 case WE_MOUSELOOP: /* Timer to scroll the text and adjust the new top */ |
278 if (WP(w, scroller_d).counter++ % 3 == 0) { |
278 if (WP(w, scroller_d).counter++ % 3 == 0) { |
279 WP(w, scroller_d).height--; |
279 WP(w, scroller_d).height--; |
280 w->SetDirty(); |
280 w->SetDirty(); |
647 static void TooltipsWndProc(BaseWindow *w, WindowEvent *e) |
647 static void TooltipsWndProc(BaseWindow *w, WindowEvent *e) |
648 { |
648 { |
649 switch (e->event) { |
649 switch (e->event) { |
650 case WE_PAINT: { |
650 case WE_PAINT: { |
651 uint arg; |
651 uint arg; |
652 GfxFillRect(0, 0, w->width - 1, w->height - 1, 0); |
652 GfxFillRect(0, 0, w->Width() - 1, w->Height() - 1, 0); |
653 GfxFillRect(1, 1, w->width - 2, w->height - 2, 0x44); |
653 GfxFillRect(1, 1, w->Width() - 2, w->Height() - 2, 0x44); |
654 |
654 |
655 for (arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) { |
655 for (arg = 0; arg < WP(w, tooltips_d).paramcount; arg++) { |
656 SetDParam(arg, WP(w, tooltips_d).params[arg]); |
656 SetDParam(arg, WP(w, tooltips_d).params[arg]); |
657 } |
657 } |
658 DrawStringMultiCenter((w->width >> 1), (w->height >> 1) - 5, WP(w, tooltips_d).string_id, 197); |
658 DrawStringMultiCenter((w->Width() >> 1), (w->Height() >> 1) - 5, WP(w, tooltips_d).string_id, 197); |
659 break; |
659 break; |
660 } |
660 } |
661 |
661 |
662 case WE_MOUSELOOP: |
662 case WE_MOUSELOOP: |
663 /* We can show tooltips while dragging tools. These are shown as long as |
663 /* We can show tooltips while dragging tools. These are shown as long as |
1206 case WE_PAINT: |
1206 case WE_PAINT: |
1207 COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
1207 COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
1208 w->DrawWidgets(); |
1208 w->DrawWidgets(); |
1209 COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
1209 COPY_IN_DPARAM(0, q->params, lengthof(q->params)); |
1210 |
1210 |
1211 DrawStringMultiCenter(w->width / 2, (w->height / 2) - 10, q->message, w->width); |
1211 DrawStringMultiCenter(w->Width() / 2, (w->Height() / 2) - 10, q->message, w->Width()); |
1212 break; |
1212 break; |
1213 |
1213 |
1214 case WE_CLICK: |
1214 case WE_CLICK: |
1215 switch (e->we.click.widget) { |
1215 switch (e->we.click.widget) { |
1216 case QUERY_WIDGET_YES: |
1216 case QUERY_WIDGET_YES: |
1278 BaseWindow *w = BaseWindow::Allocate(&_query_desc); |
1278 BaseWindow *w = BaseWindow::Allocate(&_query_desc); |
1279 if (w == NULL) return; |
1279 if (w == NULL) return; |
1280 |
1280 |
1281 if (parent == NULL) parent = BaseWindow::FindById(WC_MAIN_WINDOW, 0); |
1281 if (parent == NULL) parent = BaseWindow::FindById(WC_MAIN_WINDOW, 0); |
1282 w->parent = parent; |
1282 w->parent = parent; |
1283 w->left = parent->left + (parent->width / 2) - (w->width / 2); |
1283 /* Center window to the center of parent */ |
1284 w->top = parent->top + (parent->height / 2) - (w->height / 2); |
1284 w->SetTopLeft(parent->TopLeft() + (parent->Size() - w->Size()) / 2); |
|
1285 |
1285 |
1286 |
1286 /* Create a backup of the variadic arguments to strings because it will be |
1287 /* Create a backup of the variadic arguments to strings because it will be |
1287 * overridden pretty often. We will copy these back for drawing */ |
1288 * overridden pretty often. We will copy these back for drawing */ |
1288 COPY_OUT_DPARAM(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); |
1289 COPY_OUT_DPARAM(WP(w, query_d).params, 0, lengthof(WP(w, query_d).params)); |
1289 w->widget[QUERY_WIDGET_CAPTION].data = caption; |
1290 w->widget[QUERY_WIDGET_CAPTION].data = caption; |
1431 int pos; |
1432 int pos; |
1432 int y; |
1433 int y; |
1433 |
1434 |
1434 SetVScrollCount(w, _fios_num); |
1435 SetVScrollCount(w, _fios_num); |
1435 w->DrawWidgets(); |
1436 w->DrawWidgets(); |
1436 DrawFiosTexts(w->width); |
1437 DrawFiosTexts(w->Width()); |
1437 |
1438 |
1438 if (_savegame_sort_dirty) { |
1439 if (_savegame_sort_dirty) { |
1439 _savegame_sort_dirty = false; |
1440 _savegame_sort_dirty = false; |
1440 MakeSortedSaveGameList(); |
1441 MakeSortedSaveGameList(); |
1441 } |
1442 } |
1449 |
1450 |
1450 y = w->widget[7].top + 1; |
1451 y = w->widget[7].top + 1; |
1451 for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
1452 for (pos = w->vscroll.pos; pos < _fios_num; pos++) { |
1452 const FiosItem *item = _fios_list + pos; |
1453 const FiosItem *item = _fios_list + pos; |
1453 |
1454 |
1454 DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->width - 18); |
1455 DoDrawStringTruncated(item->title, 4, y, _fios_colors[item->type], w->Width() - 18); |
1455 y += 10; |
1456 y += 10; |
1456 if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
1457 if (y >= w->vscroll.cap * 10 + w->widget[7].top + 1) break; |
1457 } |
1458 } |
1458 |
1459 |
1459 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
1460 if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { |
1642 w = BaseWindow::Allocate(sld); |
1643 w = BaseWindow::Allocate(sld); |
1643 w->widget[1].data = saveload_captions[mode]; |
1644 w->widget[1].data = saveload_captions[mode]; |
1644 w->vscroll.cap = 24; |
1645 w->vscroll.cap = 24; |
1645 w->resize.step_width = 2; |
1646 w->resize.step_width = 2; |
1646 w->resize.step_height = 10; |
1647 w->resize.step_height = 10; |
1647 w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
1648 w->resize.height = w->Height() - 14 * 10; // Minimum of 10 items |
1648 w->LowerWidget(7); |
1649 w->LowerWidget(7); |
1649 |
1650 |
1650 WP(w, querystr_d).afilter = CS_ALPHANUMERAL; |
1651 WP(w, querystr_d).afilter = CS_ALPHANUMERAL; |
1651 InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240); |
1652 InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 240); |
1652 |
1653 |