diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index ab40ae841..fedb43235 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -221,9 +221,9 @@ else (STANDALONE)
)
endif (STANDALONE)
-if($ENV{OPENSIM_RULES} EQUAL 1)
+if(1 EQUAL 1)
add_definitions(-DOPENSIM_RULES=1)
-endif($ENV{OPENSIM_RULES} EQUAL 1)
+endif(1 EQUAL 1)
if(SERVER)
include_directories(${LIBS_PREBUILT_DIR}/include/havok)
diff --git a/indra/llui/lldelayeduidelete.cpp b/indra/llui/lldelayeduidelete.cpp
index d632c80fa..04035cd26 100644
--- a/indra/llui/lldelayeduidelete.cpp
+++ b/indra/llui/lldelayeduidelete.cpp
@@ -1,64 +1,64 @@
-//
-#include "linden_common.h"
-#include "lldelayeduidelete.h"
-#define DELETE_DELAY 0.1f
-#define DELETES_PER_DELAY 512
-std::list LLDeleteScheduler::sJobs;
-LLDeleteScheduler::LLDeleteScheduler() : LLEventTimer(DELETE_DELAY)
-{
-}
-void LLDeleteScheduler::addViewDeleteJob(std::list views)
-{
- if(!views.empty())
- {
- LLViewDeleteJob* job = new LLViewDeleteJob(views);
- sJobs.push_back(job);
- }
-}
-BOOL LLDeleteScheduler::tick() // IMPORTANT: never return TRUE
-{
- if(!sJobs.empty())
- {
- U32 completed = 0;
- do
- {
- LLDeleteJob* job = sJobs.front();
- if(job->work(completed))
- {
- delete job;
- sJobs.pop_front();
- }
- } while((completed < DELETES_PER_DELAY) && !sJobs.empty());
- }
- return FALSE; // EVER
-}
-BOOL LLDeleteJob::work(U32& completed)
-{
- llwarns << "THIS IS SPOSED TO BE OVERRIDDEN" << llendl;
- return TRUE;
-}
-LLViewDeleteJob::LLViewDeleteJob(std::list views)
-: mList(views)
-{
-}
-LLViewDeleteJob::~LLViewDeleteJob()
-{
-}
-BOOL LLViewDeleteJob::work(U32& completed)
-{
- do
- {
- if(!mList.empty())
- {
- LLView* view = mList.front();
- delete view;
- mList.pop_front();
- }
- else
- {
- return TRUE; // job done
- }
- } while(++completed < DELETES_PER_DELAY);
- return FALSE;
-}
-//
+//
+#include "linden_common.h"
+#include "lldelayeduidelete.h"
+#define DELETE_DELAY 0.1f
+#define DELETES_PER_DELAY 512
+std::list LLDeleteScheduler::sJobs;
+LLDeleteScheduler::LLDeleteScheduler() : LLEventTimer(DELETE_DELAY)
+{
+}
+void LLDeleteScheduler::addViewDeleteJob(std::list views)
+{
+ if(!views.empty())
+ {
+ LLViewDeleteJob* job = new LLViewDeleteJob(views);
+ sJobs.push_back(job);
+ }
+}
+BOOL LLDeleteScheduler::tick() // IMPORTANT: never return TRUE
+{
+ if(!sJobs.empty())
+ {
+ U32 completed = 0;
+ do
+ {
+ LLDeleteJob* job = sJobs.front();
+ if(job->work(completed))
+ {
+ delete job;
+ sJobs.pop_front();
+ }
+ } while((completed < DELETES_PER_DELAY) && !sJobs.empty());
+ }
+ return FALSE; // EVER
+}
+BOOL LLDeleteJob::work(U32& completed)
+{
+ llwarns << "THIS IS SPOSED TO BE OVERRIDDEN" << llendl;
+ return TRUE;
+}
+LLViewDeleteJob::LLViewDeleteJob(std::list views)
+: mList(views)
+{
+}
+LLViewDeleteJob::~LLViewDeleteJob()
+{
+}
+BOOL LLViewDeleteJob::work(U32& completed)
+{
+ do
+ {
+ if(!mList.empty())
+ {
+ LLView* view = mList.front();
+ delete view;
+ mList.pop_front();
+ }
+ else
+ {
+ return TRUE; // job done
+ }
+ } while(++completed < DELETES_PER_DELAY);
+ return FALSE;
+}
+//
diff --git a/indra/llui/lldelayeduidelete.h b/indra/llui/lldelayeduidelete.h
index 904a7b6a5..e682d8787 100644
--- a/indra/llui/lldelayeduidelete.h
+++ b/indra/llui/lldelayeduidelete.h
@@ -1,31 +1,31 @@
-//
-#ifndef LL_LLDELAYEDUIDELETE_H
-#define LL_LLDELAYEDUIDELETE_H
-#include "lltimer.h"
-#include "llview.h"
-class LLDeleteJob
-{
-public:
- virtual BOOL work(U32& completed);
-};
-class LLViewDeleteJob : public LLDeleteJob
-{
-public:
- LLViewDeleteJob(std::list views);
- virtual ~LLViewDeleteJob();
- virtual BOOL work(U32& completed);
-private:
- std::list mList;
-};
-class LLDeleteScheduler : public LLEventTimer
-{
-public:
- LLDeleteScheduler();
- void addViewDeleteJob(std::list views);
- BOOL tick();
-private:
- static std::list sJobs;
-};
-static LLDeleteScheduler* gDeleteScheduler;
-#endif
-//
+//
+#ifndef LL_LLDELAYEDUIDELETE_H
+#define LL_LLDELAYEDUIDELETE_H
+#include "lltimer.h"
+#include "llview.h"
+class LLDeleteJob
+{
+public:
+ virtual BOOL work(U32& completed);
+};
+class LLViewDeleteJob : public LLDeleteJob
+{
+public:
+ LLViewDeleteJob(std::list views);
+ virtual ~LLViewDeleteJob();
+ virtual BOOL work(U32& completed);
+private:
+ std::list mList;
+};
+class LLDeleteScheduler : public LLEventTimer
+{
+public:
+ LLDeleteScheduler();
+ void addViewDeleteJob(std::list views);
+ BOOL tick();
+private:
+ static std::list sJobs;
+};
+static LLDeleteScheduler* gDeleteScheduler;
+#endif
+//
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 5b38fe0ac..c87486df8 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -95,10 +95,10 @@
#include "lltexturefetch.h"
#include "llimageworker.h"
-//
-#include "lldelayeduidelete.h"
-#include "llbuildnewviewsscheduler.h"
-//
+//
+#include "lldelayeduidelete.h"
+#include "llbuildnewviewsscheduler.h"
+//
// The files below handle dependencies from cleanup.
#include "llkeyframemotion.h"
#include "llworldmap.h"
@@ -245,9 +245,9 @@ F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
LLUUID gInventoryLibraryOwner;
LLUUID gInventoryLibraryRoot;
-//
-LLUUID gLocalInventoryRoot;
-//
+//
+LLUUID gLocalInventoryRoot;
+//
BOOL gDisconnected = FALSE;
@@ -291,9 +291,9 @@ const std::string ERROR_MARKER_FILE_NAME("SecondLife.error_marker");
const std::string LLERROR_MARKER_FILE_NAME("SecondLife.llerror_marker");
const std::string LOGOUT_MARKER_FILE_NAME("SecondLife.logout_marker");
static BOOL gDoDisconnect = FALSE;
-//
-//static BOOL gBusyDisconnect = FALSE;
-//
+//
+//static BOOL gBusyDisconnect = FALSE;
+//
static std::string gLaunchFileOnQuit;
// Used on Win32 for other apps to identify our window (eg, win_setup)
@@ -575,10 +575,10 @@ bool LLAppViewer::init()
initLogging();
- //
- gDeleteScheduler = new LLDeleteScheduler();
- gBuildNewViewsScheduler = new LLBuildNewViewsScheduler();
- //
+ //
+ gDeleteScheduler = new LLDeleteScheduler();
+ gBuildNewViewsScheduler = new LLBuildNewViewsScheduler();
+ //
//
// OK to write stuff to logs now, we've now crash reported if necessary
//
@@ -594,19 +594,19 @@ bool LLAppViewer::init()
writeSystemInfo();
// Build a string representing the current version number.
- // meh
- /*
- //
+ // meh
+ /*
+ //
gCurrentVersion = llformat("%s %d.%d.%d.%d",
gSavedSettings.getString("VersionChannelName").c_str(),
LL_VERSION_MAJOR,
LL_VERSION_MINOR,
LL_VERSION_PATCH,
LL_VERSION_BUILD );
- //
- */
- gCurrentVersion = gSavedSettings.getString("SpecifiedChannel");
- //
+ //
+ */
+ gCurrentVersion = gSavedSettings.getString("SpecifiedChannel");
+ //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -940,7 +940,7 @@ bool LLAppViewer::mainLoop()
pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds!
LLFastTimer t3(LLFastTimer::FTM_IDLE);
- // bad_alloc!!
+ // bad_alloc!!
idle();
if (gAres != NULL && gAres->isInitialized())
@@ -1223,11 +1223,11 @@ bool LLAppViewer::cleanup()
// such that we can suck rectangle information out of
// it.
cleanupSavedSettings();
- llinfos << "Settings patched up" << llendflush;
-
- // moving this to below.
- /*
- //
+ llinfos << "Settings patched up" << llendflush;
+
+ // moving this to below.
+ /*
+ //
// delete some of the files left around in the cache.
removeCacheFiles("*.wav");
removeCacheFiles("*.tmp");
@@ -1236,9 +1236,9 @@ bool LLAppViewer::cleanup()
removeCacheFiles("*.dsf");
removeCacheFiles("*.bodypart");
removeCacheFiles("*.clothing");
- //
- */
- //
+ //
+ */
+ //
llinfos << "Cache files removed" << llendflush;
@@ -1367,18 +1367,18 @@ bool LLAppViewer::cleanup()
}
removeMarkerFile(); // Any crashes from here on we'll just have to ignore
- // moved this stuff from above to make it conditional here...
- if(!anotherInstanceRunning())
- {
- removeCacheFiles("*.wav");
- removeCacheFiles("*.tmp");
- removeCacheFiles("*.lso");
- removeCacheFiles("*.out");
- removeCacheFiles("*.dsf");
- removeCacheFiles("*.bodypart");
- removeCacheFiles("*.clothing");
- }
- //
+ // moved this stuff from above to make it conditional here...
+ if(!anotherInstanceRunning())
+ {
+ removeCacheFiles("*.wav");
+ removeCacheFiles("*.tmp");
+ removeCacheFiles("*.lso");
+ removeCacheFiles("*.out");
+ removeCacheFiles("*.dsf");
+ removeCacheFiles("*.bodypart");
+ removeCacheFiles("*.clothing");
+ }
+ //
writeDebugInfo();
@@ -2188,9 +2188,9 @@ bool LLAppViewer::initWindow()
// always start windowed
BOOL ignorePixelDepth = gSavedSettings.getBOOL("IgnorePixelDepth");
- //
- //gViewerWindow = new LLViewerWindow(gWindowTitle, "Second Life",
- gViewerWindow = new LLViewerWindow("Inertia", "Second Life",
+ //
+ //gViewerWindow = new LLViewerWindow(gWindowTitle, "Second Life",
+ gViewerWindow = new LLViewerWindow("Inertia", "Second Life",
//
gSavedSettings.getS32("WindowX"), gSavedSettings.getS32("WindowY"),
gSavedSettings.getS32("WindowWidth"), gSavedSettings.getS32("WindowHeight"),
@@ -2320,10 +2320,10 @@ void LLAppViewer::writeSystemInfo()
{
gDebugInfo["SLLog"] = LLError::logFileName();
- //
- //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
- //
+ //
+ //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
+ gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
+ //
gDebugInfo["ClientInfo"]["MajorVersion"] = LL_VERSION_MAJOR;
gDebugInfo["ClientInfo"]["MinorVersion"] = LL_VERSION_MINOR;
gDebugInfo["ClientInfo"]["PatchVersion"] = LL_VERSION_PATCH;
@@ -2419,10 +2419,10 @@ void LLAppViewer::handleViewerCrash()
//We already do this in writeSystemInfo(), but we do it again here to make /sure/ we have a version
//to check against no matter what
- //
- //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
- //
+ //
+ //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
+ gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
+ //
gDebugInfo["ClientInfo"]["MajorVersion"] = LL_VERSION_MAJOR;
gDebugInfo["ClientInfo"]["MinorVersion"] = LL_VERSION_MINOR;
@@ -3123,9 +3123,9 @@ void LLAppViewer::badNetworkHandler()
// Flush all of our caches on exit in the case of disconnect due to
// invalid packets.
- //
- if(1) return;
- //
+ //
+ if(1) return;
+ //
mPurgeOnExit = TRUE;
@@ -3342,10 +3342,10 @@ void LLAppViewer::idle()
// *FIX: (???) SAMANTHA
if (viewer_stats_timer.getElapsedTimeF32() >= SEND_STATS_PERIOD && !gDisconnected)
{
- // we are not transmitting session stats
- //llinfos << "Transmitting sessions stats" << llendl;
- //send_stats();
- //
+ // we are not transmitting session stats
+ //llinfos << "Transmitting sessions stats" << llendl;
+ //send_stats();
+ //
viewer_stats_timer.reset();
}
@@ -4083,10 +4083,10 @@ void LLAppViewer::handleLoginComplete()
initMainloopTimeout("Mainloop Init");
// Store some data to DebugInfo in case of a freeze.
- //
- //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
- gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
- //
+ //
+ //gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("VersionChannelName");
+ gDebugInfo["ClientInfo"]["Name"] = gSavedSettings.getString("SpecifiedChannel");
+ //
gDebugInfo["ClientInfo"]["MajorVersion"] = LL_VERSION_MAJOR;
gDebugInfo["ClientInfo"]["MinorVersion"] = LL_VERSION_MINOR;
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index f072f354a..a2de996d8 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -307,9 +307,9 @@ extern F32 gSimFrames;
extern LLUUID gInventoryLibraryOwner;
extern LLUUID gInventoryLibraryRoot;
-//
-extern LLUUID gLocalInventoryRoot;
-//
+//
+extern LLUUID gLocalInventoryRoot;
+//
extern BOOL gDisconnected;
diff --git a/indra/newview/llbuildnewviewsscheduler.cpp b/indra/newview/llbuildnewviewsscheduler.cpp
index c7dbceb25..b244b1d3f 100644
--- a/indra/newview/llbuildnewviewsscheduler.cpp
+++ b/indra/newview/llbuildnewviewsscheduler.cpp
@@ -1,140 +1,140 @@
-//
-#include "llviewerprecompiledheaders.h"
-#include "llbuildnewviewsscheduler.h"
-#include "llinventorybridge.h"
-#define BUILD_DELAY 0.1f
-#define BUILD_PER_DELAY 512
-std::list LLBuildNewViewsScheduler::sJobs;
-LLBuildNewViewsScheduler::LLBuildNewViewsScheduler() : LLEventTimer(BUILD_DELAY)
-{
-}
-void LLBuildNewViewsScheduler::addJob(LLInventoryPanel* inventory_panel, LLInventoryObject* inventory_object)
-{
- LLBuildNewViewsScheduler::job j;
- j.mInventoryPanel = inventory_panel;
- j.mInventoryObject = inventory_object;
- sJobs.push_back(j);
-}
-void LLBuildNewViewsScheduler::cancel(LLInventoryPanel* inventory_panel)
-{
- for(std::list::iterator iter = sJobs.begin();
- iter != sJobs.end(); )
- {
- LLInventoryPanel* job_panel = (*iter).mInventoryPanel;
- if(job_panel == inventory_panel)
- {
- iter = sJobs.erase(iter);
- }
- else
- {
- ++iter;
- }
- }
-}
-BOOL LLBuildNewViewsScheduler::tick()
-{
- U32 i = 0;
- while(!sJobs.empty() && (i < BUILD_PER_DELAY))
- {
- LLBuildNewViewsScheduler::job j = sJobs.front();
- buildNewViews(j.mInventoryPanel, j.mInventoryObject);
- sJobs.pop_front();
- ++i;
- }
- return FALSE;
-}
-void LLBuildNewViewsScheduler::buildNewViews(LLInventoryPanel* panelp, LLInventoryObject* objectp)
-{
- LLFolderViewItem* itemp = NULL;
-
- if (objectp)
- {
- if (objectp->getType() <= LLAssetType::AT_NONE ||
- objectp->getType() >= LLAssetType::AT_COUNT)
- {
- llwarns << "called with objectp->mType == "
- << ((S32) objectp->getType())
- << " (shouldn't happen)" << llendl;
- }
- else if (objectp->getType() == LLAssetType::AT_CATEGORY) // build new view for category
- {
- LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(objectp->getType(),
- LLInventoryType::IT_CATEGORY,
- panelp,
- objectp->getUUID());
-
- if (new_listener)
- {
- LLFolderViewFolder* folderp = new LLFolderViewFolder(new_listener->getDisplayName(),
- new_listener->getIcon(),
- panelp->getRootFolder(),
- new_listener);
-
- folderp->setItemSortOrder(panelp->getSortOrder());
- itemp = folderp;
- }
- }
- else // build new view for item
- {
- LLInventoryItem* item = (LLInventoryItem*)objectp;
- LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(
- item->getType(),
- item->getInventoryType(),
- panelp,
- item->getUUID(),
- item->getFlags());
- if (new_listener)
- {
- itemp = new LLFolderViewItem(new_listener->getDisplayName(),
- new_listener->getIcon(),
- new_listener->getCreationDate(),
- panelp->getRootFolder(),
- new_listener);
- }
- }
-
- LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)panelp->getRootFolder()->getItemByID(objectp->getParentUUID());
-
- if (itemp)
- {
- itemp->mDelayedDelete = TRUE;
- if (parent_folder)
- {
- itemp->addToFolder(parent_folder, panelp->getRootFolder());
- }
- else
- {
- llwarns << "Couldn't find parent folder for child " << itemp->getLabel() << llendl;
- delete itemp;
- }
- }
- }
-
- if (!objectp || (objectp && (objectp->getType() == LLAssetType::AT_CATEGORY)))
- {
- LLViewerInventoryCategory::cat_array_t* categories;
- LLViewerInventoryItem::item_array_t* items;
-
- panelp->getModel()->lockDirectDescendentArrays((objectp != NULL) ? objectp->getUUID() : LLUUID::null, categories, items);
- if(categories)
- {
- S32 count = categories->count();
- for(S32 i = 0; i < count; ++i)
- {
- LLInventoryCategory* cat = categories->get(i);
- addJob(panelp, cat);
- }
- }
- if(items)
- {
- S32 count = items->count();
- for(S32 i = 0; i < count; ++i)
- {
- LLInventoryItem* item = items->get(i);
- addJob(panelp, item);
- }
- }
- panelp->getModel()->unlockDirectDescendentArrays(objectp->getUUID());
- }
-}
-//
+//
+#include "llviewerprecompiledheaders.h"
+#include "llbuildnewviewsscheduler.h"
+#include "llinventorybridge.h"
+#define BUILD_DELAY 0.1f
+#define BUILD_PER_DELAY 512
+std::list LLBuildNewViewsScheduler::sJobs;
+LLBuildNewViewsScheduler::LLBuildNewViewsScheduler() : LLEventTimer(BUILD_DELAY)
+{
+}
+void LLBuildNewViewsScheduler::addJob(LLInventoryPanel* inventory_panel, LLInventoryObject* inventory_object)
+{
+ LLBuildNewViewsScheduler::job j;
+ j.mInventoryPanel = inventory_panel;
+ j.mInventoryObject = inventory_object;
+ sJobs.push_back(j);
+}
+void LLBuildNewViewsScheduler::cancel(LLInventoryPanel* inventory_panel)
+{
+ for(std::list::iterator iter = sJobs.begin();
+ iter != sJobs.end(); )
+ {
+ LLInventoryPanel* job_panel = (*iter).mInventoryPanel;
+ if(job_panel == inventory_panel)
+ {
+ iter = sJobs.erase(iter);
+ }
+ else
+ {
+ ++iter;
+ }
+ }
+}
+BOOL LLBuildNewViewsScheduler::tick()
+{
+ U32 i = 0;
+ while(!sJobs.empty() && (i < BUILD_PER_DELAY))
+ {
+ LLBuildNewViewsScheduler::job j = sJobs.front();
+ buildNewViews(j.mInventoryPanel, j.mInventoryObject);
+ sJobs.pop_front();
+ ++i;
+ }
+ return FALSE;
+}
+void LLBuildNewViewsScheduler::buildNewViews(LLInventoryPanel* panelp, LLInventoryObject* objectp)
+{
+ LLFolderViewItem* itemp = NULL;
+
+ if (objectp)
+ {
+ if (objectp->getType() <= LLAssetType::AT_NONE ||
+ objectp->getType() >= LLAssetType::AT_COUNT)
+ {
+ llwarns << "called with objectp->mType == "
+ << ((S32) objectp->getType())
+ << " (shouldn't happen)" << llendl;
+ }
+ else if (objectp->getType() == LLAssetType::AT_CATEGORY) // build new view for category
+ {
+ LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(objectp->getType(),
+ LLInventoryType::IT_CATEGORY,
+ panelp,
+ objectp->getUUID());
+
+ if (new_listener)
+ {
+ LLFolderViewFolder* folderp = new LLFolderViewFolder(new_listener->getDisplayName(),
+ new_listener->getIcon(),
+ panelp->getRootFolder(),
+ new_listener);
+
+ folderp->setItemSortOrder(panelp->getSortOrder());
+ itemp = folderp;
+ }
+ }
+ else // build new view for item
+ {
+ LLInventoryItem* item = (LLInventoryItem*)objectp;
+ LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(
+ item->getType(),
+ item->getInventoryType(),
+ panelp,
+ item->getUUID(),
+ item->getFlags());
+ if (new_listener)
+ {
+ itemp = new LLFolderViewItem(new_listener->getDisplayName(),
+ new_listener->getIcon(),
+ new_listener->getCreationDate(),
+ panelp->getRootFolder(),
+ new_listener);
+ }
+ }
+
+ LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)panelp->getRootFolder()->getItemByID(objectp->getParentUUID());
+
+ if (itemp)
+ {
+ itemp->mDelayedDelete = TRUE;
+ if (parent_folder)
+ {
+ itemp->addToFolder(parent_folder, panelp->getRootFolder());
+ }
+ else
+ {
+ llwarns << "Couldn't find parent folder for child " << itemp->getLabel() << llendl;
+ delete itemp;
+ }
+ }
+ }
+
+ if (!objectp || (objectp && (objectp->getType() == LLAssetType::AT_CATEGORY)))
+ {
+ LLViewerInventoryCategory::cat_array_t* categories;
+ LLViewerInventoryItem::item_array_t* items;
+
+ panelp->getModel()->lockDirectDescendentArrays((objectp != NULL) ? objectp->getUUID() : LLUUID::null, categories, items);
+ if(categories)
+ {
+ S32 count = categories->count();
+ for(S32 i = 0; i < count; ++i)
+ {
+ LLInventoryCategory* cat = categories->get(i);
+ addJob(panelp, cat);
+ }
+ }
+ if(items)
+ {
+ S32 count = items->count();
+ for(S32 i = 0; i < count; ++i)
+ {
+ LLInventoryItem* item = items->get(i);
+ addJob(panelp, item);
+ }
+ }
+ panelp->getModel()->unlockDirectDescendentArrays(objectp->getUUID());
+ }
+}
+//
diff --git a/indra/newview/llbuildnewviewsscheduler.h b/indra/newview/llbuildnewviewsscheduler.h
index e6720f37c..e68e4365b 100644
--- a/indra/newview/llbuildnewviewsscheduler.h
+++ b/indra/newview/llbuildnewviewsscheduler.h
@@ -1,21 +1,21 @@
-//
-#include "llinventoryview.h"
-#include "llinventory.h"
-class LLBuildNewViewsScheduler : public LLEventTimer
-{
- typedef struct
- {
- LLInventoryPanel* mInventoryPanel;
- LLInventoryObject* mInventoryObject;
- } job;
-public:
- LLBuildNewViewsScheduler();
- void addJob(LLInventoryPanel* inventory_panel, LLInventoryObject* inventory_object);
- void cancel(LLInventoryPanel* inventory_panel);
- BOOL tick();
-private:
- static std::list sJobs;
- void buildNewViews(LLInventoryPanel* panelp, LLInventoryObject* objectp);
-};
-static LLBuildNewViewsScheduler* gBuildNewViewsScheduler;
-//
+//
+#include "llinventoryview.h"
+#include "llinventory.h"
+class LLBuildNewViewsScheduler : public LLEventTimer
+{
+ typedef struct
+ {
+ LLInventoryPanel* mInventoryPanel;
+ LLInventoryObject* mInventoryObject;
+ } job;
+public:
+ LLBuildNewViewsScheduler();
+ void addJob(LLInventoryPanel* inventory_panel, LLInventoryObject* inventory_object);
+ void cancel(LLInventoryPanel* inventory_panel);
+ BOOL tick();
+private:
+ static std::list sJobs;
+ void buildNewViews(LLInventoryPanel* panelp, LLInventoryObject* objectp);
+};
+static LLBuildNewViewsScheduler* gBuildNewViewsScheduler;
+//
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 712d0c086..fb83dc1da 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -200,10 +200,12 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
mOFN.lpstrFilter = INVGZ_FILTER \
L"\0";
break;
+/*
case FFLOAD_AO:
mOFN.lpstrFilter = AO_FILTER \
L"\0";
break;
+*/
//
default:
res = FALSE;
diff --git a/indra/newview/llfloaterexploreanimations.cpp b/indra/newview/llfloaterexploreanimations.cpp
index ec9856c18..c532562d0 100644
--- a/indra/newview/llfloaterexploreanimations.cpp
+++ b/indra/newview/llfloaterexploreanimations.cpp
@@ -1,310 +1,310 @@
-//
-
-#include "llviewerprecompiledheaders.h"
-#include "llfloaterexploreanimations.h"
-#include "lluictrlfactory.h"
-#include "llscrolllistctrl.h"
-#include "llfloateranimpreview.h"
-#include "llvoavatar.h"
-#include "lllocalinventory.h"
-//
-#include "llfloatertools.h"
-#include "llselectmgr.h"
-//
-
-std::map> LLFloaterExploreAnimations::animHistory;
-LLFloaterExploreAnimations* LLFloaterExploreAnimations::sInstance;
-
-
-LLAnimHistoryItem::LLAnimHistoryItem(LLUUID assetid)
-{
- mAssetID = assetid;
-}
-
-LLFloaterExploreAnimations::LLFloaterExploreAnimations(LLUUID avatarid)
-: LLFloater()
-{
- LLFloaterExploreAnimations::sInstance = this;
- mAvatarID = avatarid;
- mAnimPreview = new LLPreviewAnimation(256, 256);
- mAnimPreview->setZoom(2.0f);
- LLUICtrlFactory::getInstance()->buildFloater(this, "floater_explore_animations.xml");
-}
-
-void LLFloaterExploreAnimations::close(bool app_quitting)
-{
- LLFloater::close(app_quitting);
-}
-
-LLFloaterExploreAnimations::~LLFloaterExploreAnimations()
-{
- delete mAnimPreview;
- LLFloaterExploreAnimations::sInstance = NULL;
-}
-
-BOOL LLFloaterExploreAnimations::postBuild(void)
-{
- childSetCommitCallback("anim_list", onSelectAnimation, this);
- childSetAction("copy_uuid_btn", onClickCopyUUID, this);
- childSetAction("open_btn", onClickOpen, this);
- childSetAction("jelly_roll_btn", onClickJellyRoll, this);
- update();
- return TRUE;
-}
-
-void LLFloaterExploreAnimations::update()
-{
- LLScrollListCtrl* list = getChild("anim_list");
- LLUUID selection = list->getSelectedValue().asUUID();
- list->clearRows(); // do this differently probably
-
- std::list history = animHistory[mAvatarID];
- std::list::iterator iter = history.begin();
- std::list::iterator end = history.end();
- for( ; iter != end; ++iter)
- {
- LLAnimHistoryItem* item = (*iter);
-
- LLSD element;
- element["id"] = item->mAssetID;
-
- LLSD& name_column = element["columns"][0];
- name_column["column"] = "name";
- name_column["value"] = item->mAssetID.asString();
-
- LLSD& info_column = element["columns"][1];
- info_column["column"] = "info";
- if(item->mPlaying)
- info_column["value"] = "Playing";
- else
- info_column["value"] = llformat("%.1f min ago", (LLTimer::getElapsedSeconds() - item->mTimeStopped) / 60.f);
-
- list->addElement(element, ADD_BOTTOM);
- }
-
- list->selectByID(selection);
-}
-
-void LLFloaterExploreAnimations::draw()
-{
- LLFloater::draw();
-
- LLRect r = getRect();
-
- gGL.color3f(1.f, 1.f, 1.f);
-
- gGL.getTexUnit(0)->bind(mAnimPreview->getTexture());
-
- gGL.begin( LLRender::QUADS );
- {
- gGL.texCoord2f(0.f, 1.f);
- gGL.vertex2i(r.getWidth() - 266, r.getHeight() - 25);
- gGL.texCoord2f(0.f, 0.f);
- gGL.vertex2i(r.getWidth() - 266, r.getHeight() - 256);
- gGL.texCoord2f(1.f, 0.f);
- gGL.vertex2i(r.getWidth() - 10, r.getHeight() - 256);
- gGL.texCoord2f(1.f, 1.f);
- gGL.vertex2i(r.getWidth() - 10, r.getHeight() - 25);
- }
- gGL.end();
-
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
- //LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
- //if (!avatarp->areAnimationsPaused())
- //{
- // mAnimPreview->requestUpdate();
- //}
-}
-
-
-
-
-
-// static
-void LLFloaterExploreAnimations::startAnim(LLUUID avatarid, LLUUID assetid)
-{
- std::string asset_str = assetid.asString();
- if(asset_str.find("17132261-c061") != std::string::npos) return; // dog1
- else if(asset_str.find("fea558cb-8b9b") != std::string::npos) return; // dog2
- else if(asset_str.find("50cb5750-0743") != std::string::npos) return; // dog3
- else if(asset_str.find("-dead-") != std::string::npos) return; // emo
-
- LLAnimHistoryItem* item = NULL;
-
- std::list history = animHistory[avatarid];
- std::list::iterator iter = history.begin();
- std::list::iterator end = history.end();
- for( ; iter != end; ++iter)
- {
- if((*iter)->mAssetID == assetid)
- {
- item = (*iter);
- break;
- }
- }
- if(!item)
- {
- item = new LLAnimHistoryItem(assetid);
- item->mAvatarID = avatarid;
- item->mTimeStarted = LLTimer::getElapsedSeconds();
- }
- item->mPlaying = true;
- history.push_back(item);
- animHistory[avatarid] = history; // is this really necessary?
- handleHistoryChange();
-}
-
-// static
-void LLFloaterExploreAnimations::stopAnim(LLUUID avatarid, LLUUID assetid)
-{
- std::string asset_str = assetid.asString();
- if(asset_str.find("17132261-c061") != std::string::npos) return; // dog1
- else if(asset_str.find("fea558cb-8b9b") != std::string::npos) return; // dog2
- else if(asset_str.find("50cb5750-0743") != std::string::npos) return; // dog3
- else if(asset_str.find("-dead-") != std::string::npos) return; // emo
-
- LLAnimHistoryItem* item = NULL;
-
- std::list history = animHistory[avatarid];
- std::list::iterator iter = history.begin();
- std::list::iterator end = history.end();
- for( ; iter != end; ++iter)
- {
- if((*iter)->mAssetID == assetid)
- {
- item = (*iter);
- break;
- }
- }
- if(!item)
- {
- item = new LLAnimHistoryItem(assetid);
- item->mAvatarID = avatarid;
- item->mTimeStarted = LLTimer::getElapsedSeconds();
- history.push_back(item);
- }
- item->mPlaying = false;
- item->mTimeStopped = LLTimer::getElapsedSeconds();
- handleHistoryChange();
-}
-
-class LLAnimHistoryItemCompare
-{
-public:
- bool operator() (LLAnimHistoryItem* first, LLAnimHistoryItem* second)
- {
- if(first->mPlaying)
- {
- if(second->mPlaying)
- {
- return (first->mTimeStarted > second->mTimeStarted);
- }
- else
- {
- return true;
- }
- }
- else if(second->mPlaying)
- {
- return false;
- }
- else
- {
- return (first->mTimeStopped > second->mTimeStopped);
- }
- }
-};
-
-// static
-void LLFloaterExploreAnimations::handleHistoryChange()
-{
- std::map>::iterator av_iter = animHistory.begin();
- std::map>::iterator av_end = animHistory.end();
- for( ; av_iter != av_end; ++av_iter)
- {
- std::list history = (*av_iter).second;
-
- // Sort it
- LLAnimHistoryItemCompare c;
- history.sort(c);
-
- // Remove dupes
- history.unique();
-
- // Trim it
- if(history.size() > 32)
- {
- history.resize(32);
- }
-
- animHistory[(*av_iter).first] = history;
- }
-
- // Update floater
- if(LLFloaterExploreAnimations::sInstance)
- LLFloaterExploreAnimations::sInstance->update();
-}
-
-
-
-
-
-// static
-void LLFloaterExploreAnimations::onSelectAnimation(LLUICtrl* ctrl, void* user_data)
-{
- LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)user_data;
- LLPreviewAnimation* preview = (LLPreviewAnimation*)floater->mAnimPreview;
- LLScrollListCtrl* list = floater->getChild("anim_list");
- LLUUID selection = list->getSelectedValue().asUUID();
-
- preview->getDummyAvatar()->deactivateAllMotions();
- preview->getDummyAvatar()->startMotion(selection, 0.f);
- preview->setZoom(2.0f);
-}
-
-// static
-void LLFloaterExploreAnimations::onClickCopyUUID(void* data)
-{
- LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
- LLScrollListCtrl* list = floater->getChild("anim_list");
- LLUUID selection = list->getSelectedValue().asUUID();
- gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(selection.asString()));
-}
-
-void LLFloaterExploreAnimations::onClickOpen(void* data)
-{
- LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
- LLScrollListCtrl* list = floater->getChild("anim_list");
- LLUUID selection = list->getSelectedValue().asUUID();
- LLUUID item = LLLocalInventory::addItem(selection.asString(), LLAssetType::AT_ANIMATION, selection, true);
-}
-
-void LLFloaterExploreAnimations::onClickJellyRoll(void* data)
-{
- std::string hover_text;
- LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
- LLObjectSelection::valid_iterator sel_it = selection->valid_begin();
- LLObjectSelection::valid_iterator sel_end = selection->valid_end();
- for( ; sel_it != sel_end; ++sel_it)
- {
- LLViewerObject* objectp = (*sel_it)->getObject();
- hover_text = objectp->getDebugText();
- if(hover_text != "")
- {
- break;
- }
- }
-
- LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
- LLScrollListCtrl* list = floater->getChild("anim_list");
- LLUUID anim_id = list->getSelectedValue().asUUID();
-
- LLFloaterNewLocalInventory* createy = new LLFloaterNewLocalInventory();
- createy->childSetText("name_line", hover_text);
- createy->childSetText("asset_id_line", anim_id.asString());
- createy->childSetValue("type_combo", "animatn");
- createy->childSetText("creator_id_line", LLFloaterNewLocalInventory::sLastCreatorId.asString());
-}
-
-//
+//
+
+#include "llviewerprecompiledheaders.h"
+#include "llfloaterexploreanimations.h"
+#include "lluictrlfactory.h"
+#include "llscrolllistctrl.h"
+#include "llfloateranimpreview.h"
+#include "llvoavatar.h"
+#include "lllocalinventory.h"
+//
+#include "llfloatertools.h"
+#include "llselectmgr.h"
+//
+
+std::map> LLFloaterExploreAnimations::animHistory;
+LLFloaterExploreAnimations* LLFloaterExploreAnimations::sInstance;
+
+
+LLAnimHistoryItem::LLAnimHistoryItem(LLUUID assetid)
+{
+ mAssetID = assetid;
+}
+
+LLFloaterExploreAnimations::LLFloaterExploreAnimations(LLUUID avatarid)
+: LLFloater()
+{
+ LLFloaterExploreAnimations::sInstance = this;
+ mAvatarID = avatarid;
+ mAnimPreview = new LLPreviewAnimation(256, 256);
+ mAnimPreview->setZoom(2.0f);
+ LLUICtrlFactory::getInstance()->buildFloater(this, "floater_explore_animations.xml");
+}
+
+void LLFloaterExploreAnimations::close(bool app_quitting)
+{
+ LLFloater::close(app_quitting);
+}
+
+LLFloaterExploreAnimations::~LLFloaterExploreAnimations()
+{
+ delete mAnimPreview;
+ LLFloaterExploreAnimations::sInstance = NULL;
+}
+
+BOOL LLFloaterExploreAnimations::postBuild(void)
+{
+ childSetCommitCallback("anim_list", onSelectAnimation, this);
+ childSetAction("copy_uuid_btn", onClickCopyUUID, this);
+ childSetAction("open_btn", onClickOpen, this);
+ childSetAction("jelly_roll_btn", onClickJellyRoll, this);
+ update();
+ return TRUE;
+}
+
+void LLFloaterExploreAnimations::update()
+{
+ LLScrollListCtrl* list = getChild("anim_list");
+ LLUUID selection = list->getSelectedValue().asUUID();
+ list->clearRows(); // do this differently probably
+
+ std::list history = animHistory[mAvatarID];
+ std::list::iterator iter = history.begin();
+ std::list::iterator end = history.end();
+ for( ; iter != end; ++iter)
+ {
+ LLAnimHistoryItem* item = (*iter);
+
+ LLSD element;
+ element["id"] = item->mAssetID;
+
+ LLSD& name_column = element["columns"][0];
+ name_column["column"] = "name";
+ name_column["value"] = item->mAssetID.asString();
+
+ LLSD& info_column = element["columns"][1];
+ info_column["column"] = "info";
+ if(item->mPlaying)
+ info_column["value"] = "Playing";
+ else
+ info_column["value"] = llformat("%.1f min ago", (LLTimer::getElapsedSeconds() - item->mTimeStopped) / 60.f);
+
+ list->addElement(element, ADD_BOTTOM);
+ }
+
+ list->selectByID(selection);
+}
+
+void LLFloaterExploreAnimations::draw()
+{
+ LLFloater::draw();
+
+ LLRect r = getRect();
+
+ gGL.color3f(1.f, 1.f, 1.f);
+
+ gGL.getTexUnit(0)->bind(mAnimPreview->getTexture());
+
+ gGL.begin( LLRender::QUADS );
+ {
+ gGL.texCoord2f(0.f, 1.f);
+ gGL.vertex2i(r.getWidth() - 266, r.getHeight() - 25);
+ gGL.texCoord2f(0.f, 0.f);
+ gGL.vertex2i(r.getWidth() - 266, r.getHeight() - 256);
+ gGL.texCoord2f(1.f, 0.f);
+ gGL.vertex2i(r.getWidth() - 10, r.getHeight() - 256);
+ gGL.texCoord2f(1.f, 1.f);
+ gGL.vertex2i(r.getWidth() - 10, r.getHeight() - 25);
+ }
+ gGL.end();
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+ //LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
+ //if (!avatarp->areAnimationsPaused())
+ //{
+ // mAnimPreview->requestUpdate();
+ //}
+}
+
+
+
+
+
+// static
+void LLFloaterExploreAnimations::startAnim(LLUUID avatarid, LLUUID assetid)
+{
+ std::string asset_str = assetid.asString();
+ if(asset_str.find("17132261-c061") != std::string::npos) return; // dog1
+ else if(asset_str.find("fea558cb-8b9b") != std::string::npos) return; // dog2
+ else if(asset_str.find("50cb5750-0743") != std::string::npos) return; // dog3
+ else if(asset_str.find("-dead-") != std::string::npos) return; // emo
+
+ LLAnimHistoryItem* item = NULL;
+
+ std::list history = animHistory[avatarid];
+ std::list::iterator iter = history.begin();
+ std::list::iterator end = history.end();
+ for( ; iter != end; ++iter)
+ {
+ if((*iter)->mAssetID == assetid)
+ {
+ item = (*iter);
+ break;
+ }
+ }
+ if(!item)
+ {
+ item = new LLAnimHistoryItem(assetid);
+ item->mAvatarID = avatarid;
+ item->mTimeStarted = LLTimer::getElapsedSeconds();
+ }
+ item->mPlaying = true;
+ history.push_back(item);
+ animHistory[avatarid] = history; // is this really necessary?
+ handleHistoryChange();
+}
+
+// static
+void LLFloaterExploreAnimations::stopAnim(LLUUID avatarid, LLUUID assetid)
+{
+ std::string asset_str = assetid.asString();
+ if(asset_str.find("17132261-c061") != std::string::npos) return; // dog1
+ else if(asset_str.find("fea558cb-8b9b") != std::string::npos) return; // dog2
+ else if(asset_str.find("50cb5750-0743") != std::string::npos) return; // dog3
+ else if(asset_str.find("-dead-") != std::string::npos) return; // emo
+
+ LLAnimHistoryItem* item = NULL;
+
+ std::list history = animHistory[avatarid];
+ std::list::iterator iter = history.begin();
+ std::list::iterator end = history.end();
+ for( ; iter != end; ++iter)
+ {
+ if((*iter)->mAssetID == assetid)
+ {
+ item = (*iter);
+ break;
+ }
+ }
+ if(!item)
+ {
+ item = new LLAnimHistoryItem(assetid);
+ item->mAvatarID = avatarid;
+ item->mTimeStarted = LLTimer::getElapsedSeconds();
+ history.push_back(item);
+ }
+ item->mPlaying = false;
+ item->mTimeStopped = LLTimer::getElapsedSeconds();
+ handleHistoryChange();
+}
+
+class LLAnimHistoryItemCompare
+{
+public:
+ bool operator() (LLAnimHistoryItem* first, LLAnimHistoryItem* second)
+ {
+ if(first->mPlaying)
+ {
+ if(second->mPlaying)
+ {
+ return (first->mTimeStarted > second->mTimeStarted);
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else if(second->mPlaying)
+ {
+ return false;
+ }
+ else
+ {
+ return (first->mTimeStopped > second->mTimeStopped);
+ }
+ }
+};
+
+// static
+void LLFloaterExploreAnimations::handleHistoryChange()
+{
+ std::map>::iterator av_iter = animHistory.begin();
+ std::map>::iterator av_end = animHistory.end();
+ for( ; av_iter != av_end; ++av_iter)
+ {
+ std::list history = (*av_iter).second;
+
+ // Sort it
+ LLAnimHistoryItemCompare c;
+ history.sort(c);
+
+ // Remove dupes
+ history.unique();
+
+ // Trim it
+ if(history.size() > 32)
+ {
+ history.resize(32);
+ }
+
+ animHistory[(*av_iter).first] = history;
+ }
+
+ // Update floater
+ if(LLFloaterExploreAnimations::sInstance)
+ LLFloaterExploreAnimations::sInstance->update();
+}
+
+
+
+
+
+// static
+void LLFloaterExploreAnimations::onSelectAnimation(LLUICtrl* ctrl, void* user_data)
+{
+ LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)user_data;
+ LLPreviewAnimation* preview = (LLPreviewAnimation*)floater->mAnimPreview;
+ LLScrollListCtrl* list = floater->getChild("anim_list");
+ LLUUID selection = list->getSelectedValue().asUUID();
+
+ preview->getDummyAvatar()->deactivateAllMotions();
+ preview->getDummyAvatar()->startMotion(selection, 0.f);
+ preview->setZoom(2.0f);
+}
+
+// static
+void LLFloaterExploreAnimations::onClickCopyUUID(void* data)
+{
+ LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
+ LLScrollListCtrl* list = floater->getChild("anim_list");
+ LLUUID selection = list->getSelectedValue().asUUID();
+ gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(selection.asString()));
+}
+
+void LLFloaterExploreAnimations::onClickOpen(void* data)
+{
+ LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
+ LLScrollListCtrl* list = floater->getChild("anim_list");
+ LLUUID selection = list->getSelectedValue().asUUID();
+ LLUUID item = LLLocalInventory::addItem(selection.asString(), LLAssetType::AT_ANIMATION, selection, true);
+}
+
+void LLFloaterExploreAnimations::onClickJellyRoll(void* data)
+{
+ std::string hover_text;
+ LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+ LLObjectSelection::valid_iterator sel_it = selection->valid_begin();
+ LLObjectSelection::valid_iterator sel_end = selection->valid_end();
+ for( ; sel_it != sel_end; ++sel_it)
+ {
+ LLViewerObject* objectp = (*sel_it)->getObject();
+ hover_text = objectp->getDebugText();
+ if(hover_text != "")
+ {
+ break;
+ }
+ }
+
+ LLFloaterExploreAnimations* floater = (LLFloaterExploreAnimations*)data;
+ LLScrollListCtrl* list = floater->getChild("anim_list");
+ LLUUID anim_id = list->getSelectedValue().asUUID();
+
+ LLFloaterNewLocalInventory* createy = new LLFloaterNewLocalInventory();
+ createy->childSetText("name_line", hover_text);
+ createy->childSetText("asset_id_line", anim_id.asString());
+ createy->childSetValue("type_combo", "animatn");
+ createy->childSetText("creator_id_line", LLFloaterNewLocalInventory::sLastCreatorId.asString());
+}
+
+//
diff --git a/indra/newview/llfloaterexploreanimations.h b/indra/newview/llfloaterexploreanimations.h
index 2c1070f93..c9317f4f8 100644
--- a/indra/newview/llfloaterexploreanimations.h
+++ b/indra/newview/llfloaterexploreanimations.h
@@ -1,58 +1,58 @@
-//
-#ifndef LL_LLFLOATEREXPLOREANIMATIONS_H
-#define LL_LLFLOATEREXPLOREANIMATIONS_H
-
-#include "llfloater.h"
-#include "llfloateranimpreview.h"
-#include "llviewerwindow.h" // gViewerWindow
-
-class LLAnimHistoryItem
-{
-public:
- LLAnimHistoryItem(LLUUID assetid);
-
- LLUUID mAvatarID;
- LLUUID mAssetID;
- bool mPlaying;
- F64 mTimeStarted;
- F64 mTimeStopped;
-};
-
-class LLFloaterExploreAnimations
-: public LLFloater
-{
-public:
- LLFloaterExploreAnimations(LLUUID avatarid);
- BOOL postBuild(void);
- void close(bool app_quitting);
-
- void update();
-
- LLUUID mAvatarID;
- LLPreviewAnimation* mAnimPreview;
-
-private:
- virtual ~LLFloaterExploreAnimations();
-
-
-// static stuff!
-public:
- static void onSelectAnimation(LLUICtrl* ctrl, void* user_data);
- static void onClickCopyUUID(void* data);
- static void onClickOpen(void* data);
- static void onClickJellyRoll(void* data);
-
- static void startAnim(LLUUID avatarid, LLUUID assetid);
- static void stopAnim(LLUUID avatarid, LLUUID assetid);
-
- static std::map> animHistory;
- static LLFloaterExploreAnimations* sInstance;
-private:
- static void handleHistoryChange();
-
-protected:
- void draw();
-};
-
-#endif
-//
+//
+#ifndef LL_LLFLOATEREXPLOREANIMATIONS_H
+#define LL_LLFLOATEREXPLOREANIMATIONS_H
+
+#include "llfloater.h"
+#include "llfloateranimpreview.h"
+#include "llviewerwindow.h" // gViewerWindow
+
+class LLAnimHistoryItem
+{
+public:
+ LLAnimHistoryItem(LLUUID assetid);
+
+ LLUUID mAvatarID;
+ LLUUID mAssetID;
+ bool mPlaying;
+ F64 mTimeStarted;
+ F64 mTimeStopped;
+};
+
+class LLFloaterExploreAnimations
+: public LLFloater
+{
+public:
+ LLFloaterExploreAnimations(LLUUID avatarid);
+ BOOL postBuild(void);
+ void close(bool app_quitting);
+
+ void update();
+
+ LLUUID mAvatarID;
+ LLPreviewAnimation* mAnimPreview;
+
+private:
+ virtual ~LLFloaterExploreAnimations();
+
+
+// static stuff!
+public:
+ static void onSelectAnimation(LLUICtrl* ctrl, void* user_data);
+ static void onClickCopyUUID(void* data);
+ static void onClickOpen(void* data);
+ static void onClickJellyRoll(void* data);
+
+ static void startAnim(LLUUID avatarid, LLUUID assetid);
+ static void stopAnim(LLUUID avatarid, LLUUID assetid);
+
+ static std::map> animHistory;
+ static LLFloaterExploreAnimations* sInstance;
+private:
+ static void handleHistoryChange();
+
+protected:
+ void draw();
+};
+
+#endif
+//
diff --git a/indra/newview/llimportobject.cpp b/indra/newview/llimportobject.cpp
index 224898e89..d25654e67 100644
--- a/indra/newview/llimportobject.cpp
+++ b/indra/newview/llimportobject.cpp
@@ -1,1133 +1,1133 @@
-//
-/**
- * @file llimportobject.cpp
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llimportobject.h"
-#include "llsdserialize.h"
-#include "llsdutil.h"
-#include "llviewerobject.h"
-#include "llagent.h"
-#include "llchat.h"
-#include "llfloaterchat.h"
-#include "llfloater.h"
-#include "lllineeditor.h"
-#include "llinventorymodel.h"
-#include "lluictrlfactory.h"
-#include "llscrolllistctrl.h"
-
-
-// static vars
-bool LLXmlImport::sImportInProgress = false;
-bool LLXmlImport::sImportHasAttachments = false;
-LLUUID LLXmlImport::sFolderID;
-LLViewerObject* LLXmlImport::sSupplyParams;
-int LLXmlImport::sPrimsNeeded;
-std::vector LLXmlImport::sPrims;
-std::map LLXmlImport::sId2attachpt;
-std::map LLXmlImport::sPt2watch;
-std::map LLXmlImport::sPt2attachpos;
-std::map LLXmlImport::sPt2attachrot;
-int LLXmlImport::sPrimIndex = 0;
-int LLXmlImport::sAttachmentsDone = 0;
-std::map LLXmlImport::sId2localid;
-std::map LLXmlImport::sRootpositions;
-LLXmlImportOptions* LLXmlImport::sXmlImportOptions;
-
-LLFloaterImportProgress* LLFloaterImportProgress::sInstance;
-
-LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options)
-{
- mName = options->mName;
- mRootObjects = options->mRootObjects;
- mChildObjects = options->mChildObjects;
- mWearables = options->mWearables;
- mSupplier = options->mSupplier;
- mKeepPosition = options->mKeepPosition;
-}
-LLXmlImportOptions::LLXmlImportOptions(std::string filename)
-: mSupplier(NULL),
- mKeepPosition(FALSE)
-{
- mName = gDirUtilp->getBaseFileName(filename, true);
- llifstream in(filename);
- if(!in.is_open())
- {
- llwarns << "Couldn't open file..." << llendl;
- return;
- }
- LLSD llsd;
- if(LLSDSerialize::fromXML(llsd, in) < 1)
- {
- llwarns << "Messed up data?" << llendl;
- return;
- }
- init(llsd);
-}
-LLXmlImportOptions::LLXmlImportOptions(LLSD llsd)
-: mName("stuff"),
- mSupplier(NULL),
- mKeepPosition(FALSE)
-{
- init(llsd);
-}
-void LLXmlImportOptions::init(LLSD llsd)
-{
- mRootObjects.clear();
- mChildObjects.clear();
- mWearables.clear();
- // Separate objects and wearables
- std::vector unsorted_objects;
- LLSD::map_iterator map_end = llsd.endMap();
- for(LLSD::map_iterator map_iter = llsd.beginMap() ; map_iter != map_end; ++map_iter)
- {
- std::string key((*map_iter).first);
- LLSD item = (*map_iter).second;
- if(item.has("type"))
- {
- if(item["type"].asString() == "wearable")
- mWearables.push_back(new LLImportWearable(item));
- else
- unsorted_objects.push_back(new LLImportObject(key, item));
- }
- else // assumed to be a prim
- unsorted_objects.push_back(new LLImportObject(key, item));
- }
- // Separate roots from children
- int total_objects = (int)unsorted_objects.size();
- for(int i = 0; i < total_objects; i++)
- {
- if(unsorted_objects[i]->mParentId == "")
- mRootObjects.push_back(unsorted_objects[i]);
- else
- mChildObjects.push_back(unsorted_objects[i]);
- }
-}
-
-LLFloaterXmlImportOptions::LLFloaterXmlImportOptions(LLXmlImportOptions* default_options)
-: mDefaultOptions(default_options)
-{
- LLUICtrlFactory::getInstance()->buildFloater(this, "floater_import_options.xml");
-}
-BOOL LLFloaterXmlImportOptions::postBuild()
-{
- center();
- LLScrollListCtrl* list = getChild("import_list");
- // Add all wearables to list and keep an id:ptr map
- std::vector::iterator wearable_end = mDefaultOptions->mWearables.end();
- for(std::vector::iterator iter = mDefaultOptions->mWearables.begin();
- iter != wearable_end; ++iter)
- {
- LLImportWearable* wearablep = (*iter);
- LLUUID id; id.generate();
- mImportWearableMap[id] = wearablep;
- LLSD element;
- element["id"] = id;
- LLSD& check_column = element["columns"][LIST_CHECKED];
- check_column["column"] = "checked";
- check_column["type"] = "checkbox";
- check_column["value"] = true;
- LLSD& type_column = element["columns"][LIST_TYPE];
- type_column["column"] = "type";
- type_column["type"] = "icon";
- type_column["value"] = "inv_item_" + LLWearable::typeToTypeName((EWearableType)(wearablep->mType)) + ".tga";
- LLSD& name_column = element["columns"][LIST_NAME];
- name_column["column"] = "name";
- name_column["value"] = wearablep->mName;
- list->addElement(element, ADD_BOTTOM);
- }
- // Add all root objects to list and keep an id:ptr map
- std::vector::iterator object_end = mDefaultOptions->mRootObjects.end();
- for(std::vector::iterator iter = mDefaultOptions->mRootObjects.begin();
- iter != object_end; ++iter)
- {
- LLImportObject* objectp = (*iter);
- LLUUID id; id.generate();
- mImportObjectMap[id] = objectp;
- LLSD element;
- element["id"] = id;
- LLSD& check_column = element["columns"][LIST_CHECKED];
- check_column["column"] = "checked";
- check_column["type"] = "checkbox";
- check_column["value"] = true;
- LLSD& type_column = element["columns"][LIST_TYPE];
- type_column["column"] = "type";
- type_column["type"] = "icon";
- type_column["value"] = "inv_item_object.tga";
- LLSD& name_column = element["columns"][LIST_NAME];
- name_column["column"] = "name";
- name_column["value"] = objectp->mPrimName;
- list->addElement(element, ADD_BOTTOM);
- }
- // Callbacks
- childSetAction("select_all_btn", onClickSelectAll, this);
- childSetAction("select_objects_btn", onClickSelectObjects, this);
- childSetAction("select_wearables_btn", onClickSelectWearables, this);
- childSetAction("ok_btn", onClickOK, this);
- childSetAction("cancel_btn", onClickCancel, this);
- return TRUE;
-}
-void LLFloaterXmlImportOptions::onClickSelectAll(void* user_data)
-{
- LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
- LLScrollListCtrl* list = floaterp->getChild("import_list");
- std::vector items = list->getAllData();
- std::vector::iterator item_iter = items.begin();
- std::vector::iterator items_end = items.end();
- bool new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
- for( ; item_iter != items_end; ++item_iter)
- {
- (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
- }
-}
-void LLFloaterXmlImportOptions::onClickSelectObjects(void* user_data)
-{
- LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
- LLScrollListCtrl* list = floaterp->getChild("import_list");
- std::vector items = list->getAllData();
- std::vector::iterator item_iter = items.begin();
- std::vector::iterator items_end = items.end();
- bool new_value = false;
- for( ; item_iter != items_end; ++item_iter)
- {
- if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() == "inv_item_object.tga")
- {
- new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
- break;
- }
- }
- for(item_iter = items.begin(); item_iter != items_end; ++item_iter)
- {
- if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() == "inv_item_object.tga")
- (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
- }
-}
-void LLFloaterXmlImportOptions::onClickSelectWearables(void* user_data)
-{
- LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
- LLScrollListCtrl* list = floaterp->getChild("import_list");
- std::vector items = list->getAllData();
- std::vector::iterator item_iter = items.begin();
- std::vector::iterator items_end = items.end();
- bool new_value = false;
- for( ; item_iter != items_end; ++item_iter)
- {
- if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() != "inv_item_object.tga")
- {
- new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
- break;
- }
- }
- for(item_iter = items.begin(); item_iter != items_end; ++item_iter)
- {
- if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() != "inv_item_object.tga")
- (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
- }
-}
-void LLFloaterXmlImportOptions::onClickOK(void* user_data)
-{
- LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
- LLXmlImportOptions* opt = new LLXmlImportOptions(floaterp->mDefaultOptions);
- opt->mRootObjects.clear();
- opt->mChildObjects.clear();
- opt->mWearables.clear();
- LLScrollListCtrl* list = floaterp->getChild("import_list");
- std::vector items = list->getAllData();
- std::vector::iterator item_end = items.end();
- std::vector::iterator child_end = floaterp->mDefaultOptions->mChildObjects.end();
- for(std::vector::iterator iter = items.begin(); iter != item_end; ++iter)
- {
- if((*iter)->getColumn(LIST_CHECKED)->getValue())
- { // checked
- LLUUID id = (*iter)->getUUID();
- if(floaterp->mImportWearableMap.find(id) != floaterp->mImportWearableMap.end())
- {
- opt->mWearables.push_back(floaterp->mImportWearableMap[id]);
- }
- else // object
- {
- LLImportObject* objectp = floaterp->mImportObjectMap[id];
- opt->mRootObjects.push_back(objectp);
- // Add child objects
- for(std::vector::iterator child_iter = floaterp->mDefaultOptions->mChildObjects.begin();
- child_iter != child_end; ++child_iter)
- {
- if((*child_iter)->mParentId == objectp->mId)
- opt->mChildObjects.push_back((*child_iter));
- }
- }
- }
- }
- opt->mKeepPosition = floaterp->childGetValue("keep_position_check");
- LLXmlImport::import(opt);
- floaterp->close();
-}
-void LLFloaterXmlImportOptions::onClickCancel(void* user_data)
-{
- LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
- floaterp->close();
-}
-
-
-
-
-
-std::string terse_F32_string( F32 f )
-{
- std::string r = llformat( "%.2f", f );
- // "1.20" -> "1.2"
- // "24.00" -> "24."
- S32 len = r.length();
- while( len > 0 && '0' == r[len - 1] )
- {
- r.erase(len-1, 1);
- len--;
- }
- if( '.' == r[len - 1] )
- {
- // "24." -> "24"
- r.erase(len-1, 1);
- }
- else if( ('-' == r[0]) && ('0' == r[1]) )
- {
- // "-0.59" -> "-.59"
- r.erase(1, 1);
- }
- else if( '0' == r[0] )
- {
- // "0.59" -> ".59"
- r.erase(0, 1);
- }
- return r;
-}
-LLImportWearable::LLImportWearable(LLSD sd)
-{
- mName = sd["name"].asString();
- mType = sd["wearabletype"].asInteger();
-
- LLSD params = sd["params"];
- LLSD textures = sd["textures"];
-
- mData = "LLWearable version 22\n" +
- mName + "\n\n" +
- "\tpermissions 0\n" +
- "\t{\n" +
- "\t\tbase_mask\t7fffffff\n" +
- "\t\towner_mask\t7fffffff\n" +
- "\t\tgroup_mask\t00000000\n" +
- "\t\teveryone_mask\t00000000\n" +
- "\t\tnext_owner_mask\t00082000\n" +
- "\t\tcreator_id\t00000000-0000-0000-0000-000000000000\n" +
- "\t\towner_id\t" + gAgent.getID().asString() + "\n" +
- "\t\tlast_owner_id\t" + gAgent.getID().asString() + "\n" +
- "\t\tgroup_id\t00000000-0000-0000-0000-000000000000\n" +
- "\t}\n" +
- "\tsale_info\t0\n" +
- "\t{\n" +
- "\t\tsale_type\tnot\n" +
- "\t\tsale_price\t10\n" +
- "\t}\n" +
- "type " + llformat("%d", mType) + "\n";
-
- mData += llformat("parameters %d\n", params.size());
- LLSD::map_iterator map_iter = params.beginMap();
- LLSD::map_iterator map_end = params.endMap();
- for( ; map_iter != map_end; ++map_iter)
- {
- mData += (*map_iter).first + " " + terse_F32_string((*map_iter).second.asReal()) + "\n";
- }
-
- mData += llformat("textures %d\n", textures.size());
- map_iter = textures.beginMap();
- map_end = textures.endMap();
- for( ; map_iter != map_end; ++map_iter)
- {
- mData += (*map_iter).first + " " + (*map_iter).second.asString() + "\n";
- }
-}
-
-//LLImportObject::LLImportObject(std::string id, std::string parentId)
-// : LLViewerObject(LLUUID::null, 9, NULL, TRUE),
-// mId(id),
-// mParentId(parentId),
-// mPrimName("Object")
-//{
-// importIsAttachment = false;
-//}
-LLImportObject::LLImportObject(std::string id, LLSD prim)
- : LLViewerObject(LLUUID::null, 9, NULL, TRUE)
-{
- importIsAttachment = false;
- mId = id;
- mParentId = "";
- mPrimName = "Object";
- if(prim.has("parent"))
- {
- mParentId = prim["parent"].asString();
- }
- // Stuff for attach
- if(prim.has("attach"))
- {
- importIsAttachment = true;
- importAttachPoint = (U8)prim["attach"].asInteger();
- importAttachPos = ll_vector3_from_sd(prim["position"]);
- importAttachRot = ll_quaternion_from_sd(prim["rotation"]);
- }
- // Transforms
- setPosition(ll_vector3_from_sd(prim["position"]), FALSE);
- setScale(ll_vector3_from_sd(prim["scale"]), FALSE);
- setRotation(ll_quaternion_from_sd(prim["rotation"]), FALSE);
- // Flags
- setFlags(FLAGS_CAST_SHADOWS, prim["shadows"].asInteger());
- setFlags(FLAGS_PHANTOM, prim["phantom"].asInteger());
- setFlags(FLAGS_USE_PHYSICS, prim["physical"].asInteger());
- // Volume params
- LLVolumeParams volume_params;
- volume_params.fromLLSD(prim["volume"]);
- setVolume(volume_params, 0, false);
- // Extra params
- if(prim.has("flexible"))
- {
- LLFlexibleObjectData* wat = new LLFlexibleObjectData();
- wat->fromLLSD(prim["flex"]);
- LLFlexibleObjectData flex = *wat;
- setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
- setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true);
- }
- if(prim.has("light"))
- {
- LLLightParams* wat = new LLLightParams();
- wat->fromLLSD(prim["light"]);
- LLLightParams light = *wat;
- setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
- setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true);
- }
- if(prim.has("sculpt"))
- {
- LLSculptParams *wat = new LLSculptParams();
- wat->fromLLSD(prim["sculpt"]);
- LLSculptParams sculpt = *wat;
- setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
- setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true);
- }
- // Textures
- LLSD textures = prim["textures"];
- LLSD::array_iterator array_iter = textures.beginArray();
- LLSD::array_iterator array_end = textures.endArray();
- int i = 0;
- for( ; array_iter != array_end; ++array_iter)
- {
- LLTextureEntry* wat = new LLTextureEntry();
- wat->fromLLSD(*array_iter);
- LLTextureEntry te = *wat;
- setTE(i, te);
- i++;
- }
- if(prim.has("name"))
- {
- mPrimName = prim["name"].asString();
- }
-}
-
-
-
-BuildingSupply::BuildingSupply() : LLEventTimer(0.1f)
-{
-}
-
-BOOL BuildingSupply::tick()
-{
- if(LLXmlImport::sImportInProgress && (LLXmlImport::sPrimsNeeded > 0))
- {
- LLXmlImport::sPrimsNeeded--;
- // Need moar prims
- if(LLXmlImport::sXmlImportOptions->mSupplier == NULL)
- {
- gMessageSystem->newMessageFast(_PREHASH_ObjectAdd);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU8Fast(_PREHASH_PCode, 9);
- gMessageSystem->addU8Fast(_PREHASH_Material, LL_MCODE_WOOD);
- gMessageSystem->addU32Fast(_PREHASH_AddFlags, 0);
- gMessageSystem->addU8Fast(_PREHASH_PathCurve, 16);
- gMessageSystem->addU8Fast(_PREHASH_ProfileCurve, 1);
- gMessageSystem->addU16Fast(_PREHASH_PathBegin, 0);
- gMessageSystem->addU16Fast(_PREHASH_PathEnd, 0);
- gMessageSystem->addU8Fast(_PREHASH_PathScaleX, 100);
- gMessageSystem->addU8Fast(_PREHASH_PathScaleY, 100);
- gMessageSystem->addU8Fast(_PREHASH_PathShearX, 0);
- gMessageSystem->addU8Fast(_PREHASH_PathShearY, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathTwist, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathTwistBegin, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathRadiusOffset, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathTaperX, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathTaperY, 0);
- gMessageSystem->addU8Fast(_PREHASH_PathRevolutions, 0);
- gMessageSystem->addS8Fast(_PREHASH_PathSkew, 0);
- gMessageSystem->addU16Fast(_PREHASH_ProfileBegin, 0);
- gMessageSystem->addU16Fast(_PREHASH_ProfileEnd, 0);
- gMessageSystem->addU16Fast(_PREHASH_ProfileHollow, 0);
- gMessageSystem->addU8Fast(_PREHASH_BypassRaycast, 1);
- LLVector3 rezpos = gAgent.getPositionAgent() + LLVector3(0.0f, 0.0f, 2.0f);
- gMessageSystem->addVector3Fast(_PREHASH_RayStart, rezpos);
- gMessageSystem->addVector3Fast(_PREHASH_RayEnd, rezpos);
- gMessageSystem->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null);
- gMessageSystem->addU8Fast(_PREHASH_RayEndIsIntersection, 0);
- gMessageSystem->addVector3Fast(_PREHASH_Scale, LLXmlImport::sSupplyParams->getScale());
- gMessageSystem->addQuatFast(_PREHASH_Rotation, LLQuaternion::DEFAULT);
- gMessageSystem->addU8Fast(_PREHASH_State, 0);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
- else // have supplier
- {
- try
- {
- gMessageSystem->newMessageFast(_PREHASH_ObjectDuplicate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
- gMessageSystem->nextBlockFast(_PREHASH_SharedData);
- LLVector3 rezpos = gAgent.getPositionAgent() + LLVector3(0.0f, 0.0f, 2.0f);
- rezpos -= LLXmlImport::sSupplyParams->getPositionRegion();
- gMessageSystem->addVector3Fast(_PREHASH_Offset, rezpos);
- gMessageSystem->addU32Fast(_PREHASH_DuplicateFlags, 0);
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, LLXmlImport::sXmlImportOptions->mSupplier->getLocalID());
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
- catch(int)
- {
- llwarns << "Abort! Abort!" << llendl;
- return TRUE;
- }
- }
- LLFloaterImportProgress::update();
- return FALSE;
- }
- return TRUE;
-}
-
-
-// static
-void LLXmlImport::import(LLXmlImportOptions* import_options)
-{
- sXmlImportOptions = import_options;
- if(sXmlImportOptions->mSupplier == NULL)
- {
- LLViewerObject* cube = new LLViewerObject(LLUUID::null, 9, NULL, TRUE);
- cube->setScale(LLVector3(.31337f, .31337f, .31337f), FALSE);
- sSupplyParams = cube;
- }
- else sSupplyParams = sXmlImportOptions->mSupplier;
-
- if(!(sXmlImportOptions->mKeepPosition) && sXmlImportOptions->mRootObjects.size())
- { // Reposition all roots so that the first root is somewhere near the avatar
- // Find the root closest to the ground
- int num_roots = (int)sXmlImportOptions->mRootObjects.size();
- int lowest_root = 0;
- F32 lowest_z(65536.f);
- for(int i = 0; i < num_roots; i++)
- {
- F32 z = sXmlImportOptions->mRootObjects[i]->getPosition().mV[2];
- if(z < lowest_z)
- {
- lowest_root = i;
- lowest_z = z;
- }
- }
- // Move all roots
- LLVector3 old_pos = sXmlImportOptions->mRootObjects[lowest_root]->getPosition();
- LLVector3 new_pos = gAgent.getPositionAgent() + (gAgent.getAtAxis() * 2.0f);
- LLVector3 difference = new_pos - old_pos;
- for(int i = 0; i < num_roots; i++)
- {
- sXmlImportOptions->mRootObjects[i]->setPosition(sXmlImportOptions->mRootObjects[i]->getPosition() + difference, FALSE);
- }
- }
-
- // Make the actual importable list
- sPrims.clear();
- // Clear these attachment-related maps
- sPt2watch.clear();
- sId2attachpt.clear();
- sPt2attachpos.clear();
- sPt2attachrot.clear();
- // Go ahead and add roots first
- std::vector::iterator root_iter = sXmlImportOptions->mRootObjects.begin();
- std::vector::iterator root_end = sXmlImportOptions->mRootObjects.end();
- for( ; root_iter != root_end; ++root_iter)
- {
- sPrims.push_back(*root_iter);
- // Remember some attachment info
- if((*root_iter)->importIsAttachment)
- {
- sId2attachpt[(*root_iter)->mId] = (*root_iter)->importAttachPoint;
- sPt2watch[(*root_iter)->importAttachPoint] = true;
- sPt2attachpos[(*root_iter)->importAttachPoint] = (*root_iter)->importAttachPos;
- sPt2attachrot[(*root_iter)->importAttachPoint] = (*root_iter)->importAttachRot;
- }
- }
- // Then add children, nearest first
- std::vector children(sXmlImportOptions->mChildObjects);
- for(root_iter = sXmlImportOptions->mRootObjects.begin() ; root_iter != root_end; ++root_iter)
- {
- while(children.size() > 0)
- {
- std::string rootid = (*root_iter)->mId;
- F32 lowest_mag = 65536.0f;
- std::vector::iterator lowest_child_iter = children.begin();
- LLImportObject* lowest_child = (*lowest_child_iter);
-
- std::vector::iterator child_end = children.end();
- for(std::vector::iterator child_iter = children.begin() ; child_iter != child_end; ++child_iter)
- {
- if((*child_iter)->mParentId == rootid)
- {
- F32 mag = (*child_iter)->getPosition().magVec();
- if(mag < lowest_mag)
- {
- lowest_child_iter = child_iter;
- lowest_child = (*lowest_child_iter);
- lowest_mag = mag;
- }
- }
- }
- sPrims.push_back(lowest_child);
- children.erase(lowest_child_iter);
- }
- }
-
- sImportInProgress = true;
- sImportHasAttachments = (sId2attachpt.size() > 0);
- sPrimsNeeded = (int)sPrims.size();
- sPrimIndex = 0;
- sId2localid.clear();
- sRootpositions.clear();
-
- LLFloaterImportProgress::show();
- LLFloaterImportProgress::update();
-
- // Create folder
- if((sXmlImportOptions->mWearables.size() > 0) || (sId2attachpt.size() > 0))
- {
- sFolderID = gInventory.createNewCategory( gAgent.getInventoryRootID(), LLAssetType::AT_NONE, sXmlImportOptions->mName);
- }
-
- // Go ahead and upload wearables
- int num_wearables = sXmlImportOptions->mWearables.size();
- for(int i = 0; i < num_wearables; i++)
- {
- LLAssetType::EType at = LLAssetType::AT_CLOTHING;
- if(sXmlImportOptions->mWearables[i]->mType < 4) at = LLAssetType::AT_BODYPART;
- LLUUID tid;
- tid.generate();
- // Create asset
- gMessageSystem->newMessageFast(_PREHASH_AssetUploadRequest);
- gMessageSystem->nextBlockFast(_PREHASH_AssetBlock);
- gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
- gMessageSystem->addS8Fast(_PREHASH_Type, (S8)at);
- gMessageSystem->addBOOLFast(_PREHASH_Tempfile, FALSE);
- gMessageSystem->addBOOLFast(_PREHASH_StoreLocal, FALSE);
- gMessageSystem->addStringFast(_PREHASH_AssetData, sXmlImportOptions->mWearables[i]->mData.c_str());
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- // Create item
- gMessageSystem->newMessageFast(_PREHASH_CreateInventoryItem);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_InventoryBlock);
- gMessageSystem->addU32Fast(_PREHASH_CallbackID, 0);
- gMessageSystem->addUUIDFast(_PREHASH_FolderID, sFolderID);
- gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
- gMessageSystem->addU32Fast(_PREHASH_NextOwnerMask, 532480);
- gMessageSystem->addS8Fast(_PREHASH_Type, at);
- gMessageSystem->addS8Fast(_PREHASH_InvType, 18);
- gMessageSystem->addS8Fast(_PREHASH_WearableType, sXmlImportOptions->mWearables[i]->mType);
- gMessageSystem->addStringFast(_PREHASH_Name, sXmlImportOptions->mWearables[i]->mName.c_str());
- gMessageSystem->addStringFast(_PREHASH_Description, "");
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
-
- new BuildingSupply();
-}
-
-// static
-void LLXmlImport::onNewPrim(LLViewerObject* object)
-{
- if(sPrimIndex >= (int)sPrims.size())
- {
- if(sAttachmentsDone >= (int)sPt2attachpos.size())
- {
- // "stop calling me"
- sImportInProgress = false;
- return;
- }
- }
-
- LLImportObject* from = sPrims[sPrimIndex];
-
- // Flags
- // trying this first in case it helps when supply is physical...
- U32 flags = from->mFlags;
- flags = flags & (~FLAGS_USE_PHYSICS);
- object->setFlags(flags, TRUE);
- object->setFlags(~flags, FALSE); // Can I improve this lol?
-
- if(from->mParentId == "")
- {
- // this will be a root
- sId2localid[from->mId] = object->getLocalID();
- sRootpositions[object->getLocalID()] = from->getPosition();
- // If it's an attachment, set description
- if(from->importIsAttachment)
- {
- gMessageSystem->newMessageFast(_PREHASH_ObjectDescription);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
- gMessageSystem->addStringFast(_PREHASH_Description, from->mId);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
- }
- else
- {
- // Move it to its root before linking
- U32 parentlocalid = sId2localid[from->mParentId];
- LLVector3 rootpos = sRootpositions[parentlocalid];
-
- U8 data[256];
- S32 offset = 0;
- gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->addU8Fast(_PREHASH_Type, 5);
- htonmemcpy(&data[offset], &(rootpos.mV), MVT_LLVector3, 12);
- offset += 12;
- htonmemcpy(&data[offset], &(from->getScale().mV), MVT_LLVector3, 12);
- offset += 12;
- gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- // Link it up
- gMessageSystem->newMessageFast(_PREHASH_ObjectLink);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, sId2localid[from->mParentId]);
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
- // Volume params
- LLVolumeParams params = from->getVolume()->getParams();
- object->setVolume(params, 0, false);
- // Extra params
- if(from->isFlexible())
- {
- LLFlexibleObjectData* wat = (LLFlexibleObjectData*)from->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
- LLFlexibleObjectData flex = *wat;
- object->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
- object->setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true);
- object->parameterChanged(LLNetworkData::PARAMS_FLEXIBLE, true);
- }
- else
- {
- // send param not in use in case the supply prim has it
- object->setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, FALSE, true);
- object->parameterChanged(LLNetworkData::PARAMS_FLEXIBLE, true);
- }
- if (from->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT))
- {
- LLLightParams* wat = (LLLightParams*)from->getParameterEntry(LLNetworkData::PARAMS_LIGHT);
- LLLightParams light = *wat;
- object->setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
- object->setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true);
- object->parameterChanged(LLNetworkData::PARAMS_LIGHT, true);
- }
- else
- {
- // send param not in use in case the supply prim has it
- object->setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, FALSE, true);
- object->parameterChanged(LLNetworkData::PARAMS_LIGHT, true);
- }
- if (from->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT))
- {
- LLSculptParams* wat = (LLSculptParams*)from->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
- LLSculptParams sculpt = *wat;
- object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
- object->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true);
- object->parameterChanged(LLNetworkData::PARAMS_SCULPT, true);
- }
- else
- {
- // send param not in use in case the supply prim has it
- object->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, FALSE, true);
- object->parameterChanged(LLNetworkData::PARAMS_SCULPT, true);
- }
- // Textures
- U8 te_count = from->getNumTEs();
- for (U8 i = 0; i < te_count; i++)
- {
- const LLTextureEntry* wat = from->getTE(i);
- LLTextureEntry te = *wat;
- object->setTE(i, te);
- }
-
- object->sendShapeUpdate();
- object->sendTEUpdate();
- // Flag update is already coming from somewhere
- //object->updateFlags();
-
- // Transforms
- object->setScale(from->getScale(), FALSE);
- object->setRotation(from->getRotation(), FALSE);
- object->setPosition(from->getPosition(), FALSE);
-
- U8 data[256];
- S32 offset = 0;
- // Position and rotation
- gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->addU8Fast(_PREHASH_Type, 3);
- htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
- offset += 12;
- LLQuaternion quat = object->getRotation();
- LLVector3 vec = quat.packToVector3();
- htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
- offset += 12;
- gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- // Position and scale
- offset = 0;
- gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->addU8Fast(_PREHASH_Type, 5);
- htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
- offset += 12;
- htonmemcpy(&data[offset], &(object->getScale().mV), MVT_LLVector3, 12);
- offset += 12;
- gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- // Test - Position, rotation, and scale, didn't work properly
- /*
- gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->addU8Fast(_PREHASH_Type, 7);
- htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
- offset += 12;
- LLQuaternion quat = object->getRotation();
- LLVector3 vec = quat.packToVector3();
- htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
- offset += 12;
- htonmemcpy(&data[offset], &(object->getScale().mV), MVT_LLVector3, 12);
- offset += 12;
- gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- // end test
- */
-
- // Name
- if(from->mPrimName != "")
- {
- gMessageSystem->newMessageFast(_PREHASH_ObjectName);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
- gMessageSystem->addStringFast(_PREHASH_Name, from->mPrimName);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
-
- sPrimIndex++;
- if(sPrimIndex >= (int)sPrims.size())
- {
- if(sId2attachpt.size() == 0)
- {
- sImportInProgress = false;
- std::string msg = "Imported " + sXmlImportOptions->mName;
- LLChat chat(msg);
- LLFloaterChat::addChat(chat);
- LLFloaterImportProgress::update();
- return;
- }
- else
- {
- // Take attachables into inventory
- std::string msg = "Wait a few moments for the attachments to attach...";
- LLChat chat(msg);
- LLFloaterChat::addChat(chat);
-
- sAttachmentsDone = 0;
- std::map::iterator at_iter = sId2attachpt.begin();
- std::map::iterator at_end = sId2attachpt.end();
- for( ; at_iter != at_end; ++at_iter)
- {
- LLUUID tid;
- tid.generate();
- U32 at_localid = sId2localid[(*at_iter).first];
- gMessageSystem->newMessageFast(_PREHASH_DeRezObject);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_AgentBlock);
- gMessageSystem->addUUIDFast(_PREHASH_GroupID, LLUUID::null);
- gMessageSystem->addU8Fast(_PREHASH_Destination, DRD_TAKE_INTO_AGENT_INVENTORY);
- gMessageSystem->addUUIDFast(_PREHASH_DestinationID, sFolderID);
- gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
- gMessageSystem->addU8Fast(_PREHASH_PacketCount, 1);
- gMessageSystem->addU8Fast(_PREHASH_PacketNumber, 0);
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, at_localid);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
- }
- }
- LLFloaterImportProgress::update();
-}
-
-// static
-void LLXmlImport::onNewItem(LLViewerInventoryItem* item)
-{
- U8 attachpt = sId2attachpt[item->getDescription()];
- if(attachpt)
- {
- // clear description, part 1
- item->setDescription(std::string("(No Description)"));
- item->updateServer(FALSE);
-
- // Attach it
- gMessageSystem->newMessageFast(_PREHASH_RezSingleAttachmentFromInv);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addUUIDFast(_PREHASH_ItemID, item->getUUID());
- gMessageSystem->addUUIDFast(_PREHASH_OwnerID, gAgent.getID());
- gMessageSystem->addU8Fast(_PREHASH_AttachmentPt, attachpt);
- gMessageSystem->addU32Fast(_PREHASH_ItemFlags, 0);
- gMessageSystem->addU32Fast(_PREHASH_GroupMask, 0);
- gMessageSystem->addU32Fast(_PREHASH_EveryoneMask, 0);
- gMessageSystem->addU32Fast(_PREHASH_NextOwnerMask, 0);
- gMessageSystem->addStringFast(_PREHASH_Name, item->getName());
- gMessageSystem->addStringFast(_PREHASH_Description, "");
- gMessageSystem->sendReliable(gAgent.getRegionHost());
- }
-}
-
-// static
-void LLXmlImport::onNewAttachment(LLViewerObject* object)
-{
- if(sPt2attachpos.size() == 0) return;
-
- U8 attachpt = (U8)object->getAttachmentPoint();
- if(sPt2watch[attachpt])
- {
- // clear description, part 2
- gMessageSystem->newMessageFast(_PREHASH_ObjectDescription);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
- gMessageSystem->addStringFast(_PREHASH_Description, "");
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- // position and rotation
- LLVector3 pos = sPt2attachpos[attachpt];
- U8 data[256];
- S32 offset = 0;
- gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->addU8Fast(_PREHASH_Type, 11); // link set this time
- htonmemcpy(&data[offset], &(pos.mV), MVT_LLVector3, 12);
- offset += 12;
- LLQuaternion quat = sPt2attachrot[attachpt];
- LLVector3 vec = quat.packToVector3();
- htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
- offset += 12;
- gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- // Select and deselect to make it send an update
- gMessageSystem->newMessageFast(_PREHASH_ObjectSelect);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- gMessageSystem->newMessageFast(_PREHASH_ObjectDeselect);
- gMessageSystem->nextBlockFast(_PREHASH_AgentData);
- gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
- gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
- gMessageSystem->sendReliable(gAgent.getRegionHost());
-
- // Done?
- sAttachmentsDone++;
- if(sAttachmentsDone >= (int)sPt2attachpos.size())
- {
- sImportInProgress = false;
- std::string msg = "Imported " + sXmlImportOptions->mName;
- LLChat chat(msg);
- LLFloaterChat::addChat(chat);
- LLFloaterImportProgress::update();
- return;
- }
- }
-}
-
-
-
-// static
-void LLXmlImport::Cancel(void* user_data)
-{
- sImportInProgress = false;
- LLFloaterImportProgress::sInstance->close(false);
-}
-
-
-
-LLFloaterImportProgress::LLFloaterImportProgress()
-: LLFloater("ImportProgress", LLRect(0, 100, 400, 0), "Import progress")
-{
- LLLineEditor* line = new LLLineEditor(
- std::string("Created"),
- LLRect(4, 80, 396, 60),
- std::string("Created prims"));
- line->setEnabled(FALSE);
- addChild(line);
-
- LLViewBorder* border = new LLViewBorder(
- "CreatedBorder",
- LLRect(4, 79, 395, 60));
- addChild(border);
-
- line = new LLLineEditor(
- std::string("Edited"),
- LLRect(4, 55, 396, 35),
- std::string("Edited prims"));
- line->setEnabled(FALSE);
- addChild(line);
-
- border = new LLViewBorder(
- "EditedBorder",
- LLRect(4, 54, 395, 35));
- addChild(border);
-
- LLButton* button = new LLButton(
- "CancelButton",
- LLRect(300, 28, 394, 8));
- button->setLabel(std::string("Cancel"));
- button->setEnabled(TRUE);
- addChild(button);
- childSetAction("CancelButton", LLXmlImport::Cancel, this);
-
- sInstance = this;
-}
-
-LLFloaterImportProgress::~LLFloaterImportProgress()
-{
- sInstance = NULL;
-}
-
-void LLFloaterImportProgress::close(bool app_quitting)
-{
- LLXmlImport::sImportInProgress = false;
- LLFloater::close(app_quitting);
-}
-
-// static
-void LLFloaterImportProgress::show()
-{
- if(!sInstance)
- sInstance = new LLFloaterImportProgress();
- sInstance->open();
- sInstance->center();
-}
-
-// static
-void LLFloaterImportProgress::update()
-{
- if(sInstance)
- {
- LLFloaterImportProgress* floater = sInstance;
-
- int create_goal = (int)LLXmlImport::sPrims.size();
- int create_done = create_goal - LLXmlImport::sPrimsNeeded;
- F32 create_width = F32(390.f / F32(create_goal));
- create_width *= F32(create_done);
- bool create_finished = create_done >= create_goal;
-
- int edit_goal = create_goal;
- int edit_done = LLXmlImport::sPrimIndex;
- F32 edit_width = F32(390.f / F32(edit_goal));
- edit_width *= edit_done;
- bool edit_finished = edit_done >= edit_goal;
-
- int attach_goal = (int)LLXmlImport::sId2attachpt.size();
- int attach_done = LLXmlImport::sAttachmentsDone;
- F32 attach_width = F32(390.f / F32(attach_goal));
- attach_width *= F32(attach_done);
- bool attach_finished = attach_done >= attach_goal;
-
- bool all_finished = create_finished && edit_finished && attach_finished;
-
- std::string title;
- title.assign(all_finished ? "Imported " : "Importing ");
- title.append(LLXmlImport::sXmlImportOptions->mName);
- if(!all_finished) title.append("...");
- floater->setTitle(title);
-
- std::string created_text = llformat("Created %d/%d prims", S32(create_done), S32(create_goal));
- std::string edited_text = llformat("Finished %d/%d prims", edit_done, edit_goal);
-
- LLLineEditor* text = floater->getChild("Created");
- text->setText(created_text);
-
- text = floater->getChild("Edited");
- text->setText(edited_text);
-
- LLViewBorder* border = floater->getChild("CreatedBorder");
- border->setRect(LLRect(4, 79, 4 + create_width, 60));
-
- border = floater->getChild("EditedBorder");
- border->setRect(LLRect(4, 54, 4 + edit_width, 35));
-
- LLButton* button = floater->getChild("CancelButton");
- button->setEnabled(!all_finished);
- }
-}
-
-//
+//
+/**
+ * @file llimportobject.cpp
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llimportobject.h"
+#include "llsdserialize.h"
+#include "llsdutil.h"
+#include "llviewerobject.h"
+#include "llagent.h"
+#include "llchat.h"
+#include "llfloaterchat.h"
+#include "llfloater.h"
+#include "lllineeditor.h"
+#include "llinventorymodel.h"
+#include "lluictrlfactory.h"
+#include "llscrolllistctrl.h"
+
+
+// static vars
+bool LLXmlImport::sImportInProgress = false;
+bool LLXmlImport::sImportHasAttachments = false;
+LLUUID LLXmlImport::sFolderID;
+LLViewerObject* LLXmlImport::sSupplyParams;
+int LLXmlImport::sPrimsNeeded;
+std::vector LLXmlImport::sPrims;
+std::map LLXmlImport::sId2attachpt;
+std::map LLXmlImport::sPt2watch;
+std::map LLXmlImport::sPt2attachpos;
+std::map LLXmlImport::sPt2attachrot;
+int LLXmlImport::sPrimIndex = 0;
+int LLXmlImport::sAttachmentsDone = 0;
+std::map LLXmlImport::sId2localid;
+std::map LLXmlImport::sRootpositions;
+LLXmlImportOptions* LLXmlImport::sXmlImportOptions;
+
+LLFloaterImportProgress* LLFloaterImportProgress::sInstance;
+
+LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options)
+{
+ mName = options->mName;
+ mRootObjects = options->mRootObjects;
+ mChildObjects = options->mChildObjects;
+ mWearables = options->mWearables;
+ mSupplier = options->mSupplier;
+ mKeepPosition = options->mKeepPosition;
+}
+LLXmlImportOptions::LLXmlImportOptions(std::string filename)
+: mSupplier(NULL),
+ mKeepPosition(FALSE)
+{
+ mName = gDirUtilp->getBaseFileName(filename, true);
+ llifstream in(filename);
+ if(!in.is_open())
+ {
+ llwarns << "Couldn't open file..." << llendl;
+ return;
+ }
+ LLSD llsd;
+ if(LLSDSerialize::fromXML(llsd, in) < 1)
+ {
+ llwarns << "Messed up data?" << llendl;
+ return;
+ }
+ init(llsd);
+}
+LLXmlImportOptions::LLXmlImportOptions(LLSD llsd)
+: mName("stuff"),
+ mSupplier(NULL),
+ mKeepPosition(FALSE)
+{
+ init(llsd);
+}
+void LLXmlImportOptions::init(LLSD llsd)
+{
+ mRootObjects.clear();
+ mChildObjects.clear();
+ mWearables.clear();
+ // Separate objects and wearables
+ std::vector unsorted_objects;
+ LLSD::map_iterator map_end = llsd.endMap();
+ for(LLSD::map_iterator map_iter = llsd.beginMap() ; map_iter != map_end; ++map_iter)
+ {
+ std::string key((*map_iter).first);
+ LLSD item = (*map_iter).second;
+ if(item.has("type"))
+ {
+ if(item["type"].asString() == "wearable")
+ mWearables.push_back(new LLImportWearable(item));
+ else
+ unsorted_objects.push_back(new LLImportObject(key, item));
+ }
+ else // assumed to be a prim
+ unsorted_objects.push_back(new LLImportObject(key, item));
+ }
+ // Separate roots from children
+ int total_objects = (int)unsorted_objects.size();
+ for(int i = 0; i < total_objects; i++)
+ {
+ if(unsorted_objects[i]->mParentId == "")
+ mRootObjects.push_back(unsorted_objects[i]);
+ else
+ mChildObjects.push_back(unsorted_objects[i]);
+ }
+}
+
+LLFloaterXmlImportOptions::LLFloaterXmlImportOptions(LLXmlImportOptions* default_options)
+: mDefaultOptions(default_options)
+{
+ LLUICtrlFactory::getInstance()->buildFloater(this, "floater_import_options.xml");
+}
+BOOL LLFloaterXmlImportOptions::postBuild()
+{
+ center();
+ LLScrollListCtrl* list = getChild("import_list");
+ // Add all wearables to list and keep an id:ptr map
+ std::vector::iterator wearable_end = mDefaultOptions->mWearables.end();
+ for(std::vector::iterator iter = mDefaultOptions->mWearables.begin();
+ iter != wearable_end; ++iter)
+ {
+ LLImportWearable* wearablep = (*iter);
+ LLUUID id; id.generate();
+ mImportWearableMap[id] = wearablep;
+ LLSD element;
+ element["id"] = id;
+ LLSD& check_column = element["columns"][LIST_CHECKED];
+ check_column["column"] = "checked";
+ check_column["type"] = "checkbox";
+ check_column["value"] = true;
+ LLSD& type_column = element["columns"][LIST_TYPE];
+ type_column["column"] = "type";
+ type_column["type"] = "icon";
+ type_column["value"] = "inv_item_" + LLWearable::typeToTypeName((EWearableType)(wearablep->mType)) + ".tga";
+ LLSD& name_column = element["columns"][LIST_NAME];
+ name_column["column"] = "name";
+ name_column["value"] = wearablep->mName;
+ list->addElement(element, ADD_BOTTOM);
+ }
+ // Add all root objects to list and keep an id:ptr map
+ std::vector::iterator object_end = mDefaultOptions->mRootObjects.end();
+ for(std::vector::iterator iter = mDefaultOptions->mRootObjects.begin();
+ iter != object_end; ++iter)
+ {
+ LLImportObject* objectp = (*iter);
+ LLUUID id; id.generate();
+ mImportObjectMap[id] = objectp;
+ LLSD element;
+ element["id"] = id;
+ LLSD& check_column = element["columns"][LIST_CHECKED];
+ check_column["column"] = "checked";
+ check_column["type"] = "checkbox";
+ check_column["value"] = true;
+ LLSD& type_column = element["columns"][LIST_TYPE];
+ type_column["column"] = "type";
+ type_column["type"] = "icon";
+ type_column["value"] = "inv_item_object.tga";
+ LLSD& name_column = element["columns"][LIST_NAME];
+ name_column["column"] = "name";
+ name_column["value"] = objectp->mPrimName;
+ list->addElement(element, ADD_BOTTOM);
+ }
+ // Callbacks
+ childSetAction("select_all_btn", onClickSelectAll, this);
+ childSetAction("select_objects_btn", onClickSelectObjects, this);
+ childSetAction("select_wearables_btn", onClickSelectWearables, this);
+ childSetAction("ok_btn", onClickOK, this);
+ childSetAction("cancel_btn", onClickCancel, this);
+ return TRUE;
+}
+void LLFloaterXmlImportOptions::onClickSelectAll(void* user_data)
+{
+ LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
+ LLScrollListCtrl* list = floaterp->getChild("import_list");
+ std::vector items = list->getAllData();
+ std::vector::iterator item_iter = items.begin();
+ std::vector::iterator items_end = items.end();
+ bool new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
+ for( ; item_iter != items_end; ++item_iter)
+ {
+ (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
+ }
+}
+void LLFloaterXmlImportOptions::onClickSelectObjects(void* user_data)
+{
+ LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
+ LLScrollListCtrl* list = floaterp->getChild("import_list");
+ std::vector items = list->getAllData();
+ std::vector::iterator item_iter = items.begin();
+ std::vector::iterator items_end = items.end();
+ bool new_value = false;
+ for( ; item_iter != items_end; ++item_iter)
+ {
+ if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() == "inv_item_object.tga")
+ {
+ new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
+ break;
+ }
+ }
+ for(item_iter = items.begin(); item_iter != items_end; ++item_iter)
+ {
+ if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() == "inv_item_object.tga")
+ (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
+ }
+}
+void LLFloaterXmlImportOptions::onClickSelectWearables(void* user_data)
+{
+ LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
+ LLScrollListCtrl* list = floaterp->getChild("import_list");
+ std::vector items = list->getAllData();
+ std::vector::iterator item_iter = items.begin();
+ std::vector::iterator items_end = items.end();
+ bool new_value = false;
+ for( ; item_iter != items_end; ++item_iter)
+ {
+ if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() != "inv_item_object.tga")
+ {
+ new_value = !((*item_iter)->getColumn(LIST_CHECKED)->getValue());
+ break;
+ }
+ }
+ for(item_iter = items.begin(); item_iter != items_end; ++item_iter)
+ {
+ if(((*item_iter)->getColumn(LIST_TYPE)->getValue()).asString() != "inv_item_object.tga")
+ (*item_iter)->getColumn(LIST_CHECKED)->setValue(new_value);
+ }
+}
+void LLFloaterXmlImportOptions::onClickOK(void* user_data)
+{
+ LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
+ LLXmlImportOptions* opt = new LLXmlImportOptions(floaterp->mDefaultOptions);
+ opt->mRootObjects.clear();
+ opt->mChildObjects.clear();
+ opt->mWearables.clear();
+ LLScrollListCtrl* list = floaterp->getChild("import_list");
+ std::vector items = list->getAllData();
+ std::vector::iterator item_end = items.end();
+ std::vector::iterator child_end = floaterp->mDefaultOptions->mChildObjects.end();
+ for(std::vector::iterator iter = items.begin(); iter != item_end; ++iter)
+ {
+ if((*iter)->getColumn(LIST_CHECKED)->getValue())
+ { // checked
+ LLUUID id = (*iter)->getUUID();
+ if(floaterp->mImportWearableMap.find(id) != floaterp->mImportWearableMap.end())
+ {
+ opt->mWearables.push_back(floaterp->mImportWearableMap[id]);
+ }
+ else // object
+ {
+ LLImportObject* objectp = floaterp->mImportObjectMap[id];
+ opt->mRootObjects.push_back(objectp);
+ // Add child objects
+ for(std::vector::iterator child_iter = floaterp->mDefaultOptions->mChildObjects.begin();
+ child_iter != child_end; ++child_iter)
+ {
+ if((*child_iter)->mParentId == objectp->mId)
+ opt->mChildObjects.push_back((*child_iter));
+ }
+ }
+ }
+ }
+ opt->mKeepPosition = floaterp->childGetValue("keep_position_check");
+ LLXmlImport::import(opt);
+ floaterp->close();
+}
+void LLFloaterXmlImportOptions::onClickCancel(void* user_data)
+{
+ LLFloaterXmlImportOptions* floaterp = (LLFloaterXmlImportOptions*)user_data;
+ floaterp->close();
+}
+
+
+
+
+
+std::string terse_F32_string( F32 f )
+{
+ std::string r = llformat( "%.2f", f );
+ // "1.20" -> "1.2"
+ // "24.00" -> "24."
+ S32 len = r.length();
+ while( len > 0 && '0' == r[len - 1] )
+ {
+ r.erase(len-1, 1);
+ len--;
+ }
+ if( '.' == r[len - 1] )
+ {
+ // "24." -> "24"
+ r.erase(len-1, 1);
+ }
+ else if( ('-' == r[0]) && ('0' == r[1]) )
+ {
+ // "-0.59" -> "-.59"
+ r.erase(1, 1);
+ }
+ else if( '0' == r[0] )
+ {
+ // "0.59" -> ".59"
+ r.erase(0, 1);
+ }
+ return r;
+}
+LLImportWearable::LLImportWearable(LLSD sd)
+{
+ mName = sd["name"].asString();
+ mType = sd["wearabletype"].asInteger();
+
+ LLSD params = sd["params"];
+ LLSD textures = sd["textures"];
+
+ mData = "LLWearable version 22\n" +
+ mName + "\n\n" +
+ "\tpermissions 0\n" +
+ "\t{\n" +
+ "\t\tbase_mask\t7fffffff\n" +
+ "\t\towner_mask\t7fffffff\n" +
+ "\t\tgroup_mask\t00000000\n" +
+ "\t\teveryone_mask\t00000000\n" +
+ "\t\tnext_owner_mask\t00082000\n" +
+ "\t\tcreator_id\t00000000-0000-0000-0000-000000000000\n" +
+ "\t\towner_id\t" + gAgent.getID().asString() + "\n" +
+ "\t\tlast_owner_id\t" + gAgent.getID().asString() + "\n" +
+ "\t\tgroup_id\t00000000-0000-0000-0000-000000000000\n" +
+ "\t}\n" +
+ "\tsale_info\t0\n" +
+ "\t{\n" +
+ "\t\tsale_type\tnot\n" +
+ "\t\tsale_price\t10\n" +
+ "\t}\n" +
+ "type " + llformat("%d", mType) + "\n";
+
+ mData += llformat("parameters %d\n", params.size());
+ LLSD::map_iterator map_iter = params.beginMap();
+ LLSD::map_iterator map_end = params.endMap();
+ for( ; map_iter != map_end; ++map_iter)
+ {
+ mData += (*map_iter).first + " " + terse_F32_string((*map_iter).second.asReal()) + "\n";
+ }
+
+ mData += llformat("textures %d\n", textures.size());
+ map_iter = textures.beginMap();
+ map_end = textures.endMap();
+ for( ; map_iter != map_end; ++map_iter)
+ {
+ mData += (*map_iter).first + " " + (*map_iter).second.asString() + "\n";
+ }
+}
+
+//LLImportObject::LLImportObject(std::string id, std::string parentId)
+// : LLViewerObject(LLUUID::null, 9, NULL, TRUE),
+// mId(id),
+// mParentId(parentId),
+// mPrimName("Object")
+//{
+// importIsAttachment = false;
+//}
+LLImportObject::LLImportObject(std::string id, LLSD prim)
+ : LLViewerObject(LLUUID::null, 9, NULL, TRUE)
+{
+ importIsAttachment = false;
+ mId = id;
+ mParentId = "";
+ mPrimName = "Object";
+ if(prim.has("parent"))
+ {
+ mParentId = prim["parent"].asString();
+ }
+ // Stuff for attach
+ if(prim.has("attach"))
+ {
+ importIsAttachment = true;
+ importAttachPoint = (U8)prim["attach"].asInteger();
+ importAttachPos = ll_vector3_from_sd(prim["position"]);
+ importAttachRot = ll_quaternion_from_sd(prim["rotation"]);
+ }
+ // Transforms
+ setPosition(ll_vector3_from_sd(prim["position"]), FALSE);
+ setScale(ll_vector3_from_sd(prim["scale"]), FALSE);
+ setRotation(ll_quaternion_from_sd(prim["rotation"]), FALSE);
+ // Flags
+ setFlags(FLAGS_CAST_SHADOWS, prim["shadows"].asInteger());
+ setFlags(FLAGS_PHANTOM, prim["phantom"].asInteger());
+ setFlags(FLAGS_USE_PHYSICS, prim["physical"].asInteger());
+ // Volume params
+ LLVolumeParams volume_params;
+ volume_params.fromLLSD(prim["volume"]);
+ setVolume(volume_params, 0, false);
+ // Extra params
+ if(prim.has("flexible"))
+ {
+ LLFlexibleObjectData* wat = new LLFlexibleObjectData();
+ wat->fromLLSD(prim["flex"]);
+ LLFlexibleObjectData flex = *wat;
+ setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
+ setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true);
+ }
+ if(prim.has("light"))
+ {
+ LLLightParams* wat = new LLLightParams();
+ wat->fromLLSD(prim["light"]);
+ LLLightParams light = *wat;
+ setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
+ setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true);
+ }
+ if(prim.has("sculpt"))
+ {
+ LLSculptParams *wat = new LLSculptParams();
+ wat->fromLLSD(prim["sculpt"]);
+ LLSculptParams sculpt = *wat;
+ setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
+ setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true);
+ }
+ // Textures
+ LLSD textures = prim["textures"];
+ LLSD::array_iterator array_iter = textures.beginArray();
+ LLSD::array_iterator array_end = textures.endArray();
+ int i = 0;
+ for( ; array_iter != array_end; ++array_iter)
+ {
+ LLTextureEntry* wat = new LLTextureEntry();
+ wat->fromLLSD(*array_iter);
+ LLTextureEntry te = *wat;
+ setTE(i, te);
+ i++;
+ }
+ if(prim.has("name"))
+ {
+ mPrimName = prim["name"].asString();
+ }
+}
+
+
+
+BuildingSupply::BuildingSupply() : LLEventTimer(0.1f)
+{
+}
+
+BOOL BuildingSupply::tick()
+{
+ if(LLXmlImport::sImportInProgress && (LLXmlImport::sPrimsNeeded > 0))
+ {
+ LLXmlImport::sPrimsNeeded--;
+ // Need moar prims
+ if(LLXmlImport::sXmlImportOptions->mSupplier == NULL)
+ {
+ gMessageSystem->newMessageFast(_PREHASH_ObjectAdd);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU8Fast(_PREHASH_PCode, 9);
+ gMessageSystem->addU8Fast(_PREHASH_Material, LL_MCODE_WOOD);
+ gMessageSystem->addU32Fast(_PREHASH_AddFlags, 0);
+ gMessageSystem->addU8Fast(_PREHASH_PathCurve, 16);
+ gMessageSystem->addU8Fast(_PREHASH_ProfileCurve, 1);
+ gMessageSystem->addU16Fast(_PREHASH_PathBegin, 0);
+ gMessageSystem->addU16Fast(_PREHASH_PathEnd, 0);
+ gMessageSystem->addU8Fast(_PREHASH_PathScaleX, 100);
+ gMessageSystem->addU8Fast(_PREHASH_PathScaleY, 100);
+ gMessageSystem->addU8Fast(_PREHASH_PathShearX, 0);
+ gMessageSystem->addU8Fast(_PREHASH_PathShearY, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathTwist, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathTwistBegin, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathRadiusOffset, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathTaperX, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathTaperY, 0);
+ gMessageSystem->addU8Fast(_PREHASH_PathRevolutions, 0);
+ gMessageSystem->addS8Fast(_PREHASH_PathSkew, 0);
+ gMessageSystem->addU16Fast(_PREHASH_ProfileBegin, 0);
+ gMessageSystem->addU16Fast(_PREHASH_ProfileEnd, 0);
+ gMessageSystem->addU16Fast(_PREHASH_ProfileHollow, 0);
+ gMessageSystem->addU8Fast(_PREHASH_BypassRaycast, 1);
+ LLVector3 rezpos = gAgent.getPositionAgent() + LLVector3(0.0f, 0.0f, 2.0f);
+ gMessageSystem->addVector3Fast(_PREHASH_RayStart, rezpos);
+ gMessageSystem->addVector3Fast(_PREHASH_RayEnd, rezpos);
+ gMessageSystem->addUUIDFast(_PREHASH_RayTargetID, LLUUID::null);
+ gMessageSystem->addU8Fast(_PREHASH_RayEndIsIntersection, 0);
+ gMessageSystem->addVector3Fast(_PREHASH_Scale, LLXmlImport::sSupplyParams->getScale());
+ gMessageSystem->addQuatFast(_PREHASH_Rotation, LLQuaternion::DEFAULT);
+ gMessageSystem->addU8Fast(_PREHASH_State, 0);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+ else // have supplier
+ {
+ try
+ {
+ gMessageSystem->newMessageFast(_PREHASH_ObjectDuplicate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID());
+ gMessageSystem->nextBlockFast(_PREHASH_SharedData);
+ LLVector3 rezpos = gAgent.getPositionAgent() + LLVector3(0.0f, 0.0f, 2.0f);
+ rezpos -= LLXmlImport::sSupplyParams->getPositionRegion();
+ gMessageSystem->addVector3Fast(_PREHASH_Offset, rezpos);
+ gMessageSystem->addU32Fast(_PREHASH_DuplicateFlags, 0);
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, LLXmlImport::sXmlImportOptions->mSupplier->getLocalID());
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+ catch(int)
+ {
+ llwarns << "Abort! Abort!" << llendl;
+ return TRUE;
+ }
+ }
+ LLFloaterImportProgress::update();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+// static
+void LLXmlImport::import(LLXmlImportOptions* import_options)
+{
+ sXmlImportOptions = import_options;
+ if(sXmlImportOptions->mSupplier == NULL)
+ {
+ LLViewerObject* cube = new LLViewerObject(LLUUID::null, 9, NULL, TRUE);
+ cube->setScale(LLVector3(.31337f, .31337f, .31337f), FALSE);
+ sSupplyParams = cube;
+ }
+ else sSupplyParams = sXmlImportOptions->mSupplier;
+
+ if(!(sXmlImportOptions->mKeepPosition) && sXmlImportOptions->mRootObjects.size())
+ { // Reposition all roots so that the first root is somewhere near the avatar
+ // Find the root closest to the ground
+ int num_roots = (int)sXmlImportOptions->mRootObjects.size();
+ int lowest_root = 0;
+ F32 lowest_z(65536.f);
+ for(int i = 0; i < num_roots; i++)
+ {
+ F32 z = sXmlImportOptions->mRootObjects[i]->getPosition().mV[2];
+ if(z < lowest_z)
+ {
+ lowest_root = i;
+ lowest_z = z;
+ }
+ }
+ // Move all roots
+ LLVector3 old_pos = sXmlImportOptions->mRootObjects[lowest_root]->getPosition();
+ LLVector3 new_pos = gAgent.getPositionAgent() + (gAgent.getAtAxis() * 2.0f);
+ LLVector3 difference = new_pos - old_pos;
+ for(int i = 0; i < num_roots; i++)
+ {
+ sXmlImportOptions->mRootObjects[i]->setPosition(sXmlImportOptions->mRootObjects[i]->getPosition() + difference, FALSE);
+ }
+ }
+
+ // Make the actual importable list
+ sPrims.clear();
+ // Clear these attachment-related maps
+ sPt2watch.clear();
+ sId2attachpt.clear();
+ sPt2attachpos.clear();
+ sPt2attachrot.clear();
+ // Go ahead and add roots first
+ std::vector::iterator root_iter = sXmlImportOptions->mRootObjects.begin();
+ std::vector::iterator root_end = sXmlImportOptions->mRootObjects.end();
+ for( ; root_iter != root_end; ++root_iter)
+ {
+ sPrims.push_back(*root_iter);
+ // Remember some attachment info
+ if((*root_iter)->importIsAttachment)
+ {
+ sId2attachpt[(*root_iter)->mId] = (*root_iter)->importAttachPoint;
+ sPt2watch[(*root_iter)->importAttachPoint] = true;
+ sPt2attachpos[(*root_iter)->importAttachPoint] = (*root_iter)->importAttachPos;
+ sPt2attachrot[(*root_iter)->importAttachPoint] = (*root_iter)->importAttachRot;
+ }
+ }
+ // Then add children, nearest first
+ std::vector children(sXmlImportOptions->mChildObjects);
+ for(root_iter = sXmlImportOptions->mRootObjects.begin() ; root_iter != root_end; ++root_iter)
+ {
+ while(children.size() > 0)
+ {
+ std::string rootid = (*root_iter)->mId;
+ F32 lowest_mag = 65536.0f;
+ std::vector::iterator lowest_child_iter = children.begin();
+ LLImportObject* lowest_child = (*lowest_child_iter);
+
+ std::vector::iterator child_end = children.end();
+ for(std::vector::iterator child_iter = children.begin() ; child_iter != child_end; ++child_iter)
+ {
+ if((*child_iter)->mParentId == rootid)
+ {
+ F32 mag = (*child_iter)->getPosition().magVec();
+ if(mag < lowest_mag)
+ {
+ lowest_child_iter = child_iter;
+ lowest_child = (*lowest_child_iter);
+ lowest_mag = mag;
+ }
+ }
+ }
+ sPrims.push_back(lowest_child);
+ children.erase(lowest_child_iter);
+ }
+ }
+
+ sImportInProgress = true;
+ sImportHasAttachments = (sId2attachpt.size() > 0);
+ sPrimsNeeded = (int)sPrims.size();
+ sPrimIndex = 0;
+ sId2localid.clear();
+ sRootpositions.clear();
+
+ LLFloaterImportProgress::show();
+ LLFloaterImportProgress::update();
+
+ // Create folder
+ if((sXmlImportOptions->mWearables.size() > 0) || (sId2attachpt.size() > 0))
+ {
+ sFolderID = gInventory.createNewCategory( gAgent.getInventoryRootID(), LLAssetType::AT_NONE, sXmlImportOptions->mName);
+ }
+
+ // Go ahead and upload wearables
+ int num_wearables = sXmlImportOptions->mWearables.size();
+ for(int i = 0; i < num_wearables; i++)
+ {
+ LLAssetType::EType at = LLAssetType::AT_CLOTHING;
+ if(sXmlImportOptions->mWearables[i]->mType < 4) at = LLAssetType::AT_BODYPART;
+ LLUUID tid;
+ tid.generate();
+ // Create asset
+ gMessageSystem->newMessageFast(_PREHASH_AssetUploadRequest);
+ gMessageSystem->nextBlockFast(_PREHASH_AssetBlock);
+ gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
+ gMessageSystem->addS8Fast(_PREHASH_Type, (S8)at);
+ gMessageSystem->addBOOLFast(_PREHASH_Tempfile, FALSE);
+ gMessageSystem->addBOOLFast(_PREHASH_StoreLocal, FALSE);
+ gMessageSystem->addStringFast(_PREHASH_AssetData, sXmlImportOptions->mWearables[i]->mData.c_str());
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ // Create item
+ gMessageSystem->newMessageFast(_PREHASH_CreateInventoryItem);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_InventoryBlock);
+ gMessageSystem->addU32Fast(_PREHASH_CallbackID, 0);
+ gMessageSystem->addUUIDFast(_PREHASH_FolderID, sFolderID);
+ gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
+ gMessageSystem->addU32Fast(_PREHASH_NextOwnerMask, 532480);
+ gMessageSystem->addS8Fast(_PREHASH_Type, at);
+ gMessageSystem->addS8Fast(_PREHASH_InvType, 18);
+ gMessageSystem->addS8Fast(_PREHASH_WearableType, sXmlImportOptions->mWearables[i]->mType);
+ gMessageSystem->addStringFast(_PREHASH_Name, sXmlImportOptions->mWearables[i]->mName.c_str());
+ gMessageSystem->addStringFast(_PREHASH_Description, "");
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+
+ new BuildingSupply();
+}
+
+// static
+void LLXmlImport::onNewPrim(LLViewerObject* object)
+{
+ if(sPrimIndex >= (int)sPrims.size())
+ {
+ if(sAttachmentsDone >= (int)sPt2attachpos.size())
+ {
+ // "stop calling me"
+ sImportInProgress = false;
+ return;
+ }
+ }
+
+ LLImportObject* from = sPrims[sPrimIndex];
+
+ // Flags
+ // trying this first in case it helps when supply is physical...
+ U32 flags = from->mFlags;
+ flags = flags & (~FLAGS_USE_PHYSICS);
+ object->setFlags(flags, TRUE);
+ object->setFlags(~flags, FALSE); // Can I improve this lol?
+
+ if(from->mParentId == "")
+ {
+ // this will be a root
+ sId2localid[from->mId] = object->getLocalID();
+ sRootpositions[object->getLocalID()] = from->getPosition();
+ // If it's an attachment, set description
+ if(from->importIsAttachment)
+ {
+ gMessageSystem->newMessageFast(_PREHASH_ObjectDescription);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
+ gMessageSystem->addStringFast(_PREHASH_Description, from->mId);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+ }
+ else
+ {
+ // Move it to its root before linking
+ U32 parentlocalid = sId2localid[from->mParentId];
+ LLVector3 rootpos = sRootpositions[parentlocalid];
+
+ U8 data[256];
+ S32 offset = 0;
+ gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->addU8Fast(_PREHASH_Type, 5);
+ htonmemcpy(&data[offset], &(rootpos.mV), MVT_LLVector3, 12);
+ offset += 12;
+ htonmemcpy(&data[offset], &(from->getScale().mV), MVT_LLVector3, 12);
+ offset += 12;
+ gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ // Link it up
+ gMessageSystem->newMessageFast(_PREHASH_ObjectLink);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, sId2localid[from->mParentId]);
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+ // Volume params
+ LLVolumeParams params = from->getVolume()->getParams();
+ object->setVolume(params, 0, false);
+ // Extra params
+ if(from->isFlexible())
+ {
+ LLFlexibleObjectData* wat = (LLFlexibleObjectData*)from->getParameterEntry(LLNetworkData::PARAMS_FLEXIBLE);
+ LLFlexibleObjectData flex = *wat;
+ object->setParameterEntry(LLNetworkData::PARAMS_FLEXIBLE, flex, true);
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, TRUE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_FLEXIBLE, true);
+ }
+ else
+ {
+ // send param not in use in case the supply prim has it
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_FLEXIBLE, FALSE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_FLEXIBLE, true);
+ }
+ if (from->getParameterEntryInUse(LLNetworkData::PARAMS_LIGHT))
+ {
+ LLLightParams* wat = (LLLightParams*)from->getParameterEntry(LLNetworkData::PARAMS_LIGHT);
+ LLLightParams light = *wat;
+ object->setParameterEntry(LLNetworkData::PARAMS_LIGHT, light, true);
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, TRUE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_LIGHT, true);
+ }
+ else
+ {
+ // send param not in use in case the supply prim has it
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_LIGHT, FALSE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_LIGHT, true);
+ }
+ if (from->getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT))
+ {
+ LLSculptParams* wat = (LLSculptParams*)from->getParameterEntry(LLNetworkData::PARAMS_SCULPT);
+ LLSculptParams sculpt = *wat;
+ object->setParameterEntry(LLNetworkData::PARAMS_SCULPT, sculpt, true);
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, TRUE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_SCULPT, true);
+ }
+ else
+ {
+ // send param not in use in case the supply prim has it
+ object->setParameterEntryInUse(LLNetworkData::PARAMS_SCULPT, FALSE, true);
+ object->parameterChanged(LLNetworkData::PARAMS_SCULPT, true);
+ }
+ // Textures
+ U8 te_count = from->getNumTEs();
+ for (U8 i = 0; i < te_count; i++)
+ {
+ const LLTextureEntry* wat = from->getTE(i);
+ LLTextureEntry te = *wat;
+ object->setTE(i, te);
+ }
+
+ object->sendShapeUpdate();
+ object->sendTEUpdate();
+ // Flag update is already coming from somewhere
+ //object->updateFlags();
+
+ // Transforms
+ object->setScale(from->getScale(), FALSE);
+ object->setRotation(from->getRotation(), FALSE);
+ object->setPosition(from->getPosition(), FALSE);
+
+ U8 data[256];
+ S32 offset = 0;
+ // Position and rotation
+ gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->addU8Fast(_PREHASH_Type, 3);
+ htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
+ offset += 12;
+ LLQuaternion quat = object->getRotation();
+ LLVector3 vec = quat.packToVector3();
+ htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
+ offset += 12;
+ gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ // Position and scale
+ offset = 0;
+ gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->addU8Fast(_PREHASH_Type, 5);
+ htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
+ offset += 12;
+ htonmemcpy(&data[offset], &(object->getScale().mV), MVT_LLVector3, 12);
+ offset += 12;
+ gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ // Test - Position, rotation, and scale, didn't work properly
+ /*
+ gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->addU8Fast(_PREHASH_Type, 7);
+ htonmemcpy(&data[offset], &(object->getPosition().mV), MVT_LLVector3, 12);
+ offset += 12;
+ LLQuaternion quat = object->getRotation();
+ LLVector3 vec = quat.packToVector3();
+ htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
+ offset += 12;
+ htonmemcpy(&data[offset], &(object->getScale().mV), MVT_LLVector3, 12);
+ offset += 12;
+ gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ // end test
+ */
+
+ // Name
+ if(from->mPrimName != "")
+ {
+ gMessageSystem->newMessageFast(_PREHASH_ObjectName);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
+ gMessageSystem->addStringFast(_PREHASH_Name, from->mPrimName);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+
+ sPrimIndex++;
+ if(sPrimIndex >= (int)sPrims.size())
+ {
+ if(sId2attachpt.size() == 0)
+ {
+ sImportInProgress = false;
+ std::string msg = "Imported " + sXmlImportOptions->mName;
+ LLChat chat(msg);
+ LLFloaterChat::addChat(chat);
+ LLFloaterImportProgress::update();
+ return;
+ }
+ else
+ {
+ // Take attachables into inventory
+ std::string msg = "Wait a few moments for the attachments to attach...";
+ LLChat chat(msg);
+ LLFloaterChat::addChat(chat);
+
+ sAttachmentsDone = 0;
+ std::map::iterator at_iter = sId2attachpt.begin();
+ std::map::iterator at_end = sId2attachpt.end();
+ for( ; at_iter != at_end; ++at_iter)
+ {
+ LLUUID tid;
+ tid.generate();
+ U32 at_localid = sId2localid[(*at_iter).first];
+ gMessageSystem->newMessageFast(_PREHASH_DeRezObject);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_AgentBlock);
+ gMessageSystem->addUUIDFast(_PREHASH_GroupID, LLUUID::null);
+ gMessageSystem->addU8Fast(_PREHASH_Destination, DRD_TAKE_INTO_AGENT_INVENTORY);
+ gMessageSystem->addUUIDFast(_PREHASH_DestinationID, sFolderID);
+ gMessageSystem->addUUIDFast(_PREHASH_TransactionID, tid);
+ gMessageSystem->addU8Fast(_PREHASH_PacketCount, 1);
+ gMessageSystem->addU8Fast(_PREHASH_PacketNumber, 0);
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, at_localid);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+ }
+ }
+ LLFloaterImportProgress::update();
+}
+
+// static
+void LLXmlImport::onNewItem(LLViewerInventoryItem* item)
+{
+ U8 attachpt = sId2attachpt[item->getDescription()];
+ if(attachpt)
+ {
+ // clear description, part 1
+ item->setDescription(std::string("(No Description)"));
+ item->updateServer(FALSE);
+
+ // Attach it
+ gMessageSystem->newMessageFast(_PREHASH_RezSingleAttachmentFromInv);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addUUIDFast(_PREHASH_ItemID, item->getUUID());
+ gMessageSystem->addUUIDFast(_PREHASH_OwnerID, gAgent.getID());
+ gMessageSystem->addU8Fast(_PREHASH_AttachmentPt, attachpt);
+ gMessageSystem->addU32Fast(_PREHASH_ItemFlags, 0);
+ gMessageSystem->addU32Fast(_PREHASH_GroupMask, 0);
+ gMessageSystem->addU32Fast(_PREHASH_EveryoneMask, 0);
+ gMessageSystem->addU32Fast(_PREHASH_NextOwnerMask, 0);
+ gMessageSystem->addStringFast(_PREHASH_Name, item->getName());
+ gMessageSystem->addStringFast(_PREHASH_Description, "");
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+ }
+}
+
+// static
+void LLXmlImport::onNewAttachment(LLViewerObject* object)
+{
+ if(sPt2attachpos.size() == 0) return;
+
+ U8 attachpt = (U8)object->getAttachmentPoint();
+ if(sPt2watch[attachpt])
+ {
+ // clear description, part 2
+ gMessageSystem->newMessageFast(_PREHASH_ObjectDescription);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_LocalID, object->getLocalID());
+ gMessageSystem->addStringFast(_PREHASH_Description, "");
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ // position and rotation
+ LLVector3 pos = sPt2attachpos[attachpt];
+ U8 data[256];
+ S32 offset = 0;
+ gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->addU8Fast(_PREHASH_Type, 11); // link set this time
+ htonmemcpy(&data[offset], &(pos.mV), MVT_LLVector3, 12);
+ offset += 12;
+ LLQuaternion quat = sPt2attachrot[attachpt];
+ LLVector3 vec = quat.packToVector3();
+ htonmemcpy(&data[offset], &(vec.mV), MVT_LLQuaternion, 12);
+ offset += 12;
+ gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset);
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ // Select and deselect to make it send an update
+ gMessageSystem->newMessageFast(_PREHASH_ObjectSelect);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ gMessageSystem->newMessageFast(_PREHASH_ObjectDeselect);
+ gMessageSystem->nextBlockFast(_PREHASH_AgentData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
+ gMessageSystem->sendReliable(gAgent.getRegionHost());
+
+ // Done?
+ sAttachmentsDone++;
+ if(sAttachmentsDone >= (int)sPt2attachpos.size())
+ {
+ sImportInProgress = false;
+ std::string msg = "Imported " + sXmlImportOptions->mName;
+ LLChat chat(msg);
+ LLFloaterChat::addChat(chat);
+ LLFloaterImportProgress::update();
+ return;
+ }
+ }
+}
+
+
+
+// static
+void LLXmlImport::Cancel(void* user_data)
+{
+ sImportInProgress = false;
+ LLFloaterImportProgress::sInstance->close(false);
+}
+
+
+
+LLFloaterImportProgress::LLFloaterImportProgress()
+: LLFloater("ImportProgress", LLRect(0, 100, 400, 0), "Import progress")
+{
+ LLLineEditor* line = new LLLineEditor(
+ std::string("Created"),
+ LLRect(4, 80, 396, 60),
+ std::string("Created prims"));
+ line->setEnabled(FALSE);
+ addChild(line);
+
+ LLViewBorder* border = new LLViewBorder(
+ "CreatedBorder",
+ LLRect(4, 79, 395, 60));
+ addChild(border);
+
+ line = new LLLineEditor(
+ std::string("Edited"),
+ LLRect(4, 55, 396, 35),
+ std::string("Edited prims"));
+ line->setEnabled(FALSE);
+ addChild(line);
+
+ border = new LLViewBorder(
+ "EditedBorder",
+ LLRect(4, 54, 395, 35));
+ addChild(border);
+
+ LLButton* button = new LLButton(
+ "CancelButton",
+ LLRect(300, 28, 394, 8));
+ button->setLabel(std::string("Cancel"));
+ button->setEnabled(TRUE);
+ addChild(button);
+ childSetAction("CancelButton", LLXmlImport::Cancel, this);
+
+ sInstance = this;
+}
+
+LLFloaterImportProgress::~LLFloaterImportProgress()
+{
+ sInstance = NULL;
+}
+
+void LLFloaterImportProgress::close(bool app_quitting)
+{
+ LLXmlImport::sImportInProgress = false;
+ LLFloater::close(app_quitting);
+}
+
+// static
+void LLFloaterImportProgress::show()
+{
+ if(!sInstance)
+ sInstance = new LLFloaterImportProgress();
+ sInstance->open();
+ sInstance->center();
+}
+
+// static
+void LLFloaterImportProgress::update()
+{
+ if(sInstance)
+ {
+ LLFloaterImportProgress* floater = sInstance;
+
+ int create_goal = (int)LLXmlImport::sPrims.size();
+ int create_done = create_goal - LLXmlImport::sPrimsNeeded;
+ F32 create_width = F32(390.f / F32(create_goal));
+ create_width *= F32(create_done);
+ bool create_finished = create_done >= create_goal;
+
+ int edit_goal = create_goal;
+ int edit_done = LLXmlImport::sPrimIndex;
+ F32 edit_width = F32(390.f / F32(edit_goal));
+ edit_width *= edit_done;
+ bool edit_finished = edit_done >= edit_goal;
+
+ int attach_goal = (int)LLXmlImport::sId2attachpt.size();
+ int attach_done = LLXmlImport::sAttachmentsDone;
+ F32 attach_width = F32(390.f / F32(attach_goal));
+ attach_width *= F32(attach_done);
+ bool attach_finished = attach_done >= attach_goal;
+
+ bool all_finished = create_finished && edit_finished && attach_finished;
+
+ std::string title;
+ title.assign(all_finished ? "Imported " : "Importing ");
+ title.append(LLXmlImport::sXmlImportOptions->mName);
+ if(!all_finished) title.append("...");
+ floater->setTitle(title);
+
+ std::string created_text = llformat("Created %d/%d prims", S32(create_done), S32(create_goal));
+ std::string edited_text = llformat("Finished %d/%d prims", edit_done, edit_goal);
+
+ LLLineEditor* text = floater->getChild("Created");
+ text->setText(created_text);
+
+ text = floater->getChild("Edited");
+ text->setText(edited_text);
+
+ LLViewBorder* border = floater->getChild("CreatedBorder");
+ border->setRect(LLRect(4, 79, 4 + create_width, 60));
+
+ border = floater->getChild("EditedBorder");
+ border->setRect(LLRect(4, 54, 4 + edit_width, 35));
+
+ LLButton* button = floater->getChild("CancelButton");
+ button->setEnabled(!all_finished);
+ }
+}
+
+//
diff --git a/indra/newview/llimportobject.h b/indra/newview/llimportobject.h
index d7f1be8e0..d3e785afb 100644
--- a/indra/newview/llimportobject.h
+++ b/indra/newview/llimportobject.h
@@ -1,127 +1,127 @@
-//
-/**
- * @file llimportobject.h
- */
-
-#ifndef LL_LLIMPORTOBJECT_H
-#define LL_LLIMPORTOBJECT_H
-
-#include "llviewerobject.h"
-#include "llfloater.h"
-
-
-class BuildingSupply : public LLEventTimer
-{
-public:
- BuildingSupply();
- BOOL tick();
-};
-
-class LLImportWearable
-{
-public:
- std::string mName;
- int mType;
- std::string mData;
-
- LLImportWearable(LLSD sd);
-};
-
-class LLImportObject : public LLViewerObject
-{
-public:
- //LLImportObject(std::string id, std::string parentId);
- LLImportObject(std::string id, LLSD prim);
-
- std::string mId;
- std::string mParentId;
- std::string mPrimName;
- bool importIsAttachment;
- U32 importAttachPoint;
- LLVector3 importAttachPos;
- LLQuaternion importAttachRot;
-};
-
-
-class LLXmlImportOptions
-{
-public:
- LLXmlImportOptions(LLXmlImportOptions* options);
- LLXmlImportOptions(std::string filename);
- LLXmlImportOptions(LLSD llsd);
- void init(LLSD llsd);
- std::string mName;
- //LLSD mLLSD;
- std::vector mRootObjects;
- std::vector mChildObjects;
- std::vector mWearables;
- BOOL mKeepPosition;
- LLViewerObject* mSupplier;
-};
-
-
-class LLXmlImport
-{
-public:
- static void import(LLXmlImportOptions* import_options);
- static void onNewPrim(LLViewerObject* object);
- static void onNewItem(LLViewerInventoryItem* item);
- static void onNewAttachment(LLViewerObject* object);
- static void Cancel(void* user_data);
-
- static bool sImportInProgress;
- static bool sImportHasAttachments;
- static LLUUID sFolderID;
- static LLViewerObject* sSupplyParams;
- static int sPrimsNeeded;
- static std::vector sPrims; // all prims being imported
- static std::map sPt2watch; // attach points that need watching
- static std::map sId2attachpt; // attach points of all attachables
- static std::map sPt2attachpos; // positions of all attachables
- static std::map sPt2attachrot; // rotations of all attachables
- static int sPrimIndex;
- static int sAttachmentsDone;
- static std::map sId2localid;
- static std::map sRootpositions;
- static LLXmlImportOptions* sXmlImportOptions;
-};
-
-
-class LLFloaterImportProgress
-: public LLFloater
-{
-public:
- void close(bool app_quitting);
- static LLFloaterImportProgress* sInstance;
- static void show();
- static void update();
-private:
- LLFloaterImportProgress();
- virtual ~LLFloaterImportProgress();
-};
-
-
-class LLFloaterXmlImportOptions : public LLFloater
-{
-public:
- LLFloaterXmlImportOptions(LLXmlImportOptions* default_options);
- BOOL postBuild();
- LLXmlImportOptions* mDefaultOptions;
- std::map mImportWearableMap;
- std::map mImportObjectMap;
-private:
- enum LIST_COLUMN_ORDER
- {
- LIST_CHECKED,
- LIST_TYPE,
- LIST_NAME,
- };
- static void onClickSelectAll(void* user_data);
- static void onClickSelectObjects(void* user_data);
- static void onClickSelectWearables(void* user_data);
- static void onClickOK(void* user_data);
- static void onClickCancel(void* user_data);
-};
-
-#endif
-//
+//
+/**
+ * @file llimportobject.h
+ */
+
+#ifndef LL_LLIMPORTOBJECT_H
+#define LL_LLIMPORTOBJECT_H
+
+#include "llviewerobject.h"
+#include "llfloater.h"
+
+
+class BuildingSupply : public LLEventTimer
+{
+public:
+ BuildingSupply();
+ BOOL tick();
+};
+
+class LLImportWearable
+{
+public:
+ std::string mName;
+ int mType;
+ std::string mData;
+
+ LLImportWearable(LLSD sd);
+};
+
+class LLImportObject : public LLViewerObject
+{
+public:
+ //LLImportObject(std::string id, std::string parentId);
+ LLImportObject(std::string id, LLSD prim);
+
+ std::string mId;
+ std::string mParentId;
+ std::string mPrimName;
+ bool importIsAttachment;
+ U32 importAttachPoint;
+ LLVector3 importAttachPos;
+ LLQuaternion importAttachRot;
+};
+
+
+class LLXmlImportOptions
+{
+public:
+ LLXmlImportOptions(LLXmlImportOptions* options);
+ LLXmlImportOptions(std::string filename);
+ LLXmlImportOptions(LLSD llsd);
+ void init(LLSD llsd);
+ std::string mName;
+ //LLSD mLLSD;
+ std::vector mRootObjects;
+ std::vector mChildObjects;
+ std::vector mWearables;
+ BOOL mKeepPosition;
+ LLViewerObject* mSupplier;
+};
+
+
+class LLXmlImport
+{
+public:
+ static void import(LLXmlImportOptions* import_options);
+ static void onNewPrim(LLViewerObject* object);
+ static void onNewItem(LLViewerInventoryItem* item);
+ static void onNewAttachment(LLViewerObject* object);
+ static void Cancel(void* user_data);
+
+ static bool sImportInProgress;
+ static bool sImportHasAttachments;
+ static LLUUID sFolderID;
+ static LLViewerObject* sSupplyParams;
+ static int sPrimsNeeded;
+ static std::vector sPrims; // all prims being imported
+ static std::map sPt2watch; // attach points that need watching
+ static std::map sId2attachpt; // attach points of all attachables
+ static std::map sPt2attachpos; // positions of all attachables
+ static std::map sPt2attachrot; // rotations of all attachables
+ static int sPrimIndex;
+ static int sAttachmentsDone;
+ static std::map sId2localid;
+ static std::map sRootpositions;
+ static LLXmlImportOptions* sXmlImportOptions;
+};
+
+
+class LLFloaterImportProgress
+: public LLFloater
+{
+public:
+ void close(bool app_quitting);
+ static LLFloaterImportProgress* sInstance;
+ static void show();
+ static void update();
+private:
+ LLFloaterImportProgress();
+ virtual ~LLFloaterImportProgress();
+};
+
+
+class LLFloaterXmlImportOptions : public LLFloater
+{
+public:
+ LLFloaterXmlImportOptions(LLXmlImportOptions* default_options);
+ BOOL postBuild();
+ LLXmlImportOptions* mDefaultOptions;
+ std::map mImportWearableMap;
+ std::map mImportObjectMap;
+private:
+ enum LIST_COLUMN_ORDER
+ {
+ LIST_CHECKED,
+ LIST_TYPE,
+ LIST_NAME,
+ };
+ static void onClickSelectAll(void* user_data);
+ static void onClickSelectObjects(void* user_data);
+ static void onClickSelectWearables(void* user_data);
+ static void onClickOK(void* user_data);
+ static void onClickCancel(void* user_data);
+};
+
+#endif
+//
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6e0999a58..dfecc2673 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3815,7 +3815,7 @@ bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& respon
}
return false;
}
-static LLNotificationFunctorRegistration confirm_replace_attachment_rez_reg("ReplaceAttachment", confirm_replace_attachment_rez);
+LLNotificationFunctorRegistration confirm_replace_attachment_rez_reg("ReplaceAttachment", confirm_replace_attachment_rez);
void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
{
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 7f119d546..b363e107f 100644
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -59,10 +59,10 @@
#include "llviewercontrol.h"
#include "llvoavatar.h"
#include "llsdutil.h"
-//
-#include "llimportobject.h"
-#include "llappviewer.h" // gLostItemsRoot
-//
+//
+#include "llimportobject.h"
+#include "llappviewer.h" // gLostItemsRoot
+//
#include
//#define DIFF_INVENTORY_FILES
@@ -211,14 +211,14 @@ BOOL LLInventoryModel::isObjectDescendentOf(const LLUUID& obj_id,
while(obj)
{
const LLUUID& parent_id = obj->getParentUUID();
- //
- if(parent_id == obj->getUUID())
- {
- // infinite loop... same thing as having no parent, hopefully.
- llwarns << "This shit has itself as parent! " << parent_id.asString() << ", " << obj->getName() << llendl;
- return FALSE;
- }
- //
+ //
+ if(parent_id == obj->getUUID())
+ {
+ // infinite loop... same thing as having no parent, hopefully.
+ llwarns << "This shit has itself as parent! " << parent_id.asString() << ", " << obj->getName() << llendl;
+ return FALSE;
+ }
+ //
if( parent_id.isNull() )
{
return FALSE;
@@ -835,14 +835,14 @@ void LLInventoryModel::deleteObject(const LLUUID& id)
// folders, items, etc in a fairly efficient manner.
void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
{
- // "Deliberately disobeying you" derf derf
- //EHasChildren children = categoryHasChildren(id);
- //if(children == CHILDREN_NO)
- //{
- // llinfos << "Not purging descendents of " << id << llendl;
- // return;
- //}
- //
+ // "Deliberately disobeying you" derf derf
+ //EHasChildren children = categoryHasChildren(id);
+ //if(children == CHILDREN_NO)
+ //{
+ // llinfos << "Not purging descendents of " << id << llendl;
+ // return;
+ //}
+ //
LLPointer cat = getCategory(id);
if(cat.notNull())
{
@@ -1397,10 +1397,10 @@ void LLInventoryModel::bulkFetch(std::string url)
if (cat)
{
- // Pre-emptive strike
- if(!(gInventory.isObjectDescendentOf(cat->getUUID(), gLocalInventoryRoot)))
- {
- //
+ // Pre-emptive strike
+ if(!(gInventory.isObjectDescendentOf(cat->getUUID(), gLocalInventoryRoot)))
+ {
+ //
if ( LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion())
{
LLSD folder_sd;
@@ -1436,9 +1436,9 @@ void LLInventoryModel::bulkFetch(std::string url)
}
}
- //
- }
- //
+ //
+ }
+ //
}
}
sFetchQueue.pop_front();
@@ -1739,10 +1739,10 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item)
if(item)
{
mItemMap[item->getUUID()] = item;
- //
- if(LLXmlImport::sImportInProgress)
- LLXmlImport::onNewItem(item);
- //
+ //
+ if(LLXmlImport::sImportInProgress)
+ LLXmlImport::onNewItem(item);
+ //
}
}
@@ -1928,8 +1928,8 @@ bool LLInventoryModel::isCategoryComplete(const LLUUID& cat_id) const
}
}
- //
- if((cat_id == gLocalInventoryRoot) || gInventory.isObjectDescendentOf(cat_id, gLocalInventoryRoot)) return true;
+ //
+ if((cat_id == gLocalInventoryRoot) || gInventory.isObjectDescendentOf(cat_id, gLocalInventoryRoot)) return true;
//
return false;
@@ -3485,11 +3485,11 @@ bool LLInventoryCollectFunctor::itemTransferCommonlyAllowed(LLInventoryItem* ite
LLVOAvatar* my_avatar = NULL;
switch(item->getType())
- {
- // I don't even think changing this did anything
- //case LLAssetType::AT_CALLINGCARD:
- // // not allowed
- // break;
+ {
+ // I don't even think changing this did anything
+ //case LLAssetType::AT_CALLINGCARD:
+ // // not allowed
+ // break;
case LLAssetType::AT_OBJECT:
my_avatar = gAgent.getAvatarObject();
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index e4cd1b24b..291a230aa 100644
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -385,14 +385,14 @@ protected:
// the internal data structures are consistent. These methods
// should be passed pointers of newly created objects, and the
// instance will take over the memory management from there.
-//
-public:
-//
+//
+public:
+//
void addCategory(LLViewerInventoryCategory* category);
void addItem(LLViewerInventoryItem* item);
-//
-protected:
-//
+//
+protected:
+//
// Internal method which looks for a category with the specified
// preferred type. Returns LLUUID::null if not found
@@ -408,18 +408,18 @@ protected:
//void recalculateCloneInformation();
// file import/export.
-//
-public:
-//
+//
+public:
+//
static bool loadFromFile(const std::string& filename,
cat_array_t& categories,
item_array_t& items);
static bool saveToFile(const std::string& filename,
const cat_array_t& categories,
const item_array_t& items);
-//
-protected:
-//
+//
+protected:
+//
// message handling functionality
//static void processUseCachedInventory(LLMessageSystem* msg, void**);
diff --git a/indra/newview/lllocalinventory.cpp b/indra/newview/lllocalinventory.cpp
index 4b434eed8..7f52ee8ce 100644
--- a/indra/newview/lllocalinventory.cpp
+++ b/indra/newview/lllocalinventory.cpp
@@ -1,521 +1,521 @@
-//
-#include "llviewerprecompiledheaders.h"
-
-#include "lllocalinventory.h"
-
-#include "llviewerinventory.h"
-#include "llviewercontrol.h"
-
-#include "llpreviewsound.h"
-#include "llpreviewanim.h"
-#include "llpreviewtexture.h"
-#include "llpreviewgesture.h"
-#include "llpreviewlandmark.h"
-#include "dofloaterhex.h"
-#include "hgfloatertexteditor.h"
-
-#include "llappviewer.h"
-
-#include "lluictrlfactory.h"
-#include "llcombobox.h"
-
-#include "llagent.h" // gAgent
-#include "llviewerwindow.h" // alertXml
-
-
-LLUUID LLLocalInventory::addItem(std::string name, int type, LLUUID asset_id, bool open_automatically)
-{
- LLUUID item_id = addItem(name, type, asset_id);
- if(open_automatically) open(item_id);
- return item_id;
-}
-
-LLUUID LLLocalInventory::addItem(std::string name, int type, LLUUID asset_id)
-{
- LLUUID item_id;
- item_id.generate();
- LLPermissions* perms = new LLPermissions();
- perms->set(LLPermissions::DEFAULT);
- perms->setOwnerAndGroup(LLUUID::null, LLUUID::null, LLUUID::null, false);
- perms->setMaskBase(0);
- perms->setMaskEveryone(0);
- perms->setMaskGroup(0);
- perms->setMaskNext(0);
- perms->setMaskOwner(0);
- LLViewerInventoryItem* item = new LLViewerInventoryItem(
- item_id,
- gLocalInventoryRoot,
- *perms,
- asset_id,
- (LLAssetType::EType)type,
- (LLInventoryType::EType)type,
- name,
- "",
- LLSaleInfo::DEFAULT,
- 0,
- 0);
- addItem(item);
- return item_id;
-}
-
-void LLLocalInventory::addItem(LLViewerInventoryItem* item)
-{
- //gInventory.addPretendItem(item);
- LLInventoryModel::update_map_t update;
- ++update[item->getParentUUID()];
- gInventory.accountForUpdate(update);
- gInventory.updateItem(item);
- gInventory.notifyObservers();
-}
-
-void LLLocalInventory::open(LLUUID item_id)
-{
- LLViewerInventoryItem* item = gInventory.getItem(item_id);
- if(!item)
- {
- llwarns << "Trying to open non-existent item" << llendl;
- return;
- }
-
- LLAssetType::EType type = item->getType();
-
- if(type == LLAssetType::AT_SOUND)
- {
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("PreviewSoundRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLPreviewSound* floaterp;
- floaterp = new LLPreviewSound("Preview sound",
- rect,
- "",
- item_id);
- floaterp->setFocus(TRUE);
- gFloaterView->adjustToFitScreen(floaterp, FALSE);
- }
- else if(type == LLAssetType::AT_ANIMATION)
- {
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("PreviewAnimRect");
- rect.translate(left - rect.mLeft, top - rect.mTop);
- LLPreviewAnim* floaterp;
- floaterp = new LLPreviewAnim("Preview anim",
- rect,
- "",
- item_id,
- 0);
- floaterp->setFocus(TRUE);
- gFloaterView->adjustToFitScreen(floaterp, FALSE);
- }
- else if(type == LLAssetType::AT_TEXTURE)
- {
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("PreviewTextureRect");
- rect.translate( left - rect.mLeft, top - rect.mTop );
-
- LLPreviewTexture* preview;
- preview = new LLPreviewTexture("preview texture",
- rect,
- "Preview texture",
- item_id,
- LLUUID::null,
- FALSE);
- //preview->setSourceID(source_id);
- preview->setFocus(TRUE);
-
- gFloaterView->adjustToFitScreen(preview, FALSE);
- }
- else if(type == LLAssetType::AT_GESTURE)
- {
- // If only the others were like this
- LLPreviewGesture::show("preview gesture", item_id, LLUUID::null, TRUE);
- }
- else if(type == LLAssetType::AT_LANDMARK)
- {
- S32 left, top;
- gFloaterView->getNewFloaterPosition(&left, &top);
- LLRect rect = gSavedSettings.getRect("PreviewLandmarkRect");
- rect.translate( left - rect.mLeft, top - rect.mTop );
-
- LLPreviewLandmark* preview;
- preview = new LLPreviewLandmark("preview landmark",
- rect,
- "Preview landmark",
- item_id);
- preview->setFocus(TRUE);
-
- gFloaterView->adjustToFitScreen(preview, FALSE);
- }
- else
- {
- llwarns << "Dunno how to open type " << type << ", falling back to hex editor" << llendl;
- DOFloaterHex::show(item_id);
- }
-}
-
-//static
-void LLLocalInventory::loadInvCache(std::string filename)
-{
- std::string extension = gDirUtilp->getExtension(filename);
- std::string inv_filename = filename;
- if(extension == "gz")
- {
- LLUUID random;
- random.generate();
- inv_filename = filename.substr(0, filename.length() - 3) + "." + random.asString();
-
- if(!gunzip_file(filename, inv_filename))
- {
- // failure... message?
- return;
- }
- }
-
- int conflicting_cat_count = 0;
- int conflicting_item_count = 0;
- int conflicting_parent_count = 0;
-
- LLInventoryModel::cat_array_t cats;
- LLInventoryModel::item_array_t items;
- if(LLInventoryModel::loadFromFile(inv_filename, cats, items))
- {
- // create a container category for everything
- LLViewerInventoryCategory* container = new LLViewerInventoryCategory(gAgent.getID());
- container->rename(gDirUtilp->getBaseFileName(filename, false));
- LLUUID container_id;
- container_id.generate();
- container->setUUID(container_id);
- container->setParent(gLocalInventoryRoot);
- container->setPreferredType(LLAssetType::AT_NONE);
- LLInventoryModel::update_map_t container_update;
- ++container_update[container->getParentUUID()];
- gInventory.accountForUpdate(container_update);
- gInventory.updateCategory(container);
- gInventory.notifyObservers();
-
- // Add all categories
- LLInventoryModel::cat_array_t::iterator cat_iter = cats.begin();
- LLInventoryModel::cat_array_t::iterator cat_end = cats.end();
- for(; cat_iter != cat_end; ++cat_iter)
- {
- // Conditionally change its parent
- // Note: Should I search for missing parent id's?
- if((*cat_iter)->getParentUUID().isNull())
- {
- (*cat_iter)->setParent(container_id);
- }
-
- // Avoid conflicts with real inventory...
- // If this category already exists, ignore it
- if(gInventory.getCategory((*cat_iter)->getUUID()))
- {
- conflicting_cat_count++;
- continue;
- }
- // If the parent exists and outside of pretend inventory, ignore it
- if(gInventory.getCategory((*cat_iter)->getParentUUID()))
- {
- if(!gInventory.isObjectDescendentOf((*cat_iter)->getParentUUID(), gLocalInventoryRoot))
- {
- conflicting_parent_count++;
- continue;
- }
- }
-
- LLInventoryModel::update_map_t update;
- ++update[(*cat_iter)->getParentUUID()];
- gInventory.accountForUpdate(update);
- gInventory.updateCategory(*cat_iter);
- gInventory.notifyObservers();
- }
-
- // Add all items
- LLInventoryModel::item_array_t::iterator item_iter = items.begin();
- LLInventoryModel::item_array_t::iterator item_end = items.end();
- for(; item_iter != item_end; ++item_iter)
- {
- // Conditionally change its parent
- // Note: Should I search for missing parent id's?
- if((*item_iter)->getParentUUID().isNull())
- {
- (*item_iter)->setParent(container_id);
- }
-
- // Avoid conflicts with real inventory...
- // If this item id already exists, ignore it
- if(gInventory.getItem((*item_iter)->getUUID()))
- {
- conflicting_item_count++;
- continue;
- }
- // If the parent exists and outside of pretend inventory, ignore it
- if(gInventory.getCategory((*item_iter)->getParentUUID()))
- {
- if(!gInventory.isObjectDescendentOf((*item_iter)->getParentUUID(), gLocalInventoryRoot))
- {
- conflicting_parent_count++;
- continue;
- }
- }
-
- LLInventoryModel::update_map_t update;
- ++update[(*item_iter)->getParentUUID()];
- gInventory.accountForUpdate(update);
- gInventory.updateItem(*item_iter);
- gInventory.notifyObservers();
- }
- }
-
- // remove temporary unzipped file
- if(extension == "gz")
- {
- LLFile::remove(inv_filename);
- }
-
- // Quality time
- if(conflicting_cat_count || conflicting_item_count || conflicting_parent_count)
- {
- std::ostringstream message;
- message << "Some items were ignored due to conflicts:\n\n";
- if(conflicting_cat_count) message << conflicting_cat_count << " folders\n";
- if(conflicting_item_count) message << conflicting_item_count << " items\n";
- if(conflicting_parent_count) message << conflicting_parent_count << " parents\n";
- LLSD args;
- args["ERROR_MESSAGE"] = message.str();
- LLNotifications::instance().add("ErrorMessage", args);
- }
-}
-
-//static
-void LLLocalInventory::saveInvCache(std::string filename, LLFolderView* folder)
-{
- LLInventoryModel* model = &gInventory;
- std::set selected_items;
- folder->getSelectionList(selected_items);
- if(selected_items.size() < 1)
- {
- // No items selected? Wtfboom
- return;
- }
- LLInventoryModel::cat_array_t cats;
- LLInventoryModel::item_array_t items;
- // Make complete lists of child categories and items
- std::set::iterator sel_iter = selected_items.begin();
- std::set::iterator sel_end = selected_items.end();
- for( ; sel_iter != sel_end; ++sel_iter)
- {
- LLInventoryCategory* cat = model->getCategory(*sel_iter);
- if(cat)
- {
- climb(cat, cats, items);
- }
- }
- // And what about items inside a folder that wasn't selected?
- // I guess I will just add selected items, so long as they aren't already added
- for(sel_iter = selected_items.begin(); sel_iter != sel_end; ++sel_iter)
- {
- LLInventoryItem* item = model->getItem(*sel_iter);
- if(item)
- {
- if(std::find(items.begin(), items.end(), item) == items.end())
- {
- items.push_back(LLPointer((LLViewerInventoryItem*)item));
- LLInventoryCategory* parent = model->getCategory(item->getParentUUID());
- if(std::find(cats.begin(), cats.end(), parent) == cats.end())
- {
- cats.push_back(LLPointer((LLViewerInventoryCategory*)parent));
- }
- }
- }
- }
- LLInventoryModel::saveToFile(filename, cats, items);
-}
-
-// static
-void LLLocalInventory::climb(LLInventoryCategory* cat,
- LLInventoryModel::cat_array_t& cats,
- LLInventoryModel::item_array_t& items)
-{
- LLInventoryModel* model = &gInventory;
-
- // Add this category
- cats.push_back(LLPointer((LLViewerInventoryCategory*)cat));
-
- LLInventoryModel::cat_array_t *direct_cats;
- LLInventoryModel::item_array_t *direct_items;
- model->getDirectDescendentsOf(cat->getUUID(), direct_cats, direct_items);
-
- // Add items
- LLInventoryModel::item_array_t::iterator item_iter = direct_items->begin();
- LLInventoryModel::item_array_t::iterator item_end = direct_items->end();
- for( ; item_iter != item_end; ++item_iter)
- {
- items.push_back(*item_iter);
- }
-
- // Do subcategories
- LLInventoryModel::cat_array_t::iterator cat_iter = direct_cats->begin();
- LLInventoryModel::cat_array_t::iterator cat_end = direct_cats->end();
- for( ; cat_iter != cat_end; ++cat_iter)
- {
- climb(*cat_iter, cats, items);
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-LLUUID LLFloaterNewLocalInventory::sLastCreatorId = LLUUID::null;
-
-LLFloaterNewLocalInventory::LLFloaterNewLocalInventory()
-: LLFloater()
-{
- LLUICtrlFactory::getInstance()->buildFloater(this, "floater_new_local_inventory.xml");
-}
-
-LLFloaterNewLocalInventory::~LLFloaterNewLocalInventory()
-{
-}
-
-BOOL LLFloaterNewLocalInventory::postBuild(void)
-{
- // Fill in default values
-
- getChild("creator_id_line")->setText(std::string("00000000-0000-0000-0000-000000000000"));
- getChild("owner_id_line")->setText(gAgent.getID().asString());
- getChild("asset_id_line")->setText(std::string("00000000-0000-0000-0000-000000000000"));
- getChild("name_line")->setText(std::string(""));
- getChild("desc_line")->setText(std::string(""));
-
- // Set up callbacks
-
- childSetAction("ok_btn", onClickOK, this);
-
- return TRUE;
-}
-
-// static
-void LLFloaterNewLocalInventory::onClickOK(void* user_data)
-{
- LLFloaterNewLocalInventory* floater = (LLFloaterNewLocalInventory*)user_data;
-
- LLUUID item_id;
- item_id.generate();
-
- std::string name = floater->getChild("name_line")->getText();
- std::string desc = floater->getChild("desc_line")->getText();
- LLUUID asset_id = LLUUID(floater->getChild("asset_id_line")->getText());
- LLUUID creator_id = LLUUID(floater->getChild("creator_id_line")->getText());
- LLUUID owner_id = LLUUID(floater->getChild("owner_id_line")->getText());
-
- LLAssetType::EType type = LLAssetType::lookup(floater->getChild("type_combo")->getValue().asString());
- LLInventoryType::EType inv_type = LLInventoryType::IT_CALLINGCARD;
- switch(type)
- {
- case LLAssetType::AT_TEXTURE:
- case LLAssetType::AT_TEXTURE_TGA:
- case LLAssetType::AT_IMAGE_TGA:
- case LLAssetType::AT_IMAGE_JPEG:
- inv_type = LLInventoryType::IT_TEXTURE;
- break;
- case LLAssetType::AT_SOUND:
- case LLAssetType::AT_SOUND_WAV:
- inv_type = LLInventoryType::IT_SOUND;
- break;
- case LLAssetType::AT_CALLINGCARD:
- inv_type = LLInventoryType::IT_CALLINGCARD;
- break;
- case LLAssetType::AT_LANDMARK:
- inv_type = LLInventoryType::IT_LANDMARK;
- break;
- case LLAssetType::AT_SCRIPT:
- inv_type = LLInventoryType::IT_LSL;
- break;
- case LLAssetType::AT_CLOTHING:
- inv_type = LLInventoryType::IT_WEARABLE;
- break;
- case LLAssetType::AT_OBJECT:
- inv_type = LLInventoryType::IT_OBJECT;
- break;
- case LLAssetType::AT_NOTECARD:
- inv_type = LLInventoryType::IT_NOTECARD;
- break;
- case LLAssetType::AT_CATEGORY:
- inv_type = LLInventoryType::IT_CATEGORY;
- break;
- case LLAssetType::AT_ROOT_CATEGORY:
- case LLAssetType::AT_TRASH:
- case LLAssetType::AT_SNAPSHOT_CATEGORY:
- case LLAssetType::AT_LOST_AND_FOUND:
- inv_type = LLInventoryType::IT_ROOT_CATEGORY;
- break;
- case LLAssetType::AT_LSL_TEXT:
- case LLAssetType::AT_LSL_BYTECODE:
- inv_type = LLInventoryType::IT_LSL;
- break;
- case LLAssetType::AT_BODYPART:
- inv_type = LLInventoryType::IT_WEARABLE;
- break;
- case LLAssetType::AT_ANIMATION:
- inv_type = LLInventoryType::IT_ANIMATION;
- break;
- case LLAssetType::AT_GESTURE:
- inv_type = LLInventoryType::IT_GESTURE;
- break;
- case LLAssetType::AT_SIMSTATE:
- default:
- inv_type = LLInventoryType::IT_CALLINGCARD;
- break;
- }
-
-
- LLPermissions* perms = new LLPermissions();
- perms->init(creator_id, owner_id, LLUUID::null, LLUUID::null);
-
- LLViewerInventoryItem* item = new LLViewerInventoryItem(
- item_id,
- gLocalInventoryRoot,
- *perms,
- asset_id,
- type,
- inv_type,
- name,
- desc,
- LLSaleInfo::DEFAULT,
- 0,
- 0);
-
- LLLocalInventory::addItem(item);
- if(floater->childGetValue("chk_open"))
- {
- LLLocalInventory::open(item_id);
- }
-
- LLFloaterNewLocalInventory::sLastCreatorId = creator_id;
- floater->close();
-}
-
-
-
-//
+//
+#include "llviewerprecompiledheaders.h"
+
+#include "lllocalinventory.h"
+
+#include "llviewerinventory.h"
+#include "llviewercontrol.h"
+
+#include "llpreviewsound.h"
+#include "llpreviewanim.h"
+#include "llpreviewtexture.h"
+#include "llpreviewgesture.h"
+#include "llpreviewlandmark.h"
+#include "dofloaterhex.h"
+#include "hgfloatertexteditor.h"
+
+#include "llappviewer.h"
+
+#include "lluictrlfactory.h"
+#include "llcombobox.h"
+
+#include "llagent.h" // gAgent
+#include "llviewerwindow.h" // alertXml
+
+
+LLUUID LLLocalInventory::addItem(std::string name, int type, LLUUID asset_id, bool open_automatically)
+{
+ LLUUID item_id = addItem(name, type, asset_id);
+ if(open_automatically) open(item_id);
+ return item_id;
+}
+
+LLUUID LLLocalInventory::addItem(std::string name, int type, LLUUID asset_id)
+{
+ LLUUID item_id;
+ item_id.generate();
+ LLPermissions* perms = new LLPermissions();
+ perms->set(LLPermissions::DEFAULT);
+ perms->setOwnerAndGroup(LLUUID::null, LLUUID::null, LLUUID::null, false);
+ perms->setMaskBase(0);
+ perms->setMaskEveryone(0);
+ perms->setMaskGroup(0);
+ perms->setMaskNext(0);
+ perms->setMaskOwner(0);
+ LLViewerInventoryItem* item = new LLViewerInventoryItem(
+ item_id,
+ gLocalInventoryRoot,
+ *perms,
+ asset_id,
+ (LLAssetType::EType)type,
+ (LLInventoryType::EType)type,
+ name,
+ "",
+ LLSaleInfo::DEFAULT,
+ 0,
+ 0);
+ addItem(item);
+ return item_id;
+}
+
+void LLLocalInventory::addItem(LLViewerInventoryItem* item)
+{
+ //gInventory.addPretendItem(item);
+ LLInventoryModel::update_map_t update;
+ ++update[item->getParentUUID()];
+ gInventory.accountForUpdate(update);
+ gInventory.updateItem(item);
+ gInventory.notifyObservers();
+}
+
+void LLLocalInventory::open(LLUUID item_id)
+{
+ LLViewerInventoryItem* item = gInventory.getItem(item_id);
+ if(!item)
+ {
+ llwarns << "Trying to open non-existent item" << llendl;
+ return;
+ }
+
+ LLAssetType::EType type = item->getType();
+
+ if(type == LLAssetType::AT_SOUND)
+ {
+ S32 left, top;
+ gFloaterView->getNewFloaterPosition(&left, &top);
+ LLRect rect = gSavedSettings.getRect("PreviewSoundRect");
+ rect.translate(left - rect.mLeft, top - rect.mTop);
+ LLPreviewSound* floaterp;
+ floaterp = new LLPreviewSound("Preview sound",
+ rect,
+ "",
+ item_id);
+ floaterp->setFocus(TRUE);
+ gFloaterView->adjustToFitScreen(floaterp, FALSE);
+ }
+ else if(type == LLAssetType::AT_ANIMATION)
+ {
+ S32 left, top;
+ gFloaterView->getNewFloaterPosition(&left, &top);
+ LLRect rect = gSavedSettings.getRect("PreviewAnimRect");
+ rect.translate(left - rect.mLeft, top - rect.mTop);
+ LLPreviewAnim* floaterp;
+ floaterp = new LLPreviewAnim("Preview anim",
+ rect,
+ "",
+ item_id,
+ 0);
+ floaterp->setFocus(TRUE);
+ gFloaterView->adjustToFitScreen(floaterp, FALSE);
+ }
+ else if(type == LLAssetType::AT_TEXTURE)
+ {
+ S32 left, top;
+ gFloaterView->getNewFloaterPosition(&left, &top);
+ LLRect rect = gSavedSettings.getRect("PreviewTextureRect");
+ rect.translate( left - rect.mLeft, top - rect.mTop );
+
+ LLPreviewTexture* preview;
+ preview = new LLPreviewTexture("preview texture",
+ rect,
+ "Preview texture",
+ item_id,
+ LLUUID::null,
+ FALSE);
+ //preview->setSourceID(source_id);
+ preview->setFocus(TRUE);
+
+ gFloaterView->adjustToFitScreen(preview, FALSE);
+ }
+ else if(type == LLAssetType::AT_GESTURE)
+ {
+ // If only the others were like this
+ LLPreviewGesture::show("preview gesture", item_id, LLUUID::null, TRUE);
+ }
+ else if(type == LLAssetType::AT_LANDMARK)
+ {
+ S32 left, top;
+ gFloaterView->getNewFloaterPosition(&left, &top);
+ LLRect rect = gSavedSettings.getRect("PreviewLandmarkRect");
+ rect.translate( left - rect.mLeft, top - rect.mTop );
+
+ LLPreviewLandmark* preview;
+ preview = new LLPreviewLandmark("preview landmark",
+ rect,
+ "Preview landmark",
+ item_id);
+ preview->setFocus(TRUE);
+
+ gFloaterView->adjustToFitScreen(preview, FALSE);
+ }
+ else
+ {
+ llwarns << "Dunno how to open type " << type << ", falling back to hex editor" << llendl;
+ DOFloaterHex::show(item_id);
+ }
+}
+
+//static
+void LLLocalInventory::loadInvCache(std::string filename)
+{
+ std::string extension = gDirUtilp->getExtension(filename);
+ std::string inv_filename = filename;
+ if(extension == "gz")
+ {
+ LLUUID random;
+ random.generate();
+ inv_filename = filename.substr(0, filename.length() - 3) + "." + random.asString();
+
+ if(!gunzip_file(filename, inv_filename))
+ {
+ // failure... message?
+ return;
+ }
+ }
+
+ int conflicting_cat_count = 0;
+ int conflicting_item_count = 0;
+ int conflicting_parent_count = 0;
+
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ if(LLInventoryModel::loadFromFile(inv_filename, cats, items))
+ {
+ // create a container category for everything
+ LLViewerInventoryCategory* container = new LLViewerInventoryCategory(gAgent.getID());
+ container->rename(gDirUtilp->getBaseFileName(filename, false));
+ LLUUID container_id;
+ container_id.generate();
+ container->setUUID(container_id);
+ container->setParent(gLocalInventoryRoot);
+ container->setPreferredType(LLAssetType::AT_NONE);
+ LLInventoryModel::update_map_t container_update;
+ ++container_update[container->getParentUUID()];
+ gInventory.accountForUpdate(container_update);
+ gInventory.updateCategory(container);
+ gInventory.notifyObservers();
+
+ // Add all categories
+ LLInventoryModel::cat_array_t::iterator cat_iter = cats.begin();
+ LLInventoryModel::cat_array_t::iterator cat_end = cats.end();
+ for(; cat_iter != cat_end; ++cat_iter)
+ {
+ // Conditionally change its parent
+ // Note: Should I search for missing parent id's?
+ if((*cat_iter)->getParentUUID().isNull())
+ {
+ (*cat_iter)->setParent(container_id);
+ }
+
+ // Avoid conflicts with real inventory...
+ // If this category already exists, ignore it
+ if(gInventory.getCategory((*cat_iter)->getUUID()))
+ {
+ conflicting_cat_count++;
+ continue;
+ }
+ // If the parent exists and outside of pretend inventory, ignore it
+ if(gInventory.getCategory((*cat_iter)->getParentUUID()))
+ {
+ if(!gInventory.isObjectDescendentOf((*cat_iter)->getParentUUID(), gLocalInventoryRoot))
+ {
+ conflicting_parent_count++;
+ continue;
+ }
+ }
+
+ LLInventoryModel::update_map_t update;
+ ++update[(*cat_iter)->getParentUUID()];
+ gInventory.accountForUpdate(update);
+ gInventory.updateCategory(*cat_iter);
+ gInventory.notifyObservers();
+ }
+
+ // Add all items
+ LLInventoryModel::item_array_t::iterator item_iter = items.begin();
+ LLInventoryModel::item_array_t::iterator item_end = items.end();
+ for(; item_iter != item_end; ++item_iter)
+ {
+ // Conditionally change its parent
+ // Note: Should I search for missing parent id's?
+ if((*item_iter)->getParentUUID().isNull())
+ {
+ (*item_iter)->setParent(container_id);
+ }
+
+ // Avoid conflicts with real inventory...
+ // If this item id already exists, ignore it
+ if(gInventory.getItem((*item_iter)->getUUID()))
+ {
+ conflicting_item_count++;
+ continue;
+ }
+ // If the parent exists and outside of pretend inventory, ignore it
+ if(gInventory.getCategory((*item_iter)->getParentUUID()))
+ {
+ if(!gInventory.isObjectDescendentOf((*item_iter)->getParentUUID(), gLocalInventoryRoot))
+ {
+ conflicting_parent_count++;
+ continue;
+ }
+ }
+
+ LLInventoryModel::update_map_t update;
+ ++update[(*item_iter)->getParentUUID()];
+ gInventory.accountForUpdate(update);
+ gInventory.updateItem(*item_iter);
+ gInventory.notifyObservers();
+ }
+ }
+
+ // remove temporary unzipped file
+ if(extension == "gz")
+ {
+ LLFile::remove(inv_filename);
+ }
+
+ // Quality time
+ if(conflicting_cat_count || conflicting_item_count || conflicting_parent_count)
+ {
+ std::ostringstream message;
+ message << "Some items were ignored due to conflicts:\n\n";
+ if(conflicting_cat_count) message << conflicting_cat_count << " folders\n";
+ if(conflicting_item_count) message << conflicting_item_count << " items\n";
+ if(conflicting_parent_count) message << conflicting_parent_count << " parents\n";
+ LLSD args;
+ args["ERROR_MESSAGE"] = message.str();
+ LLNotifications::instance().add("ErrorMessage", args);
+ }
+}
+
+//static
+void LLLocalInventory::saveInvCache(std::string filename, LLFolderView* folder)
+{
+ LLInventoryModel* model = &gInventory;
+ std::set selected_items;
+ folder->getSelectionList(selected_items);
+ if(selected_items.size() < 1)
+ {
+ // No items selected? Wtfboom
+ return;
+ }
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ // Make complete lists of child categories and items
+ std::set::iterator sel_iter = selected_items.begin();
+ std::set::iterator sel_end = selected_items.end();
+ for( ; sel_iter != sel_end; ++sel_iter)
+ {
+ LLInventoryCategory* cat = model->getCategory(*sel_iter);
+ if(cat)
+ {
+ climb(cat, cats, items);
+ }
+ }
+ // And what about items inside a folder that wasn't selected?
+ // I guess I will just add selected items, so long as they aren't already added
+ for(sel_iter = selected_items.begin(); sel_iter != sel_end; ++sel_iter)
+ {
+ LLInventoryItem* item = model->getItem(*sel_iter);
+ if(item)
+ {
+ if(std::find(items.begin(), items.end(), item) == items.end())
+ {
+ items.push_back(LLPointer((LLViewerInventoryItem*)item));
+ LLInventoryCategory* parent = model->getCategory(item->getParentUUID());
+ if(std::find(cats.begin(), cats.end(), parent) == cats.end())
+ {
+ cats.push_back(LLPointer((LLViewerInventoryCategory*)parent));
+ }
+ }
+ }
+ }
+ LLInventoryModel::saveToFile(filename, cats, items);
+}
+
+// static
+void LLLocalInventory::climb(LLInventoryCategory* cat,
+ LLInventoryModel::cat_array_t& cats,
+ LLInventoryModel::item_array_t& items)
+{
+ LLInventoryModel* model = &gInventory;
+
+ // Add this category
+ cats.push_back(LLPointer((LLViewerInventoryCategory*)cat));
+
+ LLInventoryModel::cat_array_t *direct_cats;
+ LLInventoryModel::item_array_t *direct_items;
+ model->getDirectDescendentsOf(cat->getUUID(), direct_cats, direct_items);
+
+ // Add items
+ LLInventoryModel::item_array_t::iterator item_iter = direct_items->begin();
+ LLInventoryModel::item_array_t::iterator item_end = direct_items->end();
+ for( ; item_iter != item_end; ++item_iter)
+ {
+ items.push_back(*item_iter);
+ }
+
+ // Do subcategories
+ LLInventoryModel::cat_array_t::iterator cat_iter = direct_cats->begin();
+ LLInventoryModel::cat_array_t::iterator cat_end = direct_cats->end();
+ for( ; cat_iter != cat_end; ++cat_iter)
+ {
+ climb(*cat_iter, cats, items);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+LLUUID LLFloaterNewLocalInventory::sLastCreatorId = LLUUID::null;
+
+LLFloaterNewLocalInventory::LLFloaterNewLocalInventory()
+: LLFloater()
+{
+ LLUICtrlFactory::getInstance()->buildFloater(this, "floater_new_local_inventory.xml");
+}
+
+LLFloaterNewLocalInventory::~LLFloaterNewLocalInventory()
+{
+}
+
+BOOL LLFloaterNewLocalInventory::postBuild(void)
+{
+ // Fill in default values
+
+ getChild("creator_id_line")->setText(std::string("00000000-0000-0000-0000-000000000000"));
+ getChild("owner_id_line")->setText(gAgent.getID().asString());
+ getChild("asset_id_line")->setText(std::string("00000000-0000-0000-0000-000000000000"));
+ getChild("name_line")->setText(std::string(""));
+ getChild("desc_line")->setText(std::string(""));
+
+ // Set up callbacks
+
+ childSetAction("ok_btn", onClickOK, this);
+
+ return TRUE;
+}
+
+// static
+void LLFloaterNewLocalInventory::onClickOK(void* user_data)
+{
+ LLFloaterNewLocalInventory* floater = (LLFloaterNewLocalInventory*)user_data;
+
+ LLUUID item_id;
+ item_id.generate();
+
+ std::string name = floater->getChild("name_line")->getText();
+ std::string desc = floater->getChild("desc_line")->getText();
+ LLUUID asset_id = LLUUID(floater->getChild("asset_id_line")->getText());
+ LLUUID creator_id = LLUUID(floater->getChild("creator_id_line")->getText());
+ LLUUID owner_id = LLUUID(floater->getChild("owner_id_line")->getText());
+
+ LLAssetType::EType type = LLAssetType::lookup(floater->getChild("type_combo")->getValue().asString());
+ LLInventoryType::EType inv_type = LLInventoryType::IT_CALLINGCARD;
+ switch(type)
+ {
+ case LLAssetType::AT_TEXTURE:
+ case LLAssetType::AT_TEXTURE_TGA:
+ case LLAssetType::AT_IMAGE_TGA:
+ case LLAssetType::AT_IMAGE_JPEG:
+ inv_type = LLInventoryType::IT_TEXTURE;
+ break;
+ case LLAssetType::AT_SOUND:
+ case LLAssetType::AT_SOUND_WAV:
+ inv_type = LLInventoryType::IT_SOUND;
+ break;
+ case LLAssetType::AT_CALLINGCARD:
+ inv_type = LLInventoryType::IT_CALLINGCARD;
+ break;
+ case LLAssetType::AT_LANDMARK:
+ inv_type = LLInventoryType::IT_LANDMARK;
+ break;
+ case LLAssetType::AT_SCRIPT:
+ inv_type = LLInventoryType::IT_LSL;
+ break;
+ case LLAssetType::AT_CLOTHING:
+ inv_type = LLInventoryType::IT_WEARABLE;
+ break;
+ case LLAssetType::AT_OBJECT:
+ inv_type = LLInventoryType::IT_OBJECT;
+ break;
+ case LLAssetType::AT_NOTECARD:
+ inv_type = LLInventoryType::IT_NOTECARD;
+ break;
+ case LLAssetType::AT_CATEGORY:
+ inv_type = LLInventoryType::IT_CATEGORY;
+ break;
+ case LLAssetType::AT_ROOT_CATEGORY:
+ case LLAssetType::AT_TRASH:
+ case LLAssetType::AT_SNAPSHOT_CATEGORY:
+ case LLAssetType::AT_LOST_AND_FOUND:
+ inv_type = LLInventoryType::IT_ROOT_CATEGORY;
+ break;
+ case LLAssetType::AT_LSL_TEXT:
+ case LLAssetType::AT_LSL_BYTECODE:
+ inv_type = LLInventoryType::IT_LSL;
+ break;
+ case LLAssetType::AT_BODYPART:
+ inv_type = LLInventoryType::IT_WEARABLE;
+ break;
+ case LLAssetType::AT_ANIMATION:
+ inv_type = LLInventoryType::IT_ANIMATION;
+ break;
+ case LLAssetType::AT_GESTURE:
+ inv_type = LLInventoryType::IT_GESTURE;
+ break;
+ case LLAssetType::AT_SIMSTATE:
+ default:
+ inv_type = LLInventoryType::IT_CALLINGCARD;
+ break;
+ }
+
+
+ LLPermissions* perms = new LLPermissions();
+ perms->init(creator_id, owner_id, LLUUID::null, LLUUID::null);
+
+ LLViewerInventoryItem* item = new LLViewerInventoryItem(
+ item_id,
+ gLocalInventoryRoot,
+ *perms,
+ asset_id,
+ type,
+ inv_type,
+ name,
+ desc,
+ LLSaleInfo::DEFAULT,
+ 0,
+ 0);
+
+ LLLocalInventory::addItem(item);
+ if(floater->childGetValue("chk_open"))
+ {
+ LLLocalInventory::open(item_id);
+ }
+
+ LLFloaterNewLocalInventory::sLastCreatorId = creator_id;
+ floater->close();
+}
+
+
+
+//
diff --git a/indra/newview/lllocalinventory.h b/indra/newview/lllocalinventory.h
index 630605a70..4159918f8 100644
--- a/indra/newview/lllocalinventory.h
+++ b/indra/newview/lllocalinventory.h
@@ -1,45 +1,45 @@
-//
-#ifndef LL_LLLOCALINVENTORY_H
-#define LL_LLLOCALINVENTORY_H
-
-#include "llviewerinventory.h"
-
-#include "llfloater.h"
-
-#include "llfolderview.h"
-#include "llinventorymodel.h" // cat_array_t, item_array_t
-
-class LLLocalInventory
-{
-public:
- static LLUUID addItem(std::string name, int type, LLUUID asset_id, bool open);
- static LLUUID addItem(std::string name, int type, LLUUID asset_id);
- static void addItem(LLViewerInventoryItem* item);
- static void open(LLUUID item_id);
- static void loadInvCache(std::string filename);
- static void saveInvCache(std::string filename, LLFolderView* folder);
- static void climb(LLInventoryCategory* cat,
- LLInventoryModel::cat_array_t& cats,
- LLInventoryModel::item_array_t& items);
-};
-
-
-
-
-class LLFloaterNewLocalInventory
-: public LLFloater
-{
-public:
- LLFloaterNewLocalInventory();
- BOOL postBuild(void);
-
- static void onClickOK(void* user_data);
- static LLUUID sLastCreatorId;
-
-private:
- virtual ~LLFloaterNewLocalInventory();
-
-};
-
-#endif
-//
+//
+#ifndef LL_LLLOCALINVENTORY_H
+#define LL_LLLOCALINVENTORY_H
+
+#include "llviewerinventory.h"
+
+#include "llfloater.h"
+
+#include "llfolderview.h"
+#include "llinventorymodel.h" // cat_array_t, item_array_t
+
+class LLLocalInventory
+{
+public:
+ static LLUUID addItem(std::string name, int type, LLUUID asset_id, bool open);
+ static LLUUID addItem(std::string name, int type, LLUUID asset_id);
+ static void addItem(LLViewerInventoryItem* item);
+ static void open(LLUUID item_id);
+ static void loadInvCache(std::string filename);
+ static void saveInvCache(std::string filename, LLFolderView* folder);
+ static void climb(LLInventoryCategory* cat,
+ LLInventoryModel::cat_array_t& cats,
+ LLInventoryModel::item_array_t& items);
+};
+
+
+
+
+class LLFloaterNewLocalInventory
+: public LLFloater
+{
+public:
+ LLFloaterNewLocalInventory();
+ BOOL postBuild(void);
+
+ static void onClickOK(void* user_data);
+ static LLUUID sLastCreatorId;
+
+private:
+ virtual ~LLFloaterNewLocalInventory();
+
+};
+
+#endif
+//
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 7c6573c4f..7d654aef2 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -254,9 +254,9 @@ LLViewerObject::~LLViewerObject()
{
if(iter->second != NULL)
{
- //
- // There was a crash here
- //
+ //
+ // There was a crash here
+ //
delete iter->second->data;
delete iter->second;
}
@@ -1880,11 +1880,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
if ( gShowObjectUpdates )
{
- // We want to see updates from our own avatar
- //if (!((mPrimitiveCode == LL_PCODE_LEGACY_AVATAR) && (((LLVOAvatar *) this)->mIsSelf))
- // && mRegionp)
- if(mRegionp)
- //
+ // We want to see updates from our own avatar
+ //if (!((mPrimitiveCode == LL_PCODE_LEGACY_AVATAR) && (((LLVOAvatar *) this)->mIsSelf))
+ // && mRegionp)
+ if(mRegionp)
+ //
{
LLViewerObject* object = gObjectList.createObjectViewer(LL_PCODE_LEGACY_TEXT_BUBBLE, mRegionp);
LLVOTextBubble* bubble = (LLVOTextBubble*) object;
@@ -1935,11 +1935,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
if (needs_refresh)
{
- //
- if(isChanged(MOVED)) // Update "center" if this or children are selected,
- // and translate, scale, or rotate occurred on this.
- // Leave dialog refresh to happen always, as before.
- //
+ //
+ if(isChanged(MOVED)) // Update "center" if this or children are selected,
+ // and translate, scale, or rotate occurred on this.
+ // Leave dialog refresh to happen always, as before.
+ //
LLSelectMgr::getInstance()->updateSelectionCenter();
dialog_refresh_all();
}
@@ -4087,14 +4087,14 @@ void LLViewerObject::setDebugText(const std::string &utf8text)
mText->setDoFade(FALSE);
updateText();
}
-//
-std::string LLViewerObject::getDebugText()
-{
- if(mText)
- return mText->getStringUTF8();
- return "";
-}
-//
+//
+std::string LLViewerObject::getDebugText()
+{
+ if(mText)
+ return mText->getStringUTF8();
+ return "";
+}
+//
void LLViewerObject::setIcon(LLViewerImage* icon_image)
{
@@ -5161,19 +5161,19 @@ void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplif
}
-//
-S32 LLViewerObject::getAttachmentPoint()
-{
- return ((S32)((((U8)mState & AGENT_ATTACH_MASK) >> 4) | (((U8)mState & ~AGENT_ATTACH_MASK) << 4)));
-}
-
-std::string LLViewerObject::getAttachmentPointName()
-{
- S32 point = getAttachmentPoint();
- if((point > 0) && (point < 39))
- {
- return gAgent.getAvatarObject()->mAttachmentPoints[point]->getName();
- }
- return llformat("unsupported point %d", point);
-}
-//
+//
+S32 LLViewerObject::getAttachmentPoint()
+{
+ return ((S32)((((U8)mState & AGENT_ATTACH_MASK) >> 4) | (((U8)mState & ~AGENT_ATTACH_MASK) << 4)));
+}
+
+std::string LLViewerObject::getAttachmentPointName()
+{
+ S32 point = getAttachmentPoint();
+ if((point > 0) && (point < 39))
+ {
+ return gAgent.getAvatarObject()->mAttachmentPoints[point]->getName();
+ }
+ return llformat("unsupported point %d", point);
+}
+//
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 762576ed6..ace0c2354 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -353,9 +353,9 @@ public:
void setCanSelect(BOOL canSelect);
void setDebugText(const std::string &utf8text);
- //
- std::string getDebugText();
- //
+ //
+ std::string getDebugText();
+ //
void setIcon(LLViewerImage* icon_image);
void clearIcon();
@@ -662,11 +662,11 @@ protected:
private:
static S32 sNumObjects;
-//
-public:
- S32 getAttachmentPoint();
- std::string getAttachmentPointName();
-//
+//
+public:
+ S32 getAttachmentPoint();
+ std::string getAttachmentPointName();
+//
};
///////////////////
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f29850df1..a4719e76c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -83,9 +83,9 @@
#include "llvoiceclient.h"
#include "llvoicevisualizer.h" // Ventrella
-//
-#include "llfloaterexploreanimations.h"
-//#include "llao.h"
+//
+#include "llfloaterexploreanimations.h"
+//#include "llao.h"
//
#if LL_MSVC
@@ -754,12 +754,12 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mUpdatePeriod(1),
mFullyLoadedInitialized(FALSE),
mHasBakedHair( FALSE )
- //
-// mNametagSaysIdle(false),
-// mIdleForever(true),
-// mIdleMinutes(0),
-// mFocusObject(LLUUID::null),
-// mFocusVector(LLVector3d::zero)
+ //
+// mNametagSaysIdle(false),
+// mIdleForever(true),
+// mIdleMinutes(0),
+// mFocusObject(LLUUID::null),
+// mFocusVector(LLVector3d::zero)
//
{
LLMemType mt(LLMemType::MTYPE_AVATAR);
@@ -3072,11 +3072,11 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
mNameText->setUseBubble(TRUE);
sNumVisibleChatBubbles++;
new_name = TRUE;
- }
-
- //
- //LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" );
- //avatar_name_color.setAlpha(alpha);
+ }
+
+ //
+ //LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" );
+ //avatar_name_color.setAlpha(alpha);
LLQuaternion root_rot = mRoot.getWorldRotation();
mNameText->setUsePixelSize(TRUE);
@@ -3157,108 +3157,106 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
line += lastname->getString();
BOOL need_comma = FALSE;
- BOOL need_comma = FALSE;
-
- //
- if(getTEImage(TEX_HEAD_BODYPAINT)->isMissingAsset())
- {
- mNameText->setColor(LLColor4(1.f, 1.0f, 1.0f));
- strcat(line, " (Unknown viewer)");
- }
- else
- {
- std::string uuid_str = getTEImage(TEX_HEAD_BODYPAINT)->getID().asString();
-
- if(uuid_str == "ccda2b3b-e72c-a112-e126-fee238b67218")
- {
- // textures other than head are 4934f1bf-3b1f-cf4f-dbdf-a72550d05bc6
- mNameText->setColor(LLColor4(0.f, 1.0f, 0.0f));
- strcat(line, " (Emerald)");
- }
- else if(uuid_str == "0bcd5f5d-a4ce-9ea4-f9e8-15132653b3d8")
- {
- mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
- strcat(line, " (MoyMix)");
- }
- else if(uuid_str == "5855f37d-63e5-3918-1404-8ffa3820eb6d")
- {
- mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
- strcat(line, " (MoyMix/B)");
- }
- else if(uuid_str == "9ba526b6-f43d-6b60-42de-ce62a25ee7fb")
- {
- mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
- strcat(line, " (MoyMix/nolife)");
- }
- //else if(uuid_str == "abbca853-30ba-49c1-a1e7-2a5b9a70573f")
- //{
- // mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
- // strcat(line, " (CryoLife/" + "A)");
- //}
- else if(uuid_str == "0f6723d2-5b23-6b58-08ab-308112b33786")
- {
- mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
- strcat(line, " (CryoLife)");
- }
- else if(uuid_str == "2c9c1e0b-e5d1-263e-16b1-7fc6d169f3d6")
- {
- mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
- strcat(line, " (Phoxy SL)");
- }
- else if(uuid_str == "c252d89d-6f7c-7d90-f430-d140d2e3fbbe")
- {
- mNameText->setColor(LLColor4(0.7f, 0.7f, 0.7f));
- strcat(line, " (VLife)");
- }
- else if(uuid_str == "5aa5c70d-d787-571b-0495-4fc1bdef1500")
- {
- mNameText->setColor(LLColor4(1.f, 0.0f, 0.0f));
- strcat(line, " (GridProxy/LordGregGreg)");
- }
- else if(uuid_str == "8183e823-c443-2142-6eb6-2ab763d4f81c")
- {
- mNameText->setColor(LLColor4(1.f, 1.f, 0.0f));
- strcat(line, " (GridProxy/DayOh)");
- }
- else if(uuid_str == "f3fd74a6-fee7-4b2f-93ae-ddcb5991da04")
- {
- mNameText->setColor(LLColor4(1.0f, 0.0f, 1.0f));
- strcat(line, " (PSL/A)");
- }
- else if(uuid_str == "77662f23-c77a-9b4d-5558-26b757b2144c")
- {
- mNameText->setColor(LLColor4(1.0f, 0.0f, 1.0f));
- strcat(line, " (PSL/B)");
- }
- else if(uuid_str == "1c29480c-c608-df87-28bb-964fb64c5366")
- {
- mNameText->setColor(LLColor4(1.f, 1.0f, 1.0f));
- strcat(line, " (Emerald/GEMINI)");
- }
- else if(uuid_str == "5262d71a-88f7-ef40-3b15-00ea148ab4b5")
- {
- mNameText->setColor(LLColor4(0.9f, 0.9f, 0.9f));
- strcat(line, " (GEMINI Bot)");
- }
- else if(uuid_str == "adcbe893-7643-fd12-f61c-0b39717e2e32")
- {
- mNameText->setColor(LLColor4(1.0f, 0.5f, 0.4f));
- strcat(line, " (tyk3n)");
- }
- else if(uuid_str == "f5a48821-9a98-d09e-8d6a-50cc08ba9a47")
- {
- mNameText->setColor(gColors.getColor( "AvatarNameColor" ));
- strcat(line, " (NeilLife)");
- }
-
- else
- {
- LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" );
- avatar_name_color.setAlpha(1.f);
- mNameText->setColor(avatar_name_color);
- }
- }
- //
+ //
+ if(getTEImage(TEX_HEAD_BODYPAINT)->isMissingAsset())
+ {
+ mNameText->setColor(LLColor4(1.f, 1.0f, 1.0f));
+ line += " (Unknown viewer)";
+ }
+ else
+ {
+ std::string uuid_str = getTEImage(TEX_HEAD_BODYPAINT)->getID().asString();
+
+ if(uuid_str == "ccda2b3b-e72c-a112-e126-fee238b67218")
+ {
+ // textures other than head are 4934f1bf-3b1f-cf4f-dbdf-a72550d05bc6
+ mNameText->setColor(LLColor4(0.f, 1.0f, 0.0f));
+ line += " (Emerald)";
+ }
+ else if(uuid_str == "0bcd5f5d-a4ce-9ea4-f9e8-15132653b3d8")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
+ line += " (MoyMix)";
+ }
+ else if(uuid_str == "5855f37d-63e5-3918-1404-8ffa3820eb6d")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
+ line += " (MoyMix/B)";
+ }
+ else if(uuid_str == "9ba526b6-f43d-6b60-42de-ce62a25ee7fb")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.3f, 0.5f));
+ line += " (MoyMix/nolife)";
+ }
+ //else if(uuid_str == "abbca853-30ba-49c1-a1e7-2a5b9a70573f")
+ //{
+ // mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
+ // strcat(line, " (CryoLife/" + "A)");
+ //}
+ else if(uuid_str == "0f6723d2-5b23-6b58-08ab-308112b33786")
+ {
+ mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
+ line += " (CryoLife)";
+ }
+ else if(uuid_str == "2c9c1e0b-e5d1-263e-16b1-7fc6d169f3d6")
+ {
+ mNameText->setColor(LLColor4(0.5f, 0.75f, 1.0f));
+ line += " (Phoxy SL)";
+ }
+ else if(uuid_str == "c252d89d-6f7c-7d90-f430-d140d2e3fbbe")
+ {
+ mNameText->setColor(LLColor4(0.7f, 0.7f, 0.7f));
+ line += " (VLife)";
+ }
+ else if(uuid_str == "5aa5c70d-d787-571b-0495-4fc1bdef1500")
+ {
+ mNameText->setColor(LLColor4(1.f, 0.0f, 0.0f));
+ line += " (GridProxy/LordGregGreg)";
+ }
+ else if(uuid_str == "8183e823-c443-2142-6eb6-2ab763d4f81c")
+ {
+ mNameText->setColor(LLColor4(1.f, 1.f, 0.0f));
+ line += " (GridProxy/DayOh)";
+ }
+ else if(uuid_str == "f3fd74a6-fee7-4b2f-93ae-ddcb5991da04")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.0f, 1.0f));
+ line += " (PSL/A)";
+ }
+ else if(uuid_str == "77662f23-c77a-9b4d-5558-26b757b2144c")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.0f, 1.0f));
+ line += " (PSL/B)";
+ }
+ else if(uuid_str == "1c29480c-c608-df87-28bb-964fb64c5366")
+ {
+ mNameText->setColor(LLColor4(1.f, 1.0f, 1.0f));
+ line += " (Emerald/GEMINI)";
+ }
+ else if(uuid_str == "5262d71a-88f7-ef40-3b15-00ea148ab4b5")
+ {
+ mNameText->setColor(LLColor4(0.9f, 0.9f, 0.9f));
+ line += " (GEMINI Bot)";
+ }
+ else if(uuid_str == "adcbe893-7643-fd12-f61c-0b39717e2e32")
+ {
+ mNameText->setColor(LLColor4(1.0f, 0.5f, 0.4f));
+ line += " (tyk3n)";
+ }
+ else if(uuid_str == "f5a48821-9a98-d09e-8d6a-50cc08ba9a47")
+ {
+ mNameText->setColor(gColors.getColor( "AvatarNameColor" ));
+ line += " (NeilLife)";
+ }
+
+ else
+ {
+ LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" );
+ avatar_name_color.setAlpha(1.f);
+ mNameText->setColor(avatar_name_color);
+ }
+ }
+ //
if (is_away || is_muted || is_busy)
{
line += " (";
@@ -3417,11 +3415,11 @@ void LLVOAvatar::idleUpdateTractorBeam()
return;
}
- //
- if(gSavedSettings.getBOOL("DisablePointAtAndBeam"))
- {
- return;
- }
+ //
+ if(gSavedSettings.getBOOL("DisablePointAtAndBeam"))
+ {
+ return;
+ }
//
const LLPickInfo& pick = gViewerWindow->getLastPick();
@@ -4852,8 +4850,8 @@ void LLVOAvatar::processAnimationStateChanges()
if (found_anim == mSignaledAnimations.end())
{
processSingleAnimationStateChange(anim_it->first, FALSE);
- //
- LLFloaterExploreAnimations::stopAnim(getID(), anim_it->first);
+ //
+ LLFloaterExploreAnimations::stopAnim(getID(), anim_it->first);
//
mPlayingAnimations.erase(anim_it++);
continue;
@@ -4870,8 +4868,8 @@ void LLVOAvatar::processAnimationStateChanges()
// signaled but not playing, or different sequence id, start motion
if (found_anim == mPlayingAnimations.end() || found_anim->second != anim_it->second)
{
- //
- LLFloaterExploreAnimations::startAnim(getID(), anim_it->first);
+ //
+ LLFloaterExploreAnimations::startAnim(getID(), anim_it->first);
//
if (processSingleAnimationStateChange(anim_it->first, TRUE))
{
@@ -6112,43 +6110,43 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
// attachObject()
//-----------------------------------------------------------------------------
BOOL LLVOAvatar::attachObject(LLViewerObject *viewer_object)
-{
- LLViewerJointAttachment* attachment = getTargetAttachmentPoint(viewer_object);
-
- // testzone attachpt
- if(!attachment)
- {
- S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState());
- LLUUID item_id;
- LLNameValue* item_id_nv = viewer_object->getNVPair("AttachItemID");
- if( item_id_nv )
- {
- const char* s = item_id_nv->getString();
- if(s)
- item_id.set(s);
- }
- if(!item_id.isNull())
- {
- mUnsupportedAttachmentPoints[attachmentID] = item_id;
- if (viewer_object->isSelected())
- {
- LLSelectMgr::getInstance()->updateSelectionCenter();
- LLSelectMgr::getInstance()->updatePointAt();
- }
-
- if (mIsSelf)
- {
- updateAttachmentVisibility(gAgent.getCameraMode());
-
- // Then make sure the inventory is in sync with the avatar.
- gInventory.addChangedMask( LLInventoryObserver::LABEL, item_id );
- gInventory.notifyObservers();
- }
- }
- else
- llwarns << "No item ID" << llendl;
- }
- //
+{
+ LLViewerJointAttachment* attachment = getTargetAttachmentPoint(viewer_object);
+
+ // testzone attachpt
+ if(!attachment)
+ {
+ S32 attachmentID = ATTACHMENT_ID_FROM_STATE(viewer_object->getState());
+ LLUUID item_id;
+ LLNameValue* item_id_nv = viewer_object->getNVPair("AttachItemID");
+ if( item_id_nv )
+ {
+ const char* s = item_id_nv->getString();
+ if(s)
+ item_id.set(s);
+ }
+ if(!item_id.isNull())
+ {
+ mUnsupportedAttachmentPoints[attachmentID] = item_id;
+ if (viewer_object->isSelected())
+ {
+ LLSelectMgr::getInstance()->updateSelectionCenter();
+ LLSelectMgr::getInstance()->updatePointAt();
+ }
+
+ if (mIsSelf)
+ {
+ updateAttachmentVisibility(gAgent.getCameraMode());
+
+ // Then make sure the inventory is in sync with the avatar.
+ gInventory.addChangedMask( LLInventoryObserver::LABEL, item_id );
+ gInventory.notifyObservers();
+ }
+ }
+ else
+ llwarns << "No item ID" << llendl;
+ }
+ //
if (!attachment || !attachment->addObject(viewer_object))
{
return FALSE;
@@ -6257,57 +6255,57 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
}
return TRUE;
}
- }
-
- // testzone attachpt
- LLUUID item_id;
- LLNameValue* item_id_nv = viewer_object->getNVPair("AttachItemID");
- if( item_id_nv )
- {
- const char* s = item_id_nv->getString();
- if(s)
- item_id.set(s);
- }
- if(!item_id.isNull())
- {
- std::map::iterator iter = mUnsupportedAttachmentPoints.begin();
- std::map::iterator end = mUnsupportedAttachmentPoints.end();
- for( ; iter != end; ++iter)
- {
- if((*iter).second == item_id)
- {
- mUnsupportedAttachmentPoints.erase((*iter).first);
- if (mIsSelf)
- {
- // the simulator should automatically handle
- // permission revocation
-
- stopMotionFromSource(viewer_object->getID());
- LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
-
- LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
- for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
- iter != child_list.end(); iter++)
- {
- LLViewerObject* child_objectp = *iter;
- // the simulator should automatically handle
- // permissions revocation
-
- stopMotionFromSource(child_objectp->getID());
- LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
- }
- // Then make sure the inventory is in sync with the avatar.
- gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
- gInventory.notifyObservers();
- }
- return TRUE;
- }
- }
- llwarns << "Not found" << llendl;
- }
- else
- llwarns << "No item ID" << llendl;
- //
+ }
+
+ // testzone attachpt
+ LLUUID item_id;
+ LLNameValue* item_id_nv = viewer_object->getNVPair("AttachItemID");
+ if( item_id_nv )
+ {
+ const char* s = item_id_nv->getString();
+ if(s)
+ item_id.set(s);
+ }
+ if(!item_id.isNull())
+ {
+ std::map::iterator iter = mUnsupportedAttachmentPoints.begin();
+ std::map::iterator end = mUnsupportedAttachmentPoints.end();
+ for( ; iter != end; ++iter)
+ {
+ if((*iter).second == item_id)
+ {
+ mUnsupportedAttachmentPoints.erase((*iter).first);
+ if (mIsSelf)
+ {
+ // the simulator should automatically handle
+ // permission revocation
+
+ stopMotionFromSource(viewer_object->getID());
+ LLFollowCamMgr::setCameraActive(viewer_object->getID(), FALSE);
+
+ LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
+ for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+ iter != child_list.end(); iter++)
+ {
+ LLViewerObject* child_objectp = *iter;
+ // the simulator should automatically handle
+ // permissions revocation
+
+ stopMotionFromSource(child_objectp->getID());
+ LLFollowCamMgr::setCameraActive(child_objectp->getID(), FALSE);
+ }
+ // Then make sure the inventory is in sync with the avatar.
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
+ gInventory.notifyObservers();
+ }
+ return TRUE;
+ }
+ }
+ llwarns << "Not found" << llendl;
+ }
+ else
+ llwarns << "No item ID" << llendl;
+ //
return FALSE;
}
@@ -6469,21 +6467,21 @@ BOOL LLVOAvatar::isWearingAttachment( const LLUUID& inv_item_id )
}
}
return FALSE;
-}
-
-// testzone attachpt
-BOOL LLVOAvatar::isWearingUnsupportedAttachment( const LLUUID& inv_item_id )
-{
- std::map::iterator end = mUnsupportedAttachmentPoints.end();
+}
+
+// testzone attachpt
+BOOL LLVOAvatar::isWearingUnsupportedAttachment( const LLUUID& inv_item_id )
+{
+ std::map::iterator end = mUnsupportedAttachmentPoints.end();
for(std::map::iterator iter = mUnsupportedAttachmentPoints.begin(); iter != end; ++iter)
- {
+ {
if((*iter).second == inv_item_id)
- {
+ {
return TRUE;
}
- }
+ }
return FALSE;
-}
+}
//-----------------------------------------------------------------------------
// getWornAttachment()
//-----------------------------------------------------------------------------
@@ -8733,11 +8731,11 @@ void LLVOAvatar::dumpLocalTextures()
llinfos << "LocTex " << name << ": "
<< "Discard " << image->getDiscardLevel() << ", "
- << "(" << image->getWidth() << ", " << image->getHeight() << ") "
-//
-//#if !LL_RELEASE_FOR_DOWNLOAD
-#if 1
-//
+ << "(" << image->getWidth() << ", " << image->getHeight() << ") "
+//
+//#if !LL_RELEASE_FOR_DOWNLOAD
+#if 1
+//
// End users don't get to trivially see avatar texture IDs,
// makes textures easier to steal
<< image->getID() << " "
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 3f1a8c8ce..16d5097f5 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -283,9 +283,9 @@ public:
void getOffObject();
BOOL isWearingAttachment( const LLUUID& inv_item_id );
- // testzone attachpt
- BOOL isWearingUnsupportedAttachment( const LLUUID& inv_item_id );
- //
+ // testzone attachpt
+ BOOL isWearingUnsupportedAttachment( const LLUUID& inv_item_id );
+ //
LLViewerObject* getWornAttachment( const LLUUID& inv_item_id );
const std::string getAttachedPointName(const LLUUID& inv_item_id);
@@ -685,15 +685,15 @@ protected:
public:
static void updateFreezeCounter(S32 counter = 0 );
//
-
-public:
- //bool mNametagSaysIdle;
- //bool mIdleForever;
- //LLFrameTimer mIdleTimer;
- //U32 mIdleMinutes;
- LLUUID mFocusObject;
- LLVector3d mFocusVector;
- //void resetIdleTime();
+
+public:
+ //bool mNametagSaysIdle;
+ //bool mIdleForever;
+ //LLFrameTimer mIdleTimer;
+ //U32 mIdleMinutes;
+ LLUUID mFocusObject;
+ LLVector3d mFocusVector;
+ //void resetIdleTime();
//
private:
@@ -722,7 +722,7 @@ private:
U32 mMaskTexName;
// Stores pointers to the joint meshes that this baked texture deals with
std::vector< LLViewerJointMesh * > mMeshes; // std::vector mJoints[i]->mMeshParts
-
+
};
typedef std::vector bakedtexturedata_vec_t;
bakedtexturedata_vec_t mBakedTextureData;
diff --git a/indra/tools/vstool/VSTool.csproj b/indra/tools/vstool/VSTool.csproj
index 24f1031f8..5d8764b6b 100644
--- a/indra/tools/vstool/VSTool.csproj
+++ b/indra/tools/vstool/VSTool.csproj
@@ -1,95 +1,95 @@
-
-
- Local
- 8.0.50727
- 2.0
- {96943E2D-1373-4617-A117-D0F997A94919}
- Debug
- AnyCPU
-
-
-
-
- VSTool
-
-
- JScript
- Grid
- IE50
- false
- Exe
- VSTool
- Always
- VSTool.VSToolMain
-
-
-
-
-
-
- .\
- false
- 285212672
- false
-
-
- DEBUG;TRACE
-
-
- true
- 4096
- false
-
-
- false
- false
- false
- false
- 4
- full
- prompt
-
-
- .\
- false
- 285212672
- false
-
-
- TRACE
-
-
- false
- 4096
- false
-
-
- true
- false
- false
- false
- 4
- none
- prompt
-
-
-
- System
-
-
- System.Data
-
-
-
-
- Code
-
-
-
-
-
-
-
-
-
+
+
+ Local
+ 8.0.50727
+ 2.0
+ {96943E2D-1373-4617-A117-D0F997A94919}
+ Debug
+ AnyCPU
+
+
+
+
+ VSTool
+
+
+ JScript
+ Grid
+ IE50
+ false
+ Exe
+ VSTool
+ Always
+ VSTool.VSToolMain
+
+
+
+
+
+
+ .\
+ false
+ 285212672
+ false
+
+
+ DEBUG;TRACE
+
+
+ true
+ 4096
+ false
+
+
+ false
+ false
+ false
+ false
+ 4
+ full
+ prompt
+
+
+ .\
+ false
+ 285212672
+ false
+
+
+ TRACE
+
+
+ false
+ 4096
+ false
+
+
+ true
+ false
+ false
+ false
+ 4
+ none
+ prompt
+
+
+
+ System
+
+
+ System.Data
+
+
+
+
+ Code
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/indra/tools/vstool/VSTool.sln b/indra/tools/vstool/VSTool.sln
index 885967180..543a0a2ef 100644
--- a/indra/tools/vstool/VSTool.sln
+++ b/indra/tools/vstool/VSTool.sln
@@ -1,19 +1,19 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSTool", "VSTool.csproj", "{96943E2D-1373-4617-A117-D0F997A94919}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {96943E2D-1373-4617-A117-D0F997A94919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {96943E2D-1373-4617-A117-D0F997A94919}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {96943E2D-1373-4617-A117-D0F997A94919}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {96943E2D-1373-4617-A117-D0F997A94919}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSTool", "VSTool.csproj", "{96943E2D-1373-4617-A117-D0F997A94919}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {96943E2D-1373-4617-A117-D0F997A94919}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {96943E2D-1373-4617-A117-D0F997A94919}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {96943E2D-1373-4617-A117-D0F997A94919}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {96943E2D-1373-4617-A117-D0F997A94919}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/indra/tools/vstool/main.cs b/indra/tools/vstool/main.cs
index cc268d59d..5c41c916e 100644
--- a/indra/tools/vstool/main.cs
+++ b/indra/tools/vstool/main.cs
@@ -1,711 +1,711 @@
-// Code about getting running instances visual studio
-// was borrowed from
-// http://www.codeproject.com/KB/cs/automatingvisualstudio.aspx
-
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Runtime.InteropServices.ComTypes;
-using Microsoft.CSharp;
-
-namespace VSTool
-{
- // The MessageFilter class comes from:
- // http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx
- // It allows vstool to get timing error messages from
- // visualstudio and handle them.
- public class MessageFilter : IOleMessageFilter
- {
- //
- // Class containing the IOleMessageFilter
- // thread error-handling functions.
-
- // Start the filter.
- public static void Register()
- {
- IOleMessageFilter newFilter = new MessageFilter();
- IOleMessageFilter oldFilter = null;
- CoRegisterMessageFilter(newFilter, out oldFilter);
- }
-
- // Done with the filter, close it.
- public static void Revoke()
- {
- IOleMessageFilter oldFilter = null;
- CoRegisterMessageFilter(null, out oldFilter);
- }
-
- //
- // IOleMessageFilter functions.
- // Handle incoming thread requests.
- int IOleMessageFilter.HandleInComingCall(int dwCallType,
- System.IntPtr hTaskCaller, int dwTickCount, System.IntPtr
- lpInterfaceInfo)
- {
- //Return the flag SERVERCALL_ISHANDLED.
- return 0;
- }
-
- // Thread call was rejected, so try again.
- int IOleMessageFilter.RetryRejectedCall(System.IntPtr
- hTaskCallee, int dwTickCount, int dwRejectType)
- {
- if (dwRejectType == 2)
- // flag = SERVERCALL_RETRYLATER.
- {
- // Retry the thread call immediately if return >=0 &
- // <100.
- return 99;
- }
- // Too busy; cancel call.
- return -1;
- }
-
- int IOleMessageFilter.MessagePending(System.IntPtr hTaskCallee,
- int dwTickCount, int dwPendingType)
- {
- //Return the flag PENDINGMSG_WAITDEFPROCESS.
- return 2;
- }
-
- // Implement the IOleMessageFilter interface.
- [DllImport("Ole32.dll")]
- private static extern int
- CoRegisterMessageFilter(IOleMessageFilter newFilter, out
- IOleMessageFilter oldFilter);
- }
-
- [ComImport(), Guid("00000016-0000-0000-C000-000000000046"),
- InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
- interface IOleMessageFilter
- {
- [PreserveSig]
- int HandleInComingCall(
- int dwCallType,
- IntPtr hTaskCaller,
- int dwTickCount,
- IntPtr lpInterfaceInfo);
-
- [PreserveSig]
- int RetryRejectedCall(
- IntPtr hTaskCallee,
- int dwTickCount,
- int dwRejectType);
-
- [PreserveSig]
- int MessagePending(
- IntPtr hTaskCallee,
- int dwTickCount,
- int dwPendingType);
- }
-
- class ViaCOM
- {
- public static object GetProperty(object from_obj, string prop_name)
- {
- try
- {
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- prop_name,
- BindingFlags.GetProperty, null,
- from_obj,
- null);
- }
- catch (Exception e)
- {
- Console.WriteLine("Error getting property: \"{0}\"", prop_name);
- Console.WriteLine(e.Message);
- throw e;
- }
- }
-
- public static object SetProperty(object from_obj, string prop_name, object new_value)
- {
- try
- {
- object[] args = { new_value };
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- prop_name,
- BindingFlags.DeclaredOnly |
- BindingFlags.Public |
- BindingFlags.NonPublic |
- BindingFlags.Instance |
- BindingFlags.SetProperty,
- null,
- from_obj,
- args);
- }
- catch (Exception e)
- {
- Console.WriteLine("Error setting property: \"{0}\"", prop_name);
- Console.WriteLine(e.Message);
- throw e;
- }
- }
-
- public static object CallMethod(object from_obj, string method_name, params object[] args)
- {
- try
- {
- Type objType = from_obj.GetType();
- return objType.InvokeMember(
- method_name,
- BindingFlags.DeclaredOnly |
- BindingFlags.Public |
- BindingFlags.NonPublic |
- BindingFlags.Instance |
- BindingFlags.InvokeMethod,
- null,
- from_obj,
- args);
- }
- catch (Exception e)
- {
- Console.WriteLine("Error calling method \"{0}\"", method_name);
- Console.WriteLine(e.Message);
- throw e;
- }
- }
- };
-
- ///
- /// The main entry point class for VSTool.
- ///
- class VSToolMain
- {
- #region Interop imports
- [DllImport("ole32.dll")]
- public static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable prot);
-
- [DllImport("ole32.dll")]
- public static extern int CreateBindCtx(int reserved, out IBindCtx ppbc);
- #endregion
-
- static System.Boolean ignore_case = true;
-
- static string solution_name = null;
- static bool use_new_vs = false;
- static Hashtable projectDict = new Hashtable();
- static string startup_project = null;
- static string config = null;
-
- static object dte = null;
- static object solution = null;
-
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static int Main(string[] args)
- {
- int retVal = 0;
- bool need_save = false;
-
- try
- {
- parse_command_line(args);
-
- Console.WriteLine("Editing solution: {0}", solution_name);
-
- bool found_open_solution = GetDTEAndSolution();
-
- if (dte == null || solution == null)
- {
- retVal = 1;
- }
- else
- {
- MessageFilter.Register();
-
- // Walk through all of the projects in the solution
- // and list the type of each project.
- foreach (DictionaryEntry p in projectDict)
- {
- string project_name = (string)p.Key;
- string working_dir = (string)p.Value;
- if (SetProjectWorkingDir(solution, project_name, working_dir))
- {
- need_save = true;
- }
- }
-
- if (config != null)
- {
- need_save = SetActiveConfig(config);
- }
-
- if (startup_project != null)
- {
- need_save = SetStartupProject(startup_project);
- }
-
- if (need_save)
- {
- if (found_open_solution == false)
- {
- ViaCOM.CallMethod(solution, "Close", null);
- }
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- retVal = 1;
- }
- finally
- {
- if (solution != null)
- {
- Marshal.ReleaseComObject(solution);
- solution = null;
- }
-
- if (dte != null)
- {
- Marshal.ReleaseComObject(dte);
- dte = null;
- }
-
- MessageFilter.Revoke();
- }
- return retVal;
- }
-
- public static bool parse_command_line(string[] args)
- {
- string options_desc =
- "--solution : MSVC solution name. (required)\n" +
- "--use_new_vs : Ignore running versions of visual studio.\n" +
- "--workingdir : Set working dir of a VC project.\n" +
- "--config : Set the active config for the solution.\n" +
- "--startup : Set the startup project for the solution.\n";
-
- try
- {
- // Command line param parsing loop.
- int i = 0;
- for (; i < args.Length; ++i)
- {
- if ("--solution" == args[i])
- {
- if (solution_name != null)
- {
- throw new ApplicationException("Found second --solution option");
- }
- solution_name = args[++i];
- }
- else if ("--use_new_vs" == args[i])
- {
- use_new_vs = true;
- }
-
- else if ("--workingdir" == args[i])
- {
- string project_name = args[++i];
- string working_dir = args[++i];
- projectDict.Add(project_name, working_dir);
- }
- else if ("--config" == args[i])
- {
- if (config != null)
- {
- throw new ApplicationException("Found second --config option");
- }
- config = args[++i];
- }
- else if ("--startup" == args[i])
- {
- if (startup_project != null)
- {
- throw new ApplicationException("Found second --startup option");
- }
- startup_project = args[++i];
- }
- else
- {
- throw new ApplicationException("Found unrecognized token on command line: " + args[i]);
- }
- }
-
- if (solution_name == null)
- {
- throw new ApplicationException("The --solution option is required.");
- }
- }
- catch(ApplicationException e)
- {
-
- Console.WriteLine("Oops! " + e.Message);
- Console.Write("Command line:");
- foreach (string arg in args)
- {
- Console.Write(" " + arg);
- }
- Console.Write("\n\n");
- Console.WriteLine("VSTool command line usage");
- Console.Write(options_desc);
- throw e;
- }
- return true;
- }
-
- public static bool GetDTEAndSolution()
- {
- bool found_open_solution = true;
-
- Console.WriteLine("Looking for existing VisualStudio instance...");
-
- // Get an instance of the currently running Visual Studio .NET IDE.
- // dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");
- string full_solution_name = System.IO.Path.GetFullPath(solution_name);
- if (false == use_new_vs)
- {
- dte = GetIDEInstance(full_solution_name);
- }
-
- if (dte == null)
- {
- try
- {
- Console.WriteLine(" Didn't find open solution, starting new background VisualStudio instance...");
- Console.WriteLine(" Reading .sln file version...");
- string version = GetSolutionVersion(full_solution_name);
-
- Console.WriteLine(" Using version: {0}...", version);
- string progid = GetVSProgID(version);
-
- Type objType = Type.GetTypeFromProgID(progid);
- dte = System.Activator.CreateInstance(objType);
- Console.WriteLine(" Reading solution: \"{0}\"", full_solution_name);
-
- solution = ViaCOM.GetProperty(dte, "Solution");
- object[] openArgs = { full_solution_name };
- ViaCOM.CallMethod(solution, "Open", openArgs);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- Console.WriteLine("Quitting do to error opening: {0}", full_solution_name);
- solution = null;
- dte = null;
- return found_open_solution;
- }
- found_open_solution = false;
- }
-
- if (solution == null)
- {
- solution = ViaCOM.GetProperty(dte, "Solution");
- }
-
- return found_open_solution;
- }
-
- ///
- /// Get the DTE object for the instance of Visual Studio IDE that has
- /// the specified solution open.
- ///
- /// The absolute filename of the solution
- /// Corresponding DTE object or null if no such IDE is running
- public static object GetIDEInstance( string solutionFile )
- {
- Hashtable runningInstances = GetIDEInstances( true );
- IDictionaryEnumerator enumerator = runningInstances.GetEnumerator();
-
- while ( enumerator.MoveNext() )
- {
- try
- {
- object ide = enumerator.Value;
- if (ide != null)
- {
- object sol = ViaCOM.GetProperty(ide, "Solution");
- if (0 == string.Compare((string)ViaCOM.GetProperty(sol, "FullName"), solutionFile, ignore_case))
- {
- return ide;
- }
- }
- }
- catch{}
- }
-
- return null;
- }
-
- ///
- /// Get a table of the currently running instances of the Visual Studio .NET IDE.
- ///
- /// Only return instances that have opened a solution
- /// A hashtable mapping the name of the IDE in the running object table to the corresponding DTE object
- public static Hashtable GetIDEInstances( bool openSolutionsOnly )
- {
- Hashtable runningIDEInstances = new Hashtable();
- Hashtable runningObjects = GetRunningObjectTable();
-
- IDictionaryEnumerator rotEnumerator = runningObjects.GetEnumerator();
- while ( rotEnumerator.MoveNext() )
- {
- string candidateName = (string) rotEnumerator.Key;
- if (!candidateName.StartsWith("!VisualStudio.DTE"))
- continue;
-
- object ide = rotEnumerator.Value;
- if (ide == null)
- continue;
-
- if (openSolutionsOnly)
- {
- try
- {
- object sol = ViaCOM.GetProperty(ide, "Solution");
- string solutionFile = (string)ViaCOM.GetProperty(sol, "FullName");
- if (solutionFile != String.Empty)
- {
- runningIDEInstances[ candidateName ] = ide;
- }
- }
- catch {}
- }
- else
- {
- runningIDEInstances[ candidateName ] = ide;
- }
- }
- return runningIDEInstances;
- }
-
- ///
- /// Get a snapshot of the running object table (ROT).
- ///
- /// A hashtable mapping the name of the object in the ROT to the corresponding object
- [STAThread]
- public static Hashtable GetRunningObjectTable()
- {
- Hashtable result = new Hashtable();
-
- int numFetched = 0;
- IRunningObjectTable runningObjectTable;
- IEnumMoniker monikerEnumerator;
- IMoniker[] monikers = new IMoniker[1];
-
- GetRunningObjectTable(0, out runningObjectTable);
- runningObjectTable.EnumRunning(out monikerEnumerator);
- monikerEnumerator.Reset();
-
- while (monikerEnumerator.Next(1, monikers, new IntPtr(numFetched)) == 0)
- {
- IBindCtx ctx;
- CreateBindCtx(0, out ctx);
-
- string runningObjectName;
- monikers[0].GetDisplayName(ctx, null, out runningObjectName);
-
- object runningObjectVal;
- runningObjectTable.GetObject( monikers[0], out runningObjectVal);
-
- result[ runningObjectName ] = runningObjectVal;
- }
-
- return result;
- }
-
- public static string GetSolutionVersion(string solutionFullFileName)
- {
- string version;
- System.IO.StreamReader solutionStreamReader = null;
- string firstLine;
- string format;
-
- try
- {
- solutionStreamReader = new System.IO.StreamReader(solutionFullFileName);
- do
- {
- firstLine = solutionStreamReader.ReadLine();
- }
- while (firstLine == "");
-
- format = firstLine.Substring(firstLine.LastIndexOf(" ")).Trim();
-
- switch(format)
- {
- case "7.00":
- version = "VC70";
- break;
-
- case "8.00":
- version = "VC71";
- break;
-
- case "9.00":
- version = "VC80";
- break;
-
- case "10.00":
- version = "VC90";
- break;
- default:
- throw new ApplicationException("Unknown .sln version: " + format);
- }
- }
- finally
- {
- if(solutionStreamReader != null)
- {
- solutionStreamReader.Close();
- }
- }
-
- return version;
- }
-
- public static string GetVSProgID(string version)
- {
- string progid = null;
- switch(version)
- {
- case "VC70":
- progid = "VisualStudio.DTE.7";
- break;
-
- case "VC71":
- progid = "VisualStudio.DTE.7.1";
- break;
-
- case "VC80":
- progid = "VisualStudio.DTE.8.0";
- break;
-
- case "VC90":
- progid = "VisualStudio.DTE.9.0";
- break;
- default:
- throw new ApplicationException("Can't handle VS version: " + version);
- }
-
- return progid;
- }
-
- public static bool SetProjectWorkingDir(object sol, string project_name, string working_dir)
- {
- bool made_change = false;
- Console.WriteLine("Looking for project {0}...", project_name);
- try
- {
- object prjs = ViaCOM.GetProperty(sol, "Projects");
- object count = ViaCOM.GetProperty(prjs, "Count");
- for(int i = 1; i <= (int)count; ++i)
- {
- object[] prjItemArgs = { (object)i };
- object prj = ViaCOM.CallMethod(prjs, "Item", prjItemArgs);
- string name = (string)ViaCOM.GetProperty(prj, "Name");
- if (0 == string.Compare(name, project_name, ignore_case))
- {
- Console.WriteLine("Found project: {0}", project_name);
- Console.WriteLine("Setting working directory");
-
- string full_project_name = (string)ViaCOM.GetProperty(prj, "FullName");
- Console.WriteLine(full_project_name);
-
- // *NOTE:Mani Thanks to incompatibilities between different versions of the
- // VCProjectEngine.dll assembly, we can't cast the objects recevied from the DTE to
- // the VCProjectEngine types from a different version than the one built
- // with. ie, VisualStudio.DTE.7.1 objects can't be converted in a project built
- // in VS 8.0. To avoid this problem, we can use the com object interfaces directly,
- // without the type casting. Its tedious code, but it seems to work.
-
- // oCfgs should be assigned to a 'Project.Configurations' collection.
- object oCfgs = ViaCOM.GetProperty(ViaCOM.GetProperty(prj, "Object"), "Configurations");
-
- // oCount will be assigned to the number of configs present in oCfgs.
- object oCount = ViaCOM.GetProperty(oCfgs, "Count");
-
- for (int cfgIndex = 1; cfgIndex <= (int)oCount; ++cfgIndex)
- {
- object[] itemArgs = {(object)cfgIndex};
- object oCfg = ViaCOM.CallMethod(oCfgs, "Item", itemArgs);
- object oDebugSettings = ViaCOM.GetProperty(oCfg, "DebugSettings");
- ViaCOM.SetProperty(oDebugSettings, "WorkingDirectory", (object)working_dir);
- }
-
- break;
- }
- }
- made_change = true;
- }
- catch( Exception e )
- {
- Console.WriteLine(e.Message);
- Console.WriteLine("Failed to set working dir for project, {0}.", project_name);
- }
-
- return made_change;
- }
-
- public static bool SetStartupProject(string startup_project)
- {
- bool result = false;
- try
- {
- // You need the 'unique name of the project to set StartupProjects.
- // find the project by generic name.
- Console.WriteLine("Trying to set \"{0}\" to the startup project", startup_project);
- object prjs = ViaCOM.GetProperty(solution, "Projects");
- object count = ViaCOM.GetProperty(prjs, "Count");
- for (int i = 1; i <= (int)count; ++i)
- {
- object[] itemArgs = { (object)i };
- object prj = ViaCOM.CallMethod(prjs, "Item", itemArgs);
- object prjName = ViaCOM.GetProperty(prj, "Name");
- if (0 == string.Compare((string)prjName, startup_project, ignore_case))
- {
- object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
- ViaCOM.SetProperty(solBuild, "StartupProjects", ViaCOM.GetProperty(prj, "UniqueName"));
- Console.WriteLine(" Success!");
- result = true;
- break;
- }
- }
-
- if (result == false)
- {
- Console.WriteLine(" Could not find project \"{0}\" in the solution.", startup_project);
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(" Failed to set the startup project!");
- Console.WriteLine(e.Message);
- }
- return result;
- }
-
- public static bool SetActiveConfig(string config)
- {
- bool result = false;
- try
- {
- Console.WriteLine("Trying to set active config to \"{0}\"", config);
- object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
- object solCfgs = ViaCOM.GetProperty(solBuild, "SolutionConfigurations");
- object[] itemArgs = { (object)config };
- object solCfg = ViaCOM.CallMethod(solCfgs, "Item", itemArgs);
- ViaCOM.CallMethod(solCfg, "Activate", null);
- Console.WriteLine(" Success!");
- result = true;
- }
- catch (Exception e)
- {
- Console.WriteLine(" Failed to set \"{0}\" as the active config.", config);
- Console.WriteLine(e.Message);
- }
- return result;
- }
- }
-}
+// Code about getting running instances visual studio
+// was borrowed from
+// http://www.codeproject.com/KB/cs/automatingvisualstudio.aspx
+
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+using Microsoft.CSharp;
+
+namespace VSTool
+{
+ // The MessageFilter class comes from:
+ // http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx
+ // It allows vstool to get timing error messages from
+ // visualstudio and handle them.
+ public class MessageFilter : IOleMessageFilter
+ {
+ //
+ // Class containing the IOleMessageFilter
+ // thread error-handling functions.
+
+ // Start the filter.
+ public static void Register()
+ {
+ IOleMessageFilter newFilter = new MessageFilter();
+ IOleMessageFilter oldFilter = null;
+ CoRegisterMessageFilter(newFilter, out oldFilter);
+ }
+
+ // Done with the filter, close it.
+ public static void Revoke()
+ {
+ IOleMessageFilter oldFilter = null;
+ CoRegisterMessageFilter(null, out oldFilter);
+ }
+
+ //
+ // IOleMessageFilter functions.
+ // Handle incoming thread requests.
+ int IOleMessageFilter.HandleInComingCall(int dwCallType,
+ System.IntPtr hTaskCaller, int dwTickCount, System.IntPtr
+ lpInterfaceInfo)
+ {
+ //Return the flag SERVERCALL_ISHANDLED.
+ return 0;
+ }
+
+ // Thread call was rejected, so try again.
+ int IOleMessageFilter.RetryRejectedCall(System.IntPtr
+ hTaskCallee, int dwTickCount, int dwRejectType)
+ {
+ if (dwRejectType == 2)
+ // flag = SERVERCALL_RETRYLATER.
+ {
+ // Retry the thread call immediately if return >=0 &
+ // <100.
+ return 99;
+ }
+ // Too busy; cancel call.
+ return -1;
+ }
+
+ int IOleMessageFilter.MessagePending(System.IntPtr hTaskCallee,
+ int dwTickCount, int dwPendingType)
+ {
+ //Return the flag PENDINGMSG_WAITDEFPROCESS.
+ return 2;
+ }
+
+ // Implement the IOleMessageFilter interface.
+ [DllImport("Ole32.dll")]
+ private static extern int
+ CoRegisterMessageFilter(IOleMessageFilter newFilter, out
+ IOleMessageFilter oldFilter);
+ }
+
+ [ComImport(), Guid("00000016-0000-0000-C000-000000000046"),
+ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IOleMessageFilter
+ {
+ [PreserveSig]
+ int HandleInComingCall(
+ int dwCallType,
+ IntPtr hTaskCaller,
+ int dwTickCount,
+ IntPtr lpInterfaceInfo);
+
+ [PreserveSig]
+ int RetryRejectedCall(
+ IntPtr hTaskCallee,
+ int dwTickCount,
+ int dwRejectType);
+
+ [PreserveSig]
+ int MessagePending(
+ IntPtr hTaskCallee,
+ int dwTickCount,
+ int dwPendingType);
+ }
+
+ class ViaCOM
+ {
+ public static object GetProperty(object from_obj, string prop_name)
+ {
+ try
+ {
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ prop_name,
+ BindingFlags.GetProperty, null,
+ from_obj,
+ null);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error getting property: \"{0}\"", prop_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
+ }
+
+ public static object SetProperty(object from_obj, string prop_name, object new_value)
+ {
+ try
+ {
+ object[] args = { new_value };
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ prop_name,
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Instance |
+ BindingFlags.SetProperty,
+ null,
+ from_obj,
+ args);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error setting property: \"{0}\"", prop_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
+ }
+
+ public static object CallMethod(object from_obj, string method_name, params object[] args)
+ {
+ try
+ {
+ Type objType = from_obj.GetType();
+ return objType.InvokeMember(
+ method_name,
+ BindingFlags.DeclaredOnly |
+ BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Instance |
+ BindingFlags.InvokeMethod,
+ null,
+ from_obj,
+ args);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error calling method \"{0}\"", method_name);
+ Console.WriteLine(e.Message);
+ throw e;
+ }
+ }
+ };
+
+ ///
+ /// The main entry point class for VSTool.
+ ///
+ class VSToolMain
+ {
+ #region Interop imports
+ [DllImport("ole32.dll")]
+ public static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable prot);
+
+ [DllImport("ole32.dll")]
+ public static extern int CreateBindCtx(int reserved, out IBindCtx ppbc);
+ #endregion
+
+ static System.Boolean ignore_case = true;
+
+ static string solution_name = null;
+ static bool use_new_vs = false;
+ static Hashtable projectDict = new Hashtable();
+ static string startup_project = null;
+ static string config = null;
+
+ static object dte = null;
+ static object solution = null;
+
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int retVal = 0;
+ bool need_save = false;
+
+ try
+ {
+ parse_command_line(args);
+
+ Console.WriteLine("Editing solution: {0}", solution_name);
+
+ bool found_open_solution = GetDTEAndSolution();
+
+ if (dte == null || solution == null)
+ {
+ retVal = 1;
+ }
+ else
+ {
+ MessageFilter.Register();
+
+ // Walk through all of the projects in the solution
+ // and list the type of each project.
+ foreach (DictionaryEntry p in projectDict)
+ {
+ string project_name = (string)p.Key;
+ string working_dir = (string)p.Value;
+ if (SetProjectWorkingDir(solution, project_name, working_dir))
+ {
+ need_save = true;
+ }
+ }
+
+ if (config != null)
+ {
+ need_save = SetActiveConfig(config);
+ }
+
+ if (startup_project != null)
+ {
+ need_save = SetStartupProject(startup_project);
+ }
+
+ if (need_save)
+ {
+ if (found_open_solution == false)
+ {
+ ViaCOM.CallMethod(solution, "Close", null);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ retVal = 1;
+ }
+ finally
+ {
+ if (solution != null)
+ {
+ Marshal.ReleaseComObject(solution);
+ solution = null;
+ }
+
+ if (dte != null)
+ {
+ Marshal.ReleaseComObject(dte);
+ dte = null;
+ }
+
+ MessageFilter.Revoke();
+ }
+ return retVal;
+ }
+
+ public static bool parse_command_line(string[] args)
+ {
+ string options_desc =
+ "--solution : MSVC solution name. (required)\n" +
+ "--use_new_vs : Ignore running versions of visual studio.\n" +
+ "--workingdir : Set working dir of a VC project.\n" +
+ "--config : Set the active config for the solution.\n" +
+ "--startup : Set the startup project for the solution.\n";
+
+ try
+ {
+ // Command line param parsing loop.
+ int i = 0;
+ for (; i < args.Length; ++i)
+ {
+ if ("--solution" == args[i])
+ {
+ if (solution_name != null)
+ {
+ throw new ApplicationException("Found second --solution option");
+ }
+ solution_name = args[++i];
+ }
+ else if ("--use_new_vs" == args[i])
+ {
+ use_new_vs = true;
+ }
+
+ else if ("--workingdir" == args[i])
+ {
+ string project_name = args[++i];
+ string working_dir = args[++i];
+ projectDict.Add(project_name, working_dir);
+ }
+ else if ("--config" == args[i])
+ {
+ if (config != null)
+ {
+ throw new ApplicationException("Found second --config option");
+ }
+ config = args[++i];
+ }
+ else if ("--startup" == args[i])
+ {
+ if (startup_project != null)
+ {
+ throw new ApplicationException("Found second --startup option");
+ }
+ startup_project = args[++i];
+ }
+ else
+ {
+ throw new ApplicationException("Found unrecognized token on command line: " + args[i]);
+ }
+ }
+
+ if (solution_name == null)
+ {
+ throw new ApplicationException("The --solution option is required.");
+ }
+ }
+ catch(ApplicationException e)
+ {
+
+ Console.WriteLine("Oops! " + e.Message);
+ Console.Write("Command line:");
+ foreach (string arg in args)
+ {
+ Console.Write(" " + arg);
+ }
+ Console.Write("\n\n");
+ Console.WriteLine("VSTool command line usage");
+ Console.Write(options_desc);
+ throw e;
+ }
+ return true;
+ }
+
+ public static bool GetDTEAndSolution()
+ {
+ bool found_open_solution = true;
+
+ Console.WriteLine("Looking for existing VisualStudio instance...");
+
+ // Get an instance of the currently running Visual Studio .NET IDE.
+ // dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.7.1");
+ string full_solution_name = System.IO.Path.GetFullPath(solution_name);
+ if (false == use_new_vs)
+ {
+ dte = GetIDEInstance(full_solution_name);
+ }
+
+ if (dte == null)
+ {
+ try
+ {
+ Console.WriteLine(" Didn't find open solution, starting new background VisualStudio instance...");
+ Console.WriteLine(" Reading .sln file version...");
+ string version = GetSolutionVersion(full_solution_name);
+
+ Console.WriteLine(" Using version: {0}...", version);
+ string progid = GetVSProgID(version);
+
+ Type objType = Type.GetTypeFromProgID(progid);
+ dte = System.Activator.CreateInstance(objType);
+ Console.WriteLine(" Reading solution: \"{0}\"", full_solution_name);
+
+ solution = ViaCOM.GetProperty(dte, "Solution");
+ object[] openArgs = { full_solution_name };
+ ViaCOM.CallMethod(solution, "Open", openArgs);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Console.WriteLine("Quitting do to error opening: {0}", full_solution_name);
+ solution = null;
+ dte = null;
+ return found_open_solution;
+ }
+ found_open_solution = false;
+ }
+
+ if (solution == null)
+ {
+ solution = ViaCOM.GetProperty(dte, "Solution");
+ }
+
+ return found_open_solution;
+ }
+
+ ///
+ /// Get the DTE object for the instance of Visual Studio IDE that has
+ /// the specified solution open.
+ ///
+ /// The absolute filename of the solution
+ /// Corresponding DTE object or null if no such IDE is running
+ public static object GetIDEInstance( string solutionFile )
+ {
+ Hashtable runningInstances = GetIDEInstances( true );
+ IDictionaryEnumerator enumerator = runningInstances.GetEnumerator();
+
+ while ( enumerator.MoveNext() )
+ {
+ try
+ {
+ object ide = enumerator.Value;
+ if (ide != null)
+ {
+ object sol = ViaCOM.GetProperty(ide, "Solution");
+ if (0 == string.Compare((string)ViaCOM.GetProperty(sol, "FullName"), solutionFile, ignore_case))
+ {
+ return ide;
+ }
+ }
+ }
+ catch{}
+ }
+
+ return null;
+ }
+
+ ///
+ /// Get a table of the currently running instances of the Visual Studio .NET IDE.
+ ///
+ /// Only return instances that have opened a solution
+ /// A hashtable mapping the name of the IDE in the running object table to the corresponding DTE object
+ public static Hashtable GetIDEInstances( bool openSolutionsOnly )
+ {
+ Hashtable runningIDEInstances = new Hashtable();
+ Hashtable runningObjects = GetRunningObjectTable();
+
+ IDictionaryEnumerator rotEnumerator = runningObjects.GetEnumerator();
+ while ( rotEnumerator.MoveNext() )
+ {
+ string candidateName = (string) rotEnumerator.Key;
+ if (!candidateName.StartsWith("!VisualStudio.DTE"))
+ continue;
+
+ object ide = rotEnumerator.Value;
+ if (ide == null)
+ continue;
+
+ if (openSolutionsOnly)
+ {
+ try
+ {
+ object sol = ViaCOM.GetProperty(ide, "Solution");
+ string solutionFile = (string)ViaCOM.GetProperty(sol, "FullName");
+ if (solutionFile != String.Empty)
+ {
+ runningIDEInstances[ candidateName ] = ide;
+ }
+ }
+ catch {}
+ }
+ else
+ {
+ runningIDEInstances[ candidateName ] = ide;
+ }
+ }
+ return runningIDEInstances;
+ }
+
+ ///
+ /// Get a snapshot of the running object table (ROT).
+ ///
+ /// A hashtable mapping the name of the object in the ROT to the corresponding object
+ [STAThread]
+ public static Hashtable GetRunningObjectTable()
+ {
+ Hashtable result = new Hashtable();
+
+ int numFetched = 0;
+ IRunningObjectTable runningObjectTable;
+ IEnumMoniker monikerEnumerator;
+ IMoniker[] monikers = new IMoniker[1];
+
+ GetRunningObjectTable(0, out runningObjectTable);
+ runningObjectTable.EnumRunning(out monikerEnumerator);
+ monikerEnumerator.Reset();
+
+ while (monikerEnumerator.Next(1, monikers, new IntPtr(numFetched)) == 0)
+ {
+ IBindCtx ctx;
+ CreateBindCtx(0, out ctx);
+
+ string runningObjectName;
+ monikers[0].GetDisplayName(ctx, null, out runningObjectName);
+
+ object runningObjectVal;
+ runningObjectTable.GetObject( monikers[0], out runningObjectVal);
+
+ result[ runningObjectName ] = runningObjectVal;
+ }
+
+ return result;
+ }
+
+ public static string GetSolutionVersion(string solutionFullFileName)
+ {
+ string version;
+ System.IO.StreamReader solutionStreamReader = null;
+ string firstLine;
+ string format;
+
+ try
+ {
+ solutionStreamReader = new System.IO.StreamReader(solutionFullFileName);
+ do
+ {
+ firstLine = solutionStreamReader.ReadLine();
+ }
+ while (firstLine == "");
+
+ format = firstLine.Substring(firstLine.LastIndexOf(" ")).Trim();
+
+ switch(format)
+ {
+ case "7.00":
+ version = "VC70";
+ break;
+
+ case "8.00":
+ version = "VC71";
+ break;
+
+ case "9.00":
+ version = "VC80";
+ break;
+
+ case "10.00":
+ version = "VC90";
+ break;
+ default:
+ throw new ApplicationException("Unknown .sln version: " + format);
+ }
+ }
+ finally
+ {
+ if(solutionStreamReader != null)
+ {
+ solutionStreamReader.Close();
+ }
+ }
+
+ return version;
+ }
+
+ public static string GetVSProgID(string version)
+ {
+ string progid = null;
+ switch(version)
+ {
+ case "VC70":
+ progid = "VisualStudio.DTE.7";
+ break;
+
+ case "VC71":
+ progid = "VisualStudio.DTE.7.1";
+ break;
+
+ case "VC80":
+ progid = "VisualStudio.DTE.8.0";
+ break;
+
+ case "VC90":
+ progid = "VisualStudio.DTE.9.0";
+ break;
+ default:
+ throw new ApplicationException("Can't handle VS version: " + version);
+ }
+
+ return progid;
+ }
+
+ public static bool SetProjectWorkingDir(object sol, string project_name, string working_dir)
+ {
+ bool made_change = false;
+ Console.WriteLine("Looking for project {0}...", project_name);
+ try
+ {
+ object prjs = ViaCOM.GetProperty(sol, "Projects");
+ object count = ViaCOM.GetProperty(prjs, "Count");
+ for(int i = 1; i <= (int)count; ++i)
+ {
+ object[] prjItemArgs = { (object)i };
+ object prj = ViaCOM.CallMethod(prjs, "Item", prjItemArgs);
+ string name = (string)ViaCOM.GetProperty(prj, "Name");
+ if (0 == string.Compare(name, project_name, ignore_case))
+ {
+ Console.WriteLine("Found project: {0}", project_name);
+ Console.WriteLine("Setting working directory");
+
+ string full_project_name = (string)ViaCOM.GetProperty(prj, "FullName");
+ Console.WriteLine(full_project_name);
+
+ // *NOTE:Mani Thanks to incompatibilities between different versions of the
+ // VCProjectEngine.dll assembly, we can't cast the objects recevied from the DTE to
+ // the VCProjectEngine types from a different version than the one built
+ // with. ie, VisualStudio.DTE.7.1 objects can't be converted in a project built
+ // in VS 8.0. To avoid this problem, we can use the com object interfaces directly,
+ // without the type casting. Its tedious code, but it seems to work.
+
+ // oCfgs should be assigned to a 'Project.Configurations' collection.
+ object oCfgs = ViaCOM.GetProperty(ViaCOM.GetProperty(prj, "Object"), "Configurations");
+
+ // oCount will be assigned to the number of configs present in oCfgs.
+ object oCount = ViaCOM.GetProperty(oCfgs, "Count");
+
+ for (int cfgIndex = 1; cfgIndex <= (int)oCount; ++cfgIndex)
+ {
+ object[] itemArgs = {(object)cfgIndex};
+ object oCfg = ViaCOM.CallMethod(oCfgs, "Item", itemArgs);
+ object oDebugSettings = ViaCOM.GetProperty(oCfg, "DebugSettings");
+ ViaCOM.SetProperty(oDebugSettings, "WorkingDirectory", (object)working_dir);
+ }
+
+ break;
+ }
+ }
+ made_change = true;
+ }
+ catch( Exception e )
+ {
+ Console.WriteLine(e.Message);
+ Console.WriteLine("Failed to set working dir for project, {0}.", project_name);
+ }
+
+ return made_change;
+ }
+
+ public static bool SetStartupProject(string startup_project)
+ {
+ bool result = false;
+ try
+ {
+ // You need the 'unique name of the project to set StartupProjects.
+ // find the project by generic name.
+ Console.WriteLine("Trying to set \"{0}\" to the startup project", startup_project);
+ object prjs = ViaCOM.GetProperty(solution, "Projects");
+ object count = ViaCOM.GetProperty(prjs, "Count");
+ for (int i = 1; i <= (int)count; ++i)
+ {
+ object[] itemArgs = { (object)i };
+ object prj = ViaCOM.CallMethod(prjs, "Item", itemArgs);
+ object prjName = ViaCOM.GetProperty(prj, "Name");
+ if (0 == string.Compare((string)prjName, startup_project, ignore_case))
+ {
+ object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
+ ViaCOM.SetProperty(solBuild, "StartupProjects", ViaCOM.GetProperty(prj, "UniqueName"));
+ Console.WriteLine(" Success!");
+ result = true;
+ break;
+ }
+ }
+
+ if (result == false)
+ {
+ Console.WriteLine(" Could not find project \"{0}\" in the solution.", startup_project);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(" Failed to set the startup project!");
+ Console.WriteLine(e.Message);
+ }
+ return result;
+ }
+
+ public static bool SetActiveConfig(string config)
+ {
+ bool result = false;
+ try
+ {
+ Console.WriteLine("Trying to set active config to \"{0}\"", config);
+ object solBuild = ViaCOM.GetProperty(solution, "SolutionBuild");
+ object solCfgs = ViaCOM.GetProperty(solBuild, "SolutionConfigurations");
+ object[] itemArgs = { (object)config };
+ object solCfg = ViaCOM.CallMethod(solCfgs, "Item", itemArgs);
+ ViaCOM.CallMethod(solCfg, "Activate", null);
+ Console.WriteLine(" Success!");
+ result = true;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(" Failed to set \"{0}\" as the active config.", config);
+ Console.WriteLine(e.Message);
+ }
+ return result;
+ }
+ }
+}