MCPcopy Create free account
hub / github.com/ddnet/ddnet / LoadMenuBackground

Method LoadMenuBackground

src/game/client/components/menu_background.cpp:165–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165void CMenuBackground::LoadMenuBackground(bool HasDayHint, bool HasNightHint)
166{
167 if(!m_IsInit)
168 return;
169
170 if(m_Loaded && m_pMap == m_pBackgroundMap.get())
171 m_pMap->Unload();
172
173 m_Loaded = false;
174 m_pMap = m_pBackgroundMap.get();
175 m_pLayers = m_pBackgroundLayers;
176 m_pImages = m_pBackgroundImages;
177
178 ResetPositions();
179
180 str_copy(m_aMapName, g_Config.m_ClMenuMap);
181
182 if(g_Config.m_ClMenuMap[0] != '\0')
183 {
184 m_Loading = true;
185
186 const char *pMenuMap = g_Config.m_ClMenuMap;
187 if(str_comp(pMenuMap, "auto") == 0)
188 {
189 switch(time_season())
190 {
191 case SEASON_SPRING:
192 case SEASON_EASTER:
193 pMenuMap = "heavens";
194 break;
195 case SEASON_SUMMER:
196 pMenuMap = "jungle";
197 break;
198 case SEASON_AUTUMN:
199 case SEASON_HALLOWEEN:
200 pMenuMap = "autumn";
201 break;
202 case SEASON_WINTER:
203 case SEASON_XMAS:
204 pMenuMap = "winter";
205 break;
206 case SEASON_NEWYEAR:
207 pMenuMap = "newyear";
208 break;
209 }
210 }
211 else if(str_comp(pMenuMap, "rand") == 0)
212 {
213 // make sure to load themes
214 const std::vector<CTheme> &vThemesRef = GetThemes();
215 if(vThemesRef.size() > PREDEFINED_THEMES_COUNT)
216 {
217 int RandomThemeIndex = rand() % (vThemesRef.size() - PREDEFINED_THEMES_COUNT);
218 if(RandomThemeIndex + PREDEFINED_THEMES_COUNT < (int)vThemesRef.size())
219 pMenuMap = vThemesRef[RandomThemeIndex + PREDEFINED_THEMES_COUNT].m_Name.c_str();
220 }
221 }
222

Callers 2

ConchainMenuMapMethod · 0.80
RenderThemeSelectionMethod · 0.80

Calls 15

str_compFunction · 0.85
time_seasonFunction · 0.85
time_hourofthedayFunction · 0.85
str_formatFunction · 0.85
StorageFunction · 0.85
getMethod · 0.80
str_copyFunction · 0.50
UnloadMethod · 0.45
LoadMethod · 0.45
InitMethod · 0.45
LoadBackgroundMethod · 0.45
GameLayerMethod · 0.45

Tested by

no test coverage detected