00001
00029 #include "llviewerprecompiledheaders.h"
00030
00031 #include "llfloatertrustnetrate.h"
00032
00033 #include "llcachename.h"
00034 #include "llfontgl.h"
00035 #include "lluuid.h"
00036 #include "message.h"
00037
00038 #include "llagent.h"
00039 #include "lltextbox.h"
00040 #include "llbutton.h"
00041 #include "lllineeditor.h"
00042 #include "llradiogroup.h"
00043 #include "llselectmgr.h"
00044 #include "llvieweruictrlfactory.h"
00045 #include "llviewermessage.h"
00046 #include "llviewernetwork.h"
00047 #include "llviewerregion.h"
00048
00049 #include "llviewerwindow.h"
00050
00051
00052 const S32 RATING_COST = 25;
00053
00054
00055 LLFloaterTrustNetRate::instance_map_t LLFloaterTrustNetRate::sInstanceMap;
00056
00057
00058
00059
00060 LLFloaterTrustNetRate::LLFloaterTrustNetRate(const std::string& name, const LLUUID &id)
00061 : LLFloater(name),
00062 mAvatarID( id ),
00063 mLastBehavior( 0.f ),
00064 mLastAppearance( 0.f ),
00065 mLastBuilding( 0.f ),
00066 mReputationRequested( FALSE )
00067 {
00068 gUICtrlFactory->buildFloater(this, "floater_trustnetrate.xml");
00069
00070 childSetAction("OK", onClickOK, this);
00071 childSetAction("Cancel", onClickCancel, this);
00072
00073 mObjectSelection = gSelectMgr->getEditSelection();
00074 }
00075
00076
00077 LLFloaterTrustNetRate::~LLFloaterTrustNetRate()
00078 {
00079 sInstanceMap.erase(mAvatarID);
00080 }
00081
00082
00083 void LLFloaterTrustNetRate::draw()
00084 {
00085 LLString name;
00086
00087
00088 char firstname[MAX_STRING];
00089 char lastname[MAX_STRING];
00090 gCacheName->getName(mAvatarID, firstname, lastname);
00091 name.assign(firstname);
00092 name.append(" ");
00093 name.append(lastname);
00094
00095
00096 if (!mReputationRequested)
00097 {
00098 sendReputationIndividualRequest(mAvatarID);
00099 }
00100
00101 LLString title("Your Rating of ");
00102 title.append( name );
00103
00104 setTitle(title);
00105
00106 F32 behavior = childGetValue("behavior").asString() == "Positive" ? 1.0f : 0.0f;
00107 F32 appearance = childGetValue("appearance").asString() == "Positive" ? 1.0f : 0.0f;
00108 F32 building = childGetValue("building").asString() == "Positive" ? 1.0f : 0.0f;
00109
00110 S32 change_count = 0;
00111 if (behavior != mLastBehavior) change_count++;
00112 if (appearance != mLastAppearance) change_count++;
00113 if (building != mLastBuilding) change_count++;
00114
00115 childSetTextArg("cost", "[COST]", llformat("%d",RATING_COST));
00116 childSetTextArg("cost", "[TOTAL]", llformat("%d",RATING_COST * change_count));
00117
00118 BOOL can_afford = can_afford_transaction(RATING_COST * change_count);
00119 BOOL changed = (change_count > 0);
00120 childSetEnabled("OK", changed && can_afford );
00121
00122 LLFloater::draw();
00123 }
00124
00125
00126
00127 void LLFloaterTrustNetRate::show(const LLUUID &avatar_id)
00128 {
00129 instance_map_t::iterator iter = sInstanceMap.find(avatar_id);
00130 if (iter != sInstanceMap.end())
00131 {
00132 iter->second->setFocus(TRUE);
00133 iter->second->open();
00134 }
00135 else if (avatar_id != LLUUID::null)
00136 {
00137 LLFloaterTrustNetRate *f = new LLFloaterTrustNetRate("rate", avatar_id);
00138 sInstanceMap[avatar_id] = f;
00139 f->center();
00140 f->setFocus(TRUE);
00141 f->sendReputationIndividualRequest(avatar_id);
00142 f->open();
00143 }
00144 }
00145
00146
00147
00148 void LLFloaterTrustNetRate::show(ERateSelection which)
00149 {
00150 LLUUID avatarid;
00151 LLString avatarname;
00152 switch(which)
00153 {
00154 case RS_CREATOR:
00155 gSelectMgr->selectGetCreator(avatarid, avatarname);
00156 break;
00157
00158 case RS_OWNER:
00159 default:
00160 gSelectMgr->selectGetOwner(avatarid, avatarname);
00161 break;
00162 }
00163
00164 if (avatarid != LLUUID::null)
00165 {
00166 show(avatarid);
00167 }
00168 else
00169 {
00170 gViewerWindow->alertXml("SelectSingleRate");
00171 }
00172 }
00173
00174
00175
00176 void LLFloaterTrustNetRate::onClickOK(void *data)
00177 {
00178 LLFloaterTrustNetRate *self = (LLFloaterTrustNetRate *)data;
00179
00180 F32 behavior = self->childGetValue("behavior").asString() == "Positive" ? 1.0f : 0.0f;
00181 F32 appearance = self->childGetValue("appearance").asString() == "Positive" ? 1.0f : 0.0f;
00182 F32 building = self->childGetValue("building").asString() == "Positive" ? 1.0f : 0.0f;
00183 std::string text = self->childGetValue("mesg editor").asString();
00184
00185 S32 change_count = 0;
00186 if (behavior != self->mLastBehavior) change_count++;
00187 if (appearance != self->mLastAppearance) change_count++;
00188 if (building != self->mLastBuilding) change_count++;
00189
00190 if (change_count > 0)
00191 {
00192
00193
00194
00195
00196
00197 self->mLastBehavior = behavior;
00198 self->mLastAppearance = appearance;
00199 self->mLastBuilding = building;
00200 }
00201
00202 self->close();
00203 }
00204
00205
00206
00207 void LLFloaterTrustNetRate::onClickCancel(void *data)
00208 {
00209 LLFloaterTrustNetRate *self = (LLFloaterTrustNetRate *)data;
00210 self->close();
00211 }
00212
00213
00214 void LLFloaterTrustNetRate::sendReputationIndividualRequest(const LLUUID &avatar_id)
00215 {
00216
00217
00218
00219
00220
00221
00222
00223
00224 }
00225
00226
00227
00228 void LLFloaterTrustNetRate::processReputationIndividualReply(LLMessageSystem *msg, void** data)
00229 {
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 }