OpenTTD Source 20261112-master-gbcbec5e63f
music_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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "stdafx.h"
11#include "openttd.h"
12#include "base_media_music.h"
14#include "window_gui.h"
15#include "strings_func.h"
16#include "window_func.h"
17#include "gfx_func.h"
18#include "core/random_func.hpp"
20#include "settings_type.h"
21#include "settings_gui.h"
22#include "dropdown_type.h"
23#include "slider_func.h"
24#include "mixer.h"
25
27
28#include "table/strings.h"
29#include "table/sprites.h"
30
31#include "safeguards.h"
32
33
35 struct PlaylistEntry : MusicSongInfo {
36 const MusicSet *set;
37 uint set_index;
38
39 PlaylistEntry(const MusicSet *set, uint set_index) : MusicSongInfo(set->songinfo[set_index]), set(set), set_index(set_index) { }
40 bool IsValid() const { return !this->songname.empty(); }
41 };
42 typedef std::vector<PlaylistEntry> Playlist;
43
44 Playlist active_playlist{};
45 Playlist music_set{};
46
47 PlaylistChoice selected_playlist{};
48
49 void BuildPlaylists();
50
52 void ChangeMusicSet(const std::string &set_name);
53 void Shuffle();
54 void Unshuffle();
55
56 void Play();
57 void Stop();
58 void Next();
59 void Prev();
60 void CheckStatus();
61
62 bool IsPlaying() const;
63 bool IsShuffle() const;
65
66 bool IsCustomPlaylist() const;
67 void PlaylistAdd(size_t song_index);
68 void PlaylistRemove(size_t song_index);
69 void PlaylistClear();
70
71private:
72 uint GetSetIndex();
73 void SetPositionBySetIndex(uint set_index);
74 void ChangePlaylistPosition(int ofs);
75 int playlist_position = 0;
76
78
80};
81
83
84
87{
88 const MusicSet *set = BaseMusic::GetUsedSet();
89
90 /* Clear current playlists */
91 for (auto &playlist : this->standard_playlists) playlist.clear();
92 this->music_set.clear();
93
94 /* Build standard playlists, and a list of available music */
95 for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
96 PlaylistEntry entry(set, i);
97 if (!entry.IsValid()) continue;
98
99 this->music_set.push_back(entry);
100
101 /* Add theme song to theme-only playlist */
102 if (i == 0) this->standard_playlists[PlaylistChoice::ThemeOnly].push_back(std::move(entry));
103
104 /* Don't add the theme song to standard playlists */
105 if (i > 0) {
106 this->standard_playlists[PlaylistChoice::All].push_back(entry);
108 this->standard_playlists[theme].push_back(std::move(entry));
109 }
110 }
111
112 /* Load custom playlists
113 * Song index offsets are 1-based, zero indicates invalid/end-of-list value */
114 for (uint i = 0; i < NUM_SONGS_PLAYLIST; i++) {
115 if (_settings_client.music.custom_1[i] > 0 && _settings_client.music.custom_1[i] <= NUM_SONGS_AVAILABLE) {
116 PlaylistEntry entry(set, _settings_client.music.custom_1[i] - 1);
117 if (entry.IsValid()) this->standard_playlists[PlaylistChoice::Custom1].push_back(std::move(entry));
118 }
119 if (_settings_client.music.custom_2[i] > 0 && _settings_client.music.custom_2[i] <= NUM_SONGS_AVAILABLE) {
120 PlaylistEntry entry(set, _settings_client.music.custom_2[i] - 1);
121 if (entry.IsValid()) this->standard_playlists[PlaylistChoice::Custom2].push_back(std::move(entry));
122 }
123 }
124}
125
131{
132 assert(pl < PlaylistChoice::End && pl >= PlaylistChoice::All);
133
134 if (pl != PlaylistChoice::ThemeOnly) _settings_client.music.playlist = pl;
135
136 if (_game_mode != GameMode::Menu || pl == PlaylistChoice::ThemeOnly) {
137 this->selected_playlist = pl;
138 this->active_playlist = this->standard_playlists[this->selected_playlist];
139 this->playlist_position = 0;
140
141 if (_settings_client.music.shuffle) this->Shuffle();
142 if (_settings_client.music.playing) this->Play();
143 }
144
145 InvalidateWindowData(WindowClass::MusicTrackSelection, 0);
146 InvalidateWindowData(WindowClass::Music, 0);
147}
148
153void MusicSystem::ChangeMusicSet(const std::string &set_name)
154{
155 BaseMusic::SetSetByName(set_name);
156 BaseMusic::ini_set = set_name;
157
158 this->BuildPlaylists();
159 this->ChangePlaylist(this->selected_playlist);
160
161 InvalidateWindowData(WindowClass::GameOptions, GameOptionsWindowNumber::GameOptions, 0, true);
162 InvalidateWindowData(WindowClass::MusicTrackSelection, 0, 1, true);
163 InvalidateWindowData(WindowClass::Music, 0, 1, true);
164}
165
171{
172 auto it = std::ranges::find(this->active_playlist, set_index, &PlaylistEntry::set_index);
173 if (it != std::end(this->active_playlist)) this->playlist_position = std::distance(std::begin(this->active_playlist), it);
174}
175
181{
182 return static_cast<size_t>(this->playlist_position) < this->active_playlist.size()
183 ? this->active_playlist[this->playlist_position].set_index
184 : UINT_MAX;
185}
186
191{
192 _settings_client.music.shuffle = true;
193
194 uint set_index = this->GetSetIndex();
195 this->active_playlist = this->standard_playlists[this->selected_playlist];
196 for (size_t i = 0; i < this->active_playlist.size(); i++) {
197 size_t shuffle_index = InteractiveRandom() % (this->active_playlist.size() - i);
198 std::swap(this->active_playlist[i], this->active_playlist[i + shuffle_index]);
199 }
200 this->SetPositionBySetIndex(set_index);
201
202 InvalidateWindowData(WindowClass::MusicTrackSelection, 0);
203 InvalidateWindowData(WindowClass::Music, 0);
204}
205
210{
211 _settings_client.music.shuffle = false;
212
213 uint set_index = this->GetSetIndex();
214 this->active_playlist = this->standard_playlists[this->selected_playlist];
215 this->SetPositionBySetIndex(set_index);
216
217 InvalidateWindowData(WindowClass::MusicTrackSelection, 0);
218 InvalidateWindowData(WindowClass::Music, 0);
219}
220
223{
224 /* Always set the playing flag, even if there is no music */
225 _settings_client.music.playing = true;
227 /* Make sure playlist_position is a valid index, if playlist has changed etc. */
228 this->ChangePlaylistPosition(0);
229
230 /* If there is no music, don't try to play it */
231 if (this->active_playlist.empty()) return;
232
233 MusicSongInfo song = this->active_playlist[this->playlist_position];
234 if (_game_mode == GameMode::Menu && this->selected_playlist == PlaylistChoice::ThemeOnly) song.loop = true;
236
237 InvalidateWindowData(WindowClass::Music, 0);
238}
239
242{
244 _settings_client.music.playing = false;
245
246 InvalidateWindowData(WindowClass::Music, 0);
247}
248
251{
252 this->ChangePlaylistPosition(+1);
253 if (_settings_client.music.playing) this->Play();
254
255 InvalidateWindowData(WindowClass::Music, 0);
256}
257
260{
261 this->ChangePlaylistPosition(-1);
262 if (_settings_client.music.playing) this->Play();
263
264 InvalidateWindowData(WindowClass::Music, 0);
265}
266
269{
270 if ((_game_mode == GameMode::Menu) != (this->selected_playlist == PlaylistChoice::ThemeOnly)) {
271 /* Make sure the theme-only playlist is active when on the title screen, and not during gameplay */
273 }
274 if (this->active_playlist.empty()) return;
275 /* If we were supposed to be playing, but music has stopped, move to next song */
276 if (this->IsPlaying() && !MusicDriver::GetInstance()->IsSongPlaying()) this->Next();
277}
278
284{
285 return _settings_client.music.playing && !this->active_playlist.empty();
286}
287
293{
294 return _settings_client.music.shuffle;
295}
296
302{
303 if (!this->IsPlaying()) return PlaylistEntry(BaseMusic::GetUsedSet(), 0);
304 return this->active_playlist[this->playlist_position];
305}
306
312{
313 return (this->selected_playlist == PlaylistChoice::Custom1) || (this->selected_playlist == PlaylistChoice::Custom2);
314}
315
321void MusicSystem::PlaylistAdd(size_t song_index)
322{
323 if (!this->IsCustomPlaylist()) return;
324
325 /* Pick out song from the music set */
326 if (song_index >= this->music_set.size()) return;
327 PlaylistEntry entry = this->music_set[song_index];
328
329 /* Check for maximum length */
330 if (this->standard_playlists[this->selected_playlist].size() >= NUM_SONGS_PLAYLIST) return;
331
332 /* Add it to the appropriate playlist, and the display */
333 this->standard_playlists[this->selected_playlist].push_back(entry);
334
335 /* Add it to the active playlist, if playback is shuffled select a random position to add at */
336 if (this->active_playlist.empty()) {
337 this->active_playlist.push_back(std::move(entry));
338 if (this->IsPlaying()) this->Play();
339 } else if (this->IsShuffle()) {
340 /* Generate a random position between 0 and n (inclusive, new length) to insert at */
341 size_t maxpos = this->active_playlist.size() + 1;
342 size_t newpos = InteractiveRandom() % maxpos;
343 this->active_playlist.insert(this->active_playlist.begin() + newpos, entry);
344 /* Make sure to shift up the current playback position if the song was inserted before it */
345 if ((int)newpos <= this->playlist_position) this->playlist_position++;
346 } else {
347 this->active_playlist.push_back(std::move(entry));
348 }
349
350 this->SaveCustomPlaylist(this->selected_playlist);
351
352 InvalidateWindowData(WindowClass::MusicTrackSelection, 0);
353}
354
359void MusicSystem::PlaylistRemove(size_t song_index)
360{
361 if (!this->IsCustomPlaylist()) return;
362
363 if (song_index >= this->active_playlist.size()) return;
364
365 PlaylistEntry song = this->active_playlist[song_index];
366 this->active_playlist.erase(std::next(std::begin(this->active_playlist), song_index));
367
368 Playlist &playlist = this->standard_playlists[this->selected_playlist];
369 auto it = std::end(playlist);
370 if (this->IsShuffle()) {
371 /* Playlist is shuffled, so remove the first instance. */
372 it = std::ranges::find_if(playlist, [&song](const auto &s) { return s.filename == song.filename && s.cat_index == song.cat_index; });
373 } else if (song_index < playlist.size()) {
374 /* Not shuffled, we can remove the entry directly. */
375 it = std::next(std::begin(playlist), song_index);
376 }
377
378 if (it == std::end(playlist)) return;
379 it = playlist.erase(it);
380
381 /* If it's the current song restart playback. */
382 if (this->IsPlaying() && std::distance(std::begin(playlist), it) == this->playlist_position) this->Play();
383
384 this->SaveCustomPlaylist(this->selected_playlist);
385
386 InvalidateWindowData(WindowClass::MusicTrackSelection, 0);
387}
388
394{
395 if (!this->IsCustomPlaylist()) return;
396
397 this->standard_playlists[this->selected_playlist].clear();
398 this->ChangePlaylist(this->selected_playlist);
399
400 this->SaveCustomPlaylist(this->selected_playlist);
401}
402
409{
410 if (this->active_playlist.empty()) {
411 this->playlist_position = 0;
412 } else {
413 this->playlist_position += ofs;
414 while (this->playlist_position >= (int)this->active_playlist.size()) this->playlist_position -= (int)this->active_playlist.size();
415 while (this->playlist_position < 0) this->playlist_position += (int)this->active_playlist.size();
416 }
417}
418
424{
425 std::span<uint8_t> settings_pl;
426 if (pl == PlaylistChoice::Custom1) {
427 settings_pl = _settings_client.music.custom_1;
428 } else if (pl == PlaylistChoice::Custom2) {
429 settings_pl = _settings_client.music.custom_2;
430 } else {
431 return;
432 }
433
434 size_t num = 0;
435 std::ranges::fill(settings_pl, 0);
436
437 for (const auto &song : this->standard_playlists[pl]) {
438 /* Music set indices in the settings playlist are 1-based, 0 means unused slot */
439 settings_pl[num++] = (uint8_t)song.set_index + 1;
440 }
441}
442
443
449{
450 _music.CheckStatus();
451}
452
457void ChangeMusicSet(int index)
458{
459 if (BaseMusic::GetIndexOfUsedSet() == index) return;
460 _music.ChangeMusicSet(BaseMusic::GetSet(index)->name);
461}
462
468{
469 _music.BuildPlaylists();
470}
471
477static bool IsCustomPlaylist(PlaylistChoice playlist)
478{
479 return playlist == PlaylistChoice::Custom1 || playlist == PlaylistChoice::Custom2;
480}
481
482struct MusicTrackSelectionWindow : public Window {
483 MusicTrackSelectionWindow(WindowDesc &desc, WindowNumber number) : Window(desc)
484 {
485 this->InitNested(number);
489 this->LowerWidget(WID_MTS_ALL + to_underlying(_settings_client.music.playlist));
490 }
491
492 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
493 {
494 switch (widget) {
495 case WID_MTS_PLAYLIST:
496 return GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + to_underlying(_settings_client.music.playlist));
497
498 case WID_MTS_CAPTION:
499 return GetString(STR_PLAYLIST_MUSIC_SELECTION_SETNAME, BaseMusic::GetUsedSet()->name);
500
501 default:
502 return this->Window::GetWidgetString(widget, stringid);
503 }
504 }
505
511 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
512 {
513 if (!gui_scope) return;
515 this->SetWidgetLoweredState(WID_MTS_ALL + to_underlying(playlist), playlist == _settings_client.music.playlist);
516 }
518
519 if (data == 1) {
520 this->ReInit();
521 } else {
522 this->SetDirty();
523 }
524 }
525
526 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
527 {
528 switch (widget) {
529 case WID_MTS_PLAYLIST: {
530 Dimension d = {0, 0};
531
532 for (int i = 0; i < 6; i++) {
533 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + i)));
534 }
535 d.width += padding.width;
536 d.height += padding.height;
537 size = maxdim(size, d);
538 break;
539 }
540
542 Dimension d = {0, 0};
543
544 for (const auto &song : _music.music_set) {
545 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname)));
546 }
548
549 d.width += padding.width;
550 d.height += padding.height;
551 size = maxdim(size, d);
552 break;
553 }
554 }
555 }
556
557 void DrawWidget(const Rect &r, WidgetID widget) const override
558 {
559 switch (widget) {
560 case WID_MTS_LIST_LEFT: {
562
563 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
564 for (const auto &song : _music.music_set) {
565 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
567 }
568 break;
569 }
570
571 case WID_MTS_LIST_RIGHT: {
573
574 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
575 for (const auto &song : _music.active_playlist) {
576 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
578 }
579 break;
580 }
581 }
582 }
583
584 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
585 {
586 switch (widget) {
587 case WID_MTS_LIST_LEFT: { // add to playlist
588 int y = this->GetRowFromWidget(pt.y, widget, WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FontSize::Small));
589 _music.PlaylistAdd(y);
590 break;
591 }
592
593 case WID_MTS_LIST_RIGHT: { // remove from playlist
594 int y = this->GetRowFromWidget(pt.y, widget, WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FontSize::Small));
595 _music.PlaylistRemove(y);
596 break;
597 }
598
599 case WID_MTS_MUSICSET: {
600 int selected = 0;
601 ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget, 0, DropDownOption::Filterable);
602 break;
603 }
604
605 case WID_MTS_CLEAR: // clear
606 _music.PlaylistClear();
607 break;
608
609 case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
610 case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
611 _music.ChangePlaylist(static_cast<PlaylistChoice>(widget - WID_MTS_ALL));
612 break;
613 }
614 }
615
616 void OnDropdownSelect(WidgetID widget, int index, int) override
617 {
618 switch (widget) {
619 case WID_MTS_MUSICSET:
620 ChangeMusicSet(index);
621 break;
622 default:
623 NOT_REACHED();
624 }
625 }
626};
627
628static constexpr std::initializer_list<NWidgetPart> _nested_music_track_selection_widgets = {
632 NWidget(WWT_DROPDOWN, Colours::Grey, WID_MTS_MUSICSET), SetStringTip(STR_PLAYLIST_CHANGE_SET, STR_PLAYLIST_TOOLTIP_CHANGE_SET),
633 EndContainer(),
635 NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
636 /* Left panel. */
638 NWidget(WWT_LABEL, Colours::Invalid), SetFill(1, 0), SetStringTip(STR_PLAYLIST_TRACK_INDEX),
639 NWidget(WWT_PANEL, Colours::Grey, WID_MTS_LIST_LEFT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK), EndContainer(),
641 EndContainer(),
642 /* Middle buttons. */
644 NWidget(NWID_SPACER), SetMinimalSize(60, 30), // Space above the first button from the title bar.
645 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
646 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
647 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
648 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
649 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_CUSTOM1), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
650 NWidget(WWT_TEXTBTN, Colours::Grey, WID_MTS_CUSTOM2), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
651 NWidget(NWID_SPACER), SetMinimalSize(0, 16), // Space above 'clear' button
652 NWidget(WWT_PUSHTXTBTN, Colours::Grey, WID_MTS_CLEAR), SetFill(1, 0), SetStringTip(STR_PLAYLIST_CLEAR, STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1),
654 EndContainer(),
655 /* Right panel. */
658 NWidget(WWT_PANEL, Colours::Grey, WID_MTS_LIST_RIGHT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK), EndContainer(),
660 EndContainer(),
661 EndContainer(),
662 EndContainer(),
663};
664
668 WindowClass::MusicTrackSelection, WindowClass::None,
669 {},
670 _nested_music_track_selection_widgets
671);
672
673static void ShowMusicTrackSelection()
674{
676}
677
678struct MusicWindow : public Window {
679 MusicWindow(WindowDesc &desc, WindowNumber number) : Window(desc)
680 {
681 this->InitNested(number);
682 this->LowerWidget(WID_M_ALL + to_underlying(_settings_client.music.playlist));
684
685 UpdateDisabledButtons();
686 }
687
688 void UpdateDisabledButtons()
689 {
690 /* Disable stop and play if there is no music. */
692 /* Disable most music control widgets if there is no music, or we are in the intro menu. */
694 BaseMusic::GetUsedSet()->num_available == 0 || _game_mode == GameMode::Menu,
697 );
698 /* Also disable programme button in the intro menu (not in game; it is desirable to allow change of music set.) */
700 }
701
702 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
703 {
704 switch (widget) {
705 /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
706 * This can't be done by using NWidContainerFlag::EqualSize as the WID_M_INFO is
707 * between those widgets and of different size. */
708 case WID_M_SHUFFLE: case WID_M_PROGRAMME: {
709 Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE));
710 d.width += padding.width;
711 d.height += padding.height;
712 size = maxdim(size, d);
713 break;
714 }
715
716 case WID_M_TRACK_NR: {
717 Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
718 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TRACK_DIGIT, GetParamMaxDigits(2, FontSize::Small), 2)));
719 d.width += padding.width;
720 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
721 size = maxdim(size, d);
722 break;
723 }
724
725 case WID_M_TRACK_NAME: {
726 Dimension d = GetStringBoundingBox(STR_MUSIC_TITLE_NONE);
727 for (const auto &song : _music.music_set) {
728 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TITLE_NAME, song.songname)));
729 }
730 d.width += padding.width;
731 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
732 size = maxdim(size, d);
733 break;
734 }
735
736 /* Hack-ish: set the proper widget data; only needs to be done once
737 * per (Re)Init as that's the only time the language changes. */
741 }
742 }
743
744 void DrawWidget(const Rect &r, WidgetID widget) const override
745 {
746 switch (widget) {
747 case WID_M_TRACK_NR: {
749 if (BaseMusic::GetUsedSet()->num_available == 0) {
750 break;
751 }
752 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
753 if (_music.IsPlaying()) {
754 DrawString(ir, GetString(STR_MUSIC_TRACK_DIGIT, _music.GetCurrentSong().tracknr, 2), TextColour::FromString, AlignmentH::Centre);
755 } else {
756 DrawString(ir, STR_MUSIC_TRACK_NONE, TextColour::FromString, AlignmentH::Centre);
757 }
758 break;
759 }
760
761 case WID_M_TRACK_NAME: {
763 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
764
765 MusicSystem::PlaylistEntry entry(_music.GetCurrentSong());
766 if (BaseMusic::GetUsedSet()->num_available == 0) {
767 DrawString(ir, STR_MUSIC_TITLE_NOMUSIC, TextColour::FromString, AlignmentH::Centre);
768 } else if (_music.IsPlaying()) {
769 DrawString(ir, GetString(STR_MUSIC_TITLE_NAME, entry.songname), TextColour::FromString, AlignmentH::Centre);
770 } else {
771 DrawString(ir, STR_MUSIC_TITLE_NONE, TextColour::FromString, AlignmentH::Centre);
772 }
773
774 break;
775 }
776
777 case WID_M_MUSIC_VOL:
778 DrawSliderWidget(r, Colours::Grey, Colours::Grey, TextColour::Black, 0, INT8_MAX, 0, _settings_client.music.music_vol, nullptr);
779 break;
780
781 case WID_M_EFFECT_VOL:
782 DrawSliderWidget(r, Colours::Grey, Colours::Grey, TextColour::Black, 0, INT8_MAX, 0, _settings_client.music.effect_vol, nullptr);
783 break;
784 }
785 }
786
792 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
793 {
794 if (!gui_scope) return;
796 this->SetWidgetLoweredState(WID_M_ALL + to_underlying(playlist), playlist == _settings_client.music.playlist);
797 }
798
799 UpdateDisabledButtons();
800
801 if (data == 1) {
802 this->ReInit();
803 } else {
804 this->SetDirty();
805 }
806 }
807
808 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
809 {
810 switch (widget) {
811 case WID_M_PREV: // skip to prev
812 _music.Prev();
813 break;
814
815 case WID_M_NEXT: // skip to next
816 _music.Next();
817 break;
818
819 case WID_M_STOP: // stop playing
820 _music.Stop();
821 break;
822
823 case WID_M_PLAY: // start playing
824 _music.Play();
825 break;
826
827 case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders
828 uint8_t &vol = (widget == WID_M_MUSIC_VOL) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
829 if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, 0, vol)) {
830 if (widget == WID_M_MUSIC_VOL) {
832 } else {
833 SetEffectVolume(vol);
834 }
835 this->SetWidgetDirty(widget);
836 SetWindowClassesDirty(WindowClass::GameOptions);
837 }
838
839 if (click_count > 0) this->mouse_capture_widget = widget;
840 break;
841 }
842
843 case WID_M_SHUFFLE: // toggle shuffle
844 if (_music.IsShuffle()) {
845 _music.Unshuffle();
846 } else {
847 _music.Shuffle();
848 }
849 this->SetWidgetLoweredState(WID_M_SHUFFLE, _music.IsShuffle());
851 break;
852
853 case WID_M_PROGRAMME: // show track selection
854 ShowMusicTrackSelection();
855 break;
856
857 case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
858 case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
859 _music.ChangePlaylist(static_cast<PlaylistChoice>(widget - WID_M_ALL));
860 break;
861 }
862 }
863};
864
865static constexpr std::initializer_list<NWidgetPart> _nested_music_window_widgets = {
868 NWidget(WWT_CAPTION, Colours::Grey), SetStringTip(STR_MUSIC_JAZZ_JUKEBOX_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
871 EndContainer(),
872
878 NWidget(WWT_PUSHIMGBTN, Colours::Grey, WID_M_NEXT), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_SKIP_TO_NEXT, STR_MUSIC_TOOLTIP_SKIP_TO_NEXT_TRACK_IN_SELECTION),
881 EndContainer(),
883 EndContainer(),
887 NWidget(WWT_LABEL, Colours::Invalid), SetFill(1, 0), SetStringTip(STR_MUSIC_MUSIC_VOLUME),
888 NWidget(WWT_EMPTY, Colours::Invalid, WID_M_MUSIC_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
889 EndContainer(),
891 NWidget(WWT_LABEL, Colours::Invalid), SetFill(1, 0), SetStringTip(STR_MUSIC_EFFECTS_VOLUME),
892 NWidget(WWT_EMPTY, Colours::Invalid, WID_M_EFFECT_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
893 EndContainer(),
894 EndContainer(),
895 EndContainer(),
896 EndContainer(),
900 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_SHUFFLE), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_SHUFFLE, STR_MUSIC_TOOLTIP_TOGGLE_PROGRAM_SHUFFLE),
901 EndContainer(),
905 EndContainer(),
909 EndContainer(),
911 NWidget(WWT_PUSHTXTBTN, Colours::Grey, WID_M_PROGRAMME), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_PROGRAM, STR_MUSIC_TOOLTIP_SHOW_MUSIC_TRACK_SELECTION),
912 EndContainer(),
913 EndContainer(),
914 EndContainer(),
916 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
917 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
918 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
919 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
920 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_CUSTOM1), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
921 NWidget(WWT_TEXTBTN, Colours::Grey, WID_M_CUSTOM2), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
922 EndContainer(),
923};
924
927 WindowPosition::Automatic, "music", 0, 0,
928 WindowClass::Music, WindowClass::None,
929 {},
930 _nested_music_window_widgets
931);
932
933void ShowMusicWindow()
934{
936}
Generic functions for replacing base music data.
static const uint NUM_SONGS_AVAILABLE
Maximum number of songs in the full playlist; theme song + the classes.
static const uint NUM_SONGS_CLASS
Maximum number of songs in the 'class' playlists.
static const uint NUM_SONGS_PLAYLIST
Maximum number of songs in the (custom) playlist.
static const MusicSet * GetUsedSet()
static const MusicSet * GetSet(int index)
static int GetIndexOfUsedSet()
static bool SetSetByName(const std::string &name)
static std::string ini_set
The set as saved in the config file.
Iterate a range of enum values.
virtual void StopSong()=0
Stop playing the current song.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
virtual void PlaySong(const MusicSongInfo &song)=0
Play a particular song.
virtual void SetVolume(uint8_t vol)=0
Set the volume, if possible.
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:94
static IDirectMusic * _music
The direct music object manages buffers and ports.
Definition dmusic.cpp:189
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a drop down list.
Definition dropdown.cpp:591
Types related to the drop down widget.
@ Filterable
Set if the dropdown is filterable.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Definition enum_type.hpp:21
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:88
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Geometry functions.
@ Centre
Align to the centre.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:894
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition gfx.cpp:111
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:663
Functions related to the gfx engine.
@ Small
Index of the small font in the font tables.
Definition gfx_type.h:250
@ Invalid
Invalid marker.
Definition gfx_type.h:302
@ Grey
Grey.
Definition gfx_type.h:299
@ FromString
Marker for telling to use the colour from the string.
Definition gfx_type.h:317
@ Black
Black colour.
Definition gfx_type.h:334
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FontSize::Normal)
Widget part function for setting the minimal text lines.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
Definition window.cpp:1013
#define Point
Macro that prevents name conflicts between included headers.
Functions to mix sound samples.
Base for all music playback.
void MusicLoop()
Check music playback status and start/stop/song-finished.
static WindowDesc _music_window_desc(WindowPosition::Automatic, "music", 0, 0, WindowClass::Music, WindowClass::None, {}, _nested_music_window_widgets)
Window definition for the music window.
static WindowDesc _music_track_selection_desc(WindowPosition::Automatic, {}, 0, 0, WindowClass::MusicTrackSelection, WindowClass::None, {}, _nested_music_track_selection_widgets)
Window definition for the music track selection window.
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
static bool IsCustomPlaylist(PlaylistChoice playlist)
Test if a PlaylistChoice is a custom playlist.
void InitializeMusic()
Prepare the music system for use.
Types related to the music widgets.
@ WID_MTS_OLD
Old button.
@ WID_MTS_CUSTOM2
Custom2 button.
@ WID_MTS_ALL
All button.
@ WID_MTS_CUSTOM1
Custom1 button.
@ WID_MTS_LIST_LEFT
Left button.
@ WID_MTS_EZY
Ezy button.
@ WID_MTS_CLEAR
Clear button.
@ WID_MTS_LIST_RIGHT
Right button.
@ WID_MTS_NEW
New button.
@ WID_MTS_PLAYLIST
Playlist.
@ WID_MTS_MUSICSET
Music set selection.
@ WID_MTS_CAPTION
Window caption.
@ WID_M_PREV
Previous button.
@ WID_M_TRACK_NAME
Track name.
@ WID_M_NEXT
Next button.
@ WID_M_NEW
New button.
@ WID_M_TRACK_TITLE
Track title.
@ WID_M_STOP
Stop button.
@ WID_M_BACKGROUND
Background of the window.
@ WID_M_ALL
All button.
@ WID_M_CUSTOM2
Custom2 button.
@ WID_M_CUSTOM1
Custom1 button.
@ WID_M_TRACK
Track playing.
@ WID_M_OLD
Old button.
@ WID_M_SLIDERS
Sliders.
@ WID_M_SHUFFLE
Shuffle button.
@ WID_M_EZY
Ezy button.
@ WID_M_MUSIC_VOL
Music volume.
@ WID_M_EFFECT_VOL
Effect volume.
@ WID_M_TRACK_NR
Track number.
@ WID_M_PROGRAMME
Program button.
@ WID_M_PLAY
Play button.
Some generic types.
@ Menu
In the main menu.
Definition openttd.h:19
static constexpr PixelColour PC_BLACK
Black palette colour.
Pseudo random number generator.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
Functions for setting GUIs.
Types related to global configuration settings.
PlaylistChoice
Playlists.
@ Custom2
Play the second custom playlist.
@ ThemeOnly
Play only the theme music.
@ All
Play all music (except theme).
@ Custom1
Play the first custom playlist.
@ OldStyle
Play "old style" music.
void DrawSliderWidget(Rect r, Colours wedge_colour, Colours handle_colour, TextColour text_colour, int min_value, int max_value, int nmarks, int value, SliderMarkFunc *mark_func, int soft_min, int soft_max)
Draw a slider widget with knob at given value.
Definition slider.cpp:36
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, int &value)
Handle click on a slider widget to change the value.
Definition slider.cpp:123
Functions related to the horizontal slider widget.
This file contains all sprite-related enums and defines.
static const SpriteID SPR_IMG_STOP_MUSIC
Definition sprites.h:1472
static const SpriteID SPR_IMG_PLAY_MUSIC
Definition sprites.h:1473
static const SpriteID SPR_IMG_SKIP_TO_NEXT
Definition sprites.h:1471
static const SpriteID SPR_IMG_PLAY_MUSIC_RTL
Play music button, but then for RTL users.
Definition sprites.h:82
static const SpriteID SPR_IMG_SKIP_TO_PREV
Definition sprites.h:1470
Definition of base types and functions in a cross-platform compatible way.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:423
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:55
uint64_t GetParamMaxDigits(uint count, FontSize size)
Get some number that is suitable for string size computations.
Definition strings.cpp:217
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
Dimensions (a width and height) of a rectangle in 2D.
value_type height
The height of the rectangle.
value_type width
The width of the rectangle.
All data of a music set.
Metadata about a music track.
std::string songname
name of song displayed in UI
std::string filename
file on disk containing song (when used in MusicSet class)
bool loop
song should play in a tight loop if possible, never ending
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
const MusicSet * set
music set the song comes from
Definition music_gui.cpp:36
uint set_index
index of song in set
Definition music_gui.cpp:37
void CheckStatus()
Check that music is playing if it should, and that appropriate playlist is active for game/main menu.
void ChangeMusicSet(const std::string &set_name)
Change to named music set, and reset playback.
void Shuffle()
Enable shuffle mode.
void Stop()
Stop playback and set flag that we don't intend to play music.
void BuildPlaylists()
Rebuild all playlists for the current music set.
Definition music_gui.cpp:86
void Next()
Skip to next track.
void Play()
Start/restart playback at current song.
bool IsPlaying() const
Is the player getting music right now?
void Unshuffle()
Disable shuffle mode.
void PlaylistRemove(size_t song_index)
Remove a song from a custom playlist.
void ChangePlaylist(PlaylistChoice pl)
Switch to another playlist, or reload the current one.
PlaylistEntry GetCurrentSong() const
Return the current song, or a dummy if none.
void PlaylistAdd(size_t song_index)
Append a song to a custom playlist.
void ChangePlaylistPosition(int ofs)
Change playlist position pointer by the given offset, making sure to keep it within valid range.
Playlist active_playlist
current play order of songs, including any shuffle
Definition music_gui.cpp:44
void Prev()
Skip to previous track.
void PlaylistClear()
Remove all songs from the current custom playlist.
void SaveCustomPlaylist(PlaylistChoice pl)
Save a custom playlist to settings after modification.
void SetPositionBySetIndex(uint set_index)
Set playlist position by set index.
bool IsCustomPlaylist() const
Is one of the custom playlists selected?
bool IsShuffle() const
Is shuffle mode enabled?
Playlist music_set
all songs in current music set, in set order
Definition music_gui.cpp:45
uint GetSetIndex()
Get set index from current playlist position.
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.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
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.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
High level window description.
Definition window_gui.h:171
Number to differentiate different windows of the same class.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:1025
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:565
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:513
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). INVALID_WIDGET if no widget has mouse ca...
Definition window_gui.h:325
ResizeInfo resize
Resize information.
Definition window_gui.h:313
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:514
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:440
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1879
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Definition window.cpp:218
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:459
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1869
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:380
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
@ WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition widget_type.h:40
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:70
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
@ 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_VERTICAL
Vertical container.
Definition widget_type.h:68
@ WWT_CLOSEBOX
Close box (at top-left of a window).
Definition widget_type.h:60
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
@ WWT_DROPDOWN
Drop down list.
Definition widget_type.h:61
@ EqualSize
Containers should keep all their (resizing) children equally large.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting).
Definition window.cpp:3285
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition window.cpp:3377
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ Automatic
Find a place automatically.
Definition window_gui.h:145
int WidgetID
Widget ID.
Definition window_type.h:21
@ GameOptions
Game options.
Definition window_type.h:32