Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Damian Zhaoying
2012-08-08 12:56:07 -03:00
7 changed files with 47 additions and 13 deletions

View File

@@ -217,6 +217,7 @@ public:
virtual BOOL canSaveAs() const { return FALSE; }
virtual void saveAs() {}
virtual void saveAsType(BOOL type=false) {}
// <edit>
virtual LLUUID getItemID() { return LLUUID::null; }

View File

@@ -39,6 +39,7 @@
#include "llcombobox.h"
#include "statemachine/aifilepicker.h"
#include "llfloaterinventory.h"
#include "llimagepng.h"
#include "llimagetga.h"
#include "llinventory.h"
#include "llnotificationsutil.h"
@@ -375,17 +376,27 @@ BOOL LLPreviewTexture::canSaveAs() const
return mIsCopyable && !mLoadingFullImage && mImage.notNull() && !mImage->isMissingAsset();
}
static bool sPng(false);
// virtual
void LLPreviewTexture::saveAs()
void LLPreviewTexture::saveAsType(BOOL png)
{
if( mLoadingFullImage )
return;
const LLViewerInventoryItem* item = getItem() ;
AIFilePicker* filepicker = AIFilePicker::create();
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".tga" : LLStringUtil::null, FFSAVE_TGA, "", "image");
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
sPng = png;
if(png)
{
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".png" : LLStringUtil::null, FFSAVE_PNG, "", "image");
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
}
else
{
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".tga" : LLStringUtil::null, FFSAVE_TGA, "", "image");
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
}
}
void LLPreviewTexture::saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker)
@@ -433,14 +444,16 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success,
if( self && final && success )
{
//FIXME: There has to be a better way
LLPointer<LLImagePNG> image_png = new LLImagePNG;
LLPointer<LLImageTGA> image_tga = new LLImageTGA;
if( !image_tga->encode( src ) )
if( sPng ? !image_png->encode( src, 0.0 ) : !image_tga->encode( src ) )
{
LLSD args;
args["FILE"] = self->mSaveFileName;
LLNotificationsUtil::add("CannotEncodeFile", args);
}
else if( !image_tga->save( self->mSaveFileName ) )
else if( sPng ? !image_png->save( self->mSaveFileName ) : !image_tga->save( self->mSaveFileName ) )
{
LLSD args;
args["FILE"] = self->mSaveFileName;

View File

@@ -64,7 +64,8 @@ public:
virtual void draw();
virtual BOOL canSaveAs() const;
virtual void saveAs();
virtual void saveAs(){ saveAsType(false); }
void saveAsType(BOOL png);
void saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker);
virtual LLUUID getItemID();
virtual std::string getItemCreatorName();

View File

@@ -504,6 +504,19 @@ class LLFileSavePreview : public view_listener_t
}
};
class LLFileSavePreviewPNG : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
LLFloater* top = gFloaterView->getFrontmost();
if (top)
{
top->saveAsType(true);
}
return true;
}
};
class LLFileTakeSnapshot : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
@@ -1313,6 +1326,7 @@ void init_menu_file()
(new LLFileMinimizeAllWindows())->registerListener(gMenuHolder, "File.MinimizeAllWindows");
// </edit>
(new LLFileSavePreview())->registerListener(gMenuHolder, "File.SavePreview");
(new LLFileSavePreviewPNG())->registerListener(gMenuHolder, "File.SavePreviewPNG");
(new LLFileTakeSnapshot())->registerListener(gMenuHolder, "File.TakeSnapshot");
(new LLFileTakeSnapshotToDisk())->registerListener(gMenuHolder, "File.TakeSnapshotToDisk");
(new LLFileQuit())->registerListener(gMenuHolder, "File.Quit");

View File

@@ -1345,11 +1345,11 @@ Select the thumbnail to choose a different texture.
<string name="estate_override">
One or more of these options is set at the estate level
</string>
<string name="minutes"/>minutes</string>
<string name="1_minute"/>1 minute</string>
<string name="1_second"/>1 second</string>
<string name="seconds"/>seconds</string>
<string name="remaining"/>remaining</string>
<string name="minutes">minutes</string>
<string name="1_minute">1 minute</string>
<string name="1_second">1 second</string>
<string name="seconds">seconds</string>
<string name="remaining">remaining</string>
<check_box bottom_delta="-20" enabled="true" follows="left|top" font="SansSerifSmall"
height="16" initial_value="false" label="Allow Group Access: [GROUP]"
left="8" mouse_opaque="true" name="GroupCheck" radio_style="false"

View File

@@ -52,11 +52,16 @@
</menu_item_call>
<menu_item_separator bottom="-121" enabled="true" height="8" label="-----------" left="0"
mouse_opaque="true" name="separator2" width="243" />
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As..." left="0"
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As (TGA)..." left="0"
mouse_opaque="true" name="Save Preview As..." width="243">
<on_click function="File.SavePreview" userdata="" />
<on_enable function="File.EnableSaveAs" />
</menu_item_call>
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As (PNG)..." left="0"
mouse_opaque="true" name="Save Preview AsPNG..." width="243">
<on_click function="File.SavePreviewPNG" userdata="" />
<on_enable function="File.EnableSaveAs" />
</menu_item_call>
<menu_item_separator bottom="-148" enabled="true" height="8" label="-----------" left="0"
mouse_opaque="true" name="separator3" width="243" />
<menu_item_call bottom="-167" enabled="true" height="19" label="Take Snapshot" left="0"

View File

@@ -3569,7 +3569,7 @@ If you continue to receive this message, contact the [SUPPORT_SITE].
<string name="IM_autoresponded_to">Autoresponse sent to</string>
<string name="IM_autoresponse_sent_item">was sent auto-response item</string>
<string name="Unnamed">(Unnamed)</string>
<string name="Saved_message">(Saved [LONG_TIMESTAMP])</string>
<string name="Saved_message">(Saved [LONG_TIMESTAMP]) </string>
<string name="PowerUser1">You are bestowed with powers beyond mortal comprehension.</string>
<string name="PowerUser2">Use your newfound abilities wisely.</string>
<string name="Unlocked:">Unlocked:</string>