MCPcopy Create free account
hub / github.com/OpenMW/openmw / getVector2

Method getVector2

components/settings/settings.cpp:278–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276 }
277
278 osg::Vec2f Manager::getVector2(std::string_view setting, std::string_view category)
279 {
280 const std::string& value = getString(setting, category);
281
282 std::vector<std::string> components;
283 Misc::StringUtils::split(value, components);
284
285 if (components.size() == 2)
286 {
287 auto x = Misc::StringUtils::toNumeric<float>(components[0]);
288 auto y = Misc::StringUtils::toNumeric<float>(components[1]);
289
290 if (x && y)
291 {
292 return { x.value(), y.value() };
293 }
294 }
295
296 throw std::runtime_error(std::string("Can't parse 2d vector: " + value));
297 }
298
299 osg::Vec3f Manager::getVector3(std::string_view setting, std::string_view category)
300 {

Callers

nothing calls this directly

Calls 4

splitFunction · 0.85
toNumeric<float>Function · 0.85
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected