示例#1
0
 /// <summary>
 /// 消息处理
 /// </summary>
 /// <param name="msg"></param>
 public override void ProcessEvent(MsgBase msg)
 {
     switch (msg.MsgId)
     {
     case (ushort)NetEventRegister.RegisterRes:
         MsgString msgString = msg as MsgString;
         errorPanel.Show(msgString.Str);
         break;
     }
 }
示例#2
0
        /// <summary>
        /// 处理加载场景事件
        /// </summary>
        /// <param name="msg"></param>
        public override void ProcessEvent(MsgBase msg)
        {
            base.ProcessEvent(msg);

            if (msg.MsgId == (ushort)SceneLoadEvent.LoadScene)
            {
                MsgString msgString = msg as MsgString;
                LoadNewScene(msgString.Str);
            }
        }
示例#3
0
        /// <summary>
        /// 处理应用内消息
        /// </summary>
        /// <param name="msg"></param>
        public override void ProcessEvent(MsgBase msg)
        {
            switch (msg.MsgId)
            {
            case (ushort)NetEventUser.CreateUser:
                MsgString msgString = msg as MsgString;
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.CREATE_CREQ, msgString.Str);
                break;

            case (ushort)NetEventUser.RequestUserInfo:
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.INFO_CREQ, null);
                break;

            case (ushort)NetEventUser.RequestOnline:
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.ONLINE_CREQ, null);
                break;
            }
        }
        //
        // Called when the verify output listview has an item activated.  The
        // item text is parsed to discern whenther the message activated was a
        // compiler message; if so, an editor window is opened up to the script
        // namd in the message.
        //

        private void OnVerifyOutputListViewItemActivated(object sender, EventArgs e)
        {
            ListView OutputListView = (ListView)sender;

            foreach (object Item in OutputListView.SelectedItems)
            {
                INWN2Viewer      Viewer;
                NWN2ScriptViewer ScriptViewer;
                NWN2GameScript   Script;
                IResourceEntry   ResEntry;
                ListViewItem     LvItem   = (ListViewItem)Item;
                string           ItemText = LvItem.Text;
                string           ResName;
                string           LineString;
                string           MsgString;
                int Line;
                int i;

                //
                // Try and parse out the file name and line number of the error
                // message, if it appears to be a compiler error.
                //

                // script1.nss(5): Warning: Usage of switch blocks inside of do/while scopes generates incorrect code with the standard compiler; consider avoiding the use of do/while constructs to ensure correct code generation with the standard compiler

                i = ItemText.IndexOf('.');

                if (i == -1)
                {
                    continue;
                }

                ResName = ItemText.Substring(0, i);

                LineString = ItemText.Substring(i + 1).ToLower();

                if (!LineString.StartsWith("nss("))
                {
                    continue;
                }

                i = LineString.IndexOf(')', 4);

                if (i < 5)
                {
                    continue;
                }

                MsgString = LineString.Substring(i + 1);

                if (!MsgString.StartsWith(": error: ") &&
                    !MsgString.StartsWith(": warning: "))
                {
                    continue;
                }

                try
                {
                    Line = Convert.ToInt32(LineString.Substring(4, i - 4));
                }
                catch
                {
                    continue;
                }

                //
                // Look up the resource in the resource system.
                //

                ResEntry = ResourceManager.Instance.GetEntry(
                    new OEIResRef(ResName),
                    (ushort)ResTypes.ResNSS);

                if (ResEntry is MissingResourceEntry)
                {
                    continue;
                }

                //
                // Find the toolset data item for the script in question.
                //

                Script = null;

                try
                {
                    Viewer = NWN2ToolsetMainForm.App.GetViewerForResource(
                        ResEntry.FullName);

                    if (Viewer != null)
                    {
                        Script = (NWN2GameScript)Viewer.ViewedResource;
                    }

                    if (Script == null)
                    {
                        Script = NWN2ToolsetMainForm.App.Module.Scripts[ResName];

                        if (Script == null)
                        {
                            NWN2Campaign Campaign = NWN2CampaignManager.Instance.ActiveCampaign;

                            if (Campaign != null)
                            {
                                Script = Campaign.Scripts[ResName];
                            }
                        }

                        if (Script == null)
                        {
                            Script = new NWN2GameScript(ResEntry);
                        }
                    }
                }
                catch
                {
                    Script = null;
                }

                if (Script == null)
                {
                    continue;
                }

                //
                // If a viewer isn't open for the script yet, then open one
                // now.
                //

                Viewer = NWN2ToolsetMainForm.App.GetViewerForResource(Script);

                if (Viewer == null)
                {
                    NWN2ToolsetMainForm.App.ShowResource(Script);

                    Viewer = NWN2ToolsetMainForm.App.GetViewerForResource(Script);

                    if (Viewer == null)
                    {
                        continue;
                    }
                }
                else
                {
                    //
                    // Bring the viewer to the front.
                    //

                    NWN2ToolsetMainForm.App.ShowResource(Script);
                }

                if (!(Viewer is NWN2ScriptViewer))
                {
                    continue;
                }

                ScriptViewer = (NWN2ScriptViewer)Viewer;

                //
                // Highlight the error line.
                //

                ScriptViewer.HighlightLine(Line);
            }
        }