Initial implementation of parcel property icons and maturity string on nav bar

Added new LLAgentUI location format, renamed unclear old one
Renamed ShowCoordinatesOption to NavBarShowCoordinates
Extended LLLocationInputCtrl to show icons.
Reviewed with Rick
master
James Cook 2009-11-23 14:23:51 -08:00
parent 83237f875c
commit 347562844d
14 changed files with 256 additions and 53 deletions

View File

@ -7709,7 +7709,7 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>ShowCoordinatesOption</key>
<key>NavBarShowCoordinates</key>
<map>
<key>Comment</key>
<string>Show Coordinates in Location Input Field</string>

View File

@ -130,6 +130,7 @@ BOOL LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const
// create a default name and description for the landmark
std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName();
std::string region_name = region->getName();
std::string sim_access_string = region->getSimAccessString();
std::string buffer;
if( parcel_name.empty() )
{
@ -142,7 +143,13 @@ BOOL LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const
case LOCATION_FORMAT_NORMAL:
buffer = llformat("%s", region_name.c_str());
break;
case LOCATION_FORMAT_WITHOUT_SIM:
case LOCATION_FORMAT_NO_COORDS:
buffer = llformat("%s%s%s",
region_name.c_str(),
sim_access_string.empty() ? "" : " - ",
sim_access_string.c_str());
break;
case LOCATION_FORMAT_NO_MATURITY:
case LOCATION_FORMAT_FULL:
buffer = llformat("%s (%d, %d, %d)",
region_name.c_str(),
@ -161,14 +168,20 @@ BOOL LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const
case LOCATION_FORMAT_NORMAL:
buffer = llformat("%s, %s", parcel_name.c_str(), region_name.c_str());
break;
case LOCATION_FORMAT_WITHOUT_SIM:
case LOCATION_FORMAT_NO_MATURITY:
buffer = llformat("%s, %s (%d, %d, %d)",
parcel_name.c_str(),
region_name.c_str(),
pos_x, pos_y, pos_z);
break;
case LOCATION_FORMAT_NO_COORDS:
buffer = llformat("%s, %s%s%s",
parcel_name.c_str(),
region_name.c_str(),
sim_access_string.empty() ? "" : " - ",
sim_access_string.c_str());
break;
case LOCATION_FORMAT_FULL:
std::string sim_access_string = region->getSimAccessString();
buffer = llformat("%s, %s (%d, %d, %d)%s%s",
parcel_name.c_str(),
region_name.c_str(),

View File

@ -38,10 +38,11 @@ class LLAgentUI
public:
enum ELocationFormat
{
LOCATION_FORMAT_NORMAL,
LOCATION_FORMAT_LANDMARK,
LOCATION_FORMAT_WITHOUT_SIM,
LOCATION_FORMAT_FULL,
LOCATION_FORMAT_NORMAL, // Parcel
LOCATION_FORMAT_LANDMARK, // Parcel, Region
LOCATION_FORMAT_NO_MATURITY, // Parcel, Region (x, y, z)
LOCATION_FORMAT_NO_COORDS, // Parcel, Region - Maturity
LOCATION_FORMAT_FULL, // Parcel, Region (x, y, z) - Maturity
};
static void buildName(std::string& name);

View File

@ -67,7 +67,10 @@
#include "llresmgr.h"
#include "pipeline.h"
#include "llspatialpartition.h"
// Height of the yellow selection highlight posts for land
const F32 PARCEL_POST_HEIGHT = 0.666f;
BOOL LLAgent::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
{
if(object && object->isAttachment())

View File

@ -157,15 +157,21 @@ LLLocationInputCtrl::Params::Params()
add_landmark_image_disabled("add_landmark_image_disabled"),
add_landmark_image_hover("add_landmark_image_hover"),
add_landmark_image_selected("add_landmark_image_selected"),
icon_hpad("icon_hpad", 0),
add_landmark_button("add_landmark_button"),
add_landmark_hpad("add_landmark_hpad", 0),
info_button("info_button")
info_button("info_button"),
voice_icon("voice_icon"),
fly_icon("fly_icon"),
push_icon("push_icon"),
build_icon("build_icon"),
scripts_icon("scripts_icon"),
damage_icon("damage_icon")
{
}
LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
: LLComboBox(p),
mAddLandmarkHPad(p.add_landmark_hpad),
mIconHPad(p.icon_hpad),
mInfoBtn(NULL),
mLocationContextMenu(NULL),
mAddLandmarkBtn(NULL),
@ -230,6 +236,32 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
mAddLandmarkBtn = LLUICtrlFactory::create<LLButton>(al_params);
enableAddLandmarkButton(true);
addChild(mAddLandmarkBtn);
// Parcel property icons
LLIconCtrl::Params voice_icon = p.voice_icon;
mParcelIcon[VOICE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(voice_icon);
addChild(mParcelIcon[VOICE_ICON]);
LLIconCtrl::Params fly_icon = p.fly_icon;
mParcelIcon[FLY_ICON] = LLUICtrlFactory::create<LLIconCtrl>(fly_icon);
addChild(mParcelIcon[FLY_ICON]);
LLIconCtrl::Params push_icon = p.push_icon;
mParcelIcon[PUSH_ICON] = LLUICtrlFactory::create<LLIconCtrl>(push_icon);
addChild(mParcelIcon[PUSH_ICON]);
LLIconCtrl::Params build_icon = p.build_icon;
mParcelIcon[BUILD_ICON] = LLUICtrlFactory::create<LLIconCtrl>(build_icon);
addChild(mParcelIcon[BUILD_ICON]);
LLIconCtrl::Params scripts_icon = p.scripts_icon;
mParcelIcon[SCRIPTS_ICON] = LLUICtrlFactory::create<LLIconCtrl>(scripts_icon);
addChild(mParcelIcon[SCRIPTS_ICON]);
LLIconCtrl::Params damage_icon = p.damage_icon;
mParcelIcon[DAMAGE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(damage_icon);
addChild(mParcelIcon[DAMAGE_ICON]);
// TODO: health number?
// Register callbacks and load the location field context menu (NB: the order matters).
LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2));
@ -410,9 +442,10 @@ void LLLocationInputCtrl::onFocusLost()
mTextEntry->deselect();
}
}
void LLLocationInputCtrl::draw(){
if(!hasFocus() && gSavedSettings.getBOOL("ShowCoordinatesOption")){
void LLLocationInputCtrl::draw()
{
if(!hasFocus() && gSavedSettings.getBOOL("NavBarShowCoordinates")){
refreshLocation();
}
LLComboBox::draw();
@ -532,6 +565,7 @@ void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask)
void LLLocationInputCtrl::refresh()
{
refreshLocation(); // update location string
refreshParcelIcons();
updateAddLandmarkButton(); // indicate whether current parcel has been landmarked
}
@ -548,13 +582,57 @@ void LLLocationInputCtrl::refreshLocation()
// Update location field.
std::string location_name;
LLAgentUI::ELocationFormat format = (gSavedSettings.getBOOL("ShowCoordinatesOption") ?
LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM: LLAgentUI::LOCATION_FORMAT_NORMAL);
LLAgentUI::ELocationFormat format =
(gSavedSettings.getBOOL("NavBarShowCoordinates")
? LLAgentUI::LOCATION_FORMAT_FULL
: LLAgentUI::LOCATION_FORMAT_NO_COORDS);
if (!LLAgentUI::buildLocationString(location_name, format)) location_name = "Unknown";
if (!LLAgentUI::buildLocationString(location_name, format))
{
location_name = "???";
}
setText(location_name);
}
void LLLocationInputCtrl::refreshParcelIcons()
{
LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance();
// *TODO buy
//bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false);
bool allow_voice = vpm->allowAgentVoice();
bool allow_fly = vpm->allowAgentFly();
bool allow_push = vpm->allowAgentPush();
bool allow_build = vpm->allowAgentBuild();
bool allow_scripts = vpm->allowAgentScripts();
bool allow_damage = vpm->allowAgentDamage();
// Most icons are "block this ability"
mParcelIcon[VOICE_ICON]->setVisible( !allow_voice );
mParcelIcon[FLY_ICON]->setVisible( !allow_fly );
mParcelIcon[PUSH_ICON]->setVisible( !allow_push );
mParcelIcon[BUILD_ICON]->setVisible( !allow_build );
mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts );
mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage );
// *TODO damage meter
// Slide the parcel icons rect from right to left, adjusting rectangles of
// visible icons. Assumes all icon rects are the same.
LLRect icon_rect = mParcelIcon[0]->getRect();
S32 icon_width = icon_rect.getWidth();
icon_rect.mRight = mAddLandmarkBtn->getRect().mLeft - mIconHPad;
icon_rect.mLeft = icon_rect.mRight - icon_width;
for (S32 i = 0; i < ICON_COUNT; ++i)
{
if (mParcelIcon[i]->getVisible())
{
mParcelIcon[i]->setRect( icon_rect );
icon_rect.translate( -icon_width - mIconHPad, 0);
}
}
// *TODO: health meter
}
void LLLocationInputCtrl::rebuildLocationHistory(std::string filter)
{
LLLocationHistory::location_list_t filtered_items;
@ -651,13 +729,11 @@ void LLLocationInputCtrl::updateWidgetlayout()
mInfoBtn->setRect(info_btn_rect);
// "Add Landmark" button
{
LLRect al_btn_rect = mAddLandmarkBtn->getRect();
al_btn_rect.translate(
hist_btn_rect.mLeft - mAddLandmarkHPad - al_btn_rect.getWidth(),
(rect.getHeight() - al_btn_rect.getHeight()) / 2);
mAddLandmarkBtn->setRect(al_btn_rect);
}
LLRect al_btn_rect = mAddLandmarkBtn->getRect();
al_btn_rect.translate(
hist_btn_rect.mLeft - mIconHPad - al_btn_rect.getWidth(),
(rect.getHeight() - al_btn_rect.getHeight()) / 2);
mAddLandmarkBtn->setRect(al_btn_rect);
}
void LLLocationInputCtrl::changeLocationPresentation()
@ -680,7 +756,7 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata)
if (item == std::string("show_coordinates"))
{
gSavedSettings.setBOOL("ShowCoordinatesOption",!gSavedSettings.getBOOL("ShowCoordinatesOption"));
gSavedSettings.setBOOL("NavBarShowCoordinates",!gSavedSettings.getBOOL("NavBarShowCoordinates"));
}
else if (item == std::string("landmark"))
{
@ -744,7 +820,7 @@ bool LLLocationInputCtrl::onLocationContextMenuItemEnabled(const LLSD& userdata)
}
else if(item == std::string("show_coordinates")){
return gSavedSettings.getBOOL("ShowCoordinatesOption");
return gSavedSettings.getBOOL("NavBarShowCoordinates");
}
return false;

View File

@ -33,7 +33,8 @@
#ifndef LL_LLLOCATIONINPUTCTRL_H
#define LL_LLLOCATIONINPUTCTRL_H
#include <llcombobox.h>
#include "llcombobox.h"
#include "lliconctrl.h" // Params
class LLLandmark;
@ -63,9 +64,15 @@ public:
add_landmark_image_disabled,
add_landmark_image_hover,
add_landmark_image_selected;
Optional<S32> add_landmark_hpad;
Optional<S32> icon_hpad;
Optional<LLButton::Params> add_landmark_button,
info_button;
Optional<LLIconCtrl::Params> voice_icon,
fly_icon,
push_icon,
build_icon,
scripts_icon,
damage_icon;
Params();
};
@ -103,6 +110,7 @@ private:
void enableAddLandmarkButton(bool val);
void refresh();
void refreshLocation();
void refreshParcelIcons();
void rebuildLocationHistory(std::string filter = "");
bool findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter);
void setText(const LLStringExplicit& text);
@ -126,7 +134,20 @@ private:
LLMenuGL* mLocationContextMenu;
LLButton* mAddLandmarkBtn;
LLButton* mInfoBtn;
S32 mAddLandmarkHPad;
S32 mIconHPad;
enum EParcelIcon
{
VOICE_ICON = 0,
FLY_ICON,
PUSH_ICON,
BUILD_ICON,
SCRIPTS_ICON,
DAMAGE_ICON,
ICON_COUNT
};
LLIconCtrl* mParcelIcon[ICON_COUNT];
// TODO: Health meter?
LLAddLandmarkObserver* mAddLandmarkObserver;
LLRemoveLandmarkObserver* mRemoveLandmarkObserver;

View File

@ -413,7 +413,7 @@ void LLNavigationBar::onTeleportFinished(const LLVector3d& global_agent_pos, con
* At this moment gAgent.getPositionAgent() contains previous coordinates.
* according to EXT-65 agent position is being reseted on each frame.
*/
LLAgentUI::buildLocationString(location, LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM,
LLAgentUI::buildLocationString(location, LLAgentUI::LOCATION_FORMAT_NO_MATURITY,
gAgent.getPosAgentFromGlobal(global_agent_pos));
std::string tooltip (LLSLURL::buildSLURLfromPosGlobal(gAgent.getRegion()->getName(), global_agent_pos, false));

View File

@ -52,7 +52,7 @@
const std::string& LLTeleportHistoryItem::getTitle() const
{
return gSavedSettings.getBOOL("ShowCoordinatesOption") ? mFullTitle : mTitle;
return gSavedSettings.getBOOL("NavBarShowCoordinates") ? mFullTitle : mTitle;
}
//////////////////////////////////////////////////////////////////////////////
@ -177,7 +177,7 @@ void LLTeleportHistory::purgeItems()
std::string LLTeleportHistory::getCurrentLocationTitle(bool full, const LLVector3& local_pos_override)
{
std::string location_name;
LLAgentUI::ELocationFormat fmt = full ? LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM : LLAgentUI::LOCATION_FORMAT_NORMAL;
LLAgentUI::ELocationFormat fmt = full ? LLAgentUI::LOCATION_FORMAT_NO_MATURITY : LLAgentUI::LOCATION_FORMAT_NORMAL;
if (!LLAgentUI::buildLocationString(location_name, fmt, local_pos_override)) location_name = "Unknown";
return location_name;

View File

@ -57,7 +57,8 @@ public:
{}
/**
* @return title formatted according to the current value of the ShowCoordinatesOption setting.
* @return title formatted according to the current value of the
* NavBarShowCoordinates setting.
*/
const std::string& getTitle() const;

View File

@ -247,7 +247,7 @@ bool LLToolMgr::inEdit()
bool LLToolMgr::canEdit()
{
return LLViewerParcelMgr::getInstance()->agentCanBuild();
return LLViewerParcelMgr::getInstance()->allowAgentBuild();
}
void LLToolMgr::toggleBuildMode()

View File

@ -2736,7 +2736,7 @@ bool enable_object_edit()
bool enable = false;
if (gAgent.inPrelude())
{
enable = LLViewerParcelMgr::getInstance()->agentCanBuild()
enable = LLViewerParcelMgr::getInstance()->allowAgentBuild()
|| LLSelectMgr::getInstance()->getSelection()->isAttachment();
}
else if (LLSelectMgr::getInstance()->selectGetModify())
@ -6096,7 +6096,7 @@ class LLAttachmentEnableDrop : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
BOOL can_build = gAgent.isGodlike() || (LLViewerParcelMgr::getInstance()->agentCanBuild());
BOOL can_build = gAgent.isGodlike() || (LLViewerParcelMgr::getInstance()->allowAgentBuild());
//Add an inventory observer to only allow dropping the newly attached item
//once it exists in your inventory. Look at Jira 2422.

View File

@ -650,7 +650,7 @@ LLParcel *LLViewerParcelMgr::getAgentParcel() const
}
// Return whether the agent can build on the land they are on
bool LLViewerParcelMgr::agentCanBuild() const
bool LLViewerParcelMgr::allowAgentBuild() const
{
if (mAgentParcel)
{
@ -664,19 +664,47 @@ bool LLViewerParcelMgr::agentCanBuild() const
}
}
BOOL LLViewerParcelMgr::agentCanTakeDamage() const
bool LLViewerParcelMgr::allowAgentVoice() const
{
return mAgentParcel->getAllowDamage();
LLViewerRegion* region = gAgent.getRegion();
return region && region->isVoiceEnabled()
&& mAgentParcel && mAgentParcel->getParcelFlagAllowVoice();
}
BOOL LLViewerParcelMgr::agentCanFly() const
bool LLViewerParcelMgr::allowAgentFly() const
{
return TRUE;
LLViewerRegion* region = gAgent.getRegion();
return region && !region->getBlockFly()
&& mAgentParcel && mAgentParcel->getAllowFly();
}
F32 LLViewerParcelMgr::agentDrawDistance() const
// Can the agent be pushed around by LLPushObject?
bool LLViewerParcelMgr::allowAgentPush() const
{
return 512.f;
LLViewerRegion* region = gAgent.getRegion();
return region && !region->getRestrictPushObject()
&& mAgentParcel && !mAgentParcel->getRestrictPushObject();
}
bool LLViewerParcelMgr::allowAgentScripts() const
{
LLViewerRegion* region = gAgent.getRegion();
// *NOTE: This code does not take into account group-owned parcels
// and the flag to allow group-owned scripted objects to run.
// This mirrors the traditional menu bar parcel icon code, but is not
// technically correct.
return region
&& !(region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS)
&& !(region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS)
&& mAgentParcel
&& mAgentParcel->getAllowOtherScripts();
}
bool LLViewerParcelMgr::allowAgentDamage() const
{
LLViewerRegion* region = gAgent.getRegion();
return region && region->getAllowDamage()
&& mAgentParcel && mAgentParcel->getAllowDamage();
}
BOOL LLViewerParcelMgr::isOwnedAt(const LLVector3d& pos_global) const

View File

@ -56,9 +56,6 @@ class LLViewerRegion;
// | EAST_MASK
// | WEST_MASK);
const F32 PARCEL_POST_HEIGHT = 0.666f;
//const F32 PARCEL_POST_HEIGHT = 20.f;
// Specify the type of land transfer taking place
//enum ELandTransferType
//{
@ -171,10 +168,29 @@ public:
LLParcel* getCollisionParcel() const;
BOOL agentCanTakeDamage() const;
BOOL agentCanFly() const;
F32 agentDrawDistance() const;
bool agentCanBuild() const;
// Can this agent build on the parcel he is on?
// Used for parcel property icons in nav bar.
bool allowAgentBuild() const;
// Can this agent speak on the parcel he is on?
// Used for parcel property icons in nav bar.
bool allowAgentVoice() const;
// Can this agent start flying on this parcel?
// Used for parcel property icons in nav bar.
bool allowAgentFly() const;
// Can this agent be pushed by llPushObject() on this parcel?
// Used for parcel property icons in nav bar.
bool allowAgentPush() const;
// Can scripts written by non-parcel-owners run on the agent's current
// parcel? Used for parcel property icons in nav bar.
bool allowAgentScripts() const;
// Can the agent be damaged here?
// Used for parcel property icons in nav bar.
bool allowAgentDamage() const;
F32 getHoverParcelWidth() const
{ return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); }

View File

@ -11,7 +11,7 @@
add_landmark_image_disabled="Favorite_Star_Off"
add_landmark_image_hover="Favorite_Star_Over"
add_landmark_image_selected="Favorite_Star_Press"
add_landmark_hpad="2"
icon_hpad="2"
allow_text_entry="true"
list_position="below"
show_text_as_tentative="false"
@ -38,7 +38,51 @@
scale_image="false"
top="19"
left="-3" />
<combo_button name="Location History"
<voice_icon
name="voice_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_VoiceNo"
/>
<fly_icon
name="fly_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_FlyNo"
/>
<push_icon
name="push_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_PushNo"
/>
<build_icon
name="build_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_BuildNo"
/>
<scripts_icon
name="scripts_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_ScriptsNo"
/>
<!-- NOTE: Placeholder icon, there is no dark grayscale version -->
<damage_icon
name="damage_icon"
width="22"
height="18"
top="21"
image_name="parcel_lght_Damage"
/>
<combo_button name="Location History"
label=""
pad_right="0"/>
<combo_list bg_writeable_color="MenuDefaultBgColor" page_lines="10"