diff --git a/indra/newview/app_settings/settings_ascent.xml b/indra/newview/app_settings/settings_ascent.xml index 09fba4c59..a39f9b855 100644 --- a/indra/newview/app_settings/settings_ascent.xml +++ b/indra/newview/app_settings/settings_ascent.xml @@ -818,6 +818,17 @@ Value /regionsay + SinguCmdLineSetting + + Comment + Set or toggle debug settings from the chatbar. + Persist + 1 + Type + String + Value + /setdebug + SinguCmdLineURL Comment diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index ee069ecbd..2863cfe92 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -42,6 +42,7 @@ #include "llagentui.h" #include "llavataractions.h" #include "llnotificationsutil.h" +#include "llsdserialize.h" #include "llviewerregion.h" #include "llworld.h" #include "lleventtimer.h" @@ -242,11 +243,11 @@ bool cmd_line_chat(std::string data, EChatType type) static LLCachedControl enableChatCmd(gSavedSettings, "AscentCmdLine", true); if (enableChatCmd) { - data = utf8str_tolower(data); std::istringstream input(data); std::string cmd; if (!(input >> cmd)) return true; + cmd = utf8str_tolower(cmd); static LLCachedControl sDrawDistanceCommand(gSavedSettings, "AscentCmdLineDrawDistance"); static LLCachedControl sHeightCommand(gSavedSettings, "AscentCmdLineHeight"); @@ -266,6 +267,7 @@ bool cmd_line_chat(std::string data, EChatType type) static LLCachedControl sTP2Command(gSavedSettings, "AscentCmdLineTP2"); static LLCachedControl sAwayCommand(gSavedSettings, "SinguCmdLineAway"); static LLCachedControl sURLCommand(gSavedSettings, "SinguCmdLineURL"); + static LLCachedControl sSettingCommand(gSavedSettings, "SinguCmdLineSetting"); if (cmd == utf8str_tolower(sDrawDistanceCommand)) // dd { @@ -396,7 +398,7 @@ bool cmd_line_chat(std::string data, EChatType type) slurl = LLSLURL(slurl.getRegion(), LLVector3(fmod(agentPos.mdV[VX], (F64)REGION_WIDTH_METERS), fmod(agentPos.mdV[VY], (F64)REGION_WIDTH_METERS), agentPos.mdV[VZ])); } - LLUrlAction::teleportToLocation(LLWeb::escapeURL(std::string("secondlife:///app/teleport/")+slurl.getLocationString())); + LLUrlAction::teleportToLocation(LLWeb::escapeURL("secondlife:///app/teleport/"+slurl.getLocationString())); } return false; } @@ -539,6 +541,54 @@ bool cmd_line_chat(std::string data, EChatType type) } return false; } + else if (cmd == utf8str_tolower(sSettingCommand)) + { + std::string control_name; + if (input >> control_name) + { + // Find out if this control even exists. + auto control = gSavedSettings.getControl(control_name); + if (!control) gSavedPerAccountSettings.getControl(control_name); + if (!control) return false; + + LLSD val; + // Toggle if we weren't given a value, + if (input.eof()) val = !control->get(); + else // otherwise use what we were given. + { + switch (control->type()) // Convert to the right type, we can't be a string forever. + { + case TYPE_U32: // Integer is Integer, sucks but whatever + case TYPE_S32: + { + LLSD::Integer i; + input >> i; + val = i; + break; + } + case TYPE_F32: + { + LLSD::Float f; + input >> f; + val = f; + break; + } + case TYPE_STRING: + { + LLSD::String str; + std::getline(input, str, '\0'); // Read the entire rest of the stream into str + LLStringUtil::trim(str); // There's no setting where a space would be necessary here. + val = str; + break; + } + default: // Just parse it like JSON (or accept one of the many boolean value options! + LLSDSerialize::fromNotation(val, input, LLSDSerialize::SIZE_UNLIMITED); + } + } + control->set(val); + } + return false; + } else if (cmd == "typingstop") { std::string text;