llpanelmsgs.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpanelmsgs.h"
00035 
00036 #include "llscrolllistctrl.h"
00037 #include "llviewerwindow.h"
00038 #include "llviewercontrol.h"
00039 #include "llvieweruictrlfactory.h"
00040 #include "llfirstuse.h"
00041 
00042 class LLPopupData
00043 {
00044 public:
00045         LLPopupData() : mShowNewInventory(FALSE), mAutoAcceptNewInventory(FALSE) { }
00046 
00047         BOOL mShowNewInventory;
00048         BOOL mAutoAcceptNewInventory;
00049 };
00050 
00051 LLPopupData sPopupData;
00052 
00053 //-----------------------------------------------------------------------------
00054 LLPanelMsgs::LLPanelMsgs() : 
00055         LLPanel("Messages Panel"),
00056         mDisabledPopups( NULL ),
00057         mEnabledPopups( NULL )
00058 {
00059         gUICtrlFactory->buildPanel(this, "panel_preferences_popups.xml");
00060 }
00061 
00062 
00063 LLPanelMsgs::~LLPanelMsgs()
00064 { }
00065 
00066 //-----------------------------------------------------------------------------
00067 // postBuild()
00068 //-----------------------------------------------------------------------------
00069 BOOL LLPanelMsgs::postBuild()
00070 {
00071         mDisabledPopups = LLViewerUICtrlFactory::getScrollListByName(this, "disabled_popups");
00072         mEnabledPopups = LLViewerUICtrlFactory::getScrollListByName(this, "enabled_popups");
00073         childSetAction("enable_popup", onClickEnablePopup, this);
00074         childSetAction("reset_dialogs_btn", onClickResetDialogs, this);
00075         childSetAction("skip_dialogs_btn", onClickSkipDialogs, this);
00076         buildLists();
00077 
00078         sPopupData.mAutoAcceptNewInventory = gSavedSettings.getBOOL("AutoAcceptNewInventory");
00079         sPopupData.mShowNewInventory = gSavedSettings.getBOOL("ShowNewInventory");
00080 
00081         return TRUE;
00082 }
00083 
00084 void LLPanelMsgs::buildLists()
00085 {
00086         if ( mDisabledPopups )
00087                 mDisabledPopups->deleteAllItems();
00088 
00089         if ( mEnabledPopups )
00090                 mEnabledPopups->deleteAllItems();
00091 
00092         for (LLAlertDialog::template_map_t::iterator iter = LLAlertDialog::sIgnorableTemplates.begin();
00093                  iter != LLAlertDialog::sIgnorableTemplates.end(); ++iter)
00094         {
00095                 LLAlertDialogTemplate* alert_temp = iter->second;
00096                 S32 ignore = alert_temp->getIgnore();
00097 
00098                 LLSD row;
00099                 row["columns"][0]["value"] = alert_temp->mIgnoreListText;
00100                 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00101                 row["columns"][0]["width"] = 300;
00102 
00103                 LLScrollListItem* item = NULL;
00104 
00105 
00106                 if (ignore)
00107                 {
00108                         if (ignore == LLAlertDialog::IGNORE_USE_SAVED)
00109                         {
00110                                 S32 arg = LLUI::sConfigGroup->getS32("Default" + alert_temp->mIgnoreLabel);
00111                                 row["columns"][1]["value"] = alert_temp->mOptionDefaultText[arg];
00112                                 row["columns"][1]["font"] = "SANSSERIF_SMALL";
00113                                 row["columns"][1]["width"] = 160;
00114                         }
00115                         if (mDisabledPopups)
00116                         {
00117                                 item = mDisabledPopups->addElement(row,
00118                                                                    ADD_SORTED);
00119                         }
00120                         else
00121                         {
00122                                 llwarns << "(ignore) but also (!mDisabledPopups)" << llendl;
00123                         }
00124                 }
00125                 else
00126                 {
00127                         if (mEnabledPopups)
00128                         {
00129                                 item = mEnabledPopups->addElement(row,
00130                                                                   ADD_SORTED);
00131                         }
00132                         else
00133                         {
00134                                 llwarns << "(!ignore) but also (!mEnabledPopups)" << llendl;
00135                         }
00136                 }
00137 
00138                 if (item)
00139                 {
00140                         item->setUserdata((void*)&iter->first);
00141                 }
00142         }       
00143 }
00144 
00145 void LLPanelMsgs::draw()
00146 {
00147         if (mDisabledPopups->getFirstSelected())
00148         {
00149                 childEnable("enable_popup");
00150         }
00151         else
00152         {
00153                 childDisable("enable_popup");
00154         }
00155 
00156         LLPanel::draw();
00157 }
00158 
00159 
00160 void LLPanelMsgs::apply()
00161 {
00162 }
00163 
00164 
00165 void LLPanelMsgs::cancel()
00166 {
00167         gSavedSettings.setBOOL("ShowNewInventory", sPopupData.mShowNewInventory);
00168         gSavedSettings.setBOOL("AutoAcceptNewInventory", sPopupData.mAutoAcceptNewInventory);
00169 }
00170 
00171 void LLPanelMsgs::resetAllIgnored()
00172 {
00173         for(LLAlertDialog::template_map_t::iterator iter = LLAlertDialog::sIgnorableTemplates.begin();
00174                 iter != LLAlertDialog::sIgnorableTemplates.end(); ++iter)
00175         {
00176                 LLAlertDialogTemplate* alert_temp = iter->second;
00177                 S32 ignore = alert_temp->getIgnore();
00178                 if(ignore)
00179                         alert_temp->setIgnore(false);
00180         }
00181 }
00182 
00183 void LLPanelMsgs::setAllIgnored()
00184 {
00185         for(LLAlertDialog::template_map_t::iterator iter = LLAlertDialog::sIgnorableTemplates.begin();
00186                 iter != LLAlertDialog::sIgnorableTemplates.end(); ++iter)
00187         {
00188                 LLAlertDialogTemplate* alert_temp = iter->second;
00189                 alert_temp->setIgnore(true);
00190         }
00191 }
00192 
00193 //static 
00194 void LLPanelMsgs::onClickEnablePopup(void* user_data)
00195 {
00196         LLPanelMsgs* panelp = (LLPanelMsgs*)user_data;
00197 
00198         std::vector<LLScrollListItem*> items = panelp->mDisabledPopups->getAllSelected();
00199         std::vector<LLScrollListItem*>::iterator itor;
00200         for (itor = items.begin(); itor != items.end(); ++itor)
00201         {
00202                 LLAlertDialog::template_map_t::iterator found_alert = LLAlertDialog::sAlertTemplates.find(*(LLString*)((*itor)->getUserdata()));
00203                 if (found_alert != LLAlertDialog::sAlertTemplates.end())
00204                 {
00205                         LLAlertDialogTemplate* alert_temp = LLAlertDialog::sAlertTemplates[*(LLString*)((*itor)->getUserdata())];
00206                         gSavedSettings.setWarning(alert_temp->mIgnoreLabel, TRUE);
00207                 }
00208         }
00209 
00210         panelp->buildLists();
00211 }
00212 
00213 void callback_reset_dialogs(S32 option, void* data)
00214 {
00215         if (0 == option)
00216         {
00217                 LLPanelMsgs* panelp = (LLPanelMsgs*)data;
00218                 if ( panelp )
00219                 {
00220                         panelp->resetAllIgnored();
00221                         LLFirstUse::resetFirstUse();
00222                         panelp->buildLists();
00223                 }
00224         }
00225 }
00226 
00227 // static
00228 void LLPanelMsgs::onClickResetDialogs(void* user_data)
00229 {
00230         gViewerWindow->alertXml("ResetShowNextTimeDialogs",callback_reset_dialogs,user_data);
00231 }
00232 
00233 void callback_skip_dialogs(S32 option, void* data)
00234 {
00235         if (0 == option)
00236         {
00237                 LLPanelMsgs* panelp = (LLPanelMsgs*)data;
00238                 if ( panelp )
00239                 {
00240                         panelp->setAllIgnored();
00241                         LLFirstUse::disableFirstUse();
00242                         panelp->buildLists();
00243                 }
00244         }
00245 }
00246 
00247 // static
00248 void LLPanelMsgs::onClickSkipDialogs(void* user_data)
00249 {
00250         gViewerWindow->alertXml("SkipShowNextTimeDialogs", callback_skip_dialogs, user_data);
00251 }

Generated on Thu Jul 1 06:08:59 2010 for Second Life Viewer by  doxygen 1.4.7