Resolving warnings

This commit is contained in:
Brad Davis 2016-01-20 10:58:58 -08:00
parent f9f9ddd8bd
commit 47a1c16430
3 changed files with 16 additions and 24 deletions

View file

@ -340,7 +340,9 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX); skyStage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
break; break;
} }
case BACKGROUND_MODE_INHERIT: case BACKGROUND_MODE_INHERIT:
default:
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application background through skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME); // let the application background through
_pendingSkyboxTexture = false; _pendingSkyboxTexture = false;
_skyboxTexture.clear(); _skyboxTexture.clear();

View file

@ -184,38 +184,26 @@ void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {
} }
} }
const char* backgroundModeNames[] = {"inherit", "skybox" }; using BackgroundPair = std::pair<const BackgroundMode, const QString>;
const std::array<BackgroundPair, BACKGROUND_MODE_ITEM_COUNT> BACKGROUND_MODES = {
QHash<QString, BackgroundMode> stringToBackgroundModeLookup; BackgroundPair { BACKGROUND_MODE_INHERIT, { "inherit" } },
BackgroundPair { BACKGROUND_MODE_SKYBOX, { "skybox" } }
void addBackgroundMode(BackgroundMode type) { };
stringToBackgroundModeLookup[backgroundModeNames[type]] = type;
}
void buildStringToBackgroundModeLookup() {
addBackgroundMode(BACKGROUND_MODE_INHERIT);
addBackgroundMode(BACKGROUND_MODE_SKYBOX);
}
QString EntityItemProperties::getBackgroundModeAsString() const { QString EntityItemProperties::getBackgroundModeAsString() const {
if (_backgroundMode < sizeof(backgroundModeNames) / sizeof(char *)) return BACKGROUND_MODES[_backgroundMode].second;
return QString(backgroundModeNames[_backgroundMode]);
return QString(backgroundModeNames[BACKGROUND_MODE_INHERIT]);
} }
QString EntityItemProperties::getBackgroundModeString(BackgroundMode mode) { QString EntityItemProperties::getBackgroundModeString(BackgroundMode mode) {
if (mode < sizeof(backgroundModeNames) / sizeof(char *)) return BACKGROUND_MODES[mode].second;
return QString(backgroundModeNames[mode]);
return QString(backgroundModeNames[BACKGROUND_MODE_INHERIT]);
} }
void EntityItemProperties::setBackgroundModeFromString(const QString& backgroundMode) { void EntityItemProperties::setBackgroundModeFromString(const QString& backgroundMode) {
if (stringToBackgroundModeLookup.empty()) { auto result = std::find_if(BACKGROUND_MODES.begin(), BACKGROUND_MODES.end(), [&](const BackgroundPair& pair) {
buildStringToBackgroundModeLookup(); return (pair.second == backgroundMode);
} });
auto backgroundModeItr = stringToBackgroundModeLookup.find(backgroundMode.toLower()); if (result != BACKGROUND_MODES.end()) {
if (backgroundModeItr != stringToBackgroundModeLookup.end()) { _backgroundMode = result->first;
_backgroundMode = backgroundModeItr.value();
_backgroundModeChanged = true; _backgroundModeChanged = true;
} }
} }

View file

@ -14,6 +14,8 @@
enum BackgroundMode { enum BackgroundMode {
BACKGROUND_MODE_INHERIT, BACKGROUND_MODE_INHERIT,
BACKGROUND_MODE_SKYBOX, BACKGROUND_MODE_SKYBOX,
BACKGROUND_MODE_ITEM_COUNT,
}; };