00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llfloatermute.h"
00035
00036 #include "llfontgl.h"
00037 #include "llrect.h"
00038 #include "llerror.h"
00039 #include "llstring.h"
00040 #include "message.h"
00041
00042
00043 #include "llagent.h"
00044 #include "llfloateravatarpicker.h"
00045 #include "llbutton.h"
00046 #include "lllineeditor.h"
00047 #include "llmutelist.h"
00048 #include "llresizehandle.h"
00049 #include "llscrolllistctrl.h"
00050 #include "lltextbox.h"
00051 #include "llviewertexteditor.h"
00052 #include "llviewerwindow.h"
00053 #include "llvieweruictrlfactory.h"
00054
00055
00056
00057
00058 const char FLOATER_TITLE[] = "Muted Residents & Objects";
00059 const F32 INSTANT_MSG_SIZE = 8.0f;
00060 const LLColor4 INSTANT_MSG_COLOR(1, 1, 1, 1);
00061 const LLColor4 MUTED_MSG_COLOR(0.5f, 0.5f, 0.5f, 1.f);
00062
00063 const S32 LINE = 16;
00064 const S32 LEFT = 2;
00065 const S32 VPAD = 4;
00066 const S32 HPAD = 4;
00067
00068
00069
00070 LLFloaterMute* gFloaterMute = NULL;
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 LLFloaterMute::LLFloaterMute()
00081 : LLFloater("mute floater", "FloaterMuteRect3", FLOATER_TITLE,
00082 RESIZE_YES, 220, 140, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
00083 {
00084
00085 gUICtrlFactory->buildFloater(this, "floater_mute.xml");
00086
00087 setVisible(FALSE);
00088
00089 childSetCommitCallback("mutes", onSelectName, this);
00090 childSetAction("Mute resident...", onClickPick, this);
00091 childSetAction("Mute object by name...", onClickMuteByName, this);
00092 childSetAction("Unmute", onClickRemove, this);
00093
00094 mMuteList = LLUICtrlFactory::getScrollListByName(this, "mutes");
00095 mMuteList->setCommitOnSelectionChange(TRUE);
00096
00097 refreshMuteList();
00098 }
00099
00100
00101
00102
00103 LLFloaterMute::~LLFloaterMute()
00104 {
00105 }
00106
00107
00108
00109
00110
00111 void LLFloaterMute::show()
00112 {
00113
00114 open();
00115 }
00116
00117
00118
00119
00120 void LLFloaterMute::toggle(void*)
00121 {
00122 if (gFloaterMute->getVisible())
00123 {
00124 gFloaterMute->close();
00125 }
00126 else
00127 {
00128 gFloaterMute->show();
00129 }
00130 }
00131
00132
00133
00134
00135 BOOL LLFloaterMute::visible(void*)
00136 {
00137 return (gFloaterMute && gFloaterMute->getVisible());
00138 }
00139
00140
00141
00142
00143 void LLFloaterMute::refreshMuteList()
00144 {
00145 mMuteList->deleteAllItems();
00146
00147 if (gMuteListp)
00148 {
00149 std::vector<LLMute> mutes = gMuteListp->getMutes();
00150 std::vector<LLMute>::iterator it;
00151 for (it = mutes.begin(); it != mutes.end(); ++it)
00152 {
00153 LLString display_name = it->getDisplayName();
00154 mMuteList->addStringUUIDItem(display_name, it->mID);
00155 }
00156 }
00157
00158 updateButtons();
00159 }
00160
00161 void LLFloaterMute::selectMute(const LLUUID& mute_id)
00162 {
00163 mMuteList->selectByID(mute_id);
00164 updateButtons();
00165 }
00166
00167
00168
00169
00170 void LLFloaterMute::updateButtons()
00171 {
00172 if (mMuteList->getFirstSelected())
00173 {
00174 childSetEnabled("Unmute", TRUE);
00175 }
00176 else
00177 {
00178 childSetEnabled("Unmute", FALSE);
00179 }
00180 }
00181
00182
00183
00184
00185 void LLFloaterMute::onSelectName(LLUICtrl *caller, void *data)
00186 {
00187 LLFloaterMute *floater = (LLFloaterMute*)data;
00188
00189 floater->updateButtons();
00190 }
00191
00192
00193
00194
00195 void LLFloaterMute::onClickRemove(void *data)
00196 {
00197 LLFloaterMute* floater = (LLFloaterMute *)data;
00198
00199 LLString name = floater->mMuteList->getSimpleSelectedItem();
00200 LLUUID id = floater->mMuteList->getStringUUIDSelectedItem();
00201 LLMute mute(id);
00202 mute.setFromDisplayName(name);
00203
00204
00205 S32 last_selected = floater->mMuteList->getFirstSelectedIndex();
00206 if (gMuteListp->remove(mute))
00207 {
00208
00209
00210 if (last_selected == floater->mMuteList->getItemCount())
00211 {
00212
00213 floater->mMuteList->selectNthItem(last_selected - 1);
00214 }
00215 else
00216 {
00217
00218 floater->mMuteList->selectNthItem(last_selected);
00219 }
00220 }
00221 floater->updateButtons();
00222 }
00223
00224
00225
00226
00227 void LLFloaterMute::onClickPick(void *data)
00228 {
00229 LLFloaterMute* floaterp = (LLFloaterMute*)data;
00230 const BOOL allow_multiple = FALSE;
00231 const BOOL close_on_select = TRUE;
00232 LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(onPickUser, data, allow_multiple, close_on_select);
00233 floaterp->addDependentFloater(picker);
00234 }
00235
00236
00237
00238
00239 void LLFloaterMute::onPickUser(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* user_data)
00240 {
00241 LLFloaterMute* floaterp = (LLFloaterMute*)user_data;
00242 if (!floaterp) return;
00243 if (names.empty() || ids.empty()) return;
00244
00245 LLMute mute(ids[0], names[0], LLMute::AGENT);
00246 gMuteListp->add(mute);
00247 floaterp->updateButtons();
00248 }
00249
00250
00251 void LLFloaterMute::onClickMuteByName(void* data)
00252 {
00253
00254
00255 LLString::format_map_t args;
00256 gViewerWindow->alertXmlEditText("MuteByName", args,
00257 NULL, NULL,
00258 callbackMuteByName, data);
00259
00260
00261 }
00262
00263
00264 void LLFloaterMute::callbackMuteByName(S32 option, const LLString& text, void* data)
00265 {
00266 if (option != 0) return;
00267 if (text.empty()) return;
00268
00269 LLMute mute(LLUUID::null, text, LLMute::BY_NAME);
00270 BOOL success = gMuteListp->add(mute);
00271 if (!success)
00272 {
00273 gViewerWindow->alertXml("MuteByNameFailed");
00274 }
00275 }