257 WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) |
257 WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) |
258 WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar |
258 WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar |
259 WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar |
259 WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar |
260 }; |
260 }; |
261 |
261 |
262 typedef struct Textbuf { |
262 struct Textbuf { |
263 char *buf; ///< buffer in which text is saved |
263 char *buf; ///< buffer in which text is saved |
264 uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes |
264 uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes |
265 uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes |
265 uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes |
266 bool caret; ///< is the caret ("_") visible or not |
266 bool caret; ///< is the caret ("_") visible or not |
267 uint16 caretpos; ///< the current position of the caret in the buffer, in bytes |
267 uint16 caretpos; ///< the current position of the caret in the buffer, in bytes |
268 uint16 caretxoffs; ///< the current position of the caret in pixels |
268 uint16 caretxoffs; ///< the current position of the caret in pixels |
269 } Textbuf; |
269 }; |
270 |
270 |
271 #define WP(ptr,str) (*(str*)(ptr)->custom) |
271 #define WP(ptr,str) (*(str*)(ptr)->custom) |
272 /* You cannot 100% reliably calculate the biggest custom struct as |
272 /* You cannot 100% reliably calculate the biggest custom struct as |
273 * the number of pointers in it and alignment will have a huge impact. |
273 * the number of pointers in it and alignment will have a huge impact. |
274 * 96 is the largest window-size for 64-bit machines currently */ |
274 * 96 is the largest window-size for 64-bit machines currently */ |
275 #define WINDOW_CUSTOM_SIZE 96 |
275 #define WINDOW_CUSTOM_SIZE 96 |
276 |
276 |
277 typedef struct Scrollbar { |
277 struct Scrollbar { |
278 uint16 count, cap, pos; |
278 uint16 count, cap, pos; |
279 } Scrollbar; |
279 }; |
280 |
280 |
281 typedef struct ResizeInfo { |
281 struct ResizeInfo { |
282 uint width; ///< Minimum width and height |
282 uint width; ///< Minimum width and height |
283 uint height; |
283 uint height; |
284 uint step_width; ///< In how big steps the width and height go |
284 uint step_width; ///< In how big steps the width and height go |
285 uint step_height; |
285 uint step_height; |
286 } ResizeInfo; |
286 }; |
287 |
287 |
288 typedef struct WindowMessage { |
288 struct WindowMessage { |
289 int msg; |
289 int msg; |
290 int wparam; |
290 int wparam; |
291 int lparam; |
291 int lparam; |
292 } WindowMessage; |
292 }; |
293 |
293 |
294 struct OldWidget { |
294 struct OldWidget { |
295 WindowWidgetTypes type; ///< OldWidget type, see @WindowWidgetTypes |
295 WindowWidgetTypes type; ///< OldWidget type, see @WindowWidgetTypes |
296 byte m_display_flags; ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags |
296 byte m_display_flags; ///< Resize direction, alignment, etc. during resizing, see @ResizeFlags |
297 byte color; ///< OldWidget colour, see docs/ottd-colourtext-palette.png |
297 byte color; ///< OldWidget colour, see docs/ottd-colourtext-palette.png |
600 |
600 |
601 #define REVERSED_FOR_ALL_WINDOWS(wz) \ |
601 #define REVERSED_FOR_ALL_WINDOWS(wz) \ |
602 for (WindowList::ReverseIterator it = BaseWindow::s_list.m_list.rbegin(); it != BaseWindow::s_list.m_list.rend() && (wz = (*it).w) != NULL; it++) |
602 for (WindowList::ReverseIterator it = BaseWindow::s_list.m_list.rbegin(); it != BaseWindow::s_list.m_list.rend() && (wz = (*it).w) != NULL; it++) |
603 |
603 |
604 |
604 |
605 typedef struct querystr_d { |
605 struct querystr_d { |
606 StringID caption; |
606 StringID caption; |
607 Textbuf text; |
607 Textbuf text; |
608 const char *orig; |
608 const char *orig; |
609 CharSetFilter afilter; |
609 CharSetFilter afilter; |
610 bool handled; |
610 bool handled; |
611 } querystr_d; |
611 }; |
612 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); |
612 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); |
613 |
613 |
614 typedef struct { |
614 struct menu_d { |
615 byte item_count; ///< follow_vehicle |
615 byte item_count; ///< follow_vehicle |
616 byte sel_index; ///< scrollpos_x |
616 byte sel_index; ///< scrollpos_x |
617 byte main_button; ///< scrollpos_y |
617 byte main_button; ///< scrollpos_y |
618 byte action_id; |
618 byte action_id; |
619 StringID string_id; ///< unk30 |
619 StringID string_id; ///< unk30 |
620 uint16 checked_items; ///< unk32 |
620 uint16 checked_items; ///< unk32 |
621 byte disabled_items; |
621 byte disabled_items; |
622 } menu_d; |
622 }; |
623 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); |
623 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); |
624 |
624 |
625 typedef struct { |
625 struct def_d { |
626 int16 data_1, data_2, data_3; |
626 int16 data_1, data_2, data_3; |
627 int16 data_4, data_5; |
627 int16 data_4, data_5; |
628 bool close; |
628 bool close; |
629 byte byte_1; |
629 byte byte_1; |
630 } def_d; |
630 }; |
631 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); |
631 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); |
632 |
632 |
633 typedef struct { |
633 struct void_d { |
634 void *data; |
634 void *data; |
635 } void_d; |
635 }; |
636 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); |
636 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); |
637 |
637 |
638 typedef struct { |
638 struct tree_d { |
639 uint16 base; |
639 uint16 base; |
640 uint16 count; |
640 uint16 count; |
641 } tree_d; |
641 }; |
642 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); |
642 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); |
643 |
643 |
644 typedef struct { |
644 struct tooltips_d { |
645 StringID string_id; |
645 StringID string_id; |
646 byte paramcount; |
646 byte paramcount; |
647 uint32 params[5]; |
647 uint32 params[5]; |
648 } tooltips_d; |
648 }; |
649 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); |
649 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); |
650 |
650 |
651 typedef struct { |
651 struct buildvehicle_d { |
652 byte vehicle_type; |
652 byte vehicle_type; |
653 union { |
653 union { |
654 RailTypeByte railtype; |
654 RailTypeByte railtype; |
655 AirportFTAClass::Flags flags; |
655 AirportFTAClass::Flags flags; |
656 } filter; |
656 } filter; |
659 byte sort_criteria; |
659 byte sort_criteria; |
660 bool regenerate_list; |
660 bool regenerate_list; |
661 EngineID sel_engine; |
661 EngineID sel_engine; |
662 EngineID rename_engine; |
662 EngineID rename_engine; |
663 EngineList eng_list; |
663 EngineList eng_list; |
664 } buildvehicle_d; |
664 }; |
665 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); |
665 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); |
666 |
666 |
667 typedef struct { |
667 struct replaceveh_d { |
668 byte sel_index[2]; |
668 byte sel_index[2]; |
669 EngineID sel_engine[2]; |
669 EngineID sel_engine[2]; |
670 uint16 count[2]; |
670 uint16 count[2]; |
671 bool wagon_btnstate; ///< true means engine is selected |
671 bool wagon_btnstate; ///< true means engine is selected |
672 EngineList list[2]; |
672 EngineList list[2]; |
673 bool update_left; |
673 bool update_left; |
674 bool update_right; |
674 bool update_right; |
675 bool init_lists; |
675 bool init_lists; |
676 } replaceveh_d; |
676 }; |
677 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); |
677 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); |
678 |
678 |
679 typedef struct { |
679 struct depot_d { |
680 VehicleID sel; |
680 VehicleID sel; |
681 byte type; |
681 byte type; |
682 bool generate_list; |
682 bool generate_list; |
683 uint16 engine_list_length; |
683 uint16 engine_list_length; |
684 uint16 wagon_list_length; |
684 uint16 wagon_list_length; |
685 uint16 engine_count; |
685 uint16 engine_count; |
686 uint16 wagon_count; |
686 uint16 wagon_count; |
687 Vehicle **vehicle_list; |
687 Vehicle **vehicle_list; |
688 Vehicle **wagon_list; |
688 Vehicle **wagon_list; |
689 } depot_d; |
689 }; |
690 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d)); |
690 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d)); |
691 |
691 |
692 typedef struct { |
692 struct order_d { |
693 int sel; |
693 int sel; |
694 } order_d; |
694 }; |
695 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); |
695 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); |
696 |
696 |
697 typedef struct { |
697 struct traindetails_d { |
698 byte tab; |
698 byte tab; |
699 } traindetails_d; |
699 }; |
700 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d)); |
700 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d)); |
701 |
701 |
702 typedef struct { |
702 struct smallmap_d { |
703 int32 scroll_x; |
703 int32 scroll_x; |
704 int32 scroll_y; |
704 int32 scroll_y; |
705 int32 subscroll; |
705 int32 subscroll; |
706 } smallmap_d; |
706 }; |
707 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d)); |
707 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d)); |
708 |
708 |
709 typedef struct { |
709 struct facesel_d { |
710 uint32 face; |
710 uint32 face; |
711 byte gender; |
711 byte gender; |
712 } facesel_d; |
712 }; |
713 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); |
713 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); |
714 |
714 |
715 typedef struct { |
715 struct refit_d { |
716 int sel; |
716 int sel; |
717 struct RefitOption *cargo; |
717 struct RefitOption *cargo; |
718 struct RefitList *list; |
718 struct RefitList *list; |
719 uint length; |
719 uint length; |
720 VehicleOrderID order; |
720 VehicleOrderID order; |
721 } refit_d; |
721 }; |
722 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); |
722 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); |
723 |
723 |
724 typedef struct { |
724 struct vp_d { |
725 VehicleID follow_vehicle; |
725 VehicleID follow_vehicle; |
726 int32 scrollpos_x; |
726 int32 scrollpos_x; |
727 int32 scrollpos_y; |
727 int32 scrollpos_y; |
728 } vp_d; |
728 }; |
729 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); |
729 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); |
730 |
730 |
731 /* vp2_d is the same as vp_d, except for the data_# values.. */ |
731 /* vp2_d is the same as vp_d, except for the data_# values.. */ |
732 typedef struct { |
732 struct vp2_d { |
733 VehicleID follow_vehicle; |
733 VehicleID follow_vehicle; |
734 int32 scrollpos_x; |
734 int32 scrollpos_x; |
735 int32 scrollpos_y; |
735 int32 scrollpos_y; |
736 byte data_1; |
736 byte data_1; |
737 byte data_2; |
737 byte data_2; |
738 byte data_3; |
738 byte data_3; |
739 } vp2_d; |
739 }; |
740 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d)); |
740 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d)); |
741 |
741 |
742 typedef struct { |
742 struct news_d { |
743 uint16 follow_vehicle; |
743 uint16 follow_vehicle; |
744 int32 scrollpos_x; |
744 int32 scrollpos_x; |
745 int32 scrollpos_y; |
745 int32 scrollpos_y; |
746 NewsItem *ni; |
746 NewsItem *ni; |
747 } news_d; |
747 }; |
748 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); |
748 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); |
749 |
749 |
750 typedef struct { |
750 struct highscore_d { |
751 uint32 background_img; |
751 uint32 background_img; |
752 int8 rank; |
752 int8 rank; |
753 } highscore_d; |
753 }; |
754 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); |
754 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); |
755 |
755 |
756 typedef struct { |
756 struct scroller_d { |
757 int height; |
757 int height; |
758 uint16 counter; |
758 uint16 counter; |
759 } scroller_d; |
759 }; |
760 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); |
760 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); |
761 |
761 |
762 typedef enum SortListFlags { |
762 enum SortListFlags { |
763 VL_NONE = 0x00, ///< no sort |
763 VL_NONE = 0x00, ///< no sort |
764 VL_DESC = 0x01, ///< sort descending or ascending |
764 VL_DESC = 0x01, ///< sort descending or ascending |
765 VL_RESORT = 0x02, ///< instruct the code to resort the list in the next loop |
765 VL_RESORT = 0x02, ///< instruct the code to resort the list in the next loop |
766 VL_REBUILD = 0x04, ///< create sort-listing to use for qsort and friends |
766 VL_REBUILD = 0x04, ///< create sort-listing to use for qsort and friends |
767 VL_END = 0x08 |
767 VL_END = 0x08 |
768 } SortListFlags; |
768 }; |
769 |
769 |
770 DECLARE_ENUM_AS_BIT_SET(SortListFlags); |
770 DECLARE_ENUM_AS_BIT_SET(SortListFlags); |
771 |
771 |
772 typedef struct Listing { |
772 struct Listing { |
773 bool order; ///< Ascending/descending |
773 bool order; ///< Ascending/descending |
774 byte criteria; ///< Sorting criteria |
774 byte criteria; ///< Sorting criteria |
775 } Listing; |
775 }; |
776 |
776 |
777 typedef struct list_d { |
777 struct list_d { |
778 uint16 list_length; ///< length of the list being sorted |
778 uint16 list_length; ///< length of the list being sorted |
779 byte sort_type; ///< what criteria to sort on |
779 byte sort_type; ///< what criteria to sort on |
780 SortListFlags flags; ///< used to control sorting/resorting/etc. |
780 SortListFlags flags; ///< used to control sorting/resorting/etc. |
781 uint16 resort_timer; ///< resort list after a given amount of ticks if set |
781 uint16 resort_timer; ///< resort list after a given amount of ticks if set |
782 } list_d; |
782 }; |
783 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); |
783 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); |
784 |
784 |
785 typedef struct message_d { |
785 struct message_d { |
786 int msg; |
786 int msg; |
787 int wparam; |
787 int wparam; |
788 int lparam; |
788 int lparam; |
789 } message_d; |
789 }; |
790 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); |
790 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); |
791 |
791 |
792 typedef struct dropdown_d { |
792 struct dropdown_d { |
793 uint32 disabled_state; |
793 uint32 disabled_state; |
794 uint32 hidden_state; |
794 uint32 hidden_state; |
795 WindowClass parent_wnd_class; |
795 WindowClass parent_wnd_class; |
796 WindowNumber parent_wnd_num; |
796 WindowNumber parent_wnd_num; |
797 byte parent_button; |
797 byte parent_button; |
798 byte num_items; |
798 byte num_items; |
799 byte selected_index; |
799 byte selected_index; |
800 const StringID *items; |
800 const StringID *items; |
801 byte click_delay; |
801 byte click_delay; |
802 bool drag_mode; |
802 bool drag_mode; |
803 } dropdown_d; |
803 }; |
804 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); |
804 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); |
805 |
805 |
806 |
806 |
807 /* window.cpp */ |
807 /* window.cpp */ |
808 //void CallWindowEventNP(BaseWindow *w, int event); |
808 //void CallWindowEventNP(BaseWindow *w, int event); |
809 void CallWindowTickEvent(void); |
809 void CallWindowTickEvent(); |
810 //void SetWindowDirty(const BaseWindow *w); |
810 //void SetWindowDirty(const BaseWindow *w); |
811 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam); |
811 void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, int msg, int wparam, int lparam); |
812 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam); |
812 void SendWindowMessageClass(WindowClass wnd_class, int msg, int wparam, int lparam); |
813 |
813 |
814 //BaseWindow *FindWindowById(WindowClass cls, WindowNumber number); |
814 //BaseWindow *FindWindowById(WindowClass cls, WindowNumber number); |