MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Save

Method Save

engine/Poseidon/UI/Settings/ContextControlsConfig.cpp:270–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270bool ContextControlsConfig::Save(const std::string& path) const
271{
272 std::error_code ec;
273 std::filesystem::path p(path);
274 if (p.has_parent_path())
275 std::filesystem::create_directories(p.parent_path(), ec);
276
277 ParamFile cfg;
278 cfg.Add("contextControlsVersion", kContextControlsVersion);
279
280 UserActionDesc* descs = InputSubsystem::GetUserActionDesc();
281 for (int c = 0; c < ContextCount; ++c)
282 {
283 InputContext ctx = static_cast<InputContext>(c);
284 const InputProfile& profile = profiles[c];
285 for (int a = 0; a < UAN; ++a)
286 {
287 const auto& entries = profile.GetBindingEntries(static_cast<UserAction>(a));
288 if (entries.empty())
289 continue;
290
291 ParamEntry* codes = cfg.AddArray(BindingName(ctx, descs[a]));
292 codes->Clear();
293 ParamEntry* mods = cfg.AddArray(ModifierName(ctx, descs[a]));
294 mods->Clear();
295 ParamEntry* scales = cfg.AddArray(ScaleName(ctx, descs[a]));
296 scales->Clear();
297
298 for (const InputBinding& binding : entries)
299 {
300 codes->AddValue(binding.code.toLegacy());
301 mods->AddValue(binding.modifier.valid() ? binding.modifier.toLegacy() : -1);
302 scales->AddValue(binding.scale);
303 }
304 }
305 }
306
307 cfg.Save(RString(path.c_str()));
308 return std::filesystem::exists(path, ec);
309}
310} // namespace Poseidon

Callers

nothing calls this directly

Calls 11

BindingNameFunction · 0.85
ModifierNameFunction · 0.85
ScaleNameFunction · 0.85
AddArrayMethod · 0.80
toLegacyMethod · 0.80
RStringClass · 0.50
AddMethod · 0.45
emptyMethod · 0.45
ClearMethod · 0.45
AddValueMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected