MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / resolveColor

Method resolveColor

src/components/ThemeComponent.cpp:339–360  ·  view source on GitHub ↗

takes a string of hex and resolves it to an integer

Source from the content-addressed store, hash-verified

337
338//takes a string of hex and resolves it to an integer
339unsigned int ThemeComponent::resolveColor(std::string str, unsigned int defaultColor)
340{
341 if(str.empty())
342 return defaultColor;
343
344 if(str.length() != 6 && str.length() != 8)
345 {
346 LOG(LogError) << "Color \"" << str << "\" is not a valid hex color! Must be 6 or 8 characters.";
347 return defaultColor;
348 }
349
350 //if there's no alpha specified, assume FF
351 if(str.length() == 6)
352 str += "FF";
353
354 unsigned int ret;
355 std::stringstream ss;
356 ss << std::hex << str;
357 ss >> ret;
358
359 return ret;
360}
361
362//splits a string in two at the first instance of the delimiter
363void ThemeComponent::splitString(std::string str, char delim, std::string* before, std::string* after)

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected