diff options
Diffstat (limited to 'indra/newview/llfloatercamera.cpp')
-rw-r--r-- | indra/newview/llfloatercamera.cpp | 92 |
1 files changed, 60 insertions, 32 deletions
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 764aff68c9..d0188352c7 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -65,7 +65,7 @@ public: LLPanelCameraZoom(); /* virtual */ BOOL postBuild(); - /* virtual */ void onOpen(const LLSD& key); + /* virtual */ void draw(); protected: void onZoomPlusHeldDown(); @@ -73,7 +73,6 @@ protected: void onSliderValueChanged(); private: - F32 mSavedSliderVal; LLButton* mPlusBtn; LLButton* mMinusBtn; LLSlider* mSlider; @@ -88,8 +87,7 @@ static LLRegisterPanelClassWrapper<LLPanelCameraZoom> t_camera_zoom_panel("camer LLPanelCameraZoom::LLPanelCameraZoom() : mPlusBtn( NULL ), mMinusBtn( NULL ), - mSlider( NULL ), - mSavedSliderVal(0.f) + mSlider( NULL ) { mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this)); mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this)); @@ -101,16 +99,13 @@ BOOL LLPanelCameraZoom::postBuild() mPlusBtn = getChild <LLButton> ("zoom_plus_btn"); mMinusBtn = getChild <LLButton> ("zoom_minus_btn"); mSlider = getChild <LLSlider> ("zoom_slider"); - mSlider->setMinValue(.0f); - mSlider->setMaxValue(8.f); return LLPanel::postBuild(); } -void LLPanelCameraZoom::onOpen(const LLSD& key) +void LLPanelCameraZoom::draw() { - LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - gAgent.calcFocusPositionTargetGlobal(); - mSavedSliderVal = 8.f - (F32)to_focus.magVec(); // maximum minus current - mSlider->setValue( mSavedSliderVal ); + mSlider->setValue(gAgent.getCameraZoomFraction()); + LLPanel::draw(); } void LLPanelCameraZoom::onZoomPlusHeldDown() @@ -135,15 +130,15 @@ void LLPanelCameraZoom::onZoomMinusHeldDown() void LLPanelCameraZoom::onSliderValueChanged() { - F32 val = mSlider->getValueF32(); - F32 rate = val - mSavedSliderVal; - - gAgent.unlockView(); - gAgent.cameraOrbitIn(rate); - - mSavedSliderVal = val; + F32 zoom_level = mSlider->getValueF32(); + gAgent.setCameraZoomFraction(zoom_level); } +void activate_camera_tool() +{ + LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); +}; + // // Member functions // @@ -151,7 +146,7 @@ void LLPanelCameraZoom::onSliderValueChanged() /*static*/ bool LLFloaterCamera::inFreeCameraMode() { LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA) + if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK) { return true; } @@ -177,27 +172,17 @@ void LLFloaterCamera::update() } -/*static*/ void LLFloaterCamera::updateIfNotInAvatarViewMode() -{ - LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (floater_camera && !floater_camera->inAvatarViewMode()) - { - floater_camera->update(); - } -} - - void LLFloaterCamera::toPrevMode() { switchMode(mPrevMode); } -/*static*/ void LLFloaterCamera::toPrevModeIfInAvatarViewMode() +/*static*/ void LLFloaterCamera::onLeavingMouseLook() { LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance(); - if (floater_camera && floater_camera->inAvatarViewMode()) + if (floater_camera && floater_camera->inFreeCameraMode()) { - floater_camera->toPrevMode(); + activate_camera_tool(); } } @@ -256,6 +241,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) BOOL LLFloaterCamera::postBuild() { setIsChrome(TRUE); + setTitleVisible(TRUE); // restore title visibility after chrome applying mRotate = getChild<LLJoystickCameraRotate>(ORBIT); mZoom = getChild<LLPanelCameraZoom>(ZOOM); @@ -310,6 +296,31 @@ void LLFloaterCamera::setMode(ECameraControlMode mode) updateState(); } +void LLFloaterCamera::setModeTitle(const ECameraControlMode mode) +{ + std::string title; + switch(mode) + { + case CAMERA_CTRL_MODE_ORBIT: + title = getString("orbit_mode_title"); + break; + case CAMERA_CTRL_MODE_PAN: + title = getString("pan_mode_title"); + break; + case CAMERA_CTRL_MODE_AVATAR_VIEW: + title = getString("avatar_view_mode_title"); + break; + case CAMERA_CTRL_MODE_FREE_CAMERA: + title = getString("free_mode_title"); + break; + default: + // title should be provided for all modes + llassert(false); + break; + } + setTitle(title); +} + void LLFloaterCamera::switchMode(ECameraControlMode mode) { setMode(mode); @@ -325,7 +336,7 @@ void LLFloaterCamera::switchMode(ECameraControlMode mode) break; case CAMERA_CTRL_MODE_FREE_CAMERA: - LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); + activate_camera_tool(); break; case CAMERA_CTRL_MODE_AVATAR_VIEW: @@ -369,6 +380,10 @@ void LLFloaterCamera::updateState() childSetVisible(ZOOM, CAMERA_CTRL_MODE_AVATAR_VIEW != mCurrMode); childSetVisible(PRESETS, CAMERA_CTRL_MODE_AVATAR_VIEW == mCurrMode); + updateCameraPresetButtons(); + setModeTitle(mCurrMode); + + //hiding or showing the panel with controls by reshaping the floater bool showControls = CAMERA_CTRL_MODE_FREE_CAMERA != mCurrMode; if (showControls == childIsVisible(CONTROLS)) return; @@ -399,6 +414,16 @@ void LLFloaterCamera::updateState() } } +void LLFloaterCamera::updateCameraPresetButtons() +{ + ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset"); + + childSetValue("rear_view", preset == CAMERA_PRESET_REAR_VIEW); + childSetValue("group_view", preset == CAMERA_PRESET_GROUP_VIEW); + childSetValue("front_view", preset == CAMERA_PRESET_FRONT_VIEW); + childSetValue("mouselook_view", gAgent.cameraMouselook()); +} + void LLFloaterCamera::onClickCameraPresets(const LLSD& param) { std::string name = param.asString(); @@ -420,4 +445,7 @@ void LLFloaterCamera::onClickCameraPresets(const LLSD& param) gAgent.changeCameraToMouselook(); } + LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance(); + if (camera_floater) + camera_floater->updateCameraPresetButtons(); } |