From af2cebd71c66cc7d845f920bb6fa898c4f3905a0 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 24 Aug 2012 23:13:22 +0200 Subject: [PATCH] Refactored sound explorer: Removed orphaned method signatures and switched to callbacks via boost::bind --- indra/newview/NACLfloaterexploresounds.cpp | 44 ++++++++-------------- indra/newview/NACLfloaterexploresounds.h | 17 ++------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/indra/newview/NACLfloaterexploresounds.cpp b/indra/newview/NACLfloaterexploresounds.cpp index 4634e0051c..12c591140a 100644 --- a/indra/newview/NACLfloaterexploresounds.cpp +++ b/indra/newview/NACLfloaterexploresounds.cpp @@ -47,25 +47,21 @@ const LLUUID collision_sounds[num_collision_sounds] = LLUUID("063c97d3-033a-4e9b-98d8-05c8074922cb") }; -NACLFloaterExploreSounds* NACLFloaterExploreSounds::sInstance; - NACLFloaterExploreSounds::NACLFloaterExploreSounds(const LLSD& key) : LLFloater(key), LLEventTimer(0.25f) { - NACLFloaterExploreSounds::sInstance = this; } NACLFloaterExploreSounds::~NACLFloaterExploreSounds() { - NACLFloaterExploreSounds::sInstance = NULL; } BOOL NACLFloaterExploreSounds::postBuild(void) { - childSetAction("play_locally_btn", handle_play_locally, this); - childSetAction("look_at_btn", handle_look_at, this); - childSetAction("stop_btn", handle_stop, this); - childSetAction("bl_btn", blacklistSound, this); + getChild("play_locally_btn")->setClickedCallback(boost::bind(&NACLFloaterExploreSounds::handle_play_locally, this)); + getChild("look_at_btn")->setClickedCallback(boost::bind(&NACLFloaterExploreSounds::handle_look_at, this)); + getChild("stop_btn")->setClickedCallback(boost::bind(&NACLFloaterExploreSounds::handle_stop, this)); + getChild("bl_btn")->setClickedCallback(boost::bind(&NACLFloaterExploreSounds::blacklistSound, this)); LLScrollListCtrl* list = getChild("sound_list"); list->setDoubleClickCallback(boost::bind(&NACLFloaterExploreSounds::handle_play_locally, this)); @@ -119,7 +115,6 @@ public: } }; -// static BOOL NACLFloaterExploreSounds::tick() { //if(childGetValue("pause_chk").asBoolean()) return FALSE; @@ -255,18 +250,16 @@ BOOL NACLFloaterExploreSounds::tick() return FALSE; } -// static -void NACLFloaterExploreSounds::handle_play_locally(void* user_data) +void NACLFloaterExploreSounds::handle_play_locally() { - NACLFloaterExploreSounds* floater = (NACLFloaterExploreSounds*)user_data; - LLScrollListCtrl* list = floater->getChild("sound_list"); + LLScrollListCtrl* list = getChild("sound_list"); std::vector selection = list->getAllSelected(); std::vector::iterator selection_iter = selection.begin(); std::vector::iterator selection_end = selection.end(); std::vector asset_list; for( ; selection_iter != selection_end; ++selection_iter) { - LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + LLSoundHistoryItem item = getItem((*selection_iter)->getValue()); if(item.mID.isNull()) continue; // Unique assets only if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end()) @@ -277,13 +270,11 @@ void NACLFloaterExploreSounds::handle_play_locally(void* user_data) } } -// static -void NACLFloaterExploreSounds::handle_look_at(void* user_data) +void NACLFloaterExploreSounds::handle_look_at() { - NACLFloaterExploreSounds* floater = (NACLFloaterExploreSounds*)user_data; - LLScrollListCtrl* list = floater->getChild("sound_list"); + LLScrollListCtrl* list = getChild("sound_list"); LLUUID selection = list->getSelectedValue().asUUID(); - LLSoundHistoryItem item = floater->getItem(selection); // Single item only + LLSoundHistoryItem item = getItem(selection); // Single item only if(item.mID.isNull()) return; LLVector3d pos_global = item.mPosition; @@ -312,18 +303,16 @@ void NACLFloaterExploreSounds::handle_look_at(void* user_data) gAgentCamera.setCameraAnimating(FALSE); } -// static -void NACLFloaterExploreSounds::handle_stop(void* user_data) +void NACLFloaterExploreSounds::handle_stop() { - NACLFloaterExploreSounds* floater = (NACLFloaterExploreSounds*)user_data; - LLScrollListCtrl* list = floater->getChild("sound_list"); + LLScrollListCtrl* list = getChild("sound_list"); std::vector selection = list->getAllSelected(); std::vector::iterator selection_iter = selection.begin(); std::vector::iterator selection_end = selection.end(); std::vector asset_list; for( ; selection_iter != selection_end; ++selection_iter) { - LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + LLSoundHistoryItem item = getItem((*selection_iter)->getValue()); if(item.mID.isNull()) continue; if(item.mPlaying) { @@ -351,17 +340,16 @@ void NACLFloaterExploreSounds::handle_stop(void* user_data) } //add sound to blacklist -void NACLFloaterExploreSounds::blacklistSound(void* user_data) +void NACLFloaterExploreSounds::blacklistSound() { - NACLFloaterExploreSounds* floater = (NACLFloaterExploreSounds*)user_data; - LLScrollListCtrl* list = floater->getChild("sound_list"); + LLScrollListCtrl* list = getChild("sound_list"); std::vector selection = list->getAllSelected(); std::vector::iterator selection_iter = selection.begin(); std::vector::iterator selection_end = selection.end(); std::vector asset_list; for( ; selection_iter != selection_end; ++selection_iter) { - LLSoundHistoryItem item = floater->getItem((*selection_iter)->getValue()); + LLSoundHistoryItem item = getItem((*selection_iter)->getValue()); if(item.mID.isNull()) continue; std::string entry_name; diff --git a/indra/newview/NACLfloaterexploresounds.h b/indra/newview/NACLfloaterexploresounds.h index 26a59ac8e7..2447c1de9c 100644 --- a/indra/newview/NACLfloaterexploresounds.h +++ b/indra/newview/NACLfloaterexploresounds.h @@ -22,23 +22,14 @@ public: LLSoundHistoryItem getItem(LLUUID itemID); - static void handle_play_locally(void* user_data); - static void handle_play_in_world(void* user_data); - static void handle_look_at(void* user_data); - static void handle_open(void* user_data); - static void handle_copy_uuid(void* user_data); - static void handle_stop(void* user_data); - static void blacklistSound(void* user_data); + void handle_play_locally(); + void handle_look_at(); + void handle_stop(); + void blacklistSound(); private: virtual ~NACLFloaterExploreSounds(); std::list mLastHistory; - -// static -public: - static NACLFloaterExploreSounds* sInstance; - - static void toggle(); }; #endif