From 59ed92522f7b72731911825a831bab559f0c1c8b Mon Sep 17 00:00:00 2001 From: leviathan Date: Wed, 17 Jul 2024 15:25:22 -0700 Subject: even more correct GameControl feature-flag switch --- indra/llui/lltabcontainer.cpp | 28 +++++++----- indra/llwindow/llgamecontrol.cpp | 2 +- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llfloaterpreference.cpp | 53 +++++++++++++++++++--- indra/newview/llfloaterpreference.h | 12 +++-- indra/newview/llviewermenu.cpp | 2 + indra/newview/skins/default/xui/en/menu_viewer.xml | 32 ++++++------- .../default/xui/en/panel_preferences_controls.xml | 2 +- .../xui/en/panel_preferences_game_control.xml | 18 ++------ 9 files changed, 98 insertions(+), 53 deletions(-) (limited to 'indra') diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 5e0985c79c..7c9aa42e5f 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -1258,7 +1258,6 @@ void LLTabContainer::removeTabPanel(LLPanel* child) bool has_focus = gFocusMgr.childHasKeyboardFocus(this); - // If the tab being deleted is the selected one, select a different tab. for(std::vector::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) { LLTabTuple* tuple = *iter; @@ -1296,6 +1295,7 @@ void LLTabContainer::removeTabPanel(LLPanel* child) // make sure we don't have more locked tabs than we have tabs mLockedTabCount = llmin(getTabCount(), mLockedTabCount); + // If the tab being deleted is the selected one, select a different tab. if (mCurrentTabIdx >= (S32)mTabList.size()) { mCurrentTabIdx = static_cast(mTabList.size()) - 1; @@ -1723,7 +1723,7 @@ void LLTabContainer::reshapeTuple(LLTabTuple* tuple) { S32 image_overlay_width = 0; - if(mCustomIconCtrlUsed) + if (mCustomIconCtrlUsed) { LLCustomButtonIconCtrl* button = dynamic_cast(tuple->mButton); LLIconCtrl* icon_ctrl = button ? button->getIconCtrl() : NULL; @@ -2173,12 +2173,22 @@ S32 LLTabContainer::getTotalTabWidth() const void LLTabContainer::setTabVisibility( LLPanel const *aPanel, bool aVisible ) { - for( tuple_list_t::const_iterator itr = mTabList.begin(); itr != mTabList.end(); ++itr ) + S32 num_tabs = S32(mTabList.size()); + for (S32 i = 0; i < num_tabs; ++i) { - LLTabTuple const *pTT = *itr; - if( pTT->mTabPanel == aPanel ) + LLTabTuple* tuple = mTabList[i]; + if( tuple->mTabPanel == aPanel ) { - pTT->mVisible = aVisible; + if (tuple->mVisible != aVisible) + { + tuple->mVisible = aVisible; + if (aVisible) + { + this->selectTab(i); + this->setVisible(true); + } + updateMaxScrollPos(); + } break; } } @@ -2194,11 +2204,7 @@ void LLTabContainer::setTabVisibility( LLPanel const *aPanel, bool aVisible ) break; } } - - if( foundTab ) - this->setVisible( true ); - else - this->setVisible( false ); + this->setVisible( foundTab ); updateMaxScrollPos(); } diff --git a/indra/llwindow/llgamecontrol.cpp b/indra/llwindow/llgamecontrol.cpp index 0e3782a10e..812c861370 100644 --- a/indra/llwindow/llgamecontrol.cpp +++ b/indra/llwindow/llgamecontrol.cpp @@ -434,7 +434,7 @@ namespace // data state. However, to keep the ambient resend bandwidth low we // expand the resend period at a geometric rate. // - constexpr U64 MSEC_PER_NSEC = 1e6; + constexpr U64 MSEC_PER_NSEC = 1000000; constexpr U64 FIRST_RESEND_PERIOD = 100 * MSEC_PER_NSEC; constexpr U64 RESEND_EXPANSION_RATE = 10; LLGameControl::State g_outerState; // from controller devices diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2057ddaa0d..36abebc942 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2612,7 +2612,7 @@ Value 1 - GameControl + EnableGameControl Comment Enable GameControl feature diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 3c4eab0282..7ea9f9b4c2 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -402,6 +402,7 @@ void LLFloaterPreference::saveAvatarProperties( void ) } } +// static void LLFloaterPreference::saveAvatarPropertiesCoro(const std::string cap_url, bool allow_publish) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); @@ -439,6 +440,7 @@ bool LLFloaterPreference::postBuild() mDisabledPopups = getChild("disabled_popups"); mEnablePopupBtn = getChild("enable_this_popup"); mDisablePopupBtn = getChild("disable_this_popup"); + setPanelVisibility("game_control", LLGameControl::isEnabled()); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false)); @@ -1048,6 +1050,15 @@ void LLFloaterPreference::onBtnCancel(const LLSD& userdata) } } +//static +void LLFloaterPreference::refreshInstance() +{ + if (LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences")) + { + instance->refresh(); + } +} + // static void LLFloaterPreference::updateUserInfo(const std::string& visibility) { @@ -1057,6 +1068,7 @@ void LLFloaterPreference::updateUserInfo(const std::string& visibility) } } +// static void LLFloaterPreference::refreshEnabledGraphics() { if (LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences")) @@ -1292,6 +1304,16 @@ void LLAvatarComplexityControls::setIndirectMaxArc() void LLFloaterPreference::refresh() { + setPanelVisibility("game_control", LLGameControl::isEnabled()); + LLTabContainer* tabcontainer = getChild("pref core"); + for (LLView* view : *tabcontainer->getChildList()) + { + if (LLPanelPreferenceControls* panel = dynamic_cast(view)) + { + panel->refresh(); + break; + } + } LLFloater::refresh(); setMaxNonImpostorsText( gSavedSettings.getU32("RenderAvatarMaxNonImpostors"), @@ -1945,6 +1967,16 @@ void LLFloaterPreference::selectPanel(const LLSD& name) } } +void LLFloaterPreference::setPanelVisibility(const LLSD& name, bool visible) +{ + LLTabContainer * tab_containerp = getChild("pref core"); + LLPanel * panel = tab_containerp->getPanelByName(name.asStringRef()); + if (NULL != panel) + { + tab_containerp->setTabVisibility(panel, visible); + } +} + void LLFloaterPreference::selectPrivacyPanel() { selectPanel("im"); @@ -2532,6 +2564,12 @@ LLPanelPreferenceControls::~LLPanelPreferenceControls() { } +void LLPanelPreferenceControls::refresh() +{ + populateControlTable(); + LLPanelPreference::refresh(); +} + bool LLPanelPreferenceControls::postBuild() { // populate list of controls @@ -2710,7 +2748,10 @@ void LLPanelPreferenceControls::populateControlTable() addControlTableSeparator(); addControlTableRows("control_table_contents_media.xml"); addControlTableSeparator(); - addControlTableRows("control_table_contents_game_control.xml"); + if (LLGameControl::isEnabled()) + { + addControlTableRows("control_table_contents_game_control.xml"); + } } // MODE_THIRD_PERSON; MODE_EDIT_AVATAR; MODE_SITTING else if (mEditingMode < LLKeyConflictHandler::MODE_SAVED_SETTINGS) @@ -2729,7 +2770,10 @@ void LLPanelPreferenceControls::populateControlTable() addControlTableRows("control_table_contents_media.xml"); addControlTableSeparator(); - addControlTableRows("control_table_contents_game_control.xml"); + if (LLGameControl::isEnabled()) + { + addControlTableRows("control_table_contents_game_control.xml"); + } } else { @@ -3440,12 +3484,10 @@ void LLPanelPreferenceGameControl::onCommitNumericValue() bool LLPanelPreferenceGameControl::postBuild() { // Above the tab container - mCheckEnableGameControl = getChild("enable_game_control"); mCheckGameControlToServer = getChild("game_control_to_server"); mCheckGameControlToAgent = getChild("game_control_to_agent"); mCheckAgentToGameControl = getChild("agent_to_game_control"); - mCheckEnableGameControl->setCommitCallback([this](LLUICtrl*, const LLSD&) { updateEnable(); }); mCheckGameControlToAgent->setCommitCallback([this](LLUICtrl*, const LLSD&) { updateActionTableState(); }); mCheckAgentToGameControl->setCommitCallback([this](LLUICtrl*, const LLSD&) { updateActionTableState(); }); @@ -3522,7 +3564,6 @@ bool LLPanelPreferenceGameControl::postBuild() // This function is called before floater is shown void LLPanelPreferenceGameControl::onOpen(const LLSD& key) { - mCheckEnableGameControl->setValue(LLGameControl::isEnabled()); mCheckGameControlToServer->setValue(LLGameControl::getSendToServer()); mCheckGameControlToAgent->setValue(LLGameControl::getControlAgent()); mCheckAgentToGameControl->setValue(LLGameControl::getTranslateAgentActions()); @@ -3882,7 +3923,7 @@ void LLPanelPreferenceGameControl::addActionTableSeparator() void LLPanelPreferenceGameControl::updateEnable() { - bool enabled = mCheckEnableGameControl->get(); + bool enabled = LLGameControl::isEnabled(); LLGameControl::setEnabled(enabled); mCheckGameControlToServer->setEnabled(enabled); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 1a498c035e..b3872958ac 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -92,6 +92,8 @@ public: virtual void changed() override; virtual void changed(const LLUUID& session_id, U32 mask) override {}; + static void refreshInstance(); + // static data update, called from message handler static void updateUserInfo(const std::string& visibility); @@ -201,6 +203,7 @@ public: void buildPopupLists(); static void refreshSkin(void* data); void selectPanel(const LLSD& name); + void setPanelVisibility(const LLSD& name, bool visible); void saveGraphicsPreset(std::string& preset); void setRecommendedSettings(); @@ -327,6 +330,8 @@ public: bool postBuild() override; + void refresh() override; + void apply() override; void cancel(const std::vector settings_to_skip = {}) override; void saveSettings() override; @@ -349,6 +354,9 @@ public: void onDefaultKeyBind(bool all_modes) override; void onCancelKeyBind() override; + // Cleans content and then adds content from xml files according to current mEditingMode + void populateControlTable(); + private: // reloads settings, discards current changes, updates table void regenerateControls(); @@ -358,9 +366,6 @@ private: bool addControlTableRows(const std::string &filename); void addControlTableSeparator(); - // Cleans content and then adds content from xml files according to current mEditingMode - void populateControlTable(); - // Updates keybindings from storage to table void updateTable(); @@ -435,7 +440,6 @@ private: void resetButtonMappingsToDefaults(); // Above the tab container - LLCheckBoxCtrl *mCheckEnableGameControl; LLCheckBoxCtrl *mCheckGameControlToServer; // send game_control data to server LLCheckBoxCtrl *mCheckGameControlToAgent; // use game_control data to move avatar LLCheckBoxCtrl *mCheckAgentToGameControl; // translate external avatar actions to game_control data diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index a6614542b8..39aa85beea 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -72,6 +72,7 @@ #include "llfloaterpathfindingcharacters.h" #include "llfloaterpathfindinglinksets.h" #include "llfloaterpay.h" +#include "llfloaterpreference.h" #include "llfloaterreporter.h" #include "llfloatersearch.h" #include "llfloaterscriptdebug.h" @@ -965,6 +966,7 @@ class LLAdvancedToggleExperiment : public view_listener_t if (feature == "GameControl") { LLGameControl::setEnabled(! LLGameControl::isEnabled()); + LLFloaterPreference::refreshInstance(); return true; } return false; diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index f6946f5304..da9cc0c98d 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2464,22 +2464,6 @@ function="World.EnvPreset" - - - - - - @@ -2505,6 +2489,22 @@ function="World.EnvPreset" name="Develop" tear_off="true" visible="false"> + + + + + + - + top="10"/> + top="30"/> + top="50"/> -- cgit v1.2.3