aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatermute.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloatermute.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatermute.cpp270
1 files changed, 270 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatermute.cpp b/linden/indra/newview/llfloatermute.cpp
new file mode 100644
index 0000000..a78a616
--- /dev/null
+++ b/linden/indra/newview/llfloatermute.cpp
@@ -0,0 +1,270 @@
1/**
2 * @file llfloatermute.cpp
3 * @brief Container for mute list
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llfloatermute.h"
31
32#include "llfontgl.h"
33#include "llrect.h"
34#include "llerror.h"
35#include "llstring.h"
36#include "message.h"
37
38// project include
39#include "llagent.h"
40#include "llfloateravatarpicker.h"
41#include "llbutton.h"
42#include "lllineeditor.h"
43#include "llmutelist.h"
44#include "llresizehandle.h"
45#include "llscrolllistctrl.h"
46#include "lltextbox.h"
47#include "llviewertexteditor.h"
48#include "llviewerwindow.h"
49#include "llvieweruictrlfactory.h"
50
51//
52// Constants
53//
54const char FLOATER_TITLE[] = "Muted Residents & Objects";
55const F32 INSTANT_MSG_SIZE = 8.0f;
56const LLColor4 INSTANT_MSG_COLOR(1, 1, 1, 1);
57const LLColor4 MUTED_MSG_COLOR(0.5f, 0.5f, 0.5f, 1.f);
58
59const S32 LINE = 16;
60const S32 LEFT = 2;
61const S32 VPAD = 4;
62const S32 HPAD = 4;
63//
64// Global statics
65//
66LLFloaterMute* gFloaterMute = NULL;
67
68
69//
70// Member Functions
71//
72
73//-----------------------------------------------------------------------------
74// LLFloaterMute()
75//-----------------------------------------------------------------------------
76LLFloaterMute::LLFloaterMute()
77: LLFloater("mute floater", "FloaterMuteRect3", FLOATER_TITLE,
78 RESIZE_YES, 220, 140, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
79{
80
81 gUICtrlFactory->buildFloater(this, "floater_mute.xml");
82
83 setVisible(FALSE);
84
85 childSetCommitCallback("mutes", onSelectName, this);
86 childSetAction("Mute resident...", onClickPick, this);
87 childSetAction("Mute object by name...", onClickMuteByName, this);
88 childSetAction("Unmute", onClickRemove, this);
89
90 mMuteList = LLUICtrlFactory::getScrollListByName(this, "mutes");
91
92 refreshMuteList();
93}
94
95//-----------------------------------------------------------------------------
96// ~LLFloaterMute()
97//-----------------------------------------------------------------------------
98LLFloaterMute::~LLFloaterMute()
99{
100}
101
102
103//-----------------------------------------------------------------------------
104// show()
105//-----------------------------------------------------------------------------
106void LLFloaterMute::show()
107{
108 // Make sure we make a noise.
109 open();
110}
111
112//-----------------------------------------------------------------------------
113// toggle()
114//-----------------------------------------------------------------------------
115void LLFloaterMute::toggle(void*)
116{
117 if (gFloaterMute->getVisible())
118 {
119 gFloaterMute->close();
120 }
121 else
122 {
123 gFloaterMute->show();
124 }
125}
126
127//-----------------------------------------------------------------------------
128// visible()
129//-----------------------------------------------------------------------------
130BOOL LLFloaterMute::visible(void*)
131{
132 return (gFloaterMute && gFloaterMute->getVisible());
133}
134
135//-----------------------------------------------------------------------------
136// refreshMuteList()
137//-----------------------------------------------------------------------------
138void LLFloaterMute::refreshMuteList()
139{
140 mMuteList->deleteAllItems();
141
142 if (gMuteListp)
143 {
144 std::vector<LLMute> mutes = gMuteListp->getMutes();
145 std::vector<LLMute>::iterator it;
146 for (it = mutes.begin(); it != mutes.end(); ++it)
147 {
148 LLString display_name = it->getDisplayName();
149 mMuteList->addStringUUIDItem(display_name, it->mID);
150 }
151 }
152
153 updateButtons();
154}
155
156void LLFloaterMute::selectMute(const LLUUID& mute_id)
157{
158 mMuteList->selectByID(mute_id);
159 updateButtons();
160}
161
162//-----------------------------------------------------------------------------
163// updateButtons()
164//-----------------------------------------------------------------------------
165void LLFloaterMute::updateButtons()
166{
167 if (mMuteList->getFirstSelected())
168 {
169 childSetEnabled("Unmute", TRUE);
170 }
171 else
172 {
173 childSetEnabled("Unmute", FALSE);
174 }
175}
176
177//-----------------------------------------------------------------------------
178// onSelectName()
179//-----------------------------------------------------------------------------
180void LLFloaterMute::onSelectName(LLUICtrl *caller, void *data)
181{
182 LLFloaterMute *floater = (LLFloaterMute*)data;
183
184 floater->updateButtons();
185}
186
187//-----------------------------------------------------------------------------
188// onClickRemove()
189//-----------------------------------------------------------------------------
190void LLFloaterMute::onClickRemove(void *data)
191{
192 LLFloaterMute* floater = (LLFloaterMute *)data;
193
194 LLString name = floater->mMuteList->getSimpleSelectedItem();
195 LLUUID id = floater->mMuteList->getStringUUIDSelectedItem();
196 LLMute mute(id);
197 mute.setFromDisplayName(name);
198 // now mute.mName has the suffix trimmed off
199
200 S32 last_selected = floater->mMuteList->getFirstSelectedIndex();
201 if (gMuteListp->remove(mute))
202 {
203 // Above removals may rebuild this dialog.
204
205 if (last_selected == floater->mMuteList->getItemCount())
206 {
207 // we were on the last item, so select the last item again
208 floater->mMuteList->selectNthItem(last_selected - 1);
209 }
210 else
211 {
212 // else select the item after the last item previously selected
213 floater->mMuteList->selectNthItem(last_selected);
214 }
215 }
216 floater->updateButtons();
217}
218
219//-----------------------------------------------------------------------------
220// onClickPick()
221//-----------------------------------------------------------------------------
222void LLFloaterMute::onClickPick(void *data)
223{
224 LLFloaterMute* floaterp = (LLFloaterMute*)data;
225 const BOOL allow_multiple = FALSE;
226 const BOOL close_on_select = TRUE;
227 LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(onPickUser, data, allow_multiple, close_on_select);
228 floaterp->addDependentFloater(picker);
229}
230
231//-----------------------------------------------------------------------------
232// onPickUser()
233//-----------------------------------------------------------------------------
234void LLFloaterMute::onPickUser(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* user_data)
235{
236 LLFloaterMute* floaterp = (LLFloaterMute*)user_data;
237 if (!floaterp) return;
238 if (names.empty() || ids.empty()) return;
239
240 LLMute mute(ids[0], names[0], LLMute::AGENT);
241 gMuteListp->add(mute);
242 floaterp->updateButtons();
243}
244
245
246void LLFloaterMute::onClickMuteByName(void* data)
247{
248
249
250 LLString::format_map_t args;
251 gViewerWindow->alertXmlEditText("MuteByName", args,
252 NULL, NULL,
253 callbackMuteByName, data);
254
255
256}
257
258
259void LLFloaterMute::callbackMuteByName(S32 option, const LLString& text, void* data)
260{
261 if (option != 0) return;
262 if (text.empty()) return;
263
264 LLMute mute(LLUUID::null, text, LLMute::BY_NAME);
265 BOOL success = gMuteListp->add(mute);
266 if (!success)
267 {
268 gViewerWindow->alertXml("MuteByNameFailed");
269 }
270}