From f3bc1d19adf53dd8eee484bdbd80cf194fc3f150 Mon Sep 17 00:00:00 2001 From: ziree Date: Tue, 14 Aug 2012 13:38:11 +0200 Subject: [PATCH] Fixed stand/stop flyin/flycam buttons, added Rebake Navesh menu item, status icon flashes while rebaking. Fixes FIRE-7247 --- indra/newview/lllocationinputctrl.cpp | 23 +++- indra/newview/lllocationinputctrl.h | 4 + .../llpanelpathfindingrebakenavmesh.cpp | 19 +++ .../newview/llpanelpathfindingrebakenavmesh.h | 19 ++- indra/newview/llstatusbar.cpp | 119 +++++++++--------- indra/newview/llstatusbar.h | 13 +- indra/newview/llviewermenu.cpp | 19 +++ indra/newview/llviewerwindow.cpp | 9 +- .../skins/default/xui/en/menu_viewer.xml | 14 +++ .../skins/default/xui/en/notifications.xml | 10 +- .../default/xui/en/panel_navmesh_rebake.xml | 3 + .../metaharper/xui/en/panel_toolbar_view.xml | 2 +- .../starlight/xui/en/panel_toolbar_view.xml | 2 +- .../xui/en/panel_toolbar_view.xml | 2 +- .../vintage/xui/en/panel_toolbar_view.xml | 2 +- 15 files changed, 180 insertions(+), 80 deletions(-) diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index c8031b7585..f53b3a76cc 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -67,6 +67,8 @@ #include "rlvhandler.h" // [/RLVa:KB] +#include "llpanelpathfindingrebakenavmesh.h" // Pathfinding rebake functions + //============================================================================ /* * "ADD LANDMARK" BUTTON UPDATING LOGIC @@ -1243,7 +1245,10 @@ void LLLocationInputCtrl::onParcelIconClick(EParcelIcon icon) LLNotificationsUtil::add("NoBuild"); break; case PATHFINDING_DIRTY_ICON: - LLNotificationsUtil::add("PathfindingDirty"); + // Pathfinding rebake functions + // LLNotificationsUtil::add("PathfindingDirty"); + LLNotificationsUtil::add("PathfindingDirty",LLSD(),LLSD(),boost::bind(&LLLocationInputCtrl::rebakeRegionCallback,this,_1,_2)); + // break; case PATHFINDING_DISABLED_ICON: LLNotificationsUtil::add("DynamicPathfindingDisabled"); @@ -1291,3 +1296,19 @@ void LLLocationInputCtrl::createNavMeshStatusListenerForCurrentRegion() LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(currentRegion, true); } } + +// Pathfinding rebake functions +BOOL LLLocationInputCtrl::rebakeRegionCallback(const LLSD& notification,const LLSD& response) +{ + std::string newSetName=response["message"].asString(); + S32 option=LLNotificationsUtil::getSelectedOption(notification,response); + + if(option==0) + { + if(LLPanelPathfindingRebakeNavmesh::getInstance()->isRebakeNeeded()) + LLPanelPathfindingRebakeNavmesh::getInstance()->rebakeNavmesh(); + return TRUE; + } + return FALSE; +} +// diff --git a/indra/newview/lllocationinputctrl.h b/indra/newview/lllocationinputctrl.h index cd6fd24077..b9fd7b7a28 100644 --- a/indra/newview/lllocationinputctrl.h +++ b/indra/newview/lllocationinputctrl.h @@ -205,6 +205,10 @@ private: std::string mHumanReadableLocation; bool isHumanReadableLocationVisible; std::string mMaturityHelpTopic; + + // Pathfinding rebake functions + BOOL rebakeRegionCallback(const LLSD& notification,const LLSD& response); + // }; #endif diff --git a/indra/newview/llpanelpathfindingrebakenavmesh.cpp b/indra/newview/llpanelpathfindingrebakenavmesh.cpp index 7efb1a9227..48d7cac18b 100644 --- a/indra/newview/llpanelpathfindingrebakenavmesh.cpp +++ b/indra/newview/llpanelpathfindingrebakenavmesh.cpp @@ -267,3 +267,22 @@ void LLPanelPathfindingRebakeNavmesh::updatePosition() setOrigin( x_pos, 0); } + +// Pathfinding rebake functions +bool LLPanelPathfindingRebakeNavmesh::isRebakeNeeded() +{ + return mRebakeNavMeshMode==kRebakeNavMesh_Available; +} + +bool LLPanelPathfindingRebakeNavmesh::isRebaking() +{ + return + mRebakeNavMeshMode==kRebakeNavMesh_RequestSent || + mRebakeNavMeshMode==kRebakeNavMesh_InProgress; +} + +void LLPanelPathfindingRebakeNavmesh::rebakeNavmesh() +{ + onNavMeshRebakeClick(); +} +// diff --git a/indra/newview/llpanelpathfindingrebakenavmesh.h b/indra/newview/llpanelpathfindingrebakenavmesh.h index 48764f2aa7..179a7fb7d3 100644 --- a/indra/newview/llpanelpathfindingrebakenavmesh.h +++ b/indra/newview/llpanelpathfindingrebakenavmesh.h @@ -49,9 +49,12 @@ public: virtual void draw(); virtual BOOL handleToolTip( S32 x, S32 y, MASK mask ); -protected: +// Pathfinding rebake functions +// Give status bar access to the enum +// protected: -private: +// private: +// typedef enum { kRebakeNavMesh_Available, @@ -61,13 +64,14 @@ private: kRebakeNavMesh_Default = kRebakeNavMesh_NotAvailable } ERebakeNavMeshMode; +private: // Pathfinding rebake functions LLPanelPathfindingRebakeNavmesh(); virtual ~LLPanelPathfindingRebakeNavmesh(); static LLPanelPathfindingRebakeNavmesh* getPanel(); void setMode(ERebakeNavMeshMode pRebakeNavMeshMode); - ERebakeNavMeshMode getMode() const; + // ERebakeNavMeshMode getMode() const; // Pathfinding rebake functions void onNavMeshRebakeClick(); @@ -91,6 +95,15 @@ private: LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot; boost::signals2::connection mRegionCrossingSlot; LLPathfindingManager::agent_state_slot_t mAgentStateSlot; + +// Pathfinding rebake functions +// Public accessor functions for llviewermenu.cpp to minimaze code changes +public: + bool isRebakeNeeded(); + bool isRebaking(); + void rebakeNavmesh(); + ERebakeNavMeshMode getMode() const; +// }; #endif // LL_LLPANELPATHFINDINGREBAKENAVMESH_H diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index eea2d5390a..6993ea20d5 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -1,3 +1,4 @@ + /** * @file llstatusbar.cpp * @brief LLStatusBar class implementation @@ -86,13 +87,6 @@ #include "rlvhandler.h" #include "kcwlinterface.h" -// Pathfinding support -#include "llenvmanager.h" -#include "llpathfindingmanager.h" -#include "llpathfindingnavmesh.h" -#include "llpathfindingnavmeshstatus.h" -// Pathfinding support - // library includes #include "imageids.h" #include "llfloaterreg.h" @@ -107,6 +101,8 @@ // system includes #include +#include "llpanelpathfindingrebakenavmesh.h" // Pathfinding rebake functions + // // Globals // @@ -159,11 +155,7 @@ LLStatusBar::LLStatusBar(const LLRect& rect) mShowParcelIcons(TRUE), mSquareMetersCredit(0), mSquareMetersCommitted(0), - // Pathfinding support - mRegionCrossingSlot(), - mNavMeshSlot(), - mIsNavMeshDirty(false), - // Pathfinding support + mPathfindingFlashOn(TRUE), // Pathfinding rebake functions mAudioStreamEnabled(FALSE) // ## Zi: Media/Stream separation { setRect(rect); @@ -210,19 +202,6 @@ LLStatusBar::~LLStatusBar() { mShowCoordsCtrlConnection.disconnect(); } - - // Pathfinding support - if (mRegionCrossingSlot.connected()) - { - mRegionCrossingSlot.disconnect(); - } - - if (mNavMeshSlot.connected()) - { - mNavMeshSlot.disconnect(); - } - // Pathfinding support - // LLView destructor cleans up children } @@ -376,11 +355,6 @@ BOOL LLStatusBar::postBuild() updateNetstatVisibility(LLSD(FALSE)); } - // Pathfinding support - mRegionCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLStatusBar::onRegionBoundaryCrossed, this)); - createNavMeshStatusListenerForCurrentRegion(); - // Pathfinding support - return TRUE; } @@ -449,6 +423,27 @@ void LLStatusBar::refresh() mTextTime->setToolTip (dtStr); } + // Pathfinding rebake functions + static LLPanelPathfindingRebakeNavmesh::ERebakeNavMeshMode pathfinding_mode=LLPanelPathfindingRebakeNavmesh::kRebakeNavMesh_Default; + if( LLPanelPathfindingRebakeNavmesh::getInstance()->isRebaking()) + { + LLViewerRegion* agent_region=gAgent.getRegion(); + if( agent_region && + agent_region->dynamicPathfindingEnabled() && + mRebakingTimer.getElapsedTimeF32()>0.5f) + { + mRebakingTimer.reset(); + mPathfindingFlashOn=!mPathfindingFlashOn; + updateParcelIcons(); + } + } + else if(pathfinding_mode!=LLPanelPathfindingRebakeNavmesh::getInstance()->getMode()) + { + pathfinding_mode=LLPanelPathfindingRebakeNavmesh::getInstance()->getMode(); + updateParcelIcons(); + } + // + LLRect r; const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge(); @@ -876,34 +871,6 @@ void LLStatusBar::onNavBarShowCoordinatesCtrlChanged() setParcelInfoText(new_text); } -// Pathfinding support -void LLStatusBar::onRegionBoundaryCrossed() -{ - createNavMeshStatusListenerForCurrentRegion(); -} - -void LLStatusBar::onNavMeshStatusChange(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - mIsNavMeshDirty = pNavMeshStatus.isValid() && (pNavMeshStatus.getStatus() != LLPathfindingNavMeshStatus::kComplete); - update(); -} - -void LLStatusBar::createNavMeshStatusListenerForCurrentRegion() -{ - if (mNavMeshSlot.connected()) - { - mNavMeshSlot.disconnect(); - } - - LLViewerRegion *currentRegion = gAgent.getRegion(); - if (currentRegion != NULL) - { - mNavMeshSlot = LLPathfindingManager::getInstance()->registerNavMeshListenerForRegion(currentRegion, boost::bind(&LLStatusBar::onNavMeshStatusChange, this, _2)); - LLPathfindingManager::getInstance()->requestGetNavMeshForRegion(currentRegion, true); - } -} -// Pathfinding support - void LLStatusBar::buildLocationString(std::string& loc_str, bool show_coords) { // Ansariel: Use V1 layout for location string in status bar so @@ -1038,6 +1005,16 @@ void LLStatusBar::updateParcelIcons() // Pathfinding support bool pathfinding_dynamic_enabled = agent_region->dynamicPathfindingEnabled(); + // Pathfinding rebake functions + bool pathfinding_navmesh_dirty=LLPanelPathfindingRebakeNavmesh::getInstance()->isRebakeNeeded(); + F32 pathfinding_dirty_icon_alpha=1.0; + if(LLPanelPathfindingRebakeNavmesh::getInstance()->isRebaking()) + { + pathfinding_dirty_icon_alpha=mPathfindingFlashOn ? 1.0 : 0.25; + pathfinding_navmesh_dirty=true; + } + // + // Most icons are "block this ability" mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); @@ -1047,8 +1024,9 @@ void LLStatusBar::updateParcelIcons() mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); mParcelIcon[SEE_AVATARS_ICON]->setVisible(!see_avatars); // Pathfinding support - mParcelIcon[PATHFINDING_DIRTY_ICON]->setVisible(mIsNavMeshDirty); - mParcelIcon[PATHFINDING_DISABLED_ICON]->setVisible(!mIsNavMeshDirty && !pathfinding_dynamic_enabled); + mParcelIcon[PATHFINDING_DIRTY_ICON]->setVisible(pathfinding_navmesh_dirty); + mParcelIcon[PATHFINDING_DIRTY_ICON]->setColor(LLColor4::white % pathfinding_dirty_icon_alpha); + mParcelIcon[PATHFINDING_DISABLED_ICON]->setVisible(!pathfinding_navmesh_dirty && !pathfinding_dynamic_enabled); // Pathfinding support mDamageText->setVisible(allow_damage); mBuyParcelBtn->setVisible(is_for_sale); @@ -1171,7 +1149,10 @@ void LLStatusBar::onParcelIconClick(EParcelIcon icon) break; // Pathfinding support case PATHFINDING_DIRTY_ICON: - LLNotificationsUtil::add("PathfindingDirty"); + // Pathfinding rebake functions + // LLNotificationsUtil::add("PathfindingDirty"); + LLNotificationsUtil::add("PathfindingDirty",LLSD(),LLSD(),boost::bind(&LLStatusBar::rebakeRegionCallback,this,_1,_2)); + // break; case PATHFINDING_DISABLED_ICON: LLNotificationsUtil::add("DynamicPathfindingDisabled"); @@ -1266,3 +1247,19 @@ void LLStatusBar::updateNetstatVisibility(const LLSD& data) rect.translate(NETSTAT_WIDTH * translateFactor, 0); mBalancePanel->setRect(rect); } + +// Pathfinding rebake functions +BOOL LLStatusBar::rebakeRegionCallback(const LLSD& notification,const LLSD& response) +{ + std::string newSetName=response["message"].asString(); + S32 option=LLNotificationsUtil::getSelectedOption(notification,response); + + if(option==0) + { + if(LLPanelPathfindingRebakeNavmesh::getInstance()->isRebakeNeeded()) + LLPanelPathfindingRebakeNavmesh::getInstance()->rebakeNavmesh(); + return TRUE; + } + return FALSE; +} +// diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index 6a3a5a1fec..cae2508e91 100644 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -323,12 +323,13 @@ private: boost::signals2::connection mParcelPropsCtrlConnection; boost::signals2::connection mShowCoordsCtrlConnection; boost::signals2::connection mParcelMgrConnection; - - // Pathfinding support - boost::signals2::connection mRegionCrossingSlot; - LLPathfindingNavMesh::navmesh_slot_t mNavMeshSlot; - bool mIsNavMeshDirty; - // Pathfinding support + + // Pathfinding rebake functions + BOOL rebakeRegionCallback(const LLSD& notification,const LLSD& response); + + LLFrameTimer mRebakingTimer; + BOOL mPathfindingFlashOn; + // }; // *HACK: Status bar owns your cached money balance. JC diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 770f418b67..5067b79be3 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -142,6 +142,8 @@ #include "fscontactsfloater.h" // Display group list in contacts floater #include "fswsassetblacklist.h" +#include "llpanelpathfindingrebakenavmesh.h" // Pathfinding rebake functions + using namespace LLVOAvatarDefines; typedef LLPointer LLViewerObjectPtr; @@ -9568,6 +9570,18 @@ void toggleTeleportHistory() } // Toggle teleport history panel directly +// Pathfinding rebake functions +bool enable_rebake_region() +{ + return LLPanelPathfindingRebakeNavmesh::getInstance()->isRebakeNeeded(); +} + +void handle_rebake_region() +{ + LLPanelPathfindingRebakeNavmesh::getInstance()->rebakeNavmesh(); +} +// + // Make sure to call this before any of the UI is set up, so all text editors can // pick up the menu properly. void initialize_edit_menu() @@ -10107,4 +10121,9 @@ void initialize_menus() commit.add("ToggleSettingsDebug", boost::bind(&toggleSettingsDebug)); // Toggle teleport history panel directly commit.add("ToggleTeleportHistory", boost::bind(&toggleTeleportHistory)); + + // Pathfinding rebake functions + commit.add("World.RebakeRegion", boost::bind(&handle_rebake_region)); + enable.add("World.RebakeRegion", boost::bind(&enable_rebake_region)); + // } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 82327f0f67..10af3e421a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2027,8 +2027,13 @@ void LLViewerWindow::initWorldUI() LLPanelStandStopFlying* panel_stand_stop_flying = LLPanelStandStopFlying::getInstance(); panel_ssf_container->addChild(panel_stand_stop_flying); - LLPanelPathfindingRebakeNavmesh *panel_rebake_navmesh = LLPanelPathfindingRebakeNavmesh::getInstance(); - panel_ssf_container->addChild(panel_rebake_navmesh); + // Pathfinding rebake functions + // We don't use this panel, we use a menu item instead, so we only initialize the panel + // but don't add it to the UI. + // LLPanelPathfindingRebakeNavmesh *panel_rebake_navmesh = LLPanelPathfindingRebakeNavmesh::getInstance(); + // panel_ssf_container->addChild(panel_rebake_navmesh); + LLPanelPathfindingRebakeNavmesh::getInstance(); + // panel_ssf_container->setVisible(TRUE); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 1b0b870dfc..e6b2a2e49e 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1345,6 +1345,20 @@ + + + + + + + + + + diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 3eb1f97717..986d24ceb4 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6156,12 +6156,16 @@ This area has building disabled. You can't build or rez objects here. + type="alertmodal"> - The region has pending pathfinding changes. If you have build rights, you may rebake the region by clicking on the “Rebake region” button. +The region has pending pathfinding changes. If you have build rights, you may rebake the region by clicking on the “Rebake” button. + + + + diff --git a/indra/newview/skins/starlight/xui/en/panel_toolbar_view.xml b/indra/newview/skins/starlight/xui/en/panel_toolbar_view.xml index ce1805a3a2..c94c67fc47 100644 --- a/indra/newview/skins/starlight/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/starlight/xui/en/panel_toolbar_view.xml @@ -188,7 +188,7 @@ right="-10" mouse_opaque="false" tab_stop="false" - name="stand_stop_flying_container" + name="state_management_buttons_container" visible="false" width="210" /> diff --git a/indra/newview/skins/starlightcui/xui/en/panel_toolbar_view.xml b/indra/newview/skins/starlightcui/xui/en/panel_toolbar_view.xml index 37405cab14..73c4f0c88c 100644 --- a/indra/newview/skins/starlightcui/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/starlightcui/xui/en/panel_toolbar_view.xml @@ -188,7 +188,7 @@ right="-10" mouse_opaque="false" tab_stop="false" - name="stand_stop_flying_container" + name="state_management_buttons_container" visible="false" width="210" /> diff --git a/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml b/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml index 662c720919..8123df070f 100644 --- a/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml +++ b/indra/newview/skins/vintage/xui/en/panel_toolbar_view.xml @@ -189,7 +189,7 @@ left="350" mouse_opaque="false" tab_stop="false" - name="stand_stop_flying_container" + name="state_management_buttons_container" visible="true" width="158"/>