Fix Save Preview As... for textures, now save as any type we can encode to!
Removes the previous method and condenses the menu entries back into one. - Translations have been updated except for German, German will need to update the translation for "Save Preview As..." since the name hasn't changed. Adds FFSAVE_IMAGE to the filepicker enums Crossplatformity: - The Windows version works nicely - The Linux version may not work or even compile but it should.. - The Mac version hasn't been added, instead it will default to accept any(all filter), should the provided file extension be invalid a notification will display.
This commit is contained in:
@@ -218,7 +218,6 @@ public:
|
||||
virtual BOOL canSaveAs() const { return FALSE; }
|
||||
|
||||
virtual void saveAs() {}
|
||||
virtual void saveAsType(BOOL type=false) {}
|
||||
|
||||
void setSnapTarget(LLHandle<LLFloater> handle) { mSnappedTo = handle; }
|
||||
void clearSnapTarget() { mSnappedTo.markDead(); }
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
#include "llcombobox.h"
|
||||
#include "statemachine/aifilepicker.h"
|
||||
#include "llfloaterinventory.h"
|
||||
#include "llimagepng.h"
|
||||
#include "llimagetga.h"
|
||||
#include "llimage.h"
|
||||
#include "llinventory.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llresmgr.h"
|
||||
@@ -377,27 +376,16 @@ BOOL LLPreviewTexture::canSaveAs() const
|
||||
return mIsCopyable && !mLoadingFullImage && mImage.notNull() && !mImage->isMissingAsset();
|
||||
}
|
||||
|
||||
static bool sPng(false);
|
||||
|
||||
// virtual
|
||||
void LLPreviewTexture::saveAsType(BOOL png)
|
||||
void LLPreviewTexture::saveAs()
|
||||
{
|
||||
if( mLoadingFullImage )
|
||||
return;
|
||||
|
||||
const LLViewerInventoryItem* item = getItem() ;
|
||||
AIFilePicker* filepicker = AIFilePicker::create();
|
||||
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));
|
||||
}
|
||||
filepicker->open(item ? LLDir::getScrubbedFileName(item->getName()) + ".png" : LLStringUtil::null, FFSAVE_IMAGE, "", "image");
|
||||
filepicker->run(boost::bind(&LLPreviewTexture::saveAs_continued, this, item, filepicker));
|
||||
}
|
||||
|
||||
void LLPreviewTexture::saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker)
|
||||
@@ -446,16 +434,14 @@ 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( sPng ? !image_png->encode( src, 0.0 ) : !image_tga->encode( src ) )
|
||||
LLPointer<LLImageFormatted> image = LLImageFormatted::createFromExtension(self->mSaveFileName);
|
||||
if (!image || !image->encode(src, 0.0))
|
||||
{
|
||||
LLSD args;
|
||||
args["FILE"] = self->mSaveFileName;
|
||||
LLNotificationsUtil::add("CannotEncodeFile", args);
|
||||
}
|
||||
else if( sPng ? !image_png->save( self->mSaveFileName ) : !image_tga->save( self->mSaveFileName ) )
|
||||
else if (!image->save(self->mSaveFileName))
|
||||
{
|
||||
LLSD args;
|
||||
args["FILE"] = self->mSaveFileName;
|
||||
|
||||
@@ -63,8 +63,7 @@ public:
|
||||
virtual void draw();
|
||||
|
||||
virtual BOOL canSaveAs() const;
|
||||
virtual void saveAs(){ saveAsType(false); }
|
||||
void saveAsType(BOOL png);
|
||||
virtual void saveAs();
|
||||
void saveAs_continued(LLViewerInventoryItem const* item, AIFilePicker* filepicker);
|
||||
virtual LLUUID getItemID();
|
||||
virtual std::string getItemCreatorName();
|
||||
|
||||
@@ -541,19 +541,6 @@ 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)
|
||||
@@ -1384,7 +1371,6 @@ void init_menu_file()
|
||||
(new LLFileLocalAssetBrowser())->registerListener(gMenuHolder, "File.LocalAssetBrowser");
|
||||
// </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");
|
||||
|
||||
@@ -67,16 +67,11 @@
|
||||
</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 (TGA)..." left="0"
|
||||
<menu_item_call bottom="-140" enabled="true" height="19" label="Save Preview As..." 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"
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
<menu_item_call label="Minimizar todas las Ventanas" name="Minimize All Windows"/>
|
||||
<menu_item_call label="Cerrar Ventana" name="Close Window"/>
|
||||
<menu_item_call label="Cerrar todas las Ventanas" name="Close All Windows"/>
|
||||
<menu_item_call label="Guardar Vista Previa Como (TGA)..." name="Save Preview As..."/>
|
||||
<menu_item_call label="Guardar Vista Previa Como (PNG)..." name="Save Preview AsPNG..."/>
|
||||
<menu_item_call label="Guardar Vista Previa Como..." name="Save Preview As..."/>
|
||||
<menu_item_call label="Hacer una Foto" name="Take Snapshot"/>
|
||||
<menu_item_call label="Guardar Foto en Disco" name="Snapshot to Disk"/>
|
||||
<menu_item_call label="Salir" name="Quit"/>
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
<menu_item_separator/>
|
||||
<menu_item_call label="Définir les droits par défaut " name="perm prefs"/>
|
||||
<menu_item_separator/>
|
||||
<menu_item_call label="Enregistrer la texture sur le disque dur en TGA" name="Save Preview As..."/>
|
||||
<menu_item_call label="Enregistrer la texture sur le disque dur en PNG" name="Save Preview AsPNG..."/>
|
||||
<menu_item_call label="Enregistrer la texture sur le disque" name="Save Preview As..."/>
|
||||
|
||||
<menu_item_separator/>
|
||||
<menu_item_call label="Minimiser toutes les fenêtres" name="Minimize All Windows"/>
|
||||
|
||||
@@ -329,6 +329,9 @@ void AIFilePicker::open(std::string const& filename, ESaveFilter filter, std::st
|
||||
case FFSAVE_PHYSICS:
|
||||
mFilter = "physics";
|
||||
break;
|
||||
case FFSAVE_IMAGE:
|
||||
mFilter = "image";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,8 @@ enum ESaveFilter
|
||||
FFSAVE_LANDMARK,
|
||||
FFSAVE_AO,
|
||||
FFSAVE_BLACKLIST,
|
||||
FFSAVE_PHYSICS
|
||||
FFSAVE_PHYSICS,
|
||||
FFSAVE_IMAGE,
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -134,6 +134,8 @@ static LLFilePicker::ESaveFilter str2savefilter(std::string const& filter)
|
||||
return LLFilePicker::FFSAVE_BLACKLIST;
|
||||
else if (filter == "physics")
|
||||
return LLFilePicker::FFSAVE_PHYSICS;
|
||||
else if (filter == "image")
|
||||
return LLFilePicker::FFSAVE_IMAGE;
|
||||
else
|
||||
return LLFilePicker::FFSAVE_ALL;
|
||||
}
|
||||
|
||||
@@ -692,6 +692,18 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
L"Landmarks (*.phy)\0*.phy\0" \
|
||||
L"\0";
|
||||
break;
|
||||
case FFSAVE_IMAGE:
|
||||
mOFN.lpstrDefExt = NULL;
|
||||
mOFN.lpstrFilter =
|
||||
L"Image (*.bmp *.dxt *.jpg *.jpeg *.j2c *.mip *.png *.tga)\0*.bmp;*.dxt;*.jpg;*.jpeg;*.j2c;*.mip;*.png;*.tga\0" \
|
||||
L"PNG Image (*.png)\0*.png\0" \
|
||||
L"Targa Image (*.tga)\0*.tga\0" \
|
||||
L"Bitmap Image (*.bmp)\0*.bmp\0" \
|
||||
L"JPEG Image (*.jpg *.jpeg)\0*.jpg;*.jpeg\0" \
|
||||
L"Compressed Image (*.j2c)\0*.j2c\0" \
|
||||
L"DXT Image (*.dxt *.mip)\0*.dxt;*.mip\0" \
|
||||
L"\0";
|
||||
break;
|
||||
// </edit>
|
||||
default:
|
||||
return FALSE;
|
||||
@@ -1423,6 +1435,21 @@ static std::string add_imageload_filter_to_gtkchooser(GtkWindow *picker)
|
||||
return filtername;
|
||||
}
|
||||
|
||||
static std::string add_imagesave_filter_to_gtkchooser(GTKWindow *picker)
|
||||
{
|
||||
GtkFileFilter *gfilter = gtk_file_filter_new();
|
||||
gtk_file_filter_add_mime_type(gfilter, "image/bmp");
|
||||
gtk_file_filter_add_pattern(gfilter, "*.dxt");
|
||||
gtk_file_filter_add_mime_type(gfilter, "image/jpeg");
|
||||
gtk_file_filter_add_pattern(gfilter, "*.j2c");
|
||||
gtk_file_filter_add_pattern(gfilter, "*.mip");
|
||||
gtk_file_filter_add_mime_type(gfilter, "image/png");
|
||||
gtk_file_filter_add_pattern(gfilter, "*.tga");
|
||||
std::string filtername = LLTrans::getString("image_files") + "(*.bmp; *.dxt; *.jpg; *.jpeg; *.j2c; *.mip; *.png; *.tga)";
|
||||
add_common_filters_to_gtkchooser(gfilter, picker, filtername);
|
||||
return filtername;
|
||||
}
|
||||
|
||||
static std::string add_script_filter_to_gtkchooser(GtkWindow *picker)
|
||||
{
|
||||
return add_simple_mime_filter_to_gtkchooser(picker, "text/plain",
|
||||
@@ -1497,6 +1524,10 @@ bool LLFilePickerBase::getSaveFile(ESaveFilter filter, std::string const& filena
|
||||
caption += add_script_filter_to_gtkchooser(picker);
|
||||
suggest_ext = ".lsl";
|
||||
break;
|
||||
case FFSAVE_IMAGE:
|
||||
caption += add_imagesave_filter_to_gtkchooser(picker);
|
||||
suggest_ext = ".png";
|
||||
break;
|
||||
default:;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public:
|
||||
FFSAVE_AO = 35,
|
||||
FFSAVE_BLACKLIST = 36,
|
||||
FFSAVE_PHYSICS = 37,
|
||||
FFSAVE_IMAGE = 38,
|
||||
// </edit>
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user