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 "llvieweruictrlfactory.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 "llpanellogin.h"
00050 #include "llnetmap.h"
00051 #include "llresmgr.h"
00052 #include "llspinctrl.h"
00053 #include "lltextbox.h"
00054 #include "llui.h"
00055 #include "llurlsimstring.h"
00056 #include "llviewercontrol.h"
00057 #include "viewer.h"
00058
00059
00060
00061
00062
00063 void set_crash_behavior(LLUICtrl* ctrl, void* data);
00064 void set_start_location(LLUICtrl* ctrl, void* data);
00065
00066
00067
00068
00069
00070
00071
00072
00073 void set_crash_behavior(LLUICtrl* ctrl, void* data)
00074 {
00075 gCrashBehavior = ((LLComboBox*) ctrl)->getCurrentIndex();
00076 gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, gCrashBehavior);
00077 }
00078
00079 void set_language(LLUICtrl* ctrl, void* data)
00080 {
00081 gSavedSettings.setString("Language", ctrl->getValue().asString());
00082 }
00083
00084 void LLPanelGeneral::set_start_location(LLUICtrl* ctrl, void* data)
00085 {
00086 LLURLSimString::setString(ctrl->getValue().asString());
00087 }
00088
00089 LLPanelGeneral::LLPanelGeneral()
00090 {
00091 gUICtrlFactory->buildPanel(this, "panel_preferences_general.xml");
00092 }
00093
00094 BOOL LLPanelGeneral::postBuild()
00095 {
00096 requires("location_combobox", WIDGET_TYPE_COMBO_BOX);
00097 requires("region_name_prompt", WIDGET_TYPE_TEXT_BOX);
00098 requires("show_location_checkbox", WIDGET_TYPE_CHECKBOX);
00099 requires("fade_out_radio", WIDGET_TYPE_RADIO_GROUP);
00100 requires("show_my_name_checkbox", WIDGET_TYPE_CHECKBOX);
00101 requires("show_my_title_checkbox", WIDGET_TYPE_CHECKBOX);
00102 requires("small_avatar_names_checkbox", WIDGET_TYPE_CHECKBOX);
00103 requires("effect_color_swatch", WIDGET_TYPE_COLOR_SWATCH);
00104 requires("afk_timeout_spinner", WIDGET_TYPE_SPINNER);
00105 requires("rotate_mini_map_checkbox", WIDGET_TYPE_CHECKBOX);
00106 requires("friends_online_notify_checkbox", WIDGET_TYPE_CHECKBOX);
00107 requires("notify_money_change_checkbox", WIDGET_TYPE_CHECKBOX);
00108 requires("use_system_color_picker_checkbox", WIDGET_TYPE_CHECKBOX);
00109 requires("crash_behavior_combobox", WIDGET_TYPE_COMBO_BOX);
00110
00111 if (!checkRequirements())
00112 {
00113 return FALSE;
00114 }
00115
00116 LLString region_name_prompt = childGetText("region_name_prompt");
00117
00118
00119
00120 LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(this, "location_combobox");
00121 if (combo)
00122 {
00123 if (!LLURLSimString::sInstance.mSimString.empty())
00124 {
00125 combo->setTextEntry(LLURLSimString::sInstance.mSimString);
00126 }
00127
00128 BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
00129 if (!LLURLSimString::sInstance.mSimString.empty())
00130 {
00131 combo->add( LLURLSimString::sInstance.mSimString );
00132 combo->setCurrentByIndex( 2 );
00133 }
00134 else
00135 {
00136 combo->add( region_name_prompt );
00137 combo->setCurrentByIndex( login_last ? 1 : 0 );
00138 }
00139 combo->setCommitCallback( &set_start_location );
00140 }
00141
00142
00143 childSetCommitCallback("show_location_checkbox", &LLPanelGeneral::clickShowStartLocation);
00144
00145 combo = LLUICtrlFactory::getComboBoxByName(this, "crash_behavior_combobox");
00146 if (combo)
00147 {
00148 combo->setCurrentByIndex( gCrashBehavior );
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 = LLUICtrlFactory::getComboBoxByName(this, "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 = gCrashBehavior;
00185 combo = LLUICtrlFactory::getComboBoxByName(this, "crash_behavior_combobox");
00186 if (combo)
00187 {
00188 combo->setCurrentByIndex( gCrashBehavior );
00189 }
00190
00191 mRenderName = gSavedSettings.getS32("RenderName");
00192 mRenderNameHideSelf = gSavedSettings.getBOOL("RenderNameHideSelf");
00193 mSmallAvatarNames = gSavedSettings.getBOOL("SmallAvatarNames");
00194 mRenderHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle");
00195 mChatOnlineNotification = gSavedSettings.getBOOL("ChatOnlineNotification");
00196 mAFKTimeout = gSavedSettings.getF32("AFKTimeout");
00197 mMiniMapRotate = gSavedSettings.getBOOL("MiniMapRotate");
00198 mNotifyMoney = gSavedSettings.getBOOL("NotifyMoneyChange");
00199 mUseDefaultColor = gSavedSettings.getBOOL("UseDefaultColorPicker");
00200 mEffectColor = gSavedSettings.getColor4("EffectColor");
00201
00202 mLanguage = gSavedSettings.getString("Language");
00203 }
00204
00205 void LLPanelGeneral::apply()
00206 {
00207 }
00208
00209 void LLPanelGeneral::cancel()
00210 {
00211 gSavedSettings.setS32("RenderName", mRenderName);
00212 gSavedSettings.setBOOL("RenderNameHideSelf", mRenderNameHideSelf );
00213 gSavedSettings.setBOOL("SmallAvatarNames", mSmallAvatarNames );
00214 gSavedSettings.setBOOL("RenderHideGroupTitle", mRenderHideGroupTitle );
00215 gSavedSettings.setBOOL("ChatOnlineNotification", mChatOnlineNotification );
00216 gSavedSettings.setF32("AFKTimeout", mAFKTimeout );
00217 gSavedSettings.setBOOL("MiniMapRotate", mMiniMapRotate );
00218 gSavedSettings.setBOOL("NotifyMoneyChange", mNotifyMoney );
00219 gSavedSettings.setBOOL("UseDefaultColorPicker", mUseDefaultColor );
00220 gSavedSettings.setColor4("EffectColor", mEffectColor );
00221 gSavedSettings.setString("Language", mLanguage);
00222
00223 LLURLSimString::setString(mLoginLocation);
00224
00225 gCrashBehavior = mCrashBehavior;
00226 gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, gCrashBehavior);
00227
00228
00229
00230 }
00231
00232 void LLPanelGeneral::clickShowStartLocation(LLUICtrl*, void* user_data)
00233 {
00234 LLPanelLogin::refreshLocation( false );
00235 }