Beispiel #1
0
        /// <summary>
        /// wz1节点选中事件。
        /// </summary>
        public void OnSelectedNode1Changed(object sender, WzNodeEventArgs e)
        {
            if (PluginEntry.Context.SelectedTab != PluginEntry.Tab || e.Node == null ||
                this.btnLock.Checked)
            {
                return;
            }

            Wz_File file = e.Node.GetNodeWzFile();

            if (file == null)
            {
                return;
            }

            switch (file.Type)
            {
            case Wz_Type.Character:     //读取装备
                Wz_Image wzImg = e.Node.GetValue <Wz_Image>();
                if (wzImg != null && wzImg.TryExtract())
                {
                    this.SuspendUpdateDisplay();
                    LoadPart(wzImg.Node);
                    this.ResumeUpdateDisplay();
                }
                break;
            }
        }
        private void MoveToPortal(int?toMap, string pName, string fromPName = null, bool isBack = false)
        {
            if (toMap != null && toMap != this.mapData?.ID) //跳转地图
            {
                //寻找地图数据
                Wz_Node node;
                if (MapData.FindMapByID(toMap.Value, out node))
                {
                    Wz_Image img = node.GetNodeWzImage();
                    if (img != null)
                    {
                        this.mapImg         = img;
                        viewData.ToMapID    = toMap;
                        viewData.ToPortal   = pName;
                        viewData.Portal     = fromPName;
                        viewData.IsMoveBack = isBack;
                    }
                }
                else
                {
                    this.ui.ChatBox.AppendTextSystem($"没有找到ID:{toMap.Value}的地图。");
                }
            }
            else //当前地图
            {
                viewData.ToMapID  = null;
                viewData.ToPortal = null;

                var portal = this.mapData.Scene.FindPortal(pName);
                if (portal != null)
                {
                    this.cm.StartCoroutine(OnCameraMoving(new Point(portal.X, portal.Y), 500));
                }
            }
        }
Beispiel #3
0
            public void Add(Wz_Image wzImage, List <Wz_Image> currentImages)
            {
                LinkedListNode <Wz_Image> node;

                if (_dict.TryGetValue(wzImage, out node))
                {
                    //提升位置
                    if (node.Previous != null)
                    {
                        _list.Remove(node);
                        _list.AddFirst(node);
                    }
                }
                else
                {
                    //添加item
                    while (_list.Count >= MaxCount && _list.Count > 0)
                    {
                        DisposeLast(currentImages);
                    }

                    node = _list.AddFirst(wzImage);
                    _dict.Add(wzImage, node);
                }
            }
        private void MoveToPortal(int?toMap, string pName, string fromPName = null)
        {
            if (toMap != null && toMap != this.mapData.ID) //跳转地图
            {
                //寻找地图数据
                Wz_Node node;
                if (MapData.FindMapByID(toMap.Value, out node))
                {
                    Wz_Image img = node.GetNodeWzImage();
                    if (img != null)
                    {
                        this.mapImg       = img;
                        viewData.ToMapID  = toMap;
                        viewData.ToPortal = pName;
                        viewData.Portal   = fromPName;
                    }
                }
            }
            else //当前地图
            {
                viewData.ToMapID  = null;
                viewData.ToPortal = null;

                var portal = this.mapData.Scene.FindPortal(pName);
                if (portal != null)
                {
                    this.cm.StartCoroutine(OnCameraMoving(new Point(portal.X, portal.Y), 500));
                }
            }
        }
        public FrmMapRender2(Wz_Image img)
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.DeviceCreated += Graphics_DeviceCreated;
            this.mapImg             = img;
            this.MaxElapsedTime     = TimeSpan.MaxValue;
            this.IsFixedTimeStep    = false;
            this.TargetElapsedTime  = TimeSpan.FromSeconds(1.0 / 60);
            this.InactiveSleepTime  = TimeSpan.FromSeconds(1.0 / 30);
            this.IsMouseVisible     = true;

            this.Content         = new WcR2ContentManager(this.Services);
            this.patchVisibility = new PatchVisibility();
            this.patchVisibility.FootHoldVisible   = false;
            this.patchVisibility.LadderRopeVisible = false;
            this.patchVisibility.SkyWhaleVisible   = false;

            var form = Form.FromHandle(this.Window.Handle) as Form;

            form.Load        += Form_Load;
            form.GotFocus    += Form_GotFocus;
            form.LostFocus   += Form_LostFocus;
            form.FormClosing += Form_FormClosing;
            form.FormClosed  += Form_FormClosed;

            this.imeHelper = new IMEHandler(this, true);
            GameExt.FixKeyboard(this);
        }
        private void AppendContext(Wz_Node node)
        {
            Wz_Image wzImg = node.GetNodeWzImage();

            if (wzImg != null)
            {
                _currentWzImg.Add(wzImg);
            }
        }
Beispiel #7
0
        void btnItem_Click(object sender, EventArgs e)
        {
            btnItemMapRender.Enabled = false;
            Wz_Node node = Context.SelectedNode1;

            if (node != null)
            {
                Wz_Image img    = node.Value as Wz_Image;
                Wz_File  wzFile = node.GetNodeWzFile();

                if (img != null && img.TryExtract())
                {
                    if (wzFile == null || wzFile.Type != Wz_Type.Map)
                    {
                        if (MessageBoxEx.Show("所选Img不属于Map.wz,是否继续?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                        {
                            goto exit;
                        }
                    }

                    StringLinker sl = this.Context.DefaultStringLinker;
                    if (!sl.HasValues) //生成默认stringLinker
                    {
                        sl = new StringLinker();
                        sl.Load(PluginManager.FindWz(Wz_Type.String).GetValueEx <Wz_File>(null));
                    }

                    //开始绘制
                    Thread thread = new Thread(() =>
                    {
#if !DEBUG
                        try
                        {
#endif
                        FrmMapRender frm = new MapRender.FrmMapRender(img);
                        frm.StringLinker = sl;
                        frm.Run();

#if !DEBUG
                    }
                                               catch (Exception ex)
                    {
                        MessageBoxEx.Show(ex.ToString(), "MapRender");
                    }
#endif
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    goto exit;
                }
            }

            MessageBoxEx.Show("没有选择一个map的img", "MapRender");

exit:
            btnItemMapRender.Enabled = true;
        }
Beispiel #8
0
 protected override void UnloadContent()
 {
     base.UnloadContent();
     this.resLoader.Unload();
     this.ui.UnloadContents();
     this.bgm     = null;
     this.mapImg  = null;
     this.mapData = null;
 }
Beispiel #9
0
        private void OutputImg(Wz_Image img, DifferenceType diffType, string imgName, string anchorName, string menuAnchorName, string outputDir, StreamWriter sw)
        {
            StateDetail = "正在解压img";
            if (!img.TryExtract())
            {
                return;
            }

            int idx = 0;;

            switch (diffType)
            {
            case DifferenceType.Changed:
                idx = 0;
                break;

            case DifferenceType.Append:
                idx = 1;
                break;

            case DifferenceType.Remove:
                idx = 2;
                break;
            }
            Action <Wz_Node> fnOutput = null;

            fnOutput = node =>
            {
                if (node != null)
                {
                    string fullPath = node.FullPath;
                    sw.Write("<tr class=\"r{0}\">", idx);
                    sw.Write("<td>{0}</td>", fullPath ?? " ");
                    sw.Write("<td>{0}</td>", OutputNodeValue(fullPath, node.Value, 0, outputDir) ?? " ");
                    sw.WriteLine("</tr>");

                    if (node.Nodes.Count > 0)
                    {
                        foreach (Wz_Node child in node.Nodes)
                        {
                            fnOutput(child);
                        }
                    }
                }
            };

            StateDetail = "正在输出完整img结构";
            sw.WriteLine("<table class=\"img\">");
            sw.WriteLine("<tr><th colspan=\"2\"><a name=\"{1}\">wz_image: {0}</a></th></tr>", imgName, anchorName);
            fnOutput(img.Node);
            sw.WriteLine("<tr><td colspan=\"2\"><a href=\"#{1}\">{0}</a></td></tr>", "回到目录", menuAnchorName);
            sw.WriteLine("</table>");
            sw.WriteLine("<br />");
            img.Unextract();
        }
Beispiel #10
0
        private void CompareImg(Wz_Image imgNew, Wz_Image imgOld, string imgName, string anchorName, string menuAnchorName, string outputDir, StreamWriter sw)
        {
            StateDetail = "Unpacking img";
            if (!imgNew.TryExtract() || !imgOld.TryExtract())
            {
                return;
            }
            StateDetail = "Unpacking img";
            List <CompareDifference> diffList = new List <CompareDifference>(Comparer.Compare(imgNew.Node, imgOld.Node));
            StringBuilder            sb       = new StringBuilder();

            int[] count = new int[3];
            StateDetail = "Changes are being summarized and resource files are being output. Total changes: " + diffList.Count;
            foreach (var diff in diffList)
            {
                int    idx  = -1;
                string col0 = null;
                switch (diff.DifferenceType)
                {
                case DifferenceType.Changed:
                    idx  = 0;
                    col0 = diff.NodeNew.FullPath;
                    break;

                case DifferenceType.Append:
                    idx  = 1;
                    col0 = diff.NodeNew.FullPath;
                    break;

                case DifferenceType.Remove:
                    idx  = 2;
                    col0 = diff.NodeOld.FullPath;
                    break;
                }
                sb.AppendFormat("<tr class=\"r{0}\">", idx);
                sb.AppendFormat("<td>{0}</td>", col0 ?? " ");
                sb.AppendFormat("<td>{0}</td>", OutputNodeValue(col0, diff.ValueOld, 1, outputDir) ?? " ");
                sb.AppendFormat("<td>{0}</td>", OutputNodeValue(col0, diff.ValueNew, 0, outputDir) ?? " ");
                sb.AppendLine("</tr>");
                count[idx]++;
            }
            StateDetail = "Outputting comparison report";
            bool noChange = diffList.Count <= 0;

            sw.WriteLine("<table class=\"img{0}\">", noChange ? " noChange" : "");
            sw.WriteLine("<tr><th colspan=\"3\"><a name=\"{1}\">{0}</a>: {2} Modified Attributes; {3} Added Attributes; {4} Removed Attributes</th></tr>",
                         imgName, anchorName, count[0], count[1], count[2]);
            sw.WriteLine(sb.ToString());
            sw.WriteLine("<tr><td colspan=\"3\"><a href=\"#{1}\">{0}</a></td></tr>", "Back to Top", menuAnchorName);
            sw.WriteLine("</table>");
            imgNew.Unextract();
            imgOld.Unextract();
            sb = null;
        }
Beispiel #11
0
        private void CompareImg(Wz_Image imgNew, Wz_Image imgOld, string imgName, string anchorName, string menuAnchorName, string outputDir, StreamWriter sw)
        {
            StateDetail = "正在解压img";
            if (!imgNew.TryExtract() || !imgOld.TryExtract())
            {
                return;
            }
            StateDetail = "正在对比img";
            List <CompareDifference> diffList = new List <CompareDifference>(Comparer.Compare(imgNew.Node, imgOld.Node));
            StringBuilder            sb       = new StringBuilder();

            int[] count = new int[3];
            StateDetail = "正在统计概况并输出资源文件...变动项共" + diffList.Count;
            foreach (var diff in diffList)
            {
                int    idx  = -1;
                string col0 = null;
                switch (diff.DifferenceType)
                {
                case DifferenceType.Changed:
                    idx  = 0;
                    col0 = diff.NodeNew.FullPath;
                    break;

                case DifferenceType.Append:
                    idx  = 1;
                    col0 = diff.NodeNew.FullPath;
                    break;

                case DifferenceType.Remove:
                    idx  = 2;
                    col0 = diff.NodeOld.FullPath;
                    break;
                }
                sb.AppendFormat("<tr class=\"r{0}\">", idx);
                sb.AppendFormat("<td>{0}</td>", col0 ?? " ");
                sb.AppendFormat("<td>{0}</td>", OutputNodeValue(col0, diff.ValueNew, 0, outputDir) ?? " ");
                sb.AppendFormat("<td>{0}</td>", OutputNodeValue(col0, diff.ValueOld, 1, outputDir) ?? " ");
                sb.AppendLine("</tr>");
                count[idx]++;
            }
            StateDetail = "正在输出对比报告";
            bool noChange = diffList.Count <= 0;

            sw.WriteLine("<table class=\"img{0}\">", noChange ? " noChange" : "");
            sw.WriteLine("<tr><th colspan=\"3\"><a name=\"{1}\">{0}</a> 修改:{2} 新增:{3} 移除:{4}</th></tr>",
                         imgName, anchorName, count[0], count[1], count[2]);
            sw.WriteLine(sb.ToString());
            sw.WriteLine("<tr><td colspan=\"3\"><a href=\"#{1}\">{0}</a></td></tr>", "回到目录", menuAnchorName);
            sw.WriteLine("</table>");
            imgNew.Unextract();
            imgOld.Unextract();
            sb = null;
        }
        ///<inheritdoc/>
        public override void LoadMap(string imgText)
        {
            _currentMapImage = WzTreeSearcher.SearchForMap(_wzStructure.WzNode, imgText);
            Exception ex;

            _currentMapImage.TryExtract(out ex);
            if (ex != null)
            {
                throw ex;
            }
            _stringLinker = new StringLinker();
            _stringLinker.Load(PluginManager.FindWz(Wz_Type.String).GetValueEx <Wz_File>(null));
        }
 protected override void UnloadContent()
 {
     base.UnloadContent();
     if (!this.isUnloaded)
     {
         this.resLoader.Unload();
         this.ui.UnloadContents();
         this.Content.Unload();
         this.imeHelper.Dispose();
         this.bgm        = null;
         this.mapImg     = null;
         this.mapData    = null;
         this.isUnloaded = true;
     }
 }
Beispiel #14
0
        private Wz_Node FindNodeByGearID(Wz_Node characWz, int id)
        {
            string  imgName = id.ToString("D8") + ".img";
            Wz_Node imgNode = null;

            foreach (var node1 in characWz.Nodes)
            {
                if (node1.Text == imgName)
                {
                    imgNode = node1;
                    break;
                }
                else if (node1.Nodes.Count > 0)
                {
                    foreach (var node2 in node1.Nodes)
                    {
                        if (node2.Text == imgName)
                        {
                            imgNode = node2;
                            break;
                        }
                    }
                    if (imgNode != null)
                    {
                        break;
                    }
                }
            }

            if (imgNode != null)
            {
                Wz_Image img = imgNode.GetValue <Wz_Image>();
                if (img != null && img.TryExtract())
                {
                    return(img.Node);
                }
            }

            return(null);
        }
Beispiel #15
0
        public DataSet GenerateSkillTable()
        {
            Wz_Node skillWz = PluginManager.FindWz(Wz_Type.Skill);

            if (skillWz == null)
            {
                return(null);
            }

            Regex r = new Regex(@"^(\d+)\.img", RegexOptions.Compiled);

            DataSet   ds       = new DataSet();
            DataTable jobTable = new DataTable("ms_job");

            jobTable.Columns.Add("jobID", typeof(string));
            jobTable.Columns.Add("jobName", typeof(string));

            DataTable skillTable = new DataTable("ms_skill");

            skillTable.Columns.Add("jobID", typeof(string));
            skillTable.Columns.Add("skillID", typeof(string));
            skillTable.Columns.Add("skillName", typeof(string));
            skillTable.Columns.Add("skillDesc", typeof(string));
            skillTable.Columns.Add("maxLevel", typeof(int));
            skillTable.Columns.Add("invisible", typeof(bool));
            skillTable.Columns.Add("hyper", typeof(int));
            skillTable.Columns.Add("reqSkill", typeof(string));
            skillTable.Columns.Add("reqSkillLevel", typeof(int));
            skillTable.Columns.Add("reqLevel", typeof(int));

            DataTable skillLevelTable = new DataTable("ms_skillLevel");

            skillLevelTable.Columns.Add("skillID", typeof(string));
            skillLevelTable.Columns.Add("level", typeof(int));
            skillLevelTable.Columns.Add("levelDesc", typeof(string));

            DataTable skillCommonTable = new DataTable("ms_skillCommon");

            skillCommonTable.Columns.Add("skillID", typeof(string));
            skillCommonTable.Columns.Add("commonName", typeof(string));
            skillCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillPVPCommonTable = new DataTable("ms_skillPVPCommon");

            skillPVPCommonTable.Columns.Add("skillID", typeof(string));
            skillPVPCommonTable.Columns.Add("commonName", typeof(string));
            skillPVPCommonTable.Columns.Add("commonValue", typeof(string));

            DataTable skillHTable = new DataTable("ms_skillH");

            skillHTable.Columns.Add("skillID", typeof(string));
            skillHTable.Columns.Add("desc", typeof(string));
            skillHTable.Columns.Add("pdesc", typeof(string));
            skillHTable.Columns.Add("h", typeof(string));
            skillHTable.Columns.Add("ph", typeof(string));
            skillHTable.Columns.Add("hch", typeof(string));

            StringResult sr;

            foreach (Wz_Node node in skillWz.Nodes)
            {
                //获取职业
                Match    m   = r.Match(node.Text);
                Wz_Image img = node.GetValue <Wz_Image>(null);
                if (!m.Success)
                {
                    continue;
                }
                if (img == null || !img.TryExtract())
                {
                    continue;
                }
                //导入职业
                string jobID = m.Result("$1");
                sl.StringSkill2.TryGetValue(jobID, out sr);
                jobTable.Rows.Add(jobID, (sr != null ? sr["bookName"] : null));

                //获取技能
                Wz_Node skillListNode = img.Node.FindNodeByPath("skill");
                if (skillListNode == null || skillListNode.Nodes.Count <= 0)
                {
                    continue;
                }

                foreach (Wz_Node skillNode in skillListNode.Nodes)
                {
                    Skill skill = Skill.CreateFromNode(skillNode, PluginManager.FindWz);
                    if (skill == null)
                    {
                        continue;
                    }

                    // if (skill.Invisible) //过滤不可见技能
                    //     continue;

                    //导入技能
                    string skillID = skillNode.Text;
                    sl.StringSkill2.TryGetValue(skillID, out sr);

                    string reqSkill      = null;
                    int    reqSkillLevel = 0;
                    if (skill.ReqSkill.Count > 0)
                    {
                        foreach (var kv in skill.ReqSkill)
                        {
                            reqSkill      = kv.Key.ToString();
                            reqSkillLevel = kv.Value;
                        }
                    }

                    skillTable.Rows.Add(
                        jobID,
                        skillID,
                        sr != null ? sr.Name : null,
                        sr != null ? sr.Desc : null,
                        skill.MaxLevel,
                        skill.Invisible,
                        skill.Hyper,
                        reqSkill,
                        reqSkillLevel,
                        skill.ReqLevel
                        );


                    if (!skill.PreBBSkill)
                    {
                        //导入技能common
                        foreach (var kv in skill.Common)
                        {
                            skillCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        foreach (var kv in skill.PVPcommon)
                        {
                            skillPVPCommonTable.Rows.Add(
                                skillID,
                                kv.Key,
                                kv.Value
                                );
                        }
                        //导入技能说明
                        skillHTable.Rows.Add(
                            skillID,
                            sr != null ? sr["desc"] : null,
                            sr != null ? sr["pdesc"] : null,
                            sr != null ? sr["h"] : null,
                            sr != null ? sr["ph"] : null,
                            sr != null ? sr["hch"] : null
                            );
                    }

                    //导入技能等级
                    for (int i = 1, j = skill.MaxLevel + (skill.CombatOrders ? 2 : 0); i <= j; i++)
                    {
                        skill.Level = i;
                        string levelDesc = SummaryParser.GetSkillSummary(skill, sr, SummaryParams.Default);
                        skillLevelTable.Rows.Add(
                            skillID,
                            i,
                            levelDesc);
                    }
                }

                img.Unextract();
            }

            ds.Tables.Add(jobTable);
            ds.Tables.Add(skillTable);
            ds.Tables.Add(skillLevelTable);
            ds.Tables.Add(skillCommonTable);
            ds.Tables.Add(skillPVPCommonTable);
            ds.Tables.Add(skillHTable);
            return(ds);
        }
 public MapRender(Wz_Image img) : base(img)
 {
 }
Beispiel #17
0
        void btnItem_Click(object sender, EventArgs e)
        {
            Wz_Node node = Context.SelectedNode1;

            if (node != null)
            {
                Wz_Image img    = node.Value as Wz_Image;
                Wz_File  wzFile = node.GetNodeWzFile();

                if (img != null && img.TryExtract())
                {
                    if (wzFile == null || wzFile.Type != Wz_Type.Map)
                    {
                        if (MessageBoxEx.Show("The selected Img does not belong to Map.wz. Continue?", "Message", MessageBoxButtons.OKCancel) != DialogResult.OK)
                        {
                            goto exit;
                        }
                    }

                    StringLinker sl = this.Context.DefaultStringLinker;
                    if (!sl.HasValues) //生成默认stringLinker
                    {
                        sl = new StringLinker();
                        sl.Load(PluginManager.FindWz(Wz_Type.String).GetValueEx <Wz_File>(null));
                    }

                    //开始绘制
                    Thread thread = new Thread(() =>
                    {
#if !DEBUG
                        try
                        {
#endif
#if MapRenderV1
                        if (sender == btnItemMapRender)
                        {
                            if (this.mapRenderGame1 != null)
                            {
                                return;
                            }
                            this.mapRenderGame1 = new FrmMapRender(img)
                            {
                                StringLinker = sl
                            };
                            try
                            {
                                using (this.mapRenderGame1)
                                {
                                    this.mapRenderGame1.Run();
                                }
                            }
                            finally
                            {
                                this.mapRenderGame1 = null;
                            }
                        }
                        else
#endif
                        {
                            if (this.mapRenderGame2 != null)
                            {
                                return;
                            }
                            this.mapRenderGame2 = new FrmMapRender2(img)
                            {
                                StringLinker = sl
                            };
                            this.mapRenderGame2.Window.Title = "MapRender " + this.Version;
                            try
                            {
                                using (this.mapRenderGame2)
                                {
                                    this.mapRenderGame2.Run();
                                }
                            }
                            finally
                            {
                                this.mapRenderGame2 = null;
                            }
                        }
#if !DEBUG
                    }
                                               catch (Exception ex)
                    {
                        PluginManager.LogError("MapRender", ex, "MapRender error:");
                        MessageBoxEx.Show(ex.ToString(), "MapRender");
                    }
#endif
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.IsBackground = true;
                    thread.Start();
                    goto exit;
                }
            }

            MessageBoxEx.Show("Please select a Map Img.", "Message");

exit:
            return;
        }
Beispiel #18
0
        private void OutputFile(List <Wz_File> fileNew, List <Wz_File> fileOld, Wz_Type type, List <CompareDifference> diffLst, string outputDir)
        {
            string htmlFilePath = Path.Combine(outputDir, type.ToString() + ".html");

            for (int i = 1; File.Exists(htmlFilePath); i++)
            {
                htmlFilePath = Path.Combine(outputDir, string.Format("{0}_{1}.html", type, i));
            }
            string srcDirPath = Path.Combine(outputDir, Path.GetFileNameWithoutExtension(htmlFilePath) + "_files");

            if (OutputPng && !Directory.Exists(srcDirPath))
            {
                Directory.CreateDirectory(srcDirPath);
            }

            FileStream   htmlFile = null;
            StreamWriter sw       = null;

            StateInfo   = "正在努力对比文件..." + type;
            StateDetail = "正在构造输出文件";
            try
            {
                htmlFile = new FileStream(htmlFilePath, FileMode.Create, FileAccess.Write);
                sw       = new StreamWriter(htmlFile, Encoding.UTF8);
                sw.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
                sw.WriteLine("<html>");
                sw.WriteLine("<head>");
                sw.WriteLine("<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">");
                sw.WriteLine("<title>{0} {1}←{2}</title>", type, fileNew[0].Header.WzVersion, fileOld[0].Header.WzVersion);
                sw.WriteLine("<link type=\"text/css\" rel=\"stylesheet\" href=\"style.css\" />");
                sw.WriteLine("</head>");
                sw.WriteLine("<body>");
                //输出概况
                sw.WriteLine("<p class=\"wzf\">");
                sw.WriteLine("<table>");
                sw.WriteLine("<tr><th>&nbsp;</th><th>文件名</th><th>文件大小</th><th>文件版本</th></tr>");
                sw.WriteLine("<tr><td>新文件</td><td>{0}</td><td>{1}</td><td>{2}</td></tr>",
                             string.Join("<br/>", fileNew.Select(wzf => wzf.Header.FileName).ToArray()),
                             string.Join("<br/>", fileNew.Select(wzf => wzf.Header.FileSize.ToString("N0")).ToArray()),
                             string.Join("<br/>", fileNew.Select(wzf => wzf.Header.WzVersion.ToString()).ToArray())
                             );
                sw.WriteLine("<tr><td>旧文件</td><td>{0}</td><td>{1}</td><td>{2}</td></tr>",
                             string.Join("<br/>", fileOld.Select(wzf => wzf.Header.FileName).ToArray()),
                             string.Join("<br/>", fileOld.Select(wzf => wzf.Header.FileSize.ToString("N0")).ToArray()),
                             string.Join("<br/>", fileOld.Select(wzf => wzf.Header.WzVersion.ToString()).ToArray())
                             );
                sw.WriteLine("<tr><td>对比时间</td><td colspan='3'>{0:yyyy-MM-dd HH:mm:ss.fff}</td></tr>", DateTime.Now);
                sw.WriteLine("<tr><td>参数</td><td colspan='3'>{0}</td></tr>", string.Join("<br/>", new[] {
                    this.OutputPng ? "-OutputPng" : null,
                    this.OutputAddedImg ? "-OutputAddedImg" : null,
                    this.OutputRemovedImg ? "-OutputRemovedImg" : null,
                    "-PngComparison " + this.Comparer.PngComparison,
                    this.Comparer.ResolvePngLink ? "-ResolvePngLink" : null,
                }.Where(p => p != null)));
                sw.WriteLine("</table>");
                sw.WriteLine("</p>");

                //输出目录
                StringBuilder[] sb      = { new StringBuilder(), new StringBuilder(), new StringBuilder() };
                int[]           count   = new int[6];
                string[]        diffStr = { "修改", "新增", "移除" };
                foreach (CompareDifference diff in diffLst)
                {
                    int    idx    = -1;
                    string detail = null;
                    switch (diff.DifferenceType)
                    {
                    case DifferenceType.Changed:
                        idx    = 0;
                        detail = string.Format("<a name=\"m_{1}_{2}\" href=\"#a_{1}_{2}\">{0}</a>", diff.NodeNew.FullPathToFile, idx, count[idx]);
                        break;

                    case DifferenceType.Append:
                        idx = 1;
                        if (this.OutputAddedImg)
                        {
                            detail = string.Format("<a name=\"m_{1}_{2}\" href=\"#a_{1}_{2}\">{0}</a>", diff.NodeNew.FullPathToFile, idx, count[idx]);
                        }
                        else
                        {
                            detail = diff.NodeNew.FullPathToFile;
                        }
                        break;

                    case DifferenceType.Remove:
                        idx = 2;
                        if (this.OutputRemovedImg)
                        {
                            detail = string.Format("<a name=\"m_{1}_{2}\" href=\"#a_{1}_{2}\">{0}</a>", diff.NodeOld.FullPathToFile, idx, count[idx]);
                        }
                        else
                        {
                            detail = diff.NodeOld.FullPathToFile;
                        }
                        break;

                    default:
                        continue;
                    }
                    sb[idx].Append("<tr><td>");
                    sb[idx].Append(detail);
                    sb[idx].AppendLine("</td></tr>");
                    count[idx]++;
                }
                StateDetail = "正在输出目录";
                Array.Copy(count, 0, count, 3, 3);
                for (int i = 0; i < sb.Length; i++)
                {
                    sw.WriteLine("<table class=\"lst{0}\">", i);
                    sw.WriteLine("<tr><th>{0}共{1}项</th></tr>", diffStr[i], count[i]);
                    sw.Write(sb[i].ToString());
                    sw.WriteLine("</table>");
                    sb[i]    = null;
                    count[i] = 0;
                }

                foreach (CompareDifference diff in diffLst)
                {
                    switch (diff.DifferenceType)
                    {
                    case DifferenceType.Changed:
                    {
                        StateInfo = string.Format("{0}/{1}正在对比{2}", count[0], count[3], diff.NodeNew.FullPath);
                        Wz_Image imgNew, imgOld;
                        if ((imgNew = diff.ValueNew as Wz_Image) != null &&
                            ((imgOld = diff.ValueOld as Wz_Image) != null))
                        {
                            string anchorName     = "a_0_" + count[0];
                            string menuAnchorName = "m_0_" + count[0];
                            CompareImg(imgNew, imgOld, diff.NodeNew.FullPathToFile, anchorName, menuAnchorName, srcDirPath, sw);
                        }
                        count[0]++;
                    }
                    break;

                    case DifferenceType.Append:
                        if (this.OutputAddedImg)
                        {
                            StateInfo = string.Format("{0}/{1}正在输出新增{2}", count[1], count[4], diff.NodeNew.FullPath);
                            Wz_Image imgNew = diff.ValueNew as Wz_Image;
                            if (imgNew != null)
                            {
                                string anchorName     = "a_1_" + count[1];
                                string menuAnchorName = "m_1_" + count[1];
                                OutputImg(imgNew, diff.DifferenceType, diff.NodeNew.FullPathToFile, anchorName, menuAnchorName, srcDirPath, sw);
                            }
                            count[1]++;
                        }
                        break;

                    case DifferenceType.Remove:
                        if (this.OutputRemovedImg)
                        {
                            StateInfo = string.Format("{0}/{1}正在输出删除{2}", count[2], count[5], diff.NodeOld.FullPath);
                            Wz_Image imgOld = diff.ValueOld as Wz_Image;
                            if (imgOld != null)
                            {
                                string anchorName     = "a_2_" + count[2];
                                string menuAnchorName = "m_2_" + count[2];
                                OutputImg(imgOld, diff.DifferenceType, diff.NodeOld.FullPathToFile, anchorName, menuAnchorName, srcDirPath, sw);
                            }
                            count[2]++;
                        }
                        break;

                    case DifferenceType.NotChanged:
                        break;
                    }
                }
                //html结束
                sw.WriteLine("</body>");
                sw.WriteLine("</html>");
            }
            finally
            {
                try
                {
                    if (sw != null)
                    {
                        sw.Flush();
                        sw.Close();
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #19
0
        public bool Load(Wz_File stringWz)
        {
            if (stringWz == null || stringWz.Node == null)
            {
                return(false);
            }
            this.Clear();
            int id;

            foreach (Wz_Node node in stringWz.Node.Nodes)
            {
                Wz_Image image = node.Value as Wz_Image;
                if (image == null)
                {
                    continue;
                }
                switch (node.Text)
                {
                case "Pet.img":
                case "Cash.img":
                case "Ins.img":
                case "Consume.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.Desc     = GetDefaultString(tree, "desc");
                            strResult.AutoDesc = GetDefaultString(tree, "autodesc");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringItem[id] = strResult;
                        }
                    }
                    break;

                case "Etc.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree in tree0.Nodes)
                        {
                            if (Int32.TryParse(tree.Text, out id))
                            {
                                StringResult strResult = new StringResult();
                                strResult.Name     = GetDefaultString(tree, "name");
                                strResult.Desc     = GetDefaultString(tree, "desc");
                                strResult.FullPath = tree.FullPath;

                                AddAllValue(strResult, tree);
                                stringItem[id] = strResult;
                            }
                        }
                    }
                    break;

                case "Mob.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringMob[id] = strResult;
                        }
                    }
                    break;

                case "Npc.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        if (Int32.TryParse(tree.Text, out id))
                        {
                            StringResult strResult = new StringResult();
                            strResult.Name     = GetDefaultString(tree, "name");
                            strResult.Desc     = GetDefaultString(tree, "func");
                            strResult.FullPath = tree.FullPath;

                            AddAllValue(strResult, tree);
                            stringNpc[id] = strResult;
                        }
                    }
                    break;

                case "Map.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree in tree0.Nodes)
                        {
                            if (Int32.TryParse(tree.Text, out id))
                            {
                                StringResult strResult = new StringResult();
                                strResult.Name = string.Format("{0}:{1}",
                                                               GetDefaultString(tree, "streetName"),
                                                               GetDefaultString(tree, "mapName"));
                                strResult.Desc     = GetDefaultString(tree, "mapDesc");
                                strResult.FullPath = tree.FullPath;

                                AddAllValue(strResult, tree);
                                stringMap[id] = strResult;
                            }
                        }
                    }
                    break;

                case "Skill.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree in image.Node.Nodes)
                    {
                        StringResult strResult = new StringResultSkill();
                        strResult.Name  = GetDefaultString(tree, "name");   //?? GetDefaultString(tree, "bookName");
                        strResult.Desc  = GetDefaultString(tree, "desc");
                        strResult.Pdesc = GetDefaultString(tree, "pdesc");
                        strResult.SkillH.Add(GetDefaultString(tree, "h"));
                        strResult.SkillpH.Add(GetDefaultString(tree, "ph"));
                        strResult.SkillhcH.Add(GetDefaultString(tree, "hch"));
                        if (strResult.SkillH[0] == null)
                        {
                            strResult.SkillH.RemoveAt(0);
                            for (int i = 1; ; i++)
                            {
                                string hi = GetDefaultString(tree, "h" + i);
                                if (string.IsNullOrEmpty(hi))
                                {
                                    break;
                                }
                                strResult.SkillH.Add(hi);
                            }
                        }
                        strResult.SkillH.TrimExcess();
                        strResult.SkillpH.TrimExcess();
                        strResult.FullPath = tree.FullPath;

                        AddAllValue(strResult, tree);
                        if (tree.Text.Length >= 7 && Int32.TryParse(tree.Text, out id))
                        {
                            stringSkill[id] = strResult;
                        }
                        stringSkill2[tree.Text] = strResult;
                    }
                    break;

                case "Eqp.img":
                    if (!image.TryExtract())
                    {
                        break;
                    }
                    foreach (Wz_Node tree0 in image.Node.Nodes)
                    {
                        foreach (Wz_Node tree1 in tree0.Nodes)
                        {
                            foreach (Wz_Node tree in tree1.Nodes)
                            {
                                if (Int32.TryParse(tree.Text, out id))
                                {
                                    StringResult strResult = new StringResult();
                                    strResult.Name     = GetDefaultString(tree, "name");
                                    strResult.Desc     = GetDefaultString(tree, "desc");
                                    strResult.FullPath = tree.FullPath;

                                    AddAllValue(strResult, tree);
                                    stringEqp[id] = strResult;
                                }
                            }
                        }
                    }
                    break;
                }
            }

            return(this.HasValues);
        }
Beispiel #20
0
        private static Equipment CreateEquipment(Wz_Image img, bool frameIncludeSubNode)
        {
            if (!int.TryParse(Regex.Replace(img.Name, @"(^\d+).img$", "$1"), out var equipmentId))
            {
                Log($"[img名が数字以外]{img.Node.FullPath}");
                return(null);
            }
            if (!img.TryExtract())
            {
                throw new Exception();
            }
            var info      = img.Node.Nodes.SingleOrDefault(x => x.Text == "info");
            var equipment = new Equipment {
                EquipmentId = equipmentId
            };

            Console.CursorLeft = 0;
            Console.Write(img.Name);
            if (info != null)
            {
                foreach (var node in info.Nodes)
                {
                    switch (node.Text)
                    {
                    case "islot":
                        equipment.Islot = (string)node.Value;
                        break;

                    case "vslot":
                        equipment.Vslot = (string)node.Value;
                        break;

                    case "reqJob":
                        equipment.ReqJob = GetValue <int>(node.Value);
                        break;

                    case "reqLevel":
                        equipment.ReqLevel = GetValue <int>(node.Value);
                        break;

                    case "reqSTR":
                        equipment.ReqStr = GetValue <int>(node.Value);
                        break;

                    case "reqDEX":
                        equipment.ReqDex = GetValue <int>(node.Value);
                        break;

                    case "reqINT":
                        equipment.ReqInt = GetValue <int>(node.Value);
                        break;

                    case "reqLUK":
                        equipment.ReqLuk = GetValue <int>(node.Value);
                        break;

                    case "incPDD":
                        equipment.IncPdd = GetValue <int>(node.Value);
                        break;

                    case "incSTR":
                        equipment.IncStr = GetValue <int>(node.Value);
                        break;

                    case "incDEX":
                        equipment.IncDex = GetValue <int>(node.Value);
                        break;

                    case "incINT":
                        equipment.IncInt = GetValue <int>(node.Value);
                        break;

                    case "incLUK":
                        equipment.IncLuk = GetValue <int>(node.Value);
                        break;

                    case "tuc":
                        equipment.Tuc = GetValue <int>(node.Value);
                        break;

                    case "price":
                        equipment.Price = GetValue <int>(node.Value);
                        break;

                    case "cash":
                        if (node.Value is int val)
                        {
                            equipment.Cash = val;
                        }
                        else
                        {
                            equipment.Cash = int.Parse((string)node.Value);
                        }
                        break;

                    case "icon":
                        if (node.Value is Wz_Png)
                        {
                            equipment.Icon = CreateImage(node);
                        }
                        else
                        {
                            equipment.IconImageLogicalPath = node.ResolveUol().FullPath;
                        }
                        break;

                    case "iconRaw":
                        if (node.Value is Wz_Png)
                        {
                            equipment.IconRaw = CreateImage(node);
                        }
                        else
                        {
                            equipment.IconRawImageLogicalPath = node.ResolveUol().FullPath;
                        }
                        break;
                    }
                }
            }

            equipment.Frames = new List <Frame>();

            foreach (var motion in img.Node.Nodes.Where(x => x.Text != "info"))
            {
                // フレーム番号なし defaultなど
                if (motion.Nodes.Any(x => x.Value is Wz_Png || x.Value is Wz_Uol))
                {
                    var frame = CreateFrame(equipmentId, motion.Text, "", -1, motion, frameIncludeSubNode);
                    equipment.Frames.Add(frame);
                }

                if (!motion.Nodes.Any(x => x.Value is Wz_Png) &&
                    motion.Nodes.Any(x => x.Value == null && x.Nodes.Any(n => n.Value is Wz_Png || n.Value is Wz_Uol)))
                {
                    // フレーム番号あり、パターンなし ノーマルパターン
                    foreach (var wzFrame in motion.Nodes.Where(x => x.Value == null && x.Nodes.Any(n => n.Value is Wz_Png || n.Value is Wz_Uol)))
                    {
                        if (!int.TryParse(wzFrame.Text, out _))
                        {
                            Log($"[フレーム番号が数字ではない]{img.Name} - {motion.Text} - {wzFrame.Text}");
                            continue;
                        }
                        var frame = CreateFrame(equipmentId, motion.Text, "", int.Parse(wzFrame.Text), wzFrame, frameIncludeSubNode);
                        equipment.Frames.Add(frame);
                    }
                }

                if (!motion.Nodes.Any(x => x.Value is Wz_Png) &&
                    !motion.Nodes.Any(x => x.Value == null && x.Nodes.Any(n => n.Value is Wz_Png)))
                {
                    // フレーム番号あり、パターンあり
                    foreach (var outer in motion.Nodes.Where(x => x.Value == null))
                    {
                        foreach (var inner in outer.Nodes.Where(x => x.Value == null && x.Nodes.Any(n => n.Value is Wz_Png || n.Value is Wz_Uol)))
                        {
                            string frameno;
                            string pattern;
                            if (motion.Nodes.Any(x => x.Text == "0"))
                            {
                                pattern = inner.Text;
                                frameno = outer.Text;
                            }
                            else
                            {
                                pattern = outer.Text;
                                frameno = inner.Text;
                            }
                            if (!int.TryParse(frameno, out _))
                            {
                                Log($"[フレーム番号が数字ではない]{img.Name} - {motion.Text} - {pattern} - {frameno}");
                                continue;
                            }
                            var frame = CreateFrame(equipmentId, motion.Text, pattern, int.Parse(frameno), inner, frameIncludeSubNode);
                            equipment.Frames.Add(frame);
                        }
                    }
                }
            }

            return(equipment);
        }
Beispiel #21
0
        /// <summary>
        /// 比较两个节点绑定的值是否相同。
        /// </summary>
        /// <param Name="dataNew">新的值。</param>
        /// <param Name="dataOld">旧的值。</param>
        /// <returns></returns>
        public virtual bool CompareData(object dataNew, object dataOld)
        {
            // skip virtual dir
            {
                if (dataNew is Wz_File fileNew && fileNew.IsSubDir)
                {
                    dataNew = null;
                }
                if (dataOld is Wz_File fileOld && fileOld.IsSubDir)
                {
                    dataNew = null;
                }
            }

            if (dataNew == null && dataOld == null)
            {
                return(true);
            }
            if (dataNew == null ^ dataOld == null)
            {
                return(false);
            }

            Type type = dataNew.GetType();

            if (type != dataOld.GetType())
            {
                return(false);
            }

            if (type.IsClass)
            {
                switch (dataNew)
                {
                case string str:
                    return(str == (string)dataOld);

                case Wz_Image img:
                    Wz_Image imgOld = (Wz_Image)dataOld;
                    return(img.Size == imgOld.Size && img.Checksum == imgOld.Checksum);

                case Wz_File file:
                    Wz_File fileOld = (Wz_File)dataOld;
                    return(file.Type == fileOld.Type);

                case Wz_Png png:
                    Wz_Png pngOld = (Wz_Png)dataOld;
                    switch (this.PngComparison)
                    {
                    case WzPngComparison.SizeOnly:
                        return(png.Width == pngOld.Width && png.Height == pngOld.Height);

                    case WzPngComparison.SizeAndDataLength:
                        return(png.Width == pngOld.Width &&
                               png.Height == pngOld.Height &&
                               png.DataLength == pngOld.DataLength);

                    case WzPngComparison.Pixel:
                        if (!(png.Width == pngOld.Width && png.Height == pngOld.Height && png.Form == pngOld.Form))
                        {
                            return(false);
                        }
                        byte[] pixelNew = png.GetRawData();
                        byte[] pixelOld = pngOld.GetRawData();
                        if (pixelNew == null || pixelOld == null || pixelNew.Length != pixelOld.Length)
                        {
                            return(false);
                        }
                        for (int i = 0, i1 = pixelNew.Length; i < i1; i++)
                        {
                            if (pixelNew[i] != pixelOld[i])
                            {
                                return(false);
                            }
                        }
                        return(true);

                    default:
                        goto case WzPngComparison.SizeAndDataLength;
                    }
                    break;

                case Wz_Vector vector:
                    Wz_Vector vectorOld = (Wz_Vector)dataOld;
                    return(vector.X == vectorOld.X && vector.Y == vectorOld.Y);

                case Wz_Uol uol:
                    return(uol.Uol == ((Wz_Uol)dataOld).Uol);

                case Wz_Sound sound:
                    Wz_Sound soundOld = (Wz_Sound)dataOld;
                    return(sound.Ms == soundOld.Ms && sound.DataLength == soundOld.DataLength);
                }
            }

            return(object.Equals(dataNew, dataOld));
        }
Beispiel #22
0
 public void Add(Wz_Image wzImage)
 {
     Add(wzImage, null);
 }
 public FrmMapRender2(Wz_Image img)
 {
     graphics    = new GraphicsDeviceManager(this);
     this.mapImg = img;
 }
Beispiel #24
0
        public void LoadMap(Wz_Image mapImg)
        {
            this.mapImg = mapImg;

            LoadBack();
        }