| 39 |
#include "lleventpoll.h" |
#include "lleventpoll.h" |
| 40 |
#include "llagent.h" |
#include "llagent.h" |
| 41 |
//mk |
//mk |
| 42 |
|
#include "llappviewer.h" |
| 43 |
#include "llfloaterteleporthistory.h" |
#include "llfloaterteleporthistory.h" |
| 44 |
#include "llfloaterworldmap.h" |
#include "llfloaterworldmap.h" |
| 45 |
#include "lltimer.h" |
#include "lltimer.h" |
| 46 |
#include "lluictrlfactory.h" |
#include "lluictrlfactory.h" |
| 47 |
#include "llurldispatcher.h" |
#include "llurldispatcher.h" |
| 48 |
#include "llurlsimstring.h" |
#include "llurlsimstring.h" |
| 49 |
#include "llviewercontrol.h" // gSavedSettings |
#include "llviewercontrol.h" |
| 50 |
#include "llviewerwindow.h" |
#include "llviewerwindow.h" |
| 51 |
#include "llweb.h" |
#include "llweb.h" |
| 52 |
|
|
|
#include "apr_time.h" |
|
|
|
|
| 53 |
// globals |
// globals |
| 54 |
LLFloaterTeleportHistory* gFloaterTeleportHistory; |
LLFloaterTeleportHistory* gFloaterTeleportHistory; |
| 55 |
|
|
| 56 |
LLFloaterTeleportHistory::LLFloaterTeleportHistory() |
LLFloaterTeleportHistory::LLFloaterTeleportHistory() |
| 57 |
: LLFloater(std::string("teleporthistory")), |
: LLFloater(std::string("teleporthistory")), |
| 58 |
mPlacesList(NULL), |
mPlacesList(NULL), |
| 59 |
id(0) |
mID(0) |
| 60 |
{ |
{ |
| 61 |
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_teleport_history.xml", NULL); |
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_teleport_history.xml", NULL); |
| 62 |
} |
} |
| 101 |
return TRUE; |
return TRUE; |
| 102 |
} |
} |
| 103 |
|
|
| 104 |
void LLFloaterTeleportHistory::addEntry(std::string regionName, S16 x, S16 y, S16 z) |
void LLFloaterTeleportHistory::addPendingEntry(std::string regionName, S16 x, S16 y, S16 z) |
| 105 |
{ |
{ |
| 106 |
#ifdef LL_RRINTERFACE_H //MK |
#ifdef LL_RRINTERFACE_H //MK |
| 107 |
if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) |
if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) |
| 109 |
return; |
return; |
| 110 |
} |
} |
| 111 |
#endif //mk |
#endif //mk |
|
// only if the cached scroll list pointer is valid |
|
|
if(mPlacesList) |
|
|
{ |
|
|
// prepare display of position |
|
|
std::string position=llformat("%d, %d, %d", x, y, z); |
|
|
// prepare simstring for later parsing |
|
|
std::string simString = regionName + llformat("/%d/%d/%d", x, y, z); |
|
|
simString = LLWeb::escapeURL(simString); |
|
| 112 |
|
|
| 113 |
|
// Set pending entry timestamp |
| 114 |
|
U32 utc_time; |
| 115 |
|
utc_time = time_corrected(); |
| 116 |
|
struct tm* internal_time; |
| 117 |
|
internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime); |
| 118 |
// check if we are in daylight savings time |
// check if we are in daylight savings time |
| 119 |
std::string timeZone = "PST"; |
std::string timeZone = "PST"; |
| 120 |
if(is_daylight_savings()) timeZone = "PDT"; |
if (gPacificDaylightTime) |
| 121 |
|
{ |
| 122 |
|
timeZone = " PDT"; |
| 123 |
|
} |
| 124 |
|
#ifdef LOCALIZED_TIME |
| 125 |
|
timeStructToFormattedString(internal_time, gSavedSettings.getString("LongTimeFormat"), mPendingTimeString); |
| 126 |
|
mPendingTimeString += timeZone; |
| 127 |
|
#else |
| 128 |
|
mPendingTimeString = llformat("%02d:%02d:%02d", internal_time->tm_hour, internal_time->tm_min, internal_time->tm_sec) + timeZone; |
| 129 |
|
#endif |
| 130 |
|
|
| 131 |
// do all time related stuff as closely together as possible, because every other operation |
// Set pending region name |
| 132 |
// might change the internal tm* buffer |
mPendingRegionName = regionName; |
| 133 |
struct tm* internal_time; |
|
| 134 |
internal_time = utc_to_pacific_time(time_corrected(), is_daylight_savings()); |
// Set pending position |
| 135 |
std::string timeString=llformat("%02d:%02d:%02d ", internal_time->tm_hour, internal_time->tm_min, internal_time->tm_sec)+timeZone; |
mPendingPosition = llformat("%d, %d, %d", x, y, z); |
| 136 |
|
|
| 137 |
|
// prepare simstring for later parsing |
| 138 |
|
mPendingSimString = regionName + llformat("/%d/%d/%d", x, y, z); |
| 139 |
|
mPendingSimString = LLWeb::escapeURL(mPendingSimString); |
| 140 |
|
|
| 141 |
|
// Prepare the SLURL |
| 142 |
|
mPendingSLURL = LLURLDispatcher::buildSLURL(regionName, x, y, z); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
void LLFloaterTeleportHistory::addEntry(std::string parcelName) |
| 146 |
|
{ |
| 147 |
|
if (mPendingRegionName.empty()) |
| 148 |
|
{ |
| 149 |
|
return; |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
// only if the cached scroll list pointer is valid |
| 153 |
|
if (mPlacesList) |
| 154 |
|
{ |
| 155 |
// build the list entry |
// build the list entry |
| 156 |
LLSD value; |
LLSD value; |
| 157 |
value["id"] = id; |
value["id"] = mID; |
| 158 |
value["columns"][0]["column"] = "region"; |
value["columns"][LIST_PARCEL]["column"] = "parcel"; |
| 159 |
value["columns"][0]["value"] = regionName; |
value["columns"][LIST_PARCEL]["value"] = parcelName; |
| 160 |
value["columns"][1]["column"] = "position"; |
value["columns"][LIST_REGION]["column"] = "region"; |
| 161 |
value["columns"][1]["value"] = position; |
value["columns"][LIST_REGION]["value"] = mPendingRegionName; |
| 162 |
value["columns"][2]["column"] = "visited"; |
value["columns"][LIST_POSITION]["column"] = "position"; |
| 163 |
value["columns"][2]["value"] = timeString; |
value["columns"][LIST_POSITION]["value"] = mPendingPosition; |
| 164 |
|
value["columns"][LIST_VISITED]["column"] = "visited"; |
| 165 |
|
value["columns"][LIST_VISITED]["value"] = mPendingTimeString; |
| 166 |
|
|
| 167 |
// these columns are hidden and serve as data storage for simstring and SLURL |
// these columns are hidden and serve as data storage for simstring and SLURL |
| 168 |
value["columns"][3]["column"] = "slurl"; |
value["columns"][LIST_SLURL]["column"] = "slurl"; |
| 169 |
value["columns"][3]["value"] = LLURLDispatcher::buildSLURL(regionName, x, y, z); |
value["columns"][LIST_SLURL]["value"] = mPendingSLURL; |
| 170 |
value["columns"][4]["column"] = "simstring"; |
value["columns"][LIST_SIMSTRING]["column"] = "simstring"; |
| 171 |
value["columns"][4]["value"] = simString; |
value["columns"][LIST_SIMSTRING]["value"] = mPendingSimString; |
| 172 |
|
|
| 173 |
// add the new list entry on top of the list, deselect all and disable the buttons |
// add the new list entry on top of the list, deselect all and disable the buttons |
| 174 |
mPlacesList->addElement(value, ADD_TOP); |
mPlacesList->addElement(value, ADD_TOP); |
| 175 |
mPlacesList->deselectAllItems(TRUE); |
mPlacesList->deselectAllItems(TRUE); |
| 176 |
setButtonsEnabled(FALSE); |
setButtonsEnabled(FALSE); |
| 177 |
id++; |
mID++; |
| 178 |
} |
} |
| 179 |
else |
else |
| 180 |
{ |
{ |
| 181 |
llwarns << "pointer to places list is NULL" << llendl; |
llwarns << "pointer to places list is NULL" << llendl; |
| 182 |
} |
} |
| 183 |
|
|
| 184 |
|
mPendingRegionName.clear(); |
| 185 |
} |
} |
| 186 |
|
|
| 187 |
void LLFloaterTeleportHistory::setButtonsEnabled(BOOL on) |
void LLFloaterTeleportHistory::setButtonsEnabled(BOOL on) |
| 230 |
LLScrollListItem *item = self->mPlacesList->getFirstSelected(); |
LLScrollListItem *item = self->mPlacesList->getFirstSelected(); |
| 231 |
if (item) { |
if (item) { |
| 232 |
// build secondlife::/app link from simstring for instant teleport to destination |
// build secondlife::/app link from simstring for instant teleport to destination |
| 233 |
std::string slapp="secondlife:///app/teleport/" + item->getColumn(4)->getValue().asString(); |
std::string slapp = "secondlife:///app/teleport/" + item->getColumn(LIST_SIMSTRING)->getValue().asString(); |
| 234 |
LLWebBrowserCtrl* web = NULL; |
LLWebBrowserCtrl* web = NULL; |
| 235 |
LLURLDispatcher::dispatch(slapp, web, TRUE); |
LLURLDispatcher::dispatch(slapp, web, TRUE); |
| 236 |
} |
} |
| 242 |
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; |
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; |
| 243 |
|
|
| 244 |
// get simstring from selected entry and parse it for its components |
// get simstring from selected entry and parse it for its components |
| 245 |
std::string simString = self->mPlacesList->getFirstSelected()->getColumn(4)->getValue().asString(); |
std::string simString = self->mPlacesList->getFirstSelected()->getColumn(LIST_SIMSTRING)->getValue().asString(); |
| 246 |
std::string region = ""; |
std::string region = ""; |
| 247 |
S32 x = 128; |
S32 x = 128; |
| 248 |
S32 y = 128; |
S32 y = 128; |
| 261 |
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; |
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; |
| 262 |
|
|
| 263 |
// get SLURL of the selected entry and copy it to the clipboard |
// get SLURL of the selected entry and copy it to the clipboard |
| 264 |
std::string SLURL=self->mPlacesList->getFirstSelected()->getColumn(3)->getValue().asString(); |
std::string SLURL = self->mPlacesList->getFirstSelected()->getColumn(LIST_SLURL)->getValue().asString(); |
| 265 |
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(SLURL)); |
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(SLURL)); |
| 266 |
} |
} |