diff options
| author | Merov Linden <merov@lindenlab.com> | 2014-01-16 17:52:14 -0800 | 
|---|---|---|
| committer | Merov Linden <merov@lindenlab.com> | 2014-01-16 17:52:14 -0800 | 
| commit | 91f401fa2de8c78da7c83561501a1be993588867 (patch) | |
| tree | d75493b05bf65b3ee90c8d15d77d52bf99423333 /indra | |
| parent | e0412a7d987e046c48f80992c3c7b2bdb3373201 (diff) | |
ACME-1237 : Use translation service for filter names so they can be localized and as also look proper in English. General filter manager cleanup
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llimagefiltersmanager.cpp | 58 | ||||
| -rw-r--r-- | indra/newview/llimagefiltersmanager.h | 31 | ||||
| -rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 28 | ||||
| -rwxr-xr-x | indra/newview/skins/default/xui/en/strings.xml | 12 | 
4 files changed, 73 insertions, 56 deletions
| diff --git a/indra/newview/llimagefiltersmanager.cpp b/indra/newview/llimagefiltersmanager.cpp index 14177b4f05..0633dcaefc 100644 --- a/indra/newview/llimagefiltersmanager.cpp +++ b/indra/newview/llimagefiltersmanager.cpp @@ -1,6 +1,6 @@  /**    * @file llimagefiltersmanager.cpp - * @brief Load and execute image filters. Mostly used for Flickr at the moment. + * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment.   *   * $LicenseInfo:firstyear=2001&license=viewerlgpl$   * Second Life Viewer Source Code @@ -29,10 +29,15 @@  #include "llimagefiltersmanager.h"  #include "lldiriterator.h" +#include "lltrans.h" +std::string get_sys_dir() +{ +	return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "filters", ""); +}  //--------------------------------------------------------------------------- -// LLImageFilters +// LLImageFiltersManager  //---------------------------------------------------------------------------  LLImageFiltersManager::LLImageFiltersManager() @@ -49,16 +54,10 @@ void LLImageFiltersManager::initSingleton()  	loadAllFilters();  } -// static -std::string LLImageFiltersManager::getSysDir() -{ -	return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "filters", ""); -} -  void LLImageFiltersManager::loadAllFilters()  {  	// Load system (coming out of the box) filters -	loadFiltersFromDir(getSysDir()); +	loadFiltersFromDir(get_sys_dir());  }  void LLImageFiltersManager::loadFiltersFromDir(const std::string& dir) @@ -68,29 +67,44 @@ void LLImageFiltersManager::loadFiltersFromDir(const std::string& dir)  	LLDirIterator dir_iter(dir, "*.xml");  	while (1)  	{ -		std::string file; -		if (!dir_iter.next(file)) +		std::string file_name; +		if (!dir_iter.next(file_name))  		{  			break; // no more files  		} -		// Get the ".xml" out of the file name to get the filter name -		std::string filter_name = file.substr(0,file.length()-4); -        mFiltersList.push_back(filter_name); +		// Get the ".xml" out of the file name to get the filter name. That's the one known in strings.xml +		std::string filter_name = file_name.substr(0,file_name.length()-4); +        // Get the localized name for the filter +		filter_name = LLTrans::getString(filter_name); -		std::string path = gDirUtilp->add(dir, file); - -        // For the moment, just output the file found to the log -        llinfos << "Merov : loadFiltersFromDir, filter = " << file << ",path = " << path << llendl; +        mFiltersList[filter_name] = file_name;  	}  } +// Note : That method is a bit heavy handed but the list of filters is always small (10 or so) +// and that method is typically called only once when building UI widgets. +const std::vector<std::string> LLImageFiltersManager::getFiltersList() const +{ +    std::vector<std::string> filter_list; +    for (std::map<std::string,std::string>::const_iterator it = mFiltersList.begin(); it != mFiltersList.end(); ++it) +    { +        filter_list.push_back(it->first); +    } +    return filter_list; +} +  std::string LLImageFiltersManager::getFilterPath(const std::string& filter_name)  { -    // *TODO : we should store (filter name, path) in a std::map -    std::string file = filter_name + ".xml"; -    std::string dir = getSysDir(); -    std::string path = gDirUtilp->add(dir, file); +    std::string path = ""; +    std::map<std::string,std::string>::const_iterator it = mFiltersList.find(filter_name); +    if (it != mFiltersList.end()) +    { +        // Get the file name for that filter and build the complete path +        std::string file = it->second; +        std::string dir = get_sys_dir(); +        path = gDirUtilp->add(dir, file); +    }      return path;  } diff --git a/indra/newview/llimagefiltersmanager.h b/indra/newview/llimagefiltersmanager.h index 5591e14a41..4751933065 100644 --- a/indra/newview/llimagefiltersmanager.h +++ b/indra/newview/llimagefiltersmanager.h @@ -1,6 +1,6 @@  /**    * @file llimagefiltersmanager.h - * @brief Load and execute image filters. Mostly used for Flickr at the moment. + * @brief Load image filters list and retrieve their path. Mostly used for Flickr UI at the moment.   *   * $LicenseInfo:firstyear=2000&license=viewerlgpl$   * Second Life Viewer Source Code @@ -28,49 +28,28 @@  #define LL_LLIMAGEFILTERSMANAGER_H  #include "llsingleton.h" -#include "llimage.h" -/* -typedef enum e_vignette_mode -{ -	VIGNETTE_MODE_NONE  = 0, -	VIGNETTE_MODE_BLEND = 1, -	VIGNETTE_MODE_FADE  = 2 -} EVignetteMode; -typedef enum e_screen_mode -{ -	SCREEN_MODE_2DSINE   = 0, -	SCREEN_MODE_LINE     = 1 -} EScreenMode; -*/  //============================================================================ -// library initialization class +// LLImageFiltersManager class  class LLImageFiltersManager : public LLSingleton<LLImageFiltersManager>  {  	LOG_CLASS(LLImageFiltersManager);  public: -    // getFilters(); get a vector of std::string containing the filter names -    //LLSD loadFilter(const std::string& filter_name); -    //void executeFilter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image); -    const std::vector<std::string> &getFiltersList() const { return mFiltersList; } +    const std::vector<std::string> getFiltersList() const;      std::string getFilterPath(const std::string& filter_name); -protected:  private:  	void loadAllFilters();  	void loadFiltersFromDir(const std::string& dir); -//	LLSD loadFilter(const std::string& path); -     -	static std::string getSysDir();      friend class LLSingleton<LLImageFiltersManager>;  	/*virtual*/ void initSingleton();  	LLImageFiltersManager();  	~LLImageFiltersManager(); -	// List of filters -    std::vector<std::string> mFiltersList; +	// List of filters : first is the user friendly localized name, second is the xml file name +    std::map<std::string,std::string> mFiltersList;  };  #endif // LL_LLIMAGEFILTERSMANAGER_H diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index c38798bbea..21abdd2675 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -591,11 +591,17 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update)          // Filter the thumbnail          if (getFilter() != "")          { -            LLImageFilter filter;              std::string filter_path = LLImageFiltersManager::getInstance()->getFilterPath(getFilter()); -            filter.loadFromFile(filter_path); -            filter.executeFilter(raw); -            //raw->filterGrayScale(); +            if (filter_path != "") +            { +                LLImageFilter filter; +                filter.loadFromFile(filter_path); +                filter.executeFilter(raw); +            } +            else +            { +                llwarns << "Couldn't find a path to the following filter : " << getFilter() << llendl; +            }          }  		mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE);  		mThumbnailUpToDate = TRUE ; @@ -704,11 +710,17 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )              // Apply the filter to mPreviewImage              if (previewp->getFilter() != "")              { -                LLImageFilter filter;                  std::string filter_path = LLImageFiltersManager::getInstance()->getFilterPath(previewp->getFilter()); -                filter.loadFromFile(filter_path); -                filter.executeFilter(previewp->mPreviewImage); -                //previewp->mPreviewImage->filterGrayScale(); +                if (filter_path != "") +                { +                    LLImageFilter filter; +                    filter.loadFromFile(filter_path); +                    filter.executeFilter(previewp->mPreviewImage); +                } +                else +                { +                    llwarns << "Couldn't find a path to the following filter : " << previewp->getFilter() << llendl; +                }              }  			// delete any existing image diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index d226a72d7b..92913f678d 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -168,6 +168,18 @@ Please try logging in again in a minute.</string>    <string name="SocialTwitterErrorPosting">Problem posting to Twitter</string>    <string name="SocialTwitterErrorDisconnecting">Problem disconnecting from Twitter</string> +	<!-- SLShare: User Friendly Filter Names Translation --> +    <string name="BlackAndWhite">Black & White</string> +    <string name="Colors1970">1970's Colors</string> +    <string name="Heatwave">Heat Wave</string> +    <string name="Intense">Intense</string> +    <string name="JulesVerne">Jules Verne</string> +    <string name="Newspaper">Newspaper</string> +    <string name="Overcast">Overcast</string> +    <string name="Sepia">Sepia</string> +    <string name="Spotlight">Spotlight</string> +    <string name="Video">Video</string> +      	<!-- Tooltip -->  	<string name="TooltipPerson">Person</string><!-- Object under mouse pointer is an avatar -->  	<string name="TooltipNoName">(no name)</string> <!-- No name on an object --> | 
