예제 #1
0
        /// <summary>
        /// Begin loading WZ data corresponding to the selected tab
        /// </summary>
        private void BtnWzLoad_Click(object sender, EventArgs e)
        {
            string folderPath = TextWzPath.Text;

            if (folderPath.Length > 0)
            {
                if (!folderPath.Equals(Settings.Default.PathCache))
                {
                    Settings.Default.PathCache = folderPath;
                    Settings.Default.Save();
                }
                string         stringWzPath = folderPath + @"/String";
                WzMapleVersion mapleVersion;

                if (File.Exists(stringWzPath + Resources.FileExtension))
                {
                    if (ComboEncType.SelectedIndex == 0)
                    {
                        mapleVersion = WzTool.DetectMapleVersion(stringWzPath + Resources.FileExtension, out _);
                    }
                    else
                    {
                        mapleVersion = (WzMapleVersion)
                                       ComboEncType.SelectedIndex - 1;
                    }

                    stringWz = new WzFile(stringWzPath + Resources.FileExtension, mapleVersion);
                    stringWz.ParseWzFile();
                    short?version = stringWz.Version;
                    if (WzTool.GetDecryptionSuccessRate(stringWzPath + Resources.FileExtension, mapleVersion, ref version) < 0.8)
                    {
                        MessageBox.Show(Resources.BadEncryption, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (Directory.Exists(stringWzPath))     // KMS
                {
                    mapleVersion = WzMapleVersion.EMS;
                    stringWz     = new WzFile(stringWzPath, mapleVersion);
                    WzDirectory dir = new WzDirectory("String", stringWz);
                    stringWz.WzDirectory = dir;
                    RecursivelyLoadDirectory(dir, stringWzPath, mapleVersion);
                }
                else
                {
                    MessageBox.Show(Resources.MissingStringFile, Resources.FIleNotFound, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DisposeWzFiles();
                    return;
                }
                StringUtility = new WzStringUtility(stringWz);
                LoadWzData(mapleVersion, folderPath);
            }
            DisposeWzFiles();
        }
예제 #2
0
        public void TestEmptyWzFileSerializes()
        {
            var file = new WzFile(1, WzMapleVersionType.Classic);

            using var ms = new MemoryStream();
            file.Serialize(ms);
            var contents     = Encoding.ASCII.GetString(ms.ToArray());
            var deserialized = WzObject.DeserializeFile(contents);

            Assert.IsNotNull(deserialized);
        }
예제 #3
0
        public void TestWzFile()
        {
            var file = new WzFile(1, WzMapleVersion.Classic);

            using (var ms = new MemoryStream())
            {
                file.Export(ms);
                var contents = Encoding.ASCII.GetString(ms.ToArray());
                Assert.AreEqual(374, contents.Length);
            }
        }
예제 #4
0
        public override void LoadFromWz(WzFile file)
        {
            Logger.Information("Loading Npcs");

            var dir = file.WzDirectory.GetDirectoryByName("Npc");

            dir.WzImages.ForEach(x =>
            {
                var npc = new NpcReference(x);
                Data.Data.Add(npc.MapleId, npc);
            });
        }
예제 #5
0
 public WzStringUtility(WzFile StringWZ)
 {
     EqpImage     = StringWZ.WzDirectory.GetImageByName("Eqp.img");
     EtcImage     = StringWZ.WzDirectory.GetImageByName("Etc.img");
     CashImage    = StringWZ.WzDirectory.GetImageByName("Cash.img");
     InsImage     = StringWZ.WzDirectory.GetImageByName("Ins.img");
     ConsumeImage = StringWZ.WzDirectory.GetImageByName("Consume.img");
     MapImage     = StringWZ.WzDirectory.GetImageByName("Map.img");
     MobImage     = StringWZ.WzDirectory.GetImageByName("Mob.img");
     SkillImage   = StringWZ.WzDirectory.GetImageByName("Skill.img");
     NPCImage     = StringWZ.WzDirectory.GetImageByName("Npc.img");
     PetImage     = StringWZ.WzDirectory.GetImageByName("Pet.img");
 }
예제 #6
0
 public StringWz(WzFile StringWZ, bool isFamiliar)
 {
     StringWZ.ParseWzFile();
     if (isFamiliar)
     {
         FamiliarImage = StringWZ.WzDirectory.GetImageByName("Familiar.img");
         MobImage      = StringWZ.WzDirectory.GetImageByName("Mob.img");
         ConsumeImage  = StringWZ.WzDirectory.GetImageByName("Consume.img");
     }
     else
     {
         EqpImage = StringWZ.WzDirectory.GetImageByName("Eqp.img");
     }
 }
예제 #7
0
        public override void Start()
        {
            WzFile file = MapleFileCache.Instance["Effect"];


            this.currentID = 91000000;
            ExportImage(file.WzDirectory["ItemEff.img"] as WzImage);
            this.currentID = 92000000;
            ExportImage(file.WzDirectory["SetEff.img"] as WzImage);
            this.currentID = 93000000;
            ExportImage(file.WzDirectory["CharacterEff.img"] as WzImage);
            this.currentID = 94000000;
            ExportImage(file.WzDirectory["SetItemInfoEff.img"] as WzImage);
        }
예제 #8
0
        /// <summary>
        /// Gets the '_inlink' WzCanvasProperty of this.
        ///
        /// '_inlink' is not implemented as part of WzCanvasProperty as I dont want to override existing Wz structure.
        /// It will be handled via HaRepackerMainPanel instead.
        /// </summary>
        /// <returns></returns>
        public WzImageProperty GetLinkedWzCanvasProperty()
        {
            if (!HaveInlinkProperty() && !HaveOutlinkProperty())
            {
                return(null);
            }

            string _inlink  = ((WzStringProperty)this[InlinkPropertyName])?.Value;  // could get nexon'd here. In case they place an _inlink that's not WzStringProperty
            string _outlink = ((WzStringProperty)this[OutlinkPropertyName])?.Value; // could get nexon'd here. In case they place an _outlink that's not WzStringProperty

            if (_inlink != null)
            {
                WzObject currentWzObj = this; // first object to work with
                while ((currentWzObj = currentWzObj.Parent) != null)
                {
                    if (!(currentWzObj is WzImage))  // keep looping if its not a WzImage
                    {
                        continue;
                    }

                    WzImage         wzImageParent = (WzImage)currentWzObj;
                    WzImageProperty foundProperty = wzImageParent.GetFromPath(_inlink);
                    if (foundProperty != null && foundProperty is WzImageProperty)
                    {
                        return((WzImageProperty)foundProperty);
                    }
                }
            }
            else if (_outlink != null)
            {
                WzObject currentWzObj = this; // first object to work with
                while ((currentWzObj = currentWzObj.Parent) != null)
                {
                    System.Diagnostics.Debug.WriteLine(currentWzObj.ToString());
                    if (!(currentWzObj is WzDirectory))  // keep looping if its not a WzImage
                    {
                        continue;
                    }

                    WzFile   wzFileParent  = ((WzDirectory)currentWzObj).wzFile;
                    WzObject foundProperty = wzFileParent.GetObjectFromPath(_outlink);
                    if (foundProperty != null && foundProperty is WzImageProperty)
                    {
                        return((WzImageProperty)foundProperty);
                    }
                }
            }
            return(null);
        }
예제 #9
0
        public R GetWzFile(string path, string filename, short version, short mv)
        {
            var    r = R.Init();
            WzFile wzFile;

            if (!_wzFiles.ContainsKey(filename))
            {
                var mapleVer = WzMapleVersion.Gms;
                switch (mv)
                {
                case 1:
                    mapleVer = WzMapleVersion.Gms;
                    break;

                case 2:
                    mapleVer = WzMapleVersion.Ems;
                    break;

                case 3:
                    mapleVer = WzMapleVersion.Bms;
                    break;
                }

                wzFile = new WzFile(path + "/" + filename, version, mapleVer);
                try
                {
                    wzFile.ParseWzFile();
                    _wzFiles[filename] = wzFile;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    return(r.SetResult(500, e.Message));
                }
            }

            wzFile = _wzFiles[filename];
            var dir = ListSort(wzFile.WzDirectory.WzDirectories
                               .Select(wzDirectoryWzDirectory => wzDirectoryWzDirectory.Name)
                               .ToList());
            var img = ListSort(wzFile.WzDirectory.WzImages.Select(wzDirectoryWzImage => wzDirectoryWzImage.Name)
                               .ToList());
            var map = new Dictionary <string, List <string> > {
                ["dir"] = dir, ["img"] = img
            };

            return(r.SetResult(200, $"获取{filename}文件成功!", map));
        }
예제 #10
0
파일: NewForm.cs 프로젝트: Aeopp/Github
 private void okButton_Click(object sender, EventArgs e)
 {
     if (regBox.Checked)
     {
         WzFile file = new WzFile((short)versionBox.Value, (WzMapleVersion)encryptionBox.SelectedIndex);
         file.Header.Copyright = copyrightBox.Text;
         file.Header.RecalculateFileStart();
         file.Name             = nameBox.Text + ".wz";
         file.WzDirectory.Name = nameBox.Text + ".wz";
         panel.DataTree.Nodes.Add(new WzNode(file));
     }
     else
     {
         new ListEditor(null, (WzMapleVersion)encryptionBox.SelectedIndex).Show();
     }
     Close();
 }
예제 #11
0
        public override void Start()
        {
            WzFile file = MapleFileCache.Instance["Item"];

            {
                List <string> types = new List <string>();
                foreach (var item in file.WzDirectory.GetImageByName("ItemOption.img").WzProperties) // 00000001
                {
                    int    id   = Convert.ToInt32(item.Name);
                    string desc = "";
                    if (item["info"] != null)
                    {
                        desc = item["info"]["string"].ToStringValue();
                    }

                    SQLStrings.Instance.AppendRow("item_option", id, "desc", desc);

                    foreach (var level in item["level"].WzProperties) // 00000001
                    {
                        string optionlist = "";
                        foreach (var option in level.WzProperties)
                        {
                            if (optionlist != "")
                            {
                                optionlist += ';';
                            }
                            optionlist += option.Name + '=' + option.WzValue.ToString();
                        }
                        //Console.WriteLine("Optionlist: {0}", optionlist);
                        SqlFileItemOptions.AppendToFile(id, Convert.ToInt32(level.Name), optionlist);
                    }
                }
            }

            foreach (var key in new string[] {
                "Cash", "Consume", "Install", "Etc"
            })
            {
                Console.WriteLine("Block {0}", key);
                HandleItemCategory(file[key] as WzDirectory);
            }

            Console.WriteLine("Block Pet");
            HandlePets(file["Pet"] as WzDirectory);
        }
예제 #12
0
        /// <summary>
        /// clears all collections, closes underlying file readers
        /// then calls the garbage collector for each loaded WZ file
        /// </summary>
        private void DisposeWzFiles()
        {
            stringWz?.Dispose();
            itemWz?.Dispose();
            characterWz?.Dispose();
            mapWz?.Dispose();
            mobWz?.Dispose();
            skillWz?.Dispose();
            npcWz?.Dispose();

            stringWz    = null;
            itemWz      = null;
            characterWz = null;
            mapWz       = null;
            mobWz       = null;
            skillWz     = null;
            npcWz       = null;
        }
예제 #13
0
 public bool LoadWzFile(string name)
 {
     try
     {
         WzFile wzf = new WzFile(Path.Combine(baseDir, Capitalize(name) + ".wz"), version);
         wzf.ParseWzFile();
         name                = name.ToLower();
         wzFiles[name]       = wzf;
         wzFilesUpdated[wzf] = false;
         wzDirs[name]        = new WzMainDirectory(wzf);
         return(true);
     }
     catch (Exception e)
     {
         HaRepackerLib.Warning.Error("Error initializing " + name + ".wz (" + e.Message + ").\r\nCheck that the directory is valid and the file is not in use.");
         return(false);
     }
 }
 public void SerializeFile(WzFile file, string path)
 {
     SerializeObject(file, path);
 }
 public void SerializeFile(WzFile f, string outPath)
 {
     SerializeDirectory(f.WzDirectory, outPath);
 }
 public void SerializeFile(WzFile file, string path)
 {
     SerializeDirectory(file.WzDirectory, path);
 }