SL-16976 SL-443 Keybindings: Backward compatibility #3

meow-7.2.2
Andrey Kleshchev 2022-03-04 22:24:59 +02:00
parent 76a1b181e6
commit fc90fee508
2 changed files with 49 additions and 17 deletions

View File

@ -376,23 +376,6 @@ bool LLKeyConflictHandler::loadFromSettings(const ESourceMode &load_mode, const
LL_ERRS() << "Not implememted mode " << load_mode << LL_ENDL;
break;
}
// verify version
if (keys.xml_version < 1)
{
// Updating from a version that was not aware of LMouse bindings.
// Assign defaults.
//
// mDefaultsMap is always going to have correct version so
// registerControl is usable, but using 'destination' just in case.
LLKeyConflict &type_data = (*destination)[script_mouse_handler_name];
LLKeyData data(CLICK_LEFT, KEY_NONE, MASK_NONE, true);
type_data.mKeyBind.replaceKeyData(data, 0);
// Mark this mode for an update, once user clicks 'OK' in preferences
// it should get saved
mHasUnsavedChanges = true;
}
}
return res;
}

View File

@ -1371,6 +1371,55 @@ S32 LLViewerInput::loadBindingsXML(const std::string& filename)
{
mLMouseDefaultHandling[i] = true;
}
// fix missing values
KeyBinding mouse_binding;
mouse_binding.key = "";
mouse_binding.mask = "NONE";
mouse_binding.mouse = "LMB";
mouse_binding.command = script_mouse_handler_name;
if (keys.third_person.isProvided())
{
keys.third_person.bindings.add(mouse_binding);
}
if (keys.first_person.isProvided())
{
keys.first_person.bindings.add(mouse_binding);
}
if (keys.sitting.isProvided())
{
keys.sitting.bindings.add(mouse_binding);
}
if (keys.edit_avatar.isProvided())
{
keys.edit_avatar.bindings.add(mouse_binding);
}
// fix version
keys.xml_version.set(keybindings_xml_version, true);
// Write the resulting XML to file
LLXMLNodePtr output_node = new LLXMLNode("keys", false);
LLXUIParser write_parser;
write_parser.writeXUI(output_node, keys);
if (!output_node->isNull())
{
// file in app_settings is supposed to be up to date
// this is only for the file from user_settings
LL_INFOS("ViewerInput") << "Updating file " << filename << " to a newer version" << LL_ENDL;
LLFILE *fp = LLFile::fopen(filename, "w");
if (fp != NULL)
{
LLXMLNode::writeHeaderToFile(fp);
output_node->writeToFile(fp);
fclose(fp);
}
}
}
}
return binding_count;