diff options
author | leviathan <leviathan@lindenlab.com> | 2024-08-27 16:18:57 -0700 |
---|---|---|
committer | Andrew Meadows <andrew.l.meadows@gmail.com> | 2024-10-03 09:03:31 -0700 |
commit | 8213a0fb6b3149042d6833c8f0c4a3c1bfdc8bc9 (patch) | |
tree | b363c92b9d2bd06369e86eadae3fa3a9e278c7f0 /indra/newview | |
parent | 59ed92522f7b72731911825a831bab559f0c1c8b (diff) |
more correct application of GameControl prefs
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llappviewer.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llfloaterpreference.h | 7 |
3 files changed, 48 insertions, 18 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 7eded9e174..475610be36 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -47,6 +47,7 @@ #include "llagentwearables.h" #include "lldirpicker.h" #include "llfloaterimcontainer.h" +#include "llfloaterpreference.h" #include "llimprocessing.h" #include "llwindow.h" #include "llviewerstats.h" @@ -1141,7 +1142,8 @@ bool LLAppViewer::init() [&](const std::string& name) -> std::string { return gSavedSettings.getString(name); }, [&](const std::string& name, const std::string& value) { gSavedSettings.setString(name, value); }, [&](const std::string& name) -> LLSD { return gSavedSettings.getLLSD(name); }, - [&](const std::string& name, const LLSD& value) { gSavedSettings.setLLSD(name, value); }); + [&](const std::string& name, const LLSD& value) { gSavedSettings.setLLSD(name, value); }, + [&]() { LLPanelPreferenceGameControl::updateDeviceList(); }); try { diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 7ea9f9b4c2..109db7e3d7 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1001,7 +1001,8 @@ void LLFloaterPreference::onBtnOK(const LLSD& userdata) LLUIColorTable::instance().saveUserSettings(); gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), true); - LLGameControl::loadFromSettings(); + // save current config to settings + LLGameControl::saveToSettings(); // Only save once logged in and loaded per account settings if (mGotPersonalInfo) @@ -1048,6 +1049,9 @@ void LLFloaterPreference::onBtnCancel(const LLSD& userdata) cancel(); closeFloater(); } + + // restore config from settings + LLGameControl::loadFromSettings(); } //static @@ -2261,12 +2265,12 @@ void LLPanelPreference::cancel(const std::vector<std::string> settings_to_skip) { for (control_values_map_t::iterator iter = mSavedValues.begin(); iter != mSavedValues.end(); ++iter) -{ + { LLControlVariable* control = iter->first; LLSD ctrl_value = iter->second; if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == "")) - { + { continue; } @@ -3176,6 +3180,15 @@ static LLScrollListCtrl* gSelectedGrid { nullptr }; static LLScrollListItem* gSelectedItem { nullptr }; static LLScrollListCell* gSelectedCell { nullptr }; +// static +void LLPanelPreferenceGameControl::updateDeviceList() +{ + if (gGameControlPanel) + { + gGameControlPanel->updateDeviceListInternal(); + } +} + LLPanelPreferenceGameControl::LLPanelPreferenceGameControl() { gGameControlPanel = this; @@ -3424,34 +3437,39 @@ void LLPanelPreferenceGameControl::onAxisOptionsSelect() if (LLScrollListItem* row = mAxisOptions->getFirstSelected()) { - LLGameControl::Options& deviceOptions = getSelectedDeviceOptions(); + LLGameControl::Options& options = getSelectedDeviceOptions(); S32 row_index = mAxisOptions->getItemIndex(row); - S32 column_index = row->getSelectedCell(); - if (column_index == 1) + { - LLGameControl::Options& deviceOptions = getSelectedDeviceOptions(); - deviceOptions.getAxisOptions()[row_index].mInvert = - row->getColumn(column_index)->getValue().asBoolean(); + // always update invert checkbox value because even though it may have been clicked + // the row does not know its cell has been selected + constexpr S32 invert_checkbox_column = 1; + bool invert = row->getColumn(invert_checkbox_column)->getValue().asBoolean(); + options.getAxisOptions()[row_index].mMultiplier = invert ? -1 : 1; } - else if (column_index == 2 || column_index == 3) + + S32 column_index = row->getSelectedCell(); + if (column_index == 2 || column_index == 3) { fitInRect(mNumericValueEditor, mAxisOptions, row_index, column_index); if (column_index == 2) { mNumericValueEditor->setMinValue(0); mNumericValueEditor->setMaxValue(LLGameControl::MAX_AXIS_DEAD_ZONE); - mNumericValueEditor->setValue(deviceOptions.getAxisOptions()[row_index].mDeadZone); + mNumericValueEditor->setValue(options.getAxisOptions()[row_index].mDeadZone); } else // column_index == 3 { mNumericValueEditor->setMinValue(-LLGameControl::MAX_AXIS_OFFSET); mNumericValueEditor->setMaxValue(LLGameControl::MAX_AXIS_OFFSET); - mNumericValueEditor->setValue(deviceOptions.getAxisOptions()[row_index].mOffset); + mNumericValueEditor->setValue(options.getAxisOptions()[row_index].mOffset); } mNumericValueEditor->setVisible(true); } initCombobox(row, mAxisOptions); + + LLGameControl::setDeviceOptions(mSelectedDeviceGUID, options); } } @@ -3464,7 +3482,7 @@ void LLPanelPreferenceGameControl::onCommitNumericValue() S32 row_index = mAxisOptions->getItemIndex(row); S32 column_index = row->getSelectedCell(); llassert(column_index == 2 || column_index == 3); - if (column_index != 2 && column_index != 3) + if (column_index < 2 || column_index > 3) return; if (column_index == 2) @@ -3574,6 +3592,12 @@ void LLPanelPreferenceGameControl::onOpen(const LLSD& key) populateActionTableCells(); updateActionTableState(); + updateDeviceListInternal(); + updateEnable(); +} + +void LLPanelPreferenceGameControl::updateDeviceListInternal() +{ // Setup the 2nd tab mDeviceOptions.clear(); for (const auto& pair : LLGameControl::getDeviceOptions()) @@ -3590,11 +3614,8 @@ void LLPanelPreferenceGameControl::onOpen(const LLSD& key) mDeviceOptions[device.getGUID()] = { device.getName(), device.saveOptionsToString(true), device.getOptions() }; } } - mCheckShowAllDevices->setValue(false); populateDeviceTitle(); - - updateEnable(); } void LLPanelPreferenceGameControl::populateActionTableRows(const std::string& filename) @@ -3791,7 +3812,7 @@ void LLPanelPreferenceGameControl::populateOptionsTableCells() { LLScrollListItem* row = rows[i]; const LLGameControl::Options::AxisOptions& axis_options = all_axis_options[i]; - row->getColumn(1)->setValue(axis_options.mInvert); + row->getColumn(1)->setValue(axis_options.mMultiplier == -1 ? true : false); setNumericLabel(row->getColumn(2), axis_options.mDeadZone); setNumericLabel(row->getColumn(3), axis_options.mOffset); } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index b3872958ac..57eaa193a3 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -389,12 +389,19 @@ public: TYPE_NONE }; + static void updateDeviceList(); + LLPanelPreferenceGameControl(); ~LLPanelPreferenceGameControl(); void onOpen(const LLSD& key) override; + + // This function squirrels away the current values of the controls so that + // cancel() can restore them. void saveSettings() override; + void updateDeviceListInternal(); + void onGridSelect(LLUICtrl* ctrl); void onCommitInputChannel(LLUICtrl* ctrl); |