Ejemplo n.º 1
0
        private void SecondLifeHost_OnMessageLinked(object sender, SecondLifeHostMessageLinkedEventArgs e)
        {
            SecondLifeHost secondLifeHostSender = sender as SecondLifeHost;

            Guid ObjectGuid     = this.solutionExplorer.GetParentGuid(secondLifeHostSender.GUID);
            Guid RootObjectGuid = this.solutionExplorer.GetParentGuid(ObjectGuid);

            List <Guid> list;

            int intLinkNum = e.LinkIndex;

            switch (intLinkNum)
            {
            case 1:                     // LINK_ROOT  , root prim in linked set (but not in a single prim, which is 0)
                list = this.solutionExplorer.GetScripts(RootObjectGuid, false);
                break;

            case -1:                     // LINK_SET  , all prims in object
                list = this.solutionExplorer.GetScripts(RootObjectGuid, true);
                break;

            case -2:                     // LINK_ALL_OTHERS  ,  all other prims in object besides prim function is in
                list = this.solutionExplorer.GetScripts(RootObjectGuid, true);
                // remove scripts in prim itself, and below
                foreach (Guid guid in this.solutionExplorer.GetScripts(ObjectGuid, true))
                {
                    if (list.Contains(guid))
                    {
                        list.Remove(guid);
                    }
                }
                break;

            case -3:                     // LINK_ALL_CHILDREN  , all child prims in object
                list = this.solutionExplorer.GetScripts(RootObjectGuid, true);
                // remove root itself
                foreach (Guid guid in this.solutionExplorer.GetScripts(RootObjectGuid, false))
                {
                    if (list.Contains(guid))
                    {
                        list.Remove(guid);
                    }
                }
                break;

            case -4:                     // LINK_THIS
                /*
                 * From SL Wiki: "Causes the script to act only upon the prim the prim the script is in."
                 * This means LINK_THIS, links to every script in the prim, not just the caller.
                 * @author = MrSoundless
                 * @date = 28 April 2011
                 */
                list = new List <Guid>();
                //list.Add(secondLifeHostSender.guid); // 4 feb 2008
                list = this.solutionExplorer.GetScripts(ObjectGuid, true);                         // 28 april 2011
                break;

            default:                     // Link number
                Guid ObjectNrGuid = this.solutionExplorer.GetGuidFromObjectNr(ObjectGuid, intLinkNum);
                list = this.solutionExplorer.GetScripts(ObjectNrGuid, true);
                break;
            }

            // only send message to running scripts in list
            foreach (Form form in this.Children)
            {
                EditForm editForm = form as EditForm;
                if (editForm == null || editForm.IsDisposed)
                {
                    continue;
                }

                if (editForm.runtime == null)
                {
                    continue;
                }

                if (editForm.runtime.SecondLifeHost == null)
                {
                    continue;
                }

                if (list.Contains(editForm.guid))
                {
                    editForm.runtime.SecondLifeHost.LinkMessage(e);
                }
            }
        }
Ejemplo n.º 2
0
        public void SaveCurrentFile(string strPath)
        {
            // Check if this is an expanded.lsl
            if (LSLIPathHelper.IsExpandedLSL(strPath))
            {
                string LSLIfilePath = LSLIPathHelper.CreateCollapsedPathAndScriptName(strPath);
                // Check if an LSLI version of this script exists
                if (File.Exists(LSLIfilePath))
                {
                    // Save the LSLI file as well
                    File.WriteAllText(LSLIfilePath, LSLIConverter.CollapseToLSLI(this.numberedTextBoxUC1.TextBox.Text));
                    EditForm form = null;

                    // If it's currently open, then refresh it
                    for (int i = 0; i < Application.OpenForms.Count; i++)
                    {
                        Form   openForm = Application.OpenForms[i];
                        string filename = LSLIPathHelper.TrimStarsAndWhiteSpace(openForm.Text);
                        if (filename == Path.GetFileName(LSLIfilePath))
                        {
                            form = (EditForm)openForm;
                        }
                    }

                    if (form != null && form.Enabled)
                    {
                        parent.OpenFile(LSLIfilePath, Guid.NewGuid(), true);
                        form.Close();
                    }
                }
                this.numberedTextBoxUC1.TextBox.Dirty = false;
                this.Text = LSLIPathHelper.GetExpandedTabName(strPath);
            }
            else
            {
                this.FullPathName = strPath;
                Encoding encodeAs = this.encodedAs;
                if (this.IsScript && encodeAs == null)
                {
                    switch (Properties.Settings.Default.OutputFormat)
                    {
                    case "UTF8":
                        encodeAs = Encoding.UTF8;
                        break;

                    case "Unicode":
                        encodeAs = Encoding.Unicode;
                        break;

                    case "BigEndianUnicode":
                        encodeAs = Encoding.BigEndianUnicode;
                        break;

                    default:
                        encodeAs = Encoding.Default;
                        break;
                    }
                }
                else if (encodeAs == null)
                {
                    encodeAs = Encoding.UTF8;
                }

                this.numberedTextBoxUC1.TextBox.SaveCurrentFile(strPath, encodeAs);
                this.encodedAs = encodeAs;
            }
            this.m_IsNew = false;
        }