From a9593e62b75403d3670f853e1031e0c298f1e18b Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Mon, 2 Feb 2015 16:12:32 -0500 Subject: [PATCH] LLViewerMenu code cleanup --- indra/newview/llviewercontrol.cpp | 7 ++ indra/newview/llviewermenu.cpp | 97 ++++++------------- .../skins/default/xui/en-us/menu_viewer.xml | 4 +- 3 files changed, 39 insertions(+), 69 deletions(-) diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index a8e8c2379..021844f0e 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -625,6 +625,12 @@ static bool handleAllowLargeSounds(const LLSD& newvalue) return true; } +void handleHighResChanged(const LLSD& val) +{ + if (val) // High Res Snapshot active, must uncheck RenderUIInSnapshot + gSavedSettings.setBOOL("RenderUIInSnapshot", false); +} + //////////////////////////////////////////////////////////////////////////// void settings_setup_listeners() { @@ -819,6 +825,7 @@ void settings_setup_listeners() gSavedSettings.getControl("AllowLargeSounds")->getSignal()->connect(boost::bind(&handleAllowLargeSounds, _2)); gSavedSettings.getControl("LiruUseZQSDKeys")->getSignal()->connect(boost::bind(load_default_bindings, _2)); + gSavedSettings.getControl("HighResSnapshot")->getSignal()->connect(boost::bind(&handleHighResChanged, _2)); } void onCommitControlSetting_gSavedSettings(LLUICtrl* ctrl, void* name) diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 055945c18..a072431fa 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -335,10 +335,6 @@ void set_current_pose(std::string anim) gAgent.sendAnimationRequest(current_pose, ANIM_REQUEST_START); gAgent.sendAgentSetAppearance(); } -void handle_pose_stand(void*) -{ - set_current_pose("038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53"); -} void handle_pose_stand_stop(void*) { if (on_pose_stand) @@ -349,21 +345,12 @@ void handle_pose_stand_stop(void*) gAgent.sendAgentSetAppearance(); } } -void cleanup_pose_stand(void) +void cleanup_pose_stand() { handle_pose_stand_stop(NULL); } -void handle_toggle_pose(void* userdata) { - if(current_pose.isNull()) - handle_pose_stand(userdata); - else - handle_pose_stand_stop(userdata); -} - -BOOL handle_check_pose(void* userdata) { - return current_pose.notNull(); -} +BOOL handle_check_pose(void* userdata) { return current_pose.notNull(); } void handle_open_message_log(void*); @@ -450,6 +437,7 @@ void handle_morph_load_obj(void*); void handle_debug_avatar_textures(void*); void handle_dump_region_object_cache(void*); +void menu_toggle_double_click_control(void*); BOOL menu_ui_enabled(void *user_data); BOOL menu_check_control( void* user_data); void menu_toggle_variable( void* user_data ); @@ -1158,11 +1146,11 @@ void init_debug_ui_menu(LLMenuGL* menu) menu->addChild(new LLMenuItemCallGL( "Print Agent Info", &print_agent_nvpairs, NULL, NULL, 'P', MASK_SHIFT )); menu->addChild(new LLMenuItemCallGL( "Memory Stats", &output_statistics, NULL, NULL, 'M', MASK_SHIFT | MASK_ALT | MASK_CONTROL)); menu->addChild(new LLMenuItemCheckGL("Double-Click Auto-Pilot", - menu_toggle_control, NULL, menu_check_control, + menu_toggle_double_click_control, NULL, menu_check_control, (void*)"DoubleClickAutoPilot")); // add for double click teleport support menu->addChild(new LLMenuItemCheckGL("Double-Click Teleport", - menu_toggle_control, NULL, menu_check_control, + menu_toggle_double_click_control, NULL, menu_check_control, (void*)"DoubleClickTeleport")); menu->addSeparator(); // menu->addChild(new LLMenuItemCallGL( "Print Packets Lost", &print_packets_lost, NULL, NULL, 'L', MASK_SHIFT )); @@ -7307,26 +7295,27 @@ BOOL menu_ui_enabled(void *user_data) } // TomY TODO DEPRECATE & REMOVE -void menu_toggle_control( void* user_data ) +void menu_toggle_control(void* user_data) { std::string setting(static_cast(user_data)); - BOOL checked = gSavedSettings.getBOOL(setting); - if (setting == "HighResSnapshot" && !checked) - { - // High Res Snapshot active, must uncheck RenderUIInSnapshot - gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE ); - } - else if (setting == "DoubleClickAutoPilot" && !checked) - { - // Doubleclick actions - there can be only one - gSavedSettings.setBOOL( "DoubleClickTeleport", FALSE ); - } - else if (setting == "DoubleClickTeleport" && !checked) - { - // Doubleclick actions - there can be only one - gSavedSettings.setBOOL( "DoubleClickAutoPilot", FALSE ); - } - gSavedSettings.setBOOL(setting, !checked); + LLControlVariable* control(gSavedSettings.getControl(setting)); + control->set(!control->get()); +} + +void menu_toggle_double_click_control(void* user_data) +{ + std::string setting(static_cast(user_data)); + LLControlVariable* control(gSavedSettings.getControl(setting)); + bool checked = control->get(); + // Doubleclick actions - there can be only one + if (!checked) + { + if (setting == "DoubleClickAutoPilot") + gSavedSettings.setBOOL("DoubleClickTeleport", false); + else if (setting == "DoubleClickTeleport") + gSavedSettings.setBOOL("DoubleClickAutoPilot", false); + } + control->set(!checked); } @@ -7335,14 +7324,8 @@ class LLToggleControl : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - std::string control_name = userdata.asString(); - BOOL checked = gSavedSettings.getBOOL( control_name ); - if (control_name == "HighResSnapshot" && !checked) - { - // High Res Snapshot active, must uncheck RenderUIInSnapshot - gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE ); - } - gSavedSettings.setBOOL( control_name, !checked ); + LLControlVariable* control(gSavedSettings.getControl(userdata.asString())); + control->set(!control->get()); return true; } }; @@ -8789,26 +8772,6 @@ class SinguCloseAllDialogs : public view_listener_t } }; -class SinguNimble : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - gSavedSettings.setBOOL("Nimble", !gSavedSettings.getBOOL("Nimble")); - - return true; - } -}; - -class SinguCheckNimble : public view_listener_t -{ - bool handleEvent(LLPointer event, const LLSD& userdata) - { - gMenuHolder->findControl(userdata["control"].asString())->setValue(gSavedSettings.getBOOL("Nimble")); - - return true; - } -}; - class SinguEnableStreamingAudioDisplay : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -8821,8 +8784,10 @@ class SinguPoseStand : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - handle_toggle_pose(NULL); - + if (current_pose.isNull()) + set_current_pose("038fcec9-5ebd-8a8e-0e2e-6e71a0a1ac53"); + else + handle_pose_stand_stop(NULL); return true; } }; @@ -9509,8 +9474,6 @@ void initialize_menus() // Singularity menu addMenu(new SinguCloseAllDialogs(), "CloseAllDialogs"); // ---- Fake away handled elsewhere - addMenu(new SinguNimble(), "Nimble"); - addMenu(new SinguCheckNimble(), "CheckNimble"); addMenu(new SinguEnableStreamingAudioDisplay(), "EnableStreamingAudioDisplay"); addMenu(new SinguPoseStand(), "PoseStand"); addMenu(new SinguCheckPoseStand(), "CheckPoseStand"); diff --git a/indra/newview/skins/default/xui/en-us/menu_viewer.xml b/indra/newview/skins/default/xui/en-us/menu_viewer.xml index 440891d60..85f12d49a 100644 --- a/indra/newview/skins/default/xui/en-us/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en-us/menu_viewer.xml @@ -1031,8 +1031,8 @@ - - + +