diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-11-10 19:06:03 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2020-06-23 14:50:05 +0300 |
commit | 5568018bd20a43c30caca0c6288e63bfae29a2e3 (patch) | |
tree | a5d81dbebe5601230d95b8a1c45dc1b2a577e6ca /indra | |
parent | e7d383be8a9734a5008690b8a7e1b179e2f2a718 (diff) |
SL-6109 Better key and table localization support and fix for key-replacing
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llkeybind.cpp | 31 | ||||
-rw-r--r-- | indra/llwindow/llkeyboard.cpp | 11 | ||||
-rw-r--r-- | indra/llwindow/llkeyboard.h | 2 | ||||
-rw-r--r-- | indra/newview/llkeyconflict.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llkeyconflict.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/control_table_contents.xml | 52 |
6 files changed, 68 insertions, 32 deletions
diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp index 46a3230240..ecfc289cb3 100644 --- a/indra/llcommon/llkeybind.cpp +++ b/indra/llcommon/llkeybind.cpp @@ -340,43 +340,24 @@ bool LLKeyBind::addKeyData(const LLKeyData& data) void LLKeyBind::replaceKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore, U32 index) { - if (mouse != CLICK_NONE || key != KEY_NONE ) - { - // if both click and key are none, we are inserting a placeholder, we don't want to reset anything - // otherwise reset identical key - for (data_vector_t::iterator iter = mData.begin(); iter != mData.end(); iter++) - { - if (iter->mKey == key - && iter->mMouse == mouse - && iter->mIgnoreMasks == ignore - && (iter->mIgnoreMasks || iter->mMask == mask)) - { - iter->reset(); - break; - } - } - } - if (mData.size() > index) - { - mData[index] = LLKeyData(mouse, key, mask, ignore); - } - else - { - mData.push_back(LLKeyData(mouse, key, mask, ignore)); - } + replaceKeyData(LLKeyData(mouse, key, mask, ignore), index); } void LLKeyBind::replaceKeyData(const LLKeyData& data, U32 index) { if (!data.isEmpty()) { + // if both click and key are none (isEmpty()), we are inserting a placeholder, we don't want to reset anything + // otherwise reset identical key for (data_vector_t::iterator iter = mData.begin(); iter != mData.end(); iter++) { if (iter->mKey == data.mKey && iter->mMouse == data.mMouse && iter->mIgnoreMasks == data.mIgnoreMasks - && (iter->mIgnoreMasks || iter->mMask == data.mMask)) + && iter->mMask == data.mMask) { + // Replacing only fully equal combinations even in case 'ignore' is set + // Reason: Simplicity and user might decide to do a 'move' command as W and Shift+Ctrl+W, and 'run' as Shift+W iter->reset(); break; } diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 8e75325859..5404ac50e5 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -327,7 +327,7 @@ BOOL LLKeyboard::keyFromString(const std::string& str, KEY *key) // static -std::string LLKeyboard::stringFromKey(KEY key) +std::string LLKeyboard::stringFromKey(KEY key, bool translate) { std::string res = get_if_there(sKeysToNames, key, std::string()); if (res.empty()) @@ -338,10 +338,13 @@ std::string LLKeyboard::stringFromKey(KEY key) res = std::string(buffer); } - LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; - if (trans != NULL) + if (translate) { - res = trans(res.c_str()); + LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; + if (trans != NULL) + { + res = trans(res.c_str()); + } } return res; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index f6404164e7..36bd8bcbed 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -94,7 +94,7 @@ public: static BOOL maskFromString(const std::string& str, MASK *mask); // False on failure static BOOL keyFromString(const std::string& str, KEY *key); // False on failure - static std::string stringFromKey(KEY key); + static std::string stringFromKey(KEY key, bool translate = true); static std::string stringFromAccelerator( MASK accel_mask ); // separated for convinience, returns with "+": "Shift+" or "Shift+Alt+"... static std::string stringFromAccelerator( MASK accel_mask, KEY key ); diff --git a/indra/newview/llkeyconflict.cpp b/indra/newview/llkeyconflict.cpp index 121965a388..882a1d0caf 100644 --- a/indra/newview/llkeyconflict.cpp +++ b/indra/newview/llkeyconflict.cpp @@ -517,8 +517,7 @@ void LLKeyConflictHandler::saveToSettings(bool temporary) } else { - // Note: this is UI string, we might want to hardcode our own for 'fixed' use in keys.xml - binding.key = LLKeyboard::stringFromKey(data.mKey); + binding.key = LLKeyboard::stringFromKey(data.mKey, false /*Do not localize*/); } binding.mask = string_from_mask(data.mMask); if (data.mMouse == CLICK_NONE) diff --git a/indra/newview/llkeyconflict.h b/indra/newview/llkeyconflict.h index 48af0ccdfe..84730e4d4f 100644 --- a/indra/newview/llkeyconflict.h +++ b/indra/newview/llkeyconflict.h @@ -86,6 +86,7 @@ public: LLKeyData getControl(const std::string &control_name, U32 data_index); + // localized string static std::string getStringFromKeyData(const LLKeyData& keydata); std::string getControlString(const std::string &control_name, U32 data_index); diff --git a/indra/newview/skins/default/xui/en/control_table_contents.xml b/indra/newview/skins/default/xui/en/control_table_contents.xml index da9cceb2db..7b777befee 100644 --- a/indra/newview/skins/default/xui/en/control_table_contents.xml +++ b/indra/newview/skins/default/xui/en/control_table_contents.xml @@ -30,6 +30,7 @@ value="Move_Walk_Off" /> </rows> <rows + name="walk_to" value="walk_to"> <columns column="lst_action" @@ -40,6 +41,7 @@ value="Walk to" /> </rows> <rows + name="teleport_to" value="teleport_to"> <columns column="lst_action" @@ -50,6 +52,7 @@ value="Teleport to" /> </rows> <rows + name="push_forward" value="push_forward"> <columns column="lst_action" @@ -59,6 +62,7 @@ value="Move Forward" /> </rows> <rows + name="push_backward" value="push_backward"> <columns column="lst_action" @@ -68,6 +72,7 @@ value="Move Backward" /> </rows> <rows + name="turn_left" value="turn_left"> <columns column="lst_action" @@ -77,6 +82,7 @@ value="Left" /> </rows> <rows + name="turn_right" value="turn_right"> <columns column="lst_action" @@ -86,6 +92,7 @@ value="Right" /> </rows> <rows + name="slide_left" value="slide_left"> <columns column="lst_action" @@ -95,6 +102,7 @@ value="Strafe left" /> </rows> <rows + name="slide_right" value="slide_right"> <columns column="lst_action" @@ -104,6 +112,7 @@ value="Strafe right" /> </rows> <rows + name="jump" value="jump"> <columns column="lst_action" @@ -113,6 +122,7 @@ value="Jump/Up" /> </rows> <rows + name="push_down" value="push_down"> <columns column="lst_action" @@ -122,6 +132,7 @@ value="Down" /> </rows> <rows + name="run_forward" value="run_forward"> <columns column="lst_action" @@ -131,6 +142,7 @@ value="Run Forward" /> </rows> <rows + name="run_backward" value="run_backward"> <columns column="lst_action" @@ -140,6 +152,7 @@ value="Run Backward" /> </rows> <rows + name="run_left" value="run_left"> <columns column="lst_action" @@ -149,6 +162,7 @@ value="Run Left" /> </rows> <rows + name="run_right" value="run_right"> <columns column="lst_action" @@ -158,6 +172,7 @@ value="Run Right" /> </rows> <rows + name="toggle_run" value="toggle_run"> <columns column="lst_action" @@ -167,6 +182,7 @@ value="Toggle Run" /> </rows> <rows + name="toggle_fly" value="toggle_fly"> <columns column="lst_action" @@ -176,6 +192,7 @@ value="Fly/Stop flying" /> </rows> <rows + name="toggle_sit" value="toggle_sit"> <columns column="lst_action" @@ -185,6 +202,7 @@ value="Sit/Stand" /> </rows> <rows + name="stop_moving" value="stop_moving"> <columns column="lst_action" @@ -215,6 +233,7 @@ value="Cam_FreeCam_Off" /> </rows> <rows + name="look_up" value="look_up"> <columns column="lst_action" @@ -224,6 +243,7 @@ value="Look Up" /> </rows> <rows + name="look_down" value="look_down"> <columns column="lst_action" @@ -233,6 +253,7 @@ value="Look Down" /> </rows> <rows + name="move_forward" value="move_forward"> <columns column="lst_action" @@ -242,6 +263,7 @@ value="Camera Forward" /> </rows> <rows + name="move_backward" value="move_backward"> <columns column="lst_action" @@ -251,6 +273,7 @@ value="Camera Backward" /> </rows> <rows + name="move_forward_fast" value="move_forward_fast"> <columns column="lst_action" @@ -260,6 +283,7 @@ value="Camera Forward Fast" /> </rows> <rows + name="move_backward_fast" value="move_backward_fast"> <columns column="lst_action" @@ -269,6 +293,7 @@ value="Camera Backward Fast" /> </rows> <rows + name="move_forward_sitting" value="move_forward_sitting"> <columns column="lst_action" @@ -278,6 +303,7 @@ value="Camera Forward Sitting" /> </rows> <rows + name="move_backward_sitting" value="move_backward_sitting"> <columns column="lst_action" @@ -287,6 +313,7 @@ value="Camera Backward Sitting" /> </rows> <rows + name="spin_over" value="spin_over"> <columns column="lst_action" @@ -296,6 +323,7 @@ value="Camera Spin Over" /> </rows> <rows + name="spin_under" value="spin_under"> <columns column="lst_action" @@ -305,6 +333,7 @@ value="Camera Spin Under" /> </rows> <rows + name="spin_over_sitting" value="spin_over_sitting"> <columns column="lst_action" @@ -314,6 +343,7 @@ value="Camera Spin Over" /> </rows> <rows + name="spin_under_sitting" value="spin_under_sitting"> <columns column="lst_action" @@ -323,6 +353,7 @@ value="Camera Spin Under" /> </rows> <rows + name="pan_up" value="pan_up"> <columns column="lst_action" @@ -332,6 +363,7 @@ value="Camera Pan Up" /> </rows> <rows + name="pan_down" value="pan_down"> <columns column="lst_action" @@ -341,6 +373,7 @@ value="Camera Pan Down" /> </rows> <rows + name="pan_left" value="pan_left"> <columns column="lst_action" @@ -350,6 +383,7 @@ value="Camera Pan Left" /> </rows> <rows + name="pan_right" value="pan_right"> <columns column="lst_action" @@ -359,6 +393,7 @@ value="Camera Pan Right" /> </rows> <rows + name="pan_in" value="pan_in"> <columns column="lst_action" @@ -368,6 +403,7 @@ value="Camera Pan In" /> </rows> <rows + name="pan_out" value="pan_out"> <columns column="lst_action" @@ -377,6 +413,7 @@ value="Camera Pan Out" /> </rows> <rows + name="spin_around_ccw" value="spin_around_ccw"> <columns column="lst_action" @@ -387,6 +424,7 @@ value="Counterclockwise" /> </rows> <rows + name="spin_around_cw" value="spin_around_cw"> <columns column="lst_action" @@ -397,6 +435,7 @@ value="Clockwise" /> </rows> <rows + name="spin_around_ccw_sitting" value="spin_around_ccw_sitting"> <columns column="lst_action" @@ -407,6 +446,7 @@ value="Counterclockwise Sitting" /> </rows> <rows + name="spin_around_cw_sitting" value="spin_around_cw_sitting"> <columns column="lst_action" @@ -438,6 +478,7 @@ value="Tool_Dozer" /> </rows> <rows + name="edit_avatar_spin_ccw" value="edit_avatar_spin_ccw"> <columns column="lst_action" @@ -448,6 +489,7 @@ value="Counterclockwise" /> </rows> <rows + name="edit_avatar_spin_cw" value="edit_avatar_spin_cw"> <columns column="lst_action" @@ -458,6 +500,7 @@ value="Clockwise" /> </rows> <rows + name="edit_avatar_spin_over" value="edit_avatar_spin_over"> <columns column="lst_action" @@ -468,6 +511,7 @@ value="Camera Spin Over" /> </rows> <rows + name="edit_avatar_spin_under" value="edit_avatar_spin_under"> <columns column="lst_action" @@ -478,6 +522,7 @@ value="Camera Spin Under" /> </rows> <rows + name="edit_avatar_move_forward" value="edit_avatar_move_forward"> <columns column="lst_action" @@ -487,6 +532,7 @@ value="Camera Forward" /> </rows> <rows + name="edit_avatar_move_backward" value="edit_avatar_move_backward"> <columns column="lst_action" @@ -517,6 +563,7 @@ value="Audio_Press" /> </rows> <rows + name="toggle_pause_media" value="toggle_pause_media"> <columns column="lst_action" @@ -526,6 +573,7 @@ value="Play/Pause Media" /> </rows> <rows + name="toggle_enable_media" value="toggle_enable_media"> <columns column="lst_action" @@ -535,6 +583,7 @@ value="Play/Stop All Media" /> </rows> <rows + name="voice_follow_key" value="voice_follow_key"> <columns column="lst_action" @@ -544,6 +593,7 @@ value="Voice" /> </rows> <rows + name="toggle_voice" value="toggle_voice"> <columns column="lst_action" @@ -553,6 +603,7 @@ value="Toggle Voice" /> </rows> <rows + name="start_chat" value="start_chat"> <columns column="lst_action" @@ -562,6 +613,7 @@ value="Start Chat" /> </rows> <rows + name="start_gesture" value="start_gesture"> <columns column="lst_action" |