diff options
Diffstat (limited to 'linden/indra/newview/llfloaterrate.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterrate.cpp | 277 |
1 files changed, 0 insertions, 277 deletions
diff --git a/linden/indra/newview/llfloaterrate.cpp b/linden/indra/newview/llfloaterrate.cpp deleted file mode 100644 index a057374..0000000 --- a/linden/indra/newview/llfloaterrate.cpp +++ /dev/null | |||
@@ -1,277 +0,0 @@ | |||
1 | /** | ||
2 | * @file llfloaterrate.cpp | ||
3 | * @brief Dialog for rating avatars. She's a ten! | ||
4 | * | ||
5 | * Copyright (c) 2002-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 "llfloaterrate.h" | ||
31 | |||
32 | #include "llcachename.h" | ||
33 | #include "llfontgl.h" | ||
34 | #include "lluuid.h" | ||
35 | #include "message.h" | ||
36 | |||
37 | #include "llagent.h" | ||
38 | #include "lltextbox.h" | ||
39 | #include "llbutton.h" | ||
40 | #include "lllineeditor.h" | ||
41 | #include "llradiogroup.h" | ||
42 | #include "llselectmgr.h" | ||
43 | #include "llvieweruictrlfactory.h" | ||
44 | #include "llviewermessage.h" | ||
45 | #include "llviewernetwork.h" | ||
46 | #include "llviewerregion.h" | ||
47 | #include "llviewerreputation.h" | ||
48 | #include "llviewerwindow.h" | ||
49 | |||
50 | // Dollar cost to change your rating of someone | ||
51 | const S32 RATING_COST = 25; | ||
52 | |||
53 | //static | ||
54 | LLFloaterRate::instance_map_t LLFloaterRate::sInstanceMap; | ||
55 | |||
56 | //----------------------------------------------------------------------------- | ||
57 | // Methods | ||
58 | //----------------------------------------------------------------------------- | ||
59 | LLFloaterRate::LLFloaterRate(const std::string& name, const LLUUID &id) | ||
60 | : LLFloater(name), | ||
61 | mAvatarID( id ), | ||
62 | mLastBehavior( 0.f ), | ||
63 | mLastAppearance( 0.f ), | ||
64 | mLastBuilding( 0.f ), | ||
65 | mReputationRequested( FALSE ) | ||
66 | { | ||
67 | gUICtrlFactory->buildFloater(this, "floater_rate.xml"); | ||
68 | |||
69 | childSetAction("OK", onClickOK, this); | ||
70 | childSetAction("Cancel", onClickCancel, this); | ||
71 | |||
72 | mObjectSelection = gSelectMgr->getEditSelection(); | ||
73 | } | ||
74 | |||
75 | |||
76 | LLFloaterRate::~LLFloaterRate() | ||
77 | { | ||
78 | sInstanceMap.erase(mAvatarID); | ||
79 | } | ||
80 | |||
81 | |||
82 | void LLFloaterRate::draw() | ||
83 | { | ||
84 | LLString name; | ||
85 | |||
86 | // Construct the name, if possible | ||
87 | char firstname[MAX_STRING]; /* Flawfinder: ignore */ | ||
88 | char lastname[MAX_STRING]; /* Flawfinder: ignore */ | ||
89 | gCacheName->getName(mAvatarID, firstname, lastname); | ||
90 | name.assign(firstname); | ||
91 | name.append(" "); | ||
92 | name.append(lastname); | ||
93 | |||
94 | // Request the current data, if we haven't already | ||
95 | if (!mReputationRequested) | ||
96 | { | ||
97 | sendReputationIndividualRequest(mAvatarID); | ||
98 | } | ||
99 | |||
100 | LLString title("Your Rating of "); | ||
101 | title.append( name ); | ||
102 | |||
103 | setTitle(title); | ||
104 | |||
105 | F32 behavior = childGetValue("behavior").asString() == "Positive" ? 1.0f : 0.0f; | ||
106 | F32 appearance = childGetValue("appearance").asString() == "Positive" ? 1.0f : 0.0f; | ||
107 | F32 building = childGetValue("building").asString() == "Positive" ? 1.0f : 0.0f; | ||
108 | |||
109 | S32 change_count = 0; | ||
110 | if (behavior != mLastBehavior) change_count++; | ||
111 | if (appearance != mLastAppearance) change_count++; | ||
112 | if (building != mLastBuilding) change_count++; | ||
113 | |||
114 | childSetTextArg("cost", "[COST]", llformat("%d",RATING_COST)); | ||
115 | childSetTextArg("cost", "[TOTAL]", llformat("%d",RATING_COST * change_count)); | ||
116 | |||
117 | BOOL can_afford = can_afford_transaction(RATING_COST * change_count); | ||
118 | BOOL changed = (change_count > 0); | ||
119 | childSetEnabled("OK", changed && can_afford ); | ||
120 | |||
121 | LLFloater::draw(); | ||
122 | } | ||
123 | |||
124 | |||
125 | // static | ||
126 | void LLFloaterRate::show(const LLUUID &avatar_id) | ||
127 | { | ||
128 | instance_map_t::iterator iter = sInstanceMap.find(avatar_id); | ||
129 | if (iter != sInstanceMap.end()) | ||
130 | { | ||
131 | iter->second->setFocus(TRUE); | ||
132 | iter->second->open(); /* Flawfinder: ignore */ | ||
133 | } | ||
134 | else if (avatar_id != LLUUID::null) | ||
135 | { | ||
136 | LLFloaterRate *f = new LLFloaterRate("rate", avatar_id); | ||
137 | sInstanceMap[avatar_id] = f; | ||
138 | f->center(); | ||
139 | f->setFocus(TRUE); | ||
140 | f->sendReputationIndividualRequest(avatar_id); | ||
141 | f->open(); /* Flawfinder: ignore */ | ||
142 | } | ||
143 | } | ||
144 | |||
145 | |||
146 | // static | ||
147 | void LLFloaterRate::show(ERateSelection which) | ||
148 | { | ||
149 | LLUUID avatarid; | ||
150 | LLString avatarname; | ||
151 | switch(which) | ||
152 | { | ||
153 | case RS_CREATOR: | ||
154 | gSelectMgr->selectGetCreator(avatarid, avatarname); | ||
155 | break; | ||
156 | |||
157 | case RS_OWNER: | ||
158 | default: | ||
159 | gSelectMgr->selectGetOwner(avatarid, avatarname); | ||
160 | break; | ||
161 | } | ||
162 | |||
163 | if (avatarid != LLUUID::null) | ||
164 | { | ||
165 | show(avatarid); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | gViewerWindow->alertXml("SelectSingleRate"); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | |||
174 | // static | ||
175 | void LLFloaterRate::onClickOK(void *data) | ||
176 | { | ||
177 | LLFloaterRate *self = (LLFloaterRate *)data; | ||
178 | |||
179 | F32 behavior = self->childGetValue("behavior").asString() == "Positive" ? 1.0f : 0.0f; | ||
180 | F32 appearance = self->childGetValue("appearance").asString() == "Positive" ? 1.0f : 0.0f; | ||
181 | F32 building = self->childGetValue("building").asString() == "Positive" ? 1.0f : 0.0f; | ||
182 | std::string text = self->childGetValue("mesg editor").asString(); | ||
183 | |||
184 | S32 change_count = 0; | ||
185 | if (behavior != self->mLastBehavior) change_count++; | ||
186 | if (appearance != self->mLastAppearance) change_count++; | ||
187 | if (building != self->mLastBuilding) change_count++; | ||
188 | |||
189 | if (change_count > 0) | ||
190 | { | ||
191 | send_reputation_agent_assign(gAgent.getID(), self->mAvatarID, | ||
192 | behavior, appearance, building, text.c_str() ); | ||
193 | |||
194 | give_money(LLUUID::null, gAgent.getRegion(), change_count * RATING_COST); | ||
195 | |||
196 | self->mLastBehavior = behavior; | ||
197 | self->mLastAppearance = appearance; | ||
198 | self->mLastBuilding = building; | ||
199 | } | ||
200 | |||
201 | self->close(); | ||
202 | } | ||
203 | |||
204 | |||
205 | // static | ||
206 | void LLFloaterRate::onClickCancel(void *data) | ||
207 | { | ||
208 | LLFloaterRate *self = (LLFloaterRate *)data; | ||
209 | self->close(); | ||
210 | } | ||
211 | |||
212 | |||
213 | void LLFloaterRate::sendReputationIndividualRequest(const LLUUID &avatar_id) | ||
214 | { | ||
215 | mReputationRequested = TRUE; | ||
216 | |||
217 | LLMessageSystem *msg = gMessageSystem; | ||
218 | msg->newMessageFast(_PREHASH_ReputationIndividualRequest); | ||
219 | msg->nextBlockFast(_PREHASH_ReputationData); | ||
220 | msg->addUUIDFast(_PREHASH_FromID, gAgent.getID() ); | ||
221 | msg->addUUIDFast(_PREHASH_ToID, avatar_id ); | ||
222 | msg->sendReliable( gUserServer ); | ||
223 | } | ||
224 | |||
225 | |||
226 | // static | ||
227 | void LLFloaterRate::processReputationIndividualReply(LLMessageSystem *msg, void** data) | ||
228 | { | ||
229 | LLUUID from_id; | ||
230 | LLUUID to_id; | ||
231 | F32 behavior = 0.f; | ||
232 | F32 appearance = 0.f; | ||
233 | F32 building = 0.f; | ||
234 | |||
235 | msg->getUUIDFast(_PREHASH_ReputationData, _PREHASH_FromID, from_id ); | ||
236 | msg->getUUIDFast(_PREHASH_ReputationData, _PREHASH_ToID, to_id ); | ||
237 | msg->getF32Fast(_PREHASH_ReputationData, _PREHASH_Behavior, behavior ); | ||
238 | msg->getF32Fast(_PREHASH_ReputationData, _PREHASH_Appearance, appearance ); | ||
239 | msg->getF32Fast(_PREHASH_ReputationData, _PREHASH_Building, building ); | ||
240 | |||
241 | instance_map_t::iterator iter = sInstanceMap.find(to_id); | ||
242 | if (iter != sInstanceMap.end()) | ||
243 | { | ||
244 | LLFloaterRate* f = iter->second; | ||
245 | |||
246 | f->mLastBehavior = behavior; | ||
247 | f->mLastAppearance = appearance; | ||
248 | f->mLastBuilding = building; | ||
249 | |||
250 | if (behavior > 0.f) | ||
251 | { | ||
252 | f->childSetValue("behavior", "Positive"); | ||
253 | } | ||
254 | else | ||
255 | { | ||
256 | f->childSetValue("behavior", "No Rating"); | ||
257 | } | ||
258 | |||
259 | if (appearance > 0.f) | ||
260 | { | ||
261 | f->childSetValue("appearance", "Positive"); | ||
262 | } | ||
263 | else | ||
264 | { | ||
265 | f->childSetValue("appearance", "No Rating"); | ||
266 | } | ||
267 | |||
268 | if (building > 0.f) | ||
269 | { | ||
270 | f->childSetValue("building", "Positive"); | ||
271 | } | ||
272 | else | ||
273 | { | ||
274 | f->childSetValue("building", "No Rating"); | ||
275 | } | ||
276 | } | ||
277 | } | ||