Fuckin TPV-Compliant Sound Explorer, How Does That Work?

Motherfuckin' Miracles, that's how. :o)
This commit is contained in:
CharleyLevenque
2010-08-27 05:55:15 -04:00
parent cd473c8574
commit 27dbe74066

View File

@@ -1,439 +1,467 @@
// <edit> // <edit>
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "llfloaterexploresounds.h" #include "llfloaterexploresounds.h"
#include "lluictrlfactory.h" #include "lluictrlfactory.h"
#include "llscrolllistctrl.h" #include "llscrolllistctrl.h"
#include "lllocalinventory.h" #include "lllocalinventory.h"
#include "llagent.h" #include "llagent.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "llviewerobjectlist.h" #include "llviewerobjectlist.h"
#include "llviewerregion.h" #include "llviewerregion.h"
#include "llviewerparcelmgr.h"
static const size_t num_collision_sounds = 28; #include "llparcel.h"
const LLUUID collision_sounds[num_collision_sounds] = #include "llchat.h"
{ #include "llfloaterchat.h"
LLUUID("dce5fdd4-afe4-4ea1-822f-dd52cac46b08"),
LLUUID("51011582-fbca-4580-ae9e-1a5593f094ec"), static const size_t num_collision_sounds = 28;
LLUUID("68d62208-e257-4d0c-bbe2-20c9ea9760bb"), const LLUUID collision_sounds[num_collision_sounds] =
LLUUID("75872e8c-bc39-451b-9b0b-042d7ba36cba"), {
LLUUID("6a45ba0b-5775-4ea8-8513-26008a17f873"), LLUUID("dce5fdd4-afe4-4ea1-822f-dd52cac46b08"),
LLUUID("992a6d1b-8c77-40e0-9495-4098ce539694"), LLUUID("51011582-fbca-4580-ae9e-1a5593f094ec"),
LLUUID("2de4da5a-faf8-46be-bac6-c4d74f1e5767"), LLUUID("68d62208-e257-4d0c-bbe2-20c9ea9760bb"),
LLUUID("6e3fb0f7-6d9c-42ca-b86b-1122ff562d7d"), LLUUID("75872e8c-bc39-451b-9b0b-042d7ba36cba"),
LLUUID("14209133-4961-4acc-9649-53fc38ee1667"), LLUUID("6a45ba0b-5775-4ea8-8513-26008a17f873"),
LLUUID("bc4a4348-cfcc-4e5e-908e-8a52a8915fe6"), LLUUID("992a6d1b-8c77-40e0-9495-4098ce539694"),
LLUUID("9e5c1297-6eed-40c0-825a-d9bcd86e3193"), LLUUID("2de4da5a-faf8-46be-bac6-c4d74f1e5767"),
LLUUID("e534761c-1894-4b61-b20c-658a6fb68157"), LLUUID("6e3fb0f7-6d9c-42ca-b86b-1122ff562d7d"),
LLUUID("8761f73f-6cf9-4186-8aaa-0948ed002db1"), LLUUID("14209133-4961-4acc-9649-53fc38ee1667"),
LLUUID("874a26fd-142f-4173-8c5b-890cd846c74d"), LLUUID("bc4a4348-cfcc-4e5e-908e-8a52a8915fe6"),
LLUUID("0e24a717-b97e-4b77-9c94-b59a5a88b2da"), LLUUID("9e5c1297-6eed-40c0-825a-d9bcd86e3193"),
LLUUID("75cf3ade-9a5b-4c4d-bb35-f9799bda7fb2"), LLUUID("e534761c-1894-4b61-b20c-658a6fb68157"),
LLUUID("153c8bf7-fb89-4d89-b263-47e58b1b4774"), LLUUID("8761f73f-6cf9-4186-8aaa-0948ed002db1"),
LLUUID("55c3e0ce-275a-46fa-82ff-e0465f5e8703"), LLUUID("874a26fd-142f-4173-8c5b-890cd846c74d"),
LLUUID("24babf58-7156-4841-9a3f-761bdbb8e237"), LLUUID("0e24a717-b97e-4b77-9c94-b59a5a88b2da"),
LLUUID("aca261d8-e145-4610-9e20-9eff990f2c12"), LLUUID("75cf3ade-9a5b-4c4d-bb35-f9799bda7fb2"),
LLUUID("0642fba6-5dcf-4d62-8e7b-94dbb529d117"), LLUUID("153c8bf7-fb89-4d89-b263-47e58b1b4774"),
LLUUID("25a863e8-dc42-4e8a-a357-e76422ace9b5"), LLUUID("55c3e0ce-275a-46fa-82ff-e0465f5e8703"),
LLUUID("9538f37c-456e-4047-81be-6435045608d4"), LLUUID("24babf58-7156-4841-9a3f-761bdbb8e237"),
LLUUID("8c0f84c3-9afd-4396-b5f5-9bca2c911c20"), LLUUID("aca261d8-e145-4610-9e20-9eff990f2c12"),
LLUUID("be582e5d-b123-41a2-a150-454c39e961c8"), LLUUID("0642fba6-5dcf-4d62-8e7b-94dbb529d117"),
LLUUID("c70141d4-ba06-41ea-bcbc-35ea81cb8335"), LLUUID("25a863e8-dc42-4e8a-a357-e76422ace9b5"),
LLUUID("7d1826f4-24c4-4aac-8c2e-eff45df37783"), LLUUID("9538f37c-456e-4047-81be-6435045608d4"),
LLUUID("063c97d3-033a-4e9b-98d8-05c8074922cb") LLUUID("8c0f84c3-9afd-4396-b5f5-9bca2c911c20"),
}; LLUUID("be582e5d-b123-41a2-a150-454c39e961c8"),
LLUUID("c70141d4-ba06-41ea-bcbc-35ea81cb8335"),
LLFloaterExploreSounds* LLFloaterExploreSounds::sInstance; LLUUID("7d1826f4-24c4-4aac-8c2e-eff45df37783"),
LLUUID("063c97d3-033a-4e9b-98d8-05c8074922cb")
LLFloaterExploreSounds::LLFloaterExploreSounds() };
: LLFloater(), LLEventTimer(0.25f)
{ LLFloaterExploreSounds* LLFloaterExploreSounds::sInstance;
LLFloaterExploreSounds::sInstance = this;
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_explore_sounds.xml"); LLFloaterExploreSounds::LLFloaterExploreSounds()
} : LLFloater(), LLEventTimer(0.25f)
{
LLFloaterExploreSounds::~LLFloaterExploreSounds() LLFloaterExploreSounds::sInstance = this;
{ LLUICtrlFactory::getInstance()->buildFloater(this, "floater_explore_sounds.xml");
LLFloaterExploreSounds::sInstance = NULL; }
}
LLFloaterExploreSounds::~LLFloaterExploreSounds()
// static {
void LLFloaterExploreSounds::toggle() LLFloaterExploreSounds::sInstance = NULL;
{ }
if(LLFloaterExploreSounds::sInstance) LLFloaterExploreSounds::sInstance->close(FALSE);
else LLFloaterExploreSounds::sInstance = new LLFloaterExploreSounds(); // static
} void LLFloaterExploreSounds::toggle()
{
void LLFloaterExploreSounds::close(bool app_quitting) if(LLFloaterExploreSounds::sInstance) LLFloaterExploreSounds::sInstance->close(FALSE);
{ else LLFloaterExploreSounds::sInstance = new LLFloaterExploreSounds();
LLFloater::close(app_quitting); }
}
void LLFloaterExploreSounds::close(bool app_quitting)
BOOL LLFloaterExploreSounds::postBuild(void) {
{ LLFloater::close(app_quitting);
childSetDoubleClickCallback("sound_list", handle_play_locally, this); }
childSetAction("play_locally_btn", handle_play_locally, this); BOOL LLFloaterExploreSounds::postBuild(void)
childSetAction("play_in_world_btn", handle_play_in_world, this); {
childSetAction("play_ambient_btn", handle_play_ambient, this); childSetDoubleClickCallback("sound_list", handle_play_locally, this);
childSetAction("look_at_btn", handle_look_at, this);
childSetAction("copy_uuid_btn", handle_copy_uuid, this); childSetAction("play_locally_btn", handle_play_locally, this);
childSetAction("stop_btn", handle_stop, this); childSetAction("play_in_world_btn", handle_play_in_world, this);
childSetAction("play_ambient_btn", handle_play_ambient, this);
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("sound_list"); childSetAction("look_at_btn", handle_look_at, this);
list->sortByColumn("playing", TRUE); childSetAction("copy_uuid_btn", handle_copy_uuid, this);
return TRUE; childSetAction("stop_btn", handle_stop, this);
}
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("sound_list");
LLSoundHistoryItem LLFloaterExploreSounds::getItem(LLUUID itemID) list->sortByColumn("playing", TRUE);
{ return TRUE;
if(gSoundHistory.find(itemID) != gSoundHistory.end()) }
return gSoundHistory[itemID];
else LLSoundHistoryItem LLFloaterExploreSounds::getItem(LLUUID itemID)
{ {
// If log is paused, hopefully we can find it in mLastHistory if(gSoundHistory.find(itemID) != gSoundHistory.end())
std::list<LLSoundHistoryItem>::iterator iter = mLastHistory.begin(); return gSoundHistory[itemID];
std::list<LLSoundHistoryItem>::iterator end = mLastHistory.end(); else
for( ; iter != end; ++iter) {
{ // If log is paused, hopefully we can find it in mLastHistory
if((*iter).mID == itemID) return (*iter); std::list<LLSoundHistoryItem>::iterator iter = mLastHistory.begin();
} std::list<LLSoundHistoryItem>::iterator end = mLastHistory.end();
} for( ; iter != end; ++iter)
LLSoundHistoryItem item; {
item.mID = LLUUID::null; if((*iter).mID == itemID) return (*iter);
return item; }
} }
LLSoundHistoryItem item;
class LLSoundHistoryItemCompare item.mID = LLUUID::null;
{ return item;
public: }
bool operator() (LLSoundHistoryItem first, LLSoundHistoryItem second)
{ class LLSoundHistoryItemCompare
if(first.mPlaying) {
{ public:
if(second.mPlaying) bool operator() (LLSoundHistoryItem first, LLSoundHistoryItem second)
{ {
return (first.mTimeStarted > second.mTimeStarted); if(first.mPlaying)
} {
else if(second.mPlaying)
{ {
return true; return (first.mTimeStarted > second.mTimeStarted);
} }
} else
else if(second.mPlaying) {
{ return true;
return false; }
} }
else else if(second.mPlaying)
{ {
return (first.mTimeStopped > second.mTimeStopped); return false;
} }
} else
}; {
return (first.mTimeStopped > second.mTimeStopped);
// static }
BOOL LLFloaterExploreSounds::tick() }
{ };
//if(childGetValue("pause_chk").asBoolean()) return FALSE;
// static
bool show_collision_sounds = childGetValue("collision_chk").asBoolean(); BOOL LLFloaterExploreSounds::tick()
bool show_repeated_assets = childGetValue("repeated_asset_chk").asBoolean(); {
bool show_avatars = childGetValue("avatars_chk").asBoolean(); //if(childGetValue("pause_chk").asBoolean()) return FALSE;
bool show_objects = childGetValue("objects_chk").asBoolean();
bool show_collision_sounds = childGetValue("collision_chk").asBoolean();
std::list<LLSoundHistoryItem> history; bool show_repeated_assets = childGetValue("repeated_asset_chk").asBoolean();
if(childGetValue("pause_chk").asBoolean()) bool show_avatars = childGetValue("avatars_chk").asBoolean();
{ bool show_objects = childGetValue("objects_chk").asBoolean();
history = mLastHistory;
} std::list<LLSoundHistoryItem> history;
else if(childGetValue("pause_chk").asBoolean())
{ {
std::map<LLUUID, LLSoundHistoryItem>::iterator map_iter = gSoundHistory.begin(); history = mLastHistory;
std::map<LLUUID, LLSoundHistoryItem>::iterator map_end = gSoundHistory.end(); }
for( ; map_iter != map_end; ++map_iter) else
{ {
history.push_back((*map_iter).second); std::map<LLUUID, LLSoundHistoryItem>::iterator map_iter = gSoundHistory.begin();
} std::map<LLUUID, LLSoundHistoryItem>::iterator map_end = gSoundHistory.end();
LLSoundHistoryItemCompare c; for( ; map_iter != map_end; ++map_iter)
history.sort(c); {
mLastHistory = history; history.push_back((*map_iter).second);
} }
LLSoundHistoryItemCompare c;
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("sound_list"); history.sort(c);
mLastHistory = history;
// Save scroll pos and selection so they can be restored }
S32 scroll_pos = list->getScrollPos();
LLDynamicArray<LLUUID> selected_ids; LLScrollListCtrl* list = getChild<LLScrollListCtrl>("sound_list");
std::vector<LLScrollListItem*> selected_items = list->getAllSelected();
std::vector<LLScrollListItem*>::iterator selection_iter = selected_items.begin(); // Save scroll pos and selection so they can be restored
std::vector<LLScrollListItem*>::iterator selection_end = selected_items.end(); S32 scroll_pos = list->getScrollPos();
for(; selection_iter != selection_end; ++selection_iter) LLDynamicArray<LLUUID> selected_ids;
selected_ids.push_back((*selection_iter)->getUUID()); std::vector<LLScrollListItem*> selected_items = list->getAllSelected();
std::vector<LLScrollListItem*>::iterator selection_iter = selected_items.begin();
list->clearRows(); std::vector<LLScrollListItem*>::iterator selection_end = selected_items.end();
for(; selection_iter != selection_end; ++selection_iter)
std::list<LLUUID> unique_asset_list; selected_ids.push_back((*selection_iter)->getUUID());
std::list<LLSoundHistoryItem>::iterator iter = history.begin(); list->clearRows();
std::list<LLSoundHistoryItem>::iterator end = history.end();
for( ; iter != end; ++iter) std::list<LLUUID> unique_asset_list;
{
LLSoundHistoryItem item = (*iter); std::list<LLSoundHistoryItem>::iterator iter = history.begin();
std::list<LLSoundHistoryItem>::iterator end = history.end();
bool is_avatar = item.mOwnerID == item.mSourceID; for( ; iter != end; ++iter)
if(is_avatar && !show_avatars) continue; {
LLSoundHistoryItem item = (*iter);
bool is_object = !is_avatar;
if(is_object && !show_objects) continue; bool is_avatar = item.mOwnerID == item.mSourceID;
if(is_avatar && !show_avatars) continue;
bool is_repeated_asset = std::find(unique_asset_list.begin(), unique_asset_list.end(), item.mAssetID) != unique_asset_list.end();
if(is_repeated_asset && !show_repeated_assets) continue; bool is_object = !is_avatar;
if(is_object && !show_objects) continue;
if(!item.mReviewed)
{ bool is_repeated_asset = std::find(unique_asset_list.begin(), unique_asset_list.end(), item.mAssetID) != unique_asset_list.end();
item.mReviewedCollision = std::find(&collision_sounds[0], &collision_sounds[num_collision_sounds], item.mAssetID) != &collision_sounds[num_collision_sounds]; if(is_repeated_asset && !show_repeated_assets) continue;
item.mReviewed = true;
} if(!item.mReviewed)
bool is_collision_sound = item.mReviewedCollision; {
if(is_collision_sound && !show_collision_sounds) continue; item.mReviewedCollision = std::find(&collision_sounds[0], &collision_sounds[num_collision_sounds], item.mAssetID) != &collision_sounds[num_collision_sounds];
item.mReviewed = true;
unique_asset_list.push_back(item.mAssetID); }
bool is_collision_sound = item.mReviewedCollision;
LLSD element; if(is_collision_sound && !show_collision_sounds) continue;
element["id"] = item.mID;
unique_asset_list.push_back(item.mAssetID);
LLSD& playing_column = element["columns"][0];
playing_column["column"] = "playing"; LLSD element;
if(item.mPlaying) element["id"] = item.mID;
playing_column["value"] = " Playing";
else LLSD& playing_column = element["columns"][0];
playing_column["value"] = llformat("%.1f min ago", (LLTimer::getElapsedSeconds() - item.mTimeStopped) / 60.f); playing_column["column"] = "playing";
if(item.mPlaying)
LLSD& type_column = element["columns"][1]; playing_column["value"] = " Playing";
type_column["column"] = "type"; else
if(item.mType == LLAudioEngine::AUDIO_TYPE_UI) playing_column["value"] = llformat("%.1f min ago", (LLTimer::getElapsedSeconds() - item.mTimeStopped) / 60.f);
{
// this shouldn't happen for now, as UI is forbidden in the log LLSD& type_column = element["columns"][1];
type_column["value"] = "UI"; type_column["column"] = "type";
} if(item.mType == LLAudioEngine::AUDIO_TYPE_UI)
else {
{ // this shouldn't happen for now, as UI is forbidden in the log
std::string type; type_column["value"] = "UI";
}
if(is_avatar) else
{ {
type = "Avatar"; std::string type;
}
else if(is_avatar)
{ {
if(item.mIsTrigger) type = "Avatar";
{ }
type = "llTriggerSound"; else
} {
else if(item.mIsTrigger)
{ {
if(item.mIsLooped) type = "llTriggerSound";
type = "llLoopSound"; }
else else
type = "llPlaySound"; {
} if(item.mIsLooped)
} type = "llLoopSound";
else
type_column["value"] = type; type = "llPlaySound";
} }
}
LLSD& owner_column = element["columns"][2];
owner_column["column"] = "owner"; type_column["value"] = type;
std::string fullname; }
BOOL is_group;
if(gCacheName->getIfThere(item.mOwnerID, fullname, is_group)) LLSD& owner_column = element["columns"][2];
{ owner_column["column"] = "owner";
if(is_group) fullname += " (Group)"; std::string fullname;
owner_column["value"] = fullname; BOOL is_group;
} if(gCacheName->getIfThere(item.mOwnerID, fullname, is_group))
else {
owner_column["value"] = item.mOwnerID.asString(); if(is_group) fullname += " (Group)";
owner_column["value"] = fullname;
LLSD& sound_column = element["columns"][3]; }
sound_column["column"] = "sound"; else
sound_column["value"] = item.mAssetID.asString(); owner_column["value"] = item.mOwnerID.asString();
list->addElement(element, ADD_BOTTOM); LLSD& sound_column = element["columns"][3];
} sound_column["column"] = "sound";
list->selectMultiple(selected_ids); if (item.mOwnerID == gAgent.getID())
list->setScrollPos(scroll_pos); sound_column["value"] = item.mAssetID.asString();
else
return FALSE; sound_column["value"] = LLUUID::null.asString();
}
list->addElement(element, ADD_BOTTOM);
// static }
void LLFloaterExploreSounds::handle_play_locally(void* user_data)
{ list->selectMultiple(selected_ids);
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; list->setScrollPos(scroll_pos);
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
std::vector<LLScrollListItem*> selection = list->getAllSelected(); return FALSE;
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin(); }
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
std::vector<LLUUID> asset_list; // static
for( ; selection_iter != selection_end; ++selection_iter) void LLFloaterExploreSounds::handle_play_locally(void* user_data)
{ {
LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
if(item.mID.isNull()) continue; LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
// Unique assets only std::vector<LLScrollListItem*> selection = list->getAllSelected();
if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end()) std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin();
{ std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
asset_list.push_back(item.mAssetID); std::vector<LLUUID> asset_list;
gAudiop->triggerSound(item.mAssetID, LLUUID::null, 1.0f, LLAudioEngine::AUDIO_TYPE_UI); for( ; selection_iter != selection_end; ++selection_iter)
} {
} LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue());
} if(item.mID.isNull()) continue;
// Unique assets only
// static if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end())
void LLFloaterExploreSounds::handle_play_in_world(void* user_data) {
{ asset_list.push_back(item.mAssetID);
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; gAudiop->triggerSound(item.mAssetID, LLUUID::null, 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list"); }
std::vector<LLScrollListItem*> selection = list->getAllSelected(); }
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin(); }
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
for( ; selection_iter != selection_end; ++selection_iter) // static
{ void LLFloaterExploreSounds::handle_play_in_world(void* user_data)
LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); {
if(item.mID.isNull()) continue; LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
LLMessageSystem* msg = gMessageSystem; std::vector<LLScrollListItem*> selection = list->getAllSelected();
msg->newMessageFast(_PREHASH_SoundTrigger); std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin();
msg->nextBlockFast(_PREHASH_SoundData); std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
msg->addUUIDFast(_PREHASH_SoundID, item.mAssetID); for( ; selection_iter != selection_end; ++selection_iter)
// Client untrusted, ids set on sim {
msg->addUUIDFast(_PREHASH_OwnerID, LLUUID::null ); LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue());
msg->addUUIDFast(_PREHASH_ObjectID, LLUUID::null ); if(item.mID.isNull()) continue;
msg->addUUIDFast(_PREHASH_ParentID, LLUUID::null );
msg->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle()); LLMessageSystem* msg = gMessageSystem;
LLVector3 position = gAgent.getPositionAgent(); msg->newMessageFast(_PREHASH_SoundTrigger);
msg->addVector3Fast(_PREHASH_Position, position); msg->nextBlockFast(_PREHASH_SoundData);
msg->addF32Fast(_PREHASH_Gain, 1.0f); msg->addUUIDFast(_PREHASH_SoundID, item.mAssetID);
// Client untrusted, ids set on sim
gAgent.sendMessage(); msg->addUUIDFast(_PREHASH_OwnerID, LLUUID::null );
} msg->addUUIDFast(_PREHASH_ObjectID, LLUUID::null );
} msg->addUUIDFast(_PREHASH_ParentID, LLUUID::null );
msg->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle());
// static LLVector3 position = gAgent.getPositionAgent();
void LLFloaterExploreSounds::handle_play_ambient(void* user_data) msg->addVector3Fast(_PREHASH_Position, position);
{ msg->addF32Fast(_PREHASH_Gain, 1.0f);
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list"); gAgent.sendMessage();
std::vector<LLScrollListItem*> selection = list->getAllSelected(); }
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin(); }
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
for( ; selection_iter != selection_end; ++selection_iter) // static
{ void LLFloaterExploreSounds::handle_play_ambient(void* user_data)
LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); {
if(item.mID.isNull()) continue; LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
int gain = 0.01f; if(!gAgent.isInGroup(parcel->getGroupID()))
for(int i = 0; i < 2; i++) {
{ LLChat chat;
gMessageSystem->newMessageFast(_PREHASH_SoundTrigger); chat.mSourceType = CHAT_SOURCE_SYSTEM;
gMessageSystem->nextBlockFast(_PREHASH_SoundData); chat.mText = llformat("Can't play ambient sound: Must be on land you're grouped to.");
gMessageSystem->addUUIDFast(_PREHASH_SoundID, item.mAssetID); LLFloaterChat::addChat(chat);
gMessageSystem->addUUIDFast(_PREHASH_OwnerID, LLUUID::null); return;
gMessageSystem->addUUIDFast(_PREHASH_ObjectID, LLUUID::null); }
gMessageSystem->addUUIDFast(_PREHASH_ParentID, LLUUID::null);
gMessageSystem->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle()); LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
LLVector3d pos = -from_region_handle(gAgent.getRegion()->getHandle()); LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
gMessageSystem->addVector3Fast(_PREHASH_Position, (LLVector3)pos); std::vector<LLScrollListItem*> selection = list->getAllSelected();
gMessageSystem->addF32Fast(_PREHASH_Gain, gain); std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin();
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
gMessageSystem->sendReliable(gAgent.getRegionHost()); for( ; selection_iter != selection_end; ++selection_iter)
{
gain = 1.0f; LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue());
} if(item.mID.isNull()) continue;
} int gain = 0.01f;
} for(int i = 0; i < 2; i++)
{
gMessageSystem->newMessageFast(_PREHASH_SoundTrigger);
// static gMessageSystem->nextBlockFast(_PREHASH_SoundData);
void LLFloaterExploreSounds::handle_look_at(void* user_data) gMessageSystem->addUUIDFast(_PREHASH_SoundID, item.mAssetID);
{ gMessageSystem->addUUIDFast(_PREHASH_OwnerID, LLUUID::null);
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; gMessageSystem->addUUIDFast(_PREHASH_ObjectID, LLUUID::null);
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list"); gMessageSystem->addUUIDFast(_PREHASH_ParentID, LLUUID::null);
LLUUID selection = list->getSelectedValue().asUUID(); gMessageSystem->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle());
LLSoundHistoryItem item = floater->getItem(selection); // Single item only LLVector3d pos = -from_region_handle(gAgent.getRegion()->getHandle());
if(item.mID.isNull()) return; gMessageSystem->addVector3Fast(_PREHASH_Position, (LLVector3)pos);
gMessageSystem->addF32Fast(_PREHASH_Gain, gain);
LLVector3d pos_global = item.mPosition;
gMessageSystem->sendReliable(gAgent.getRegionHost());
// Try to find object position
if(item.mSourceID.notNull()) gain = 1.0f;
{ }
LLViewerObject* object = gObjectList.findObject(item.mSourceID); }
if(object) }
{
pos_global = object->getPositionGlobal();
} // static
} void LLFloaterExploreSounds::handle_look_at(void* user_data)
{
// Move the camera LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
// Find direction to self (reverse) LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
LLVector3d cam = gAgent.getPositionGlobal() - pos_global; LLUUID selection = list->getSelectedValue().asUUID();
cam.normalize(); LLSoundHistoryItem item = floater->getItem(selection); // Single item only
// Go 4 meters back and 3 meters up if(item.mID.isNull()) return;
cam *= 4.0f;
cam += pos_global; LLVector3d pos_global = item.mPosition;
cam += LLVector3d(0.f, 0.f, 3.0f);
// Try to find object position
gAgent.setFocusOnAvatar(FALSE, FALSE); if(item.mSourceID.notNull())
gAgent.setCameraPosAndFocusGlobal(cam, pos_global, item.mSourceID); {
gAgent.setCameraAnimating(FALSE); LLViewerObject* object = gObjectList.findObject(item.mSourceID);
} if(object)
{
// static pos_global = object->getPositionGlobal();
void LLFloaterExploreSounds::handle_open(void* user_data) }
{ }
} // Move the camera
// Find direction to self (reverse)
// static LLVector3d cam = gAgent.getPositionGlobal() - pos_global;
void LLFloaterExploreSounds::handle_copy_uuid(void* user_data) cam.normalize();
{ // Go 4 meters back and 3 meters up
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data; cam *= 4.0f;
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list"); cam += pos_global;
LLUUID selection = list->getSelectedValue().asUUID(); // Single item only cam += LLVector3d(0.f, 0.f, 3.0f);
LLSoundHistoryItem item = floater->getItem(selection);
if(item.mID.isNull()) return; gAgent.setFocusOnAvatar(FALSE, FALSE);
gAgent.setCameraPosAndFocusGlobal(cam, pos_global, item.mSourceID);
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(item.mAssetID.asString())); gAgent.setCameraAnimating(FALSE);
} }
// static // static
void LLFloaterExploreSounds::handle_stop(void* user_data) void LLFloaterExploreSounds::handle_open(void* user_data)
{ {
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list"); }
std::vector<LLScrollListItem*> selection = list->getAllSelected();
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin(); // static
std::vector<LLScrollListItem*>::iterator selection_end = selection.end(); void LLFloaterExploreSounds::handle_copy_uuid(void* user_data)
std::vector<LLUUID> asset_list; {
for( ; selection_iter != selection_end; ++selection_iter) LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
{ LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); LLUUID selection = list->getSelectedValue().asUUID(); // Single item only
if(item.mID.isNull()) continue; LLSoundHistoryItem item = floater->getItem(selection);
if(item.mPlaying) if(item.mID.isNull()) return;
{
if(item.mAudioSource) if (item.mOwnerID == gAgent.getID())
{ {
S32 type = item.mType; gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(item.mAssetID.asString()));
item.mAudioSource->setType(LLAudioEngine::AUDIO_TYPE_UI); }
if(item.mAudioSource) else
item.mAudioSource->play(LLUUID::null); {
if(item.mAudioSource) LLChat chat;
item.mAudioSource->setType(type); chat.mSourceType = CHAT_SOURCE_SYSTEM;
} chat.mText = llformat("Can't copy UUIDs you don't own.");
} LLFloaterChat::addChat(chat);
} }
} }
// static
// </edit> void LLFloaterExploreSounds::handle_stop(void* user_data)
{
LLFloaterExploreSounds* floater = (LLFloaterExploreSounds*)user_data;
LLScrollListCtrl* list = floater->getChild<LLScrollListCtrl>("sound_list");
std::vector<LLScrollListItem*> selection = list->getAllSelected();
std::vector<LLScrollListItem*>::iterator selection_iter = selection.begin();
std::vector<LLScrollListItem*>::iterator selection_end = selection.end();
std::vector<LLUUID> asset_list;
for( ; selection_iter != selection_end; ++selection_iter)
{
LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue());
if(item.mID.isNull()) continue;
if(item.mPlaying)
{
if(item.mAudioSource)
{
S32 type = item.mType;
item.mAudioSource->setType(LLAudioEngine::AUDIO_TYPE_UI);
if(item.mAudioSource)
item.mAudioSource->play(LLUUID::null);
if(item.mAudioSource)
item.mAudioSource->setType(type);
}
}
}
}
// </edit>