コード例 #1
0
ファイル: MainForm.cs プロジェクト: uvbs/OpenAo
        private void WaterMap_BTN_Click(object sender, EventArgs e)
        {
            image = new Bitmap(512, 512);

            var idx  = MapFormatter.GetIndex("tileinfo", "WaterType");
            var temp = (_DatData[2] as object[]).Select(x => (uint)(x as object[])[idx]).ToArray();

            for (int x = 0; x < 256; x++)
            {
                for (int y = 0; y < 256; y++)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            switch (temp[x + 256 * y])
                            {
                            case 1:
                                image.SetPixel(2 * (255 - y) + i, 2 * x + j, Color.LightBlue);
                                break;

                            default:
                                image.SetPixel(2 * (255 - y) + i, 2 * x + j, Color.Green);
                                break;
                            }
                        }
                    }
                }
            }



            pictureBox2.Image = image;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: uvbs/OpenAo
        private void treeView2_dat_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var node = e.Node;

            if (node == null || !(node.Tag is Tuple <string, string, int>))
            {
                return;
            }
            var info = node.Tag as Tuple <string, string, int>;

            var temp = AtumZip.ZippedFile.UnzipItems(LoadingData.directory + info.Item1);

            using (var tempstream = new MemoryStream(temp[0].Data))
                _DatData = MapFormatter.Read(tempstream);


            if (info.Item2 == "base")
            {
                string temp5 = info.Item1;
                temp5             = temp5.Remove(temp5.Length - 4, 4);
                pictureBox2.Image = new Bitmap(PaintStuff.GetMapImage(LoadingData.directory + temp5 + ".map"), new Size(512, 512));
                PictureBox cc = new PictureBox();
                cc.Width  = pictureBox2.Width;
                cc.Height = pictureBox2.Height;
                Controls.Add(cc);
                Bitmap   crap = (Bitmap)pictureBox2.Image;
                Graphics g    = Graphics.FromImage(crap);
                Bitmap   ttt  = PaintStuff.GetWaterImage(_DatData);
                // g.DrawImage(ttt, 0, 0, 512, 512);
                SolidBrush sb = new SolidBrush(Color.Red);
                g.FillEllipse(sb, 20, 20, 20, 20);
                g.DrawEllipse(new Pen(Color.Red), 20, 20, 20, 20);
                pictureBox2.Refresh();
            }

            switch (info.Item2)
            {
            case "mapdata":

                var tempdt = MapFormatter.GetFormatter(0).GetSchema();
                tempdt.Rows.Add(_DatData[0] as object[]);
                dataGridView3.DataSource = tempdt;

                // dataGridView3.DataSource = MapFormatter.GetFormatter(0).GetSchema(new object[] { (_DatData[0] as object[] });

                break;

            case "vertexinfo":
                dataGridView3.DataSource = MapFormatter.GetFormatter(1).GetSchema(_DatData[1] as object[][]);
                break;

            case "tileinfo":
                dataGridView3.DataSource = MapFormatter.GetFormatter(2).GetSchema(_DatData[2] as object[][]);
                break;

            case "objectinfo":
                dataGridView3.DataSource = MapFormatter.GetFormatter(3).GetSchema(_DatData[3] as object[][]);
                break;
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: uvbs/OpenAo
        private void makebitmap(PictureBox box, BitmapType btype)
        {
            try
            {
                image = new Bitmap(512, 512);
                if (btype == BitmapType.SMA)
                {
                    var idx = SmaFormatter.GetIndex("tileinfo", "EventType");

                    var temp = (_SmaData[1] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray();
                    for (int x = 0; x < 256; x++)
                    {
                        for (int y = 0; y < 256; y++)
                        {
                            for (int i = 0; i < 2; i++)
                            {
                                for (int j = 0; j < 2; j++)
                                {
                                    image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black);
                                }
                            }
                        }
                    }
                    box.Image = image;
                }

                if (btype == BitmapType.DAT)
                {
                    var idx  = MapFormatter.GetIndex("tileinfo", "EventType");
                    var temp = (_DatData[2] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray();
                    for (int x = 0; x < 256; x++)
                    {
                        for (int y = 0; y < 256; y++)
                        {
                            for (int i = 0; i < 2; i++)
                            {
                                for (int j = 0; j < 2; j++)
                                {
                                    image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black);
                                }
                            }
                        }
                    }
                    box.Image = image;
                }
            }catch (Exception ex) { ErrorLogger.LogException(ex); }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: uvbs/OpenAo
        private void PadMap_BTN_Click(object sender, EventArgs e)
        {
            image = new Bitmap(512, 512);
            var idx  = MapFormatter.GetIndex("tileinfo", "EventType");
            var temp = (_DatData[2] as object[]).Select(x => (byte)(x as object[])[idx]).ToArray();

            for (int x = 0; x < 256; x++)
            {
                for (int y = 0; y < 256; y++)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            image.SetPixel(2 * (255 - y) + i, 2 * x + j, temp[x + 256 * y] == 0 ? Color.LightBlue : Color.Black);
                        }
                    }
                }
            }
            pictureBox2.Image = image;
        }
コード例 #5
0
ファイル: ServerHelpers.cs プロジェクト: uvbs/OpenAo
        /// <summary>
        /// Generates an array of map ideces and monster unique numbers
        /// from dat and sma files. 2017-01-05 panoskj
        /// </summary>
        public static object[] SomeQuery()
        {
            var dats = Directory.GetFiles(@"..\..\..\map", "*.dat");
            var smas = Directory.GetFiles(@"..\..\..\map", "*.sma");

            // data from map config
            var mapcfg = GetMapConfig(@"..\..\..\config\map.cfg").
                         ToDictionary(x => x.Item1, x => new Tuple <int, int>(x.Item2, x.Item3));

            // reads a dat file
            Func <string, Tuple <int, object> > readDat = (s) =>
            {
                int idx = int.Parse(Path.GetFileNameWithoutExtension(s));

                using (AtumZip.ZippedFile zpf = File.OpenRead(s))

                    return(new Tuple <int, object>(idx, MapFormatter.Read(zpf.At(0))));
            };

            // reads a sma file
            Func <string, Tuple <int, object> > readSma = (s) =>
            {
                int idx = int.Parse(Path.GetFileNameWithoutExtension(s));

                using (var src = File.OpenRead(s))

                    if (mapcfg.ContainsKey(idx) && mapcfg[idx].Item1 == mapcfg[idx].Item2)
                    {
                        return(new Tuple <int, object>(idx,
                                                       SmaFormatter.Read(src, (uint)mapcfg[idx].Item1)));
                    }

                    else
                    {
                        return(null);
                    }
            };

            // collects all tables containing spawn information
            var datmondata = dats.Select(x => readDat(x)).Where(x => x != null).
                             Select(x => new { Index = x.Item1, Data = (x.Item2 as object[])[3] as object[][] });

            // collects all tables containing spawn information
            var smamondata = smas.Select(x => readSma(x)).Where(x => x != null).
                             Select(x => new { Index = x.Item1, Data = (x.Item2 as object[])[2] as object[][] });

            // indeces for later use
            var idx1 = MapFormatter.GetIndex("objectinfo", "ObjectMonsterUniqueNumber");
            var idx2 = SmaFormatter.GetIndex("monsterinfo", "Monster Num");

            // from each object spawn row of each collected table
            // select the map index and ObjectMonsterUniqueNumber
            // if ObjectMonsterUniqueNumber is in range [2000000, 3000000)
            var res1 = from data in datmondata
                       from spawn in data.Data
                       where (uint)spawn[idx1] >= 2000000 && (uint)spawn[idx1] < 3000000 // or check for EventType == 6
                       select new
            {
                Index   = data.Index,
                Monster = (uint)spawn[idx1]
            };

            // from each monster spawn of each collected table
            // select the map index and Monster Num
            // if Monster Num is not 0
            var res2 = from data in smamondata
                       from spawn in data.Data
                       where (uint)spawn[idx2] != 0
                       select new
            {
                Index   = data.Index,
                Monster = (uint)spawn[idx2]
            };

            // return the distinct results
            return(res1.Concat(res2).Distinct().ToArray());
        }
コード例 #6
0
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var node = e.Node;
            var tag  = node?.Tag as treeViewTag;

            if (tag == null)
            {
                return;
            }


            var type   = (int)tag.Operation;
            var format = tag.Formatter;
            var data   = tag.Data;

            dataGridView.ReadOnly = true;

            if (type == 0)
            {
                dataGridView.DataSource = format.GetSchema(data as IEnumerable <object[]>);
            }

            if (type == 1 && node.Nodes.Count == 0)
            {
                foreach (var group in data as IEnumerable <IGrouping <object, object[]> > )
                {
                    var child = new TreeNode(group.Key.ToString() + " [" + group.Count() + "]");

                    child.Tag = new object[] { 2, null, group };

                    node.Nodes.Add(child);
                }
            }

            if (type == 2)
            {
                dataGridView.DataSource = ((node.Parent.Parent.Tag as object[])[1] as Formatter.Struct).GetSchema(data as IEnumerable <object[]>);
            }


            if (type == 3 && node.Nodes.Count == 0)
            {
                var mapinf = ((CachedInfo)data).Data as object[];

                if (mapinf == null)
                {
                    node.Name = data as string + " [Invalid]";
                }

                else
                {
                    for (int i = 1; i < 4; ++i)
                    {
                        var formatter = MapFormatter.GetFormatter(i);

                        var child = new TreeNode(formatter.Name + " [" + (mapinf[i] as object[]).Length + "]");

                        child.Tag = new treeViewTag(0, formatter, mapinf[i], null);

                        node.Nodes.Add(child);
                    }
                }
            }

            if (type == 4 && data != null)
            {
                var objinfname = ((CachedInfo)data).Name;
                var objinf0    = ((CachedInfo)data).Data as object[];

                if (objinf0 == null)
                {
                    return;
                }

                var objinf = (objinf0[1] as IEnumerable <object>).Select(x => x as object[]).Select(x => new { data = x[0] as object[], effects = x[1] as object[][] });

                if (node.Nodes.Count == 0)
                {
                    node.Nodes.Add("Name: " + (objinf0[0] as object[])[0] as string);

                    var idx1 = FormatterOmi.GetFormatter("ti_Item")["ItemNum"];
                    var idx2 = FormatterOmi.GetFormatter("ti_Item")["Kind"];
                    var idx3 = FormatterOmi.GetFormatter("ti_Item")["ItemName"];
                    var idx4 = FormatterOmi.GetFormatter("ti_Item")["SourceIndex"];

                    int sourceindex;

                    if (int.TryParse(objinfname, out sourceindex))
                    {
                        var usages = from item in omi[0] as object[][]
                                     where (uint)item[idx4] == sourceindex ||
                                     (((byte)item[idx2] == 16 || (byte)item[idx2] == 60) && (uint)item[idx4] == (sourceindex - 4000000)) ||
                                     (((byte)item[idx2] < 16) && (uint)item[idx4] == (sourceindex - 100000)) ||
                                     (((byte)item[idx2] == 25) && (uint)item[idx4] == (sourceindex - 500000))
                                     select new { ItemNum = (uint)item[idx1], ItemName = item[idx3] as string };

                        var usagesnode = new TreeNode("Used by items [" + usages.Count() + "]");

                        foreach (var usage in usages)
                        {
                            var child = new TreeNode("[" + usage.ItemNum + "] " + usage.ItemName);

                            child.Tag = new treeViewTag(0, FormatterOmi.GetFormatter("ti_Item"), (omi[0] as object[][]).Where(x => (uint)x[idx1] == usage.ItemNum), null);

                            usagesnode.Nodes.Add(child);
                        }
                        node.Nodes.Add(usagesnode);
                    }

                    var effectsnode = new TreeNode("Body Condition Effects");

                    var idx = format["BodyConditionName"];

                    foreach (var row in objinf)
                    {
                        var child = new TreeNode(row.data[idx] as string + " [" + row.effects.Length + "]");

                        child.Tag = new treeViewTag(0, ObjectInfoFormatter.GetFormatter("effects"), row.effects, null);

                        effectsnode.Nodes.Add(child);
                    }

                    node.Nodes.Add(effectsnode);
                }

                dataGridView.DataSource = format.GetSchema(objinf.Select(x => x.data));
            }

            if (type == 5 && data != null)
            {
                dataGridView.ReadOnly = false;

                var temp = ((CachedInfo)data).Data as object[];

                var idx = EffectInfoFormatter.HeaderFormatter["EffectType"];

                var efftype = (uint)(temp[0] as object[])[idx];

                var formatter = EffectInfoFormatter.GetFormatter(efftype);

                dataGridView.DataSource = formatter.GetSchema(
                    new object[][] { temp[1] as object[] });
            }
        }
コード例 #7
0
 object DeserializeMapInfo(string name)
 {
     using (AtumZip.ZippedFile zpf = File.OpenRead(@"res-map\" + name + ".dat"))
         return(MapFormatter.Read(zpf.At(0)));
 }