hbfloatersoundslist.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. /**
  2. * @file hbfloatersoundslist.cpp
  3. * @brief HBFloaterSoundsList class implementation
  4. *
  5. * This class implements a floater where all sounds are listed, allowing
  6. * the user to mute a source or stop any sound.
  7. *
  8. * $LicenseInfo:firstyear=2014&license=viewergpl$
  9. *
  10. * Copyright (c) 2014, Henri Beauchamp.
  11. *
  12. * Second Life Viewer Source Code
  13. * The source code in this file ("Source Code") is provided by Linden Lab
  14. * to you under the terms of the GNU General Public License, version 2.0
  15. * ("GPL"), unless you have obtained a separate licensing agreement
  16. * ("Other License"), formally executed by you and Linden Lab. Terms of
  17. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  18. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  19. *
  20. * There are special exceptions to the terms and conditions of the GPL as
  21. * it is applied to this Source Code. View the full text of the exception
  22. * in the file doc/FLOSS-exception.txt in this software distribution, or
  23. * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
  24. *
  25. * By copying, modifying or distributing this software, you acknowledge
  26. * that you have read and understood your obligations described above,
  27. * and agree to abide by those obligations.
  28. *
  29. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  30. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  31. * COMPLETENESS OR PERFORMANCE.
  32. * $/LicenseInfo$
  33. */
  34. #include "llviewerprecompiledheaders.h"
  35. #include "hbfloatersoundslist.h"
  36. #include "llaudioengine.h"
  37. #include "llbutton.h"
  38. #include "llcachename.h"
  39. #include "llcheckboxctrl.h"
  40. #include "llscrolllistctrl.h"
  41. #include "lluictrlfactory.h"
  42. #include "llmessage.h"
  43. #include "sound_ids.h"
  44. #include "llagent.h"
  45. #include "llappviewer.h" // For gFrameTimeSeconds
  46. #include "llfloaterinspect.h"
  47. #include "llfloatermute.h"
  48. #include "llgridmanager.h" // For gIsInSecondLife
  49. #include "lltracker.h"
  50. #include "llviewercontrol.h"
  51. #include "llviewerobjectlist.h"
  52. #include "llviewerregion.h"
  53. #include "llviewerwindow.h"
  54. // We do not update the sounds list faster than that
  55. constexpr F32 MIN_UPDATE_DELAY = 1.f; // in seconds
  56. //static
  57. HBFloaterSoundsList::names_map_t HBFloaterSoundsList::sObjectNames;
  58. HBFloaterSoundsList::groups_map_t HBFloaterSoundsList::sGroupOwnedObjects;
  59. HBFloaterSoundsList::HBFloaterSoundsList(const LLSD&)
  60. : mLastUpdate(0.f),
  61. mIsDirty(true),
  62. mTrackingLocation()
  63. {
  64. // Ignore all collision/sliding/rolling sounds from sound_ids.h
  65. if (gIsInSecondLife)
  66. {
  67. mIgnoredSounds.emplace(SND_FLESH_FLESH);
  68. mIgnoredSounds.emplace(SND_FLESH_PLASTIC);
  69. mIgnoredSounds.emplace(SND_FLESH_RUBBER);
  70. mIgnoredSounds.emplace(SND_GLASS_FLESH);
  71. mIgnoredSounds.emplace(SND_GLASS_GLASS);
  72. mIgnoredSounds.emplace(SND_GLASS_PLASTIC);
  73. mIgnoredSounds.emplace(SND_GLASS_RUBBER);
  74. mIgnoredSounds.emplace(SND_GLASS_WOOD);
  75. mIgnoredSounds.emplace(SND_METAL_FLESH);
  76. mIgnoredSounds.emplace(SND_METAL_GLASS);
  77. mIgnoredSounds.emplace(SND_METAL_METAL);
  78. mIgnoredSounds.emplace(SND_METAL_PLASTIC);
  79. mIgnoredSounds.emplace(SND_METAL_RUBBER);
  80. mIgnoredSounds.emplace(SND_METAL_WOOD);
  81. mIgnoredSounds.emplace(SND_PLASTIC_PLASTIC);
  82. mIgnoredSounds.emplace(SND_RUBBER_PLASTIC);
  83. mIgnoredSounds.emplace(SND_RUBBER_RUBBER);
  84. mIgnoredSounds.emplace(SND_STONE_FLESH);
  85. mIgnoredSounds.emplace(SND_STONE_GLASS);
  86. mIgnoredSounds.emplace(SND_STONE_METAL);
  87. mIgnoredSounds.emplace(SND_STONE_PLASTIC);
  88. mIgnoredSounds.emplace(SND_STONE_RUBBER);
  89. mIgnoredSounds.emplace(SND_STONE_STONE);
  90. mIgnoredSounds.emplace(SND_STONE_WOOD);
  91. mIgnoredSounds.emplace(SND_WOOD_FLESH);
  92. mIgnoredSounds.emplace(SND_WOOD_PLASTIC);
  93. mIgnoredSounds.emplace(SND_WOOD_RUBBER);
  94. mIgnoredSounds.emplace(SND_WOOD_WOOD);
  95. mIgnoredSounds.emplace(SND_SLIDE_FLESH_FLESH);
  96. mIgnoredSounds.emplace(SND_SLIDE_FLESH_FABRIC);
  97. mIgnoredSounds.emplace(SND_SLIDE_FLESH_GRAVEL);
  98. mIgnoredSounds.emplace(SND_SLIDE_FLESH_GRAVEL_02);
  99. mIgnoredSounds.emplace(SND_SLIDE_FLESH_GRAVEL_03);
  100. mIgnoredSounds.emplace(SND_SLIDE_GLASS_GRAVEL);
  101. mIgnoredSounds.emplace(SND_SLIDE_GLASS_GRAVEL_02);
  102. mIgnoredSounds.emplace(SND_SLIDE_GLASS_GRAVEL_03);
  103. mIgnoredSounds.emplace(SND_SLIDE_METAL_FABRIC);
  104. mIgnoredSounds.emplace(SND_SLIDE_METAL_FLESH);
  105. mIgnoredSounds.emplace(SND_SLIDE_METAL_FLESH_02);
  106. mIgnoredSounds.emplace(SND_SLIDE_METAL_GLASS);
  107. mIgnoredSounds.emplace(SND_SLIDE_METAL_GLASS_02);
  108. mIgnoredSounds.emplace(SND_SLIDE_METAL_GLASS_03);
  109. mIgnoredSounds.emplace(SND_SLIDE_METAL_GLASS_04);
  110. mIgnoredSounds.emplace(SND_SLIDE_METAL_GRAVEL);
  111. mIgnoredSounds.emplace(SND_SLIDE_METAL_GRAVEL_02);
  112. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL);
  113. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL_02);
  114. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL_03);
  115. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL_04);
  116. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL_05);
  117. mIgnoredSounds.emplace(SND_SLIDE_METAL_METAL_06);
  118. mIgnoredSounds.emplace(SND_SLIDE_METAL_RUBBER);
  119. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD);
  120. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_02);
  121. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_03);
  122. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_04);
  123. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_05);
  124. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_06);
  125. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_07);
  126. mIgnoredSounds.emplace(SND_SLIDE_METAL_WOOD_08);
  127. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL);
  128. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL_02);
  129. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL_03);
  130. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL_04);
  131. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL_05);
  132. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_GRAVEL_06);
  133. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_FABRIC);
  134. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_FABRIC_02);
  135. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_FABRIC_03);
  136. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_FABRIC_04);
  137. mIgnoredSounds.emplace(SND_SLIDE_RUBBER_PLASTIC);
  138. mIgnoredSounds.emplace(SND_SLIDE_RUBBER_PLASTIC_02);
  139. mIgnoredSounds.emplace(SND_SLIDE_RUBBER_PLASTIC_03);
  140. mIgnoredSounds.emplace(SND_SLIDE_STONE_PLASTIC);
  141. mIgnoredSounds.emplace(SND_SLIDE_STONE_PLASTIC_02);
  142. mIgnoredSounds.emplace(SND_SLIDE_STONE_PLASTIC_03);
  143. mIgnoredSounds.emplace(SND_SLIDE_STONE_RUBBER);
  144. mIgnoredSounds.emplace(SND_SLIDE_STONE_RUBBER_02);
  145. mIgnoredSounds.emplace(SND_SLIDE_STONE_STONE);
  146. mIgnoredSounds.emplace(SND_SLIDE_STONE_STONE_02);
  147. mIgnoredSounds.emplace(SND_SLIDE_STONE_WOOD);
  148. mIgnoredSounds.emplace(SND_SLIDE_STONE_WOOD_02);
  149. mIgnoredSounds.emplace(SND_SLIDE_STONE_WOOD_03);
  150. mIgnoredSounds.emplace(SND_SLIDE_STONE_WOOD_04);
  151. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FABRIC);
  152. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FABRIC_02);
  153. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FABRIC_03);
  154. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FABRIC_04);
  155. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FLESH);
  156. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FLESH_02);
  157. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FLESH_03);
  158. mIgnoredSounds.emplace(SND_SLIDE_WOOD_FLESH_04);
  159. mIgnoredSounds.emplace(SND_SLIDE_WOOD_GRAVEL);
  160. mIgnoredSounds.emplace(SND_SLIDE_WOOD_GRAVEL_02);
  161. mIgnoredSounds.emplace(SND_SLIDE_WOOD_GRAVEL_03);
  162. mIgnoredSounds.emplace(SND_SLIDE_WOOD_GRAVEL_04);
  163. mIgnoredSounds.emplace(SND_SLIDE_WOOD_PLASTIC);
  164. mIgnoredSounds.emplace(SND_SLIDE_WOOD_PLASTIC_02);
  165. mIgnoredSounds.emplace(SND_SLIDE_WOOD_PLASTIC_03);
  166. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD);
  167. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_02);
  168. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_03);
  169. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_04);
  170. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_05);
  171. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_06);
  172. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_07);
  173. mIgnoredSounds.emplace(SND_SLIDE_WOOD_WOOD_08);
  174. mIgnoredSounds.emplace(SND_ROLL_FLESH_PLASTIC);
  175. mIgnoredSounds.emplace(SND_ROLL_FLESH_PLASTIC_02);
  176. mIgnoredSounds.emplace(SND_ROLL_GLASS_GRAVEL);
  177. mIgnoredSounds.emplace(SND_ROLL_GLASS_GRAVEL_02);
  178. mIgnoredSounds.emplace(SND_ROLL_GLASS_WOOD);
  179. mIgnoredSounds.emplace(SND_ROLL_GLASS_WOOD_02);
  180. mIgnoredSounds.emplace(SND_ROLL_GRAVEL_GRAVEL);
  181. mIgnoredSounds.emplace(SND_ROLL_GRAVEL_GRAVEL_02);
  182. mIgnoredSounds.emplace(SND_ROLL_METAL_FABRIC);
  183. mIgnoredSounds.emplace(SND_ROLL_METAL_FABRIC_02);
  184. mIgnoredSounds.emplace(SND_ROLL_METAL_GLASS);
  185. mIgnoredSounds.emplace(SND_ROLL_METAL_GLASS_02);
  186. mIgnoredSounds.emplace(SND_ROLL_METAL_GLASS_03);
  187. mIgnoredSounds.emplace(SND_ROLL_METAL_GRAVEL);
  188. mIgnoredSounds.emplace(SND_ROLL_METAL_METAL);
  189. mIgnoredSounds.emplace(SND_ROLL_METAL_METAL_02);
  190. mIgnoredSounds.emplace(SND_ROLL_METAL_METAL_03);
  191. mIgnoredSounds.emplace(SND_ROLL_METAL_METAL_04);
  192. mIgnoredSounds.emplace(SND_ROLL_METAL_PLASTIC);
  193. mIgnoredSounds.emplace(SND_ROLL_METAL_PLASTIC_01);
  194. mIgnoredSounds.emplace(SND_ROLL_METAL_WOOD);
  195. mIgnoredSounds.emplace(SND_ROLL_METAL_WOOD_02);
  196. mIgnoredSounds.emplace(SND_ROLL_METAL_WOOD_03);
  197. mIgnoredSounds.emplace(SND_ROLL_METAL_WOOD_04);
  198. mIgnoredSounds.emplace(SND_ROLL_METAL_WOOD_05);
  199. mIgnoredSounds.emplace(SND_ROLL_PLASTIC_FABRIC);
  200. mIgnoredSounds.emplace(SND_ROLL_PLASTIC_PLASTIC);
  201. mIgnoredSounds.emplace(SND_ROLL_PLASTIC_PLASTIC_02);
  202. mIgnoredSounds.emplace(SND_ROLL_STONE_PLASTIC);
  203. mIgnoredSounds.emplace(SND_ROLL_STONE_STONE);
  204. mIgnoredSounds.emplace(SND_ROLL_STONE_STONE_02);
  205. mIgnoredSounds.emplace(SND_ROLL_STONE_STONE_03);
  206. mIgnoredSounds.emplace(SND_ROLL_STONE_STONE_04);
  207. mIgnoredSounds.emplace(SND_ROLL_STONE_STONE_05);
  208. mIgnoredSounds.emplace(SND_ROLL_STONE_WOOD);
  209. mIgnoredSounds.emplace(SND_ROLL_STONE_WOOD_02);
  210. mIgnoredSounds.emplace(SND_ROLL_STONE_WOOD_03);
  211. mIgnoredSounds.emplace(SND_ROLL_STONE_WOOD_04);
  212. mIgnoredSounds.emplace(SND_ROLL_WOOD_FLESH);
  213. mIgnoredSounds.emplace(SND_ROLL_WOOD_FLESH_02);
  214. mIgnoredSounds.emplace(SND_ROLL_WOOD_FLESH_03);
  215. mIgnoredSounds.emplace(SND_ROLL_WOOD_FLESH_04);
  216. mIgnoredSounds.emplace(SND_ROLL_WOOD_GRAVEL);
  217. mIgnoredSounds.emplace(SND_ROLL_WOOD_GRAVEL_02);
  218. mIgnoredSounds.emplace(SND_ROLL_WOOD_GRAVEL_03);
  219. mIgnoredSounds.emplace(SND_ROLL_WOOD_PLASTIC);
  220. mIgnoredSounds.emplace(SND_ROLL_WOOD_PLASTIC_02);
  221. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD);
  222. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_02);
  223. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_03);
  224. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_04);
  225. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_05);
  226. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_06);
  227. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_07);
  228. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_08);
  229. mIgnoredSounds.emplace(SND_ROLL_WOOD_WOOD_09);
  230. mIgnoredSounds.emplace(SND_SLIDE_STONE_STONE_01);
  231. mIgnoredSounds.emplace(SND_STONE_DIRT_01);
  232. mIgnoredSounds.emplace(SND_STONE_DIRT_02);
  233. mIgnoredSounds.emplace(SND_STONE_DIRT_03);
  234. mIgnoredSounds.emplace(SND_STONE_DIRT_04);
  235. mIgnoredSounds.emplace(SND_STONE_STONE_02);
  236. mIgnoredSounds.emplace(SND_STONE_STONE_04);
  237. mIgnoredSounds.emplace(SND_STEP_ON_LAND);
  238. mIgnoredSounds.emplace(SND_OPENSIM_COLLISION);
  239. #if 0 // These are NULL UUIDs...
  240. mIgnoredSounds.emplace(SND_SLIDE_FLESH_PLASTIC);
  241. mIgnoredSounds.emplace(SND_SLIDE_FLESH_RUBBER);
  242. mIgnoredSounds.emplace(SND_SLIDE_GLASS_FLESH);
  243. mIgnoredSounds.emplace(SND_SLIDE_GLASS_GLASS);
  244. mIgnoredSounds.emplace(SND_SLIDE_GLASS_PLASTIC);
  245. mIgnoredSounds.emplace(SND_SLIDE_GLASS_RUBBER);
  246. mIgnoredSounds.emplace(SND_SLIDE_GLASS_WOOD);
  247. mIgnoredSounds.emplace(SND_SLIDE_METAL_PLASTIC);
  248. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_PLASTIC);
  249. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_PLASTIC_02);
  250. mIgnoredSounds.emplace(SND_SLIDE_PLASTIC_PLASTIC_03);
  251. mIgnoredSounds.emplace(SND_SLIDE_RUBBER_RUBBER);
  252. mIgnoredSounds.emplace(SND_SLIDE_STONE_FLESH);
  253. mIgnoredSounds.emplace(SND_SLIDE_STONE_GLASS);
  254. mIgnoredSounds.emplace(SND_SLIDE_STONE_METAL);
  255. mIgnoredSounds.emplace(SND_SLIDE_WOOD_RUBBER);
  256. mIgnoredSounds.emplace(SND_ROLL_FLESH_FLESH);
  257. mIgnoredSounds.emplace(SND_ROLL_FLESH_RUBBER);
  258. mIgnoredSounds.emplace(SND_ROLL_GLASS_FLESH);
  259. mIgnoredSounds.emplace(SND_ROLL_GLASS_GLASS);
  260. mIgnoredSounds.emplace(SND_ROLL_GLASS_PLASTIC);
  261. mIgnoredSounds.emplace(SND_ROLL_GLASS_RUBBER);
  262. mIgnoredSounds.emplace(SND_ROLL_METAL_FLESH);
  263. mIgnoredSounds.emplace(SND_ROLL_METAL_RUBBER);
  264. mIgnoredSounds.emplace(SND_ROLL_RUBBER_PLASTIC);
  265. mIgnoredSounds.emplace(SND_ROLL_RUBBER_RUBBER);
  266. mIgnoredSounds.emplace(SND_ROLL_STONE_FLESH);
  267. mIgnoredSounds.emplace(SND_ROLL_STONE_GLASS);
  268. mIgnoredSounds.emplace(SND_ROLL_STONE_METAL);
  269. mIgnoredSounds.emplace(SND_ROLL_STONE_RUBBER);
  270. mIgnoredSounds.emplace(SND_ROLL_WOOD_RUBBER);
  271. #endif
  272. }
  273. else
  274. {
  275. // Just one collision sound available in OpenSIM...
  276. mIgnoredSounds.emplace(SND_OPENSIM_COLLISION);
  277. }
  278. LLUICtrlFactory::getInstance()->buildFloater(this,
  279. "floater_sounds_list.xml");
  280. LLMuteList::addObserver(this);
  281. }
  282. //virtual
  283. HBFloaterSoundsList::~HBFloaterSoundsList()
  284. {
  285. LLMuteList::removeObserver(this);
  286. }
  287. //virtual
  288. bool HBFloaterSoundsList::postBuild()
  289. {
  290. mSoundsList = getChild<LLScrollListCtrl>("sounds_list");
  291. mSoundsList->setCommitCallback(onSelectSound);
  292. mSoundsList->setDoubleClickCallback(onDoubleClick);
  293. mSoundsList->setCallbackUserData(this);
  294. mPlayFlyoutBtn = getChild<LLFlyoutButton>("play");
  295. mPlayFlyoutBtn->setCommitCallback(onPlaySoundBtn);
  296. mPlayFlyoutBtn->setCallbackUserData(this);
  297. mPlayFlyoutBtn->setEnabled(false);
  298. mBlockSoundBtn = getChild<LLFlyoutButton>("block");
  299. mBlockSoundBtn->setCommitCallback(onBlockSoundBtn);
  300. mBlockSoundBtn->setCallbackUserData(this);
  301. mBlockSoundBtn->setEnabled(false);
  302. mShowFlyoutBtn = getChild<LLFlyoutButton>("show");
  303. mShowFlyoutBtn->setCommitCallback(onShowSourceBtn);
  304. mShowFlyoutBtn->setCallbackUserData(this);
  305. mShowFlyoutBtn->setEnabled(false);
  306. mMuteFlyoutBtn = getChild<LLFlyoutButton>("mute_object");
  307. mMuteFlyoutBtn->setCommitCallback(onMuteObjectBtn);
  308. mMuteFlyoutBtn->setCallbackUserData(this);
  309. mMuteFlyoutBtn->setEnabled(false);
  310. mMuteOwnerBtn = getChild<LLButton>("mute_owner");
  311. mMuteOwnerBtn->setClickedCallback(onMuteOwnerBtn, this);
  312. mMuteOwnerBtn->setEnabled(false);
  313. mFreezeCheck = getChild<LLCheckBoxCtrl>("freeze");
  314. mNoneString = getString("none");
  315. mLoadingString = getString("loading");
  316. mAttachmentString = getString("attachment");
  317. return true;
  318. }
  319. //virtual
  320. void HBFloaterSoundsList::draw()
  321. {
  322. static LLCachedControl<bool> play_attached(gSavedSettings,
  323. "EnableAttachmentSounds");
  324. if (!mTrackingLocation.isExactlyZero())
  325. {
  326. F32 dist = 3.f;
  327. if (gTracker.getTrackingStatus() == LLTracker::TRACKING_LOCATION)
  328. {
  329. dist = fabsf((F32)(gTracker.getTrackedPositionGlobal() -
  330. mTrackingLocation).length());
  331. }
  332. if (dist > 2.f)
  333. {
  334. // Tracker stopped or tracking another location
  335. mTrackingID.setNull();
  336. mTrackingLocation.setZero();
  337. mIsDirty = true;
  338. mLastUpdate = 0.f; // force an immediate update
  339. }
  340. }
  341. if (gAudiop && !mFreezeCheck->get() && !isMinimized() &&
  342. (mIsDirty || gAudiop->mSourcesUpdated) &&
  343. gFrameTimeSeconds - mLastUpdate >= MIN_UPDATE_DELAY)
  344. {
  345. mLastUpdate = gFrameTimeSeconds;
  346. gAudiop->mSourcesUpdated = false; // Reset the flag
  347. LLUUID cur_source_id, cur_object_id, cur_sound_id, selected_id;
  348. LLScrollListItem* item = mSoundsList->getFirstSelected();
  349. if (item)
  350. {
  351. cur_sound_id = item->getColumn(LIST_SOUND)->getValue().asUUID();
  352. cur_source_id = item->getColumn(LIST_SOURCE_ID)->getValue().asUUID();
  353. cur_object_id = item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  354. }
  355. S32 scrollpos = mSoundsList->getScrollPos();
  356. mSoundsList->deleteAllItems();
  357. LLUUID owner_id, source_id, object_id, item_id;
  358. std::string owner_name, object_name, style;
  359. for (LLAudioEngine::source_map_t::const_iterator
  360. it = gAudiop->mAllSources.begin(),
  361. end = gAudiop->mAllSources.end();
  362. it != end; ++it)
  363. {
  364. const LLAudioSource* source = it->second;
  365. if (!source) // Paranoia
  366. {
  367. continue;
  368. }
  369. const uuid_list_t& sounds = source->getPlayedSoundsUUIDs();
  370. if (sounds.empty())
  371. {
  372. // No sound played for this source, so far... Skip it.
  373. continue;
  374. }
  375. LLViewerObject* objectp = NULL;
  376. source_id = object_id = source->getID();
  377. if (object_id.notNull())
  378. {
  379. objectp = gObjectList.findObject(object_id);
  380. if (!objectp)
  381. {
  382. // It is most likey an object-less source (triggered sound
  383. // or UI sound). Treat it as such and report no object for
  384. // it.
  385. object_id.setNull();
  386. }
  387. }
  388. bool loading_object = false;
  389. if (objectp)
  390. {
  391. // Always use the root-edit name and Id (since we cannot get
  392. // any info for non-root objects without editing them for good.
  393. LLViewerObject* parentp = objectp->getRootEdit();
  394. if (parentp)
  395. {
  396. object_id = parentp->getID();
  397. }
  398. else
  399. {
  400. parentp = objectp;
  401. }
  402. names_map_t::iterator nit = sObjectNames.find(object_id);
  403. if (nit != sObjectNames.end())
  404. {
  405. object_name = nit->second;
  406. }
  407. else if (parentp->isAttachment())
  408. {
  409. // Do not bother asking for details: attachments info
  410. // cannot be gathered that easily...
  411. object_name = mAttachmentString;
  412. // ... and store for faster, future lookups:
  413. sObjectNames.emplace(object_id, object_name);
  414. }
  415. else
  416. {
  417. requestInfo(object_id);
  418. object_name = mLoadingString;
  419. loading_object = true;
  420. }
  421. }
  422. else
  423. {
  424. object_name = mNoneString;
  425. }
  426. bool loading_owner = false;
  427. owner_id = source->getOwnerID();
  428. if (owner_id.isNull())
  429. {
  430. LL_DEBUGS("SoundsList") << "No object owner stored in LLAudioSource for object:"
  431. << object_id << LL_ENDL;
  432. if (objectp)
  433. {
  434. owner_id = objectp->mOwnerID;
  435. }
  436. }
  437. if (owner_id.isNull())
  438. {
  439. if (object_id.notNull())
  440. {
  441. groups_map_t::iterator git =
  442. sGroupOwnedObjects.find(object_id);
  443. if (git != sGroupOwnedObjects.end())
  444. {
  445. owner_id = git->second;
  446. }
  447. else
  448. {
  449. LL_DEBUGS("SoundsList") << "No object owner stored in LLViewerObject for object:"
  450. << object_id << LL_ENDL;
  451. // No info about the owner... We will find out via the
  452. // object info request
  453. requestInfo(object_id);
  454. owner_name = mLoadingString;
  455. loading_owner = true;
  456. }
  457. }
  458. else
  459. {
  460. owner_name = getString("unknown");
  461. }
  462. }
  463. if (gCacheNamep && owner_id.notNull())
  464. {
  465. bool group_owned = sGroupOwnedObjects.count(object_id) != 0;
  466. bool ret = group_owned ?
  467. gCacheNamep->getGroupName(owner_id, owner_name) :
  468. gCacheNamep->getFullName(owner_id, owner_name);
  469. if (!ret)
  470. {
  471. gCacheNamep->get(owner_id, group_owned,
  472. boost::bind(&HBFloaterSoundsList::setDirty));
  473. owner_name = mLoadingString;
  474. loading_owner = true;
  475. }
  476. }
  477. bool muted_object = owner_id != gAgentID && object_id.notNull() &&
  478. (LLMuteList::isMuted(object_id) ||
  479. (!play_attached &&
  480. object_name == mAttachmentString));
  481. bool muted_owner = owner_id != gAgentID && owner_id.notNull() &&
  482. LLMuteList::isMuted(owner_id,
  483. LLMute::flagObjectSounds);
  484. if ((object_id.notNull() && object_id == mTrackingID) ||
  485. (object_id.isNull() && source_id == mTrackingID))
  486. {
  487. style = "BOLD";
  488. }
  489. else
  490. {
  491. style = "NORMAL";
  492. }
  493. for (uuid_list_t::const_iterator sit = sounds.begin(),
  494. send = sounds.end();
  495. sit != send; ++sit)
  496. {
  497. const LLUUID& sound_id = *sit;
  498. if (sound_id.isNull() || mIgnoredSounds.count(sound_id) ||
  499. (object_id.isNull() && owner_id == gAgentID &&
  500. gAudiop->isUISound(sound_id)))
  501. {
  502. // Do not take into account the sounds played by the grid's
  503. // physics engine (collision, sliding, rolling sounds),
  504. // neither the UI sounds played by the viewer, neither a
  505. // null uuid (paranoia).
  506. continue;
  507. }
  508. // Note: a same source Id may appear several times in the list,
  509. // associated with several sounds; a sound Id may be used in
  510. // several sources; an object may use several sources...
  511. // Since we must use a unique Id for each list element, let's
  512. // generate one randomly...
  513. item_id.generate();
  514. // Retain this line as the selected one if the sound_id and
  515. // either the object_id (when not null) or source_id match the
  516. // ones that were selected before the list was cleared.
  517. if (sound_id == cur_sound_id &&
  518. ((object_id.notNull() && object_id == cur_object_id) ||
  519. (object_id.isNull() && source_id == cur_source_id)))
  520. {
  521. selected_id = item_id;
  522. }
  523. LLSD element;
  524. element["id"] = item_id;
  525. LLSD& sound_column = element["columns"][LIST_SOUND];
  526. sound_column["column"] = "sound";
  527. sound_column["value"] = sound_id.asString();
  528. sound_column["font-style"] = style;
  529. if (LLAudioData::isBlockedSound(sound_id))
  530. {
  531. sound_column["color"] = LLColor4::red2.getValue();
  532. }
  533. LLSD& object_column = element["columns"][LIST_OBJECT];
  534. object_column["column"] = "object";
  535. object_column["value"] = object_name;
  536. object_column["font-style"] = loading_object ? style + "|ITALIC"
  537. : style;
  538. if (muted_object)
  539. {
  540. object_column["color"] = LLColor4::red2.getValue();
  541. }
  542. LLSD& owner_column = element["columns"][LIST_OWNER];
  543. owner_column["column"] = "owner";
  544. owner_column["value"] = owner_name;
  545. owner_column["font-style"] = loading_owner ? style + "|ITALIC"
  546. : style;
  547. if (muted_owner)
  548. {
  549. owner_column["color"] = LLColor4::red2.getValue();
  550. }
  551. LLSD& srcid_column = element["columns"][LIST_SOURCE_ID];
  552. srcid_column["column"] = "source_id";
  553. srcid_column["value"] = source_id;
  554. LLSD& objid_column = element["columns"][LIST_OBJECT_ID];
  555. objid_column["column"] = "object_id";
  556. objid_column["value"] = object_id;
  557. LLSD& ownid_column = element["columns"][LIST_OWNER_ID];
  558. ownid_column["column"] = "owner_id";
  559. ownid_column["value"] = owner_id;
  560. mSoundsList->addElement(element, ADD_SORTED);
  561. }
  562. }
  563. mSoundsList->setScrollPos(scrollpos);
  564. if (selected_id.notNull())
  565. {
  566. mSoundsList->selectByID(selected_id);
  567. #if 0 // This can become rather annoying on fast refreshing lists...
  568. mSoundsList->scrollToShowSelected();
  569. #endif
  570. }
  571. else
  572. {
  573. mSoundsList->deselectAllItems(true);
  574. mPlayFlyoutBtn->setEnabled(false);
  575. mShowFlyoutBtn->setEnabled(false);
  576. mBlockSoundBtn->setEnabled(false);
  577. mMuteFlyoutBtn->setEnabled(false);
  578. mMuteOwnerBtn->setEnabled(false);
  579. mSelectedLocation.setZero();
  580. }
  581. mIsDirty = false;
  582. }
  583. LLFloater::draw();
  584. }
  585. //virtual
  586. void HBFloaterSoundsList::onChange()
  587. {
  588. mIsDirty = true;
  589. mLastUpdate = 0.f; // Force an immediate update
  590. setButtonsStatus();
  591. }
  592. void HBFloaterSoundsList::setButtonsStatus()
  593. {
  594. LLScrollListItem* item = mSoundsList->getFirstSelected();
  595. bool selected = item != NULL;
  596. mPlayFlyoutBtn->setEnabled(selected);
  597. mShowFlyoutBtn->setEnabled(selected);
  598. mBlockSoundBtn->setEnabled(selected);
  599. mMuteFlyoutBtn->setEnabled(selected);
  600. mMuteOwnerBtn->setEnabled(selected);
  601. if (selected)
  602. {
  603. const LLUUID& sound_id =
  604. item->getColumn(LIST_SOUND)->getValue().asUUID();
  605. if (LLAudioData::isBlockedSound(sound_id))
  606. {
  607. mBlockSoundBtn->setLabel(getString("allow_sound_text"));
  608. mPlayFlyoutBtn->setEnabled(false); // We cannot play it anyway
  609. }
  610. else
  611. {
  612. mBlockSoundBtn->setLabel(getString("block_sound_text"));
  613. }
  614. const LLUUID& object_id =
  615. item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  616. if (object_id.notNull() && LLMuteList::isMuted(object_id))
  617. {
  618. mMuteFlyoutBtn->setLabel(getString("unmute_object_text"));
  619. }
  620. else
  621. {
  622. mMuteFlyoutBtn->setLabel(getString("mute_object_text"));
  623. }
  624. // Set the selected source location
  625. LLVector3d pos_global;
  626. if (object_id.notNull())
  627. {
  628. LLViewerObject* objectp = gObjectList.findObject(object_id);
  629. if (objectp)
  630. {
  631. pos_global = objectp->getPositionGlobal();
  632. }
  633. }
  634. if (pos_global.isExactlyZero())
  635. {
  636. // Get the source id
  637. const LLUUID& source_id =
  638. item->getColumn(LIST_SOURCE_ID)->getValue().asUUID();
  639. // Find the source (if still there) and its position
  640. for (LLAudioEngine::source_map_t::const_iterator
  641. it = gAudiop->mAllSources.begin(),
  642. end = gAudiop->mAllSources.end();
  643. it != end; ++it)
  644. {
  645. const LLAudioSource* source = it->second;
  646. if (source && source->getID() == source_id)
  647. {
  648. pos_global = source->getPositionGlobal();
  649. break;
  650. }
  651. }
  652. }
  653. mSelectedLocation = pos_global;
  654. const LLUUID& owner_id =
  655. item->getColumn(LIST_OWNER_ID)->getValue().asUUID();
  656. if (owner_id.notNull() &&
  657. LLMuteList::isMuted(owner_id, LLMute::flagObjectSounds))
  658. {
  659. mMuteOwnerBtn->setLabel(getString("unmute_owner_text"));
  660. }
  661. else
  662. {
  663. mMuteOwnerBtn->setLabel(getString("mute_owner_text"));
  664. }
  665. if (owner_id == gAgentID)
  666. {
  667. // Cannot mute self...
  668. mMuteFlyoutBtn->setEnabled(false);
  669. mMuteOwnerBtn->setEnabled(false);
  670. }
  671. if (object_id.isNull())
  672. {
  673. mMuteFlyoutBtn->setEnabled(false);
  674. mShowFlyoutBtn->setEnabled(false);
  675. }
  676. if (owner_id.isNull())
  677. {
  678. mMuteOwnerBtn->setEnabled(false);
  679. }
  680. }
  681. else
  682. {
  683. mSelectedLocation.setZero();
  684. }
  685. }
  686. void HBFloaterSoundsList::requestInfo(const LLUUID& object_id)
  687. {
  688. LLMessageSystem* msg = gMessageSystemp;
  689. if (msg && object_id.notNull() && !mRequests.count(object_id))
  690. {
  691. LLViewerObject* objectp = gObjectList.findObject(object_id);
  692. if (objectp)
  693. {
  694. LLViewerRegion* regionp = objectp->getRegion();
  695. LLMessageSystem* msg = gMessageSystemp;
  696. if (regionp && msg)
  697. {
  698. mRequests.emplace(object_id);
  699. msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily);
  700. msg->nextBlockFast(_PREHASH_AgentData);
  701. msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
  702. msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
  703. msg->nextBlockFast(_PREHASH_ObjectData);
  704. msg->addU32Fast(_PREHASH_RequestFlags, 0);
  705. msg->addUUIDFast(_PREHASH_ObjectID, object_id);
  706. msg->sendReliable(regionp->getHost());
  707. LL_DEBUGS("SoundsList") << "Sent data request for object "
  708. << object_id << LL_ENDL;
  709. }
  710. }
  711. }
  712. }
  713. //static
  714. void HBFloaterSoundsList::setDirty()
  715. {
  716. HBFloaterSoundsList* self = findInstance();
  717. if (self)
  718. {
  719. self->mIsDirty = true;
  720. self->mLastUpdate = 0.f; // Force an immediate update
  721. self->setButtonsStatus();
  722. }
  723. }
  724. //static
  725. void HBFloaterSoundsList::processObjectPropertiesFamily(LLMessageSystem* msg)
  726. {
  727. HBFloaterSoundsList* self = findInstance();
  728. if (!msg || !self) return;
  729. LLUUID object_id;
  730. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, object_id);
  731. if (!self->mRequests.count(object_id))
  732. {
  733. // Object data not requested by us.
  734. return;
  735. }
  736. self->mRequests.erase(object_id);
  737. LL_DEBUGS("SoundsList") << "Got info for object: " << object_id << LL_ENDL;
  738. LLUUID owner_id;
  739. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_OwnerID, owner_id);
  740. if (owner_id.isNull())
  741. {
  742. msg->getUUIDFast(_PREHASH_ObjectData, _PREHASH_GroupID, owner_id);
  743. sGroupOwnedObjects.emplace(object_id, owner_id);
  744. }
  745. else
  746. {
  747. LLViewerObject* obj = gObjectList.findObject(object_id);
  748. if (obj && obj->mOwnerID.isNull())
  749. {
  750. LL_DEBUGS("SoundsList") << "Setting the owner in LLViewerObject to: "
  751. << owner_id << LL_ENDL;
  752. obj->mOwnerID = owner_id;
  753. }
  754. }
  755. std::string name;
  756. msg->getStringFast(_PREHASH_ObjectData, _PREHASH_Name, name);
  757. sObjectNames.emplace(object_id, name);
  758. self->mIsDirty = true;
  759. }
  760. //static
  761. void HBFloaterSoundsList::newRegion()
  762. {
  763. // We changed region so we can clear the object names cache.
  764. sObjectNames.clear();
  765. sGroupOwnedObjects.clear();
  766. HBFloaterSoundsList* self = findInstance();
  767. if (self)
  768. {
  769. self->mIsDirty = true;
  770. self->mLastUpdate = 0.f; // Force an immediate update
  771. }
  772. }
  773. //static
  774. LLVector3d HBFloaterSoundsList::selectedLocation()
  775. {
  776. HBFloaterSoundsList* self = findInstance();
  777. return self ? self->mSelectedLocation : LLVector3d();
  778. }
  779. //static
  780. void HBFloaterSoundsList::onPlaySoundBtn(LLUICtrl* ctrl, void* userdata)
  781. {
  782. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  783. if (!self || !ctrl || !gWindowp) return;
  784. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  785. if (!item) return;
  786. // Get the sound id
  787. LLUUID sound_id = item->getColumn(LIST_SOUND)->getValue().asUUID();
  788. if (ctrl->getValue().asString() == "copy_id")
  789. {
  790. gWindowp->copyTextToClipboard(utf8str_to_wstring(sound_id.asString()));
  791. }
  792. else if (gAudiop)
  793. {
  794. gAudiop->triggerSound(sound_id, gAgentID, 1.f,
  795. LLAudioEngine::AUDIO_TYPE_SFX);
  796. }
  797. }
  798. //static
  799. void HBFloaterSoundsList::onBlockSoundBtn(LLUICtrl* ctrl, void* userdata)
  800. {
  801. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  802. if (!self || !ctrl) return;
  803. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  804. if (!item) return;
  805. const LLUUID& sound_id = item->getColumn(LIST_SOUND)->getValue().asUUID();
  806. bool blocked = LLAudioData::isBlockedSound(sound_id);
  807. if (ctrl->getValue().asString() == "block_all_same_owner")
  808. {
  809. const LLUUID& owner_id =
  810. item->getColumn(LIST_OWNER_ID)->getValue().asUUID();
  811. if (owner_id.isNull()) return;
  812. std::vector<LLScrollListItem*> list = self->mSoundsList->getAllData();
  813. for (U32 i = 0, count = list.size(); i < count; ++i)
  814. {
  815. item = list[i];
  816. if (item->getColumn(LIST_OWNER_ID)->getValue().asUUID() ==
  817. owner_id)
  818. {
  819. const LLUUID& id =
  820. item->getColumn(LIST_SOUND)->getValue().asUUID();
  821. LLAudioData::blockSound(id, !blocked);
  822. }
  823. }
  824. }
  825. else if (ctrl->getValue().asString() == "block_all_same_name")
  826. {
  827. const LLUUID& object_id =
  828. item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  829. if (object_id.isNull()) return;
  830. std::string obj_name =
  831. item->getColumn(LIST_OBJECT)->getValue().asString();
  832. if (obj_name.empty() || obj_name == self->mLoadingString)
  833. {
  834. return;
  835. }
  836. std::vector<LLScrollListItem*> list = self->mSoundsList->getAllData();
  837. for (U32 i = 0, count = list.size(); i < count; ++i)
  838. {
  839. item = list[i];
  840. if (item->getColumn(LIST_OBJECT)->getValue().asString() ==
  841. obj_name)
  842. {
  843. const LLUUID& id =
  844. item->getColumn(LIST_SOUND)->getValue().asUUID();
  845. LLAudioData::blockSound(id, !blocked);
  846. }
  847. }
  848. }
  849. else
  850. {
  851. LLAudioData::blockSound(sound_id, !blocked);
  852. }
  853. self->mIsDirty = true;
  854. self->mLastUpdate = 0.f; // Force an immediate update
  855. self->setButtonsStatus();
  856. }
  857. //static
  858. void HBFloaterSoundsList::onMuteOwnerBtn(void* userdata)
  859. {
  860. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  861. if (!self) return;
  862. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  863. if (!item) return;
  864. const LLUUID& owner_id =
  865. item->getColumn(LIST_OWNER_ID)->getValue().asUUID();
  866. if (owner_id.isNull()) return;
  867. std::string name;
  868. if (gCacheNamep)
  869. {
  870. gCacheNamep->getFullName(owner_id, name);
  871. }
  872. LLMute mute(owner_id, name, LLMute::AGENT);
  873. if (LLMuteList::isMuted(mute.mID, LLMute::flagObjectSounds))
  874. {
  875. LLMuteList::remove(mute, LLMute::flagObjectSounds);
  876. }
  877. else if (LLMuteList::add(mute, LLMute::flagObjectSounds))
  878. {
  879. LLFloaterMute::selectMute(mute.mID);
  880. }
  881. }
  882. //static
  883. void HBFloaterSoundsList::onShowSourceBtn(LLUICtrl* ctrl, void* userdata)
  884. {
  885. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  886. if (!self || !ctrl) return;
  887. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  888. if (!item) return;
  889. const LLUUID& object_id =
  890. item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  891. if (object_id.isNull()) return;
  892. if (ctrl->getValue().asString() == "inspect")
  893. {
  894. LLViewerObject* objectp = gObjectList.findObject(object_id);
  895. if (objectp)
  896. {
  897. LLFloaterInspect::show(objectp);
  898. }
  899. }
  900. else
  901. {
  902. gAgent.lookAtObject(object_id, CAMERA_POSITION_OBJECT);
  903. }
  904. }
  905. //static
  906. void HBFloaterSoundsList::onMuteObjectBtn(LLUICtrl* ctrl, void* userdata)
  907. {
  908. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  909. if (!self || !ctrl) return;
  910. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  911. if (!item) return;
  912. const LLUUID& object_id =
  913. item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  914. if (object_id.isNull()) return;
  915. std::string obj_name;
  916. names_map_t::iterator it = sObjectNames.find(object_id);
  917. if (it != sObjectNames.end())
  918. {
  919. obj_name = it->second;
  920. }
  921. if (ctrl->getValue().asString() == "mute_by_name")
  922. {
  923. LLMute mute(LLUUID::null, obj_name, LLMute::BY_NAME);
  924. if (LLMuteList::isMuted(LLUUID::null, mute.mName))
  925. {
  926. LLMuteList::remove(mute);
  927. }
  928. else if (LLMuteList::add(mute))
  929. {
  930. LLFloaterMute::selectMute(mute.mName);
  931. }
  932. }
  933. else
  934. {
  935. LLMute mute(object_id, obj_name, LLMute::OBJECT);
  936. if (LLMuteList::isMuted(mute.mID, mute.mName))
  937. {
  938. LLMuteList::remove(mute);
  939. }
  940. else if (LLMuteList::add(mute))
  941. {
  942. LLFloaterMute::selectMute(mute.mID);
  943. }
  944. }
  945. }
  946. //static
  947. void HBFloaterSoundsList::onSelectSound(LLUICtrl*, void* userdata)
  948. {
  949. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  950. if (self)
  951. {
  952. self->setButtonsStatus();
  953. }
  954. }
  955. //static
  956. void HBFloaterSoundsList::onDoubleClick(void* userdata)
  957. {
  958. HBFloaterSoundsList* self = (HBFloaterSoundsList*)userdata;
  959. if (!self || !gAudiop) return;
  960. LLScrollListItem* item = self->mSoundsList->getFirstSelected();
  961. if (!item) return;
  962. std::string name;
  963. LLVector3d pos_global;
  964. // Get the object id
  965. const LLUUID& object_id =
  966. item->getColumn(LIST_OBJECT_ID)->getValue().asUUID();
  967. if (object_id.notNull())
  968. {
  969. // Try to track the most up-to-date object position
  970. LLViewerObject* objectp = gObjectList.findObject(object_id);
  971. if (objectp)
  972. {
  973. pos_global = objectp->getPositionGlobal();
  974. }
  975. // Get the object name
  976. names_map_t::iterator it = sObjectNames.find(object_id);
  977. if (it != sObjectNames.end())
  978. {
  979. name = it->second;
  980. }
  981. }
  982. // Get the source id
  983. const LLUUID& source_id =
  984. item->getColumn(LIST_SOURCE_ID)->getValue().asUUID();
  985. if (pos_global.isExactlyZero())
  986. {
  987. // Find the source (if still there) and its position
  988. for (LLAudioEngine::source_map_t::const_iterator
  989. it = gAudiop->mAllSources.begin(),
  990. end = gAudiop->mAllSources.end();
  991. it != end; ++it)
  992. {
  993. const LLAudioSource* source = it->second;
  994. if (source && source->getID() == source_id)
  995. {
  996. pos_global = source->getPositionGlobal();
  997. break;
  998. }
  999. }
  1000. }
  1001. if (pos_global.isExactlyZero())
  1002. {
  1003. // Source gone or ambient sound (cannot track)... Give-up.
  1004. return;
  1005. }
  1006. self->mTrackingLocation = pos_global;
  1007. self->mTrackingID = object_id.notNull() ? object_id : source_id;
  1008. if (name.empty())
  1009. {
  1010. name = self->getString("sound_source");
  1011. }
  1012. gTracker.trackLocation(self->mTrackingLocation, name, "",
  1013. LLTracker::LOCATION_ITEM);
  1014. self->mIsDirty = true;
  1015. self->mLastUpdate = 0.f; // Force an immediate update
  1016. }