OpenTTD Source 20251005-master-ga617d009cc
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 if (song_index >= this->active_playlist.size()) return;
369
370 PlaylistEntry song = this->active_playlist[song_index];
371 this->active_playlist.erase(std::next(std::begin(this->active_playlist), song_index));
372
373 Playlist &playlist = this->standard_playlists[this->selected_playlist];
374 auto it = std::end(playlist);
375 if (this->IsShuffle()) {
376 /* Playlist is shuffled, so remove the first instance. */
377 it = std::ranges::find_if(playlist, [&song](const auto &s) { return s.filename == song.filename && s.cat_index == song.cat_index; });
378 } else if (song_index < playlist.size()) {
379 /* Not shuffled, we can remove the entry directly. */
380 it = std::next(std::begin(playlist), song_index);
381 }
382
383 if (it == std::end(playlist)) return;
384 it = playlist.erase(it);
385
386 /* If it's the current song restart playback. */
387 if (this->IsPlaying() && std::distance(std::begin(playlist), it) == this->playlist_position) this->Play();
388
389 this->SaveCustomPlaylist(this->selected_playlist);
390
392}
393
399{
400 if (!this->IsCustomPlaylist()) return;
401
402 this->standard_playlists[this->selected_playlist].clear();
403 this->ChangePlaylist(this->selected_playlist);
404
405 this->SaveCustomPlaylist(this->selected_playlist);
406}
407
414{
415 if (this->active_playlist.empty()) {
416 this->playlist_position = 0;
417 } else {
418 this->playlist_position += ofs;
419 while (this->playlist_position >= (int)this->active_playlist.size()) this->playlist_position -= (int)this->active_playlist.size();
420 while (this->playlist_position < 0) this->playlist_position += (int)this->active_playlist.size();
421 }
422}
423
428void MusicSystem::SaveCustomPlaylist(PlaylistChoices pl)
429{
430 uint8_t *settings_pl;
431 if (pl == PLCH_CUSTOM1) {
432 settings_pl = _settings_client.music.custom_1;
433 } else if (pl == PLCH_CUSTOM2) {
434 settings_pl = _settings_client.music.custom_2;
435 } else {
436 return;
437 }
438
439 size_t num = 0;
440 std::fill_n(settings_pl, NUM_SONGS_PLAYLIST, 0);
441
442 for (const auto &song : this->standard_playlists[pl]) {
443 /* Music set indices in the settings playlist are 1-based, 0 means unused slot */
444 settings_pl[num++] = (uint8_t)song.set_index + 1;
445 }
446}
447
448
454{
455 _music.CheckStatus();
456}
457
462void ChangeMusicSet(int index)
463{
464 if (BaseMusic::GetIndexOfUsedSet() == index) return;
465 _music.ChangeMusicSet(BaseMusic::GetSet(index)->name);
466}
467
473{
474 _music.BuildPlaylists();
475}
476
477
480 {
481 this->InitNested(number);
486 }
487
488 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
489 {
490 switch (widget) {
491 case WID_MTS_PLAYLIST:
492 return GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + _settings_client.music.playlist);
493
494 case WID_MTS_CAPTION:
495 return GetString(STR_PLAYLIST_MUSIC_SELECTION_SETNAME, BaseMusic::GetUsedSet()->name);
496
497 default:
498 return this->Window::GetWidgetString(widget, stringid);
499 }
500 }
501
507 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
508 {
509 if (!gui_scope) return;
510 for (int i = 0; i < 6; i++) {
512 }
514
515 if (data == 1) {
516 this->ReInit();
517 } else {
518 this->SetDirty();
519 }
520 }
521
522 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
523 {
524 switch (widget) {
525 case WID_MTS_PLAYLIST: {
526 Dimension d = {0, 0};
527
528 for (int i = 0; i < 6; i++) {
529 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_PROGRAM, STR_MUSIC_PLAYLIST_ALL + i)));
530 }
531 d.width += padding.width;
532 d.height += padding.height;
533 size = maxdim(size, d);
534 break;
535 }
536
538 Dimension d = {0, 0};
539
540 for (const auto &song : _music.music_set) {
541 d = maxdim(d, GetStringBoundingBox(GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname)));
542 }
543 d.height *= std::max(NUM_SONGS_AVAILABLE, NUM_SONGS_PLAYLIST);
544
545 d.width += padding.width;
546 d.height += padding.height;
547 size = maxdim(size, d);
548 break;
549 }
550 }
551 }
552
553 void DrawWidget(const Rect &r, WidgetID widget) const override
554 {
555 switch (widget) {
556 case WID_MTS_LIST_LEFT: {
558
559 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
560 for (const auto &song : _music.music_set) {
561 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
562 tr.top += GetCharacterHeight(FS_SMALL);
563 }
564 break;
565 }
566
567 case WID_MTS_LIST_RIGHT: {
569
570 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
571 for (const auto &song : _music.active_playlist) {
572 DrawString(tr, GetString(STR_PLAYLIST_TRACK_NAME, song.tracknr, 2, song.songname));
573 tr.top += GetCharacterHeight(FS_SMALL);
574 }
575 break;
576 }
577 }
578 }
579
580 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
581 {
582 switch (widget) {
583 case WID_MTS_LIST_LEFT: { // add to playlist
585 _music.PlaylistAdd(y);
586 break;
587 }
588
589 case WID_MTS_LIST_RIGHT: { // remove from playlist
591 _music.PlaylistRemove(y);
592 break;
593 }
594
595 case WID_MTS_MUSICSET: {
596 int selected = 0;
597 ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget);
598 break;
599 }
600
601 case WID_MTS_CLEAR: // clear
602 _music.PlaylistClear();
603 break;
604
605 case WID_MTS_ALL: case WID_MTS_OLD: case WID_MTS_NEW:
606 case WID_MTS_EZY: case WID_MTS_CUSTOM1: case WID_MTS_CUSTOM2: // set playlist
607 _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_MTS_ALL));
608 break;
609 }
610 }
611
612 void OnDropdownSelect(WidgetID widget, int index, int) override
613 {
614 switch (widget) {
615 case WID_MTS_MUSICSET:
616 ChangeMusicSet(index);
617 break;
618 default:
619 NOT_REACHED();
620 }
621 }
622};
623
624static constexpr NWidgetPart _nested_music_track_selection_widgets[] = {
626 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
627 NWidget(WWT_CAPTION, COLOUR_GREY, WID_MTS_CAPTION),
628 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_MTS_MUSICSET), SetStringTip(STR_PLAYLIST_CHANGE_SET, STR_PLAYLIST_TOOLTIP_CHANGE_SET),
629 EndContainer(),
630 NWidget(WWT_PANEL, COLOUR_GREY),
631 NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
632 /* Left panel. */
634 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_PLAYLIST_TRACK_INDEX),
635 NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_LEFT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK), EndContainer(),
637 EndContainer(),
638 /* Middle buttons. */
640 NWidget(NWID_SPACER), SetMinimalSize(60, 30), // Space above the first button from the title bar.
641 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
642 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
643 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
644 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_MTS_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
645 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),
646 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),
647 NWidget(NWID_SPACER), SetMinimalSize(0, 16), // Space above 'clear' button
648 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_MTS_CLEAR), SetFill(1, 0), SetStringTip(STR_PLAYLIST_CLEAR, STR_PLAYLIST_TOOLTIP_CLEAR_CURRENT_PROGRAM_CUSTOM1),
650 EndContainer(),
651 /* Right panel. */
653 NWidget(WWT_LABEL, INVALID_COLOUR, WID_MTS_PLAYLIST), SetFill(1, 0),
654 NWidget(WWT_PANEL, COLOUR_GREY, WID_MTS_LIST_RIGHT), SetFill(1, 1), SetMinimalSize(180, 194), SetToolTip(STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK), EndContainer(),
656 EndContainer(),
657 EndContainer(),
658 EndContainer(),
659};
660
661static WindowDesc _music_track_selection_desc(
662 WDP_AUTO, {}, 0, 0,
664 {},
665 _nested_music_track_selection_widgets
666);
667
668static void ShowMusicTrackSelection()
669{
670 AllocateWindowDescFront<MusicTrackSelectionWindow>(_music_track_selection_desc, 0);
671}
672
673struct MusicWindow : public Window {
674 MusicWindow(WindowDesc &desc, WindowNumber number) : Window(desc)
675 {
676 this->InitNested(number);
679
680 UpdateDisabledButtons();
681 }
682
683 void UpdateDisabledButtons()
684 {
685 /* Disable stop and play if there is no music. */
687 /* Disable most music control widgets if there is no music, or we are in the intro menu. */
689 BaseMusic::GetUsedSet()->num_available == 0 || _game_mode == GM_MENU,
692 );
693 /* Also disable programme button in the intro menu (not in game; it is desirable to allow change of music set.) */
694 this->SetWidgetsDisabledState(_game_mode == GM_MENU, WID_M_PROGRAMME);
695 }
696
697 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
698 {
699 switch (widget) {
700 /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
701 * This can't be done by using NWidContainerFlag::EqualSize as the WID_M_INFO is
702 * between those widgets and of different size. */
703 case WID_M_SHUFFLE: case WID_M_PROGRAMME: {
704 Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE));
705 d.width += padding.width;
706 d.height += padding.height;
707 size = maxdim(size, d);
708 break;
709 }
710
711 case WID_M_TRACK_NR: {
712 Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
713 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TRACK_DIGIT, GetParamMaxDigits(2, FS_SMALL), 2)));
714 d.width += padding.width;
715 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
716 size = maxdim(size, d);
717 break;
718 }
719
720 case WID_M_TRACK_NAME: {
721 Dimension d = GetStringBoundingBox(STR_MUSIC_TITLE_NONE);
722 for (const auto &song : _music.music_set) {
723 d = maxdim(d, GetStringBoundingBox(GetString(STR_MUSIC_TITLE_NAME, song.songname)));
724 }
725 d.width += padding.width;
726 d.height += padding.height + WidgetDimensions::scaled.fullbevel.bottom;
727 size = maxdim(size, d);
728 break;
729 }
730
731 /* Hack-ish: set the proper widget data; only needs to be done once
732 * per (Re)Init as that's the only time the language changes. */
733 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;
734 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;
735 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;
736 }
737 }
738
739 void DrawWidget(const Rect &r, WidgetID widget) const override
740 {
741 switch (widget) {
742 case WID_M_TRACK_NR: {
744 if (BaseMusic::GetUsedSet()->num_available == 0) {
745 break;
746 }
747 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
748 if (_music.IsPlaying()) {
749 DrawString(ir, GetString(STR_MUSIC_TRACK_DIGIT, _music.GetCurrentSong().tracknr, 2), TC_FROMSTRING, SA_HOR_CENTER);
750 } else {
751 DrawString(ir, STR_MUSIC_TRACK_NONE, TC_FROMSTRING, SA_HOR_CENTER);
752 }
753 break;
754 }
755
756 case WID_M_TRACK_NAME: {
758 Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
759
761 if (BaseMusic::GetUsedSet()->num_available == 0) {
762 DrawString(ir, STR_MUSIC_TITLE_NOMUSIC, TC_FROMSTRING, SA_HOR_CENTER);
763 } else if (_music.IsPlaying()) {
764 DrawString(ir, GetString(STR_MUSIC_TITLE_NAME, entry.songname), TC_FROMSTRING, SA_HOR_CENTER);
765 } else {
766 DrawString(ir, STR_MUSIC_TITLE_NONE, TC_FROMSTRING, SA_HOR_CENTER);
767 }
768
769 break;
770 }
771
772 case WID_M_MUSIC_VOL:
773 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.music_vol, nullptr);
774 break;
775
776 case WID_M_EFFECT_VOL:
777 DrawSliderWidget(r, COLOUR_GREY, COLOUR_GREY, TC_BLACK, 0, INT8_MAX, 0, _settings_client.music.effect_vol, nullptr);
778 break;
779 }
780 }
781
787 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
788 {
789 if (!gui_scope) return;
790 for (int i = 0; i < 6; i++) {
792 }
793
794 UpdateDisabledButtons();
795
796 if (data == 1) {
797 this->ReInit();
798 } else {
799 this->SetDirty();
800 }
801 }
802
803 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
804 {
805 switch (widget) {
806 case WID_M_PREV: // skip to prev
807 _music.Prev();
808 break;
809
810 case WID_M_NEXT: // skip to next
811 _music.Next();
812 break;
813
814 case WID_M_STOP: // stop playing
815 _music.Stop();
816 break;
817
818 case WID_M_PLAY: // start playing
819 _music.Play();
820 break;
821
822 case WID_M_MUSIC_VOL: case WID_M_EFFECT_VOL: { // volume sliders
824 if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, 0, vol)) {
825 if (widget == WID_M_MUSIC_VOL) {
827 } else {
828 SetEffectVolume(vol);
829 }
830 this->SetWidgetDirty(widget);
832 }
833
834 if (click_count > 0) this->mouse_capture_widget = widget;
835 break;
836 }
837
838 case WID_M_SHUFFLE: // toggle shuffle
839 if (_music.IsShuffle()) {
840 _music.Unshuffle();
841 } else {
842 _music.Shuffle();
843 }
846 break;
847
848 case WID_M_PROGRAMME: // show track selection
849 ShowMusicTrackSelection();
850 break;
851
852 case WID_M_ALL: case WID_M_OLD: case WID_M_NEW:
853 case WID_M_EZY: case WID_M_CUSTOM1: case WID_M_CUSTOM2: // playlist
854 _music.ChangePlaylist((MusicSystem::PlaylistChoices)(widget - WID_M_ALL));
855 break;
856 }
857 }
858};
859
860static constexpr NWidgetPart _nested_music_window_widgets[] = {
862 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
863 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_MUSIC_JAZZ_JUKEBOX_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
864 NWidget(WWT_SHADEBOX, COLOUR_GREY),
865 NWidget(WWT_STICKYBOX, COLOUR_GREY),
866 EndContainer(),
867
870 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
872 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PREV), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_SKIP_TO_PREV, STR_MUSIC_TOOLTIP_SKIP_TO_PREVIOUS_TRACK),
873 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),
874 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_STOP), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_STOP_MUSIC, STR_MUSIC_TOOLTIP_STOP_PLAYING_MUSIC),
875 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_M_PLAY), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_PLAY_MUSIC, STR_MUSIC_TOOLTIP_START_PLAYING_MUSIC),
876 EndContainer(),
877 NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
878 EndContainer(),
879 NWidget(WWT_PANEL, COLOUR_GREY, WID_M_SLIDERS),
882 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_MUSIC_MUSIC_VOLUME),
883 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),
884 EndContainer(),
886 NWidget(WWT_LABEL, INVALID_COLOUR), SetFill(1, 0), SetStringTip(STR_MUSIC_EFFECTS_VOLUME),
887 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),
888 EndContainer(),
889 EndContainer(),
890 EndContainer(),
891 EndContainer(),
892 NWidget(WWT_PANEL, COLOUR_GREY, WID_M_BACKGROUND),
895 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_SHUFFLE), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_SHUFFLE, STR_MUSIC_TOOLTIP_TOGGLE_PROGRAM_SHUFFLE),
896 EndContainer(),
898 NWidget(WWT_LABEL, INVALID_COLOUR, WID_M_TRACK), SetFill(0, 0), SetStringTip(STR_MUSIC_TRACK),
899 NWidget(WWT_INSET, COLOUR_GREY, WID_M_TRACK_NR), SetFill(0, 0), EndContainer(),
900 EndContainer(),
902 NWidget(WWT_LABEL, INVALID_COLOUR, WID_M_TRACK_TITLE), SetFill(1, 0), SetStringTip(STR_MUSIC_XTITLE),
903 NWidget(WWT_INSET, COLOUR_GREY, WID_M_TRACK_NAME), SetFill(1, 0), EndContainer(),
904 EndContainer(),
906 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_M_PROGRAMME), SetMinimalSize(50, 0), SetStringTip(STR_MUSIC_PROGRAM, STR_MUSIC_TOOLTIP_SHOW_MUSIC_TRACK_SELECTION),
907 EndContainer(),
908 EndContainer(),
909 EndContainer(),
911 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_ALL), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_ALL, STR_MUSIC_TOOLTIP_SELECT_ALL_TRACKS_PROGRAM),
912 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_OLD), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_OLD_STYLE, STR_MUSIC_TOOLTIP_SELECT_OLD_STYLE_MUSIC),
913 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_NEW), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_NEW_STYLE, STR_MUSIC_TOOLTIP_SELECT_NEW_STYLE_MUSIC),
914 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_M_EZY), SetFill(1, 0), SetStringTip(STR_MUSIC_PLAYLIST_EZY_STREET, STR_MUSIC_TOOLTIP_SELECT_EZY_STREET_STYLE),
915 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),
916 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),
917 EndContainer(),
918};
919
920static WindowDesc _music_window_desc(
921 WDP_AUTO, "music", 0, 0,
923 {},
924 _nested_music_window_widgets
925);
926
927void ShowMusicWindow()
928{
929 AllocateWindowDescFront<MusicWindow>(_music_window_desc, 0);
930}
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 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 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:966
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:978
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). INVALID_WIDGET if no widget has mouse ca...
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:1802
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:3184
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:3276
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:31
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
@ 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.