diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llnotify.cpp | 145 |
1 files changed, 132 insertions, 13 deletions
diff --git a/linden/indra/newview/llnotify.cpp b/linden/indra/newview/llnotify.cpp index e2626b4..7822d00 100644 --- a/linden/indra/newview/llnotify.cpp +++ b/linden/indra/newview/llnotify.cpp | |||
@@ -71,6 +71,16 @@ void LLNotifyBox::showXml( const LLString& xml_desc, notify_callback_t callback, | |||
71 | return showXml(xml_desc, LLString::format_map_t(), callback, user_data); | 71 | return showXml(xml_desc, LLString::format_map_t(), callback, user_data); |
72 | } | 72 | } |
73 | 73 | ||
74 | |||
75 | //static | ||
76 | void LLNotifyBox::showXml( const LLString& xml_desc, const LLString::format_map_t& args, BOOL is_caution, | ||
77 | notify_callback_t callback, void *user_data) | ||
78 | { | ||
79 | // for script permission prompts | ||
80 | LLNotifyBox* notify = new LLNotifyBox(xml_desc, args, callback, user_data, is_caution); | ||
81 | gNotifyBoxView->addChild(notify); | ||
82 | } | ||
83 | |||
74 | //static | 84 | //static |
75 | void LLNotifyBox::showXml( const LLString& xml_desc, const LLString::format_map_t& args, | 85 | void LLNotifyBox::showXml( const LLString& xml_desc, const LLString::format_map_t& args, |
76 | notify_callback_t callback, void *user_data) | 86 | notify_callback_t callback, void *user_data) |
@@ -85,7 +95,7 @@ void LLNotifyBox::showXml( const LLString& xml_desc, const LLString::format_map_ | |||
85 | const option_list_t& options, | 95 | const option_list_t& options, |
86 | BOOL layout_script_dialog) | 96 | BOOL layout_script_dialog) |
87 | { | 97 | { |
88 | LLNotifyBox* notify = new LLNotifyBox(xml_desc, args, callback, user_data, options, layout_script_dialog); | 98 | LLNotifyBox* notify = new LLNotifyBox(xml_desc, args, callback, user_data, FALSE, options, layout_script_dialog); |
89 | gNotifyBoxView->addChild(notify); | 99 | gNotifyBoxView->addChild(notify); |
90 | } | 100 | } |
91 | 101 | ||
@@ -99,7 +109,7 @@ void LLNotifyBox::cleanup() | |||
99 | //--------------------------------------------------------------------------- | 109 | //--------------------------------------------------------------------------- |
100 | 110 | ||
101 | LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& args, | 111 | LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& args, |
102 | notify_callback_t callback, void* user_data, | 112 | notify_callback_t callback, void* user_data, BOOL is_caution, |
103 | const option_list_t& extra_options, | 113 | const option_list_t& extra_options, |
104 | BOOL layout_script_dialog) | 114 | BOOL layout_script_dialog) |
105 | : LLPanel("notify", LLRect(), BORDER_NO), | 115 | : LLPanel("notify", LLRect(), BORDER_NO), |
@@ -152,9 +162,19 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
152 | options.insert(options.end(), extra_options.begin(), extra_options.end()); | 162 | options.insert(options.end(), extra_options.begin(), extra_options.end()); |
153 | 163 | ||
154 | // initialize | 164 | // initialize |
155 | 165 | ||
156 | mIsTip = xml_template->mIsTip; | 166 | mIsTip = xml_template->mIsTip; |
157 | mIsFocusRoot = !mIsTip; | 167 | mIsFocusRoot = !mIsTip; |
168 | |||
169 | // caution flag can be set explicitly by specifying it in the | ||
170 | // call to the c'tor, or it can be set implicitly if the | ||
171 | // notify xml template specifies that it is a caution | ||
172 | // | ||
173 | // (but a tip-style notification cannot be a caution notification, | ||
174 | // since the rendering of the additional top textbox doesn't | ||
175 | // account for the special layout of a tip notification) | ||
176 | mIsCaution = ((xml_template->mIsCaution | is_caution) && (!mIsTip)); | ||
177 | |||
158 | mAnimating = TRUE; | 178 | mAnimating = TRUE; |
159 | mCallback = callback; | 179 | mCallback = callback; |
160 | mData = user_data; | 180 | mData = user_data; |
@@ -162,7 +182,7 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
162 | mDefaultOption = xml_template->mDefaultOption; | 182 | mDefaultOption = xml_template->mDefaultOption; |
163 | 183 | ||
164 | LLRect rect = mIsTip ? getNotifyTipRect(message) | 184 | LLRect rect = mIsTip ? getNotifyTipRect(message) |
165 | : getNotifyRect(mNumOptions, layout_script_dialog); | 185 | : getNotifyRect(mNumOptions, layout_script_dialog, mIsCaution); |
166 | setRect(rect); | 186 | setRect(rect); |
167 | setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT)); | 187 | setFollows(mIsTip ? (FOLLOWS_BOTTOM|FOLLOWS_RIGHT) : (FOLLOWS_TOP|FOLLOWS_RIGHT)); |
168 | setBackgroundVisible(FALSE); | 188 | setBackgroundVisible(FALSE); |
@@ -171,18 +191,57 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
171 | LLIconCtrl* icon; | 191 | LLIconCtrl* icon; |
172 | LLTextEditor* text; | 192 | LLTextEditor* text; |
173 | 193 | ||
174 | S32 x = HPAD + HPAD; | ||
175 | const S32 TOP = mRect.getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32); | 194 | const S32 TOP = mRect.getHeight() - (mIsTip ? (S32)sFont->getLineHeight() : 32); |
176 | const S32 BOTTOM = (S32)sFont->getLineHeight(); | 195 | const S32 BOTTOM = (S32)sFont->getLineHeight(); |
196 | S32 x = HPAD + HPAD; | ||
197 | S32 y = TOP; | ||
198 | |||
199 | if (mIsTip) | ||
200 | { | ||
201 | // use the tip notification icon | ||
202 | icon = new LLIconCtrl("icon", LLRect(x, y, x+32, TOP-32), "notify_tip_icon.tga"); | ||
203 | } | ||
204 | else if (mIsCaution) | ||
205 | { | ||
206 | // use the caution notification icon | ||
207 | icon = new LLIconCtrl("icon", LLRect(x, y, x+32, TOP-32), "notify_caution_icon.tga"); | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | // use the default notification icon | ||
212 | icon = new LLIconCtrl("icon", LLRect(x, y, x+32, TOP-32), "notify_box_icon.tga"); | ||
213 | } | ||
177 | 214 | ||
178 | icon = new LLIconCtrl("icon", | ||
179 | LLRect(x, TOP, x+32, TOP-32), | ||
180 | mIsTip ? "notify_tip_icon.tga" : "notify_box_icon.tga"); | ||
181 | icon->setMouseOpaque(FALSE); | 215 | icon->setMouseOpaque(FALSE); |
182 | addChild(icon); | 216 | addChild(icon); |
183 | 217 | ||
184 | x += HPAD + HPAD + 32; | 218 | x += HPAD + HPAD + 32; |
185 | 219 | ||
220 | // add a caution textbox at the top of a caution notification | ||
221 | LLTextBox* caution_box = NULL; | ||
222 | if (mIsCaution) | ||
223 | { | ||
224 | S32 caution_height = ((S32)sFont->getLineHeight() * 2) + VPAD; | ||
225 | caution_box = new LLTextBox( | ||
226 | "caution_box", | ||
227 | LLRect(x, y, mRect.getWidth() - 2, caution_height), | ||
228 | "", | ||
229 | sFont, | ||
230 | FALSE); | ||
231 | |||
232 | caution_box->setFontStyle(LLFontGL::BOLD); | ||
233 | caution_box->setColor(gColors.getColor("NotifyCautionWarnColor")); | ||
234 | caution_box->setBackgroundColor(gColors.getColor("NotifyCautionBoxColor")); | ||
235 | caution_box->setBorderVisible(FALSE); | ||
236 | caution_box->setWrappedText(LLNotifyBox::getTemplateMessage("ScriptQuestionCautionWarn")); | ||
237 | |||
238 | addChild(caution_box); | ||
239 | |||
240 | // adjust the vertical position of the next control so that | ||
241 | // it appears below the caution textbox | ||
242 | y = y - caution_height; | ||
243 | } | ||
244 | |||
186 | const S32 BOTTOM_PAD = VPAD * 3; | 245 | const S32 BOTTOM_PAD = VPAD * 3; |
187 | const S32 BTN_TOP = BOTTOM_PAD + (((mNumOptions-1+2)/3)) * (BTN_HEIGHT+VPAD); | 246 | const S32 BTN_TOP = BOTTOM_PAD + (((mNumOptions-1+2)/3)) * (BTN_HEIGHT+VPAD); |
188 | 247 | ||
@@ -194,7 +253,7 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
194 | DB_INV_ITEM_NAME_BUF_SIZE; // For script dialogs: add space for title. | 253 | DB_INV_ITEM_NAME_BUF_SIZE; // For script dialogs: add space for title. |
195 | 254 | ||
196 | text = new LLTextEditor("box", | 255 | text = new LLTextEditor("box", |
197 | LLRect(x, TOP, mRect.getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16), | 256 | LLRect(x, y, mRect.getWidth()-2, mIsTip ? BOTTOM : BTN_TOP+16), |
198 | MAX_LENGTH, | 257 | MAX_LENGTH, |
199 | message, | 258 | message, |
200 | sFont, | 259 | sFont, |
@@ -235,7 +294,9 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
235 | addChild(btn); | 294 | addChild(btn); |
236 | mNextBtn = btn; | 295 | mNextBtn = btn; |
237 | 296 | ||
238 | S32 btn_width = 90; | 297 | // make caution notification buttons slightly narrower |
298 | // so that 3 of them can fit without overlapping the "next" button | ||
299 | S32 btn_width = mIsCaution? 84 : 90; | ||
239 | LLRect btn_rect; | 300 | LLRect btn_rect; |
240 | 301 | ||
241 | for (S32 i = 0; i < mNumOptions; i++) | 302 | for (S32 i = 0; i < mNumOptions; i++) |
@@ -271,6 +332,13 @@ LLNotifyBox::LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& | |||
271 | 332 | ||
272 | btn = new LLButton(options[i], btn_rect, "", onClickButton, userdata); | 333 | btn = new LLButton(options[i], btn_rect, "", onClickButton, userdata); |
273 | btn->setFont(font); | 334 | btn->setFont(font); |
335 | |||
336 | if (mIsCaution) | ||
337 | { | ||
338 | btn->setImageColor(LLUI::sColorsGroup->getColor("ButtonCautionImageColor")); | ||
339 | btn->setDisabledImageColor(LLUI::sColorsGroup->getColor("ButtonCautionImageColor")); | ||
340 | } | ||
341 | |||
274 | addChild(btn, -1); | 342 | addChild(btn, -1); |
275 | 343 | ||
276 | if (i == mDefaultOption) | 344 | if (i == mDefaultOption) |
@@ -374,7 +442,8 @@ void LLNotifyBox::drawBackground() const | |||
374 | { | 442 | { |
375 | LLGLSTexture texture_enabled; | 443 | LLGLSTexture texture_enabled; |
376 | LLViewerImage::bindTexture(imagep); | 444 | LLViewerImage::bindTexture(imagep); |
377 | LLColor4 color = gColors.getColor("NotifyBoxColor"); | 445 | // set proper background color depending on whether notify box is a caution or not |
446 | LLColor4 color = mIsCaution? gColors.getColor("NotifyCautionBoxColor") : gColors.getColor("NotifyBoxColor"); | ||
378 | if(gFocusMgr.childHasKeyboardFocus( this )) | 447 | if(gFocusMgr.childHasKeyboardFocus( this )) |
379 | { | 448 | { |
380 | const S32 focus_width = 2; | 449 | const S32 focus_width = 2; |
@@ -387,7 +456,12 @@ void LLNotifyBox::drawBackground() const | |||
387 | color = gColors.getColor("ColorDropShadow"); | 456 | color = gColors.getColor("ColorDropShadow"); |
388 | glColor4fv(color.mV); | 457 | glColor4fv(color.mV); |
389 | gl_segmented_rect_2d_tex(0, mRect.getHeight(), mRect.getWidth(), 0, imagep->getWidth(), imagep->getHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); | 458 | gl_segmented_rect_2d_tex(0, mRect.getHeight(), mRect.getWidth(), 0, imagep->getWidth(), imagep->getHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); |
390 | color = gColors.getColor("NotifyBoxColor"); | 459 | |
460 | if( mIsCaution ) | ||
461 | color = gColors.getColor("NotifyCautionBoxColor"); | ||
462 | else | ||
463 | color = gColors.getColor("NotifyBoxColor"); | ||
464 | |||
391 | glColor4fv(color.mV); | 465 | glColor4fv(color.mV); |
392 | gl_segmented_rect_2d_tex(1, mRect.getHeight()-1, mRect.getWidth()-1, 1, imagep->getWidth(), imagep->getHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); | 466 | gl_segmented_rect_2d_tex(1, mRect.getHeight()-1, mRect.getWidth()-1, 1, imagep->getWidth(), imagep->getHeight(), 16, mIsTip ? ROUNDED_RECT_TOP : ROUNDED_RECT_BOTTOM); |
393 | } | 467 | } |
@@ -467,9 +541,17 @@ void LLNotifyBox::moveToBack() | |||
467 | 541 | ||
468 | 542 | ||
469 | // static | 543 | // static |
470 | LLRect LLNotifyBox::getNotifyRect(S32 num_options, BOOL layout_script_dialog) | 544 | LLRect LLNotifyBox::getNotifyRect(S32 num_options, BOOL layout_script_dialog, BOOL is_caution) |
471 | { | 545 | { |
472 | S32 notify_height = gSavedSettings.getS32("NotifyBoxHeight"); | 546 | S32 notify_height = gSavedSettings.getS32("NotifyBoxHeight"); |
547 | if (is_caution) | ||
548 | { | ||
549 | // make caution-style dialog taller to accomodate extra text, | ||
550 | // as well as causing the accept/decline buttons to be drawn | ||
551 | // in a different position, to help prevent "quick-click-through" | ||
552 | // of many permissions prompts | ||
553 | notify_height = gSavedSettings.getS32("PermissionsCautionNotifyBoxHeight"); | ||
554 | } | ||
473 | const S32 NOTIFY_WIDTH = gSavedSettings.getS32("NotifyBoxWidth"); | 555 | const S32 NOTIFY_WIDTH = gSavedSettings.getS32("NotifyBoxWidth"); |
474 | 556 | ||
475 | const S32 TOP = gNotifyBoxView->getRect().getHeight(); | 557 | const S32 TOP = gNotifyBoxView->getRect().getHeight(); |
@@ -588,6 +670,17 @@ void LLNotifyBox::onClickButton(void* data) | |||
588 | LLNotifyBox* self = self_and_button->mSelf; | 670 | LLNotifyBox* self = self_and_button->mSelf; |
589 | S32 button = self_and_button->mButton; | 671 | S32 button = self_and_button->mButton; |
590 | 672 | ||
673 | // for caution notifications, check if the last button in the prompt was clicked | ||
674 | // unless it is the only button, in which case it will just be an "OK" button | ||
675 | if ((self->mIsCaution) && (button > 0) && (button == (self->mNumOptions - 1))) | ||
676 | { | ||
677 | // show an alert dialog containing more explanation about the debit permission | ||
678 | LLAlertDialog::showXml("DebitPermissionDetails"); | ||
679 | |||
680 | // keep this notification open | ||
681 | return; | ||
682 | } | ||
683 | |||
591 | if (self->mCallback) | 684 | if (self->mCallback) |
592 | { | 685 | { |
593 | self->mCallback(button, self->mData); | 686 | self->mCallback(button, self->mData); |
@@ -620,6 +713,20 @@ const LLString& LLNotifyBox::getTemplateMessage(const LLString& xml_desc) | |||
620 | } | 713 | } |
621 | } | 714 | } |
622 | 715 | ||
716 | // method to check whether a given notify template show as a caution or not | ||
717 | BOOL LLNotifyBox::getTemplateIsCaution(const LLString& xml_desc) | ||
718 | { | ||
719 | BOOL is_caution = FALSE; | ||
720 | |||
721 | template_map_t::iterator iter = sNotifyTemplates.find(xml_desc); | ||
722 | if (iter != sNotifyTemplates.end()) | ||
723 | { | ||
724 | is_caution = iter->second->mIsCaution; | ||
725 | } | ||
726 | |||
727 | return is_caution; | ||
728 | } | ||
729 | |||
623 | //static | 730 | //static |
624 | bool LLNotifyBox::parseNotify(const LLString& xml_filename) | 731 | bool LLNotifyBox::parseNotify(const LLString& xml_filename) |
625 | { | 732 | { |
@@ -660,6 +767,18 @@ bool LLNotifyBox::parseNotify(const LLString& xml_filename) | |||
660 | { | 767 | { |
661 | xml_template->mIsTip = tip; | 768 | xml_template->mIsTip = tip; |
662 | } | 769 | } |
770 | |||
771 | // parse a bool attribute named "caution" to determine | ||
772 | // whether this notification gets cautionary special handling | ||
773 | BOOL caution = FALSE; | ||
774 | if (notify->getAttributeBOOL("caution", caution)) | ||
775 | { | ||
776 | if (xml_template) | ||
777 | { | ||
778 | xml_template->mIsCaution = caution; | ||
779 | } | ||
780 | } | ||
781 | |||
663 | 782 | ||
664 | S32 btn_idx = 0; | 783 | S32 btn_idx = 0; |
665 | for (LLXMLNode* child = notify->getFirstChild(); | 784 | for (LLXMLNode* child = notify->getFirstChild(); |