OpenTTD Source 20250218-master-g53dd1258a7
story_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#include "stdafx.h"
11#include "window_gui.h"
12#include "strings_func.h"
13#include "gui.h"
14#include "story_base.h"
16#include "company_func.h"
17#include "command_func.h"
18#include "dropdown_type.h"
19#include "dropdown_func.h"
20#include "sortlist_type.h"
21#include "goal_base.h"
22#include "viewport_func.h"
23#include "window_func.h"
24#include "company_base.h"
25#include "tilehighlight_func.h"
26#include "vehicle_base.h"
27#include "story_cmd.h"
28
30
31#include "table/strings.h"
32#include "table/sprites.h"
33
34#include "safeguards.h"
35
36static CursorID TranslateStoryPageButtonCursor(StoryPageButtonCursor cursor);
37
40
42protected:
44 const StoryPageElement *pe;
45 Rect bounds;
46 };
47 typedef std::vector<LayoutCacheElement> LayoutCache;
48
49 enum class ElementFloat : uint8_t {
50 None,
51 Left,
52 Right,
53 };
54
56 mutable LayoutCache layout_cache;
57
62
64
65 static const std::initializer_list<GUIStoryPageList::SortFunction * const> page_sorter_funcs;
66 static const std::initializer_list<GUIStoryPageElementList::SortFunction * const> page_element_sorter_funcs;
67
70 {
71 if (this->story_pages.NeedRebuild()) {
72 this->story_pages.clear();
73
74 for (const StoryPage *p : StoryPage::Iterate()) {
75 if (this->IsPageAvailable(p)) {
76 this->story_pages.push_back(p);
77 }
78 }
79
80 this->story_pages.RebuildDone();
81 }
82
83 this->story_pages.Sort();
84 }
85
87 static bool PageOrderSorter(const StoryPage * const &a, const StoryPage * const &b)
88 {
89 return a->sort_value < b->sort_value;
90 }
91
94 {
95 if (this->story_page_elements.NeedRebuild()) {
96 this->story_page_elements.clear();
97
98 const StoryPage *p = GetSelPage();
99 if (p != nullptr) {
100 for (const StoryPageElement *pe : StoryPageElement::Iterate()) {
101 if (pe->page == p->index) {
102 this->story_page_elements.push_back(pe);
103 }
104 }
105 }
106
107 this->story_page_elements.RebuildDone();
108 }
109
110 this->story_page_elements.Sort();
112 }
113
115 static bool PageElementOrderSorter(const StoryPageElement * const &a, const StoryPageElement * const &b)
116 {
117 return a->sort_value < b->sort_value;
118 }
119
120 /*
121 * Checks if a given page should be visible in the story book.
122 * @param page The page to check.
123 * @return True if the page should be visible, otherwise false.
124 */
125 bool IsPageAvailable(const StoryPage *page) const
126 {
127 return page->company == CompanyID::Invalid() || page->company == this->window_number;
128 }
129
135 {
136 if (!StoryPage::IsValidID(selected_page_id)) return nullptr;
138 }
139
144 int GetSelPageNum() const
145 {
146 int page_number = 0;
147 for (const StoryPage *p : this->story_pages) {
148 if (p->index == this->selected_page_id) {
149 return page_number;
150 }
151 page_number++;
152 }
153 return -1;
154 }
155
160 {
161 /* Verify that the selected page exist. */
162 if (!StoryPage::IsValidID(this->selected_page_id)) return false;
163
164 return this->story_pages.front()->index == this->selected_page_id;
165 }
166
171 {
172 /* Verify that the selected page exist. */
173 if (!StoryPage::IsValidID(this->selected_page_id)) return false;
174
175 if (this->story_pages.size() <= 1) return true;
176 const StoryPage *last = this->story_pages.back();
177 return last->index == this->selected_page_id;
178 }
179
184 {
185 /* Generate generic title if selected page have no custom title. */
186 StoryPage *page = this->GetSelPage();
187 if (page != nullptr && page->title.empty()) {
189 }
190
191 this->story_page_elements.ForceRebuild();
193
194 if (this->active_button_id != StoryPageElementID::Invalid()) ResetObjectToPlace();
195
196 this->vscroll->SetCount(this->GetContentHeight());
200 }
201
206 {
207 if (!StoryPage::IsValidID(this->selected_page_id)) return;
208
209 /* Find the last available page which is previous to the current selected page. */
211 last_available = nullptr;
212 for (const StoryPage *p : this->story_pages) {
213 if (p->index == this->selected_page_id) {
214 if (last_available == nullptr) return; // No previous page available.
215 this->SetSelectedPage(last_available->index);
216 return;
217 }
218 last_available = p;
219 }
220 }
221
226 {
227 if (!StoryPage::IsValidID(this->selected_page_id)) return;
228
229 /* Find selected page. */
230 for (auto iter = this->story_pages.begin(); iter != this->story_pages.end(); iter++) {
231 const StoryPage *p = *iter;
232 if (p->index == this->selected_page_id) {
233 /* Select the page after selected page. */
234 iter++;
235 if (iter != this->story_pages.end()) {
236 this->SetSelectedPage((*iter)->index);
237 }
238 return;
239 }
240 }
241 }
242
247 {
248 DropDownList list;
249 uint16_t page_num = 1;
250 for (const StoryPage *p : this->story_pages) {
251 bool current_page = p->index == this->selected_page_id;
252 if (!p->title.empty()) {
253 list.push_back(MakeDropDownListStringItem(p->title, p->index.base(), current_page));
254 } else {
255 /* No custom title => use a generic page title with page number. */
257 list.push_back(MakeDropDownListStringItem(STR_STORY_BOOK_GENERIC_PAGE_ITEM, p->index.base(), current_page));
258 }
259 page_num++;
260 }
261
262 return list;
263 }
264
272
280 uint GetHeadHeight(int max_width) const
281 {
282 StoryPage *page = this->GetSelPage();
283 if (page == nullptr) return 0;
284 int height = 0;
285
286 /* Title lines */
287 height += GetCharacterHeight(FS_NORMAL); // Date always use exactly one line.
288 SetDParamStr(0, !page->title.empty() ? page->title : this->selected_generic_title);
290
291 return height;
292 }
293
301 {
302 switch (pe.type) {
303 case SPET_GOAL: {
305 if (g == nullptr) return SPR_IMG_GOAL_BROKEN_REF;
306 return g->completed ? SPR_IMG_GOAL_COMPLETED : SPR_IMG_GOAL;
307 }
308 case SPET_LOCATION:
309 return SPR_IMG_VIEW_LOCATION;
310 default:
311 NOT_REACHED();
312 }
313 }
314
322 {
323 switch (pe.type) {
324 case SPET_TEXT:
325 SetDParamStr(0, pe.text);
327
328 case SPET_GOAL:
329 case SPET_LOCATION: {
331 return sprite_dim.height;
332 }
333
334 case SPET_BUTTON_PUSH:
335 case SPET_BUTTON_TILE:
336 case SPET_BUTTON_VEHICLE: {
339 }
340
341 default:
342 NOT_REACHED();
343 }
344 return 0;
345 }
346
352 ElementFloat GetPageElementFloat(const StoryPageElement &pe) const
353 {
354 switch (pe.type) {
355 case SPET_BUTTON_PUSH:
356 case SPET_BUTTON_TILE:
357 case SPET_BUTTON_VEHICLE: {
359 if (flags & SPBF_FLOAT_LEFT) return ElementFloat::Left;
360 if (flags & SPBF_FLOAT_RIGHT) return ElementFloat::Right;
361 return ElementFloat::None;
362 }
363
364 default:
365 return ElementFloat::None;
366 }
367 }
368
375 {
376 switch (pe.type) {
377 case SPET_BUTTON_PUSH:
378 case SPET_BUTTON_TILE:
379 case SPET_BUTTON_VEHICLE: {
382 }
383
384 default:
385 NOT_REACHED(); // only buttons can float
386 }
387 }
388
391 {
392 this->layout_cache.clear();
393 }
394
397 {
398 /* Assume if the layout cache has contents it is valid */
399 if (!this->layout_cache.empty()) return;
400
401 StoryPage *page = this->GetSelPage();
402 if (page == nullptr) return;
405
406 /* Make space for the header */
408
409 /* Current bottom of left/right column */
410 int left_y = main_y;
411 int right_y = main_y;
412 /* Current width of left/right column, 0 indicates no content in column */
413 int left_width = 0;
414 int right_width = 0;
415 /* Indexes into element cache for yet unresolved floats */
416 std::vector<size_t> left_floats;
417 std::vector<size_t> right_floats;
418
419 /* Build layout */
420 for (const StoryPageElement *pe : this->story_page_elements) {
421 ElementFloat fl = this->GetPageElementFloat(*pe);
422
423 if (fl == ElementFloat::None) {
424 /* Verify available width */
426 int left_offset = (left_width == 0) ? 0 : (left_width + element_dist);
427 int right_offset = (right_width == 0) ? 0 : (right_width + element_dist);
429 /* Width of floats leave too little for main content, push down */
430 main_y = std::max(main_y, left_y);
431 main_y = std::max(main_y, right_y);
434 /* Do not add element_dist here, to keep together elements which were supposed to float besides each other. */
435 }
436 /* Determine height */
439 /* Check for button that needs extra margin */
440 if (left_offset == 0 && right_offset == 0) {
441 switch (pe->type) {
442 case SPET_BUTTON_PUSH:
443 case SPET_BUTTON_TILE:
446 break;
447 default:
448 break;
449 }
450 }
451 /* Position element in main column */
452 LayoutCacheElement ce{ pe, {} };
453 ce.bounds.left = left_offset;
454 ce.bounds.right = max_width - right_offset;
455 ce.bounds.top = main_y;
456 main_y += height;
457 ce.bounds.bottom = main_y;
458 this->layout_cache.push_back(ce);
460 /* Clear all floats */
462 left_y = right_y = main_y = std::max({main_y, left_y, right_y});
463 left_floats.clear();
464 right_floats.clear();
465 } else {
466 /* Prepare references to correct column */
467 int &cur_width = (fl == ElementFloat::Left) ? left_width : right_width;
468 int &cur_y = (fl == ElementFloat::Left) ? left_y : right_y;
469 std::vector<size_t> &cur_floats = (fl == ElementFloat::Left) ? left_floats : right_floats;
470 /* Position element */
471 cur_width = std::max(cur_width, this->GetPageElementFloatWidth(*pe));
472 LayoutCacheElement ce{ pe, {} };
473 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
474 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
475 ce.bounds.top = cur_y;
477 ce.bounds.bottom = cur_y;
478 cur_floats.push_back(this->layout_cache.size());
479 this->layout_cache.push_back(ce);
481 /* Update floats in column to all have the same width */
482 for (size_t index : cur_floats) {
483 LayoutCacheElement &ce = this->layout_cache[index];
484 ce.bounds.left = (fl == ElementFloat::Left) ? 0 : (max_width - cur_width);
485 ce.bounds.right = (fl == ElementFloat::Left) ? cur_width : max_width;
486 }
487 }
488 }
489 }
490
496 {
498
499 /* The largest bottom coordinate of any element is the height of the content */
500 int32_t max_y = std::accumulate(this->layout_cache.begin(), this->layout_cache.end(), 0, [](int32_t max_y, const LayoutCacheElement &ce) -> int32_t { return std::max<int32_t>(max_y, ce.bounds.bottom); });
501
502 return max_y;
503 }
504
516 void DrawActionElement(int &y_offset, int width, int line_height, SpriteID action_sprite, StringID string_id = STR_JUST_RAW_STRING) const
517 {
519 uint element_height = std::max(sprite_dim.height, (uint)line_height);
520
521 uint sprite_top = y_offset + (element_height - sprite_dim.height) / 2;
522 uint text_top = y_offset + (element_height - line_height) / 2;
523
524 DrawSprite(action_sprite, PAL_NONE, 0, sprite_top);
525 DrawString(sprite_dim.width + WidgetDimensions::scaled.frametext.left, width, text_top, string_id, TC_BLACK);
526
527 y_offset += element_height;
528 }
529
535 {
536 switch (pe.type) {
537 case SPET_TEXT:
538 /* Do nothing. */
539 break;
540
541 case SPET_LOCATION:
542 if (_ctrl_pressed) {
544 } else {
546 }
547 break;
548
549 case SPET_GOAL:
551 break;
552
553 case SPET_BUTTON_PUSH:
554 if (this->active_button_id != StoryPageElementID::Invalid()) ResetObjectToPlace();
555 this->active_button_id = pe.index;
556 this->SetTimeout();
558
559 Command<CMD_STORY_PAGE_BUTTON>::Post(TileIndex{}, pe.index, VehicleID::Invalid());
560 break;
561
562 case SPET_BUTTON_TILE:
563 if (this->active_button_id == pe.index) {
565 this->active_button_id = StoryPageElementID::Invalid();
566 } else {
567 CursorID cursor = TranslateStoryPageButtonCursor(StoryPageButtonData{ pe.referenced_id }.GetCursor());
568 SetObjectToPlaceWnd(cursor, PAL_NONE, HT_RECT, this);
569 this->active_button_id = pe.index;
570 }
572 break;
573
575 if (this->active_button_id == pe.index) {
577 this->active_button_id = StoryPageElementID::Invalid();
578 } else {
579 CursorID cursor = TranslateStoryPageButtonCursor(StoryPageButtonData{ pe.referenced_id }.GetCursor());
580 SetObjectToPlaceWnd(cursor, PAL_NONE, HT_VEHICLE, this);
581 this->active_button_id = pe.index;
582 }
584 break;
585
586 default:
587 NOT_REACHED();
588 }
589 }
590
591public:
593 {
594 this->CreateNestedTree();
595 this->vscroll = this->GetScrollbar(WID_SB_SCROLLBAR);
597
598 /* Initialize page sort. */
599 this->story_pages.SetSortFuncs(StoryBookWindow::page_sorter_funcs);
600 this->story_pages.ForceRebuild();
601 this->BuildStoryPageList();
602 this->story_page_elements.SetSortFuncs(StoryBookWindow::page_element_sorter_funcs);
603 /* story_page_elements will get built by SetSelectedPage */
604
605 this->FinishInitNested(window_number);
606 this->owner = this->window_number;
607
608 /* Initialize selected vars. */
609 this->selected_generic_title.clear();
610 this->selected_page_id = StoryPageID::Invalid();
611
612 this->active_button_id = StoryPageElementID::Invalid();
613
614 this->OnInvalidateData(-1);
615 }
616
621 {
622 this->SetWidgetDisabledState(WID_SB_PREV_PAGE, story_pages.empty() || this->IsFirstPageSelected());
623 this->SetWidgetDisabledState(WID_SB_NEXT_PAGE, story_pages.empty() || this->IsLastPageSelected());
626 }
627
633 {
634 if (this->selected_page_id != page_index) {
635 if (this->active_button_id != 0) ResetObjectToPlace();
636 this->active_button_id = StoryPageElementID::Invalid();
637 this->selected_page_id = page_index;
638 this->RefreshSelectedPage();
640 }
641 }
642
643 void SetStringParameters(WidgetID widget) const override
644 {
645 switch (widget) {
646 case WID_SB_SEL_PAGE: {
647 StoryPage *page = this->GetSelPage();
648 SetDParamStr(0, page != nullptr && !page->title.empty() ? page->title : this->selected_generic_title);
649 break;
650 }
651 case WID_SB_CAPTION:
652 if (this->window_number == CompanyID::Invalid()) {
654 } else {
656 SetDParam(1, this->window_number);
657 }
658 break;
659 }
660 }
661
662 void OnPaint() override
663 {
664 /* Detect if content has changed height. This can happen if a
665 * multi-line text contains eg. {COMPANY} and that company is
666 * renamed.
667 */
668 if (this->vscroll->GetCount() != this->GetContentHeight()) {
669 this->vscroll->SetCount(this->GetContentHeight());
672 }
673
674 this->DrawWidgets();
675 }
676
677 void DrawWidget(const Rect &r, WidgetID widget) const override
678 {
679 if (widget != WID_SB_PAGE_PANEL) return;
680
681 StoryPage *page = this->GetSelPage();
682 if (page == nullptr) return;
683
684 Rect fr = r.Shrink(WidgetDimensions::scaled.frametext);
685
686 /* Set up a clipping region for the panel. */
688 if (!FillDrawPixelInfo(&tmp_dpi, fr)) return;
689
691
692 /* Draw content (now coordinates given to Draw** are local to the new clipping region). */
693 fr = fr.Translate(-fr.left, -fr.top);
694 int line_height = GetCharacterHeight(FS_NORMAL);
695 const int scrollpos = this->vscroll->GetPosition();
696 int y_offset = -scrollpos;
697
698 /* Date */
699 if (page->date != CalendarTime::INVALID_DATE) {
700 SetDParam(0, page->date);
701 DrawString(0, fr.right, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
702 }
703 y_offset += line_height;
704
705 /* Title */
706 SetDParamStr(0, !page->title.empty() ? page->title : this->selected_generic_title);
707 y_offset = DrawStringMultiLine(0, fr.right, y_offset, fr.bottom, STR_STORY_BOOK_TITLE, TC_BLACK, SA_TOP | SA_HOR_CENTER);
708
709 /* Page elements */
711 for (const LayoutCacheElement &ce : this->layout_cache) {
712 y_offset = ce.bounds.top - scrollpos;
713 switch (ce.pe->type) {
714 case SPET_TEXT:
715 SetDParamStr(0, ce.pe->text);
716 y_offset = DrawStringMultiLine(ce.bounds.left, ce.bounds.right, ce.bounds.top - scrollpos, ce.bounds.bottom - scrollpos, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_LEFT);
717 break;
718
719 case SPET_GOAL: {
720 Goal *g = Goal::Get((GoalID) ce.pe->referenced_id);
722 if (g != nullptr) SetDParamStr(0, g->text);
723 DrawActionElement(y_offset, ce.bounds.right - ce.bounds.left, line_height, GetPageElementSprite(*ce.pe), string_id);
724 break;
725 }
726
727 case SPET_LOCATION:
728 SetDParamStr(0, ce.pe->text);
729 DrawActionElement(y_offset, ce.bounds.right - ce.bounds.left, line_height, GetPageElementSprite(*ce.pe));
730 break;
731
732 case SPET_BUTTON_PUSH:
733 case SPET_BUTTON_TILE:
734 case SPET_BUTTON_VEHICLE: {
736 const FrameFlags frame = this->active_button_id == ce.pe->index ? FrameFlag::Lowered : FrameFlags{};
737 const Colours bgcolour = StoryPageButtonData{ ce.pe->referenced_id }.GetColour();
738
739 DrawFrameRect(ce.bounds.left, ce.bounds.top - scrollpos, ce.bounds.right, ce.bounds.bottom - scrollpos - 1, bgcolour, frame);
740
741 SetDParamStr(0, ce.pe->text);
742 DrawString(ce.bounds.left + WidgetDimensions::scaled.bevel.left, ce.bounds.right - WidgetDimensions::scaled.bevel.right, ce.bounds.top + tmargin - scrollpos, STR_JUST_RAW_STRING, TC_WHITE, SA_CENTER);
743 break;
744 }
745
746 default: NOT_REACHED();
747 }
748 }
749 }
750
752 {
753 if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return;
754
755 Dimension d;
757 d.width = 0;
758
759 switch (widget) {
760 case WID_SB_SEL_PAGE: {
761
762 /* Get max title width. */
763 for (size_t i = 0; i < this->story_pages.size(); i++) {
764 const StoryPage *s = this->story_pages[i];
765
766 if (!s->title.empty()) {
767 SetDParamStr(0, s->title);
768 } else {
769 SetDParamStr(0, this->selected_generic_title);
770 }
772
773 if (title_d.width > d.width) {
774 d.width = title_d.width;
775 }
776 }
777
778 d.width += padding.width;
779 d.height += padding.height;
780 size = maxdim(size, d);
781 break;
782 }
783
784 case WID_SB_PAGE_PANEL: {
785 d.height *= 5;
786 d.height += padding.height + WidgetDimensions::scaled.frametext.Vertical();
787 size = maxdim(size, d);
788 break;
789 }
790 }
791
792 }
793
794 void OnResize() override
795 {
797 this->vscroll->SetCapacityFromWidget(this, WID_SB_PAGE_PANEL, WidgetDimensions::scaled.frametext.Vertical());
798 this->vscroll->SetCount(this->GetContentHeight());
799 }
800
801 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
802 {
803 switch (widget) {
804 case WID_SB_SEL_PAGE: {
805 DropDownList list = this->BuildDropDownList();
806 if (!list.empty()) {
807 /* Get the index of selected page. */
808 int selected = 0;
809 for (size_t i = 0; i < this->story_pages.size(); i++) {
810 const StoryPage *p = this->story_pages[i];
811 if (p->index == this->selected_page_id) break;
812 selected++;
813 }
814
815 ShowDropDownList(this, std::move(list), selected, widget);
816 }
817 break;
818 }
819
820 case WID_SB_PREV_PAGE:
821 this->SelectPrevPage();
822 break;
823
824 case WID_SB_NEXT_PAGE:
825 this->SelectNextPage();
826 break;
827
828 case WID_SB_PAGE_PANEL: {
831
832 for (const LayoutCacheElement &ce : this->layout_cache) {
833 if (clicked_y >= ce.bounds.top && clicked_y < ce.bounds.bottom && pt.x >= ce.bounds.left && pt.x < ce.bounds.right) {
834 this->OnPageElementClick(*ce.pe);
835 return;
836 }
837 }
838 }
839 }
840 }
841
842 void OnDropdownSelect(WidgetID widget, int index) override
843 {
844 if (widget != WID_SB_SEL_PAGE) return;
845
846 /* index (which is set in BuildDropDownList) is the page id. */
847 this->SetSelectedPage(static_cast<StoryPageID>(index));
848 }
849
857 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
858 {
859 if (!gui_scope) return;
860
861 /* If added/removed page, force rebuild. Sort order never change so just a
862 * re-sort is never needed.
863 */
864 if (data == -1) {
865 this->story_pages.ForceRebuild();
866 this->BuildStoryPageList();
867
868 /* Was the last page removed? */
869 if (this->story_pages.empty()) {
870 this->selected_generic_title.clear();
871 }
872
873 /* Verify page selection. */
874 if (!StoryPage::IsValidID(this->selected_page_id)) {
875 this->selected_page_id = StoryPageID::Invalid();
876 }
877 if (this->selected_page_id == StoryPageID::Invalid() && !this->story_pages.empty()) {
878 /* No page is selected, but there exist at least one available.
879 * => Select first page.
880 */
881 this->SetSelectedPage(this->story_pages[0]->index);
882 }
883
884 this->SetWidgetDisabledState(WID_SB_SEL_PAGE, this->story_pages.empty());
887 } else if (data >= 0 && this->selected_page_id == data) {
888 this->RefreshSelectedPage();
889 }
890 }
891
892 void OnTimeout() override
893 {
894 this->active_button_id = StoryPageElementID::Invalid();
896 }
897
898 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
899 {
900 const StoryPageElement *const pe = StoryPageElement::GetIfValid(this->active_button_id);
901 if (pe == nullptr || pe->type != SPET_BUTTON_TILE) {
903 this->active_button_id = StoryPageElementID::Invalid();
905 return;
906 }
907
908 Command<CMD_STORY_PAGE_BUTTON>::Post(tile, pe->index, VehicleID::Invalid());
910 }
911
912 bool OnVehicleSelect(const Vehicle *v) override
913 {
914 const StoryPageElement *const pe = StoryPageElement::GetIfValid(this->active_button_id);
915 if (pe == nullptr || pe->type != SPET_BUTTON_VEHICLE) {
917 this->active_button_id = StoryPageElementID::Invalid();
919 return false;
920 }
921
922 /* Check that the vehicle matches the requested type */
924 VehicleType wanted_vehtype = data.GetVehicleType();
925 if (wanted_vehtype != VEH_INVALID && wanted_vehtype != v->type) return false;
926
929 return true;
930 }
931
932 void OnPlaceObjectAbort() override
933 {
934 this->active_button_id = StoryPageElementID::Invalid();
936 }
937};
938
939const std::initializer_list<GUIStoryPageList::SortFunction * const> StoryBookWindow::page_sorter_funcs = {
940 &PageOrderSorter,
941};
942
943const std::initializer_list<GUIStoryPageElementList::SortFunction * const> StoryBookWindow::page_element_sorter_funcs = {
944 &PageElementOrderSorter,
945};
946
947static constexpr NWidgetPart _nested_story_book_widgets[] = {
949 NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
950 NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SB_CAPTION), SetStringTip(STR_JUST_STRING1, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
951 NWidget(WWT_SHADEBOX, COLOUR_BROWN),
952 NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
953 NWidget(WWT_STICKYBOX, COLOUR_BROWN),
954 EndContainer(),
958 EndContainer(),
960 NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_PREV_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetStringTip(STR_STORY_BOOK_PREV_PAGE, STR_STORY_BOOK_PREV_PAGE_TOOLTIP),
961 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_BROWN, WID_SB_SEL_PAGE), SetMinimalSize(93, 12), SetFill(1, 0),
962 SetStringTip(STR_JUST_RAW_STRING, STR_STORY_BOOK_SEL_PAGE_TOOLTIP), SetResize(1, 0),
963 NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_NEXT_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetStringTip(STR_STORY_BOOK_NEXT_PAGE, STR_STORY_BOOK_NEXT_PAGE_TOOLTIP),
964 NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
965 EndContainer(),
966};
967
968static WindowDesc _story_book_desc(
969 WDP_AUTO, "view_story", 400, 300,
971 {},
972 _nested_story_book_widgets
973);
974
975static WindowDesc _story_book_gs_desc(
976 WDP_CENTER, "view_story_gs", 400, 300,
978 {},
979 _nested_story_book_widgets
980);
981
982static CursorID TranslateStoryPageButtonCursor(StoryPageButtonCursor cursor)
983{
984 switch (cursor) {
985 case SPBC_MOUSE: return SPR_CURSOR_MOUSE;
986 case SPBC_ZZZ: return SPR_CURSOR_ZZZ;
987 case SPBC_BUOY: return SPR_CURSOR_BUOY;
988 case SPBC_QUERY: return SPR_CURSOR_QUERY;
989 case SPBC_HQ: return SPR_CURSOR_HQ;
990 case SPBC_SHIP_DEPOT: return SPR_CURSOR_SHIP_DEPOT;
991 case SPBC_SIGN: return SPR_CURSOR_SIGN;
992 case SPBC_TREE: return SPR_CURSOR_TREE;
993 case SPBC_BUY_LAND: return SPR_CURSOR_BUY_LAND;
994 case SPBC_LEVEL_LAND: return SPR_CURSOR_LEVEL_LAND;
995 case SPBC_TOWN: return SPR_CURSOR_TOWN;
996 case SPBC_INDUSTRY: return SPR_CURSOR_INDUSTRY;
997 case SPBC_ROCKY_AREA: return SPR_CURSOR_ROCKY_AREA;
998 case SPBC_DESERT: return SPR_CURSOR_DESERT;
999 case SPBC_TRANSMITTER: return SPR_CURSOR_TRANSMITTER;
1000 case SPBC_AIRPORT: return SPR_CURSOR_AIRPORT;
1001 case SPBC_DOCK: return SPR_CURSOR_DOCK;
1002 case SPBC_CANAL: return SPR_CURSOR_CANAL;
1003 case SPBC_LOCK: return SPR_CURSOR_LOCK;
1004 case SPBC_RIVER: return SPR_CURSOR_RIVER;
1005 case SPBC_AQUEDUCT: return SPR_CURSOR_AQUEDUCT;
1006 case SPBC_BRIDGE: return SPR_CURSOR_BRIDGE;
1007 case SPBC_RAIL_STATION: return SPR_CURSOR_RAIL_STATION;
1008 case SPBC_TUNNEL_RAIL: return SPR_CURSOR_TUNNEL_RAIL;
1009 case SPBC_TUNNEL_ELRAIL: return SPR_CURSOR_TUNNEL_ELRAIL;
1010 case SPBC_TUNNEL_MONO: return SPR_CURSOR_TUNNEL_MONO;
1011 case SPBC_TUNNEL_MAGLEV: return SPR_CURSOR_TUNNEL_MAGLEV;
1012 case SPBC_AUTORAIL: return SPR_CURSOR_AUTORAIL;
1013 case SPBC_AUTOELRAIL: return SPR_CURSOR_AUTOELRAIL;
1014 case SPBC_AUTOMONO: return SPR_CURSOR_AUTOMONO;
1015 case SPBC_AUTOMAGLEV: return SPR_CURSOR_AUTOMAGLEV;
1016 case SPBC_WAYPOINT: return SPR_CURSOR_WAYPOINT;
1017 case SPBC_RAIL_DEPOT: return SPR_CURSOR_RAIL_DEPOT;
1018 case SPBC_ELRAIL_DEPOT: return SPR_CURSOR_ELRAIL_DEPOT;
1019 case SPBC_MONO_DEPOT: return SPR_CURSOR_MONO_DEPOT;
1020 case SPBC_MAGLEV_DEPOT: return SPR_CURSOR_MAGLEV_DEPOT;
1021 case SPBC_CONVERT_RAIL: return SPR_CURSOR_CONVERT_RAIL;
1022 case SPBC_CONVERT_ELRAIL: return SPR_CURSOR_CONVERT_ELRAIL;
1023 case SPBC_CONVERT_MONO: return SPR_CURSOR_CONVERT_MONO;
1024 case SPBC_CONVERT_MAGLEV: return SPR_CURSOR_CONVERT_MAGLEV;
1025 case SPBC_AUTOROAD: return SPR_CURSOR_AUTOROAD;
1026 case SPBC_AUTOTRAM: return SPR_CURSOR_AUTOTRAM;
1027 case SPBC_ROAD_DEPOT: return SPR_CURSOR_ROAD_DEPOT;
1028 case SPBC_BUS_STATION: return SPR_CURSOR_BUS_STATION;
1029 case SPBC_TRUCK_STATION: return SPR_CURSOR_TRUCK_STATION;
1030 case SPBC_ROAD_TUNNEL: return SPR_CURSOR_ROAD_TUNNEL;
1031 case SPBC_CLONE_TRAIN: return SPR_CURSOR_CLONE_TRAIN;
1032 case SPBC_CLONE_ROADVEH: return SPR_CURSOR_CLONE_ROADVEH;
1033 case SPBC_CLONE_SHIP: return SPR_CURSOR_CLONE_SHIP;
1034 case SPBC_CLONE_AIRPLANE: return SPR_CURSOR_CLONE_AIRPLANE;
1035 case SPBC_DEMOLISH: return ANIMCURSOR_DEMOLISH;
1036 case SPBC_LOWERLAND: return ANIMCURSOR_LOWERLAND;
1037 case SPBC_RAISELAND: return ANIMCURSOR_RAISELAND;
1038 case SPBC_PICKSTATION: return ANIMCURSOR_PICKSTATION;
1039 case SPBC_BUILDSIGNALS: return ANIMCURSOR_BUILDSIGNALS;
1040 default: return SPR_CURSOR_QUERY;
1041 }
1042}
1043
1050void ShowStoryBook(CompanyID company, StoryPageID page_id, bool centered)
1051{
1052 if (!Company::IsValidID(company)) company = (CompanyID)CompanyID::Invalid();
1053
1054 StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow, true>(centered ? _story_book_gs_desc : _story_book_desc, company);
1055 if (page_id != StoryPageID::Invalid()) w->SetSelectedPage(page_id);
1056}
@ None
Tile is not animated.
Enum-as-bit-set wrapper.
List template of 'things' T to sort in a GUI.
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void SetSortFuncs(std::span< SortFunction *const > n_funcs)
Hand the sort function pointers to the GUIList.
Scrollbar data structure.
void SetCount(size_t num)
Sets the number of elements in the list.
size_type GetScrolledRowFromWidget(int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition widget.cpp:2459
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition widget.cpp:2533
size_type GetCount() const
Gets the number of elements in the list.
void SetStepSize(size_t stepsize)
Set the distance to scroll when using the buttons or the wheel.
size_type GetPosition() const
Gets the position of the first visible element in the list.
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Representation of an invalid date.
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
RectPadding frametext
Padding inside frame with text.
Definition window_gui.h:41
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:28
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition window_gui.h:38
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to companies.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Definition dropdown.cpp:404
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:77
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Geometry functions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition gfx.cpp:704
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition gfx.cpp:922
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:851
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:657
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition gfx.cpp:988
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:774
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition gfx.cpp:1548
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:243
uint32_t CursorID
The number of the cursor (sprite)
Definition gfx_type.h:19
@ SA_TOP
Top align the text.
Definition gfx_type.h:380
@ SA_LEFT
Left align the text.
Definition gfx_type.h:375
@ SA_HOR_CENTER
Horizontally center the text.
Definition gfx_type.h:376
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:385
Goal base class.
void ShowGoalsList(CompanyID company)
Open a goal list window.
Definition goal_gui.cpp:316
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
A number of safeguards to prevent using unsafe methods.
Base types for having sorted lists in GUIs.
This file contains all sprite-related enums and defines.
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
Definition sprites.h:1511
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Definition sprites.h:1512
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition sprites.h:1390
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition sprites.h:1508
static const CursorID ANIMCURSOR_LOWERLAND
699 - 701 - lower land tool
Definition sprites.h:1509
static const CursorID ANIMCURSOR_RAISELAND
696 - 698 - raise land tool
Definition sprites.h:1510
Definition of base types and functions in a cross-platform compatible way.
StoryPage base class.
StoryPageButtonFlags
Flags available for buttons.
Definition story_base.h:42
@ SPET_LOCATION
An element that references a tile along with a one-line text.
Definition story_base.h:32
@ SPET_GOAL
An element that references a goal.
Definition story_base.h:33
@ SPET_BUTTON_PUSH
A push button that triggers an immediate event.
Definition story_base.h:34
@ SPET_BUTTON_TILE
A button that allows the player to select a tile, and triggers an event with the tile.
Definition story_base.h:35
@ SPET_TEXT
A text element.
Definition story_base.h:31
@ SPET_BUTTON_VEHICLE
A button that allows the player to select a vehicle, and triggers an event with the vehicle.
Definition story_base.h:36
StoryPageButtonCursor
Mouse cursors usable by story page buttons.
Definition story_base.h:50
Command definitions related to stories.
void ShowStoryBook(CompanyID company, StoryPageID page_id, bool centered)
Raise or create the story book window for company, at page page_id.
Types related to the story widgets.
@ WID_SB_PAGE_PANEL
Page body.
@ WID_SB_SEL_PAGE
Page selector.
@ WID_SB_SCROLLBAR
Scrollbar of the goal list.
@ WID_SB_CAPTION
Caption of the window.
@ WID_SB_PREV_PAGE
Prev button.
@ WID_SB_NEXT_PAGE
Next button.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition strings.cpp:163
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition strings.cpp:420
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition strings.cpp:466
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
VehicleType type
Type of vehicle.
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
Definition gfx_type.h:156
Struct about goals, current and completed.
Definition goal_base.h:21
bool completed
Is the goal completed or not?
Definition goal_base.h:27
std::string text
Text of the goal.
Definition goal_base.h:25
Partial widget specification to allow NWidgets to be written nested.
Coordinates of a point in 2D.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Tindex index
Index of this pool item.
static Titem * GetIfValid(auto index)
Returns Titem with given index.
static Titem * Get(auto index)
Returns Titem with given index.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
void OnTimeout() override
Called when this window's timeout has been reached.
void BuildStoryPageList()
(Re)Build story page list.
Definition story_gui.cpp:69
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
std::string selected_generic_title
If the selected page doesn't have a custom title, this buffer is used to store a generic page title.
Definition story_gui.cpp:61
void OnPageElementClick(const StoryPageElement &pe)
Internal event handler for when a page element is clicked.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
void OnResize() override
Called after the window got resized.
static bool PageElementOrderSorter(const StoryPageElement *const &a, const StoryPageElement *const &b)
Sort story page elements by order value.
uint GetAvailablePageContentWidth() const
Get the width available for displaying content on the page panel.
void OnPaint() override
The window must be repainted.
void SetSelectedPage(StoryPageID page_index)
Sets the selected page.
bool IsFirstPageSelected()
Check if the selected page is also the first available page.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
DropDownList BuildDropDownList() const
Builds the page selector drop down list.
int GetPageElementFloatWidth(const StoryPageElement &pe) const
Get the width a page element would use if it was floating left or right.
LayoutCache layout_cache
Cached element layout.
Definition story_gui.cpp:56
void UpdatePrevNextDisabledState()
Updates the disabled state of the prev/next buttons.
Scrollbar * vscroll
Scrollbar of the page text.
Definition story_gui.cpp:55
void SelectNextPage()
Selects the next available page after the currently selected page.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void SelectPrevPage()
Selects the previous available page before the currently selected page.
void DrawActionElement(int &y_offset, int width, int line_height, SpriteID action_sprite, StringID string_id=STR_JUST_RAW_STRING) const
Draws a page element that is composed of a sprite to the left and a single line of text after that.
void RefreshSelectedPage()
Updates the content of selected page.
StoryPageID selected_page_id
Pool index of selected page.
Definition story_gui.cpp:60
bool IsLastPageSelected()
Check if the selected page is also the last available page.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
GUIStoryPageList story_pages
Sorted list of pages.
Definition story_gui.cpp:58
void InvalidateStoryPageElementLayout()
Invalidate the current page layout.
void BuildStoryPageElementList()
(Re)Build story page element list.
Definition story_gui.cpp:93
StoryPage * GetSelPage() const
Get instance of selected page.
static bool PageOrderSorter(const StoryPage *const &a, const StoryPage *const &b)
Sort story pages by order value.
Definition story_gui.cpp:87
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
StoryPageElementID active_button_id
Which button element the player is currently using.
Definition story_gui.cpp:63
int32_t GetContentHeight()
Get the total height of the content displayed in this window.
uint GetHeadHeight(int max_width) const
Counts how many pixels of height that are used by Date and Title (excluding marginal after Title,...
uint GetPageElementHeight(const StoryPageElement &pe, int max_width) const
Get the height in pixels used by a page element.
int GetSelPageNum() const
Get the page number of selected page.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
SpriteID GetPageElementSprite(const StoryPageElement &pe) const
Decides which sprite to display for a given page element.
void EnsureStoryPageElementLayout() const
Create the page layout if it is missing.
GUIStoryPageElementList story_page_elements
Sorted list of page elements that belong to the current page.
Definition story_gui.cpp:59
ElementFloat GetPageElementFloat(const StoryPageElement &pe) const
Get the float style of a page element.
Helper to construct packed "id" values for button-type StoryPageElement.
Definition story_base.h:122
Struct about story page elements.
Definition story_base.h:144
uint32_t referenced_id
Id of referenced object (location, goal etc.)
Definition story_base.h:149
std::string text
Static content text of page element.
Definition story_base.h:150
uint32_t sort_value
A number that increases for every created story page element. Used for sorting. The id of a story pag...
Definition story_base.h:145
StoryPageElementType type
Type of page element.
Definition story_base.h:147
Struct about stories, current and completed.
Definition story_base.h:164
uint32_t sort_value
A number that increases for every created story page. Used for sorting. The id of a story page is the...
Definition story_base.h:165
CompanyID company
StoryPage is for a specific company; CompanyID::Invalid() if it is global.
Definition story_base.h:167
std::string title
Title of story page.
Definition story_base.h:169
TimerGameCalendar::Date date
Date when the page was created.
Definition story_base.h:166
Vehicle data structure.
High level window description.
Definition window_gui.h:168
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:272
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1730
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:731
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:548
ResizeInfo resize
Resize information.
Definition window_gui.h:313
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1720
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition window_gui.h:315
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition window_gui.h:354
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
Definition window_gui.h:969
WindowFlags flags
Window flags.
Definition window_gui.h:299
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition window.cpp:311
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:380
int height
Height of the window (number of pixels down in y direction)
Definition window_gui.h:311
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:310
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:301
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
Base class for all vehicles.
VehicleType
Available vehicle types.
@ VEH_INVALID
Non-existing type of vehicle.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:283
@ NWID_BUTTON_DROPDOWN
Button with a drop-down.
Definition widget_type.h:74
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:46
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:41
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition widget_type.h:76
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition widget_type.h:59
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:56
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ WDP_CENTER
Center the window.
Definition window_gui.h:146
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:145
int WidgetID
Widget ID.
Definition window_type.h:20
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:47
@ WC_STORY_BOOK
Story book; Window numbers: