3 // Radegast Metaverse Client
4 // Copyright (c) 2009-2012, Radegast Development Team
5 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
10 // * Redistributions of source code must retain the above copyright notice,
11 // this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 // * Neither the name of the application "Radegast", nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 using System.Collections.Generic;
34 using System.ComponentModel;
39 using System.Windows.Forms;
40 using OpenMetaverse.StructuredData;
44 public enum AutoResponseType : int
47 WhenFromNonFriend = 1,
51 public partial class frmSettings : RadegastForm
54 private static bool settingInitialized = false;
56 public static void InitSettigs(Settings s)
58 if (s["im_timestamps"].Type == OSDType.Unknown)
60 s["im_timestamps"] = OSD.FromBoolean(true);
63 if (s["rlv_enabled"].Type == OSDType.Unknown)
65 s["rlv_enabled"] = new OSDBoolean(false);
68 if (s["mu_emotes"].Type == OSDType.Unknown)
70 s["mu_emotes"] = new OSDBoolean(false);
73 if (s["friends_notification_highlight"].Type == OSDType.Unknown)
75 s["friends_notification_highlight"] = new OSDBoolean(true);
78 if (!s.ContainsKey("no_typing_anim")) s["no_typing_anim"] = OSD.FromBoolean(false);
80 if (!s.ContainsKey("auto_response_type"))
82 s["auto_response_type"] = (int)AutoResponseType.WhenBusy;
83 s["auto_response_text"] = "The Resident you messaged is in 'busy mode' which means they have requested not to be disturbed. Your message will still be shown in their IM panel for later viewing.";
86 if (!s.ContainsKey("script_syntax_highlight")) s["script_syntax_highlight"] = OSD.FromBoolean(true);
88 if (!s.ContainsKey("display_name_mode")) s["display_name_mode"] = (int)NameMode.Smart;
90 // Convert legacy settings from first last name to username
91 if (!s.ContainsKey("username") && (s.ContainsKey("first_name") && s.ContainsKey("last_name")))
93 s["username"] = s["first_name"] + " " + s["last_name"];
94 s.Remove("first_name");
95 s.Remove("last_name");
98 if (!s.ContainsKey("reconnect_time")) s["reconnect_time"] = 120;
100 if (!s.ContainsKey("transaction_notification_chat")) s["transaction_notification_chat"] = true;
102 if (!s.ContainsKey("transaction_notification_dialog")) s["transaction_notification_dialog"] = true;
104 if (!s.ContainsKey("minimize_to_tray")) s["minimize_to_tray"] = false;
106 if (!s.ContainsKey("scene_window_docked")) s["scene_window_docked"] = true;
108 if (!s.ContainsKey("taskbar_highlight")) s["taskbar_highlight"] = true;
110 if (!s.ContainsKey("rendering_occlusion_culling_enabled")) s["rendering_occlusion_culling_enabled"] = true;
112 if (!s.ContainsKey("rendering_use_vbo")) s["rendering_use_vbo"] = true;
114 if (!s.ContainsKey("send_rad_client_tag")) s["send_rad_client_tag"] = true;
116 if (!s.ContainsKey("log_to_file")) s["log_to_file"] = true;
118 if (!s.ContainsKey("disable_chat_im_log")) s["disable_chat_im_log"] = false;
121 public frmSettings(RadegastInstance instance)
123 if (settingInitialized)
125 frmSettings.InitSettigs(instance.GlobalSettings);
128 InitializeComponent();
130 s = instance.GlobalSettings;
131 tbpGraphics.Controls.Add(new Radegast.Rendering.GraphicsPreferences(instance));
132 cbChatTimestamps.Checked = s["chat_timestamps"].AsBoolean();
134 cbIMTimeStamps.Checked = s["im_timestamps"].AsBoolean();
136 cbChatTimestamps.CheckedChanged += new EventHandler(cbChatTimestamps_CheckedChanged);
137 cbIMTimeStamps.CheckedChanged += new EventHandler(cbIMTimeStamps_CheckedChanged);
139 cbTrasactDialog.Checked = s["transaction_notification_dialog"].AsBoolean();
140 cbTrasactChat.Checked = s["transaction_notification_chat"].AsBoolean();
142 cbFriendsNotifications.Checked = s["show_friends_online_notifications"].AsBoolean();
143 cbFriendsNotifications.CheckedChanged += new EventHandler(cbFriendsNotifications_CheckedChanged);
145 cbAutoReconnect.Checked = s["auto_reconnect"].AsBoolean();
146 cbAutoReconnect.CheckedChanged += new EventHandler(cbAutoReconnect_CheckedChanged);
148 cbHideLoginGraphics.Checked = s["hide_login_graphics"].AsBoolean();
149 cbHideLoginGraphics.CheckedChanged += new EventHandler(cbHideLoginGraphics_CheckedChanged);
151 cbRLV.Checked = s["rlv_enabled"].AsBoolean();
152 cbRLV.CheckedChanged += (object sender, EventArgs e) =>
154 s["rlv_enabled"] = new OSDBoolean(cbRLV.Checked);
157 cbMUEmotes.Checked = s["mu_emotes"].AsBoolean();
158 cbMUEmotes.CheckedChanged += (object sender, EventArgs e) =>
160 s["mu_emotes"] = new OSDBoolean(cbMUEmotes.Checked);
163 cbFriendsHighlight.Checked = s["friends_notification_highlight"].AsBoolean();
164 cbFriendsHighlight.CheckedChanged += (object sender, EventArgs e) =>
166 s["friends_notification_highlight"] = new OSDBoolean(cbFriendsHighlight.Checked);
169 if (s["chat_font_size"].Type != OSDType.Real)
171 s["chat_font_size"] = OSD.FromReal(((ChatConsole)instance.TabConsole.Tabs["chat"].Control).cbxInput.Font.Size);
174 cbFontSize.Text = s["chat_font_size"].AsReal().ToString(System.Globalization.CultureInfo.InvariantCulture);
176 if (!s.ContainsKey("minimize_to_tray")) s["minimize_to_tray"] = OSD.FromBoolean(false);
177 cbMinToTrey.Checked = s["minimize_to_tray"].AsBoolean();
178 cbMinToTrey.CheckedChanged += (object sender, EventArgs e) =>
180 s["minimize_to_tray"] = OSD.FromBoolean(cbMinToTrey.Checked);
184 cbNoTyping.Checked = s["no_typing_anim"].AsBoolean();
185 cbNoTyping.CheckedChanged += (object sender, EventArgs e) =>
187 s["no_typing_anim"] = OSD.FromBoolean(cbNoTyping.Checked);
190 txtAutoResponse.Text = s["auto_response_text"];
191 txtAutoResponse.TextChanged += (object sender, EventArgs e) =>
193 s["auto_response_text"] = txtAutoResponse.Text;
195 AutoResponseType art = (AutoResponseType)s["auto_response_type"].AsInteger();
198 case AutoResponseType.WhenBusy: rbAutobusy.Checked = true; break;
199 case AutoResponseType.WhenFromNonFriend: rbAutoNonFriend.Checked = true; break;
200 case AutoResponseType.Always: rbAutoAlways.Checked = true; break;
203 cbSyntaxHighlight.Checked = s["script_syntax_highlight"].AsBoolean();
204 cbSyntaxHighlight.CheckedChanged += (object sender, EventArgs e) =>
206 s["script_syntax_highlight"] = OSD.FromBoolean(cbSyntaxHighlight.Checked);
209 switch ((NameMode)s["display_name_mode"].AsInteger())
211 case NameMode.Standard: rbDNOff.Checked = true; break;
212 case NameMode.Smart: rbDNSmart.Checked = true; break;
213 case NameMode.DisplayNameAndUserName: rbDNDandUsernme.Checked = true; break;
214 case NameMode.OnlyDisplayName: rbDNOnlyDN.Checked = true; break;
217 txtReconnectTime.Text = s["reconnect_time"].AsInteger().ToString();
219 cbTaskBarHighLight.Checked = s["taskbar_highlight"];
220 cbTaskBarHighLight.CheckedChanged += (sender, e) =>
222 s["taskbar_highlight"] = cbTaskBarHighLight.Checked;
225 cbRadegastClientTag.Checked = s["send_rad_client_tag"];
226 cbRadegastClientTag.CheckedChanged += (sender, e) =>
228 s["send_rad_client_tag"] = cbRadegastClientTag.Checked;
229 instance.SetClientTag();
232 cbOnInvOffer.SelectedIndex = s["inv_auto_accept_mode"].AsInteger();
233 cbOnInvOffer.SelectedIndexChanged += (sender, e) =>
235 s["inv_auto_accept_mode"] = cbOnInvOffer.SelectedIndex;
238 cbRadegastLogToFile.Checked = s["log_to_file"];
240 cbDisableChatIMLog.Checked = s["disable_chat_im_log"];
241 cbDisableChatIMLog.CheckedChanged += (sender, e) =>
243 s["disable_chat_im_log"] = cbDisableChatIMLog.Checked;
247 void cbHideLoginGraphics_CheckedChanged(object sender, EventArgs e)
249 s["hide_login_graphics"] = OSD.FromBoolean(cbHideLoginGraphics.Checked);
252 void cbAutoReconnect_CheckedChanged(object sender, EventArgs e)
254 s["auto_reconnect"] = OSD.FromBoolean(cbAutoReconnect.Checked);
257 void cbFriendsNotifications_CheckedChanged(object sender, EventArgs e)
259 s["show_friends_online_notifications"] = OSD.FromBoolean(cbFriendsNotifications.Checked);
262 void cbChatTimestamps_CheckedChanged(object sender, EventArgs e)
264 s["chat_timestamps"] = OSD.FromBoolean(cbChatTimestamps.Checked);
267 void cbIMTimeStamps_CheckedChanged(object sender, EventArgs e)
269 s["im_timestamps"] = OSD.FromBoolean(cbIMTimeStamps.Checked);
272 private void cbTrasactDialog_CheckedChanged(object sender, EventArgs e)
274 s["transaction_notification_dialog"] = OSD.FromBoolean(cbTrasactDialog.Checked);
277 private void cbTrasactChat_CheckedChanged(object sender, EventArgs e)
279 s["transaction_notification_chat"] = OSD.FromBoolean(cbTrasactChat.Checked);
282 private void UpdateFontSize()
285 double existing = s["chat_font_size"].AsReal();
287 if (!double.TryParse(cbFontSize.Text, out f))
289 cbFontSize.Text = s["chat_font_size"].AsReal().ToString(System.Globalization.CultureInfo.InvariantCulture);
293 if (Math.Abs(existing - f) > 0.0001f)
294 s["chat_font_size"] = OSD.FromReal(f);
298 private void cbFontSize_SelectedIndexChanged(object sender, EventArgs e)
303 private void cbFontSize_KeyDown(object sender, KeyEventArgs e)
305 if (e.KeyCode == Keys.Enter)
308 e.Handled = e.SuppressKeyPress = true;
312 private void cbFontSize_Leave(object sender, EventArgs e)
317 private void rbAutobusy_CheckedChanged(object sender, EventArgs e)
319 s["auto_response_type"] = (int)AutoResponseType.WhenBusy;
322 private void rbAutoNonFriend_CheckedChanged(object sender, EventArgs e)
324 s["auto_response_type"] = (int)AutoResponseType.WhenFromNonFriend;
327 private void rbAutoAlways_CheckedChanged(object sender, EventArgs e)
329 s["auto_response_type"] = (int)AutoResponseType.Always;
332 private void rbDNOff_CheckedChanged(object sender, EventArgs e)
335 s["display_name_mode"] = (int)NameMode.Standard;
338 private void rbDNSmart_CheckedChanged(object sender, EventArgs e)
340 if (rbDNSmart.Checked)
341 s["display_name_mode"] = (int)NameMode.Smart;
344 private void rbDNDandUsernme_CheckedChanged(object sender, EventArgs e)
346 if (rbDNDandUsernme.Checked)
347 s["display_name_mode"] = (int)NameMode.DisplayNameAndUserName;
350 private void rbDNOnlyDN_CheckedChanged(object sender, EventArgs e)
352 if (rbDNOnlyDN.Checked)
353 s["display_name_mode"] = (int)NameMode.OnlyDisplayName;
356 private void txtReconnectTime_TextChanged(object sender, EventArgs e)
358 string input = System.Text.RegularExpressions.Regex.Replace(txtReconnectTime.Text, @"[^\d]", "");
360 int.TryParse(input, out t);
362 if (txtReconnectTime.Text != t.ToString())
364 txtReconnectTime.Text = t.ToString();
365 txtReconnectTime.Select(txtReconnectTime.Text.Length, 0);
368 s["reconnect_time"] = t;
371 private void cbRadegastLogToFile_CheckedChanged(object sender, EventArgs e)
373 s["log_to_file"] = OSD.FromBoolean(cbRadegastLogToFile.Checked);