00001 00033 #include "llviewerprecompiledheaders.h" 00034 00035 #include "llfloaterbump.h" 00036 00037 #include "llscrolllistctrl.h" 00038 00039 #include "lluictrlfactory.h" 00040 #include "llviewermessage.h" 00041 #include "llappviewer.h" // gPacificDaylightTime 00042 00046 LLFloaterBump* LLFloaterBump::sInstance = NULL; 00047 00051 00052 // Default constructor 00053 LLFloaterBump::LLFloaterBump() 00054 : LLFloater() 00055 { 00056 sInstance = this; 00057 00058 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_bumps.xml"); 00059 } 00060 00061 00062 // Destroys the object 00063 LLFloaterBump::~LLFloaterBump() 00064 { 00065 sInstance = NULL; 00066 } 00067 00068 // static 00069 void LLFloaterBump::show(void *contents) 00070 { 00071 if (gNoRender) 00072 { 00073 return; 00074 } 00075 00076 if (!sInstance) 00077 { 00078 sInstance = new LLFloaterBump(); 00079 } 00080 00081 LLScrollListCtrl* list = sInstance->getChild<LLScrollListCtrl>("bump_list"); 00082 if (!list) return; 00083 list->deleteAllItems(); 00084 00085 if (gMeanCollisionList.empty()) 00086 { 00087 LLString none_detected = sInstance->getString("none_detected"); 00088 LLSD row; 00089 row["columns"][0]["value"] = none_detected; 00090 row["columns"][0]["font"] = "SansSerifBold"; 00091 list->addElement(row); 00092 } 00093 else 00094 { 00095 for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin(); 00096 iter != gMeanCollisionList.end(); ++iter) 00097 { 00098 LLMeanCollisionData *mcd = *iter; 00099 LLFloaterBump::add(list, mcd); 00100 } 00101 } 00102 00103 sInstance->open(); /*Flawfinder: ignore*/ 00104 } 00105 00106 void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd) 00107 { 00108 if (!sInstance) 00109 { 00110 new LLFloaterBump(); 00111 } 00112 00113 if (!mcd->mFirstName[0] 00114 || list->getItemCount() >= 20) 00115 { 00116 return; 00117 } 00118 00119 // There's only one internal tm buffer. 00120 struct tm* timep; 00121 00122 // Convert to Pacific, based on server's opinion of whether 00123 // it's daylight savings time there. 00124 timep = utc_to_pacific_time(mcd->mTime, gPacificDaylightTime); 00125 00126 LLString time = llformat("[%d:%02d]", timep->tm_hour, timep->tm_min); 00127 00128 LLString action; 00129 switch(mcd->mType) 00130 { 00131 case MEAN_BUMP: 00132 action = "bump"; 00133 break; 00134 case MEAN_LLPUSHOBJECT: 00135 action = "llpushobject"; 00136 break; 00137 case MEAN_SELECTED_OBJECT_COLLIDE: 00138 action = "selected_object_collide"; 00139 break; 00140 case MEAN_SCRIPTED_OBJECT_COLLIDE: 00141 action = "scripted_object_collide"; 00142 break; 00143 case MEAN_PHYSICAL_OBJECT_COLLIDE: 00144 action = "physical_object_collide"; 00145 break; 00146 default: 00147 llinfos << "LLFloaterBump::add unknown mean collision type " 00148 << mcd->mType << llendl; 00149 return; 00150 } 00151 00152 // All above action strings are in XML file 00153 LLUIString text = sInstance->getUIString(action); 00154 text.setArg("[TIME]", time); 00155 text.setArg("[FIRST]", mcd->mFirstName); 00156 text.setArg("[LAST]", mcd->mLastName); 00157 00158 LLSD row; 00159 row["id"] = mcd->mPerp; 00160 row["columns"][0]["value"] = text; 00161 row["columns"][0]["font"] = "SansSerifBold"; 00162 list->addElement(row); 00163 }