aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterhud.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloaterhud.cpp')
-rw-r--r--linden/indra/newview/llfloaterhud.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterhud.cpp b/linden/indra/newview/llfloaterhud.cpp
new file mode 100644
index 0000000..2f192f7
--- /dev/null
+++ b/linden/indra/newview/llfloaterhud.cpp
@@ -0,0 +1,140 @@
1/**
2 * @file llfloaterhud.cpp
3 * @brief Implementation of HUD floater
4 *
5 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 *
7 * Copyright (c) 2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34#include "llfloaterhud.h"
35#include "llviewercontrol.h"
36#include "lluictrlfactory.h"
37#include "llwebbrowserctrl.h"
38#include "llalertdialog.h"
39
40// statics
41LLFloaterHUD* LLFloaterHUD::sInstance = 0;
42std::string LLFloaterHUD::sTutorialUrl = "";
43
44///----------------------------------------------------------------------------
45/// Class LLFloaterHUD
46///----------------------------------------------------------------------------
47#define super LLFloater /* superclass */
48
49// Default constructor
50LLFloaterHUD::LLFloaterHUD()
51: LLFloater("floater_hud"),
52 mWebBrowser(0)
53{
54 // Don't grab the focus as it will impede performing in-world actions
55 // while using the HUD
56 setAutoFocus(FALSE);
57
58 // Opaque background since we never get the focus
59 setBackgroundOpaque(TRUE);
60
61 // Create floater from its XML definition
62 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_hud.xml");
63
64 // Position floater based on saved location
65 LLRect saved_position_rect = gSavedSettings.getRect("FloaterHUDRect");
66 reshape(saved_position_rect.getWidth(), saved_position_rect.getHeight(), FALSE);
67 setRect(saved_position_rect);
68
69 mWebBrowser = getChild<LLWebBrowserCtrl>("floater_hud_browser" );
70 if (mWebBrowser)
71 {
72 // Always refresh the browser
73 mWebBrowser->setAlwaysRefresh(true);
74
75 // Open links in internal browser
76 mWebBrowser->setOpenInExternalBrowser(false);
77
78 LLString language(gSavedSettings.getString("Language"));
79 if(language == "default")
80 {
81 language = gSavedSettings.getString("SystemLanguage");
82 }
83
84 std::string url = sTutorialUrl + language + "/";
85 mWebBrowser->navigateTo(url);
86 }
87
88 // Remember the one instance
89 sInstance = this;
90}
91
92// Get the instance
93LLFloaterHUD* LLFloaterHUD::getInstance()
94{
95 if (!sInstance)
96 {
97 new LLFloaterHUD();
98 }
99 return sInstance;
100}
101
102// Destructor
103LLFloaterHUD::~LLFloaterHUD()
104{
105 // Save floater position
106 gSavedSettings.setRect("FloaterHUDRect", getRect() );
107
108 // Clear out the one instance if it's ours
109 if (sInstance == this)
110 {
111 sInstance = NULL;
112 }
113}
114
115// Show the HUD
116void LLFloaterHUD::show()
117{
118 // do not build the floater if there the url is empty
119 if (sTutorialUrl == "")
120 {
121 LLAlertDialog::showXml("TutorialNotFound");
122 return;
123 }
124
125 // Create the instance if necessary
126 LLFloaterHUD* hud = getInstance();
127 hud->open();
128 hud->setFrontmost(FALSE);
129}
130
131void LLFloaterHUD::close()
132{
133 if (sInstance) sInstance->close();
134}
135
136void LLFloaterHUD::onFocusReceived()
137{
138 // Never get the focus
139 setFocus(FALSE);
140}