[Local Textures] These should persist through relogs, duh!
This commit is contained in:
@@ -64,6 +64,8 @@ this feature is still a work in progress.
|
|||||||
#include "llviewermenufile.h"
|
#include "llviewermenufile.h"
|
||||||
#include "llfloaterimagepreview.h"
|
#include "llfloaterimagepreview.h"
|
||||||
#include "llfile.h"
|
#include "llfile.h"
|
||||||
|
#include "llsdparam.h"
|
||||||
|
#include "llsdserialize.h"
|
||||||
|
|
||||||
/* including to force rebakes when needed */
|
/* including to force rebakes when needed */
|
||||||
#include "llvoavatarself.h"
|
#include "llvoavatarself.h"
|
||||||
@@ -93,18 +95,27 @@ bool LocalAssetBrowser::mSculptUpdated;
|
|||||||
containing one loaded local texture.
|
containing one loaded local texture.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LocalBitmap::LocalBitmap(std::string fullpath)
|
LocalBitmap::Params::Params(const std::string& path)
|
||||||
|
: fullpath("path", path)
|
||||||
|
, keep_updating("update", gSavedSettings.getBOOL("LocalBitmapUpdate"))
|
||||||
|
, type("type", TYPE_TEXTURE)
|
||||||
|
, id("id", LLUUID::generateNewID())
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalBitmap::LocalBitmap(const Params& p)
|
||||||
|
{
|
||||||
|
llassert(!p.fullpath.empty());
|
||||||
valid = false;
|
valid = false;
|
||||||
if ( gDirUtilp->fileExists(fullpath) )
|
if ( gDirUtilp->fileExists(p.fullpath) )
|
||||||
{
|
{
|
||||||
/* taking care of basic properties */
|
/* taking care of basic properties */
|
||||||
id.generate();
|
id = p.id;
|
||||||
filename = fullpath;
|
filename = p.fullpath;
|
||||||
keep_updating = gSavedSettings.getBOOL("LocalBitmapUpdate");
|
keep_updating = p.keep_updating;
|
||||||
linkstatus = keep_updating ? LINK_ON : LINK_OFF;
|
linkstatus = keep_updating ? LINK_ON : LINK_OFF;
|
||||||
shortname = gDirUtilp->getBaseFileName(filename, true);
|
shortname = gDirUtilp->getBaseFileName(filename, true);
|
||||||
bitmap_type = TYPE_TEXTURE;
|
bitmap_type = p.type;
|
||||||
sculpt_dirty = false;
|
sculpt_dirty = false;
|
||||||
volume_dirty = false;
|
volume_dirty = false;
|
||||||
|
|
||||||
@@ -142,6 +153,7 @@ LocalBitmap::LocalBitmap(std::string fullpath)
|
|||||||
|
|
||||||
/* filename is valid, bitmap is decoded and valid, i can haz liftoff! */
|
/* filename is valid, bitmap is decoded and valid, i can haz liftoff! */
|
||||||
valid = true;
|
valid = true;
|
||||||
|
LocalAssetBrowser::add(*this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,6 +440,15 @@ void LocalBitmap::getDebugInfo() const
|
|||||||
<< "==========================" << LL_ENDL;
|
<< "==========================" << LL_ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLSD LocalBitmap::asLLSD() const
|
||||||
|
{
|
||||||
|
return LLSD()
|
||||||
|
.with("path", filename)
|
||||||
|
.with("id", id)
|
||||||
|
.with("update", keep_updating)
|
||||||
|
.with("type", bitmap_type);
|
||||||
|
}
|
||||||
|
|
||||||
/*=======================================*/
|
/*=======================================*/
|
||||||
/* LocalAssetBrowser: internal class */
|
/* LocalAssetBrowser: internal class */
|
||||||
/*=======================================*/
|
/*=======================================*/
|
||||||
@@ -437,15 +458,47 @@ void LocalBitmap::getDebugInfo() const
|
|||||||
Sits in memory until the viewer is closed.
|
Sits in memory until the viewer is closed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const std::string LocalAssetBrowser::getFileName() const
|
||||||
|
{
|
||||||
|
return gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "local_assets.xml");
|
||||||
|
}
|
||||||
|
|
||||||
LocalAssetBrowser::LocalAssetBrowser()
|
LocalAssetBrowser::LocalAssetBrowser()
|
||||||
{
|
{
|
||||||
|
gLocalBrowser = this;
|
||||||
mLayerUpdated = false;
|
mLayerUpdated = false;
|
||||||
mSculptUpdated = false;
|
mSculptUpdated = false;
|
||||||
|
|
||||||
|
// Load bitmaps
|
||||||
|
llifstream file(getFileName());
|
||||||
|
if (!file) return;
|
||||||
|
LLSD saved_assets;
|
||||||
|
LLSDSerialize::fromXML(saved_assets, file);
|
||||||
|
file.close();
|
||||||
|
for (auto it = saved_assets.beginArray(), end = saved_assets.endArray(); it < end; ++it)
|
||||||
|
{
|
||||||
|
const auto&& p = LLSDParamAdapter<LocalBitmap::Params>(*it);
|
||||||
|
LocalBitmap bm(p); // Creating one adds it to the list
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!loaded_bitmaps.empty()) PingTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalAssetBrowser::~LocalAssetBrowser()
|
LocalAssetBrowser::~LocalAssetBrowser()
|
||||||
{
|
{
|
||||||
|
// Save bitmaps
|
||||||
|
llofstream file(getFileName());
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
LL_WARNS() << "Could not open file " << getFileName() << " for saving." << LL_ENDL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LLSD saved_assets(LLSD::emptyArray());
|
||||||
|
for (const auto& bitmap : loaded_bitmaps)
|
||||||
|
saved_assets.append(bitmap.asLLSD());
|
||||||
|
LLSDSerialize::toPrettyXML(saved_assets, file);
|
||||||
|
file.close();
|
||||||
|
gLocalBrowser = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalAssetBrowser::AddBitmap()
|
void LocalAssetBrowser::AddBitmap()
|
||||||
@@ -461,20 +514,13 @@ void LocalAssetBrowser::AddBitmap_continued(AIFilePicker* filepicker)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bool change_happened = false;
|
bool change_happened = false;
|
||||||
std::vector<std::string> const& filenames(filepicker->getFilenames());
|
|
||||||
for(std::vector<std::string>::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename)
|
for(const auto& filename : filepicker->getFilenames())
|
||||||
{
|
if (LocalBitmap(filename).getIfValidBool())
|
||||||
LocalBitmap unit(*filename);
|
|
||||||
if (unit.getIfValidBool())
|
|
||||||
{
|
|
||||||
loaded_bitmaps.push_back(unit);
|
|
||||||
change_happened = true;
|
change_happened = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (change_happened) onChangeHappened();
|
if (change_happened) onChangeHappened();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalAssetBrowser::DelBitmap( std::vector<LLScrollListItem*> delete_vector, S32 column )
|
void LocalAssetBrowser::DelBitmap( std::vector<LLScrollListItem*> delete_vector, S32 column )
|
||||||
{
|
{
|
||||||
bool change_happened = false;
|
bool change_happened = false;
|
||||||
|
|||||||
@@ -97,7 +97,15 @@ struct affected_object
|
|||||||
class LocalBitmap
|
class LocalBitmap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalBitmap(std::string filename);
|
struct Params : public LLInitParam::Block<Params>
|
||||||
|
{
|
||||||
|
Mandatory<std::string> fullpath;
|
||||||
|
Optional<bool> keep_updating;
|
||||||
|
Optional<S32> type;
|
||||||
|
Optional<LLUUID> id;
|
||||||
|
Params(const std::string& path = LLStringUtil::null);
|
||||||
|
};
|
||||||
|
LocalBitmap(const Params& p);
|
||||||
virtual ~LocalBitmap();
|
virtual ~LocalBitmap();
|
||||||
friend class LocalAssetBrowser;
|
friend class LocalAssetBrowser;
|
||||||
|
|
||||||
@@ -138,6 +146,8 @@ class LocalBitmap
|
|||||||
bool getIfValidBool() const;
|
bool getIfValidBool() const;
|
||||||
S32 getType() const;
|
S32 getType() const;
|
||||||
void getDebugInfo() const;
|
void getDebugInfo() const;
|
||||||
|
LLSD asLLSD() const;
|
||||||
|
|
||||||
|
|
||||||
private: /* [maintenence functions] */
|
private: /* [maintenence functions] */
|
||||||
void updateSelf();
|
void updateSelf();
|
||||||
@@ -174,9 +184,10 @@ class LocalBitmap
|
|||||||
|
|
||||||
class AIFilePicker;
|
class AIFilePicker;
|
||||||
|
|
||||||
class LocalAssetBrowser
|
class LocalAssetBrowser : public LLSingleton<LocalAssetBrowser>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
const std::string getFileName() const;
|
||||||
LocalAssetBrowser();
|
LocalAssetBrowser();
|
||||||
virtual ~LocalAssetBrowser();
|
virtual ~LocalAssetBrowser();
|
||||||
friend class FloaterLocalAssetBrowser;
|
friend class FloaterLocalAssetBrowser;
|
||||||
@@ -184,6 +195,7 @@ class LocalAssetBrowser
|
|||||||
static void UpdateTextureCtrlList(LLScrollListCtrl*);
|
static void UpdateTextureCtrlList(LLScrollListCtrl*);
|
||||||
static void setLayerUpdated(bool toggle) { mLayerUpdated = toggle; }
|
static void setLayerUpdated(bool toggle) { mLayerUpdated = toggle; }
|
||||||
static void setSculptUpdated(bool toggle) { mSculptUpdated = toggle; }
|
static void setSculptUpdated(bool toggle) { mSculptUpdated = toggle; }
|
||||||
|
static void add(const LocalBitmap& unit) { loaded_bitmaps.push_back(unit); }
|
||||||
static void AddBitmap();
|
static void AddBitmap();
|
||||||
static void AddBitmap_continued(AIFilePicker* filepicker);
|
static void AddBitmap_continued(AIFilePicker* filepicker);
|
||||||
static void DelBitmap( std::vector<LLScrollListItem*>, S32 column = BITMAPLIST_COL_ID );
|
static void DelBitmap( std::vector<LLScrollListItem*>, S32 column = BITMAPLIST_COL_ID );
|
||||||
|
|||||||
@@ -165,6 +165,7 @@
|
|||||||
// in save_settings_to_globals()
|
// in save_settings_to_globals()
|
||||||
#include "llbutton.h"
|
#include "llbutton.h"
|
||||||
#include "llcombobox.h"
|
#include "llcombobox.h"
|
||||||
|
#include "floaterlocalassetbrowse.h"
|
||||||
#include "llstatusbar.h"
|
#include "llstatusbar.h"
|
||||||
#include "llsurface.h"
|
#include "llsurface.h"
|
||||||
#include "llvosky.h"
|
#include "llvosky.h"
|
||||||
@@ -1723,6 +1724,8 @@ bool LLAppViewer::cleanup()
|
|||||||
|
|
||||||
LLFloaterTeleportHistory::saveFile("teleport_history.xml");
|
LLFloaterTeleportHistory::saveFile("teleport_history.xml");
|
||||||
|
|
||||||
|
LocalAssetBrowser::deleteSingleton(); // <edit/>
|
||||||
|
|
||||||
// save mute list. gMuteList used to also be deleted here too.
|
// save mute list. gMuteList used to also be deleted here too.
|
||||||
LLMuteList::getInstance()->cache(gAgent.getID());
|
LLMuteList::getInstance()->cache(gAgent.getID());
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,7 @@
|
|||||||
#include "generichandlers.h"
|
#include "generichandlers.h"
|
||||||
|
|
||||||
// <edit>
|
// <edit>
|
||||||
|
#include "floaterlocalassetbrowse.h"
|
||||||
#include "llpanellogin.h"
|
#include "llpanellogin.h"
|
||||||
//#include "llfloateravatars.h"
|
//#include "llfloateravatars.h"
|
||||||
//#include "llactivation.h"
|
//#include "llactivation.h"
|
||||||
@@ -890,6 +891,8 @@ bool idle_startup()
|
|||||||
LLToolMgr::getInstance()->initTools();
|
LLToolMgr::getInstance()->initTools();
|
||||||
|
|
||||||
display_startup();
|
display_startup();
|
||||||
|
// Load local textures now, maybe someone wants to use them in UI (why?)
|
||||||
|
LocalAssetBrowser::instance(); // <edit/>
|
||||||
// Quickly get something onscreen to look at.
|
// Quickly get something onscreen to look at.
|
||||||
gViewerWindow->initWorldUI();
|
gViewerWindow->initWorldUI();
|
||||||
display_startup();
|
display_startup();
|
||||||
|
|||||||
Reference in New Issue
Block a user