コード例 #1
0
        public void Open(WZDirectory other, List <WZPatchOperation> operations, string Base)
        {
            int count = file.ReadValue();

            List <string> names = new List <string>();

            for (int i = 0; i < count; i++)
            {
                string Name = "";
                int    size, checksum, offset;
                byte   type = file.ReadByte();

                switch (type)
                {
                case 0x02: Name = file.ReadStringAt(true); break;

                case 0x03:
                case 0x04: Name = file.ReadString(); break;
                }

                size     = file.ReadValue();
                checksum = file.ReadValue();
                offset   = file.ReadOffset();

                switch (type)
                {
                case 0x02:
                case 0x04:
                {
                    IMGFile img = other.GetIMG(Base + ((Base == "") ? "" : "/") + Name);
                    if (img == null || img.Checksum != checksum)
                    {
                        operations.Add(new Add(file, offset + file.FileStart, size));
                    }
                    else
                    {
                        operations.Add(new Copy(other.file, img.baseOffset + other.file.FileStart, img.Size));
                    }
                    break;
                }

                case 0x03:
                {
                    names.Add(Name);
                    break;
                }
                }
            }
            foreach (string name in names)
            {
                Open(other, operations, Base + ((Base == "") ? "" : "/") + name);
            }
        }
コード例 #2
0
        public void WriteIMGs(BinaryWriter file)
        {
            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                img.Write(file);
            }


            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                directory.WriteIMGs(file);
            }
        }
コード例 #3
0
        private int CalculateIMGsSize()
        {
            int size = 0;

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                size += directory.CalculateIMGsSize();
            }
            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                size += img.Size;
            }
            return(size);
        }
コード例 #4
0
 public void CreateTempIMGs()
 {
     foreach (DictionaryEntry entry in Directories)
     {
         WZDirectory directory = (WZDirectory)entry.Value;
         directory.CreateTempIMGs();
     }
     foreach (DictionaryEntry entry in IMGs)
     {
         IMGFile img = (IMGFile)entry.Value;
         if (img.ToSave)
         {
             img.CreateTemp();
         }
     }
 }
コード例 #5
0
        public override void Write(BinaryWriter file)
        {
            if (dirOffsets.Contains(this))
            {
                WriteOffsetAt(file, (int)dirOffsets[this], (int)file.BaseStream.Position);
            }

            WritePackedInt(file, Directories.Count + IMGs.Count);

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                WriteString(file, directory.Name, 3, 1, true);
                WritePackedInt(file, directory.CalculateIMGsSize());
                WritePackedInt(file, 0); // checksum
                dirOffsets[directory] = (int)file.BaseStream.Position;
                file.Write((int)0);      // keep place for the offset
            }

            foreach (DictionaryEntry entry in IMGs)
            {
                IMGFile img = (IMGFile)entry.Value;
                img.CalculateChecksum();
                WriteString(file, img.Name, 4, 2, true);
                WritePackedInt(file, img.Size);
                WritePackedInt(file, img.Checksum);
                imgOffsets[img] = (int)file.BaseStream.Position;
                file.Write((int)0); // keep place for the offset
            }

            foreach (DictionaryEntry entry in Directories)
            {
                WZDirectory directory = (WZDirectory)entry.Value;
                directory.Write(file);
            }

            /*foreach (DictionaryEntry entry in IMGs)
             * {
             *  IMGFile img = (IMGFile)entry.Value;
             *  img.Write(file);
             * }*/
        }
コード例 #6
0
ファイル: MapEditor.cs プロジェクト: smolson4/wzmapeditor
        private void mportFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (load())
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter = ".img File|*.img";
                if (open.ShowDialog() != DialogResult.Cancel)
                {
                    ImportMap imp = new ImportMap(System.IO.Path.GetFileNameWithoutExtension(open.FileName));

                    imp.ShowDialog();
                    if (!imp.Canceled)
                    {
                        File f = new File(open.FileName);
                        IMGFile img = new IMGFile(imp.MapID.Text.PadLeft(9, '0') + ".img", f);

                        WZDirectory dir = file.Directory.GetDirectory("Map/Map" + img.Name[0]);
                        dir.IMGs.Add(img.Name, img);
                        img.Directory = dir;
                        IMGEntry sname = new IMGEntry(int.Parse(imp.MapID.Text).ToString());
                        sname.SetString("streetName", imp.StreetName.Text);
                        sname.SetString("mapName", imp.MapName.Text);
                        lock (StringLock)
                        {
                            MapEditor.stringf.Directory.GetIMG("Map.img").ToSave = true;
                            MapEditor.stringf.Directory.GetIMG("Map.img").GetChild((string)imp.MapGroup.SelectedItem).Add(sname);
                        }

                        if (Map.Instance != null)
                        {
                            OnMapUnload();
                        }
                        Map map;

                        lock (MapLock)
                            map = new Map(img);

                        map.map.ToSave = true;

                        UpdateIMGsList(true);

                        this.MapID = img.Name.Substring(0, 9);

                        ZoomLevel = 0;
                        Zoom = 1;

                        SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom));

                        GraphicPanel.Render();
                    }

                }

            }
        }
コード例 #7
0
ファイル: MapEditor.cs プロジェクト: smolson4/wzmapeditor
        private void New_Click(object sender, EventArgs e)
        {
            if (load())
            {
                NewMapWizard wizard = new NewMapWizard();
                wizard.ShowDialog();
                if (!wizard.Cancel)
                {
                    int MapID = int.Parse(wizard.MapID.Text);
                    int width = int.Parse(wizard.MapWidth.Text);
                    int height = int.Parse(wizard.MapHeight.Text);
                    int cy = Math.Min(height / 2, 300);
                    int cx = width / 2;
                    IMGFile img = new IMGFile(MapID.ToString().PadLeft(9, '0') + ".img");
                    IMGEntry info = new IMGEntry("info");
                    info.SetInt("version", 10);
                    info.SetInt("cloud", 0);
                    info.SetInt("town", wizard.IsTown.Checked ? 1 : 0);
                    info.SetInt("version", wizard.IsTown.Checked ? 1 : 0);
                    info.SetInt("returnMap", wizard.IsReturnMap.Checked ? int.Parse(wizard.ReturnMap.Text) : 999999999);
                    info.SetFloat("mobRate", 1);
                    info.SetString("bgm", ((string)wizard.BGMsList.SelectedItem).Replace(".img", ""));
                    info.SetString("mapDesc", "");
                    info.SetInt("hideMinimap", 0);
                    info.SetInt("forcedReturn", 999999999);
                    info.SetInt("moveLimit", 0);
                    info.SetString("mapMark", wizard.selectedMark);
                    info.SetInt("fieldLimit", 0);
                    info.SetInt("VRTop", cy - height);
                    info.SetInt("VRLeft", cx - width);
                    info.SetInt("VRBottom", cy);
                    info.SetInt("VRRight", cx);
                    info.SetInt("swim", wizard.IsSwim.Checked ? 1 : 0);
                    img.Add(info);
                    img.Add(MapBackground.Object.GetChild("back").Clone() as IMGEntry);
                    img.Add(new IMGEntry("life"));
                    for (int i = 0; i < 8; i++)
                    {
                        IMGEntry entry = new IMGEntry(i.ToString());
                        entry.Add(new IMGEntry("info"));
                        entry.Add(new IMGEntry("tile"));
                        entry.Add(new IMGEntry("obj"));
                        img.Add(entry);
                    }
                    img.Add(new IMGEntry("reactor"));
                    img.Add(new IMGEntry("foothold"));
                    if (wizard.IsMiniMap.Checked)
                    {
                        IMGEntry minimap = new IMGEntry("miniMap");
                        minimap.SetCanvas("canvas", new WZCanvas());
                        minimap.SetInt("width", width + 100);
                        minimap.SetInt("height", height + 100);
                        minimap.SetInt("centerX", (width - cx) + 50);
                        minimap.SetInt("centerY", (height - cy) + 50);
                        minimap.SetInt("mag", 4);
                        img.Add(minimap);
                    }
                    img.Add(new IMGEntry("portal"));
                    WZDirectory dir = file.Directory.GetDirectory("Map/Map" + img.Name[0]);
                    dir.IMGs.Add(img.Name, img);
                    img.Directory = dir;
                    IMGEntry sname = new IMGEntry(MapID.ToString());
                    sname.SetString("streetName", wizard.StreetName.Text);
                    sname.SetString("mapName", wizard.MapName.Text);
                    lock (StringLock)
                    {
                        MapEditor.stringf.Directory.GetIMG("Map.img").ToSave = true;
                        MapEditor.stringf.Directory.GetIMG("Map.img").GetChild((string)wizard.MapGroup.SelectedItem).Add(sname);
                    }

                    if (Map.Instance != null)
                    {
                        OnMapUnload();
                    }
                    Map map;

                    lock(MapLock)
                        map = new Map(img);

                    img.ToSave = true;

                    UpdateIMGsList(true);

                    this.MapID = img.Name.Substring(0, 9);

                    ZoomLevel = 0;
                    Zoom = 1;

                    SetMapSize((int)(map.Width * Zoom), (int)(map.Height * Zoom));

                    GraphicPanel.Render();
                }
            }
        }
コード例 #8
0
ファイル: MapEditor.cs プロジェクト: smolson4/wzmapeditor
        private void UpdateObjectsList()
        {
            ObjectsList.Controls.Clear();
            IMGFile objects = file.Directory.GetIMG("Obj/" + (string)ObjectsFolders.SelectedItem);
            SelectedIMG = objects;
            if (objects != null)
            {
                IMGEntry e1 = objects.GetChild((string)SubObjectsList.SelectedItem);
                if(e1 != null)
                {
                    string n1 = e1.Name;
                    foreach (IMGEntry e2 in e1.childs.Values)
                    {
                        string n2 = e2.Name;
                        foreach (IMGEntry e3 in e2.childs.Values)
                        {
                            string name = n1 + "/" + n2 + "/" + e3.Name;
                            if (e3.GetCanvas("0") != null)
                            {
                                ImageViewer imageViewer = ObjectsList.Add(e3.GetCanvas("0").GetBitmap(), name, true);
                                imageViewer.MouseClick += new MouseEventHandler(ImageViewer_MouseClick);
                                imageViewer.MouseDoubleClick += new MouseEventHandler(ImageViewer_MouseDoubleClick);
                                imageViewer.MaxWidth = 100;
                                imageViewer.MaxHeight = 100;
                                float mp = 1;
                                float dx = 0, dy = 0;
                                if (imageViewer.Width - 8 > 100)
                                {
                                    dx = 100f / (imageViewer.Width - 8);
                                }
                                if (imageViewer.Height - 20 > 100)
                                {
                                    dy = 100f / (imageViewer.Height - 20);
                                }

                                if (dx != 0 && dy == 0) mp = dx;
                                if (dy != 0 && dx == 0) mp = dy;
                                if (dx != 0 && dx != 0) mp = Math.Min(dx, dy);
                                imageViewer.Width = (int)((imageViewer.Width - 8) * mp + 8);
                                imageViewer.Height = (int)((imageViewer.Height - 20) * mp + 20);
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
ファイル: MapEditor.cs プロジェクト: smolson4/wzmapeditor
 private void LoadNames(WZDirectory dir, IMGFile strings, Hashtable names)
 {
     foreach (IMGFile life in dir.IMGs.Values)
     {
         string id = int.Parse(life.Name.Substring(0, 7)).ToString();
         names.Add(id, strings.GetString(id + "/name"));
     }
 }