2 // Radegast Metaverse Client
3 // Copyright (c) 2009-2010, Radegast Development Team
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 // * Neither the name of the application "Radegast", nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System.Collections.Generic;
35 using System.Text.RegularExpressions;
37 using System.Threading;
38 using System.Windows.Forms;
39 using System.Resources;
42 using Radegast.Netcom;
44 using OpenMetaverse.StructuredData;
45 using OpenMetaverse.Assets;
49 public partial class frmMain : RadegastForm
51 #region Public members
52 public static ImageList ResourceImages = new ImageList();
53 public static List<string> ImageNames = new List<string>();
55 public TabsConsole TabConsole
57 get { return tabsConsole; }
60 public MapConsole WorldMap
66 return (MapConsole)MapTab.Control;
72 public RadegastTab MapTab
76 if (tabsConsole.TabExists("map"))
78 return tabsConsole.Tabs["map"];
87 public MediaConsole MediaConsole { get { return mediaConsole; } }
90 /// Drop down that contains the tools menu
92 public ToolStripDropDownButton ToolsMenu
94 get { return tbnTools; }
98 /// Dropdown that contains the heelp menu
100 public ToolStripDropDownButton HelpMenu
102 get { return tbtnHelp; }
106 /// Drop down that contants the plugins menu. Make sure to set it Visible if
107 /// you add items to this menu, it's hidden by default
109 public ToolStripDropDownButton PluginsMenu
111 get { return tbnPlugins; }
116 #region Private members
117 private RadegastInstance instance;
118 private GridClient client { get { return instance.Client; } }
119 private RadegastNetcom netcom { get { return instance.Netcom; } }
120 private TabsConsole tabsConsole;
121 private System.Timers.Timer statusTimer;
122 private AutoPilot ap;
123 private bool AutoPilotActive = false;
124 private TransparentButton btnDialogNextControl;
125 private MediaConsole mediaConsole;
128 #region Constructor and disposal
129 public frmMain(RadegastInstance instance)
132 InitializeComponent();
133 Disposed += new EventHandler(frmMain_Disposed);
135 this.instance = instance;
136 this.instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(instance_ClientChanged);
137 netcom.NetcomSync = this;
139 pnlDialog.Visible = false;
140 btnDialogNextControl = new TransparentButton();
141 pnlDialog.Controls.Add(btnDialogNextControl);
144 btnDialogNextControl.Size = new Size(35, 20);
145 btnDialogNextControl.BackColor = Color.Transparent;
146 btnDialogNextControl.ForeColor = Color.Gold;
147 btnDialogNextControl.FlatAppearance.BorderSize = 0;
148 btnDialogNextControl.FlatStyle = FlatStyle.Flat;
149 btnDialogNextControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
150 btnDialogNextControl.Text = ">>";
151 btnDialogNextControl.Font = new Font(btnDialogNextControl.Font, FontStyle.Bold);
152 btnDialogNextControl.Margin = new Padding(0);
153 btnDialogNextControl.Padding = new Padding(0);
154 btnDialogNextControl.UseVisualStyleBackColor = false;
155 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
156 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
157 btnDialogNextControl.Click += new EventHandler(btnDialogNextControl_Click);
159 if (instance.MonoRuntime)
161 statusStrip1.LayoutStyle = ToolStripLayoutStyle.Table;
165 if (instance.GlobalSettings["transaction_notification_chat"].Type == OSDType.Unknown)
166 instance.GlobalSettings["transaction_notification_chat"] = OSD.FromBoolean(true);
168 if (instance.GlobalSettings["transaction_notification_dialog"].Type == OSDType.Unknown)
169 instance.GlobalSettings["transaction_notification_dialog"] = OSD.FromBoolean(true);
171 if (!instance.GlobalSettings.ContainsKey("minimize_to_tray"))
172 instance.GlobalSettings["minimize_to_tray"] = OSD.FromBoolean(false);
175 netcom.ClientLoginStatus += new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
176 netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut);
177 netcom.ClientDisconnected += new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
178 RegisterClientEvents(client);
180 InitializeStatusTimer();
181 RefreshWindowTitle();
184 private void RegisterClientEvents(GridClient client)
186 client.Parcels.ParcelProperties += new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
187 client.Self.MoneyBalanceReply += new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
190 private void UnregisterClientEvents(GridClient client)
192 client.Parcels.ParcelProperties -= new EventHandler<ParcelPropertiesEventArgs>(Parcels_ParcelProperties);
193 client.Self.MoneyBalanceReply -= new EventHandler<MoneyBalanceReplyEventArgs>(Self_MoneyBalanceReply);
196 void instance_ClientChanged(object sender, ClientChangedEventArgs e)
198 UnregisterClientEvents(e.OldClient);
199 RegisterClientEvents(client);
202 void frmMain_Disposed(object sender, EventArgs e)
206 netcom.NetcomSync = null;
207 netcom.ClientLoginStatus -= new EventHandler<LoginProgressEventArgs>(netcom_ClientLoginStatus);
208 netcom.ClientLoggedOut -= new EventHandler(netcom_ClientLoggedOut);
209 netcom.ClientDisconnected -= new EventHandler<DisconnectedEventArgs>(netcom_ClientDisconnected);
213 UnregisterClientEvents(client);
215 this.instance.CleanUp();
219 #region Event handlers
220 void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
222 if (!String.IsNullOrEmpty(e.Description))
224 if (instance.GlobalSettings["transaction_notification_dialog"].AsBoolean())
225 AddNotification(new ntfGeneric(instance, e.Description));
226 if (instance.GlobalSettings["transaction_notification_chat"].AsBoolean())
227 TabConsole.DisplayNotificationInChat(e.Description);
231 public void InitializeControls()
233 InitializeTabsConsole();
235 if (instance.MediaManager.SoundSystemAvailable)
237 mediaConsole = new MediaConsole(instance);
238 tbtnMedia.Visible = true;
242 public bool InAutoReconnect { get; set; }
244 private void DisplayAutoReconnectForm()
246 if (IsDisposed) return;
250 BeginInvoke(new MethodInvoker(DisplayAutoReconnectForm));
254 InAutoReconnect = true;
255 frmReconnect dialog = new frmReconnect(instance, 120);
256 dialog.ShowDialog(this);
261 public void BeginAutoReconnect()
263 // Sleep for 3 seconds on a separate thread while things unwind on
264 // disconnect, since ShowDialog() blocks GUI thread
265 (new Thread(new ThreadStart(() =>
267 System.Threading.Thread.Sleep(3000);
268 DisplayAutoReconnectForm();
272 Name = "Reconnect Delay Thread",
278 private void netcom_ClientLoginStatus(object sender, LoginProgressEventArgs e)
280 if (e.Status == LoginStatus.Failed)
284 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
285 BeginAutoReconnect();
287 InAutoReconnect = false;
290 else if (e.Status == LoginStatus.Success)
292 InAutoReconnect = false;
293 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
294 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
295 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = true;
298 RefreshWindowTitle();
302 private void netcom_ClientLoggedOut(object sender, EventArgs e)
304 tbtnVoice.Enabled = disconnectToolStripMenuItem.Enabled =
305 tbtnGroups.Enabled = tbnObjects.Enabled = tbtnWorld.Enabled = tbnTools.Enabled = tmnuImport.Enabled =
306 tbtnFriends.Enabled = tbtnInventory.Enabled = tbtnSearch.Enabled = tbtnMap.Enabled = false;
308 reconnectToolStripMenuItem.Enabled = true;
309 InAutoReconnect = false;
311 if (statusTimer != null)
315 RefreshWindowTitle();
318 private void netcom_ClientDisconnected(object sender, DisconnectedEventArgs e)
320 if (e.Reason == NetworkManager.DisconnectType.ClientInitiated) return;
321 netcom_ClientLoggedOut(sender, EventArgs.Empty);
323 if (instance.GlobalSettings["auto_reconnect"].AsBoolean())
325 BeginAutoReconnect();
329 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
331 if (statusTimer != null)
334 statusTimer.Dispose();
338 if (mediaConsole != null)
340 if (tabsConsole.TabExists("media"))
342 tabsConsole.Tabs["media"].AllowClose = true;
343 tabsConsole.Tabs["media"].Close();
347 mediaConsole.Dispose();
352 if (netcom.IsLoggedIn)
354 Thread saveInvToDisk = new Thread(new ThreadStart(
357 client.Inventory.Store.SaveToDisk(instance.InventoryCacheFileName);
359 saveInvToDisk.Name = "Save inventory to disk";
360 saveInvToDisk.Start();
367 # region Update status
369 void Parcels_ParcelProperties(object sender, ParcelPropertiesEventArgs e)
371 if (e.Result != ParcelResult.Single) return;
374 BeginInvoke(new MethodInvoker(() => Parcels_ParcelProperties(sender, e)));
378 Parcel parcel = instance.State.Parcel = e.Parcel;
380 tlblParcel.Text = parcel.Name;
381 tlblParcel.ToolTipText = parcel.Desc;
383 if ((parcel.Flags & ParcelFlags.AllowFly) != ParcelFlags.AllowFly)
384 icoNoFly.Visible = true;
386 icoNoFly.Visible = false;
388 if ((parcel.Flags & ParcelFlags.CreateObjects) != ParcelFlags.CreateObjects)
389 icoNoBuild.Visible = true;
391 icoNoBuild.Visible = false;
393 if ((parcel.Flags & ParcelFlags.AllowOtherScripts) != ParcelFlags.AllowOtherScripts)
394 icoNoScript.Visible = true;
396 icoNoScript.Visible = false;
398 if ((parcel.Flags & ParcelFlags.RestrictPushObject) == ParcelFlags.RestrictPushObject)
399 icoNoPush.Visible = true;
401 icoNoPush.Visible = false;
403 if ((parcel.Flags & ParcelFlags.AllowDamage) == ParcelFlags.AllowDamage)
404 icoHealth.Visible = true;
406 icoHealth.Visible = false;
408 if ((parcel.Flags & ParcelFlags.AllowVoiceChat) != ParcelFlags.AllowVoiceChat)
409 icoNoVoice.Visible = true;
411 icoNoVoice.Visible = false;
414 private void RefreshStatusBar()
416 if (netcom.IsLoggedIn)
418 tlblLoginName.Text = netcom.LoginOptions.FullName;
419 tlblMoneyBalance.Text = client.Self.Balance.ToString();
420 icoHealth.Text = client.Self.Health.ToString() + "%";
422 tlblRegionInfo.Text =
423 client.Network.CurrentSim.Name +
424 " (" + Math.Floor(client.Self.SimPosition.X).ToString() + ", " +
425 Math.Floor(client.Self.SimPosition.Y).ToString() + ", " +
426 Math.Floor(client.Self.SimPosition.Z).ToString() + ")";
430 tlblLoginName.Text = "Offline";
431 tlblMoneyBalance.Text = "0";
432 icoHealth.Text = "0%";
433 tlblRegionInfo.Text = "No Region";
434 tlblParcel.Text = "No Parcel";
436 icoHealth.Visible = false;
437 icoNoBuild.Visible = false;
438 icoNoFly.Visible = false;
439 icoNoPush.Visible = false;
440 icoNoScript.Visible = false;
441 icoNoVoice.Visible = false;
445 private void RefreshWindowTitle()
447 StringBuilder sb = new StringBuilder();
448 sb.Append("Radegast - ");
450 if (netcom.IsLoggedIn)
452 sb.Append("[" + netcom.LoginOptions.FullName + "]");
454 if (instance.State.IsAway)
456 sb.Append(" - Away");
457 if (instance.State.IsBusy) sb.Append(", Busy");
459 else if (instance.State.IsBusy)
461 sb.Append(" - Busy");
464 if (instance.State.IsFollowing)
466 sb.Append(" - Following ");
467 sb.Append(instance.State.FollowName);
472 sb.Append("Logged Out");
475 this.Text = sb.ToString();
479 private void InitializeStatusTimer()
481 statusTimer = new System.Timers.Timer(250);
482 statusTimer.SynchronizingObject = this;
483 statusTimer.Elapsed += new ElapsedEventHandler(statusTimer_Elapsed);
486 private void statusTimer_Elapsed(object sender, ElapsedEventArgs e)
488 // Mono sometimes fires timer after is's disposed
491 RefreshWindowTitle();
498 #region Initialization, configuration, and key shortcuts
499 private void InitializeTabsConsole()
501 tabsConsole = new TabsConsole(instance);
502 tabsConsole.Dock = DockStyle.Fill;
503 toolStripContainer1.ContentPanel.Controls.Add(tabsConsole);
506 private void frmMain_KeyDown(object sender, KeyEventArgs e)
509 if (e.Modifiers == Keys.Control && e.KeyCode == Keys.W)
511 e.Handled = e.SuppressKeyPress = true;
512 RadegastTab tab = tabsConsole.SelectedTab;
518 else if (tab.AllowHide)
526 // Ctl-Shift-H: Teleport Home
527 if (e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.H)
529 e.Handled = e.SuppressKeyPress = true;
530 tmnuTeleportHome.PerformClick();
534 // Alt-Ctrl-D Open debug console
535 if (e.Modifiers == (Keys.Control | Keys.Alt) && e.KeyCode == Keys.D)
537 e.Handled = e.SuppressKeyPress = true;
538 debugConsoleToolStripMenuItem.PerformClick();
542 // Alt 1-8: Toggle various tabs
543 if (e.Modifiers == Keys.Alt)
548 e.Handled = e.SuppressKeyPress = true;
549 tabsConsole.Tabs["chat"].Select();
553 e.Handled = e.SuppressKeyPress = true;
554 tbtnFriends.PerformClick();
558 e.Handled = e.SuppressKeyPress = true;
559 tbtnGroups.PerformClick();
563 e.Handled = e.SuppressKeyPress = true;
564 tbtnInventory.PerformClick();
568 e.Handled = e.SuppressKeyPress = true;
569 tbtnSearch.PerformClick();
573 e.Handled = e.SuppressKeyPress = true;
574 tbtnMap.PerformClick();
578 e.Handled = e.SuppressKeyPress = true;
579 tbnObjects.PerformClick();
583 e.Handled = e.SuppressKeyPress = true;
584 tbtnMedia.PerformClick();
588 e.Handled = e.SuppressKeyPress = true;
589 tbtnVoice.PerformClick();
594 // ctrl-g, goto slurl
595 if (e.Control && e.KeyCode == Keys.G)
597 if (!ProcessLink(Clipboard.GetText(), true))
598 MapToCurrentLocation();
600 e.Handled = e.SuppressKeyPress = true;
604 // ctrl-(shift)-tab for next/previous tab
605 if (e.Control && e.KeyCode == Keys.Tab)
609 TabConsole.SelectPreviousTab();
613 TabConsole.SelectNextTab();
615 e.Handled = e.SuppressKeyPress = true;
620 bool firstLoad = true;
622 private void frmMain_Load(object sender, EventArgs e)
627 tabsConsole.SelectTab("login");
628 ResourceManager rm = Properties.Resources.ResourceManager;
629 ResourceSet set = rm.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
630 System.Collections.IDictionaryEnumerator de = set.GetEnumerator();
631 while (de.MoveNext() == true)
633 if (de.Entry.Value is Image)
635 Bitmap bitMap = de.Entry.Value as Bitmap;
636 ResourceImages.Images.Add(bitMap);
637 ImageNames.Add(de.Entry.Key.ToString());
640 StartUpdateCheck(false);
645 #region Public methods
647 private Dictionary<UUID, frmProfile> shownProfiles = new Dictionary<UUID, frmProfile>();
649 public void ShowAgentProfile(string name, UUID agentID)
653 frmProfile profile = null;
654 if (shownProfiles.TryGetValue(agentID, out profile))
656 profile.WindowState = FormWindowState.Normal;
661 profile = new frmProfile(instance, name, agentID);
663 profile.Disposed += (object sender, EventArgs e) =>
667 frmProfile agentProfile = (frmProfile)sender;
668 if (shownProfiles.ContainsKey(agentProfile.AgentID))
669 shownProfiles.Remove(agentProfile.AgentID);
675 shownProfiles.Add(agentID, profile);
680 private Dictionary<UUID, frmGroupInfo> shownGroupProfiles = new Dictionary<UUID, frmGroupInfo>();
682 public void ShowGroupProfile(AvatarGroup group)
684 ShowGroupProfile(new OpenMetaverse.Group()
687 InsigniaID = group.GroupInsigniaID,
688 Name = group.GroupName
693 public void ShowGroupProfile(OpenMetaverse.Group group)
695 lock (shownGroupProfiles)
697 frmGroupInfo profile = null;
698 if (shownGroupProfiles.TryGetValue(group.ID, out profile))
700 profile.WindowState = FormWindowState.Normal;
705 profile = new frmGroupInfo(instance, group);
707 profile.Disposed += (object sender, EventArgs e) =>
709 lock (shownGroupProfiles)
711 frmGroupInfo groupProfile = (frmGroupInfo)sender;
712 if (shownGroupProfiles.ContainsKey(groupProfile.Group.ID))
713 shownGroupProfiles.Remove(groupProfile.Group.ID);
719 shownGroupProfiles.Add(group.ID, profile);
724 public void ProcessLink(string link)
726 ProcessLink(link, false);
729 public bool ProcessLink(string link, bool onlyMap)
731 if (!link.Contains("://"))
733 link = "http://" + link;
736 Regex r = new Regex(@"^(http://(slurl\.com|maps\.secondlife\.com)/secondlife/|secondlife://)(?<region>[^/]+)/(?<x>\d+)/(?<y>\d+)(/(?<z>\d+))?",
737 RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase
739 Match m = r.Match(link);
743 string region = HttpUtility.UrlDecode(m.Groups["region"].Value);
744 int x = int.Parse(m.Groups["x"].Value);
745 int y = int.Parse(m.Groups["y"].Value);
748 if (!string.IsNullOrEmpty(m.Groups["z"].Value))
750 z = int.Parse(m.Groups["z"].Value);
754 WorldMap.DisplayLocation(region, x, y, z);
759 System.Diagnostics.Process.Start(link);
765 #region Notifications
766 CircularList<Control> notifications = new CircularList<Control>();
768 public Color NotificationBackground
770 get { return pnlDialog.BackColor; }
773 void ResizeNotificationByControl(Control active)
775 int Width = active.Size.Width + 6;
776 int Height = notifications.Count > 1 ? active.Size.Height + 3 + btnDialogNextControl.Size.Height : active.Size.Height + 3;
777 pnlDialog.Size = new Size(Width, Height);
779 pnlDialog.Left = pnlDialog.Parent.ClientSize.Width - Width;
781 btnDialogNextControl.Top = btnDialogNextControl.Parent.ClientSize.Height - btnDialogNextControl.Size.Height;
782 btnDialogNextControl.Left = btnDialogNextControl.Parent.ClientSize.Width - btnDialogNextControl.Size.Width;
784 btnDialogNextControl.BringToFront();
787 public void AddNotification(Control control)
791 BeginInvoke(new MethodInvoker(delegate()
793 AddNotification(control);
799 FormFlash.StartFlash(this);
800 pnlDialog.Visible = true;
801 pnlDialog.BringToFront();
803 foreach (Control existing in notifications)
805 existing.Visible = false;
808 notifications.Add(control);
809 control.Visible = true;
810 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
813 pnlDialog.Controls.Add(control);
814 ResizeNotificationByControl(control);
816 btnDialogNextControl.Visible = notifications.Count > 1;
819 public void RemoveNotification(Control control)
821 pnlDialog.Controls.Remove(control);
822 notifications.Remove(control);
825 if (notifications.HasNext)
827 pnlDialog.Visible = true;
828 Control active = notifications.Next;
829 active.Visible = true;
830 ResizeNotificationByControl(active);
834 pnlDialog.Visible = false;
837 btnDialogNextControl.Visible = notifications.Count > 1;
840 private void btnDialogNextControl_Click(object sender, EventArgs e)
842 foreach (Control existing in notifications)
844 existing.Visible = false;
847 if (notifications.HasNext)
849 pnlDialog.Visible = true;
850 Control active = notifications.Next;
851 active.Visible = true;
852 ResizeNotificationByControl(active);
856 pnlDialog.Visible = false;
860 #endregion Notifications
862 #region Menu click handlers
864 private void tmnuStatusAway_Click(object sender, EventArgs e)
866 instance.State.SetAway(tmnuStatusAway.Checked);
869 private void tmnuHelpReadme_Click(object sender, EventArgs e)
871 System.Diagnostics.Process.Start(Application.StartupPath + @"\Readme.txt");
874 private void tmnuStatusBusy_Click(object sender, EventArgs e)
876 instance.State.SetBusy(tmnuStatusBusy.Checked);
879 private void tmnuControlFly_Click(object sender, EventArgs e)
881 instance.State.SetFlying(tmnuControlFly.Checked);
884 private void tmnuControlAlwaysRun_Click(object sender, EventArgs e)
886 instance.State.SetAlwaysRun(tmnuControlAlwaysRun.Checked);
889 private void tmnuPrefs_Click(object sender, EventArgs e)
891 (new frmSettings(instance)).ShowDialog();
894 private void tbtnAppearance_Click(object sender, EventArgs e)
896 client.Appearance.RequestSetAppearance(false);
899 private void importObjectToolStripMenuItem_Click(object sender, EventArgs e)
901 PrimDeserializer.ImportFromFile(client);
904 private void autopilotToolStripMenuItem_Click(object sender, EventArgs e)
908 ap = new AutoPilot(client);
910 ap.InsertWaypoint(new Vector3(66, 163, 21));
911 ap.InsertWaypoint(new Vector3(66, 98, 21));
913 ap.InsertWaypoint(new Vector3(101, 98, 21));
914 ap.InsertWaypoint(new Vector3(101, 45, 21));
915 ap.InsertWaypoint(new Vector3(93, 27, 21));
916 ap.InsertWaypoint(new Vector3(106, 12, 21));
917 ap.InsertWaypoint(new Vector3(123, 24, 21));
918 ap.InsertWaypoint(new Vector3(114, 45, 21));
919 ap.InsertWaypoint(new Vector3(114, 98, 21));
921 ap.InsertWaypoint(new Vector3(130, 98, 21));
922 ap.InsertWaypoint(new Vector3(130, 163, 21));
924 ap.InsertWaypoint(new Vector3(64, 68, 21));
925 ap.InsertWaypoint(new Vector3(65, 20, 21));
926 ap.InsertWaypoint(new Vector3(33, 23, 21));
927 ap.InsertWaypoint(new Vector3(17, 39, 21));
928 ap.InsertWaypoint(new Vector3(17, 62, 21));
934 AutoPilotActive = false;
939 AutoPilotActive = true;
945 private void cleanCacheToolStripMenuItem_Click(object sender, EventArgs e)
947 client.Assets.Cache.Clear();
950 private void rebakeTexturesToolStripMenuItem_Click(object sender, EventArgs e)
952 client.Appearance.RequestSetAppearance(true);
955 public void MapToCurrentLocation()
957 if (MapTab != null && client.Network.Connected)
960 WorldMap.DisplayLocation(client.Network.CurrentSim.Name,
961 (int)client.Self.SimPosition.X,
962 (int)client.Self.SimPosition.Y,
963 (int)client.Self.SimPosition.Z);
967 private void standToolStripMenuItem_Click(object sender, EventArgs e)
969 instance.State.SetSitting(false, UUID.Zero);
972 private void groundSitToolStripMenuItem_Click(object sender, EventArgs e)
974 client.Self.SitOnGround();
977 private void newWindowToolStripMenuItem_Click(object sender, EventArgs e)
979 try { System.Diagnostics.Process.Start(Application.ExecutablePath); }
980 catch (Exception) { }
983 private void tmnuExit_Click(object sender, EventArgs e)
988 private void tlblRegionInfo_Click(object sender, EventArgs e)
990 if (WorldMap != null && client.Network.Connected)
996 private void scriptEditorToolStripMenuItem_Click(object sender, EventArgs e)
998 ScriptEditor se = new ScriptEditor(instance);
999 se.Dock = DockStyle.Fill;
1003 private void tmnuSetHome_Click(object sender, EventArgs e)
1005 client.Self.SetHome();
1008 private void tmnuCreateLandmark_Click(object sender, EventArgs e)
1010 string location = string.Format(", {0} ({1}, {2}, {3})",
1011 client.Network.CurrentSim.Name,
1012 (int)client.Self.SimPosition.X,
1013 (int)client.Self.SimPosition.Y,
1014 (int)client.Self.SimPosition.Z
1017 string name = tlblParcel.Text;
1018 int maxLen = 63 - location.Length;
1020 if (name.Length > maxLen)
1021 name = name.Substring(0, maxLen);
1025 client.Inventory.RequestCreateItem(
1026 client.Inventory.FindFolderForType(AssetType.Landmark),
1028 tlblParcel.ToolTipText,
1031 InventoryType.Landmark,
1033 (bool success, InventoryItem item) =>
1037 BeginInvoke(new MethodInvoker(() =>
1039 Landmark ln = new Landmark(instance, (InventoryLandmark)item);
1040 ln.Dock = DockStyle.Fill;
1049 private void timerWorldClock_Tick(object sender, EventArgs e)
1051 lblTime.Text = instance.GetWorldTime().ToString("h:mm tt", System.Globalization.CultureInfo.InvariantCulture);
1054 private void reportBugsToolStripMenuItem_Click(object sender, EventArgs e)
1056 ProcessLink("http://jira.openmetaverse.org/browse/RAD");
1059 private void aboutRadegastToolStripMenuItem_Click(object sender, EventArgs e)
1061 (new frmAbout(instance)).ShowDialog();
1064 #region Update Checking
1065 private UpdateChecker updateChecker = null;
1066 private bool ManualUpdateCheck = false;
1068 public void StartUpdateCheck(bool userInitiated)
1070 ManualUpdateCheck = userInitiated;
1072 if (updateChecker != null)
1074 if (ManualUpdateCheck)
1075 tabsConsole.DisplayNotificationInChat("Update check already in progress.");
1079 if (ManualUpdateCheck)
1080 tabsConsole.DisplayNotificationInChat("Checking for updates...", ChatBufferTextStyle.StatusBlue);
1081 updateChecker = new UpdateChecker();
1082 updateChecker.OnUpdateInfoReceived += new UpdateChecker.UpdateInfoCallback(OnUpdateInfoReceived);
1083 updateChecker.StartCheck();
1086 private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
1088 tabsConsole.SelectTab("chat");
1089 StartUpdateCheck(true);
1092 void OnUpdateInfoReceived(object sender, UpdateCheckerArgs e)
1096 BeginInvoke(new MethodInvoker(() => OnUpdateInfoReceived(sender, e)));
1102 if (ManualUpdateCheck)
1103 tabsConsole.DisplayNotificationInChat("Error: Failed connecting to the update site.", ChatBufferTextStyle.StatusBlue);
1107 if (!ManualUpdateCheck && e.Info.DisplayMOTD)
1109 tabsConsole.DisplayNotificationInChat(e.Info.MOTD, ChatBufferTextStyle.StatusBlue);
1112 if (e.Info.UpdateAvailable)
1114 tabsConsole.DisplayNotificationInChat("New version available at " + e.Info.DownloadSite, ChatBufferTextStyle.Alert);
1118 if (ManualUpdateCheck)
1119 tabsConsole.DisplayNotificationInChat("Your version is up to date.", ChatBufferTextStyle.StatusBlue);
1123 updateChecker.Dispose();
1124 updateChecker = null;
1128 private void ToggleHidden(string tabName)
1130 if (!tabsConsole.TabExists(tabName)) return;
1132 RadegastTab tab = tabsConsole.Tabs[tabName];
1151 private void tbtnFriends_Click(object sender, EventArgs e)
1153 ToggleHidden("friends");
1156 private void tbtnInventory_Click(object sender, EventArgs e)
1158 ToggleHidden("inventory");
1161 private void tbtnSearch_Click(object sender, EventArgs e)
1163 ToggleHidden("search");
1166 private void tbtnGroups_Click(object sender, EventArgs e)
1168 ToggleHidden("groups");
1171 private void tbtnVoice_Click(object sender, EventArgs e)
1173 ToggleHidden("voice");
1176 private void tbtnMedia_Click(object sender, EventArgs e)
1178 if (tabsConsole.TabExists("media"))
1180 ToggleHidden("media");
1184 RadegastTab tab = tabsConsole.AddTab("media", "Media", mediaConsole);
1185 tab.AllowClose = false;
1186 tab.AllowHide = true;
1191 private void debugConsoleToolStripMenuItem_Click(object sender, EventArgs e)
1193 if (tabsConsole.TabExists("debug"))
1195 ToggleHidden("debug");
1199 RadegastTab tab = tabsConsole.AddTab("debug", "Debug", new DebugConsole(instance));
1200 tab.AllowClose = false;
1201 tab.AllowHide = true;
1206 private void tbnObjects_Click(object sender, EventArgs e)
1208 if (tabsConsole.TabExists("objects"))
1210 RadegastTab tab = tabsConsole.Tabs["objects"];
1214 ((ObjectsConsole)tab.Control).RefreshObjectList();
1223 RadegastTab tab = tabsConsole.AddTab("objects", "Objects", new ObjectsConsole(instance));
1224 tab.AllowClose = true;
1225 tab.AllowDetach = true;
1227 tab.AllowHide = false;
1229 ((ObjectsConsole)tab.Control).RefreshObjectList();
1233 private void tbtnMap_Click(object sender, EventArgs e)
1235 ToggleHidden("map");
1237 MapToCurrentLocation();
1240 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
1242 if (client.Network.Connected)
1243 client.Network.RequestLogout();
1246 private void reconnectToolStripMenuItem_Click(object sender, EventArgs e)
1248 instance.Reconnect();
1251 private frmKeyboardShortcuts keyboardShortcutsForm = null;
1252 private void keyboardShortcutsToolStripMenuItem_Click(object sender, EventArgs e)
1254 if (keyboardShortcutsForm != null)
1256 keyboardShortcutsForm.Focus();
1260 keyboardShortcutsForm = new frmKeyboardShortcuts(instance);
1262 keyboardShortcutsForm.Disposed += (object senderx, EventArgs ex) =>
1264 if (components != null)
1266 components.Remove(keyboardShortcutsForm);
1268 keyboardShortcutsForm = null;
1271 keyboardShortcutsForm.Show(this);
1272 keyboardShortcutsForm.Top = Top + 100;
1273 keyboardShortcutsForm.Left = Left + 100;
1275 if (components != null)
1277 components.Add(keyboardShortcutsForm);
1285 // Menu item for testing out stuff
1286 private void testToolStripMenuItem_Click(object sender, EventArgs e)
1290 Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
1293 client.Grid.GridRegion -= new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
1297 client.Grid.GridRegion += new EventHandler<GridRegionEventArgs>(Grid_GridRegion);
1298 client.Grid.RequestMainlandSims(GridLayerType.Objects);
1301 void Grid_GridRegion(object sender, GridRegionEventArgs e)
1304 if ((nr_reg % 100) == 0)
1306 nr_agent += e.Region.Agents;
1307 Logger.Log("Number of regions: " + nr_reg.ToString() + " agents: " + nr_agent.ToString(), Helpers.LogLevel.Info);
1311 private void reloadInventoryToolStripMenuItem_Click(object sender, EventArgs e)
1313 if (tabsConsole.TabExists("inventory"))
1315 ((InventoryConsole)tabsConsole.Tabs["inventory"].Control).ReloadInventory();
1316 tabsConsole.Tabs["inventory"].Select();
1320 private void btnLoadScript_Click(object sender, EventArgs e)
1322 if (!TabConsole.TabExists("plugin_manager"))
1324 TabConsole.AddTab("plugin_manager", "Plugins", new PluginsTab(instance));
1326 TabConsole.Tabs["plugin_manager"].Select();
1329 private void frmMain_Resize(object sender, EventArgs e)
1331 if (WindowState == FormWindowState.Minimized && instance.GlobalSettings["minimize_to_tray"].AsBoolean())
1333 ShowInTaskbar = false;
1334 trayIcon.Visible = true;
1338 private void treyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
1340 WindowState = FormWindowState.Normal;
1341 ShowInTaskbar = true;
1342 trayIcon.Visible = false;
1345 private void ctxTreyRestore_Click(object sender, EventArgs e)
1347 treyIcon_MouseDoubleClick(this, null);
1350 private void ctxTreyExit_Click(object sender, EventArgs e)
1352 tmnuExit_Click(this, EventArgs.Empty);
1355 private void tmnuTeleportHome_Click(object sender, EventArgs e)
1357 TabConsole.DisplayNotificationInChat("Teleporting home...");
1358 client.Self.RequestTeleport(UUID.Zero);
1361 private void stopAllAnimationsToolStripMenuItem_Click(object sender, EventArgs e)
1363 instance.State.StopAllAnimations();
1366 private void restartRegionToolStripMenuItem_Click(object sender, EventArgs e)
1368 if (MessageBox.Show(new WindowWrapper(Handle),
1369 "Do you want to restart region " + client.Network.CurrentSim.Name + "?",
1370 "Confirm restart", MessageBoxButtons.YesNo) == DialogResult.Yes)
1372 client.Estate.RestartRegion();
1376 private void regionInfoToolStripMenuItem_Click(object sender, EventArgs e)
1378 if (tabsConsole.TabExists("current region info"))
1380 tabsConsole.Tabs["current region info"].Select();
1384 tabsConsole.AddTab("current region info", "Region info", new RegionInfo(instance));
1385 tabsConsole.Tabs["current region info"].Select();