llfloaterbump.cpp

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

Generated on Thu Jul 1 06:08:31 2010 for Second Life Viewer by  doxygen 1.4.7