From 3cc37fb12b9275112485645e8de9b0469ba4ae01 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 22 Apr 2012 19:42:37 -0500 Subject: [PATCH] LLAgentCamera update. Culled a bunch of dead code from llappviewer. Moved build-mode toggle off into lltoolmgr. --- indra/newview/app_settings/settings.xml | 82 +++++- indra/newview/llagentcamera.cpp | 18 +- indra/newview/llagentcamera.h | 33 ++- indra/newview/llappviewer.cpp | 2 + indra/newview/llfloatertools.cpp | 45 +++- indra/newview/lltoolbar.cpp | 2 +- indra/newview/lltoolmgr.cpp | 115 +++++++- indra/newview/lltoolmgr.h | 12 +- indra/newview/lltoolpie.cpp | 4 +- indra/newview/llviewermenu.cpp | 331 +++++------------------- indra/newview/llviewermenu.h | 14 +- 11 files changed, 354 insertions(+), 304 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 64fd98527..399e0e66c 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2920,10 +2920,10 @@ 6.0 - CameraOffsetDefault + CameraOffsetRearView Comment - Default camera offset from avatar + Initial camera offset from avatar in Rear View Persist 1 Type @@ -2935,6 +2935,36 @@ 0.75 + CameraOffsetFrontView + + Comment + Initial camera offset from avatar in Front View + Persist + 1 + Type + Vector3 + Value + + 2.2 + 0.0 + 0.0 + + + CameraOffsetGroupView + + Comment + Initial camera offset from avatar in Group View + Persist + 1 + Type + Vector3 + Value + + -1.0 + 0.7 + 0.5 + + CameraOffsetScale Comment @@ -2972,6 +3002,18 @@ Value 1.0 + CameraPreset + + Comment + Preset camera position - view (0 - rear, 1 - front, 2 - group) + Persist + 1 + Type + U32 + Value + 0 + + CameraFocusTransitionTime Comment @@ -6679,14 +6721,14 @@ Value 0 - FocusOffsetDefault + FocusOffsetRearView Comment - Default focus point offset relative to avatar (x-axis is forward) + Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward) Persist 1 Type - Vector3 + Vector3D Value 1.0 @@ -6694,6 +6736,36 @@ 1.0 + FocusOffsetFrontView + + Comment + Initial focus point offset relative to avatar for the camera preset Front View + Persist + 1 + Type + Vector3D + Value + + 0.0 + 0.0 + 0.0 + + + FocusOffsetGroupView + + Comment + Initial focus point offset relative to avatar for the camera preset Group View + Persist + 1 + Type + Vector3D + Value + + 1.5 + 0.7 + 1.0 + + FocusPosOnLogout Comment diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index b3b72a356..44994b59a 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -128,7 +128,7 @@ LLAgentCamera::LLAgentCamera() : mCameraMode( CAMERA_MODE_THIRD_PERSON ), mLastCameraMode( CAMERA_MODE_THIRD_PERSON ), - //mCameraPreset(CAMERA_PRESET_REAR_VIEW), + mCameraPreset(CAMERA_PRESET_REAR_VIEW), mCameraAnimating( FALSE ), mAnimationCameraStartGlobal(), @@ -141,7 +141,6 @@ LLAgentCamera::LLAgentCamera() : mCameraFocusOffset(), mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW), - mCameraOffsetDefault(), mCameraCollidePlane(), mCurrentCameraDistance(2.f), // meters, set in init() @@ -212,8 +211,7 @@ void LLAgentCamera::init() mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild")); - mCameraOffsetDefault = gSavedSettings.getVector3("CameraOffsetDefault");//Legacy - /*mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView"); mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView"); @@ -221,7 +219,7 @@ void LLAgentCamera::init() mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView"); mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView"); - mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");*/ + mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView"); mCameraCollidePlane.clearVec(); mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"); @@ -1681,14 +1679,13 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset() { // ...offset from avatar LLVector3d focus_offset; - focus_offset.setVec(gSavedSettings.getVector3("FocusOffsetDefault")); LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion(); if (isAgentAvatarValid() && gAgentAvatarp->getParent()) { agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation(); } - //focus_offset = convert_from_llsd(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); + focus_offset = convert_from_llsd(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, ""); return focus_offset * agent_rot; } @@ -2023,8 +2020,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit) LLVector3 LLAgentCamera::getCameraOffsetInitial() { - //return convert_from_llsd(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, ""); - return mCameraOffsetDefault; + return convert_from_llsd(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, ""); } @@ -2449,7 +2445,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar() } -/*void LLAgentCamera::switchCameraPreset(ECameraPreset preset) +void LLAgentCamera::switchCameraPreset(ECameraPreset preset) { //zoom is supposed to be reset for the front and group views mCameraZoomFraction = 1.f; @@ -2460,7 +2456,7 @@ void LLAgentCamera::changeCameraToCustomizeAvatar() mCameraPreset = preset; gSavedSettings.setU32("CameraPreset", mCameraPreset); -}*/ +} // diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h index 86b2d84fd..663742751 100644 --- a/indra/newview/llagentcamera.h +++ b/indra/newview/llagentcamera.h @@ -46,6 +46,19 @@ enum ECameraMode CAMERA_MODE_FOLLOW }; +/** Camera Presets for CAMERA_MODE_THIRD_PERSON */ +enum ECameraPreset +{ + /** Default preset, what the Third Person Mode actually was */ + CAMERA_PRESET_REAR_VIEW, + + /** "Looking at the Avatar from the front" */ + CAMERA_PRESET_FRONT_VIEW, + + /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */ + CAMERA_PRESET_GROUP_VIEW +}; + //------------------------------------------------------------------------ // LLAgentCamera //------------------------------------------------------------------------ @@ -94,9 +107,28 @@ private: ECameraMode mCameraMode; // Target mode after transition animation is done ECameraMode mLastCameraMode; F32 mUIOffset; + + //-------------------------------------------------------------------- + // Preset + //-------------------------------------------------------------------- +public: + void switchCameraPreset(ECameraPreset preset); +private: /** Determines default camera offset depending on the current camera preset */ LLVector3 getCameraOffsetInitial(); + /** Camera preset in Third Person Mode */ + ECameraPreset mCameraPreset; + + /** Initial camera offsets */ + std::map > mCameraOffsetInitial; + + /** Initial focus offsets */ + std::map > mFocusOffsetInitial; + + //-------------------------------------------------------------------- + // Position + //-------------------------------------------------------------------- public: LLVector3d getCameraPositionGlobal() const; const LLVector3 &getCameraPositionAgent() const; @@ -185,7 +217,6 @@ public: private: LLVector3d mCameraFocusOffset; // Offset from focus point in build mode LLVector3d mCameraFocusOffsetTarget; // Target towards which we are lerping the camera's focus offset - LLVector3 mCameraOffsetDefault; BOOL mFocusOnAvatar; LLVector3d mFocusGlobal; LLVector3d mFocusTargetGlobal; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a91538406..b2f3b32f1 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -724,6 +724,8 @@ bool LLAppViewer::init() &LLURLDispatcher::dispatchFromTextEditor, &LLURLDispatcher::dispatchFromTextEditor); + LLToolMgr::getInstance(); // Initialize tool manager if not already instantiated + ///////////////////////////////////////////////// // // Load settings files diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 913051f61..2f48e7ff7 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -102,7 +102,6 @@ const std::string PANEL_NAMES[LLFloaterTools::PANEL_COUNT] = }; // Local prototypes -void commit_select_tool(LLUICtrl *ctrl, void *data); void commit_select_component(LLUICtrl *ctrl, void *data); void click_show_more(void*); void click_popup_info(void*); @@ -123,6 +122,7 @@ void commit_radio_orbit(LLUICtrl *, void*); void commit_radio_pan(LLUICtrl *, void*); void commit_grid_mode(LLUICtrl *, void*); void commit_slider_zoom(LLUICtrl *, void*); +void commit_select_tool(LLUICtrl *ctrl, void *data); //static @@ -254,15 +254,15 @@ BOOL LLFloaterTools::postBuild() mRadioSpin = getChild("radio spin"); childSetCommitCallback("radio spin",click_popup_grab_spin,NULL); mRadioPosition = getChild("radio position"); - childSetCommitCallback("radio position",commit_select_tool,LLToolCompTranslate::getInstance()); + childSetCommitCallback("radio position",commit_select_tool,NULL); mRadioRotate = getChild("radio rotate"); - childSetCommitCallback("radio rotate",commit_select_tool,LLToolCompRotate::getInstance()); + childSetCommitCallback("radio rotate",commit_select_tool,NULL); mRadioStretch = getChild("radio stretch"); - childSetCommitCallback("radio stretch",commit_select_tool,LLToolCompScale::getInstance()); + childSetCommitCallback("radio stretch",commit_select_tool,NULL); mRadioSelectFace = getChild("radio select face"); - childSetCommitCallback("radio select face",commit_select_tool,LLToolFace::getInstance()); + childSetCommitCallback("radio select face",commit_select_tool,NULL); mRadioAlign = getChild("radio align"); - childSetCommitCallback("radio align",commit_select_tool,QToolAlign::getInstance()); + childSetCommitCallback("radio align",commit_select_tool,NULL); mCheckSelectIndividual = getChild("checkbox edit linked parts"); childSetValue("checkbox edit linked parts",(BOOL)gSavedSettings.getBOOL("EditLinkedParts")); childSetCommitCallback("checkbox edit linked parts",commit_select_component,this); @@ -307,7 +307,7 @@ BOOL LLFloaterTools::postBuild() mCheckCopyRotates = getChild("checkbox copy rotates"); childSetValue("checkbox copy rotates",(BOOL)gSavedSettings.getBOOL("CreateToolCopyRotates")); mRadioSelectLand = getChild("radio select land"); - childSetCommitCallback("radio select land",commit_select_tool, LLToolSelectLand::getInstance()); + childSetCommitCallback("radio select land",commit_select_tool, NULL); mRadioDozerFlatten = getChild("radio flatten"); childSetCommitCallback("radio flatten",click_popup_dozer_mode, (void*)0); mRadioDozerRaise = getChild("radio raise"); @@ -997,7 +997,33 @@ void click_apply_to_selection(void* user) void commit_select_tool(LLUICtrl *ctrl, void *data) { S32 show_owners = gSavedSettings.getBOOL("ShowParcelOwners"); - gFloaterTools->setEditTool(data); + + LLCheckBoxCtrl* group = (LLCheckBoxCtrl*)ctrl; + std::string selected = group->getValue().asString(); + if (selected == "radio position") + { + LLFloaterTools::setEditTool( LLToolCompTranslate::getInstance() ); + } + else if (selected == "radio rotate") + { + LLFloaterTools::setEditTool( LLToolCompRotate::getInstance() ); + } + else if (selected == "radio stretch") + { + LLFloaterTools::setEditTool( LLToolCompScale::getInstance() ); + } + else if (selected == "radio select face") + { + LLFloaterTools::setEditTool( LLToolFace::getInstance() ); + } + else if (selected == "radio align") + { + LLFloaterTools::setEditTool( QToolAlign::getInstance() ); + } + else if (selected == "radio select land") + { + LLFloaterTools::setEditTool( LLToolSelectLand::getInstance()); + } gSavedSettings.setBOOL("ShowParcelOwners", show_owners); } @@ -1051,7 +1077,8 @@ void LLFloaterTools::onClickGridOptions(void* data) void LLFloaterTools::setEditTool(void* tool_pointer) { - select_tool(tool_pointer); + LLTool *tool = (LLTool *)tool_pointer; + LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool ); } void LLFloaterTools::onFocusReceived() diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 5678aa236..08a1b26ef 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -537,7 +537,7 @@ void LLToolBar::onClickDirectory(void*) // static void LLToolBar::onClickBuild(void*) { - toggle_build_mode(); + LLToolMgr::getInstance()->toggleBuildMode(); } diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp index 0ad252cae..ff4f66e63 100644 --- a/indra/newview/lltoolmgr.cpp +++ b/indra/newview/lltoolmgr.cpp @@ -51,10 +51,18 @@ #include "lltoolselectland.h" #include "lltoolobjpicker.h" #include "lltoolpipette.h" -#include "llviewerparcelmgr.h" #include "llagent.h" #include "llagentcamera.h" #include "llviewercontrol.h" +#include "llmemberlistener.h" +#include "llevent.h" +#include "llviewerjoystick.h" +#include "llviewermenu.h" +#include "llviewerparcelmgr.h" +#include "llfirstuse.h" +#include "llfloatertools.h" + +#include "rlvhandler.h" // Used when app not active to avoid processing hover. @@ -69,6 +77,24 @@ LLToolset* gFaceEditToolset = NULL; ///////////////////////////////////////////////////// // LLToolMgr +class LLViewBuildMode : public LLMemberListener +{ + bool handleEvent(LLPointer event, const LLSD& userdata) + { + LLToolMgr::getInstance()->toggleBuildMode(); + return true; + } +}; +class LLViewCheckBuildMode : public LLMemberListener +{ + bool handleEvent(LLPointer event, const LLSD& userdata) + { + bool new_value = LLToolMgr::getInstance()->inEdit(); + gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); + return true; + } +}; + LLToolMgr::LLToolMgr() : mBaseTool(NULL), @@ -88,6 +114,14 @@ LLToolMgr::LLToolMgr() gFaceEditToolset = new LLToolset("FaceEdit"); } +void LLToolMgr::initMenu(std::vector > >& menu_list) +{ + menu_list.push_back(new LLViewBuildMode()); + menu_list.back()->registerListener(gMenuHolder, "View.BuildMode"); + menu_list.push_back(new LLViewCheckBuildMode()); + menu_list.back()->registerListener(gMenuHolder, "View.CheckBuildMode"); +} + void LLToolMgr::initTools() { static BOOL initialized = FALSE; @@ -236,7 +270,7 @@ void LLToolMgr::updateToolStatus() getCurrentTool(); } -BOOL LLToolMgr::inEdit() +bool LLToolMgr::inEdit() { return mBaseTool != LLToolPie::getInstance() && mBaseTool != gToolNull; } @@ -245,6 +279,77 @@ bool LLToolMgr::canEdit() { return LLViewerParcelMgr::getInstance()->allowAgentBuild(); } + +void LLToolMgr::toggleBuildMode() +{ + if (!inBuildMode()) + { + ECameraMode camMode = gAgentCamera.getCameraMode(); + if (CAMERA_MODE_MOUSELOOK == camMode || CAMERA_MODE_CUSTOMIZE_AVATAR == camMode) + { + // pull the user out of mouselook or appearance mode when entering build mode + handle_reset_view(); + } + + if (gSavedSettings.getBOOL("EditCameraMovement")) + { + // camera should be set + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + handle_toggle_flycam(); + } + + if (gAgentCamera.getFocusOnAvatar()) + { + // zoom in if we're looking at the avatar + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis())); + gAgentCamera.cameraZoomIn(0.666f); + gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); + } + } + +// [RLVa:KB] - Checked: 2009-07-05 (RLVa-1.0.0b) + bool fRlvCanEdit = (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ)); + if (!fRlvCanEdit) + { + LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); + RlvSelectIsEditable f; + if ((hSel.notNull()) && ((hSel->getFirstRootNode(&f, TRUE)) != NULL)) + LLSelectMgr::getInstance()->deselectAll(); + } +// [/RLVa:KB] + + setCurrentToolset(gBasicToolset); + getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() ); + + // Could be first use + LLFirstUse::useBuild(); + + gAgentCamera.resetView(false); + + // avoid spurious avatar movements + LLViewerJoystick::getInstance()->setNeedsReset(); + + } + else + { + if (gSavedSettings.getBOOL("EditCameraMovement")) + { + // just reset the view, will pull us out of edit mode + handle_reset_view(); + } + else + { + // manually disable edit mode, but do not affect the camera + gAgentCamera.resetView(false); + gFloaterTools->close(); + gViewerWindow->showCursor(); + } + // avoid spurious avatar movements pulling out of edit mode + LLViewerJoystick::getInstance()->setNeedsReset(); + } +} bool LLToolMgr::inBuildMode() { // when entering mouselook inEdit() immediately returns true before @@ -408,9 +513,3 @@ void LLToolset::selectPrevTool() selectToolByIndex((S32)mToolList.size()-1); } } - -void select_tool( void *tool_pointer ) -{ - LLTool *tool = (LLTool *)tool_pointer; - LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool ); -} diff --git a/indra/newview/lltoolmgr.h b/indra/newview/lltoolmgr.h index e3fdb129a..31a481b17 100644 --- a/indra/newview/lltoolmgr.h +++ b/indra/newview/lltoolmgr.h @@ -35,8 +35,11 @@ #include "llkeyboard.h" +#include "llmemberlistener.h" + class LLTool; class LLToolset; +class LLView; // Key bindings for common operations const MASK MASK_VERTICAL = MASK_CONTROL; @@ -52,14 +55,17 @@ public: LLToolMgr(); ~LLToolMgr(); + void initMenu(std::vector > >& menu_list); + // Must be called after gSavedSettings set up. void initTools(); LLTool* getCurrentTool(); // returns active tool, taking into account keyboard state LLTool* getBaseTool(); // returns active tool when overrides are deactivated - BOOL inEdit(); + bool inEdit(); bool canEdit(); + void toggleBuildMode(); /* Determines if we are in Build mode or not. */ bool inBuildMode(); @@ -118,10 +124,6 @@ protected: tool_list_t mToolList; }; -// Handy callbacks for switching tools -void select_tool(void *tool); - - // Globals extern LLToolset* gBasicToolset; diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 580f05314..9b3a87d0e 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -75,7 +75,7 @@ #include "rlvhandler.h" // [/RLVa:KB] -extern void handle_buy(void*); +extern void handle_buy(); extern BOOL gDebugClicks; @@ -627,7 +627,7 @@ void LLToolPie::selectionPropertiesReceived() switch (click_action) { case CLICK_ACTION_BUY: - handle_buy(NULL); + handle_buy(); break; case CLICK_ACTION_PAY: handle_give_money_dialog(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e7265eb8e..dc4fb0b5a 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -344,7 +344,6 @@ typedef LLMemberListener view_listener_t; // // Local prototypes // -void handle_leave_group(void *); // File Menu void handle_compress_image(void*); @@ -368,37 +367,34 @@ void handle_region_clear_temp_asset_data(void*); BOOL sitting_on_selection(); void near_sit_object(); -void label_sit_or_stand(std::string& label, void*); +//void label_sit_or_stand(std::string& label, void*); // buy and take alias into the same UI positions, so these // declarations handle this mess. BOOL is_selection_buy_not_take(); S32 selection_price(); BOOL enable_take(); void handle_take(); -bool confirm_take(const LLSD& notification, const LLSD& response); -BOOL enable_buy(void*); -void handle_buy(void *); +bool confirm_take(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle selection_handle); + void handle_buy_object(LLSaleInfo sale_info); void handle_buy_contents(LLSaleInfo sale_info); -void label_touch(std::string& label, void*); + +bool for_sale_selection(LLSelectNode* nodep); // Land pie menu void near_sit_down_point(BOOL success, void *); // Avatar pie menu -void handle_follow(void *userdata); void handle_talk_to(void *userdata); // Debug menu -void show_permissions_control(void*); -void toggle_build_options(void* user_data); -void reload_ui(void*); + + void handle_agent_stop_moving(void*); void print_packets_lost(void*); void drop_packet(void*); void velocity_interpolate( void* data ); void toggle_wind_audio(void); -void toggle_water_audio(void); void handle_rebake_textures(void*); BOOL check_admin_override(void*); void handle_admin_override_toggle(void*); @@ -407,14 +403,6 @@ void handle_toggle_hacked_godmode(void*); BOOL check_toggle_hacked_godmode(void*); #endif -void toggle_glow(void *); -BOOL check_glow(void *); - -void toggle_vertex_shaders(void *); -BOOL check_vertex_shaders(void *); - -void toggle_cull_small(void *); - void toggle_show_xui_names(void *); BOOL check_show_xui_names(void *); @@ -568,14 +556,8 @@ void handle_crash(void*); void handle_dump_followcam(void*); void handle_viewer_enable_message_log(void*); void handle_viewer_disable_message_log(void*); -void handle_send_postcard(void*); -void handle_gestures_old(void*); -void handle_focus(void *); + BOOL enable_buy_land(void*); -void handle_move(void*); -void handle_show_inventory(void*); -void handle_activate(void*); -BOOL enable_activate(void*); // Help menu void handle_buy_currency(void*); @@ -687,6 +669,8 @@ void set_underclothes_menu_options() } } +static std::vector > sMenus; + void init_menus() { S32 top = gViewerWindow->getRootView()->getRect().getHeight(); @@ -892,6 +876,7 @@ void init_menus() gMenuHolder->addChild(gLoginMenuBarView); + LLToolMgr::getInstance()->initMenu(sMenus); } @@ -900,8 +885,6 @@ void init_client_menu(LLMenuGL* menu) { LLMenuGL* sub_menu = NULL; - //menu->addChild(new LLMenuItemCallGL("Permissions Control", &show_permissions_control)); - // this is now in the view menu so we don't need it here! { // *TODO: Translate @@ -1544,7 +1527,6 @@ void init_debug_rendering_menu(LLMenuGL* menu) menu->addSeparator(); menu->addChild(new LLMenuItemCheckGL("Axes", menu_toggle_control, NULL, menu_check_control, (void*)"ShowAxes")); - //menu->addChild(new LLMenuItemCheckGL("Cull Small Objects", toggle_cull_small, NULL, menu_check_control, (void*)"RenderCullBySize")); menu->addSeparator(); menu->addChild(new LLMenuItemCheckGL("Hide Selected", menu_toggle_control, NULL, menu_check_control, (void*)"HideSelectedObjects")); @@ -1809,8 +1791,6 @@ void init_server_menu(LLMenuGL* menu) menu->createJumpKeys(); } -static std::vector > sMenus; - //----------------------------------------------------------------------------- // cleanup_menus() //----------------------------------------------------------------------------- @@ -1968,18 +1948,19 @@ class LLObjectEnableTouch : public view_listener_t } }; -void label_touch(std::string& label, void*) -{ - LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); - if (node && node->mValid && !node->mTouchName.empty()) - { - label.assign(node->mTouchName); - } - else - { - label.assign("Touch"); - } -} + +//void label_touch(std::string& label, void*) +//{ +// LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); +// if (node && node->mValid && !node->mTouchName.empty()) +// { +// label.assign(node->mTouchName); +// } +// else +// { +// label.assign("Touch"); +// } +//} bool handle_object_open() { @@ -2028,95 +2009,7 @@ class LLObjectEnableOpen : public view_listener_t }; -class LLViewCheckBuildMode : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - bool new_value = LLToolMgr::getInstance()->inEdit(); - gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); - return true; - } -}; -bool toggle_build_mode() -{ - if (LLToolMgr::getInstance()->inBuildMode()) - { - if (gSavedSettings.getBOOL("EditCameraMovement")) - { - // just reset the view, will pull us out of edit mode - handle_reset_view(); - } - else - { - // manually disable edit mode, but do not affect the camera - gAgentCamera.resetView(false); - gFloaterTools->close(); - gViewerWindow->showCursor(); - } - // avoid spurious avatar movements pulling out of edit mode - LLViewerJoystick::getInstance()->setNeedsReset(); - } - else - { - ECameraMode camMode = gAgentCamera.getCameraMode(); - if (CAMERA_MODE_MOUSELOOK == camMode || CAMERA_MODE_CUSTOMIZE_AVATAR == camMode) - { - // pull the user out of mouselook or appearance mode when entering build mode - handle_reset_view(); - } - - if (gSavedSettings.getBOOL("EditCameraMovement")) - { - // camera should be set - if (LLViewerJoystick::getInstance()->getOverrideCamera()) - { - handle_toggle_flycam(); - } - - if (gAgentCamera.getFocusOnAvatar()) - { - // zoom in if we're looking at the avatar - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - gAgentCamera.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis())); - gAgentCamera.cameraZoomIn(0.666f); - gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); - } - } - -// [RLVa:KB] - Checked: 2009-07-05 (RLVa-1.0.0b) - bool fRlvCanEdit = (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ)); - if (!fRlvCanEdit) - { - LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); - RlvSelectIsEditable f; - if ((hSel.notNull()) && ((hSel->getFirstRootNode(&f, TRUE)) != NULL)) - LLSelectMgr::getInstance()->deselectAll(); - } -// [/RLVa:KB] - - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() ); - - // Could be first use - LLFirstUse::useBuild(); - - gAgentCamera.resetView(false); - - // avoid spurious avatar movements - LLViewerJoystick::getInstance()->setNeedsReset(); - - } - return true; -} - -class LLViewBuildMode : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - return toggle_build_mode(); - } -}; class LLViewJoystickFlycam : public view_listener_t @@ -2517,15 +2410,18 @@ BOOL enable_has_attachments(void*) //--------------------------------------------------------------------------- // Avatar pie menu //--------------------------------------------------------------------------- -void handle_follow(void *userdata) -{ - // follow a given avatar by ID - LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - if (objectp) - { - gAgent.startFollowPilot(objectp->getID()); - } -} +//--------------------------------------------------------------------------- +// Avatar pie menu +//--------------------------------------------------------------------------- +//void handle_follow(void *userdata) +//{ +// // follow a given avatar by ID +// LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); +// if (objectp) +// { +// gAgent.startFollowPilot(objectp->getID()); +// } +//} class LLObjectEnableMute : public view_listener_t { @@ -3415,16 +3311,6 @@ bool callback_leave_group(const LLSD& notification, const LLSD& response) return false; } -void handle_leave_group(void *) -{ - if (gAgent.getGroupID() != LLUUID::null) - { - LLSD args; - args["GROUP"] = gAgent.getGroupName(); - LLNotificationsUtil::add("GroupLeaveConfirmMember", args, LLSD(), callback_leave_group); - } -} - void append_aggregate(std::string& string, const LLAggregatePermissions& ag_perm, PermissionBit bit, const char* txt) { LLAggregatePermissions::EValue val = ag_perm.getValue(bit); @@ -3447,32 +3333,35 @@ void append_aggregate(std::string& string, const LLAggregatePermissions& ag_perm string.append(buffer); } -BOOL enable_buy(void*) +bool enable_buy_object() { // In order to buy, there must only be 1 purchaseable object in // the selection manger. - if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != 1) return FALSE; + if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != 1) return false; LLViewerObject* obj = NULL; LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); if(node) { obj = node->getObject(); - if(!obj) return FALSE; + if(!obj) return false; - if(node->mSaleInfo.isForSale() && node->mPermissions->getMaskOwner() & PERM_TRANSFER && - (node->mPermissions->getMaskOwner() & PERM_COPY || node->mSaleInfo.getSaleType() != LLSaleInfo::FS_COPY)) + if( for_sale_selection(node) ) { - if(obj->permAnyOwner()) return TRUE; + // *NOTE: Is this needed? This checks to see if anyone owns the + // object, dating back to when we had "public" objects owned by + // no one. JC + if(obj->permAnyOwner()) return true; } } - return FALSE; + return false; } + class LLObjectEnableBuy : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - bool new_value = enable_buy(NULL); + bool new_value = enable_buy_object(); gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); return true; } @@ -4108,15 +3997,6 @@ class LLLandSit : public view_listener_t } }; -void show_permissions_control(void*) -{ - LLFloaterPermissionsMgr* floaterp = LLFloaterPermissionsMgr::show(); - floaterp->mPermissions->addPermissionsData("foo1", LLUUID::null, 0); - floaterp->mPermissions->addPermissionsData("foo2", LLUUID::null, 0); - floaterp->mPermissions->addPermissionsData("foo3", LLUUID::null, 0); -} - - class LLCreateLandmarkCallback : public LLInventoryCallback { public: @@ -4127,11 +4007,6 @@ public: } }; -void reload_ui(void *) -{ - LLUICtrlFactory::getInstance()->rebuild(); -} - class LLWorldFly : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -4278,7 +4153,9 @@ void reset_view_final( BOOL proceed ) return; } + gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); gAgentCamera.resetView(TRUE, TRUE); + gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR); } class LLViewLookAtLastChatter : public view_listener_t @@ -4994,7 +4871,7 @@ void handle_take() LLNotification::Params params("ConfirmObjectTakeLock"); params.payload(payload) - .functor(confirm_take); + .functor(boost::bind(&confirm_take, _1, _2, LLSelectMgr::instance().getSelection())); if(locked_but_takeable_object || !you_own_everything) @@ -5021,7 +4898,7 @@ void handle_take() } } -bool confirm_take(const LLSD& notification, const LLSD& response) +bool confirm_take(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle selection_handle) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if(enable_take() && (option == 0)) @@ -5091,7 +4968,7 @@ class LLToolsBuyOrTake : public view_listener_t if (total_price <= gStatusBar->getBalance() || total_price == 0) { - handle_buy(NULL); + handle_buy(); } else { @@ -5112,7 +4989,7 @@ class LLToolsEnableBuyOrTake : public view_listener_t bool handleEvent(LLPointer event, const LLSD& userdata) { bool is_buy = is_selection_buy_not_take(); - bool new_value = is_buy ? enable_buy(NULL) : enable_take(); + bool new_value = is_buy ? enable_buy_object() : enable_take(); gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); // Update label @@ -5230,7 +5107,7 @@ void handle_buy_currency(void*) // LLFloaterBuyCurrency::buyCurrency(); } -void handle_buy(void*) +void handle_buy() { if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) return; @@ -5252,11 +5129,26 @@ class LLObjectBuy : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - handle_buy(NULL); + handle_buy(); return true; } }; +bool anyone_copy_selection(LLSelectNode* nodep) +{ + bool perm_copy = (bool)(nodep->getObject()->permCopy()); + bool all_copy = (bool)(nodep->mPermissions->getMaskEveryone() & PERM_COPY); + return perm_copy && all_copy; +} + +bool for_sale_selection(LLSelectNode* nodep) +{ + return nodep->mSaleInfo.isForSale() + && nodep->mPermissions->getMaskOwner() & PERM_TRANSFER + && (nodep->mPermissions->getMaskOwner() & PERM_COPY + || nodep->mSaleInfo.getSaleType() != LLSaleInfo::FS_COPY); +} + BOOL sitting_on_selection() { LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); @@ -6843,33 +6735,6 @@ class LLShowAgentGroups : public view_listener_t return true; } }; - -void handle_focus(void *) -{ - if (gDisconnected) - { - return; - } - - if (gAgentCamera.getFocusOnAvatar()) - { - // zoom in if we're looking at the avatar - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); - gAgentCamera.cameraZoomIn(0.666f); - } - else - { - gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); - } - - gViewerWindow->moveCursorToCenter(); - - // Switch to camera toolset -// LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); - LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCamera::getInstance() ); -} - class LLLandEdit : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -6928,26 +6793,6 @@ BOOL enable_buy_land(void*) } -void handle_move(void*) -{ - if (gAgentCamera.getFocusOnAvatar()) - { - // zoom in if we're looking at the avatar - gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); - gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); - - gAgentCamera.cameraZoomIn(0.666f); - } - else - { - gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); - } - - gViewerWindow->moveCursorToCenter(); - - LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); - LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() ); -} class LLObjectAttachToAvatar : public view_listener_t { @@ -7558,16 +7403,6 @@ class LLAvatarSendIM : public view_listener_t } }; - -void handle_activate(void*) -{ -} - -BOOL enable_activate(void*) -{ - return FALSE; -} - namespace { struct QueueObjects : public LLSelectedObjectFunctor @@ -8302,19 +8137,6 @@ BOOL enable_god_basic(void*) //return gAgent.getGodLevel() > GOD_NOT; } -#if 0 // 1.9.2 -void toggle_vertex_shaders(void *) -{ - BOOL use_shaders = gPipeline.getUseVertexShaders(); - gPipeline.setUseVertexShaders(use_shaders); -} - -BOOL check_vertex_shaders(void *) -{ - return gPipeline.getUseVertexShaders(); -} -#endif - void toggle_show_xui_names(void *) { BOOL showXUINames = gSavedSettings.getBOOL("ShowXUINames"); @@ -8328,15 +8150,6 @@ BOOL check_show_xui_names(void *) return gSavedSettings.getBOOL("ShowXUINames"); } - - -void toggle_cull_small(void *) -{ -// gPipeline.mCullBySize = !gPipeline.mCullBySize; -// -// gSavedSettings.setBOOL("RenderCullBySize", gPipeline.mCullBySize); -} - class LLToolsSelectOnlyMyObjects : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -9424,7 +9237,7 @@ class LLWorldDayCycle : public view_listener_t } }; -static void addMenu(view_listener_t *menu, const std::string& name) +void addMenu(view_listener_t *menu, const std::string& name) { sMenus.push_back(menu); menu->registerListener(gMenuHolder, name); @@ -9494,7 +9307,6 @@ void initialize_menus() // View menu addMenu(new LLViewMouselook(), "View.Mouselook"); - addMenu(new LLViewBuildMode(), "View.BuildMode"); addMenu(new LLViewJoystickFlycam(), "View.JoystickFlycam"); addMenu(new LLViewCommunicate(), "View.Communicate"); addMenu(new LLViewResetView(), "View.ResetView"); @@ -9514,7 +9326,6 @@ void initialize_menus() addMenu(new LLViewEnableLastChatter(), "View.EnableLastChatter"); addMenu(new LLViewToggleRadar(), "View.ToggleAvatarList"); - addMenu(new LLViewCheckBuildMode(), "View.CheckBuildMode"); addMenu(new LLViewCheckJoystickFlycam(), "View.CheckJoystickFlycam"); addMenu(new LLViewCheckShowHoverTips(), "View.CheckShowHoverTips"); addMenu(new LLViewCheckHighlightTransparent(), "View.CheckHighlightTransparent"); diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index 6d98b6c10..5f9c37dd9 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -39,7 +39,7 @@ class LLUICtrl; class LLView; class LLParcelSelection; class LLObjectSelection; - +class LLSelectNode; void pre_init_menus(); void init_menus(); @@ -97,8 +97,17 @@ void exchange_callingcard(const LLUUID& dest_id); void handle_gestures(void*); void handle_sit_down(void*); -bool toggle_build_mode(); void handle_object_build(void*); + +void handle_buy(); +// Can anyone take a free copy of the object? +// *TODO: Move to separate file +bool anyone_copy_selection(LLSelectNode* nodep); + +// Is this selected object for sale? +// *TODO: Move to separate file +bool for_sale_selection(LLSelectNode* nodep); + void handle_save_snapshot(void *); void handle_toggle_flycam(); void handle_fake_away_status(void*); @@ -106,6 +115,7 @@ void handle_fake_away_status(void*); bool handle_sit_or_stand(); bool handle_give_money_dialog(); bool handle_object_open(); +bool enable_buy_object(); bool handle_go_to(); // Export to XML or Collada