MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / prepareDraw

Function prepareDraw

src/OpenLoco/src/Ui/Windows/MusicJukebox.cpp:69–136  ·  view source on GitHub ↗

0x004C0217, 0x004C0217

Source from the content-addressed store, hash-verified

67
68 // 0x004C0217, 0x004C0217
69 static void prepareDraw(Window& self)
70 {
71 self.widgets[Widx::frame].right = self.width - 1;
72 self.widgets[Widx::frame].bottom = self.height - 1;
73 self.widgets[Widx::panel].right = self.width - 1;
74 self.widgets[Widx::panel].bottom = self.height - 1;
75 self.widgets[Widx::caption].right = self.width - 2;
76 self.widgets[Widx::close_button].left = self.width - 15;
77 self.widgets[Widx::close_button].right = self.width - 15 + 12;
78
79 // Currently playing music track
80 {
81 StringId songName = StringIds::music_none;
82 if (SceneManager::isPlayMode())
83 {
84 songName = Jukebox::getSelectedTrackTitleId();
85 }
86 else if (SceneManager::isTitleMode())
87 {
88 auto& cfg = Config::get();
89 if (cfg.audio.playTitleMusic)
90 {
91 songName = StringIds::music_locomotion_title;
92 }
93 }
94 auto args = FormatArguments(self.widgets[Widx::currently_playing].textArgs);
95 args.push(songName);
96 }
97
98 self.activatedWidgets = 0;
99 self.disabledWidgets = 0;
100
101 // Jukebox controls (stop/play/skip)
102 if (!SceneManager::isPlayMode())
103 {
104 self.disabledWidgets |= (1ULL << Widx::currently_playing) | (1ULL << Widx::currently_playing_btn) | (1ULL << Widx::music_controls_play) | (1ULL << Widx::music_controls_stop) | (1ULL << Widx::music_controls_next);
105 }
106 else if (Jukebox::isMusicPlaying())
107 {
108 // Play button appears pressed
109 self.activatedWidgets |= (1ULL << Widx::music_controls_play);
110 }
111 else
112 {
113 // Stop button appears pressed
114 self.activatedWidgets |= (1ULL << Widx::music_controls_stop);
115 }
116
117 // Selected playlist
118 {
119 static constexpr StringId playlist_string_ids[] = {
120 StringIds::play_only_music_from_current_era,
121 StringIds::play_all_music,
122 StringIds::play_custom_music_selection,
123 };
124
125 auto args = FormatArguments(self.widgets[Widx::music_playlist].textArgs);
126

Callers

nothing calls this directly

Calls 8

isPlayModeFunction · 0.85
getSelectedTrackTitleIdFunction · 0.85
isTitleModeFunction · 0.85
isMusicPlayingFunction · 0.85
enumValueFunction · 0.85
getFunction · 0.50
FormatArgumentsClass · 0.50
pushMethod · 0.45

Tested by

no test coverage detected