00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llpanelgeneral.h"
00035
00036
00037 #include "llerror.h"
00038 #include "llrect.h"
00039 #include "llfontgl.h"
00040 #include "message.h"
00041 #include "lluictrlfactory.h"
00042
00043
00044 #include "llagent.h"
00045 #include "llviewerwindow.h"
00046 #include "llcolorswatch.h"
00047 #include "llcombobox.h"
00048 #include "llconsole.h"
00049 #include "lllineeditor.h"
00050 #include "llpanellogin.h"
00051 #include "llnetmap.h"
00052 #include "llresmgr.h"
00053 #include "llspinctrl.h"
00054 #include "lltextbox.h"
00055 #include "llui.h"
00056 #include "llurlsimstring.h"
00057 #include "llviewercontrol.h"
00058 #include "llappviewer.h"
00059 #include "llurlsimstring.h"
00060 #include "llappviewer.h"
00061
00062 #include "llcheckboxctrl.h"
00063 #include "llradiogroup.h"
00064
00065
00066
00067
00068 void set_crash_behavior(LLUICtrl* ctrl, void* data);
00069 void set_start_location(LLUICtrl* ctrl, void* data);
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 static void set_render_name_fade_out(LLUICtrl* ctrl, void* data)
00080 {
00081 LLComboBox* combo = (LLComboBox*)ctrl;
00082 if (!combo) return;
00083 gSavedSettings.setS32("RenderName", combo->getCurrentIndex() );
00084 }
00085
00086 void set_crash_behavior(LLUICtrl* ctrl, void* data)
00087 {
00088 LLAppViewer::instance()->setCrashBehavior(((LLComboBox*) ctrl)->getCurrentIndex());
00089 }
00090
00091 void set_language(LLUICtrl* ctrl, void* data)
00092 {
00093 gSavedSettings.setString("Language", ctrl->getValue().asString());
00094 }
00095
00096 void LLPanelGeneral::set_start_location(LLUICtrl* ctrl, void* data)
00097 {
00098 LLURLSimString::setString(ctrl->getValue().asString());
00099 }
00100
00101 void LLPanelGeneral::set_specific_start_location(LLLineEditor* line_editor, void* data)
00102 {
00103 LLURLSimString::setString(line_editor->getValue().asString());
00104 }
00105
00106 LLPanelGeneral::LLPanelGeneral()
00107 {
00108 LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_general.xml");
00109 }
00110
00111 BOOL LLPanelGeneral::postBuild()
00112 {
00113 childSetCommitCallback("fade_out_combobox", set_render_name_fade_out);
00114
00115 LLString region_name_prompt = getString("region_name_prompt");
00116
00117
00118
00119 LLComboBox* combo = getChild<LLComboBox>( "location_combobox");
00120 if (combo)
00121 {
00122 if (!LLURLSimString::sInstance.mSimString.empty())
00123 {
00124 combo->setTextEntry(LLURLSimString::sInstance.mSimString);
00125 }
00126
00127 BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
00128 if (!LLURLSimString::sInstance.mSimString.empty())
00129 {
00130 combo->add( LLURLSimString::sInstance.mSimString );
00131 combo->setCurrentByIndex( 2 );
00132 }
00133 else
00134 {
00135 combo->add( region_name_prompt );
00136 combo->setCurrentByIndex( login_last ? 1 : 0 );
00137 }
00138 combo->setCommitCallback( &set_start_location );
00139 combo->setTextEntryCallback( &set_specific_start_location );
00140 }
00141
00142
00143 childSetCommitCallback("show_location_checkbox", &LLPanelGeneral::clickShowStartLocation);
00144
00145 combo = getChild<LLComboBox>( "crash_behavior_combobox");
00146 if (combo)
00147 {
00148 combo->setCurrentByIndex( LLAppViewer::instance()->getCrashBehavior() );
00149 combo->setCommitCallback( &set_crash_behavior );
00150 }
00151
00152 childSetCommitCallback("language_combobox", set_language );
00153 childSetValue("language_combobox", gSavedSettings.getString("Language"));
00154
00155 refresh();
00156
00157 return TRUE;
00158 }
00159
00160 LLPanelGeneral::~LLPanelGeneral()
00161 {
00162
00163 }
00164
00165 void LLPanelGeneral::refresh()
00166 {
00167 LLPanel::refresh();
00168 BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
00169 LLComboBox* combo = getChild<LLComboBox>( "location_combobox");
00170 if (combo)
00171 {
00172 if (!LLURLSimString::sInstance.mSimString.empty())
00173 {
00174 combo->setCurrentByIndex( 2 );
00175 }
00176 else
00177 {
00178 combo->setCurrentByIndex( login_last ? 1 : 0 );
00179 }
00180
00181 mLoginLocation = combo->getValue().asString();
00182 }
00183
00184 mCrashBehavior = LLAppViewer::instance()->getCrashBehavior();
00185 combo = getChild<LLComboBox>( "crash_behavior_combobox");
00186 if (combo)
00187 {
00188 combo->setCurrentByIndex( LLAppViewer::instance()->getCrashBehavior() );
00189 }
00190
00191 mRenderName = gSavedSettings.getS32("RenderName");
00192 combo = getChild<LLComboBox>("fade_out_combobox");
00193 if (combo)
00194 {
00195 combo->setCurrentByIndex( mRenderName );
00196 }
00197
00198 mRenderNameHideSelf = gSavedSettings.getBOOL("RenderNameHideSelf");
00199 mSmallAvatarNames = gSavedSettings.getBOOL("SmallAvatarNames");
00200 mRenderHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle");
00201 mChatOnlineNotification = gSavedSettings.getBOOL("ChatOnlineNotification");
00202 mAFKTimeout = gSavedSettings.getF32("AFKTimeout");
00203 mMiniMapRotate = gSavedSettings.getBOOL("MiniMapRotate");
00204 mNotifyMoney = gSavedSettings.getBOOL("NotifyMoneyChange");
00205 mUseDefaultColor = gSavedSettings.getBOOL("UseDefaultColorPicker");
00206 mEffectColor = gSavedSettings.getColor4("EffectColor");
00207 mShowSearch = gSavedSettings.getBOOL("ShowSearchBar");
00208
00209 mUIScaleFactor = gSavedSettings.getF32("UIScaleFactor");
00210 mUIAutoScale = gSavedSettings.getBOOL("UIAutoScale");
00211
00212 mLanguage = gSavedSettings.getString("Language");
00213 }
00214
00215 void LLPanelGeneral::apply()
00216 {
00217 }
00218
00219 void LLPanelGeneral::cancel()
00220 {
00221 gSavedSettings.setS32("RenderName", mRenderName);
00222 gSavedSettings.setBOOL("RenderNameHideSelf", mRenderNameHideSelf );
00223 gSavedSettings.setBOOL("SmallAvatarNames", mSmallAvatarNames );
00224 gSavedSettings.setBOOL("RenderHideGroupTitle", mRenderHideGroupTitle );
00225 gSavedSettings.setBOOL("ChatOnlineNotification", mChatOnlineNotification );
00226 gSavedSettings.setF32("AFKTimeout", mAFKTimeout );
00227 gSavedSettings.setBOOL("MiniMapRotate", mMiniMapRotate );
00228 gSavedSettings.setBOOL("NotifyMoneyChange", mNotifyMoney );
00229 gSavedSettings.setBOOL("UseDefaultColorPicker", mUseDefaultColor );
00230 gSavedSettings.setBOOL("ShowSearchBar", mShowSearch);
00231 gSavedSettings.setColor4("EffectColor", mEffectColor );
00232 gSavedSettings.setF32("UIScaleFactor", mUIScaleFactor);
00233 gSavedSettings.setBOOL("UIAutoScale", mUIAutoScale);
00234 gSavedSettings.setString("Language", mLanguage);
00235
00236 LLURLSimString::setString(mLoginLocation);
00237
00238 LLAppViewer::instance()->setCrashBehavior(mCrashBehavior);
00239 }
00240
00241 void LLPanelGeneral::clickShowStartLocation(LLUICtrl*, void* user_data)
00242 {
00243 LLPanelLogin::refreshLocation( false );
00244 }