OpenTTD Source 20250908-master-g16cd420e4c
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 <http://www.gnu.org/licenses/>.
6 */
7
10#include "stdafx.h"
11#include "openttd.h"
12#include "base_media_base.h"
13#include "base_media_music.h"
15#include "window_gui.h"
16#include "strings_func.h"
17#include "window_func.h"
18#include "sound_func.h"
19#include "gfx_func.h"
20#include "zoom_func.h"
21#include "core/random_func.hpp"
22#include "error.h"
24#include "string_func.h"
25#include "settings_type.h"
26#include "settings_gui.h"
27#include "dropdown_func.h"
28#include "dropdown_type.h"
29#include "slider_func.h"
30#include "mixer.h"
31
33
34#include "table/strings.h"
35#include "table/sprites.h"
36
37#include "safeguards.h"
38
39
42 const MusicSet *set;
43 uint set_index;
44
46 bool IsValid() const { return !this->songname.empty(); }
47 };
48 typedef std::vector<PlaylistEntry> Playlist;
49
50 enum PlaylistChoices : uint8_t {
51 PLCH_ALLMUSIC,
52 PLCH_OLDSTYLE,
53 PLCH_NEWSTYLE,
54 PLCH_EZYSTREET,
55 PLCH_CUSTOM1,
56 PLCH_CUSTOM2,
57 PLCH_THEMEONLY,
58 PLCH_MAX,
59 };
60
61 Playlist active_playlist{};
62 Playlist music_set{};
63
64 PlaylistChoices selected_playlist{};
65
66 void BuildPlaylists();
67
68 void ChangePlaylist(PlaylistChoices pl);
69 void ChangeMusicSet(const std::string &set_name);
70 void Shuffle();
71 void Unshuffle();
72
73 void Play();
74 void Stop();
75 void Next();
76 void Prev();
77 void CheckStatus();
78
79 bool IsPlaying() const;
80 bool IsShuffle() const;
81 PlaylistEntry GetCurrentSong() const;
82
83 bool IsCustomPlaylist() const;
84 void PlaylistAdd(size_t song_index);
85 void PlaylistRemove(size_t song_index);
86 void PlaylistClear();
87
88private:
89 uint GetSetIndex();
90 void SetPositionBySetIndex(uint set_index);
91 void ChangePlaylistPosition(int ofs);
92 int playlist_position = 0;
93
94 void SaveCustomPlaylist(PlaylistChoices pl);
95
96 std::array<Playlist, PLCH_MAX> standard_playlists{};
97};
98
99MusicSystem _music;
100
101
104{
105 const MusicSet *set = BaseMusic::GetUsedSet();
106
107 /* Clear current playlists */
108 for (auto &playlist : this->standard_playlists) playlist.clear();
109 this->music_set.clear();
110
111 /* Build standard playlists, and a list of available music */
112 for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
113 PlaylistEntry entry(set, i);
114 if (!entry.IsValid()) continue;
115
116 this->music_set.push_back(entry);
117
118 /* Add theme song to theme-only playlist */
119 if (i == 0) this->standard_playlists[PLCH_THEMEONLY].push_back(std::move(entry));
120
121 /* Don't add the theme song to standard playlists */
122 if (i > 0) {
123 this->standard_playlists[PLCH_ALLMUSIC].push_back(entry);
124 uint theme = (i - 1) / NUM_SONGS_CLASS;
125 this->standard_playlists[PLCH_OLDSTYLE + theme].push_back(std::move(entry));
126 }
127 }
128
129 /* Load custom playlists
130 * Song index offsets are 1-based, zero indicates invalid/end-of-list value */
131 for (uint i = 0; i < NUM_SONGS_PLAYLIST; i++) {
133 PlaylistEntry entry(set, _settings_client.music.custom_1[i] - 1);
134 if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM1].push_back(std::move(entry));
135 }
137 PlaylistEntry entry(set, _settings_client.music.custom_2[i] - 1);
138 if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM2].push_back(std::move(entry));
139 }
140 }
141}
142
147void MusicSystem::ChangePlaylist(PlaylistChoices pl)
148{
149 assert(pl < PLCH_MAX && pl >= PLCH_ALLMUSIC);
150
151 if (pl != PLCH_THEMEONLY) _settings_client.music.playlist = pl;
152
153 if (_game_mode != GM_MENU || pl == PLCH_THEMEONLY) {
154 this->selected_playlist = pl;
155 this->active_playlist = this->standard_playlists[this->selected_playlist];
156 this->playlist_position = 0;
157
159 if (_settings_client.music.playing) this->Play();
160 }
161
164}
165
170void MusicSystem::ChangeMusicSet(const std::string &set_name)
171{
172 BaseMusic::SetSetByName(set_name);
173 BaseMusic::ini_set = set_name;
174
175 this->BuildPlaylists();
176 this->ChangePlaylist(this->selected_playlist);
177
181}
182
188{
189 auto it = std::ranges::find(this->active_playlist, set_index, &PlaylistEntry::set_index);
190 if (it != std::end(this->active_playlist)) this->playlist_position = std::distance(std::begin(this->active_playlist), it);
191}
192
198{
199 return static_cast<size_t>(this->playlist_position) < this->active_playlist.size()
200 ? this->active_playlist[this->playlist_position].set_index
201 : UINT_MAX;
202}
203
208{
210
211 uint set_index = this->GetSetIndex();
212 this->active_playlist = this->standard_playlists[this->selected_playlist];
213 for (size_t i = 0; i < this->active_playlist.size(); i++) {
214 size_t shuffle_index = InteractiveRandom() % (this->active_playlist.size() - i);
215 std::swap(this->active_playlist[i], this->active_playlist[i + shuffle_index]);
216 }
217 this->SetPositionBySetIndex(set_index);
218
221}
222
227{
229
230 uint set_index = this->GetSetIndex();
231 this->active_playlist = this->standard_playlists[this->selected_playlist];
232 this->SetPositionBySetIndex(set_index);
233
236}
237
240{
241 /* Always set the playing flag, even if there is no music */
244 /* Make sure playlist_position is a valid index, if playlist has changed etc. */
245 this->ChangePlaylistPosition(0);
246
247 /* If there is no music, don't try to play it */
248 if (this->active_playlist.empty()) return;
249
250 MusicSongInfo song = this->active_playlist[this->playlist_position];
251 if (_game_mode == GM_MENU && this->selected_playlist == PLCH_THEMEONLY) song.loop = true;
253
255}
256
265
274
283
286{
287 if ((_game_mode == GM_MENU) != (this->selected_playlist == PLCH_THEMEONLY)) {
288 /* Make sure the theme-only playlist is active when on the title screen, and not during gameplay */
289 this->ChangePlaylist((_game_mode == GM_MENU) ? PLCH_THEMEONLY : (PlaylistChoices)_settings_client.music.playlist);
290 }
291 if (this->active_playlist.empty()) return;
292 /* If we were supposed to be playing, but music has stopped, move to next song */
293 if (this->IsPlaying() && !MusicDriver::GetInstance()->IsSongPlaying()) this->Next();
294}
295
298{
299 return _settings_client.music.playing && !this->active_playlist.empty();
300}
301
304{
306}
307
310{
311 if (!this->IsPlaying()) return PlaylistEntry(BaseMusic::GetUsedSet(), 0);
312 return this->active_playlist[this->playlist_position];
313}
314
317{
318 return (this->selected_playlist == PLCH_CUSTOM1) || (this->selected_playlist == PLCH_CUSTOM2);
319}
320
326void MusicSystem::PlaylistAdd(size_t song_index)
327{
328 if (!this->IsCustomPlaylist()) return;
329
330 /* Pick out song from the music set */
331 if (song_index >= this->music_set.size()) return;
332 PlaylistEntry entry = this->music_set[song_index];
333
334 /* Check for maximum length */
335 if (this->standard_playlists[this->selected_playlist].size() >= NUM_SONGS_PLAYLIST) return;
336
337 /* Add it to the appropriate playlist, and the display */
338 this->standard_playlists[this->selected_playlist].push_back(entry);
339
340 /* Add it to the active playlist, if playback is shuffled select a random position to add at */
341 if (this->active_playlist.empty()) {
342 this->active_playlist.push_back(std::move(entry));
343 if (this->IsPlaying()) this->Play();
344 } else if (this->IsShuffle()) {
345 /* Generate a random position between 0 and n (inclusive, new length) to insert at */
346 size_t maxpos = this->active_playlist.size() + 1;
347 size_t newpos = InteractiveRandom() % maxpos;
348 this->active_playlist.insert(this->active_playlist.begin() + newpos, entry);
349 /* Make sure to shift up the current playback position if the song was inserted before it */
350 if ((int)newpos <= this->playlist_position) this->playlist_position++;
351 } else {
352 this->active_playlist.push_back(std::move(entry));
353 }
354
355 this->SaveCustomPlaylist(this->selected_playlist);
356
358}
359
364void MusicSystem::PlaylistRemove(size_t song_index)
365{
366 if (!this->IsCustomPlaylist()) return;
367
368 Playlist &pl = this->standard_playlists[this->selected_playlist];
369 if (song_index >= pl.size()) return;
370
371 /* Remove from "simple" playlists */
372 PlaylistEntry song = pl[song_index];
373 pl.erase(pl.begin() + song_index);
374
375 /* Find in actual active playlist (may be shuffled) and remove,
376 * if it's the current song restart playback */
377 for (size_t i = 0; i < this->active_playlist.size(); i++) {
378 Playlist::iterator s2 = this->active_playlist.begin() + i;
379 if (s2->filename == song.filename && s2->cat_index == song.cat_index) {
380 this->active_playlist.erase(s2);
381 if ((int)i == this->playlist_position && this->IsPlaying()) this->Play();
382 break;
383 }
384 }
385
386 this->SaveCustomPlaylist(this->selected_playlist);
387
389}
390
396{
397 if (!this->IsCustomPlaylist()) return;
398
399 this->standard_playlists[this->selected_playlist].clear();
400 this->ChangePlaylist(this->selected_playlist);
401
402 this->SaveCustomPlaylist(this->selected_playlist);
403}
404
411{
412 if (this->active_playlist.empty()) {
413 this->playlist_position = 0;
414 } else {
415 this->playlist_position += ofs;
416 while (this->playlist_position >= (int)this->active_playlist.size()) this->playlist_position -= (int)this->active_playlist.size();
417 while (this->playlist_position < 0) this->playlist_position += (int)this->active_playlist.size();
418 }
419}
420
425void MusicSystem::SaveCustomPlaylist(PlaylistChoices pl)
426{
427 uint8_t *settings_pl;
428 if (pl == PLCH_CUSTOM1) {
429 settings_pl = _settings_client.music.custom_1;
430 } else if (pl == PLCH_CUSTOM2) {
431 settings_pl = _settings_client.music.custom_2;
432 } else {
433 return;
434 }
435
436 size_t num = 0;
437 std::fill_n(settings_pl, NUM_SONGS_PLAYLIST, 0);
438
439 for (const auto &song : this->standard_playlists[pl]) {
440 /* Music set indices in the settings playlist are 1-based, 0 means unused slot */
441 settings_pl[num++] = (uint8_t)song.set_index + 1;
442 }
443}
444
445
451{
452 _music.CheckStatus();
453}
454
459void ChangeMusicSet(int index)
460{
461 if (BaseMusic::GetIndexOfUsedSet() == index) return;
462 _music.ChangeMusicSet(BaseMusic::GetSet(index)->name);
463}
464
470{
471 _music.BuildPlaylists();
472}
473
474
477 {
478 this->InitNested(number);
483 }
484
485 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
486 {
487 switch (widget) {
488 case WID_MTS_PLAYLIST:
489 return GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + _settings_client.music.playlist);
490
491 case WID_MTS_CAPTION:
492 return GetString(STR_PLAYLIST_MUSIC_SELECTION_SETNAME, BaseMusic::GetUsedSet()->name);
493
494 default:
495 return this->Window::GetWidgetString(widget, stringid);
496 }
497 }
498
504 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
505 {
506 if (!gui_scope) return;
507 for (int i = 0; i < 6; i++) {
509 }
511
512 if (data == 1) {
513 this->ReInit();
514 } else {
515 this->SetDirty();
516 }
517 }
518
519 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
520 {
521 switch (widget) {
522 case WID_MTS_PLAYLIST: {
523 Dimension d = {0, 0};
524
525 for (int i = 0; i < 6; i++) {
526 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + i)));
527 }
528 d.width += padding.width;
529 d.height += padding.height;
530 size = maxdim(size, d);
531 break;
532 }
533
535 Dimension d = {0, 0};
536
537 for (const auto &song : _music.music_set) {
538 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname)));
539 }
540 d.height *= std::max(NUM_SONGS_AVAILABLE, NUM_SONGS_PLAYLIST);
541
542 d.width += padding.width;
543 d.height += padding.height;
544 size = maxdim(size, d);
545 break;
546 }
547 }
548 }
549
550 void DrawWidget(const Rect &r, WidgetID widget) const override
551 {
552 switch (widget) {
553 case WID_MTS_LIST_LEFT: {
555
556 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
557 for (const auto &song : _music.music_set) {
558 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
559 tr.top += GetCharacterHeight(FS_SMALL);
560 }
561 break;
562 }
563
564 case WID_MTS_LIST_RIGHT: {
566
567 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
568 for (const auto &song : _music.active_playlist) {
569 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
570 tr.top += GetCharacterHeight(FS_SMALL);
571 }
572 break;
573 }
574 }
575 }
576
577 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
578 {
579 switch (widget) {
580 case WID_MTS_LIST_LEFT: { // add to playlist
582 _music.PlaylistAdd(y);
583 break;
584 }
585
586 case WID_MTS_LIST_RIGHT: { // remove from playlist
588 _music.PlaylistRemove(y);
589 break;
590 }
591
592 case WID_MTS_MUSICSET: {
593 int selected = 0;
594 ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget);
595 break;
596 }
597
598 case WID_MTS_CLEAR: // clear
599 _music.PlaylistClear();
600 break;
601
602 case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
603 case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
604 _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_MTS_ALL));
605 break;
606 }
607 }
608
609 void OnDropdownSelect(WidgetID widget, int index, int) override
610 {
611 switch (widget) {
612 case WID_MTS_MUSICSET:
613 ChangeMusicSet(index);
614 break;
615 default:
616 NOT_REACHED();
617 }
618 }
619};
620
621static constexpr NWidgetPart _nested_music_track_selection_widgets[] = {
623 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
624 NWidget(WWT_CAPTION, COLOUR_GREY, WID_MTS_CAPTION),
625 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_MTS_MUSICSET), SetStringTip(STR_PLAYLIST_CHANGE_SET, STR_PLAYLIST_TOOLTIP_CHANGE_SET),
626 EndContainer(),
627 NWidget(WWT_PANEL, COLOUR_GREY),
628 NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
629 /* Left panel. */
631 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_PLAYLIST_TRACK_INDEX),
632 NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_LEFT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK), EndContainer(),
634 EndContainer(),
635 /* Middle buttons. */
637 NWidget(NWID_SPACER), SetMinimalSize(60, 30), // Space above the first button from the title bar.
638 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
639 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
640 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
641 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
642 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_CUSTOM1), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
643 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_CUSTOM2), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
644 NWidget(NWID_SPACER), SetMinimalSize(0, 16), // Space above 'clear' button
645 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_MTS_CLEAR), SetFill(1, 0), SetStringTip(STR_PLAYLIST_CLEAR, STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1),
647 EndContainer(),
648 /* Right panel. */
650 NWidget(WWT_LABEL, INVALID_COLOUR, WID_MTS_PLAYLIST), SetFill(1, 0),
651 NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_RIGHT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK), EndContainer(),
653 EndContainer(),
654 EndContainer(),
655 EndContainer(),
656};
657
658static WindowDesc _music_track_selection_desc(
659 WDP_AUTO, {}, 0, 0,
661 {},
662 _nested_music_track_selection_widgets
663);
664
665static void ShowMusicTrackSelection()
666{
667 AllocateWindowDescFront<MusicTrackSelectionWindow>(_music_track_selection_desc, 0);
668}
669
670struct MusicWindow : public Window {
671 MusicWindow(WindowDesc &desc, WindowNumber number) : Window(desc)
672 {
673 this->InitNested(number);
676
677 UpdateDisabledButtons();
678 }
679
680 void UpdateDisabledButtons()
681 {
682 /* Disable stop and play if there is no music. */
684 /* Disable most music control widgets if there is no music, or we are in the intro menu. */
686 BaseMusic::GetUsedSet()->num_available == 0 || _game_mode == GM_MENU,
689 );
690 /* Also disable programme button in the intro menu (not in game; it is desirable to allow change of music set.) */
691 this->SetWidgetsDisabledState(_game_mode == GM_MENU, WID_M_PROGRAMME);
692 }
693
694 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
695 {
696 switch (widget) {
697 /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
698 * This can't be done by using NWidContainerFlag::EqualSize as the WID_M_INFO is
699 * between those widgets and of different size. */
700 case WID_M_SHUFFLE: case WID_M_PROGRAMME: {
701 Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE));
702 d.width += padding.width;
703 d.height += padding.height;
704 size = maxdim(size, d);
705 break;
706 }
707
708 case WID_M_TRACK_NR: {
709 Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
710 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TRACK_DIGIT, GetParamMaxDigits(2, FS_SMALL), 2)));
711 d.width += padding.width;
712 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
713 size = maxdim(size, d);
714 break;
715 }
716
717 case WID_M_TRACK_NAME: {
718 Dimension d = GetStringBoundingBox(STR_MUSIC_TITLE_NONE);
719 for (const auto &song : _music.music_set) {
720 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TITLE_NAME, song.songname)));
721 }
722 d.width += padding.width;
723 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
724 size = maxdim(size, d);
725 break;
726 }
727
728 /* Hack-ish: set the proper widget data; only needs to be done once
729 * per (Re)Init as that's the only time the language changes. */
730 case WID_M_PREV: this->GetWidget<NWidgetCore>(WID_M_PREV)->SetSprite(_current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV); break;
731 case WID_M_NEXT: this->GetWidget<NWidgetCore>(WID_M_NEXT)->SetSprite(_current_text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT); break;
732 case WID_M_PLAY: this->GetWidget<NWidgetCore>(WID_M_PLAY)->SetSprite(_current_text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC); break;
733 }
734 }
735
736 void DrawWidget(const Rect &r, WidgetID widget) const override
737 {
738 switch (widget) {
739 case WID_M_TRACK_NR: {
741 if (BaseMusic::GetUsedSet()->num_available == 0) {
742 break;
743 }
744 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
745 if (_music.IsPlaying()) {
746 DrawString(ir, GetString(STR_MUSIC_TRACK_DIGIT, _music.GetCurrentSong().tracknr, 2), TC_FROMSTRING, SA_HOR_CENTER);
747 } else {
748 DrawString(ir, STR_MUSIC_TRACK_NONE, TC_FROMSTRING, SA_HOR_CENTER);
749 }
750 break;
751 }
752
753 case WID_M_TRACK_NAME: {
755 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
756
758 if (BaseMusic::GetUsedSet()->num_available == 0) {
759 DrawString(ir, STR_MUSIC_TITLE_NOMUSIC, TC_FROMSTRING, SA_HOR_CENTER);
760 } else if (_music.IsPlaying()) {
761 DrawString(ir, GetString(STR_MUSIC_TITLE_NAME, entry.songname), TC_FROMSTRING, SA_HOR_CENTER);
762 } else {
763 DrawString(ir, STR_MUSIC_TITLE_NONE, TC_FROMSTRING, SA_HOR_CENTER);
764 }
765
766 break;
767 }
768
769 case WID_M_MUSIC_VOL:
770 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.music_vol, nullptr);
771 break;
772
773 case WID_M_EFFECT_VOL:
774 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.effect_vol, nullptr);
775 break;
776 }
777 }
778
784 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
785 {
786 if (!gui_scope) return;
787 for (int i = 0; i < 6; i++) {
789 }
790
791 UpdateDisabledButtons();
792
793 if (data == 1) {
794 this->ReInit();
795 } else {
796 this->SetDirty();
797 }
798 }
799
800 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
801 {
802 switch (widget) {
803 case WID_M_PREV: // skip to prev
804 _music.Prev();
805 break;
806
807 case WID_M_NEXT: // skip to next
808 _music.Next();
809 break;
810
811 case WID_M_STOP: // stop playing
812 _music.Stop();
813 break;
814
815 case WID_M_PLAY: // start playing
816 _music.Play();
817 break;
818
819 case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders
821 if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, 0, vol)) {
822 if (widget == WID_M_MUSIC_VOL) {
824 } else {
825 SetEffectVolume(vol);
826 }
827 this->SetWidgetDirty(widget);
829 }
830
831 if (click_count > 0) this->mouse_capture_widget = widget;
832 break;
833 }
834
835 case WID_M_SHUFFLE: // toggle shuffle
836 if (_music.IsShuffle()) {
837 _music.Unshuffle();
838 } else {
839 _music.Shuffle();
840 }
843 break;
844
845 case WID_M_PROGRAMME: // show track selection
846 ShowMusicTrackSelection();
847 break;
848
849 case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
850 case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
851 _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_M_ALL));
852 break;
853 }
854 }
855};
856
857static constexpr NWidgetPart _nested_music_window_widgets[] = {
859 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
860 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_MUSIC_JAZZ_JUKEBOX_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
861 NWidget(WWT_SHADEBOX, COLOUR_GREY),
862 NWidget(WWT_STICKYBOX, COLOUR_GREY),
863 EndContainer(),
864
867 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
869 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PREV), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_SKIP_TO_PREV, STR_MUSIC_TOOLTIP_SKIP_TO_PREVIOUS_TRACK),
870 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_NEXT), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_SKIP_TO_NEXT, STR_MUSIC_TOOLTIP_SKIP_TO_NEXT_TRACK_IN_SELECTION),
871 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_STOP), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_STOP_MUSIC, STR_MUSIC_TOOLTIP_STOP_PLAYING_MUSIC),
872 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PLAY), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_PLAY_MUSIC, STR_MUSIC_TOOLTIP_START_PLAYING_MUSIC),
873 EndContainer(),
874 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
875 EndContainer(),
876 NWidget(WWT_PANEL, COLOUR_GREY, WID_M_SLIDERS),
879 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_MUSIC_MUSIC_VOLUME),
880 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_M_MUSIC_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
881 EndContainer(),
883 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_MUSIC_EFFECTS_VOLUME),
884 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_M_EFFECT_VOL), SetMinimalSize(67, 0), SetMinimalTextLines(1, 0), SetFill(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
885 EndContainer(),
886 EndContainer(),
887 EndContainer(),
888 EndContainer(),
889 NWidget(WWT_PANEL, COLOUR_GREY, WID_M_BACKGROUND),
892 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_SHUFFLE), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_SHUFFLE, STR_MUSIC_TOOLTIP_TOGGLE_PROGRAM_SHUFFLE),
893 EndContainer(),
895 NWidget(WWT_LABEL, INVALID_COLOUR, WID_M_TRACK), SetFill(0, 0), SetStringTip(STR_MUSIC_TRACK),
896 NWidget(WWT_INSET, COLOUR_GREY, WID_M_TRACK_NR), SetFill(0, 0), EndContainer(),
897 EndContainer(),
899 NWidget(WWT_LABEL, INVALID_COLOUR, WID_M_TRACK_TITLE), SetFill(1, 0), SetStringTip(STR_MUSIC_XTITLE),
900 NWidget(WWT_INSET, COLOUR_GREY, WID_M_TRACK_NAME), SetFill(1, 0), EndContainer(),
901 EndContainer(),
903 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_M_PROGRAMME), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_PROGRAM, STR_MUSIC_TOOLTIP_SHOW_MUSIC_TRACK_SELECTION),
904 EndContainer(),
905 EndContainer(),
906 EndContainer(),
908 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
909 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
910 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
911 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
912 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_CUSTOM1), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_1, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_1_USER_DEFINED),
913 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_CUSTOM2), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_CUSTOM_2, STR_MUSIC_TOOLTIP_SELECT_CUSTOM_2_USER_DEFINED),
914 EndContainer(),
915};
916
917static WindowDesc _music_window_desc(
918 WDP_AUTO, "music", 0, 0,
920 {},
921 _nested_music_window_widgets
922);
923
924void ShowMusicWindow()
925{
926 AllocateWindowDescFront<MusicWindow>(_music_window_desc, 0);
927}
Generic functions for replacing base data (graphics, sounds).
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()
Return the used set.
static const MusicSet * GetSet(int index)
Get the name of the graphics set at the specified index.
static int GetIndexOfUsedSet()
Get the index of the currently active graphics set.
static bool SetSetByName(const std::string &name)
Set the set to be used.
static std::string ini_set
The set as saved in the config file.
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.
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition window_gui.h:38
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:415
Functions related to the drop down widget.
Types related to the drop down widget.
Functions related to errors.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Geometry functions.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:895
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:666
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:116
Functions related to the gfx engine.
@ FS_SMALL
Index of the small font in the font tables.
Definition gfx_type.h:250
@ SA_HOR_CENTER
Horizontally center the text.
Definition gfx_type.h:389
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 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 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 SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
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:963
Functions to mix sound samples.
Base for all music playback.
void MusicLoop()
Check music playback status and start/stop/song-finished.
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
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.
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.
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)
Draw a slider widget with knob at given value.
Definition slider.cpp:34
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:94
Functions related to sound.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
uint64_t GetParamMaxDigits(uint count, FontSize size)
Get some number that is suitable for string size computations.
Definition strings.cpp:218
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
MusicSettings music
settings related to music/sound
Dimensions (a width and height) of a rectangle in 2D.
All data of a music set.
uint8_t effect_vol
The requested effects volume.
bool playing
Whether music is playing.
uint8_t music_vol
The requested music volume.
uint8_t custom_1[33]
The order of the first custom playlist.
uint8_t custom_2[33]
The order of the second custom playlist.
uint8_t playlist
The playlist (number) to play.
bool shuffle
Whether to shuffle the music.
Metadata about a music track.
std::string songname
name of song displayed in UI
uint8_t tracknr
track number 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:42
uint set_index
index of song in set
Definition music_gui.cpp:43
void SaveCustomPlaylist(PlaylistChoices pl)
Save a custom playlist to settings after modification.
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 ChangePlaylist(PlaylistChoices pl)
Switch to another playlist, or reload the current one.
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.
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.
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:61
void Prev()
Skip to previous track.
void PlaylistClear()
Remove all songs from the current custom playlist.
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:62
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.
Partial widget specification to allow NWidgets to be written nested.
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:167
Number to differentiate different windows of the same class.
Data structure for an opened window.
Definition window_gui.h:273
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:975
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:556
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
Definition window_gui.h:326
ResizeInfo resize
Resize information.
Definition window_gui.h:314
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:515
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:441
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:212
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:460
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1799
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:381
@ 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:41
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
@ WWT_LABEL
Centered label.
Definition widget_type.h:49
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:71
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:67
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:45
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:40
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:58
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:56
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:53
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:69
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:61
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:38
@ WWT_DROPDOWN
Drop down list.
Definition widget_type.h:62
@ 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:3181
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:3273
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:144
int WidgetID
Widget ID.
Definition window_type.h:20
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition window_type.h:28
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:47
@ WC_MUSIC_TRACK_SELECTION
Music track selection; Window numbers:
@ WC_MUSIC_WINDOW
Music window; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Functions related to zooming.