From 3609359ca157d122a15480f19fea18de0015cb3c Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Mon, 22 Feb 2010 13:47:15 +0100 Subject: Ported temporary texture uploads from Emerald. --- linden/indra/newview/app_settings/settings.xml | 15 +++++ linden/indra/newview/llfloaterimagepreview.cpp | 4 ++ linden/indra/newview/llfloatersnapshot.cpp | 41 ++++++------ linden/indra/newview/llinventorybridge.cpp | 26 +++++++- linden/indra/newview/llinventorybridge.h | 2 + linden/indra/newview/llviewermenufile.cpp | 75 ++++++++++++++++++---- .../default/xui/en-us/floater_image_preview.xml | 4 ++ .../skins/default/xui/en-us/floater_snapshot.xml | 11 +++- 8 files changed, 140 insertions(+), 38 deletions(-) diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 5687eb7..93dc2fb 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -3415,6 +3415,21 @@ 1.0 + + + EmeraldTemporaryUpload + + Comment + Whether or not a texture upload is temp + Persist + 0 + Type + Boolean + Value + 0 + + + EnableRippleWater Comment diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp index 24b9929..87d577d 100644 --- a/linden/indra/newview/llfloaterimagepreview.cpp +++ b/linden/indra/newview/llfloaterimagepreview.cpp @@ -58,6 +58,7 @@ #include "lluictrlfactory.h" #include "llviewerimagelist.h" #include "llstring.h" +#include "llviewercontrol.h" //static S32 LLFloaterImagePreview::sUploadAmount = 10; @@ -120,6 +121,9 @@ BOOL LLFloaterImagePreview::postBuild() if (mRawImagep->getWidth() * mRawImagep->getHeight () <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF) childEnable("lossless_check"); + + gSavedSettings.setBOOL("EmeraldTemporaryUpload",FALSE); + childSetValue("temp_check",FALSE); } else { diff --git a/linden/indra/newview/llfloatersnapshot.cpp b/linden/indra/newview/llfloatersnapshot.cpp index 6597f9d..b4f2cc2 100644 --- a/linden/indra/newview/llfloatersnapshot.cpp +++ b/linden/indra/newview/llfloatersnapshot.cpp @@ -80,8 +80,10 @@ ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- -S32 LLFloaterSnapshot::sUIWinHeightLong = 546 ; -S32 LLFloaterSnapshot::sUIWinHeightShort = LLFloaterSnapshot::sUIWinHeightLong - 250 ; + +//Hey, why use XUI files when you can hardcode? Why say "Floater" when you can say "UIWin"? +S32 LLFloaterSnapshot::sUIWinHeightLong = 568 ;//height of the floater with "more" options +S32 LLFloaterSnapshot::sUIWinHeightShort = LLFloaterSnapshot::sUIWinHeightLong - 270 ;//dto. "less" options S32 LLFloaterSnapshot::sUIWinWidth = 215 ; LLSnapshotFloaterView* gSnapshotFloaterView = NULL; @@ -809,24 +811,14 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) formatted->decode(previewp->mPreviewImageEncoded, 0); } } - else if(previewp->getSnapshotType() == SNAPSHOT_POSTCARD) + else { + // delete any existing image previewp->mFormattedImage = NULL; + // now create the new one of the appropriate format. // note: postcards hardcoded to use jpeg always. - previewp->mFormattedImage = new LLImageJPEG(previewp->mSnapshotQuality); - - if(previewp->mFormattedImage->encode(previewp->mPreviewImage, 0)) - { - previewp->mDataSize = previewp->mFormattedImage->getDataSize(); - previewp->mFormattedImage->decode(previewp->mPreviewImageEncoded, 0); - } - } - else //SNAPSHOT_LOCAL - { - previewp->mFormattedImage = NULL; - // save snapshot using the appropriate format. - LLFloaterSnapshot::ESnapshotFormat format = previewp->getSnapshotFormat(); - + LLFloaterSnapshot::ESnapshotFormat format = previewp->getSnapshotType() == SNAPSHOT_POSTCARD + ? LLFloaterSnapshot::SNAPSHOT_FORMAT_JPEG : previewp->getSnapshotFormat(); switch(format) { case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG: @@ -1269,7 +1261,12 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetVisible("save_btn", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL); floater->childSetEnabled("keep_aspect_check", shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE && !sAspectRatioCheckOff); floater->childSetEnabled("layer_types", shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL); - + if(shot_type != LLSnapshotLivePreview::SNAPSHOT_TEXTURE) + { + floater->childSetValue("temp_check", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE); + } + floater->childSetEnabled("temp_check", shot_type == LLSnapshotLivePreview::SNAPSHOT_TEXTURE); + BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot"); BOOL is_local = shot_type == LLSnapshotLivePreview::SNAPSHOT_LOCAL; @@ -1290,6 +1287,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) floater->childSetVisible("freeze_frame_check", is_advance); floater->childSetVisible("auto_snapshot_check", is_advance); floater->childSetVisible("image_quality_slider", is_advance); + floater->childSetVisible("temp_check", is_advance); LLSnapshotLivePreview* previewp = getPreviewView(floater); BOOL got_bytes = previewp && previewp->getDataSize() > 0; @@ -2085,6 +2083,9 @@ BOOL LLFloaterSnapshot::postBuild() sInstance->getRootView()->addChild(previewp); sInstance->getRootView()->addChild(gSnapshotFloaterView); + gSavedSettings.setBOOL("EmeraldTemporaryUpload",FALSE); + childSetValue("temp_check",FALSE); + Impl::sPreviewHandle = previewp->getHandle(); impl.updateControls(this); @@ -2103,6 +2104,8 @@ void LLFloaterSnapshot::draw() } // TODO*: Do we need all this? - Jacek + //SG & Emerald don't ... let's try and comment it out -Armin +/* if(!isMinimized()) { if (previewp && previewp->getDataSize() > 0) @@ -2194,7 +2197,7 @@ void LLFloaterSnapshot::draw() childSetToolTip("ui_check", std::string("If selected shows the UI in the snapshot")); } - +*/ LLFloater::draw(); if (previewp) diff --git a/linden/indra/newview/llinventorybridge.cpp b/linden/indra/newview/llinventorybridge.cpp index 0d0c512..42af09a 100644 --- a/linden/indra/newview/llinventorybridge.cpp +++ b/linden/indra/newview/llinventorybridge.cpp @@ -948,9 +948,10 @@ std::string LLItemBridge::getLabelSuffix() const LLInventoryItem* item = getItem(); if(item) { + LLPermissions perm = item->getPermissions(); // it's a bit confusing to put nocopy/nomod/etc on calling cards. - if(LLAssetType::AT_CALLINGCARD != item->getType() - && item->getPermissions().getOwner() == gAgent.getID()) + if(/*LLAssetType::AT_CALLINGCARD != item->getType() + && */perm.getOwner() == gAgent.getID()) { BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); @@ -961,6 +962,8 @@ std::string LLItemBridge::getLabelSuffix() const const char* NO_COPY = " (no copy)"; const char* NO_MOD = " (no modify)"; const char* NO_XFER = " (no transfer)"; + const char* TEMPO = " (temporary)"; + const char* scopy; if(copy) scopy = EMPTY; else scopy = NO_COPY; @@ -970,7 +973,10 @@ std::string LLItemBridge::getLabelSuffix() const const char* sxfer; if(xfer) sxfer = EMPTY; else sxfer = NO_XFER; - suffix = llformat("%s%s%s",scopy,smod,sxfer); + const char* stempo; + if(perm.getGroup() == gAgent.getID())stempo = TEMPO; + else stempo = EMPTY; + suffix = llformat("%s%s%s%s",scopy,smod,sxfer,stempo); } } return suffix; @@ -4572,6 +4578,20 @@ BOOL LLWearableBridge::isItemRemovable() return LLInvFVBridge::isItemRemovable(); } +//k, all uploadable asset types do not use this characteristic; therefore, we can use it to show temporaryness and not interfere cuz we're awesome like that +LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const +{ + LLPermissions perm = getItem()->getPermissions(); + if(perm.getGroup() == gAgent.getID()) + { + return LLFontGL::ITALIC; + } + else + { + return LLFontGL::NORMAL; + } +} + LLFontGL::StyleFlags LLWearableBridge::getLabelStyle() const { if( gAgent.isWearingItem( mUUID ) ) diff --git a/linden/indra/newview/llinventorybridge.h b/linden/indra/newview/llinventorybridge.h index 6c1c469..3f4cfb0 100644 --- a/linden/indra/newview/llinventorybridge.h +++ b/linden/indra/newview/llinventorybridge.h @@ -263,6 +263,8 @@ public: virtual BOOL hasChildren() const { return FALSE; } virtual BOOL isUpToDate() const { return TRUE; } + virtual LLFontGL::StyleFlags getLabelStyle() const; + // override for LLInvFVBridge virtual void clearDisplayName() { mDisplayName.clear(); } diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp index 3283391..8f47e0b 100644 --- a/linden/indra/newview/llviewermenufile.cpp +++ b/linden/indra/newview/llviewermenufile.cpp @@ -844,6 +844,40 @@ void upload_new_resource(const std::string& src_filename, std::string name, } } +void temp_upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) +{ + LLResourceData* data = (LLResourceData*)user_data; + if(result >= 0) + { + LLAssetType::EType dest_loc = (data->mPreferredLocation == LLAssetType::AT_NONE) ? data->mAssetInfo.mType : data->mPreferredLocation; + LLUUID folder_id(gInventory.findCategoryUUIDForType(dest_loc)); + LLUUID item_id; + item_id.generate(); + LLPermissions perm; + perm.init(gAgentID, + gAgentID, + gAgentID, + gAgentID); + perm.setMaskBase(PERM_ALL); + perm.setMaskOwner(PERM_ALL); + perm.setMaskEveryone(PERM_ALL); + perm.setMaskGroup(PERM_ALL); + LLPointer item = new LLViewerInventoryItem(item_id, folder_id, perm, data->mAssetInfo.mTransactionID.makeAssetID(gAgent.getSecureSessionID()), data->mAssetInfo.mType, data->mInventoryType, data->mAssetInfo.getName(), "", LLSaleInfo::DEFAULT, LLInventoryItem::II_FLAGS_NONE, time_corrected()); + item->updateServer(TRUE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + }else // if(result >= 0) + { + LLSD args; + args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); + args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); + LLNotifications::instance().add("CannotUploadReason", args); + } + + LLUploadDialog::modalUploadFinished(); + delete data; +} + void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status) // StoreAssetData callback (fixed) { LLResourceData* data = (LLResourceData*)user_data; @@ -968,6 +1002,11 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty S32 expected_upload_cost, void *userdata) { + if(gDisconnected) + { + return ; + } + LLAssetID uuid = tid.makeAssetID(gAgent.getSecureSessionID()); if( LLAssetType::AT_SOUND == asset_type ) @@ -1013,8 +1052,11 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl; lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLAssetType::AT_NONE) ? asset_type : destination_folder_type) << llendl; lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl; + std::string url = gAgent.getRegion()->getCapability("NewFileAgentInventory"); - if (!url.empty()) + BOOL temporary_up = gSavedSettings.getBOOL("EmeraldTemporaryUpload"); + gSavedSettings.setBOOL("EmeraldTemporaryUpload",FALSE); + if (!url.empty() && temporary_up == FALSE) { llinfos << "New Agent Inventory via capability" << llendl; LLSD body; @@ -1036,19 +1078,22 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty } else { - llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl; - // check for adequate funds - // TODO: do this check on the sim - if (LLAssetType::AT_SOUND == asset_type || - LLAssetType::AT_TEXTURE == asset_type || - LLAssetType::AT_ANIMATION == asset_type) + if(temporary_up == FALSE) { - S32 balance = gStatusBar->getBalance(); - if (balance < expected_upload_cost) + llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl; + // check for adequate funds + // TODO: do this check on the sim + if (LLAssetType::AT_SOUND == asset_type || + LLAssetType::AT_TEXTURE == asset_type || + LLAssetType::AT_ANIMATION == asset_type) { - // insufficient funds, bail on this upload - LLFloaterBuyCurrency::buyCurrency("Uploading costs", expected_upload_cost); - return; + S32 balance = gStatusBar->getBalance(); + if (balance < expected_upload_cost) + { + // insufficient funds, bail on this upload + LLFloaterBuyCurrency::buyCurrency("Uploading costs", expected_upload_cost); + return; + } } } @@ -1065,7 +1110,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty data->mAssetInfo.setDescription(desc); data->mPreferredLocation = destination_folder_type; - LLAssetStorage::LLStoreAssetCallback asset_callback = &upload_done_callback; + LLAssetStorage::LLStoreAssetCallback asset_callback = temporary_up ? &temp_upload_done_callback : &upload_done_callback; if (callback) { asset_callback = callback; @@ -1073,7 +1118,9 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty gAssetStorage->storeAssetData(data->mAssetInfo.mTransactionID, data->mAssetInfo.mType, asset_callback, (void*)data, - FALSE); + temporary_up, + TRUE, + temporary_up); } } diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_image_preview.xml b/linden/indra/newview/skins/default/xui/en-us/floater_image_preview.xml index 926e715..76c1852 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_image_preview.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_image_preview.xml @@ -57,6 +57,10 @@ Try saving image as 24 bit Targa (.tga). follows="bottom|left" font="SansSerifSmall" height="16" initial_value="false" label="Use lossless compression" left="10" left_delta="2" name="lossless_check" width="280" /> +