private void listViewIds_SelectedIndexChanged(object sender, EventArgs e) { if (listViewIds.SelectedItems.Count <= 0) { return; } if (isInit) { if (pack.data.ContainsKey(selectId)) //数据修改后直接切换页面时的提醒 { bool isdirty = false; foreach (String head in pack.header) { String keyname = pack.header[0]; int index = pack.GetPackIndexByName(head); String value = getControlValue(panelEditZone.Controls[head] as IAutoControl); if (value != pack.data[selectId][index]) { panelEditZone.Controls["lbl" + head].ForeColor = Color.Red; //dirty标记 isdirty = true; } } if (isdirty) { if (MessageBoxEx.Show("数据修改后没有保存,确定不需要保存数据吗?", "警告", SystemIcons.Warning) != System.Windows.Forms.DialogResult.OK) { return; } } } foreach (String head in pack.header) { panelEditZone.Controls["lbl" + head].ForeColor = Color.Black;//dirty标记还原 } } searchBase = listViewIds.SelectedIndices[0]; String[] data = listViewIds.SelectedItems[0].Text.Split('.'); if (lastSelected != null) { lastSelected.BackColor = System.Drawing.SystemColors.Window; } listViewIds.SelectedItems[0].BackColor = Color.Gold; selectId = int.Parse(data[0]); lastSelected = listViewIds.SelectedItems[0]; foreach (String head in pack.header) { int index = pack.GetPackIndexByName(head); setControlValue(panelEditZone.Controls[head] as IAutoControl, pack.data[selectId][index]); } }
private void DataViewForm_Load(object sender, EventArgs e) { pack = OldDataPackBook.GetPack(packName); foreach (String head in pack.header) { dataGridView1.Columns.Add(head, head); int index = pack.GetPackIndexByName(head); if (pack.datatype[index] == "int") { dataGridView1.Columns[head].Width = 40; } dataGridView1.Columns[head].HeaderText = pack.comment[index]; } foreach (int key in pack.data.Keys) { dataGridView1.Rows.Add(pack.data[key].ToArray()); dataGridView1.Rows[dataGridView1.Rows.Count - 1].HeaderCell.Value = key.ToString(); } this.Text = String.Format("{0} (总计{1}条) (缓存时间{2})", packName, pack.data.Values.Count, pack.cachTime.ToString()); isLoad = true; }
private void installMonster() { if (listViewMonster.Items.Count > 0) { return; } OldDataPack pack = OldDataPackBook.GetPack("cfg_monster"); int midindex = pack.GetPackIndexByName("mid"); int mnameindex = pack.GetPackIndexByName("name"); listViewMonster.Items.Clear(); foreach (List <String> monster in pack.data.Values) { string id = monster[midindex]; string name = monster[mnameindex]; ListViewItem lvm = new ListViewItem(String.Format("{0}.{1}", id, name)); listViewMonster.Items.Add(lvm); } }
private void installPlant() { if (listViewPlant.Items.Count > 0) { return; } OldDataPack pack = OldDataPackBook.GetPack("cfg_plant"); int pidindex = pack.GetPackIndexByName("id"); int pnameindex = pack.GetPackIndexByName("name"); listViewPlant.Items.Clear(); foreach (List <String> plant in pack.data.Values) { string id = plant[pidindex]; string name = plant[pnameindex]; ListViewItem lvm = new ListViewItem(String.Format("{0}.{1}", id, name)); listViewPlant.Items.Add(lvm); } }
private void installLiveMonster() { OldDataPack pack = OldDataPackBook.GetPack("cfg_map_monster"); int idindex = pack.GetPackIndexByName("id"); int mapidindex = pack.GetPackIndexByName("mapid"); int monsteridindex = pack.GetPackIndexByName("monsterid"); OldDataPack packM = OldDataPackBook.GetPack("cfg_monster"); int mnameindex = packM.GetPackIndexByName("name"); listViewLives.Items.Clear(); foreach (List <String> monster in pack.data.Values) { string id = monster[idindex]; string map = monster[mapidindex]; int mid = int.Parse(monster[monsteridindex]); if (int.Parse(map) == selectMapId) { ListViewItem lvm = new ListViewItem(String.Format("{0}.{1} (id={2})", id, packM.data[mid][mnameindex], mid)); listViewLives.Items.Add(lvm); } } }
private void installLivePlant() { OldDataPack pack = OldDataPackBook.GetPack("cfg_map_plant"); int idindex = pack.GetPackIndexByName("id"); int mapidindex = pack.GetPackIndexByName("mapid"); int plantidindex = pack.GetPackIndexByName("plantid"); OldDataPack packM = OldDataPackBook.GetPack("cfg_plant"); int pnameindex = packM.GetPackIndexByName("name"); listViewVegas.Items.Clear(); foreach (List <String> plant in pack.data.Values) { string id = plant[idindex]; string map = plant[mapidindex]; int pid = int.Parse(plant[plantidindex]); if (int.Parse(map) == selectMapId) { ListViewItem lvm = new ListViewItem(String.Format("{0}.{1} (id={2})", id, packM.data[pid][pnameindex], pid)); listViewVegas.Items.Add(lvm); } } }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!isLoad) { return; } string head = pack.header[e.ColumnIndex]; int index = int.Parse(dataGridView1.Rows[e.RowIndex].HeaderCell.Value.ToString()); string value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); int off = pack.GetPackIndexByName(head); if (value != pack.data[index][off]) { pack.EditPackData(index, head, value); } }
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); }
private void listViewIds_SelectedIndexChanged(object sender, EventArgs e) { if (listViewIds.SelectedItems.Count <= 0) { return; } panelEditZone.Controls.Clear(); if (lastSelected != null) { lastSelected.BackColor = System.Drawing.SystemColors.Window; } listViewIds.SelectedItems[0].BackColor = Color.Gold; lastSelected = listViewIds.SelectedItems[0]; IniFile configData = new IniFile(String.Format("config/db/cfg_movie.ini")); String[] data = listViewIds.SelectedItems[0].Text.Split('.'); selectId = int.Parse(data[0]); int index = 0; int row = 0; int col = 0; List <List <String> > tDatas = new List <List <string> >(); foreach (int key in pack.data.Keys) { if (int.Parse(pack.data[key][1]) != selectId) { continue; } tDatas.Add(pack.data[key]); } tDatas.Sort(new CompareByTime()); foreach (List <String> dps in tDatas) { int key = int.Parse(dps[0]); index = 0; int wid = panelEditZone.Width / 2; Point offside = new Point(8, 20); Font fontsong = new Font("宋体", 10, FontStyle.Regular); foreach (String head in pack.header) { int indx = pack.GetPackIndexByName(head); // if (indx == 0) // continue; #region 构建控件 Label lbl = new Label(); lbl.Location = new Point(col * wid + offside.X, row * 30 + offside.Y); lbl.Text = head; lbl.AutoSize = true; lbl.Font = fontsong; lbl.Name = "lbl" + head; panelEditZone.Controls.Add(lbl); Label lbl2 = new Label(); lbl2.ForeColor = Color.DarkBlue; lbl2.Location = new Point(lbl.Location.X + lbl.Width + 5, row * 30 + 3 + offside.Y); lbl2.Text = pack.comment[indx]; int wordscap = (165 - lbl.Width) / 16; if (lbl2.Text.Length > wordscap) { if (wordscap <= 0) { lbl2.Text = ""; } else { lbl2.Text = String.Format("{0}...", lbl2.Text.Substring(0, wordscap - 1)); } } lbl2.AutoSize = true; panelEditZone.Controls.Add(lbl2); string enums = configData.IniReadValue(head, "enums"); string bind = configData.IniReadValue(head, "bind"); Control c; if (enums != "") //combox { c = new UCComboBox(); (c as UCComboBox).Info = enums; } else if (bind != "") //boxlabel { c = new UCBoxLabel(); (c as UCBoxLabel).TableName = bind; } else //textbox { c = new UCTextBox(); if (pack.datatype[indx] == "char") { (c as UCTextBox).TextSize = pack.datasize[indx]; } } // c.Enabled = (indx > 1 && (packName!="cfg_monster_group_drop" || bikey.a != bikey.b)); c.Name = String.Format("{0}-{1}", head, key); c.Location = new Point(col * wid + 170 + offside.X, row * 30 + offside.Y); if (c.Height > 30) { row += c.Height / 30; col = 0; } panelEditZone.Controls.Add(c); #endregion setControlValue(c as IAutoControl, pack.data[key][indx]); index++; if (index == 1) { row++; col = 0; } else if (indx < pack.datatype.Count && col == 0 && (pack.datatype[indx] != "char" || pack.datasize[indx] <= 8) && (indx > pack.datatype.Count - 2 || pack.datatype[indx + 1] != "char" || pack.datasize[indx + 1] <= 8)) { col++; } else { row++; col = 0; } } row += 2; col = 0; fontsong.Dispose(); } Button tb = new Button(); tb.Text = "新建"; tb.Location = new Point(30, row * 30); tb.Click += buttonAdd_Click; panelEditZone.Controls.Add(tb); tb = new Button(); tb.Text = "删除"; tb.Location = new Point(130, row * 30); tb.Click += buttonDelete_Click; panelEditZone.Controls.Add(tb); tb = new Button(); tb.Text = "保存"; tb.Location = new Point(230, row * 30); tb.Click += buttonEdit_Click; panelEditZone.Controls.Add(tb); row += 2; panelEditZone.Height = (row + 2) * 30; searchBase = listViewIds.SelectedIndices[0]; }