Beispiel #1
0
        private void changeMap(int mapid)
        {
            DataPack pack        = DataPackBook.GetPack("map");
            int      width       = pack.GetPackIndexByName("width");
            int      height      = pack.GetPackIndexByName("height");
            int      nameindex   = pack.GetPackIndexByName("name");
            int      folderindex = pack.GetPackIndexByName("url");

            selectMapSize.Width  = int.Parse(pack.data[mapid][width]);
            selectMapSize.Height = int.Parse(pack.data[mapid][height]);
            selectMapName        = pack.data[mapid][nameindex];
            selectFolder         = pack.data[mapid][folderindex];

            if (panelMap.Width == 0 || panelMap.Height == 0)
            {
                return;
            }

            baseOffside = new Point(0, 0);

            String minipath = String.Format("res/map/{0}.jpg", selectFolder);

            //if (File.Exists(minipath))
            {
                pictureBoxMiniMap.Image = MapPainter.GetNetImage(minipath);
            }

            blockInfos = new List <int>();
            RDFileInfo.GetBlockInfo(selectFolder, selectMapId, selectMapSize, blockInfos);
//            installLiveMonster();
//            installLivePlant();
            panelMap.Invalidate();
        }
Beispiel #2
0
        private void installMap()
        {
            if (listViewMaps.Items.Count > 0)
            {
                return;
            }

            DataPack pack       = DataPackBook.GetPack("map");
            int      midindex   = pack.GetPackIndexByName("id");
            int      mnameindex = pack.GetPackIndexByName("name");

            listViewMaps.Items.Clear();
            foreach (List <String> map in pack.data.Values)
            {
                string id   = map[midindex];
                string name = map[mnameindex];

                ListViewItem lvm = new ListViewItem(String.Format("{0}.{1}", id, name));
                listViewMaps.Items.Add(lvm);
            }
        }
Beispiel #3
0
        private void refreshList(int selid)
        {
            IniFile configData   = new IniFile(String.Format("config/db/{0}.ini", packName));
            string  firstbind    = configData.IniReadValue("main", "firstbind");
            string  nameindexget = configData.IniReadValue("main", "nameindex");

            if (nameindexget != "")
            {
                nameIndex = int.Parse(nameindexget);
            }

            int index = 0;

            listViewIds.Items.Clear();
            int kv = pack.GetPackIndexByName(comboBoxWord.SelectedItem.ToString());

            foreach (List <String> item in pack.data.Values)
            {
                int id = int.Parse(item[0]);

                if (kv >= 0 && textBoxValue.Text != "" && !item[kv].Contains(textBoxValue.Text))
                {
                    continue;
                }

                string name = item[nameIndex];
                if (firstbind != "")
                {
                    if (DataPackBook.GetPack(firstbind).data.ContainsKey(id))
                    {
                        name = DataPackBook.GetPack(firstbind).data[id][nameIndex];
                    }
                }
                int          commontid = pack.GetPackIndexByName("comment");
                ListViewItem lvm       = new ListViewItem(String.Format("{0}.{1}{2}", item[0], name, commontid >= 0 && item[commontid] != "" ? "(" + item[commontid] + ")" : ""));

                listViewIds.Items.Add(lvm);
                if ((index == selid && index == 0) || selid == id)
                {
                    lvm.Selected = true;
                    lvm.EnsureVisible();
                }
                index++;
            }
            this.Text = String.Format("{0} (总计{1}条)", packName, pack.data.Values.Count);
        }
Beispiel #4
0
        private void panelMap_Paint(object sender, PaintEventArgs e)
        {
            if (selectMapId == 0 || selectMapSize.Width == 0 || selectMapSize.Height == 0)
            {
                return;
            }

            if (showSkin)
            {
                for (int i = baseOffside.X / 192; i < (baseOffside.X + panelMap.Width) / 192 + 1; i++)
                {
                    for (int j = baseOffside.Y / 192; j < (baseOffside.Y + panelMap.Height) / 192 + 1; j++)
                    {
                        string imagepath = string.Format("res/map/{0}/{1}_{2}.jpg", selectFolder, j, i);
                        //if (File.Exists(imagepath))
                        {
                            Image image = MapPainter.GetNetImage(imagepath);
                            e.Graphics.DrawImage(image, i * 192 - baseOffside.X, j * 192 - baseOffside.Y);
                            image.Dispose();
                        }
                    }
                }
            }

            if (showBarrier) //是否显示阻挡
            {
                int col = (int)Math.Floor((double)selectMapSize.Width / 48);

                int xoff = baseOffside.X % 48;
                int yoff = baseOffside.Y % 34;
                for (int x = -xoff; x < panelMap.Width + xoff; x += 48)
                {
                    for (int y = -yoff; y < panelMap.Width + yoff; y += 34)
                    {
                        Point tile = TilePixelConvertor.PixelToTile(x + baseOffside.X, y + baseOffside.Y);
                        int   val  = 1;
                        if (tile.Y >= 0 && tile.X >= 0)
                        {
                            if (tile.Y * col + tile.X >= blockInfos.Count)
                            {
                                val = 0;
                            }
                            else
                            {
                                val = blockInfos[tile.Y * col + tile.X];
                            }
                        }
                        MapPainter.DrawRectTile(e.Graphics, x, y, val);

/*                        tile = TilePixelConvertor.PixelToTile(i + 32, j + 16);
 *                      val = 1;
 *                      if (tile.Y >= 0 && tile.X >= 0)
 *                      {
 *                          if (tile.Y * col + tile.X >= blockInfos.Count)
 *                              val = 2;
 *                          else
 *                              val = blockInfos[tile.Y * col + tile.X];
 *                      }
 *                      MapPainter.DrawRectTile(e.Graphics, i - baseOffside.X + 32, j - baseOffside.Y + 16, val);*/
                    }
                }
            }

            if (false && showGridLine)
            { //show region
                int col = (int)Math.Round((double)selectMapSize.Width / 64);

                OldDataPack pack         = OldDataPackBook.GetPack("cfg_map_region");
                int         mapidindex   = pack.GetPackIndexByName("mapid");
                int         mapminxindex = pack.GetPackIndexByName("min_x");
                int         mapminyindex = pack.GetPackIndexByName("min_y");
                int         mapmaxxindex = pack.GetPackIndexByName("max_x");
                int         mapmaxyindex = pack.GetPackIndexByName("max_y");
                int         typeindex    = pack.GetPackIndexByName("type");

                List <List <String> > regions = new List <List <string> >();
                foreach (List <String> rect in pack.data.Values)
                {
                    if (int.Parse(rect[mapidindex]) == selectMapId)
                    {
                        regions.Add(rect);
                    }
                }

                Dictionary <int, bool> showname = new Dictionary <int, bool>();
                for (int i = baseOffside.X / 64 * 64; i < baseOffside.X + panelMap.Width; i += 64)
                {
                    for (int j = baseOffside.Y / 32 * 32; j < baseOffside.Y + panelMap.Height; j += 32)
                    {
                        foreach (List <String> region in regions)
                        {
                            Point tile = TilePixelConvertor.PixelToTile(i, j);
                            if (TilePixelConvertor.InRegion(int.Parse(region[mapminxindex]), int.Parse(region[mapminyindex]), int.Parse(region[mapmaxxindex]), int.Parse(region[mapmaxyindex]), tile.X, tile.Y))
                            {
                                MapPainter.DrawCircleRegion(e.Graphics, i - baseOffside.X, j - baseOffside.Y, int.Parse(region[typeindex]));

                                if (tile.X >= (int.Parse(region[mapminxindex]) + int.Parse(region[mapmaxxindex])) / 2 && tile.Y >= (int.Parse(region[mapminyindex]) + int.Parse(region[mapmaxyindex])) / 2)
                                {
                                    if (!showname.ContainsKey(int.Parse(region[0])))
                                    {
                                        Font fontSong = new Font("宋体", 14, FontStyle.Bold);
                                        e.Graphics.DrawString(region[1], fontSong, Brushes.Black, i - baseOffside.X - 10, j - baseOffside.Y - 4);
                                        fontSong.Dispose();
                                        showname.Add(int.Parse(region[0]), true);
                                    }
                                }
                            }

                            tile = TilePixelConvertor.PixelToTile(i + 32, j + 16);
                            if (TilePixelConvertor.InRegion(int.Parse(region[mapminxindex]), int.Parse(region[mapminyindex]), int.Parse(region[mapmaxxindex]), int.Parse(region[mapmaxyindex]), tile.X, tile.Y))
                            {
                                MapPainter.DrawCircleRegion(e.Graphics, i - baseOffside.X + 32, j - baseOffside.Y + 16, int.Parse(region[typeindex]));
                            }
                        }
                    }
                }
            }

            if (showGridLine) //是否显示网格
            {
                int xoff = baseOffside.X % 48;
                int yoff = baseOffside.Y % 34;
                for (int i = 1; i * 48 - xoff < panelMap.Width; ++i)
                {
                    e.Graphics.DrawLine(Pens.DarkGray, i * 48 - xoff, 0, i * 48 - xoff, panelMap.Height);
                }
                for (int i = 1; i * 34 - yoff < panelMap.Height; ++i)
                {
                    e.Graphics.DrawLine(Pens.DarkGray, 0, i * 34 - yoff, panelMap.Width, i * 34 - yoff);
                }
            }

            if (false)
            {//传送点
                OldDataPack pack         = OldDataPackBook.GetPack("cfg_map_rect");
                int         frommapindex = pack.GetPackIndexByName("from_map");
                int         fromxindex   = pack.GetPackIndexByName("from_x");
                int         fromyindex   = pack.GetPackIndexByName("from_y");
                int         tomapindex   = pack.GetPackIndexByName("to_map");

                Font fontSong = new Font("宋体", 11, FontStyle.Bold);

                foreach (List <String> rect in pack.data.Values)
                {
                    int frommap = int.Parse(rect[frommapindex]);
                    int fromx   = int.Parse(rect[fromxindex]);
                    int fromy   = int.Parse(rect[fromyindex]);
                    int tomap   = int.Parse(rect[tomapindex]);

                    Rectangle dest = new Rectangle(baseOffside.X, baseOffside.Y, panelMap.Width, panelMap.Height);
                    Point     mpos = TilePixelConvertor.TileToPixel(fromx, fromy);

                    if (selectMapId == frommap && dest.Contains(mpos))
                    {
                        Image body = Image.FromFile("icons/rect.png");
                        e.Graphics.DrawImage(body, mpos.X - baseOffside.X - body.Width / 2, mpos.Y - baseOffside.Y - body.Height / 2, body.Width, body.Height);
                        body.Dispose();

                        DataPack packm     = DataPackBook.GetPack("map");
                        int      nameindex = packm.GetPackIndexByName("name");
                        String   name      = packm.data[tomap][nameindex];
                        e.Graphics.DrawString(name, fontSong, Brushes.Black, mpos.X - baseOffside.X - 10, mpos.Y - baseOffside.Y - 4);
                        e.Graphics.DrawString(name, fontSong, Brushes.Lime, mpos.X - baseOffside.X - 11, mpos.Y - baseOffside.Y - 5);
                    }
                }

                fontSong.Dispose();
            }

            if (false && showPlant) //显示植物
            {
                OldDataPack pack         = OldDataPackBook.GetPack("cfg_map_plant");
                int         idindex      = pack.GetPackIndexByName("id");
                int         mapidindex   = pack.GetPackIndexByName("mapid");
                int         plantidindex = pack.GetPackIndexByName("plantid");
                int         xindex       = pack.GetPackIndexByName("x");
                int         yindex       = pack.GetPackIndexByName("y");

                OldDataPack mpack     = OldDataPackBook.GetPack("cfg_plant");
                int         bodyindex = mpack.GetPackIndexByName("body");

                Font fontSong = new Font("宋体", 11, FontStyle.Bold);
                foreach (List <String> plant in pack.data.Values)
                {
                    int id      = int.Parse(plant[idindex]);
                    int map     = int.Parse(plant[mapidindex]);
                    int x       = int.Parse(plant[xindex]);
                    int y       = int.Parse(plant[yindex]);
                    int plantid = int.Parse(plant[plantidindex]);

                    Rectangle dest = new Rectangle(baseOffside.X, baseOffside.Y, panelMap.Width, panelMap.Height);

                    Point mpos = TilePixelConvertor.TileToPixel(x, y);
                    if (map == selectMapId && dest.Contains(mpos))
                    {
                        string bodyurl   = mpack.data[plantid][bodyindex];
                        String imagepath = String.Format("res/entity/units/plant/{0}.png", bodyurl);
                        //Image body = MapPainter.GetNetImage(imagepath);
                        // string imagepath = string.Format("res/map/{0}/{1}_{2}.jpg", selectFolder, j, i);
                        // if (File.Exists(imagepath))
                        {
                            Image image = MapPainter.GetNetImage(imagepath); //new Bitmap(imagepath);
                            e.Graphics.DrawImage(image, mpos.X - baseOffside.X - image.Width / 2, mpos.Y - baseOffside.Y - image.Height, image.Width, image.Height);
                            //body.Dispose();
                            image.Dispose();
                        }

                        e.Graphics.DrawString(id.ToString(), fontSong, Brushes.Black, mpos.X - baseOffside.X - 10, mpos.Y - baseOffside.Y - 4);
                        e.Graphics.DrawString(id.ToString(), fontSong, Brushes.White, mpos.X - baseOffside.X - 11, mpos.Y - baseOffside.Y - 5);
                    }
                }

                fontSong.Dispose();
            }

            if (showMonster) //是否绘制怪物
            {
                int monnum = 0;

                DataPack pack                = DataPackBook.GetPack("map_monster");
                int      idindex             = pack.GetPackIndexByName("id");
                int      mapidindex          = pack.GetPackIndexByName("map_id");
                int      monstergroupidindex = pack.GetPackIndexByName("monster_group_id");
                int      xindex              = pack.GetPackIndexByName("x");
                int      yindex              = pack.GetPackIndexByName("y");

                DataPack mpack            = DataPackBook.GetPack("monster");
                int      groupindex       = mpack.GetPackIndexByName("group_id");
                int      monsterbodyindex = mpack.GetPackIndexByName("monster_body");
                int      avatarbodyindex  = mpack.GetPackIndexByName("avatar_body");

                Font fontSong = new Font("宋体", 11, FontStyle.Bold);
                foreach (List <String> mapmonster in pack.data.Values)
                {
                    int id             = int.Parse(mapmonster[idindex]);
                    int map            = int.Parse(mapmonster[mapidindex]);
                    int x              = int.Parse(mapmonster[xindex]);
                    int y              = int.Parse(mapmonster[yindex]);
                    int monstergroupid = int.Parse(mapmonster[monstergroupidindex]);

                    Rectangle dest = new Rectangle(baseOffside.X, baseOffside.Y, panelMap.Width, panelMap.Height);

                    Point mpos = TilePixelConvertor.TileToPixel(x, y);
                    if (map == selectMapId && dest.Contains(mpos))
                    {
                        foreach (List <String> monster in mpack.data.Values)
                        {
                            int groupid = int.Parse(monster[groupindex]);
                            if (groupid == monstergroupid)
                            {
                                string monsterbodyurl = monster[monsterbodyindex];
                                string avatarbodyurl  = monster[avatarbodyindex];
                                string bodyurl        = "";
                                if (monsterbodyurl.Length > 0)
                                {
                                    bodyurl = monsterbodyurl;
                                }
                                else
                                {
                                    bodyurl = avatarbodyurl;
                                }
                                String imagepath = String.Format("res/entity/monster/{0}.png", bodyurl);
                                Image  body      = MapPainter.GetNetImage(imagepath); //new Bitmap(imagepath);//
                                //if (File.Exists(imagepath))
                                {
                                    e.Graphics.DrawImage(body, mpos.X - baseOffside.X - body.Width / 2, mpos.Y - baseOffside.Y - body.Height, body.Width, body.Height);
                                    body.Dispose();
                                }
                                //body.Dispose();

                                e.Graphics.DrawString(id.ToString(), fontSong, Brushes.Black, mpos.X - baseOffside.X - 10, mpos.Y - baseOffside.Y - 4);
                                e.Graphics.DrawString(id.ToString(), fontSong, Brushes.White, mpos.X - baseOffside.X - 11, mpos.Y - baseOffside.Y - 5);

                                monnum++;
                                break;
                            }
                        }
                    }
                }

                String moncount = String.Format("当前屏怪物数:{0}", monnum);
                e.Graphics.DrawString(moncount, fontSong, Brushes.Black, 4, panelMap.Height - 19);
                e.Graphics.DrawString(moncount, fontSong, Brushes.White, 3, panelMap.Height - 20);

                fontSong.Dispose();
            }

            if (showNpc)
            {
                DataPack pack       = DataPackBook.GetPack("npc");
                int      idindex    = pack.GetPackIndexByName("id");
                int      mapidindex = pack.GetPackIndexByName("mapid");
                int      xindex     = pack.GetPackIndexByName("x");
                int      yindex     = pack.GetPackIndexByName("y");
                int      nameindex  = pack.GetPackIndexByName("name");
                int      bodyindex  = pack.GetPackIndexByName("body");

                Font fontSong = new Font("宋体", 11, FontStyle.Bold);
                foreach (List <String> npc in pack.data.Values)
                {
                    int    id      = int.Parse(npc[idindex]);
                    string map     = npc[mapidindex];
                    int    x       = int.Parse(npc[xindex]);
                    int    y       = int.Parse(npc[yindex]);
                    string bodyurl = npc[bodyindex];
                    string name    = npc[nameindex];

                    Rectangle dest = new Rectangle(baseOffside.X, baseOffside.Y, panelMap.Width, panelMap.Height);

                    Point mpos = TilePixelConvertor.TileToPixel(x, y);
                    if (map.Contains(selectMapId.ToString()) && dest.Contains(mpos))
                    {
                        String imagepath = String.Format("res/entity/npc/{0}.png", bodyurl);
                        Image  body      = MapPainter.GetNetImage(imagepath);
                        //if (File.Exists(imagepath))
                        {
                            //   Image body =new Bitmap(imagepath);
                            e.Graphics.DrawImage(body, mpos.X - baseOffside.X - body.Width / 2, mpos.Y - baseOffside.Y - body.Height, body.Width, body.Height);
                            body.Dispose();
                        }

                        e.Graphics.DrawString(id + "." + name, fontSong, Brushes.Black, mpos.X - baseOffside.X - 10, mpos.Y - baseOffside.Y - 4);
                        e.Graphics.DrawString(id + "." + name, fontSong, Brushes.White, mpos.X - baseOffside.X - 11, mpos.Y - baseOffside.Y - 5);
                    }
                }

                fontSong.Dispose();
            }

            e.Graphics.FillRectangle(Brushes.Gray, 0, 0, 4, panelMap.Height);
            e.Graphics.FillRectangle(Brushes.Gray, 0, panelMap.Height - 4, panelMap.Width, 4);
            e.Graphics.FillRectangle(Brushes.Orange, 0, baseOffside.Y * panelMap.Height / selectMapSize.Height, 4, panelMap.Height * panelMap.Height / selectMapSize.Height);
            e.Graphics.FillRectangle(Brushes.Orange, baseOffside.X * panelMap.Width / selectMapSize.Width, panelMap.Height - 4, panelMap.Width * panelMap.Width / selectMapSize.Width, 4);
        }
Beispiel #5
0
        private void UCGroupItem_Paint(object sender, PaintEventArgs e)
        {
            TriDataPack data = TriDataPackBook.GetPack("drop_group");

            Font font = new Font("宋体", 10, FontStyle.Regular);

            e.Graphics.DrawString(String.Format("掉落组: {0}, 累计{1}件", val, tks.Count), font, Brushes.Black, 0, 0);

            int pos = 0;

            foreach (TriData tk in tks)
            {
                int id   = int.Parse(data.data[tk][1]);
                int type = int.Parse(data.data[tk][2]);
                int pro  = int.Parse(data.data[tk][3]);

                string url  = "";
                string name = "";
                if (type == 1)
                {
                    DataPack itm   = DataPackBook.GetPack("item");
                    int      index = itm.GetPackIndexByName("icon");
                    if (!itm.data.ContainsKey(id))
                    {
                        continue;
                    }
                    url   = string.Format("res/images/icon/item/{0}.png", itm.data[id][index]);
                    index = itm.GetPackIndexByName("name");
                    name  = itm.data[id][index];
                }
                else if (type == 2)
                {
                    DataPack itm   = DataPackBook.GetPack("equip");
                    int      index = itm.GetPackIndexByName("icon");
                    if (!itm.data.ContainsKey(id))
                    {
                        continue;
                    }
                    url   = string.Format("res/images/icon/equip/{0}.png", itm.data[id][index]);
                    index = itm.GetPackIndexByName("name");
                    name  = itm.data[id][index];
                }
                else if (type == 3)
                {
                    DataPack itm   = DataPackBook.GetPack("heji_rune");
                    int      index = itm.GetPackIndexByName("icon");
                    if (!itm.data.ContainsKey(id))
                    {
                        continue;
                    }
                    url   = string.Format("res/images/icon/rune/{0}.png", itm.data[id][index]);
                    index = itm.GetPackIndexByName("name");
                    name  = itm.data[id][index];
                }

                //if (File.Exists(url))
                Image item = MapPainter.GetNetImage(url);
                e.Graphics.DrawImage(item, pos * 45 + 5, 20, 30, 30);

                e.Graphics.DrawString(String.Format("{0}", name.Substring(0, Math.Min(name.Length, 3))), font, Brushes.Black, pos * 45, 52);
                e.Graphics.DrawString(String.Format("{0}%", pro / 10), font, Brushes.Black, pos * 45 + 5, 65);

                pos++;
            }
            font.Dispose();
        }
Beispiel #6
0
        private void UCGroupItem_Paint(object sender, PaintEventArgs e)
        {
            TriDataPack data = TriDataPackBook.GetPack("drop_group");

            Font font = new Font("宋体", 10, FontStyle.Regular);

            e.Graphics.DrawString(String.Format("物品id: {0}, 物品类型: {1}", val, type), font, Brushes.Black, 0, 0);

            int id = int.Parse(val);

            string url  = "";
            string name = "";

            if (type == 1)
            {
                DataPack itm   = DataPackBook.GetPack("item");
                int      index = itm.GetPackIndexByName("icon");
                if (!itm.data.ContainsKey(id))
                {
                    return;
                }
                url   = string.Format("res/images/icon/item/{0}.png", itm.data[id][index]);
                index = itm.GetPackIndexByName("name");
                name  = itm.data[id][index];
            }
            else if (type == 2)
            {
                DataPack itm   = DataPackBook.GetPack("equip");
                int      index = itm.GetPackIndexByName("icon");
                if (!itm.data.ContainsKey(id))
                {
                    return;
                }
                url   = string.Format("res/images/icon/equip/{0}.png", itm.data[id][index]);
                index = itm.GetPackIndexByName("name");
                name  = itm.data[id][index];
            }
            else if (type == 3)
            {
                DataPack itm   = DataPackBook.GetPack("heji_rune");
                int      index = itm.GetPackIndexByName("icon");
                if (!itm.data.ContainsKey(id))
                {
                    return;
                }
                url   = string.Format("res/images/icon/rune/{0}.png", itm.data[id][index]);
                index = itm.GetPackIndexByName("name");
                name  = itm.data[id][index];
            }

            //if (File.Exists(url))
            Image item = MapPainter.GetNetImage(url);

            if (item != null)
            {
                e.Graphics.DrawImage(item, 5, 20, 30, 30);
            }

            e.Graphics.DrawString(name, font, Brushes.Black, 52, 30);

            font.Dispose();
        }
Beispiel #7
0
        private void textBoxData_TextChanged(object sender, EventArgs e)
        {
            String[] items = textBoxData.Text.Split('|');
            int      count = 0;

            panelData.Controls.Clear();
            if (textBoxData.Text == "")
            {
                return;
            }

            try
            {
                foreach (String s in items)
                {
                    String[] itemData = s.Split(':');
                    String   path     = "";
                    String   name     = "";
                    if (int.Parse(itemData[1]) == 1 || int.Parse(itemData[1]) == 3)
                    {
                        DataPack pack      = DataPackBook.GetPack("item");
                        int      urlindex  = pack.GetPackIndexByName("icon");
                        int      nameindex = pack.GetPackIndexByName("name");
                        path = String.Format("res/images/icon/item/{0}.png", pack.data[int.Parse(itemData[0])][urlindex]);
                        name = pack.data[int.Parse(itemData[0])][nameindex];
                    }
                    else if (int.Parse(itemData[1]) == 2)
                    {
                        DataPack pack      = DataPackBook.GetPack("equip");
                        int      urlindex  = pack.GetPackIndexByName("icon");
                        int      nameindex = pack.GetPackIndexByName("name");
                        path = String.Format("res/images/icon/equip/{0}.png", pack.data[int.Parse(itemData[0])][urlindex]);
                        name = pack.data[int.Parse(itemData[0])][nameindex];
                    }
                    else if (int.Parse(itemData[1]) == 3)
                    {
                        DataPack pack      = DataPackBook.GetPack("heji_rune");
                        int      urlindex  = pack.GetPackIndexByName("icon");
                        int      nameindex = pack.GetPackIndexByName("name");
                        path = String.Format("res/images/icon/rune/{0}.png", pack.data[int.Parse(itemData[0])][urlindex]);
                        name = pack.data[int.Parse(itemData[0])][nameindex];
                    }

                    PictureBox pc = new PictureBox();
                    pc.Location = new Point((count % 2) * 90, (count / 2) * 30);
                    pc.SizeMode = PictureBoxSizeMode.Zoom;
                    pc.Width    = 20;
                    pc.Height   = 20;

                    pc.Image = MapPainter.GetNetImage(path);//Image.FromFile(path);
                    panelData.Controls.Add(pc);

                    Label lb = new Label();
                    lb.Location = new Point((count % 2) * 90 + 31, (count / 2) * 30);
                    lb.AutoSize = true;
                    lb.Text     = String.Format("{0}x{1}", name, (itemData.Length < 3 ? "1" : itemData[2]));
                    panelData.Controls.Add(lb);

                    count++;
                }

                panelData.Height = (count + 1) / 2 * 30;
            }
            catch (Exception)
            {
                panelData.Controls.Clear();

                Label lb = new Label();
                lb.Location = new Point(0, 0);
                lb.AutoSize = true;
                lb.Text     = "数据错误";
                panelData.Controls.Add(lb);

                panelData.Height = 30;
            }
        }
Beispiel #8
0
        private void textBoxData_TextChanged(object sender, EventArgs e)
        {
            Regex           regex = new Regex(@"<l><n>(?<num>\d+)</n></l>", RegexOptions.Multiline);
            string          data  = textBoxData.Text;
            MatchCollection col   = regex.Matches(data);

            foreach (Match mat in col)
            {
                string   cap  = mat.Groups["num"].Value;
                DataPack pack = DataPackBook.GetPack("npc");
                int      info = int.Parse(cap);
                if (pack.data.ContainsKey(info))
                {
                    cap = pack.data[info][1];
                }
                data = data.Replace(mat.Value, String.Format("[{0}]", cap));
            }

            regex = new Regex(@"<l><g>(?<num>\d+)</g></l>", RegexOptions.Multiline);
            col   = regex.Matches(data);
            foreach (Match mat in col)
            {
                string   cap   = mat.Groups["num"].Value;
                DataPack pack  = DataPackBook.GetPack("monster");
                int      index = pack.GetPackIndexByName("group_id");
                foreach (List <String> monsterData in pack.data.Values)
                {
                    if (monsterData[index] == cap)
                    {
                        cap = monsterData[1];
                        break;
                    }
                }
                data = data.Replace(mat.Value, String.Format("[{0}]", cap));
            }

            regex = new Regex(@"<l><z>(?<num>\d+)</z></l>", RegexOptions.Multiline);
            col   = regex.Matches(data);
            foreach (Match mat in col)
            {
                string   cap   = mat.Groups["num"].Value;
                DataPack pack  = DataPackBook.GetPack("plant");
                int      index = pack.GetPackIndexByName("group_id");
                foreach (List <String> plantData in pack.data.Values)
                {
                    if (plantData[index] == cap)
                    {
                        cap = plantData[1];
                        break;
                    }
                }
                data = data.Replace(mat.Value, String.Format("[{0}]", cap));
            }

            regex = new Regex(@"<l><f>(?<num>\d+)</f></l>", RegexOptions.Multiline);
            col   = regex.Matches(data);
            foreach (Match mat in col)
            {
                string   cap  = mat.Groups["num"].Value;
                DataPack pack = DataPackBook.GetPack("dungeon");
                int      info = int.Parse(cap);
                if (pack.data.ContainsKey(info))
                {
                    cap = pack.data[info][1];
                }
                data = data.Replace(mat.Value, String.Format("[{0}]", cap));
            }

            regex = new Regex("<l><d m=\"\\d+\" x=\"\\d+\" y=\"\\d+\">(?<name>\\w+)</d></l>", RegexOptions.Multiline);
            col   = regex.Matches(data);
            foreach (Match mat in col)
            {
                string cap = mat.Groups["name"].Value;
                data = data.Replace(mat.Value, String.Format("[{0}]", cap));
            }

            richTextBox1.Text = "";
            richTextBox1.Text = data;

            int baseq = 0;

            while (true)
            {
                int start = richTextBox1.Text.IndexOf("[", baseq);
                int end   = richTextBox1.Text.IndexOf("]", baseq);
                if (start == -1)
                {
                    break;
                }

                if (start >= 0 && end >= 0)
                {
                    richTextBox1.Select(start, end - start + 1);
                    richTextBox1.SelectionColor = Color.Blue;
                    richTextBox1.Select(start, 0);
                }
                baseq = end + 1;
            }
        }