aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llprogressview.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llprogressview.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llprogressview.cpp')
-rw-r--r--linden/indra/newview/llprogressview.cpp345
1 files changed, 345 insertions, 0 deletions
diff --git a/linden/indra/newview/llprogressview.cpp b/linden/indra/newview/llprogressview.cpp
new file mode 100644
index 0000000..9e7f1a5
--- /dev/null
+++ b/linden/indra/newview/llprogressview.cpp
@@ -0,0 +1,345 @@
1/**
2 * @file llprogressview.cpp
3 * @brief LLProgressView class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llprogressview.h"
31
32#include "indra_constants.h"
33#include "llmath.h"
34#include "llgl.h"
35#include "llui.h"
36#include "llfontgl.h"
37#include "llimagegl.h"
38#include "lltimer.h"
39#include "llglheaders.h"
40
41#include "llagent.h"
42#include "llfocusmgr.h"
43#include "llbutton.h"
44#include "llviewercontrol.h"
45#include "llviewerimagelist.h"
46#include "llviewerwindow.h"
47#include "viewer.h"
48
49LLProgressView* LLProgressView::sInstance = NULL;
50
51LLPointer<LLImageGL> gStartImageGL = NULL;
52S32 gStartImageWidth = 1;
53S32 gStartImageHeight = 1;
54const F32 FADE_IN_TIME = 1.f;
55
56const LLString ANIMATION_FILENAME = "Login Sequence ";
57const LLString ANIMATION_SUFFIX = ".jpg";
58const F32 TOTAL_LOGIN_TIME = 10.f; // seconds, wild guess at time from GL context to actual world view
59S32 gLastStartAnimationFrame = 0; // human-style indexing, first image = 1
60const S32 ANIMATION_FRAMES = 1; //13;
61
62// XUI:translate
63LLProgressView::LLProgressView(const std::string& name, const LLRect &rect)
64: LLView(name, rect, TRUE)
65{
66 mPercentDone = 0.f;
67 mDrawBackground = TRUE;
68
69 const S32 CANCEL_BTN_WIDTH = 70;
70 const S32 CANCEL_BTN_OFFSET = 16;
71 LLRect r;
72 r.setOriginAndSize(
73 mRect.getWidth() - CANCEL_BTN_OFFSET - CANCEL_BTN_WIDTH, CANCEL_BTN_OFFSET,
74 CANCEL_BTN_WIDTH, BTN_HEIGHT );
75
76 mCancelBtn = new LLButton(
77 "Quit",
78 r,
79 "",
80 LLProgressView::onCancelButtonClicked,
81 NULL );
82 mCancelBtn->setFollows( FOLLOWS_RIGHT | FOLLOWS_BOTTOM );
83 addChild( mCancelBtn );
84 mFadeTimer.stop();
85 setVisible(FALSE);
86
87 sInstance = this;
88}
89
90
91LLProgressView::~LLProgressView()
92{
93 gFocusMgr.releaseFocusIfNeeded( this );
94
95 sInstance = NULL;
96}
97
98EWidgetType LLProgressView::getWidgetType() const
99{
100 return WIDGET_TYPE_PROGRESS_VIEW;
101}
102
103LLString LLProgressView::getWidgetTag() const
104{
105 return LL_PROGRESS_VIEW_TAG;
106}
107
108BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask)
109{
110 if( childrenHandleHover( x, y, mask ) == NULL )
111 {
112 lldebugst(LLERR_USER_INPUT) << "hover handled by LLProgressView" << llendl;
113 gViewerWindow->setCursor(UI_CURSOR_WAIT);
114 }
115 return TRUE;
116}
117
118
119BOOL LLProgressView::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
120{
121 if( getVisible() )
122 {
123 // Suck up all keystokes except CTRL-Q.
124 if( ('Q' == key) && (MASK_CONTROL == mask) )
125 {
126 app_request_quit();
127 }
128 return TRUE;
129 }
130 return FALSE;
131}
132
133void LLProgressView::setVisible(BOOL visible)
134{
135 if (getVisible() && !visible)
136 {
137 mFadeTimer.start();
138 }
139 else if (!getVisible() && visible)
140 {
141 gFocusMgr.setTopView(this, NULL);
142 mFadeTimer.stop();
143 mProgressTimer.start();
144 LLView::setVisible(visible);
145 }
146}
147
148
149void LLProgressView::draw()
150{
151 static LLTimer timer;
152
153 if (gNoRender)
154 {
155 return;
156 }
157
158 // Make sure the progress view always fills the entire window.
159 S32 width = gViewerWindow->getWindowWidth();
160 S32 height = gViewerWindow->getWindowHeight();
161 if( (width != mRect.getWidth()) || (height != mRect.getHeight()) )
162 {
163 reshape( width, height );
164 }
165
166 // Paint bitmap if we've got one
167 if (mDrawBackground)
168 {
169 glPushMatrix();
170 if (gStartImageGL)
171 {
172 LLGLSUIDefault gls_ui;
173 LLViewerImage::bindTexture(gStartImageGL);
174 glColor4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f);
175 F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight;
176 F32 view_aspect = (F32)width / (F32)height;
177 // stretch image to maintain aspect ratio
178 if (image_aspect > view_aspect)
179 {
180 glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * width, 0.f, 0.f);
181 glScalef(image_aspect / view_aspect, 1.f, 1.f);
182 }
183 else
184 {
185 glTranslatef(0.f, -0.5f * (view_aspect / image_aspect - 1.f) * height, 0.f);
186 glScalef(1.f, view_aspect / image_aspect, 1.f);
187 }
188 gl_rect_2d_simple_tex( mRect.getWidth(), mRect.getHeight() );
189 gStartImageGL->unbindTexture(0, GL_TEXTURE_2D);
190 }
191 else
192 {
193 LLGLSNoTexture gls_no_texture;
194 glColor4f(0.f, 0.f, 0.f, 1.f);
195 gl_rect_2d(mRect);
196 }
197 glPopMatrix();
198 }
199
200 if (mFadeTimer.getStarted())
201 {
202 LLView::draw();
203 if (mFadeTimer.getElapsedTimeF32() > FADE_IN_TIME)
204 {
205 gFocusMgr.removeTopViewWithoutCallback(this);
206 LLView::setVisible(FALSE);
207 gStartImageGL = NULL;
208 }
209 return;
210 }
211
212 S32 line_x = mRect.getWidth() / 2;
213 S32 line_one_y = mRect.getHeight() / 2 + 64;
214 const S32 LINE_SPACING = 25;
215 S32 line_two_y = line_one_y - LINE_SPACING;
216 const LLFontGL* font = LLFontGL::sSansSerif;
217
218 LLViewerImage* shadow_imagep = gImageList.getImage(LLUUID(gViewerArt.getString("rounded_square_soft.tga")), MIPMAP_FALSE, TRUE);
219 LLViewerImage* bar_imagep = gImageList.getImage(LLUUID(gViewerArt.getString("rounded_square.tga")), MIPMAP_FALSE, TRUE);
220
221 //LLColor4 background_color = gColors.getColor("DefaultShadowLight");
222 LLColor4 background_color = LLColor4(0.3254f, 0.4f, 0.5058f, 1.0f);
223
224 F32 alpha = 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32()));
225 // background_color.mV[3] = background_color.mV[3]*alpha;
226
227 LLString top_line = gSecondLife;
228
229 font->renderUTF8(top_line, 0,
230 line_x, line_one_y,
231 LLColor4::white,
232 LLFontGL::HCENTER, LLFontGL::BASELINE,
233 LLFontGL::DROP_SHADOW);
234 font->renderUTF8(mText, 0,
235 line_x, line_two_y,
236 LLColor4::white,
237 LLFontGL::HCENTER, LLFontGL::BASELINE,
238 LLFontGL::DROP_SHADOW);
239
240 S32 bar_bottom = line_two_y - 30;
241 S32 bar_height = 18;
242 S32 bar_width = mRect.getWidth() * 2 / 3;
243 S32 bar_left = (mRect.getWidth() / 2) - (bar_width / 2);
244
245 gl_draw_scaled_image_with_border(
246 bar_left + 2,
247 bar_bottom - 2,
248 16,
249 16,
250 bar_width,
251 bar_height,
252 shadow_imagep,
253 gColors.getColor("ColorDropShadow"));
254
255 gl_draw_scaled_image_with_border(
256 bar_left,
257 bar_bottom,
258 16,
259 16,
260 bar_width,
261 bar_height,
262 bar_imagep,
263 LLColor4(0.7f, 0.7f, 0.8f, 1.0f));
264
265 gl_draw_scaled_image_with_border(bar_left + 2, bar_bottom + 2, 16, 16,
266 bar_width - 4, bar_height - 4,
267 bar_imagep,
268 background_color);
269
270 LLColor4 bar_color = LLColor4(0.5764f, 0.6627f, 0.8352f, 1.0f);
271 bar_color.mV[3] = alpha;
272 gl_draw_scaled_image_with_border(bar_left + 2, bar_bottom + 2, 16, 16,
273 llround((bar_width - 4) * (mPercentDone / 100.f)), bar_height - 4,
274 bar_imagep,
275 bar_color);
276
277 S32 line_three_y = line_two_y - LINE_SPACING * 3;
278
279 // draw the message if there is one
280 if(!mMessage.empty())
281 {
282 LLWString wmessage = utf8str_to_wstring(mMessage);
283 const F32 MAX_PIXELS = 640.0f;
284 S32 chars_left = wmessage.length();
285 S32 chars_this_time = 0;
286 S32 msgidx = 0;
287 while(chars_left > 0)
288 {
289 chars_this_time = font->maxDrawableChars(wmessage.substr(msgidx).c_str(),
290 MAX_PIXELS,
291 MAX_STRING - 1,
292 TRUE);
293 LLWString wbuffer = wmessage.substr(msgidx, chars_this_time);
294 font->render(wbuffer, 0,
295 (F32)line_x, (F32)line_three_y,
296 LLColor4::white,
297 LLFontGL::HCENTER, LLFontGL::BASELINE,
298 LLFontGL::DROP_SHADOW);
299 msgidx += chars_this_time;
300 chars_left -= chars_this_time;
301 line_three_y -= LINE_SPACING;
302 }
303 }
304
305 // draw children
306 LLView::draw();
307}
308
309void LLProgressView::setText(const LLString& text)
310{
311 mText = text;
312}
313
314void LLProgressView::setPercent(const F32 percent)
315{
316 mPercentDone = llclamp(percent, 0.f, 100.f);
317}
318
319void LLProgressView::setMessage(const LLString& msg)
320{
321 mMessage = msg;
322}
323
324void LLProgressView::setCancelButtonVisible(BOOL b, const LLString& label)
325{
326 mCancelBtn->setVisible( b );
327 mCancelBtn->setEnabled( b );
328 mCancelBtn->setLabelSelected(label);
329 mCancelBtn->setLabelUnselected(label);
330}
331
332// static
333void LLProgressView::onCancelButtonClicked(void*)
334{
335 if (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE)
336 {
337 app_request_quit();
338 }
339 else
340 {
341 gAgent.teleportCancel();
342 sInstance->mCancelBtn->setEnabled(FALSE);
343 sInstance->setVisible(FALSE);
344 }
345}