diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llkeyconflict.cpp | 60 | ||||
-rw-r--r-- | indra/newview/llkeyconflict.h | 10 | ||||
-rw-r--r-- | indra/newview/lltool.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lltoolpie.cpp | 226 | ||||
-rw-r--r-- | indra/newview/lltoolpie.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewerkeyboard.cpp | 114 | ||||
-rw-r--r-- | indra/newview/llviewerkeyboard.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 1 |
9 files changed, 213 insertions, 214 deletions
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index d7a8f9fd4f..0af6249351 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -167,7 +167,7 @@ static const U32 ALLOW_KEYS = 4; //keyboard static const U32 ALLOW_MASK_KEYS = 8; static const U32 ALLOW_MASKS = 16; static const U32 CAN_IGNORE_MASKS = 32; // For example W (aka Forward) should work regardless of SHIFT being pressed -static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS; +static const U32 DEFAULT_KEY_FILTER = ALLOW_MOUSE | ALLOW_MASK_MOUSE | ALLOW_KEYS | ALLOW_MASK_KEYS | CAN_IGNORE_MASKS; class LLSetKeyBindDialog : public LLModalDialog { @@ -2919,6 +2919,10 @@ LLPanelPreferenceControls::LLPanelPreferenceControls() mEditingMode(0), mShowKeyDialog(false) { + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + mConflictHandler[i].setLoadMode((LLKeyConflictHandler::EModes)i); + } } LLPanelPreferenceControls::~LLPanelPreferenceControls() @@ -3243,7 +3247,10 @@ void LLPanelPreferenceControls::onSetKeyBind(EMouseClickType click, KEY key, MAS void LLPanelPreferenceControls::onRestoreDefaults() { - mConflictHandler[mEditingMode].resetToDefaults(); + for (U32 i = 0; i < LLKeyConflictHandler::MODE_COUNT; ++i) + { + mConflictHandler[mEditingMode].resetToDefaults(); + } populateControlTable(); } diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index be0b8fd4ca..87ea408a6a 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -57,8 +57,8 @@ static const std::string typetostring[LLKeyConflictHandler::CONTROL_NUM_INDICES] "control_touch", "control_wear", "control_movements", - "control_moveto", - "control_teleportto", + "walk_to", + "teleport_to", "push_forward", "push_backward", "turn_left", @@ -164,7 +164,9 @@ static const control_enum_t command_to_key = { "toggle_run", LLKeyConflictHandler::CONTROL_TOGGLE_RUN }, { "toggle_sit", LLKeyConflictHandler::CONTROL_SIT }, { "toggle_parcel_media", LLKeyConflictHandler::CONTROL_PAUSE_MEDIA }, - { "toggle_enable_media", LLKeyConflictHandler::CONTROL_ENABLE_MEDIA }, + { "toggle_enable_media", LLKeyConflictHandler::CONTROL_ENABLE_MEDIA }, + { "walk_to", LLKeyConflictHandler::CONTROL_MOVETO }, + { "teleport_to", LLKeyConflictHandler::CONTROL_TELEPORTTO }, }; @@ -268,7 +270,7 @@ LLKeyConflictHandler::LLKeyConflictHandler() LLKeyConflictHandler::LLKeyConflictHandler(EModes mode) : mHasUnsavedChanges(false), - mLoadedMode(mode) + mLoadMode(mode) { loadFromSettings(mode); } @@ -497,7 +499,7 @@ void LLKeyConflictHandler::loadFromSettings(EModes load_mode) mControlsMap.insert(mDefaultsMap.begin(), mDefaultsMap.end()); } } - mLoadedMode = load_mode; + mLoadMode = load_mode; } void LLKeyConflictHandler::saveToSettings() @@ -507,7 +509,7 @@ void LLKeyConflictHandler::saveToSettings() return; } - if (mLoadedMode == MODE_GENERAL) + if (mLoadMode == MODE_GENERAL) { for (U32 i = 0; i < CONTROL_NUM_INDICES; i++) { @@ -591,7 +593,7 @@ void LLKeyConflictHandler::saveToSettings() } } - switch (mLoadedMode) + switch (mLoadMode) { case MODE_FIRST_PERSON: if (keys.first_person.isProvided()) @@ -657,7 +659,7 @@ void LLKeyConflictHandler::saveToSettings() LLKeyData LLKeyConflictHandler::getDefaultControl(EControlTypes control_type, U32 index) { - if (mLoadedMode == MODE_GENERAL) + if (mLoadMode == MODE_GENERAL) { std::string name = getControlName(control_type); LLControlVariablePtr var = gSavedSettings.getControl(name); @@ -686,7 +688,7 @@ void LLKeyConflictHandler::resetToDefault(EControlTypes control_type, U32 index) void LLKeyConflictHandler::resetToDefault(EControlTypes control_type) { - if (mLoadedMode == MODE_GENERAL) + if (mLoadMode == MODE_GENERAL) { std::string name = getControlName(control_type); LLControlVariablePtr var = gSavedSettings.getControl(name); @@ -753,40 +755,18 @@ void LLKeyConflictHandler::resetToDefaults() { if (!empty()) { - resetToDefaults(mLoadedMode); + resetToDefaults(mLoadMode); } -} - -void LLKeyConflictHandler::resetAllToDefaults() -{ - std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "keys.xml"); - if (gDirUtilp->fileExists(filename)) + else { - LLFile::remove(filename); - std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "keys.xml"); - gViewerKeyboard.loadBindingsXML(filename); + // not optimal since: + // 1. We are not sure that mLoadMode was set + // 2. We are not sure if there are any changes in comparison to default + // 3. We are loading 'current' only to replace it + // but it is reliable and works Todo: consider optimizing. + loadFromSettings(mLoadMode); + resetToDefaults(mLoadMode); } - - for (U32 i = 0; i < CONTROL_NUM_INDICES; i++) - { - EControlTypes type = (EControlTypes)i; - switch (type) - { - case LLKeyConflictHandler::CONTROL_VIEW_ACTIONS: - case LLKeyConflictHandler::CONTROL_INTERACTIONS: - case LLKeyConflictHandler::CONTROL_MOVEMENTS: - case LLKeyConflictHandler::CONTROL_MEDIACONTENT: - case LLKeyConflictHandler::CONTROL_RESERVED: - // ignore 'headers', they are for representation and organization purposes - break; - default: - { - resetToDefault(type); - break; - } - } - } - mHasUnsavedChanges = false; } void LLKeyConflictHandler::clear() diff --git a/indra/newview/llkeyconflict.h b/indra/newview/llkeyconflict.h index 7890be1e28..b0f99e2d0c 100644 --- a/indra/newview/llkeyconflict.h +++ b/indra/newview/llkeyconflict.h @@ -183,18 +183,20 @@ public: // Resets keybinding to default variant from 'saved settings' or xml void resetToDefault(EControlTypes control_type, U32 index); void resetToDefault(EControlTypes control_type); - void resetToDefaults(EModes mode); + // resets current mode to defaults, void resetToDefaults(); - void resetAllToDefaults(); bool empty() { return mControlsMap.empty(); } void clear(); bool hasUnsavedChanges() { return mHasUnsavedChanges; } - EModes getLoadedMode() { return mLoadedMode; } + void setLoadMode(EModes mode) { mLoadMode = mode; } + EModes getLoadMode() { return mLoadMode; } // todo: conflict search private: + void resetToDefaults(EModes mode); + // at the moment these kind of control is not savable, but takes part will take part in conflict resolution void registerTemporaryControl(EControlTypes control_type, EMouseClickType mouse_ind, KEY key, MASK mask, U32 conflict_mask); @@ -207,7 +209,7 @@ private: control_map_t mControlsMap; control_map_t mDefaultsMap; bool mHasUnsavedChanges; - EModes mLoadedMode; + EModes mLoadMode; }; diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp index 0038138078..e2ab450d8c 100644 --- a/indra/newview/lltool.cpp +++ b/indra/newview/lltool.cpp @@ -85,7 +85,7 @@ BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask) // by default, didn't handle it // LL_INFOS() << "LLTool::handleMouseDown" << LL_ENDL; gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN); - return TRUE; + return FALSE; } BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask) diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 3879acefa6..35b4306e1d 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -83,7 +83,6 @@ LLToolPie::LLToolPie() mMouseOutsideSlop( false ), mMouseSteerX(-1), mMouseSteerY(-1), - mBlockClickToWalk(false), mClickAction(0), mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ), mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") ), @@ -172,10 +171,8 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mPick.mKeyMask = mask; mMouseButtonDown = true; - - handleLeftClickPick(); - return TRUE; + return handleLeftClickPick(); } // Spawn context menus on right mouse down so you can drag over and select @@ -374,8 +371,6 @@ BOOL LLToolPie::handleLeftClickPick() // put focus back "in world" if (gFocusMgr.getKeyboardFocus()) { - // don't click to walk on attempt to give focus to world - mBlockClickToWalk = true; gFocusMgr.setKeyboardFocus(NULL); } @@ -419,7 +414,7 @@ BOOL LLToolPie::handleLeftClickPick() } object = (LLViewerObject*)object->getParent(); } - if (object && object == gAgentAvatarp && !gSavedSettings.getBOOL("ClickToWalk")) + if (object && object == gAgentAvatarp) { // we left clicked on avatar, switch to focus mode mMouseButtonDown = false; @@ -436,7 +431,6 @@ BOOL LLToolPie::handleLeftClickPick() // LLFirstUse::useLeftClickNoHit(); ///////// - // Eat the event return LLTool::handleMouseDown(x, y, mask); } @@ -545,15 +539,90 @@ void LLToolPie::resetSelection() void LLToolPie::walkToClickedLocation() { - if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); } - mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); - mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); - mAutoPilotDestination->setPixelSize(5); - mAutoPilotDestination->setColor(LLColor4U(170, 210, 190)); - mAutoPilotDestination->setDuration(3.f); - - LLVector3d pos = LLToolPie::getInstance()->getPick().mPosGlobal; - gAgent.startAutoPilotGlobal(pos, std::string(), NULL, NULL, NULL, 0.f, 0.03f, FALSE); + if (gAgent.getFlying() // don't auto-navigate while flying until that works + || !gAgentAvatarp + || gAgentAvatarp->isSitting()) + { + return; + } + + LLPickInfo saved_pick = mPick; + mPick = gViewerWindow->pickImmediate(mHoverPick.mMousePt.mX, mHoverPick.mMousePt.mY, + FALSE /* ignore transparent */, + FALSE /* ignore rigged */, + FALSE /* ignore particles */); + + if (mPick.mPickType == LLPickInfo::PICK_OBJECT) + { + if (mPick.getObject() && mPick.getObject()->isHUDAttachment()) + { + mPick = saved_pick; + return; + } + } + + LLViewerObject* avatar_object = mPick.getObject(); + + // get pointer to avatar + while (avatar_object && !avatar_object->isAvatar()) + { + avatar_object = (LLViewerObject*)avatar_object->getParent(); + } + + if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) + { + const F64 SELF_CLICK_WALK_DISTANCE = 3.0; + // pretend we picked some point a bit in front of avatar + mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; + } + + gAgentCamera.setFocusOnAvatar(TRUE, TRUE); + + if ((mPick.mPickType == LLPickInfo::PICK_LAND && !mPick.mPosGlobal.isExactlyZero()) || + (mPick.mObjectID.notNull() && !mPick.mPosGlobal.isExactlyZero())) + { + if (mAutoPilotDestination) { mAutoPilotDestination->markDead(); } + mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE); + mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal); + mAutoPilotDestination->setPixelSize(5); + mAutoPilotDestination->setColor(LLColor4U(170, 210, 190)); + mAutoPilotDestination->setDuration(3.f); + + LLVector3d pos = LLToolPie::getInstance()->getPick().mPosGlobal; + gAgent.startAutoPilotGlobal(pos, std::string(), NULL, NULL, NULL, 0.f, 0.03f, FALSE); + LLFirstUse::notMoving(false); + showVisualContextMenuEffect(); + } + else + { + LL_DEBUGS() << "walk target was " + << (mPick.mPosGlobal.isExactlyZero() ? "zero" : "not zero") + << ", pick type was " << (mPick.mPickType == LLPickInfo::PICK_LAND ? "land" : "not land") + << ", pick object was " << mPick.mObjectID + << LL_ENDL; + mPick = saved_pick; + } +} + +void LLToolPie::teleportToClickedLocation() +{ + LLViewerObject* objp = mHoverPick.getObject(); + LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL; + + bool is_in_world = mHoverPick.mObjectID.notNull() && objp && !objp->isHUDAttachment(); + bool is_land = mHoverPick.mPickType == LLPickInfo::PICK_LAND; + bool pos_non_zero = !mHoverPick.mPosGlobal.isExactlyZero(); + bool has_touch_handler = (objp && objp->flagHandleTouch()) || (parentp && parentp->flagHandleTouch()); + bool has_click_action = final_click_action(objp); + + if (pos_non_zero && (is_land || (is_in_world && !has_touch_handler && !has_click_action))) + { + LLVector3d pos = mHoverPick.mPosGlobal; + pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot(); + gAgent.teleportViaLocationLookAt(pos); + } + mPick = mHoverPick; + showVisualContextMenuEffect(); } // When we get object properties after left-clicking on an object @@ -629,8 +698,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask) LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL; } else if (!mMouseOutsideSlop - && mMouseButtonDown - && gSavedSettings.getBOOL("ClickToWalk")) + && mMouseButtonDown) { S32 delta_x = x - mMouseDownX; S32 delta_y = y - mMouseDownY; @@ -715,70 +783,10 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) mDoubleClickTimer.reset(); } LLViewerObject* obj = mPick.getObject(); - U8 click_action = final_click_action(obj); - // let media have first pass at click - if (handleMediaMouseUp() || LLViewerMediaFocus::getInstance()->getFocus()) - { - mBlockClickToWalk = true; - } stopCameraSteering(); mMouseButtonDown = false; - if (click_action == CLICK_ACTION_NONE // not doing 1-click action - && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled - && !gAgent.getFlying() // don't auto-navigate while flying until that works - && gAgentAvatarp - && !gAgentAvatarp->isSitting() - && !mBlockClickToWalk // another behavior hasn't cancelled click to walk - ) - { - // We may be doing click to walk, but we don't want to use a target on - // a transparent object because the user thought they were clicking on - // whatever they were seeing through it, so recompute what was clicked on - // ignoring transparent objects - LLPickInfo savedPick = mPick; - mPick = gViewerWindow->pickImmediate(savedPick.mMousePt.mX, savedPick.mMousePt.mY, - FALSE /* ignore transparent */, - FALSE /* ignore rigged */, - FALSE /* ignore particles */); - - if (!mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick - && (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land - || mPick.mObjectID.notNull())) // or on an object - { - // handle special cases of steering picks - LLViewerObject* avatar_object = mPick.getObject(); - - // get pointer to avatar - while (avatar_object && !avatar_object->isAvatar()) - { - avatar_object = (LLViewerObject*)avatar_object->getParent(); - } - - if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf()) - { - const F64 SELF_CLICK_WALK_DISTANCE = 3.0; - // pretend we picked some point a bit in front of avatar - mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE; - } - gAgentCamera.setFocusOnAvatar(TRUE, TRUE); - walkToClickedLocation(); - LLFirstUse::notMoving(false); - - return TRUE; - } - else - { - LL_DEBUGS("maint5901") << "walk target was " - << (mPick.mPosGlobal.isExactlyZero() ? "zero" : "not zero") - << ", pick type was " << (mPick.mPickType == LLPickInfo::PICK_LAND ? "land" : "not land") - << ", pick object was " << mPick.mObjectID - << LL_ENDL; - // we didn't click to walk, so restore the original target - mPick = savedPick; - } - } gViewerWindow->setCursor(UI_CURSOR_ARROW); if (hasMouseCapture()) { @@ -788,7 +796,6 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) LLToolMgr::getInstance()->clearTransientTool(); gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on - mBlockClickToWalk = false; return LLTool::handleMouseUp(x, y, mask); } @@ -814,66 +821,13 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask) return TRUE; } - if (!mDoubleClickTimer.getStarted() || (mDoubleClickTimer.getElapsedTimeF32() > 0.3f)) + if (!mDoubleClickTimer.getStarted() || (mDoubleClickTimer.getElapsedTimeF32() > 0.3f)) { mDoubleClickTimer.stop(); return FALSE; } mDoubleClickTimer.stop(); - if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) - { - // We may be doing double click to walk, but we don't want to use a target on - // a transparent object because the user thought they were clicking on - // whatever they were seeing through it, so recompute what was clicked on - // ignoring transparent objects - LLPickInfo savedPick = mPick; - mPick = gViewerWindow->pickImmediate(savedPick.mMousePt.mX, savedPick.mMousePt.mY, - FALSE /* ignore transparent */, - FALSE /* ignore rigged */, - FALSE /* ignore particles */); - - if(mPick.mPickType == LLPickInfo::PICK_OBJECT) - { - if (mPick.getObject() && mPick.getObject()->isHUDAttachment()) - { - mPick = savedPick; - return FALSE; - } - } - - if ((mPick.mPickType == LLPickInfo::PICK_LAND && !mPick.mPosGlobal.isExactlyZero()) || - (mPick.mObjectID.notNull() && !mPick.mPosGlobal.isExactlyZero())) - { - walkToClickedLocation(); - return TRUE; - } - else - { - // restore the original pick for any other purpose - mPick = savedPick; - } - } - else if (gSavedSettings.getBOOL("DoubleClickTeleport")) - { - LLViewerObject* objp = mPick.getObject(); - LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL; - - bool is_in_world = mPick.mObjectID.notNull() && objp && !objp->isHUDAttachment(); - bool is_land = mPick.mPickType == LLPickInfo::PICK_LAND; - bool pos_non_zero = !mPick.mPosGlobal.isExactlyZero(); - bool has_touch_handler = (objp && objp->flagHandleTouch()) || (parentp && parentp->flagHandleTouch()); - bool has_click_action = final_click_action(objp); - - if (pos_non_zero && (is_land || (is_in_world && !has_touch_handler && !has_click_action))) - { - LLVector3d pos = mPick.mPosGlobal; - pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot(); - gAgent.teleportViaLocationLookAt(pos); - return TRUE; - } - } - return FALSE; } @@ -1405,7 +1359,6 @@ void LLToolPie::VisitHomePage(const LLPickInfo& info) void LLToolPie::handleSelect() { // tool is reselected when app gets focus, etc. - mBlockClickToWalk = true; } void LLToolPie::handleDeselect() @@ -1466,7 +1419,7 @@ void LLToolPie::stopCameraSteering() bool LLToolPie::inCameraSteerMode() { - return mMouseButtonDown && mMouseOutsideSlop && gSavedSettings.getBOOL("ClickToWalk"); + return mMouseButtonDown && mMouseOutsideSlop; } // true if x,y outside small box around start_x,start_y @@ -1917,7 +1870,6 @@ void LLToolPie::startCameraSteering() { LLFirstUse::notMoving(false); mMouseOutsideSlop = true; - mBlockClickToWalk = true; if (gAgentCamera.getFocusOnAvatar()) { diff --git a/indra/newview/lltoolpie.h b/indra/newview/lltoolpie.h index 6d0e25eaeb..c1c8718f7d 100644 --- a/indra/newview/lltoolpie.h +++ b/indra/newview/lltoolpie.h @@ -68,7 +68,7 @@ public: LLObjectSelection* getLeftClickSelection() { return (LLObjectSelection*)mLeftClickSelection; } void resetSelection(); void walkToClickedLocation(); - void blockClickToWalk() { mBlockClickToWalk = true; } + void teleportToClickedLocation(); void stopClickToWalk(); static void selectionPropertiesReceived(); diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index fb1f33c6b0..abc7346616 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -38,6 +38,7 @@ #include "llmorphview.h" #include "llmoveview.h" #include "lltoolfocus.h" +#include "lltoolpie.h" #include "llviewerwindow.h" #include "llvoavatarself.h" #include "llfloatercamera.h" @@ -567,7 +568,7 @@ void edit_avatar_move_backward( EKeystate s ) void stop_moving( EKeystate s ) { - if( KEYSTATE_UP == s ) return; + if( KEYSTATE_DOWN != s ) return; // stop agent gAgent.setControlFlags(AGENT_CONTROL_STOP); @@ -581,7 +582,8 @@ void start_chat( EKeystate s ) { return; // can't talk, gotta go, kthxbye! } - + if (KEYSTATE_DOWN != s) return; + // start chat LLFloaterIMNearbyChat::startChat(NULL); } @@ -649,6 +651,19 @@ void toggle_enable_media(EKeystate s) LLViewerMedia::setAllMediaEnabled(!pause); } +void walk_to(EKeystate s) +{ + LL_WARNS() << "processing " << LLSD(s).asString() << LL_ENDL; + if (KEYSTATE_DOWN != s) return; + LLToolPie::getInstance()->walkToClickedLocation(); +} + +void teleport_to(EKeystate s) +{ + if (KEYSTATE_DOWN != s) return; + LLToolPie::getInstance()->teleportToClickedLocation(); +} + #define REGISTER_KEYBOARD_ACTION(KEY, ACTION) LLREGISTER_STATIC(LLKeyboardActionRegistry, KEY, ACTION); REGISTER_KEYBOARD_ACTION("jump", agent_jump); REGISTER_KEYBOARD_ACTION("push_down", agent_push_down); @@ -694,6 +709,8 @@ REGISTER_KEYBOARD_ACTION("toggle_run", toggle_run); REGISTER_KEYBOARD_ACTION("toggle_sit", toggle_sit); REGISTER_KEYBOARD_ACTION("toggle_pause_media", toggle_pause_media); REGISTER_KEYBOARD_ACTION("toggle_enable_media", toggle_enable_media); +REGISTER_KEYBOARD_ACTION("teleport_to", teleport_to); +REGISTER_KEYBOARD_ACTION("walk_to", walk_to); #undef REGISTER_KEYBOARD_ACTION LLViewerKeyboard::LLViewerKeyboard() @@ -756,7 +773,7 @@ BOOL LLViewerKeyboard::mouseFromString(const std::string& string, EMouseClickTyp *mode = CLICK_LEFT; return TRUE; } - else if (string == "DLMB") + else if (string == "Double LMB") { *mode = CLICK_DOUBLELEFT; return TRUE; @@ -1045,24 +1062,44 @@ S32 LLViewerKeyboard::loadBindingMode(const LLViewerKeyboard::KeyMode& keymode, it != end_it; ++it) { + bool processed = false; if (!it->key.getValue().empty()) { KEY key; - MASK mask; - bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; LLKeyboard::keyFromString(it->key, &key); - LLKeyboard::maskFromString(it->mask, &mask); - bindKey(mode, key, mask, ignore, it->command); - binding_count++; + if (key != KEY_NONE) + { + MASK mask; + bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; + LLKeyboard::maskFromString(it->mask, &mask); + bindKey(mode, key, mask, ignore, it->command); + processed = true; + } + else + { + LL_WARNS_ONCE() << "There might be issues in keybindings' file" << LL_ENDL; + } } - else if (it->mouse.isProvided() && !it->mouse.getValue().empty()) + if (!processed && it->mouse.isProvided() && !it->mouse.getValue().empty()) { EMouseClickType mouse; - MASK mask; - bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; mouseFromString(it->mouse.getValue(), &mouse); - LLKeyboard::maskFromString(it->mask, &mask); - bindMouse(mode, mouse, mask, ignore, it->command); + if (mouse != CLICK_NONE) + { + MASK mask; + bool ignore = it->ignore.isProvided() ? it->ignore.getValue() : false; + LLKeyboard::maskFromString(it->mask, &mask); + bindMouse(mode, mouse, mask, ignore, it->command); + processed = true; + } + else + { + LL_WARNS_ONCE() << "There might be issues in keybindings' file" << LL_ENDL; + } + } + if (processed) + { + // total binding_count++; } } @@ -1261,28 +1298,41 @@ BOOL LLViewerKeyboard::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK ma if (clicktype != CLICK_NONE) { - // special case - // if UI doesn't handle double click, LMB click is issued, so supres LMB 'down' when doubleclick is set + // Special case + // If UI doesn't handle double click, LMB click is issued, so supres LMB 'down' when doubleclick is set // handle !down as if we are handling doubleclick - bool override_lmb = (clicktype == CLICK_LEFT - && (mMouseLevel[CLICK_DOUBLELEFT] == MOUSE_STATE_DOWN || mMouseLevel[CLICK_DOUBLELEFT] == MOUSE_STATE_LEVEL)); - if (override_lmb && !down) + bool double_click_sp = (clicktype == CLICK_LEFT + && (mMouseLevel[CLICK_DOUBLELEFT] != MOUSE_STATE_SILENT) + && mMouseLevel[CLICK_LEFT] == MOUSE_STATE_SILENT); + if (double_click_sp && !down) { - // process doubleclick instead + // Process doubleclick instead clicktype = CLICK_DOUBLELEFT; } - if (override_lmb && down) + + if (double_click_sp && down) { - // else-supress + // Consume click. + // Due to handling, double click that is not handled will be immediately followed by LMB click } - // if UI handled 'down', it should handle 'up' as well - // if we handle 'down' not by UI, then we should handle 'up'/'level' regardless of UI - else if (handled && mMouseLevel[clicktype] != MOUSE_STATE_SILENT) + // If UI handled 'down', it should handle 'up' as well + // If we handle 'down' not by UI, then we should handle 'up'/'level' regardless of UI + else if (handled) { // UI handled new 'down' so iterupt whatever state we were in. - mMouseLevel[clicktype] = MOUSE_STATE_UP; + if (mMouseLevel[clicktype] != MOUSE_STATE_SILENT) + { + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + mMouseLevel[clicktype] = MOUSE_STATE_CLICK; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_UP; + } + } } else if (down) { @@ -1297,10 +1347,17 @@ BOOL LLViewerKeyboard::handleMouse(LLWindow *window_impl, LLCoordGL pos, MASK ma mMouseLevel[clicktype] = MOUSE_STATE_DOWN; } } - else + else if (mMouseLevel[clicktype] != MOUSE_STATE_SILENT) { // Released mouse key - mMouseLevel[clicktype] = MOUSE_STATE_UP; + if (mMouseLevel[clicktype] == MOUSE_STATE_DOWN) + { + mMouseLevel[clicktype] = MOUSE_STATE_CLICK; + } + else + { + mMouseLevel[clicktype] = MOUSE_STATE_UP; + } } } @@ -1316,6 +1373,7 @@ bool LLViewerKeyboard::scanMouse(const LLMouseBinding *binding, S32 binding_coun switch (state) { case MOUSE_STATE_DOWN: + case MOUSE_STATE_CLICK: binding[i].mFunction(KEYSTATE_DOWN); break; case MOUSE_STATE_LEVEL: @@ -1360,7 +1418,7 @@ void LLViewerKeyboard::scanMouse() // mouse doesn't support 'continued' state like keyboard does, so after handling, switch to LEVEL mMouseLevel[i] = MOUSE_STATE_LEVEL; } - else if (mMouseLevel[i] == MOUSE_STATE_UP) + else if (mMouseLevel[i] == MOUSE_STATE_UP || mMouseLevel[i] == MOUSE_STATE_CLICK) { mMouseLevel[i] = MOUSE_STATE_SILENT; } diff --git a/indra/newview/llviewerkeyboard.h b/indra/newview/llviewerkeyboard.h index 3ba033509c..10b16e5fa0 100644 --- a/indra/newview/llviewerkeyboard.h +++ b/indra/newview/llviewerkeyboard.h @@ -141,6 +141,7 @@ private: enum EMouseState { MOUSE_STATE_DOWN, // key down this frame + MOUSE_STATE_CLICK, // key went up and down in scope of same frame MOUSE_STATE_LEVEL, // clicked again fast, or never released MOUSE_STATE_UP, // went up this frame MOUSE_STATE_SILENT // notified about 'up', do not notify again diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b6c7be2ed3..ab054fabde 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8031,7 +8031,6 @@ BOOL LLViewerMenuHolderGL::hideMenus() if (LLMenuHolderGL::hideMenus()) { - LLToolPie::instance().blockClickToWalk(); handled = TRUE; } |