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

Method Load

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

Source from the content-addressed store, hash-verified

214}
215
216bool ContextControlsConfig::Load(const std::string& path)
217{
218 std::error_code ec;
219 if (!std::filesystem::exists(path, ec))
220 return false;
221
222 ParamFile cfg;
223 cfg.Parse(RString(path.c_str()));
224
225 int version = 0;
226 if (auto* e = cfg.FindEntry("contextControlsVersion"))
227 version = (int)*e;
228 (void)version;
229
230 for (InputProfile& profile : profiles)
231 profile.ClearAll();
232
233 UserActionDesc* descs = InputSubsystem::GetUserActionDesc();
234 for (int c = 0; c < ContextCount; ++c)
235 {
236 InputContext ctx = static_cast<InputContext>(c);
237 InputProfile& profile = profiles[c];
238 for (int a = 0; a < UAN; ++a)
239 {
240 const ParamEntry* entry = cfg.FindEntry(BindingName(ctx, descs[a]));
241 if (!entry)
242 continue;
243
244 const ParamEntry* modEntry = cfg.FindEntry(ModifierName(ctx, descs[a]));
245 const ParamEntry* scaleEntry = cfg.FindEntry(ScaleName(ctx, descs[a]));
246 const int n = entry->GetSize();
247 for (int i = 0; i < n; ++i)
248 {
249 InputCode code = InputCode::FromLegacy((int)(*entry)[i]);
250 if (!code.valid())
251 continue;
252
253 int modRaw = -1;
254 if (modEntry && i < modEntry->GetSize())
255 modRaw = (int)(*modEntry)[i];
256 InputCode modifier = modRaw >= 0 ? InputCode::FromLegacy(modRaw) : InputCode{};
257
258 float scale = 1.0f;
259 if (scaleEntry && i < scaleEntry->GetSize())
260 scale = (float)(*scaleEntry)[i];
261
262 profile.Bind(static_cast<UserAction>(a), InputBinding(code, modifier, ActivationMode::OnHold, scale));
263 }
264 }
265 }
266
267 return true;
268}
269
270bool ContextControlsConfig::Save(const std::string& path) const
271{

Callers

nothing calls this directly

Calls 11

BindingNameFunction · 0.85
ModifierNameFunction · 0.85
ScaleNameFunction · 0.85
InputBindingClass · 0.85
RStringClass · 0.50
ParseMethod · 0.45
FindEntryMethod · 0.45
ClearAllMethod · 0.45
GetSizeMethod · 0.45
validMethod · 0.45
BindMethod · 0.45

Tested by

no test coverage detected