diff options
author | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-05-30 22:34:56 +0300 |
---|---|---|
committer | Vadim ProductEngine <vsavchuk@productengine.com> | 2011-05-30 22:34:56 +0300 |
commit | 657e434fd59139436e8b97e5ecd01ca686e82269 (patch) | |
tree | bebf0c4c8adff3587cec47f6403757f841f5c872 /indra/newview/lldaycyclemanager.cpp | |
parent | 6f1cdd4926444567d21b1d6e0735a445b981e56b (diff) |
STORM-1253 WIP New day cycle editor.
Done:
* Creating new local day cycles.
* Editing existing local day cycles.
* Deleting day cycles.
To do:
* Editing region day cycle, dealing with skies in region scope.
* Handle teleport while editing a day cycle.
* Update UI when a day cycle or sky preset gets deleted.
* Make the time ctrl increase/decrease consistently.
Diffstat (limited to 'indra/newview/lldaycyclemanager.cpp')
-rw-r--r-- | indra/newview/lldaycyclemanager.cpp | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp index c0eae8cd3c..e80da5ba11 100644 --- a/indra/newview/lldaycyclemanager.cpp +++ b/indra/newview/lldaycyclemanager.cpp @@ -38,7 +38,7 @@ const LLDayCycleManager::dc_map_t& LLDayCycleManager::getPresets() return mDayCycleMap; } -bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) +bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycle) const { dc_map_t::const_iterator it = mDayCycleMap.find(name); if (it == mDayCycleMap.end()) @@ -50,7 +50,7 @@ bool LLDayCycleManager::getPreset(const std::string name, LLWLDayCycle& day_cycl return true; } -bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) +bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) const { LLWLDayCycle dc; if (!getPreset(name, dc)) @@ -62,6 +62,46 @@ bool LLDayCycleManager::getPreset(const std::string name, LLSD& day_cycle) return true; } +bool LLDayCycleManager::presetExists(const std::string name) const +{ + LLWLDayCycle dummy; + return getPreset(name, dummy); +} + +bool LLDayCycleManager::isSystemPreset(const std::string& name) const +{ + return gDirUtilp->fileExists(getSysDir() + LLURI::escape(name) + ".xml"); +} + +bool LLDayCycleManager::savePreset(const std::string& name, const LLSD& data) +{ + // Save given preset. + LLWLDayCycle day; + day.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); + day.save(getUserDir() + LLURI::escape(name) + ".xml"); + + // Add it to our map. + addPreset(name, data); + return true; +} + +bool LLDayCycleManager::deletePreset(const std::string& name) +{ + std::string path; + std::string filename = LLURI::escape(name) + ".xml"; + + // Try removing specified user preset. + path = getUserDir() + filename; + if (gDirUtilp->fileExists(path)) + { + gDirUtilp->deleteFilesInDir(getUserDir(), filename); + return true; + } + + // Invalid or system preset. + return false; +} + // virtual void LLDayCycleManager::initSingleton() { @@ -102,13 +142,25 @@ bool LLDayCycleManager::loadPreset(const std::string& path) } std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - LLWLDayCycle day_cycle; - day_cycle.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); - mDayCycleMap[name] = day_cycle; + addPreset(name, data); return true; } +bool LLDayCycleManager::addPreset(const std::string& name, const LLSD& data) +{ + if (name.empty()) + { + llassert(name.empty()); + return false; + } + + LLWLDayCycle day; + day.loadDayCycle(data, LLEnvKey::SCOPE_LOCAL); + mDayCycleMap[name] = day; + return false; +} + // static std::string LLDayCycleManager::getSysDir() { |