diff options
Diffstat (limited to 'indra/newview/llfloaterhud.cpp')
| -rw-r--r-- | indra/newview/llfloaterhud.cpp | 136 |
1 files changed, 55 insertions, 81 deletions
diff --git a/indra/newview/llfloaterhud.cpp b/indra/newview/llfloaterhud.cpp index 72110e4fff..4181d1906e 100644 --- a/indra/newview/llfloaterhud.cpp +++ b/indra/newview/llfloaterhud.cpp @@ -2,22 +2,40 @@ * @file llfloaterhud.cpp * @brief Implementation of HUD floater * - * $LicenseInfo:firstyear=2008&license=viewergpl$ - * Copyright (c) 2008, Linden Research, Inc. + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, 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$ */ #include "llviewerprecompiledheaders.h" #include "llfloaterhud.h" + +// Viewer libs #include "llviewercontrol.h" -#include "llvieweruictrlfactory.h" -#include "llwebbrowserctrl.h" -#include "llalertdialog.h" +#include "llmediactrl.h" + +// Linden libs +#include "llnotificationsutil.h" +#include "lluictrlfactory.h" -// statics -LLFloaterHUD* LLFloaterHUD::sInstance = 0; -std::string LLFloaterHUD::sTutorialUrl = ""; ///---------------------------------------------------------------------------- /// Class LLFloaterHUD @@ -25,94 +43,50 @@ std::string LLFloaterHUD::sTutorialUrl = ""; #define super LLFloater /* superclass */ // Default constructor -LLFloaterHUD::LLFloaterHUD() -: LLFloater("floater_hud"), +LLFloaterHUD::LLFloaterHUD(const LLSD& key) +: LLFloater(key), mWebBrowser(0) { + // do not build the floater if there the url is empty + if (gSavedSettings.getString("TutorialURL") == "") + { + LLNotificationsUtil::add("TutorialNotFound"); + return; + } + // Don't grab the focus as it will impede performing in-world actions // while using the HUD - setAutoFocus(FALSE); + setIsChrome(TRUE); + + // Chrome doesn't show the window title by default, but here we + // want to show it. + setTitleVisible(true); // Opaque background since we never get the focus setBackgroundOpaque(TRUE); - - // Create floater from its XML definition - gUICtrlFactory->buildFloater(this, "floater_hud.xml"); - - // Position floater based on saved location - LLRect saved_position_rect = gSavedSettings.getRect("FloaterHUDRect"); - reshape(saved_position_rect.getWidth(), saved_position_rect.getHeight(), FALSE); - setRect(saved_position_rect); - - mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "floater_hud_browser" ); - if (mWebBrowser) - { - // Always refresh the browser - mWebBrowser->setAlwaysRefresh(true); - - // Open links in internal browser - mWebBrowser->setOpenInExternalBrowser(false); - - LLString language(gSavedSettings.getString("Language")); - if(language == "default") - { - language = gSavedSettings.getString("SystemLanguage"); - } - - std::string url = sTutorialUrl + language + "/"; - mWebBrowser->navigateTo(url); - } - - // Remember the one instance - sInstance = this; } -// Get the instance -LLFloaterHUD* LLFloaterHUD::getInstance() +BOOL LLFloaterHUD::postBuild() { - if (!sInstance) + mWebBrowser = getChild<LLMediaCtrl>("floater_hud_browser" ); + if (mWebBrowser) { - new LLFloaterHUD(); + // This is a "chrome" floater, so we don't want anything to + // take focus (as the user needs to be able to walk with + // arrow keys during tutorial). + mWebBrowser->setTakeFocusOnClick(false); + + std::string language = LLUI::getLanguage(); + std::string base_url = gSavedSettings.getString("TutorialURL"); + + std::string url = base_url + language + "/"; + mWebBrowser->navigateTo(url); } - return sInstance; + + return TRUE; } // Destructor LLFloaterHUD::~LLFloaterHUD() { - // Save floater position - gSavedSettings.setRect("FloaterHUDRect", getRect() ); - - // Clear out the one instance if it's ours - if (sInstance == this) - { - sInstance = NULL; - } -} - -// Show the HUD -void LLFloaterHUD::show() -{ - // do not build the floater if there the url is empty - if (sTutorialUrl == "") - { - LLAlertDialog::showXml("TutorialNotFound"); - return; - } - - // Create the instance if necessary - LLFloaterHUD* hud = getInstance(); - hud->open(); - hud->setFrontmost(FALSE); -} - -void LLFloaterHUD::close() -{ - if (sInstance) sInstance->close(); -} - -void LLFloaterHUD::onFocusReceived() -{ - // Never get the focus - setFocus(FALSE); } |
