1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
/**
* @file llalertdialog.cpp
* @brief LLAlertDialog base class
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2007, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llboost.h"
#include "llalertdialog.h"
#include "llfontgl.h"
#include "llresmgr.h"
#include "lltextbox.h"
#include "llbutton.h"
#include "llcheckboxctrl.h"
#include "llkeyboard.h"
#include "llfocusmgr.h"
#include "llui.h"
#include "llxmlnode.h"
#include "lllineeditor.h"
#include "lluictrlfactory.h"
const S32 MAX_ALLOWED_MSG_WIDTH = 400;
const F32 DEFAULT_BUTTON_DELAY = 0.5f;
const S32 MSG_PAD = 8;
/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sAlertTemplates;
/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sIgnorableTemplates;
/*static*/ LLControlGroup* LLAlertDialog::sSettings = NULL;
/*static*/ std::map<LLString,LLAlertDialog*> LLAlertDialog::sUniqueActiveMap;
/*static*/ LLAlertDialog::display_callback_t LLAlertDialog::sDisplayCallback;
/*static*/ LLString LLAlertDialog::sStringSkipNextTime("Skip this dialog next time");
/*static*/ LLString LLAlertDialog::sStringAlwaysChoose("Always choose this option");
//static
LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc,
alert_callback_t callback, void *user_data)
{
LLString::format_map_t args;
return createXml(xml_desc, args, callback, user_data);
}
//static
LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc, const LLString::format_map_t& args,
alert_callback_t callback, void *user_data)
{
template_map_t::iterator iter = sAlertTemplates.find(xml_desc);
if (iter != sAlertTemplates.end())
{
LLAlertDialogTemplate* xml_template = iter->second;
// deletes itself
llwarns << "Alert: [" << xml_desc << "] " << llendl;
LLAlertDialog* dialog = new LLAlertDialog( xml_template, args, callback, user_data);
return dialog;
}
else
{
LLString::format_map_t args;
args["[ALERT_NAME]"] = xml_desc;
llwarns << "Missing Alert: [" << xml_desc << "]" << llendl;
LLAlertDialog* dialogp = LLAlertDialog::showXml("MissingAlert", args);
if (dialogp == NULL)
{
llerrs << "Bad or missing alerts.xml!" << llendl;
}
return NULL;
}
}
//static
LLAlertDialog* LLAlertDialog::showXml( const LLString& xml_desc,
alert_callback_t callback, void *user_data)
{
LLString::format_map_t args;
return showXml(xml_desc, args, callback, user_data);
}
//static
LLAlertDialog* LLAlertDialog::showXml( const LLString& xml_desc, const LLString::format_map_t& args,
alert_callback_t callback, void *user_data)
{
LLAlertDialog* dialog = createXml(xml_desc, args, callback, user_data);
return dialog && dialog->show() ? dialog : NULL;
}
//static
LLAlertDialog* LLAlertDialog::showCritical( const LLString& desc, alert_callback_t callback, void *user_data)
{
LLAlertDialogTemplate xml_template;
LLString::format_map_t args;
xml_template.mTitle = "Critical Error";
xml_template.mMessage = desc;
xml_template.mModal = TRUE;
xml_template.mOptions.push_back("Quit");
LLAlertDialog* dialog = new LLAlertDialog( &xml_template, args, callback, user_data);
return dialog && dialog->show() ? dialog : NULL;
}
//-----------------------------------------------------------------------------
// Private methods
static const S32 VPAD = 16;
static const S32 HPAD = 25;
static const S32 BTN_HPAD = 8;
static const LLFONT_ID font_name = LLFONT_SANSSERIF;
LLAlertDialog::LLAlertDialog( const LLAlertDialogTemplate* xml_template,
const LLString::format_map_t& args,
alert_callback_t callback, void *user_data)
: LLModalDialog( xml_template->mTitle, 100, 100, xml_template->mModal ), // dummy size. Will reshape below.
mCallback( callback ),
mUserData( user_data ),
mNumOptions( 0 ),
mDefaultOption( 0 ),
mOptionChosen( -1 ),
mCheck(NULL),
mUnique(xml_template->mUnique),
mIgnorable(xml_template->mIgnorable),
mLabel(xml_template->mLabel),
mIgnoreLabel(xml_template->mIgnoreLabel),
mButtonData(NULL),
mLineEditor(NULL),
mTextCallback(NULL)
{
createDialog(&(xml_template->mOptions), xml_template->mDefaultOption,
xml_template->mMessage, args,
xml_template->mEditLineText);
setTitle(xml_template->mTitle);
if (xml_template->mIgnorable)
{
if (xml_template->mIgnorable == IGNORE_USE_DEFAULT)
{
setCheckBox(sStringSkipNextTime, xml_template->mIgnoreLabel);
}
else // xml_template->mIgnorable == IGNORE_USE_SAVED
{
setCheckBox(sStringAlwaysChoose, xml_template->mIgnoreLabel);
}
}
}
// All logic for deciding not to show an alert is done here,
// so that the alert is valid until show() is called.
bool LLAlertDialog::show()
{
// If mModal, check to see if we are not displaying alerts,
// and do any application logic before showing modal alerts
if (sDisplayCallback)
{
bool show = sDisplayCallback(mModal);
if (show == false)
{
mOptionChosen = mDefaultOption;
llinfos << "Alert: " << mLabel << llendl;
delete this;
return false;
}
}
// Check to see if the user wants to ignore this alert
if (mIgnorable > 0)
{
BOOL warn = sSettings->getWarning(mIgnoreLabel);
if (!warn)
{
switch(mIgnorable)
{
case IGNORE_USE_DEFAULT:
mOptionChosen = mDefaultOption;
break;
case IGNORE_USE_SAVED:
mOptionChosen = sSettings->getS32("Default" + mIgnoreLabel);
break;
case IGNORE_SHOW_AGAIN:
break;
}
delete this;
return false;
}
}
// Check to see if we are already displaying the alert
if (mUnique)
{
std::map<LLString,LLAlertDialog*>::iterator iter = sUniqueActiveMap.find(mLabel);
if (iter != sUniqueActiveMap.end())
{
gFloaterView->bringToFront(iter->second);
mUnique = FALSE; // don't remove entry from map on destruction
delete this;
return false;
}
sUniqueActiveMap[mLabel] = this;
}
startModal();
gFloaterView->adjustToFitScreen(this, FALSE);
open(); /* Flawfinder: ignore */
setFocus(TRUE);
if (mLineEditor)
{
mLineEditor->setFocus(TRUE);
mLineEditor->selectAll();
}
if(mDefaultOption >= 0)
{
// delay before enabling default button
mDefaultBtnTimer.start();
mDefaultBtnTimer.setTimerExpirySec(DEFAULT_BUTTON_DELAY);
}
return true;
}
//static
void LLAlertDialog::format(LLString& msg, const LLString::format_map_t& args)
{
// XUI:translate!
LLString::format_map_t targs = args;
targs["[SECOND_LIFE]"] = "Second Life";
LLString::format(msg, targs);
}
void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 default_option,
const LLString& msg_in, const LLString::format_map_t& args,
const LLString& edit_text)
{
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
const LLFontGL* font = gResMgr->getRes( font_name );
const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
const S32 EDITOR_HEIGHT = 20;
// Buttons
std::vector<LLString> default_option_list;
mNumOptions = optionsp->size();
if( 0 == mNumOptions )
{
default_option_list.push_back("Close");
optionsp = &default_option_list;
default_option = 0;
mNumOptions = 1;
}
const std::vector<LLString>& options = *optionsp;
mButtonData = new ButtonData[mNumOptions];
// Calc total width of buttons
S32 button_width = 0;
S32 sp = font->getWidth("OO");
for( S32 i = 0; i < mNumOptions; i++ )
{
S32 w = S32(font->getWidth( options[i] ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
button_width = llmax( w, button_width );
}
S32 btn_total_width = button_width;
if( mNumOptions > 1 )
{
btn_total_width = (mNumOptions * button_width) + ((mNumOptions - 1) * BTN_HPAD);
}
// Message: create text box using raw string, as text has been structure deliberately
// Use size of created text box to generate dialog box size
LLString msg = msg_in;
LLAlertDialog::format( msg, args );
llwarns << "Alert: " << msg << llendl;
LLTextBox* msg_box = new LLTextBox( "Alert message", msg, (F32)MAX_ALLOWED_MSG_WIDTH, font );
const LLRect& text_rect = msg_box->getRect();
S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
S32 dialog_height = text_rect.getHeight() + 3 * VPAD + BTN_HEIGHT;
if (hasTitleBar())
{
dialog_height += LINE_HEIGHT; // room for title bar
}
if (edit_text.size() > 0)
{
dialog_width = llmax(dialog_width, S32(font->getWidth( edit_text ) + 0.99f));
dialog_height += EDITOR_HEIGHT;
}
reshape( dialog_width, dialog_height, FALSE );
S32 msg_y = mRect.getHeight() - VPAD;
if (hasTitleBar())
{
msg_y -= LINE_HEIGHT; // room for title
}
LLRect rect;
rect.setLeftTopAndSize( HPAD, msg_y, text_rect.getWidth(), text_rect.getHeight() );
msg_box->setRect( rect );
msg_box->setColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) );
addChild(msg_box);
// Buttons
S32 button_left = (mRect.getWidth() - btn_total_width) / 2;
for( S32 i = 0; i < mNumOptions; i++ )
{
LLRect button_rect;
button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );
LLButton* btn = new LLButton(
"btn", button_rect,
"","", "",
&LLAlertDialog::onButtonPressed, (void*)(&mButtonData[i]),
font,
options[i],
options[i]);
mButtonData[i].mSelf = this;
mButtonData[i].mButton = btn;
mButtonData[i].mOption = i;
addChild(btn);
if( i == default_option )
{
btn->setFocus(TRUE);
}
button_left += button_width + BTN_HPAD;
}
// (Optional) Edit Box
if (edit_text.size() > 0)
{
S32 y = VPAD + BTN_HEIGHT + VPAD/2;
mLineEditor = new LLLineEditor("lineeditor",
LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y),
edit_text,
LLFontGL::sSansSerif,
STD_STRING_STR_LEN);
addChild(mLineEditor);
}
}
bool LLAlertDialog::setCheckBox( const LLString& check_title, const LLString& check_control )
{
const LLFontGL* font = gResMgr->getRes( font_name );
const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
// Extend dialog for "check next time"
S32 max_msg_width = mRect.getWidth() - 2 * HPAD;
S32 check_width = S32(font->getWidth(check_title) + 0.99f) + 16;
max_msg_width = llmax(max_msg_width, check_width);
S32 dialog_width = max_msg_width + 2 * HPAD;
S32 dialog_height = mRect.getHeight();
dialog_height += LINE_HEIGHT;
dialog_height += LINE_HEIGHT / 2;
reshape( dialog_width, dialog_height, FALSE );
S32 msg_x = (mRect.getWidth() - max_msg_width) / 2;
LLRect check_rect;
check_rect.setOriginAndSize(msg_x, VPAD+BTN_HEIGHT+LINE_HEIGHT/2,
max_msg_width, LINE_HEIGHT);
mCheck = new LLCheckboxCtrl("check", check_rect, check_title, font);
addChild(mCheck);
// mCheck is sometimes "show again" and sometimes "hide" :-(
// If it's "Show Again", and we showed it, it must be checked. JC
if (mIgnorable == IGNORE_SHOW_AGAIN)
{
mCheck->setValue(TRUE);
}
return true;
}
void LLAlertDialog::setVisible( BOOL visible )
{
LLModalDialog::setVisible( visible );
if( visible )
{
centerOnScreen();
make_ui_sound("UISndAlert");
}
}
LLAlertDialog::~LLAlertDialog()
{
if (mOptionChosen >= 0)
{
if (mTextCallback && mLineEditor)
{
mTextCallback(mOptionChosen, mLineEditor->getText(), mUserData);
}
else if (mCallback)
{
mCallback(mOptionChosen, mUserData);
}
// Only change warn state if we actually warned.
if (mCheck
&& sSettings->getWarning(mIgnoreLabel))
{
// mCheck sometimes means "hide and do the default" and
// other times means "warn me again". Yuck. JC
BOOL check = mCheck->getValue();
switch(mIgnorable)
{
case IGNORE_USE_DEFAULT:
sSettings->setWarning(mIgnoreLabel, !check);
break;
case IGNORE_USE_SAVED:
sSettings->setWarning(mIgnoreLabel, !check);
sSettings->setS32("Default" + mIgnoreLabel, mOptionChosen);
break;
case IGNORE_SHOW_AGAIN:
sSettings->setWarning(mIgnoreLabel, check);
break;
default:
break;
}
}
}
delete[] mButtonData;
if (mUnique)
{
sUniqueActiveMap.erase(mLabel);
}
}
BOOL LLAlertDialog::hasTitleBar() const
{
return (getTitle() != "" && getTitle() != " ") // has title
|| isMinimizeable()
|| isCloseable();
}
BOOL LLAlertDialog::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent )
{
if( KEY_RETURN == key && mask == MASK_NONE )
{
// Warning: handleKeyHere may result in the default button
// being committed, which will destroy this object.
// Everything works, but the call stack will pass through
// the very end of functions that belong to deleted objects.
// Should find a less fragile way to do this.
LLModalDialog::handleKeyHere( key, mask , called_from_parent );
return TRUE;
}
else if (KEY_RIGHT == key)
{
focusNextItem(FALSE);
return TRUE;
}
else if (KEY_LEFT == key)
{
focusPrevItem(FALSE);
return TRUE;
}
else if (KEY_TAB == key && mask == MASK_NONE)
{
focusNextItem(FALSE);
return TRUE;
}
else if (KEY_TAB == key && mask == MASK_SHIFT)
{
focusPrevItem(FALSE);
return TRUE;
}
else
{
return LLModalDialog::handleKeyHere( key, mask , called_from_parent );
}
}
// virtual
void LLAlertDialog::draw()
{
// if the default button timer has just expired, activate the default button
if(mDefaultBtnTimer.hasExpired() && mDefaultBtnTimer.getStarted())
{
mDefaultBtnTimer.stop(); // prevent this block from being run more than once
setDefaultBtn(mButtonData[mDefaultOption].mButton);
}
if (getVisible())
{
LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow");
S32 shadow_lines = LLUI::sConfigGroup->getS32("DropShadowFloater");
gl_drop_shadow( 0, mRect.getHeight(), mRect.getWidth(), 0,
shadow_color, shadow_lines);
LLModalDialog::draw();
}
}
void LLAlertDialog::setOptionEnabled( S32 option, BOOL enable )
{
if( (option >= 0) && (option < mNumOptions) )
{
mButtonData[option].mButton->setEnabled( enable );
}
}
void LLAlertDialog::setEditTextCallback(alert_text_callback_t callback, void *user_data)
{
if (mLineEditor)
{
mTextCallback = callback;
mUserData = user_data;
}
else
{
llwarns << "LLAlertDialog::setEditTextCallback called on dialog with no line editor" << llendl;
}
}
void LLAlertDialog::setEditTextArgs(const LLString::format_map_t& edit_args)
{
if (mLineEditor)
{
LLString msg = mLineEditor->getText();
LLAlertDialog::format(msg, edit_args);
mLineEditor->setText(msg);
}
else
{
llwarns << "LLAlertDialog::setEditTextArgs called on dialog with no line editor" << llendl;
}
}
void LLAlertDialog::setDrawAsterixes(BOOL enable)
{
if (mLineEditor)
{
if (enable)
{
mLineEditor->clear();
}
mLineEditor->setDrawAsterixes(enable);
}
}
// static
void LLAlertDialog::onButtonPressed( void* userdata )
{
ButtonData* button_data = (ButtonData*)userdata;
LLAlertDialog* self = button_data->mSelf;
self->mOptionChosen = button_data->mOption;
self->close(); // deletes self
}
//=============================================================================
//static
const LLString& LLAlertDialog::getTemplateMessage(const LLString& xml_desc)
{
template_map_t::iterator iter = sAlertTemplates.find(xml_desc);
if (iter != sAlertTemplates.end())
{
return iter->second->mMessage;
}
else
{
return xml_desc;
}
}
//static
bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* settings, BOOL settings_only)
{
LLXMLNodePtr root;
BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
if (!success || root.isNull() || !root->hasName( "alerts" ))
{
llerrs << "Problem reading UI Alerts file: " << xml_filename << llendl;
return false;
}
BOOL add_settings = FALSE;
if (settings)
{
sSettings = settings;
add_settings = TRUE;
}
llassert(sSettings);
for (LLXMLNode* alert = root->getFirstChild();
alert != NULL; alert = alert->getNextSibling())
{
if (alert->hasName("global"))
{
LLString global_name;
if (alert->getAttributeString("name", global_name))
{
if (global_name == "skipnexttime")
{
sStringSkipNextTime = alert->getTextContents();
}
else if (global_name == "alwayschoose")
{
sStringAlwaysChoose = alert->getTextContents();
}
}
continue;
}
if (!alert->hasName("alert"))
{
continue;
}
LLAlertDialogTemplate* xml_template = settings_only ? NULL : new LLAlertDialogTemplate;
// name=
LLString alert_name;
if (alert->getAttributeString("name", alert_name))
{
if (xml_template)
{
xml_template->mLabel = alert_name;
}
}
else
{
llwarns << "Unable to parse alert with no name" << llendl;
delete xml_template;
continue;
}
// title=
LLString title;
if (alert->getAttributeString("title", title))
{
if (xml_template)
{
xml_template->mTitle = title;
}
}
// modal=
BOOL modal;
if (alert->getAttributeBOOL("modal", modal))
{
if (xml_template)
{
xml_template->mModal = modal;
}
}
// unique=
BOOL unique;
if (alert->getAttributeBOOL("unique", unique))
{
if (xml_template)
{
xml_template->mUnique = unique;
}
}
S32 default_option = 0;
BOOL nodefault;
if (alert->getAttributeBOOL("nodefault", nodefault))
{
if (nodefault)
{
if (xml_template)
{
xml_template->mDefaultOption = -1;
}
default_option = -1;
}
}
S32 btn_idx = 0;
for (LLXMLNode* child = alert->getFirstChild();
child != NULL; child = child->getNextSibling())
{
// <message>
if (child->hasName("message"))
{
if (xml_template)
{
xml_template->mMessage = child->getTextContents();
}
}
// <option>
if (child->hasName("option"))
{
LLString label = child->getTextContents();
BOOL is_default = FALSE;
child->getAttributeBOOL("default", is_default);
LLString ignore_text;
if (!child->getAttributeString("ignore", ignore_text))
{
ignore_text = label;
}
if (xml_template)
{
xml_template->addOption(label, ignore_text, is_default);
}
if (is_default)
{
default_option = btn_idx;
}
btn_idx++;
}
// <editline>
if (child->hasName("editline"))
{
if (xml_template)
{
xml_template->mEditLineText = child->getTextContents();
if (xml_template->mEditLineText.empty())
{
xml_template->mEditLineText = " ";
}
}
}
// <ignore>
if (child->hasName("ignore"))
{
LLString ignore_text = child->getTextContents();
// label=
LLString name;
child->getAttributeString("name", name);
//always set to alert_name for the sake of i18n
//if (name.empty())
name = alert_name;
if (xml_template)
{
xml_template->mIgnorable = LLAlertDialog::IGNORE_USE_DEFAULT;
xml_template->mIgnoreListText = ignore_text;
xml_template->mIgnoreLabel = name;
}
if (!ignore_text.empty())
{
if (add_settings)
{
settings->addWarning(name);
}
if (xml_template)
{
sIgnorableTemplates[name] = xml_template; // will override any previous entry
}
}
// save_option=
BOOL save_option = FALSE;
child->getAttributeBOOL("save_option", save_option);
if (save_option)
{
if (xml_template)
{
xml_template->mIgnorable = LLAlertDialog::IGNORE_USE_SAVED;
}
if (add_settings)
{
settings->declareS32("Default" + name, default_option, "Default option number for this alert dialog");
}
}
}
}
if (xml_template)
{
xml_template->mDefaultOption = default_option;
sAlertTemplates[xml_template->mLabel] = xml_template;
}
}
return true;
}
|