Bulldozer Teleport History from Henri's

This commit is contained in:
Siana Gearz
2011-03-11 15:45:59 +01:00
parent 3ce40cf763
commit 19f9af6c29
5 changed files with 135 additions and 107 deletions

View File

@@ -39,25 +39,24 @@
#include "lleventpoll.h" #include "lleventpoll.h"
#include "llagent.h" #include "llagent.h"
//mk //mk
#include "llappviewer.h"
#include "llfloaterteleporthistory.h" #include "llfloaterteleporthistory.h"
#include "llfloaterworldmap.h" #include "llfloaterworldmap.h"
#include "lltimer.h" #include "lltimer.h"
#include "lluictrlfactory.h" #include "lluictrlfactory.h"
#include "llurldispatcher.h" #include "llurldispatcher.h"
#include "llurlsimstring.h" #include "llurlsimstring.h"
#include "llviewercontrol.h" // gSavedSettings #include "llviewercontrol.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "llweb.h" #include "llweb.h"
#include "apr_time.h"
// globals // globals
LLFloaterTeleportHistory* gFloaterTeleportHistory; LLFloaterTeleportHistory* gFloaterTeleportHistory;
LLFloaterTeleportHistory::LLFloaterTeleportHistory() LLFloaterTeleportHistory::LLFloaterTeleportHistory()
: LLFloater(std::string("teleporthistory")), : LLFloater(std::string("teleporthistory")),
mPlacesList(NULL), mPlacesList(NULL),
id(0) mID(0)
{ {
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_teleport_history.xml", NULL); LLUICtrlFactory::getInstance()->buildFloater(this, "floater_teleport_history.xml", NULL);
} }
@@ -71,7 +70,7 @@ LLFloaterTeleportHistory::~LLFloaterTeleportHistory()
void LLFloaterTeleportHistory::onFocusReceived() void LLFloaterTeleportHistory::onFocusReceived()
{ {
// take care to enable or disable buttons depending on the selection in the places list // take care to enable or disable buttons depending on the selection in the places list
if(mPlacesList->getFirstSelected()) if (mPlacesList->getFirstSelected())
{ {
setButtonsEnabled(TRUE); setButtonsEnabled(TRUE);
} }
@@ -86,7 +85,7 @@ BOOL LLFloaterTeleportHistory::postBuild()
{ {
// make sure the cached pointer to the scroll list is valid // make sure the cached pointer to the scroll list is valid
mPlacesList=getChild<LLScrollListCtrl>("places_list"); mPlacesList=getChild<LLScrollListCtrl>("places_list");
if(!mPlacesList) if (!mPlacesList)
{ {
llwarns << "coud not get pointer to places list" << llendl; llwarns << "coud not get pointer to places list" << llendl;
return FALSE; return FALSE;
@@ -102,7 +101,7 @@ BOOL LLFloaterTeleportHistory::postBuild()
return TRUE; return TRUE;
} }
void LLFloaterTeleportHistory::addEntry(std::string regionName, S16 x, S16 y, S16 z) void LLFloaterTeleportHistory::addPendingEntry(std::string regionName, S16 x, S16 y, S16 z)
{ {
#ifdef LL_RRINTERFACE_H //MK #ifdef LL_RRINTERFACE_H //MK
if (gRRenabled && gAgent.mRRInterface.mContainsShowloc) if (gRRenabled && gAgent.mRRInterface.mContainsShowloc)
@@ -110,51 +109,79 @@ void LLFloaterTeleportHistory::addEntry(std::string regionName, S16 x, S16 y, S1
return; return;
} }
#endif //mk #endif //mk
// only if the cached scroll list pointer is valid
if(mPlacesList) // Set pending entry timestamp
U32 utc_time;
utc_time = time_corrected();
struct tm* internal_time;
internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime);
// check if we are in daylight savings time
std::string timeZone = " PST";
if (gPacificDaylightTime)
{ {
// prepare display of position timeZone = " PDT";
std::string position=llformat("%d, %d, %d", x, y, z); }
// prepare simstring for later parsing #ifdef LOCALIZED_TIME
std::string simString = regionName + llformat("/%d/%d/%d", x, y, z); timeStructToFormattedString(internal_time, gSavedSettings.getString("LongTimeFormat"), mPendingTimeString);
simString = LLWeb::escapeURL(simString); mPendingTimeString += timeZone;
#else
mPendingTimeString = llformat("%02d:%02d:%02d", internal_time->tm_hour, internal_time->tm_min, internal_time->tm_sec) + timeZone;
#endif
// check if we are in daylight savings time // Set pending region name
std::string timeZone = "PST"; mPendingRegionName = regionName;
if(is_daylight_savings()) timeZone = "PDT";
// do all time related stuff as closely together as possible, because every other operation // Set pending position
// might change the internal tm* buffer mPendingPosition = llformat("%d, %d, %d", x, y, z);
struct tm* internal_time;
internal_time = utc_to_pacific_time(time_corrected(), is_daylight_savings());
std::string timeString=llformat("%02d:%02d:%02d ", internal_time->tm_hour, internal_time->tm_min, internal_time->tm_sec)+timeZone;
// prepare simstring for later parsing
mPendingSimString = regionName + llformat("/%d/%d/%d", x, y, z);
mPendingSimString = LLWeb::escapeURL(mPendingSimString);
// Prepare the SLURL
mPendingSLURL = LLURLDispatcher::buildSLURL(regionName, x, y, z);
}
void LLFloaterTeleportHistory::addEntry(std::string parcelName)
{
if (mPendingRegionName.empty())
{
return;
}
// only if the cached scroll list pointer is valid
if (mPlacesList)
{
// build the list entry // build the list entry
LLSD value; LLSD value;
value["id"] = id; value["id"] = mID;
value["columns"][0]["column"] = "region"; value["columns"][LIST_PARCEL]["column"] = "parcel";
value["columns"][0]["value"] = regionName; value["columns"][LIST_PARCEL]["value"] = parcelName;
value["columns"][1]["column"] = "position"; value["columns"][LIST_REGION]["column"] = "region";
value["columns"][1]["value"] = position; value["columns"][LIST_REGION]["value"] = mPendingRegionName;
value["columns"][2]["column"] = "visited"; value["columns"][LIST_POSITION]["column"] = "position";
value["columns"][2]["value"] = timeString; value["columns"][LIST_POSITION]["value"] = mPendingPosition;
value["columns"][LIST_VISITED]["column"] = "visited";
value["columns"][LIST_VISITED]["value"] = mPendingTimeString;
// 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
value["columns"][3]["column"] = "slurl"; value["columns"][LIST_SLURL]["column"] = "slurl";
value["columns"][3]["value"] = LLURLDispatcher::buildSLURL(regionName, x, y, z); value["columns"][LIST_SLURL]["value"] = mPendingSLURL;
value["columns"][4]["column"] = "simstring"; value["columns"][LIST_SIMSTRING]["column"] = "simstring";
value["columns"][4]["value"] = simString; value["columns"][LIST_SIMSTRING]["value"] = mPendingSimString;
// 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
mPlacesList->addElement(value, ADD_TOP); mPlacesList->addElement(value, ADD_TOP);
mPlacesList->deselectAllItems(TRUE); mPlacesList->deselectAllItems(TRUE);
setButtonsEnabled(FALSE); setButtonsEnabled(FALSE);
id++; mID++;
} }
else else
{ {
llwarns << "pointer to places list is NULL" << llendl; llwarns << "pointer to places list is NULL" << llendl;
} }
mPendingRegionName.clear();
} }
void LLFloaterTeleportHistory::setButtonsEnabled(BOOL on) void LLFloaterTeleportHistory::setButtonsEnabled(BOOL on)
@@ -185,7 +212,7 @@ void LLFloaterTeleportHistory::onPlacesSelected(LLUICtrl* /* ctrl */, void* data
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data;
// on selection change check if we need to enable or disable buttons // on selection change check if we need to enable or disable buttons
if(self->mPlacesList->getFirstSelected()) if (self->mPlacesList->getFirstSelected())
{ {
self->setButtonsEnabled(TRUE); self->setButtonsEnabled(TRUE);
} }
@@ -201,7 +228,7 @@ void LLFloaterTeleportHistory::onTeleport(void* data)
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data;
// build secondlife::/app link from simstring for instant teleport to destination // build secondlife::/app link from simstring for instant teleport to destination
std::string slapp="secondlife:///app/teleport/" + self->mPlacesList->getFirstSelected()->getColumn(4)->getValue().asString(); std::string slapp = "secondlife:///app/teleport/" + self->mPlacesList->getFirstSelected()->getColumn(LIST_SIMSTRING)->getValue().asString();
LLMediaCtrl* web = NULL; LLMediaCtrl* web = NULL;
LLURLDispatcher::dispatch(slapp, web, TRUE); LLURLDispatcher::dispatch(slapp, web, TRUE);
} }
@@ -212,7 +239,7 @@ void LLFloaterTeleportHistory::onShowOnMap(void* data)
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data;
// get simstring from selected entry and parse it for its components // get simstring from selected entry and parse it for its components
std::string simString = self->mPlacesList->getFirstSelected()->getColumn(4)->getValue().asString(); std::string simString = self->mPlacesList->getFirstSelected()->getColumn(LIST_SIMSTRING)->getValue().asString();
std::string region = ""; std::string region = "";
S32 x = 128; S32 x = 128;
S32 y = 128; S32 y = 128;
@@ -231,6 +258,6 @@ void LLFloaterTeleportHistory::onCopySLURL(void* data)
LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data; LLFloaterTeleportHistory* self = (LLFloaterTeleportHistory*) data;
// get SLURL of the selected entry and copy it to the clipboard // get SLURL of the selected entry and copy it to the clipboard
std::string SLURL=self->mPlacesList->getFirstSelected()->getColumn(3)->getValue().asString(); std::string SLURL = self->mPlacesList->getFirstSelected()->getColumn(LIST_SLURL)->getValue().asString();
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(SLURL)); gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(SLURL));
} }

View File

@@ -45,39 +45,54 @@
class LLFloaterTeleportHistory : public LLFloater class LLFloaterTeleportHistory : public LLFloater
{ {
public: public:
LLFloaterTeleportHistory(); LLFloaterTeleportHistory();
virtual ~LLFloaterTeleportHistory(); virtual ~LLFloaterTeleportHistory();
/// @brief: reimplemented to check for selection changes in the places list scrolllist /// @brief: reimplemented to check for selection changes in the places list scrolllist
virtual void onFocusReceived(); virtual void onFocusReceived();
/// @brief: reimplemented to make the menu toggle work /// @brief: reimplemented to make the menu toggle work
virtual void onClose(bool app_quitting); virtual void onClose(bool app_quitting);
/// @brief: reimplemented to prevent this floater from closing while the viewer is shutting down /// @brief: reimplemented to prevent this floater from closing while the viewer is shutting down
virtual BOOL canClose(); virtual BOOL canClose();
BOOL postBuild(); BOOL postBuild();
/// @brief: adds a teleport destination to the list of visited places /// @brief: adds the pending teleport destination
void addEntry(std::string regionName, S16 x, S16 y, S16 z); void addPendingEntry(std::string regionName, S16 x, S16 y, S16 z);
/// @brief: adds the destination to the list of visited places
void addEntry(std::string parcelName);
protected: private:
static void onPlacesSelected(LLUICtrl* ctrl, void* data); enum HISTORY_COLUMN_ORDER
static void onTeleport(void* data); {
static void onShowOnMap(void* data); LIST_PARCEL,
static void onCopySLURL(void* data); LIST_REGION,
LIST_POSITION,
LIST_VISITED,
LIST_SLURL,
LIST_SIMSTRING
};
/// @brief: enables or disables the "Teleport", "Show On Map" and "Copy To SLURL" buttons **/ static void onPlacesSelected(LLUICtrl* ctrl, void* data);
void setButtonsEnabled(BOOL on); static void onTeleport(void* data);
static void onShowOnMap(void* data);
static void onCopySLURL(void* data);
LLScrollListCtrl* mPlacesList; /// @brief: enables or disables the "Teleport", "Show On Map" and "Copy To SLURL" buttons **/
void setButtonsEnabled(BOOL on);
S32 id; LLScrollListCtrl* mPlacesList;
/// @brief: to see if this was the first time setVisible() was called (at program startup) S32 mID;
BOOL firstRun;
std::string mPendingRegionName;
std::string mPendingPosition;
std::string mPendingSimString;
std::string mPendingTimeString;
std::string mPendingSLURL;
}; };
// globals // globals

View File

@@ -3748,7 +3748,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
} }
// add teleport destination to the list of visited places // add teleport destination to the list of visited places
gFloaterTeleportHistory->addEntry(regionp->getName(),(S16)agent_pos.mV[0],(S16)agent_pos.mV[1],(S16)agent_pos.mV[2]); gFloaterTeleportHistory->addPendingEntry(regionp->getName(), (S16)agent_pos.mV[VX], (S16)agent_pos.mV[VY], (S16)agent_pos.mV[VZ]);
} }
else else
{ {

View File

@@ -53,6 +53,7 @@
#include "llfloatergroups.h" #include "llfloatergroups.h"
//#include "llfloaterhtml.h" //#include "llfloaterhtml.h"
#include "llfloatersellland.h" #include "llfloatersellland.h"
#include "llfloaterteleporthistory.h"
#include "llfloatertools.h" #include "llfloatertools.h"
#include "llnotify.h" #include "llnotify.h"
#include "llparcelselection.h" #include "llparcelselection.h"
@@ -1518,6 +1519,9 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
} }
} }
// Add any pending entry to the TP history now that we got the *new* parcel name.
gFloaterTeleportHistory->addEntry(LLViewerParcelMgr::getInstance()->getAgentParcelName());
// Handle updating selections, if necessary. // Handle updating selections, if necessary.
if (sequence_id == SELECTED_PARCEL_SEQ_ID) if (sequence_id == SELECTED_PARCEL_SEQ_ID)
{ {

View File

@@ -1,46 +1,28 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater can_close="true" can_drag_on_left="false" can_minimize="true" can_resize="false" <floater name="teleporthistory" title="Teleport History" rect_control="FloaterTeleportHistoryRect"
min_width="470" min_height="250" width="470" height="250" name="teleporthistory" can_close="true" can_drag_on_left="false" can_minimize="true" can_resize="true"
rect_control="FloaterTeleportHistoryRect" title="Teleport History"> min_width="550" min_height="150" width="550" height="200">
<tab_container label="TPlistTabs" bottom="40" height="185" left="5" mouse_opaque="false" name="tplisttabs" <scroll_list name="places_list" can_resize="true" multi_select="false"
tab_min_width="50" tab_position="top" width="460" bg_opaque_color="0,0,0,0.0"> background_visible="true" draw_border="true" draw_stripes="true" draw_heading="true"
<panel border="true" bottom="-185" follows="left|top|right|bottom" height="185" height="150" width="530" bottom_delta="-170" top="10" left="10" follows="left|top|right|bottom">
label="Teleported into" left="2" mouse_opaque="true" name="TP-in" width="455"> <column name="parcel" label="Parcel" dynamicwidth="true" />
<scroll_list background_visible="true" draw_border="true" draw_stripes="true" <column name="region" label="Region" width="150" />
draw_heading="true" follows="left|top|right|bottom" left="2" top="5" width="450" <column name="position" label="Position" width="90" />
height="175" bottom_delta="-177" multi_select="false" name="places_list_in"> <column name="visited" label="Visited" width="110" />
<column dynamicwidth="true" label="Region" name="region" /> <!--Hidden fields, used as storage for prebuilt strings, please keep at width 0-->
<column dynamicwidth="true" label="Position" name="position" /> <column name="slurl" label="" width="0" />
<column dynamicwidth="true" label="Visited" name="visited" /> <column name="simstring" label="" width="0" />
<!--Hidden fields, used as storage for prebuilt strings, please keep at width 0--> </scroll_list>
<column width="0" label="SLURL" name="slurl" /> <button name="teleport" label="Teleport" tool_tip="Teleport to selected location"
<column width="0" label="Sim String" name="simstring" /> enabled="false" mouse_opaque="true" font="SansSerif" halign="center"
</scroll_list> height="20" width="90" bottom_delta="-24" left="10" follows="left|bottom"
</panel> />
<panel border="true" bottom="-185" follows="left|top|right|bottom" height="185" <button name="show_on_map" label="Show on map" tool_tip="Center map on selected location."
label="Teleported out of" left="2" mouse_opaque="true" name="TP-out" width="455"> enabled="false" mouse_opaque="true" font="SansSerif" halign="center"
<scroll_list background_visible="true" draw_border="true" draw_stripes="true" height="20" width="125" bottom_delta="0" left_delta="100" follows="left|bottom"
draw_heading="true" follows="left|top|right|bottom" left="2" top="5" width="450" />
height="175" bottom_delta="-177" multi_select="false" name="places_list_out"> <button name="copy_slurl" label="Copy SLURL to clipboard" tool_tip="Copy selected location as SLURL."
<column dynamicwidth="true" label="Region" name="region" /> enabled="false" mouse_opaque="true" font="SansSerif" halign="center"
<column dynamicwidth="true" label="Position" name="position" /> height="20" width="180" bottom_delta="0" left_delta="135" follows="left|bottom"
<column dynamicwidth="true" label="Visited" name="visited" /> />
<!--Hidden fields, used as storage for prebuilt strings, please keep at width 0-->
<column width="0" label="SLURL" name="slurl" />
<column width="0" label="Sim String" name="simstring" />
</scroll_list>
</panel>
</tab_container>
<button
bottom_delta="-24" enabled="false" follows="left|bottom" font="SansSerif" halign="center"
width="90" height="20" label="Teleport" label_selected="Teleport"
left="10" mouse_opaque="true" name="teleport" tool_tip="Teleport to selected location" />
<button bottom_delta="0" enabled="false" follows="left|bottom" font="SansSerif" halign="center"
height="20" label="Show On Map" label_selected="Show On Map"
left_delta="100" mouse_opaque="true" name="show_on_map"
tool_tip="Center map on this location" width="125" />
<button bottom_delta="0" enabled="false" follows="bottom|right" font="SansSerif"
height="20" label="Copy SLURL to clipboard" left="-230" name="copy_slurl"
tool_tip="Copies current location as SLURL to be used on the web."
width="222" />
</floater> </floater>