MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / Load

Method Load

TranslucentTB/managers/configmanager.cpp:168–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168bool ConfigManager::Load(bool firstLoad)
169{
170 if (const wil::unique_file file { _wfsopen(m_ConfigPath.c_str(), L"rbS", _SH_DENYNO) })
171 {
172 if (LoadFromFile(file.get()))
173 {
174 if (firstLoad)
175 {
176 if (!m_Config.Language.empty() && Localization::SetProcessLangOverride(m_Config.Language))
177 {
178 m_StartupLanguage = m_Config.Language;
179 }
180 }
181 else if (m_StartupLanguage != m_Config.Language && !std::exchange(m_ShownChangeWarning, true))
182 {
183 // try using the new locale for that dialog box
184 LCID newLang = LocaleNameToLCID(m_Config.Language.c_str(), LOCALE_ALLOW_NEUTRAL_NAMES);
185
186 Localization::ShowLocalizedMessageBox(IDS_LANGUAGE_CHANGED, MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND, wil::GetModuleInstanceHandle(), newLang ? LANGIDFROMLCID(newLang) : MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)).detach();
187 }
188 }
189
190 // note: this demarks if the file exists, even if parsing failed.
191 return true;
192 }
193 else
194 {
195 const errno_t err = errno;
196 const bool fileExists = err != ENOENT;
197 if (fileExists)
198 {
199 // if the file failed to open, but it exists, something went wrong
200 ErrnoTHandle(err, spdlog::level::err, L"Failed to open configuration file");
201 }
202
203 // opening file failed, use defaults
204 m_Config = { };
205 return fileExists;
206 }
207}
208
209void ConfigManager::Reload()
210{

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
getMethod · 0.80
detachMethod · 0.80

Tested by

no test coverage detected