diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.cpp | 138 | ||||
-rw-r--r-- | indra/llui/llcommandmanager.h | 97 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.h | 1 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 5 | ||||
-rw-r--r-- | indra/newview/CMakeLists.txt | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/commands.xml | 17 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/textures.xml | 3 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 8 |
10 files changed, 282 insertions, 1 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index cf3f9b1a7b..0687cf55d8 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -35,6 +35,7 @@ set(llui_SOURCE_FILES llcheckboxctrl.cpp llclipboard.cpp llcombobox.cpp + llcommandmanager.cpp llconsole.cpp llcontainerview.cpp llctrlselectioninterface.cpp @@ -132,6 +133,7 @@ set(llui_HEADER_FILES llcheckboxctrl.h llclipboard.h llcombobox.h + llcommandmanager.h llconsole.h llcontainerview.h llctrlselectioninterface.h diff --git a/indra/llui/llcommandmanager.cpp b/indra/llui/llcommandmanager.cpp new file mode 100644 index 0000000000..306b357d6a --- /dev/null +++ b/indra/llui/llcommandmanager.cpp @@ -0,0 +1,138 @@ +/** + * @file llcommandmanager.cpp + * @brief LLCommandManager class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +// A control that displays the name of the chosen item, which when +// clicked shows a scrolling box of options. + +#include "linden_common.h" + +#include "llcommandmanager.h" +#include "lldir.h" +#include "llerror.h" +#include "llxuiparser.h" + +#include <boost/foreach.hpp> + + +// +// LLCommand class +// + +LLCommand::Params::Params() + : function("function") + , icon("icon") + , label_ref("label_ref") + , name("name") + , param("param") + , tooltip_ref("tooltip_ref") +{ +} + +LLCommand::LLCommand(const LLCommand::Params& p) + : mFunction(p.function) + , mIcon(p.icon) + , mLabelRef(p.label_ref) + , mName(p.name) + , mParam(p.param) + , mTooltipRef(p.tooltip_ref) +{ +} + + +// +// LLCommandManager class +// + +LLCommandManager::LLCommandManager() +{ +} + +LLCommandManager::~LLCommandManager() +{ +} + +U32 LLCommandManager::count() const +{ + return mCommands.size(); +} + +LLCommand * LLCommandManager::getCommand(U32 commandIndex) +{ + return mCommands[commandIndex]; +} + +LLCommand * LLCommandManager::getCommand(const std::string& commandName) +{ + LLCommand * command_name_match = NULL; + + for (CommandVector::iterator it = mCommands.begin(); it != mCommands.end(); ++it) + { + LLCommand * command = *it; + + if (command->name() == commandName) + { + command_name_match = command; + break; + } + } + + return command_name_match; +} + +//static +bool LLCommandManager::load() +{ + LLCommandManager& mgr = LLCommandManager::instance(); + + std::string commands_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "commands.xml"); + + LLCommandManager::Params commandsParams; + + LLSimpleXUIParser parser; + + if (!parser.readXUI(commands_file, commandsParams)) + { + llerrs << "Unable to load xml file: " << commands_file << llendl; + return false; + } + + if (!commandsParams.validateBlock()) + { + llerrs << "Unable to validate commands param block from file: " << commands_file << llendl; + return false; + } + + BOOST_FOREACH(LLCommand::Params& commandParams, commandsParams.commands) + { + LLCommand * command = new LLCommand(commandParams); + + mgr.mCommands.push_back(command); + + llinfos << "Successfully loaded command: " << command->name() << llendl; + } + + return true; +} diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h new file mode 100644 index 0000000000..4f3c9b2ada --- /dev/null +++ b/indra/llui/llcommandmanager.h @@ -0,0 +1,97 @@ +/** + * @file llcommandmanager.h + * @brief LLCommandManager class to hold commands + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_COMMANDMANAGER_H +#define LL_COMMANDMANAGER_H + +#include "llinitparam.h" +#include "llsingleton.h" + + +class LLCommand +{ +public: + struct Params : public LLInitParam::Block<Params> + { + Mandatory<std::string> function; + Mandatory<std::string> icon; + Mandatory<std::string> label_ref; + Mandatory<std::string> name; + Optional<std::string> param; + Mandatory<std::string> tooltip_ref; + + Params(); + }; + + LLCommand(const LLCommand::Params& p); + + const std::string& functionName() const { return mFunction; } + const std::string& icon() const { return mIcon; } + const std::string& labelRef() const { return mLabelRef; } + const std::string& name() const { return mName; } + const std::string& param() const { return mParam; } + const std::string& tooltipRef() const { return mTooltipRef; } + +private: + std::string mFunction; + std::string mIcon; + std::string mLabelRef; + std::string mName; + std::string mParam; + std::string mTooltipRef; +}; + + +class LLCommandManager +: public LLSingleton<LLCommandManager> +{ +public: + struct Params : public LLInitParam::Block<Params> + { + Multiple< LLCommand::Params, AtLeast<1> > commands; + + Params() + : commands("command") + { + } + }; + + LLCommandManager(); + ~LLCommandManager(); + + U32 count() const; + LLCommand * getCommand(U32 commandIndex); + LLCommand * getCommand(const std::string& commandName); + + static bool load(); + +private: + typedef std::vector<LLCommand *> CommandVector; + CommandVector mCommands; +}; + + +#endif // LL_COMMANDMANAGER_H diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index fc7dcfcc4e..bc740dde17 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -453,6 +453,17 @@ void LLFloaterReg::toggleFloaterInstance(const LLSD& sdname) } //static +void LLFloaterReg::toggleToolbarFloaterInstance(const LLSD& sdname) +{ + // Do some extra logic here for 3-state toolbar floater toggling madness :) + + LLSD key; + std::string name = sdname.asString(); + parse_name_key(name, key); + toggleInstance(name, key); +} + +//static bool LLFloaterReg::floaterInstanceVisible(const LLSD& sdname) { LLSD key; diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index a2027a77a0..6239d98a7d 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -127,6 +127,7 @@ public: static void showFloaterInstance(const LLSD& sdname); static void hideFloaterInstance(const LLSD& sdname); static void toggleFloaterInstance(const LLSD& sdname); + static void toggleToolbarFloaterInstance(const LLSD& sdname); static bool floaterInstanceVisible(const LLSD& sdname); static bool floaterInstanceMinimized(const LLSD& sdname); diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 593354ee9b..1bc575438c 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -41,6 +41,7 @@ #include "llgl.h" // Project includes +#include "llcommandmanager.h" #include "llcontrol.h" #include "llui.h" #include "lluicolortable.h" @@ -1617,6 +1618,7 @@ void LLUI::initClass(const settings_map_t& settings, // Callbacks for associating controls with floater visibilty: reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleFloaterInstance, _2)); + reg.add("Floater.ToolbarToggle", boost::bind(&LLFloaterReg::toggleToolbarFloaterInstance, _2)); reg.add("Floater.Show", boost::bind(&LLFloaterReg::showFloaterInstance, _2)); reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideFloaterInstance, _2)); reg.add("Floater.InitToVisibilityControl", boost::bind(&LLFloaterReg::initUICtrlToFloaterVisibilityControl, _1, _2)); @@ -1635,6 +1637,9 @@ void LLUI::initClass(const settings_map_t& settings, // Used by menus along with Floater.Toggle to display visibility as a checkmark LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::floaterInstanceVisible, _2)); + + // Parse the master list of commands + LLCommandManager::load(); } void LLUI::cleanupClass() diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 18e092eb4a..597a1dd603 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1409,6 +1409,7 @@ list(APPEND viewer_SOURCE_FILES ${viewer_XUI_FILES}) set(viewer_APPSETTINGS_FILES app_settings/anim.ini app_settings/cmd_line.xml + app_settings/commands.xml app_settings/grass.xml app_settings/high_graphics.xml app_settings/ignorable_dialogs.xml diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml new file mode 100644 index 0000000000..8e45e866ca --- /dev/null +++ b/indra/newview/app_settings/commands.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<commands> + <command name="avatar" + icon="Command_Avatar_Icon" + label_ref="Command_Avatar_Label" + tooltip_ref="Command_Avatar_Tooltip" + function="Floater.ToolbarToggle" + param="avatar" + /> + <command name="places" + icon="Command_Places_Icon" + label_ref="Command_Places_Label" + tooltip_ref="Command_Places_Tooltip" + function="Floater.ToolbarToggle" + param="places" + /> +</commands> diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 4d83ec2902..598e39730c 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -125,6 +125,9 @@ with the same filename but different name <texture name="Checkbox_Press" file_name="widgets/Checkbox_Press.png" preload="true" /> <texture name="Check_Mark" file_name="icons/check_mark" preload="true" /> + <texture name="Command_Avatar_Icon" file_name="icons/SL_Logo.png" preload="true" /> + <texture name="Command_Places_Icon" file_name="icons/SL_Logo.png" preload="true" /> + <texture name="ComboButton_Disabled" file_name="widgets/ComboButton_Disabled.png" preload="true" scale.left="2" scale.top="19" scale.right="18" scale.bottom="2" /> <texture name="ComboButton_Selected" file_name="widgets/ComboButton_Selected.png" preload="true" scale.left="2" scale.top="19" scale.right="18" scale.bottom="2" /> <texture name="ComboButton_UpSelected" file_name="widgets/ComboButton_UpSelected.png" preload="true" scale.left="2" scale.top="19" scale.right="18" scale.bottom="2" /> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index c0154ae9b3..3b986664db 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3651,4 +3651,10 @@ Try enclosing path to the editor with double quotes. <string name="BeaconMedia">Viewing media beacons (white)</string> <string name="ParticleHiding">Hiding Particles</string> - </strings> + <!-- commands --> + <string name="Command_Avatar_Label">Avatar</string> + <string name="Command_Avatar_Tooltip">Customize your avatar</string> + <string name="Command_Places_Label">Places</string> + <string name="Command_Places_Tooltip">Destination guide</string> + +</strings> |