62 if (_landinfo_data[5][0] != '\0') DrawStringMultiCenter(140, 76, BindCString(_landinfo_data[5]), 276); |
62 if (_landinfo_data[5][0] != '\0') DrawStringMultiCenter(140, 76, BindCString(_landinfo_data[5]), 276); |
63 if (_landinfo_data[6][0] != '\0') DoDrawStringCentered(140, 71, _landinfo_data[6], 0); |
63 if (_landinfo_data[6][0] != '\0') DoDrawStringCentered(140, 71, _landinfo_data[6], 0); |
64 } |
64 } |
65 } |
65 } |
66 |
66 |
67 static const Widget _land_info_widgets[] = { |
67 static const OldWidget _land_info_widgets[] = { |
68 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
68 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
69 { WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
69 { WWT_CAPTION, RESIZE_NONE, 14, 11, 279, 0, 13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
70 { WWT_PANEL, RESIZE_NONE, 14, 0, 279, 14, 92, 0x0, STR_NULL}, |
70 { WWT_PANEL, RESIZE_NONE, 14, 0, 279, 14, 92, 0x0, STR_NULL}, |
71 { WIDGETS_END}, |
71 { WIDGETS_END}, |
72 }; |
72 }; |
281 } |
281 } |
282 break; |
282 break; |
283 } |
283 } |
284 } |
284 } |
285 |
285 |
286 static const Widget _about_widgets[] = { |
286 static const OldWidget _about_widgets[] = { |
287 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
287 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
288 { WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
288 { WWT_CAPTION, RESIZE_NONE, 14, 11, 419, 0, 13, STR_015B_OPENTTD, STR_NULL}, |
289 { WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
289 { WWT_PANEL, RESIZE_NONE, 14, 0, 419, 14, 271, 0x0, STR_NULL}, |
290 { WWT_FRAME, RESIZE_NONE, 14, 5, 414, 40, 245, STR_NULL, STR_NULL}, |
290 { WWT_FRAME, RESIZE_NONE, 14, 5, 414, 40, 245, STR_NULL, STR_NULL}, |
291 { WIDGETS_END}, |
291 { WIDGETS_END}, |
319 { 0x75F, PAL_NONE }, { 0x774, PAL_NONE }, { 0x720, PAL_NONE }, { 0x797, PAL_NONE }, |
319 { 0x75F, PAL_NONE }, { 0x774, PAL_NONE }, { 0x720, PAL_NONE }, { 0x797, PAL_NONE }, |
320 { 0x79E, PAL_NONE }, { 0x7A5, PALETTE_TO_GREEN }, { 0x7AC, PALETTE_TO_RED }, { 0x7B3, PAL_NONE }, |
320 { 0x79E, PAL_NONE }, { 0x7A5, PALETTE_TO_GREEN }, { 0x7AC, PALETTE_TO_RED }, { 0x7B3, PAL_NONE }, |
321 { 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED } |
321 { 0x7BA, PAL_NONE }, { 0x7C1, PALETTE_TO_RED, }, { 0x7C8, PALETTE_TO_PALE_GREEN }, { 0x7CF, PALETTE_TO_YELLOW }, { 0x7D6, PALETTE_TO_RED } |
322 }; |
322 }; |
323 |
323 |
324 static void BuildTreesWndProc(Window *w, WindowEvent *e) |
324 static void BuildTreesWndProc(BaseWindow *w, WindowEvent *e) |
325 { |
325 { |
326 switch (e->event) { |
326 switch (e->event) { |
327 case WE_PAINT: { |
327 case WE_PAINT: { |
328 int x,y; |
328 int x,y; |
329 int i, count; |
329 int i, count; |
401 w->RaiseButtons(); |
401 w->RaiseButtons(); |
402 break; |
402 break; |
403 } |
403 } |
404 } |
404 } |
405 |
405 |
406 static const Widget _build_trees_widgets[] = { |
406 static const OldWidget _build_trees_widgets[] = { |
407 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
407 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
408 { WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
408 { WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
409 { WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 170, 0x0, STR_NULL}, |
409 { WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 170, 0x0, STR_NULL}, |
410 { WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
410 { WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
411 { WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
411 { WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
429 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
429 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
430 _build_trees_widgets, |
430 _build_trees_widgets, |
431 BuildTreesWndProc |
431 BuildTreesWndProc |
432 }; |
432 }; |
433 |
433 |
434 static const Widget _build_trees_scen_widgets[] = { |
434 static const OldWidget _build_trees_scen_widgets[] = { |
435 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
435 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
436 { WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
436 { WWT_CAPTION, RESIZE_NONE, 7, 11, 142, 0, 13, STR_2802_TREES, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
437 { WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 183, 0x0, STR_NULL}, |
437 { WWT_PANEL, RESIZE_NONE, 7, 0, 142, 14, 183, 0x0, STR_NULL}, |
438 { WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
438 { WWT_PANEL, RESIZE_NONE, 14, 2, 35, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
439 { WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
439 { WWT_PANEL, RESIZE_NONE, 14, 37, 70, 16, 61, 0x0, STR_280D_SELECT_TREE_TYPE_TO_PLANT}, |
462 |
462 |
463 |
463 |
464 void ShowBuildTreesToolbar(void) |
464 void ShowBuildTreesToolbar(void) |
465 { |
465 { |
466 if (!IsValidPlayer(_current_player)) return; |
466 if (!IsValidPlayer(_current_player)) return; |
467 AllocateWindowDescFront(&_build_trees_desc, 0); |
467 BaseWindow::AllocateFront(&_build_trees_desc, 0); |
468 } |
468 } |
469 |
469 |
470 void ShowBuildTreesScenToolbar(void) |
470 void ShowBuildTreesScenToolbar(void) |
471 { |
471 { |
472 AllocateWindowDescFront(&_build_trees_scen_desc, 0); |
472 BaseWindow::AllocateFront(&_build_trees_scen_desc, 0); |
473 } |
473 } |
474 |
474 |
475 static uint32 _errmsg_decode_params[20]; |
475 static uint32 _errmsg_decode_params[20]; |
476 static StringID _errmsg_message_1, _errmsg_message_2; |
476 static StringID _errmsg_message_1, _errmsg_message_2; |
477 static uint _errmsg_duration; |
477 static uint _errmsg_duration; |
478 |
478 |
479 |
479 |
480 static const Widget _errmsg_widgets[] = { |
480 static const OldWidget _errmsg_widgets[] = { |
481 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
481 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
482 { WWT_CAPTION, RESIZE_NONE, 4, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL}, |
482 { WWT_CAPTION, RESIZE_NONE, 4, 11, 239, 0, 13, STR_00B2_MESSAGE, STR_NULL}, |
483 { WWT_PANEL, RESIZE_NONE, 4, 0, 239, 14, 45, 0x0, STR_NULL}, |
483 { WWT_PANEL, RESIZE_NONE, 4, 0, 239, 14, 45, 0x0, STR_NULL}, |
484 { WIDGETS_END}, |
484 { WIDGETS_END}, |
485 }; |
485 }; |
486 |
486 |
487 static const Widget _errmsg_face_widgets[] = { |
487 static const OldWidget _errmsg_face_widgets[] = { |
488 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
488 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
489 { WWT_CAPTION, RESIZE_NONE, 4, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL}, |
489 { WWT_CAPTION, RESIZE_NONE, 4, 11, 333, 0, 13, STR_00B3_MESSAGE_FROM, STR_NULL}, |
490 { WWT_PANEL, RESIZE_NONE, 4, 0, 333, 14, 136, 0x0, STR_NULL}, |
490 { WWT_PANEL, RESIZE_NONE, 4, 0, 333, 14, 136, 0x0, STR_NULL}, |
491 { WIDGETS_END}, |
491 { WIDGETS_END}, |
492 }; |
492 }; |
493 |
493 |
494 static void ErrmsgWndProc(Window *w, WindowEvent *e) |
494 static void ErrmsgWndProc(BaseWindow *w, WindowEvent *e) |
495 { |
495 { |
496 switch (e->event) { |
496 switch (e->event) { |
497 case WE_PAINT: |
497 case WE_PAINT: |
498 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
498 COPY_IN_DPARAM(0, _errmsg_decode_params, lengthof(_errmsg_decode_params)); |
499 w->DrawWidgets(); |
499 w->DrawWidgets(); |
584 |
584 |
585 } else { |
585 } else { |
586 pt.x = (_screen.width - 240) >> 1; |
586 pt.x = (_screen.width - 240) >> 1; |
587 pt.y = (_screen.height - 46) >> 1; |
587 pt.y = (_screen.height - 46) >> 1; |
588 } |
588 } |
589 w = Window::Allocate(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
589 w = BaseWindow::Allocate(pt.x, pt.y, 240, 46, ErrmsgWndProc, WC_ERRMSG, _errmsg_widgets); |
590 } else { |
590 } else { |
591 if ( (x|y) != 0) { |
591 if ( (x|y) != 0) { |
592 pt = RemapCoords2(x, y); |
592 pt = RemapCoords2(x, y); |
593 vp = Window::FindById(WC_MAIN_WINDOW, 0)->viewport; |
593 vp = BaseWindow::FindById(WC_MAIN_WINDOW, 0)->viewport; |
594 pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
594 pt.x = clamp(((pt.x - vp->virtual_left) >> vp->zoom) + vp->left - (334/2), 0, _screen.width - 334); |
595 pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
595 pt.y = clamp(((pt.y - vp->virtual_top) >> vp->zoom) + vp->top - (137/2), 22, _screen.height - 137); |
596 } else { |
596 } else { |
597 pt.x = (_screen.width - 334) >> 1; |
597 pt.x = (_screen.width - 334) >> 1; |
598 pt.y = (_screen.height - 137) >> 1; |
598 pt.y = (_screen.height - 137) >> 1; |
599 } |
599 } |
600 w = Window::Allocate(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
600 w = BaseWindow::Allocate(pt.x, pt.y, 334, 137, ErrmsgWndProc, WC_ERRMSG, _errmsg_face_widgets); |
601 } |
601 } |
602 |
602 |
603 w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
603 w->desc_flags = WDF_STD_BTN | WDF_DEF_WIDGET; |
604 } |
604 } |
605 |
605 |
636 |
636 |
637 SetDParam(0, cost); |
637 SetDParam(0, cost); |
638 AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250); |
638 AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250); |
639 } |
639 } |
640 |
640 |
641 static const Widget _tooltips_widgets[] = { |
641 static const OldWidget _tooltips_widgets[] = { |
642 { WWT_PANEL, RESIZE_NONE, 14, 0, 199, 0, 31, 0x0, STR_NULL}, |
642 { WWT_PANEL, RESIZE_NONE, 14, 0, 199, 0, 31, 0x0, STR_NULL}, |
643 { WIDGETS_END}, |
643 { WIDGETS_END}, |
644 }; |
644 }; |
645 |
645 |
646 |
646 |
647 static void TooltipsWndProc(Window *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); |
706 * go below window, flip it so it is shown above the cursor */ |
706 * go below window, flip it so it is shown above the cursor */ |
707 y = clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); |
707 y = clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); |
708 if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; |
708 if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; |
709 x = clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); |
709 x = clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); |
710 |
710 |
711 w = Window::Allocate(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
711 w = BaseWindow::Allocate(x, y, br.width, br.height, TooltipsWndProc, WC_TOOLTIPS, _tooltips_widgets); |
712 |
712 |
713 WP(w, tooltips_d).string_id = str; |
713 WP(w, tooltips_d).string_id = str; |
714 assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0])); |
714 assert(sizeof(WP(w, tooltips_d).params[0]) == sizeof(params[0])); |
715 memcpy(WP(w, tooltips_d).params, params, sizeof(WP(w, tooltips_d).params[0]) * paramcount); |
715 memcpy(WP(w, tooltips_d).params, params, sizeof(WP(w, tooltips_d).params[0]) * paramcount); |
716 WP(w, tooltips_d).paramcount = paramcount; |
716 WP(w, tooltips_d).paramcount = paramcount; |
758 GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
758 GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
759 DrawStationCoverageText(accepts, sx, sy, mask); |
759 DrawStationCoverageText(accepts, sx, sy, mask); |
760 } |
760 } |
761 } |
761 } |
762 |
762 |
763 void CheckRedrawStationCoverage(const Window *w) |
763 void CheckRedrawStationCoverage(const BaseWindow *w) |
764 { |
764 { |
765 if (_thd.dirty & 1) { |
765 if (_thd.dirty & 1) { |
766 _thd.dirty &= ~1; |
766 _thd.dirty &= ~1; |
767 w->SetDirty(); |
767 w->SetDirty(); |
768 } |
768 } |
769 } |
769 } |
770 |
770 |
771 void SetVScrollCount(Window *w, int num) |
771 void SetVScrollCount(BaseWindow *w, int num) |
772 { |
772 { |
773 w->vscroll.count = num; |
773 w->vscroll.count = num; |
774 num -= w->vscroll.cap; |
774 num -= w->vscroll.cap; |
775 if (num < 0) num = 0; |
775 if (num < 0) num = 0; |
776 if (num < w->vscroll.pos) w->vscroll.pos = num; |
776 if (num < w->vscroll.pos) w->vscroll.pos = num; |
777 } |
777 } |
778 |
778 |
779 void SetVScroll2Count(Window *w, int num) |
779 void SetVScroll2Count(BaseWindow *w, int num) |
780 { |
780 { |
781 w->vscroll2.count = num; |
781 w->vscroll2.count = num; |
782 num -= w->vscroll2.cap; |
782 num -= w->vscroll2.cap; |
783 if (num < 0) num = 0; |
783 if (num < 0) num = 0; |
784 if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
784 if (num < w->vscroll2.pos) w->vscroll2.pos = num; |
785 } |
785 } |
786 |
786 |
787 void SetHScrollCount(Window *w, int num) |
787 void SetHScrollCount(BaseWindow *w, int num) |
788 { |
788 { |
789 w->hscroll.count = num; |
789 w->hscroll.count = num; |
790 num -= w->hscroll.cap; |
790 num -= w->hscroll.cap; |
791 if (num < 0) num = 0; |
791 if (num < 0) num = 0; |
792 if (num < w->hscroll.pos) w->hscroll.pos = num; |
792 if (num < w->hscroll.pos) w->hscroll.pos = num; |
1008 return true; |
1008 return true; |
1009 } |
1009 } |
1010 return false; |
1010 return false; |
1011 } |
1011 } |
1012 |
1012 |
1013 void HandleEditBox(Window *w, querystr_d *string, int wid) |
1013 void HandleEditBox(BaseWindow *w, querystr_d *string, int wid) |
1014 { |
1014 { |
1015 if (HandleCaret(&string->text)) w->InvalidateWidget(wid); |
1015 if (HandleCaret(&string->text)) w->InvalidateWidget(wid); |
1016 } |
1016 } |
1017 |
1017 |
1018 void DrawEditBox(Window *w, querystr_d *string, int wid) |
1018 void DrawEditBox(BaseWindow *w, querystr_d *string, int wid) |
1019 { |
1019 { |
1020 DrawPixelInfo dpi, *old_dpi; |
1020 DrawPixelInfo dpi, *old_dpi; |
1021 int delta; |
1021 int delta; |
1022 const Widget *wi = &w->widget[wid]; |
1022 const OldWidget *wi = &w->widget[wid]; |
1023 const Textbuf *tb = &string->text; |
1023 const Textbuf *tb = &string->text; |
1024 |
1024 |
1025 GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215); |
1025 GfxFillRect(wi->left + 1, wi->top + 1, wi->right - 1, wi->bottom - 1, 215); |
1026 |
1026 |
1027 /* Limit the drawing of the string inside the widget boundaries */ |
1027 /* Limit the drawing of the string inside the widget boundaries */ |
1109 break; |
1109 break; |
1110 |
1110 |
1111 case WE_DESTROY: /* Call cancellation of query, if we have not handled it before */ |
1111 case WE_DESTROY: /* Call cancellation of query, if we have not handled it before */ |
1112 if (!qs->handled && w->parent != NULL) { |
1112 if (!qs->handled && w->parent != NULL) { |
1113 WindowEvent e; |
1113 WindowEvent e; |
1114 Window *parent = w->parent; |
1114 BaseWindow *parent = w->parent; |
1115 |
1115 |
1116 qs->handled = true; |
1116 qs->handled = true; |
1117 e.event = WE_ON_EDIT_TEXT_CANCEL; |
1117 e.event = WE_ON_EDIT_TEXT_CANCEL; |
1118 parent->wndproc(parent, &e); |
1118 parent->wndproc(parent, &e); |
1119 } |
1119 } |
1120 CLRBIT(_no_scroll, SCROLL_EDIT); |
1120 CLRBIT(_no_scroll, SCROLL_EDIT); |
1121 break; |
1121 break; |
1122 } |
1122 } |
1123 } |
1123 } |
1124 |
1124 |
1125 static const Widget _query_string_widgets[] = { |
1125 static const OldWidget _query_string_widgets[] = { |
1126 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1126 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1127 { WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, |
1127 { WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL}, |
1128 { WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, |
1128 { WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, 0x0, STR_NULL}, |
1129 { WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, |
1129 { WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, 0x0, STR_NULL}, |
1130 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, |
1130 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 129, 30, 41, STR_012E_CANCEL, STR_NULL}, |
1146 * @param str StringID for the text shown in the textbox |
1146 * @param str StringID for the text shown in the textbox |
1147 * @param caption StringID of text shown in caption of querywindow |
1147 * @param caption StringID of text shown in caption of querywindow |
1148 * @param maxlen maximum length in characters allowed. If bit 12 is set we |
1148 * @param maxlen maximum length in characters allowed. If bit 12 is set we |
1149 * will not check the resulting string against to original string to return success |
1149 * will not check the resulting string against to original string to return success |
1150 * @param maxwidth maximum width in pixels allowed |
1150 * @param maxwidth maximum width in pixels allowed |
1151 * @param parent pointer to a Window that will handle the events (ok/cancel) of this |
1151 * @param parent pointer to a BaseWindow that will handle the events (ok/cancel) of this |
1152 * window. If NULL, results are handled by global function HandleOnEditText |
1152 * window. If NULL, results are handled by global function HandleOnEditText |
1153 * @param afilter filters out unwanted character input */ |
1153 * @param afilter filters out unwanted character input */ |
1154 void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter) |
1154 void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, BaseWindow *parent, CharSetFilter afilter) |
1155 { |
1155 { |
1156 static char orig_str_buf[lengthof(_edit_str_buf)]; |
1156 static char orig_str_buf[lengthof(_edit_str_buf)]; |
1157 Window *w; |
1157 BaseWindow *w; |
1158 uint realmaxlen = maxlen & ~0x1000; |
1158 uint realmaxlen = maxlen & ~0x1000; |
1159 |
1159 |
1160 assert(realmaxlen < lengthof(_edit_str_buf)); |
1160 assert(realmaxlen < lengthof(_edit_str_buf)); |
1161 |
1161 |
1162 DeleteWindowById(WC_QUERY_STRING, 0); |
1162 DeleteWindowById(WC_QUERY_STRING, 0); |
1163 DeleteWindowById(WC_SAVELOAD, 0); |
1163 DeleteWindowById(WC_SAVELOAD, 0); |
1164 |
1164 |
1165 w = AllocateWindowDesc(&_query_string_desc); |
1165 w = BaseWindow::Allocate(&_query_string_desc); |
1166 w->parent = parent; |
1166 w->parent = parent; |
1167 |
1167 |
1168 GetString(_edit_str_buf, str, lastof(_edit_str_buf)); |
1168 GetString(_edit_str_buf, str, lastof(_edit_str_buf)); |
1169 _edit_str_buf[realmaxlen - 1] = '\0'; |
1169 _edit_str_buf[realmaxlen - 1] = '\0'; |
1170 |
1170 |
1188 QUERY_WIDGET_YES |
1188 QUERY_WIDGET_YES |
1189 }; |
1189 }; |
1190 |
1190 |
1191 |
1191 |
1192 typedef struct query_d { |
1192 typedef struct query_d { |
1193 void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise |
1193 void (*proc)(BaseWindow*, bool); ///< callback function executed on closing of popup. BaseWindow* points to parent, bool is true if 'yes' clicked, false otherwise |
1194 StringID message; ///< message shown for query window |
1194 StringID message; ///< message shown for query window |
1195 uint32 params[20]; ///< local copy of _decode_parameters |
1195 uint32 params[20]; ///< local copy of _decode_parameters |
1196 bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) |
1196 bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) |
1197 } query_d; |
1197 } query_d; |
1198 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); |
1198 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); |
1199 |
1199 |
1200 |
1200 |
1201 static void QueryWndProc(Window *w, WindowEvent *e) |
1201 static void QueryWndProc(BaseWindow *w, WindowEvent *e) |
1202 { |
1202 { |
1203 query_d *q = &WP(w, query_d); |
1203 query_d *q = &WP(w, query_d); |
1204 |
1204 |
1205 switch (e->event) { |
1205 switch (e->event) { |
1206 case WE_PAINT: |
1206 case WE_PAINT: |
1245 break; |
1245 break; |
1246 } |
1246 } |
1247 } |
1247 } |
1248 |
1248 |
1249 |
1249 |
1250 static const Widget _query_widgets[] = { |
1250 static const OldWidget _query_widgets[] = { |
1251 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1251 { WWT_CLOSEBOX, RESIZE_NONE, 4, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1252 { WWT_CAPTION, RESIZE_NONE, 4, 11, 209, 0, 13, STR_NULL, STR_NULL}, |
1252 { WWT_CAPTION, RESIZE_NONE, 4, 11, 209, 0, 13, STR_NULL, STR_NULL}, |
1253 { WWT_PANEL, RESIZE_NONE, 4, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL}, |
1253 { WWT_PANEL, RESIZE_NONE, 4, 0, 209, 14, 81, 0x0, /*OVERRIDE*/STR_NULL}, |
1254 {WWT_PUSHTXTBTN, RESIZE_NONE, 3, 20, 90, 62, 73, STR_00C9_NO, STR_NULL}, |
1254 {WWT_PUSHTXTBTN, RESIZE_NONE, 3, 20, 90, 62, 73, STR_00C9_NO, STR_NULL}, |
1255 {WWT_PUSHTXTBTN, RESIZE_NONE, 3, 120, 190, 62, 73, STR_00C8_YES, STR_NULL}, |
1255 {WWT_PUSHTXTBTN, RESIZE_NONE, 3, 120, 190, 62, 73, STR_00C8_YES, STR_NULL}, |
1271 * @param message string that will be shown for the window |
1271 * @param message string that will be shown for the window |
1272 * @param parent pointer to parent window, if this pointer is NULL the parent becomes |
1272 * @param parent pointer to parent window, if this pointer is NULL the parent becomes |
1273 * the main window WC_MAIN_WINDOW |
1273 * the main window WC_MAIN_WINDOW |
1274 * @param x,y coordinates to show the window at |
1274 * @param x,y coordinates to show the window at |
1275 * @param yes_no_callback callback function called when window is closed through any button */ |
1275 * @param yes_no_callback callback function called when window is closed through any button */ |
1276 void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) |
1276 void ShowQuery(StringID caption, StringID message, BaseWindow *parent, void (*callback)(BaseWindow*, bool)) |
1277 { |
1277 { |
1278 Window *w = AllocateWindowDesc(&_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 = Window::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 w->left = parent->left + (parent->width / 2) - (w->width / 2); |
1284 w->top = parent->top + (parent->height / 2) - (w->height / 2); |
1284 w->top = parent->top + (parent->height / 2) - (w->height / 2); |
1285 |
1285 |
1286 /* Create a backup of the variadic arguments to strings because it will be |
1286 /* Create a backup of the variadic arguments to strings because it will be |
1291 WP(w, query_d).proc = callback; |
1291 WP(w, query_d).proc = callback; |
1292 WP(w, query_d).calledback = false; |
1292 WP(w, query_d).calledback = false; |
1293 } |
1293 } |
1294 |
1294 |
1295 |
1295 |
1296 static const Widget _load_dialog_widgets[] = { |
1296 static const OldWidget _load_dialog_widgets[] = { |
1297 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1297 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1298 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1298 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1299 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
1299 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
1300 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
1300 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
1301 { WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
1301 { WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
1305 { WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 281, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1305 { WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 281, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1306 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 282, 293, 0x0, STR_RESIZE_BUTTON}, |
1306 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 282, 293, 0x0, STR_RESIZE_BUTTON}, |
1307 { WIDGETS_END}, |
1307 { WIDGETS_END}, |
1308 }; |
1308 }; |
1309 |
1309 |
1310 static const Widget _save_dialog_widgets[] = { |
1310 static const OldWidget _save_dialog_widgets[] = { |
1311 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1311 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1312 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1312 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 256, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1313 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
1313 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 127, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
1314 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
1314 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 128, 256, 14, 25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP}, |
1315 { WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
1315 { WWT_PANEL, RESIZE_RIGHT, 14, 0, 256, 26, 47, 0x0, STR_NULL}, |
1637 case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
1637 case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break; |
1638 default: sld = &_load_dialog_desc; break; |
1638 default: sld = &_load_dialog_desc; break; |
1639 } |
1639 } |
1640 |
1640 |
1641 assert((uint)mode < lengthof(saveload_captions)); |
1641 assert((uint)mode < lengthof(saveload_captions)); |
1642 w = AllocateWindowDesc(sld); |
1642 w = BaseWindow::Allocate(sld); |
1643 w->widget[1].data = saveload_captions[mode]; |
1643 w->widget[1].data = saveload_captions[mode]; |
1644 w->vscroll.cap = 24; |
1644 w->vscroll.cap = 24; |
1645 w->resize.step_width = 2; |
1645 w->resize.step_width = 2; |
1646 w->resize.step_height = 10; |
1646 w->resize.step_height = 10; |
1647 w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
1647 w->resize.height = w->height - 14 * 10; // Minimum of 10 items |
1778 {SLE_UINT8, {CE_NONE}, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat,-1, 4}, |
1778 {SLE_UINT8, {CE_NONE}, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat,-1, 4}, |
1779 {SLE_INT32, {CE_NONE}, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1}, |
1779 {SLE_INT32, {CE_NONE}, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1}, |
1780 }; |
1780 }; |
1781 |
1781 |
1782 |
1782 |
1783 static const Widget _cheat_widgets[] = { |
1783 static const OldWidget _cheat_widgets[] = { |
1784 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1784 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1785 { WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1785 { WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1786 { WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL}, |
1786 { WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL}, |
1787 { WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP}, |
1787 { WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP}, |
1788 { WIDGETS_END}, |
1788 { WIDGETS_END}, |
1789 }; |
1789 }; |
1790 |
1790 |
1791 static void CheatsWndProc(Window *w, WindowEvent *e) |
1791 static void CheatsWndProc(BaseWindow *w, WindowEvent *e) |
1792 { |
1792 { |
1793 switch (e->event) { |
1793 switch (e->event) { |
1794 case WE_PAINT: { |
1794 case WE_PAINT: { |
1795 int clk = WP(w,def_d).data_1; |
1795 int clk = WP(w,def_d).data_1; |
1796 int x, y; |
1796 int x, y; |