diff --git a/DataEditorX/Core/Card.cs b/DataEditorX/Core/Card.cs index 1e56572..4eedc3b 100644 --- a/DataEditorX/Core/Card.cs +++ b/DataEditorX/Core/Card.cs @@ -14,6 +14,7 @@ public sealed class Card : IEquatable { public const int STR_SIZE = 16; public const int SETCODE_SIZE = 4; + public static Card Empty => new(0); #region 构造 /// @@ -28,8 +29,8 @@ public Card(long cardCode) alias = 0; setcode = 0; type = 0; - atk = 0; - def = 0; + atk = -1; + def = -1; level = 0; race = 0; attribute = 0; diff --git a/DataEditorX/Core/Database.cs b/DataEditorX/Core/Database.cs index 68d8c58..aa1d4ab 100644 --- a/DataEditorX/Core/Database.cs +++ b/DataEditorX/Core/Database.cs @@ -207,13 +207,15 @@ public static void InitParameters(SQLiteCommand cmd) public static void AddParameters(SQLiteCommand cmd, Card c) { + long atk = (c.atk == -1) ? 0 : c.atk; + long def = (c.def == -1) ? 0 : c.def; cmd.Parameters["@id"].Value = c.id; cmd.Parameters["@ot"].Value = c.ot; cmd.Parameters["@alias"].Value = c.alias; cmd.Parameters["@setcode"].Value = c.setcode; cmd.Parameters["@type"].Value = c.type; - cmd.Parameters["@atk"].Value = c.atk; - cmd.Parameters["@def"].Value = c.def; + cmd.Parameters["@atk"].Value = atk; + cmd.Parameters["@def"].Value = def; cmd.Parameters["@level"].Value = c.level; cmd.Parameters["@race"].Value = c.race; cmd.Parameters["@attribute"].Value = c.attribute; @@ -515,7 +517,8 @@ public static string GetSelectCondition(Card c, SQLiteParameterCollection parame sb.Append(@" AND datas.type = @type"); parameters.Add("@type", System.Data.DbType.Int64).Value = CardType.TYPE_TRAP; } - else { + else + { sb.Append(@" AND datas.type & @type = @type"); parameters.Add("@type", System.Data.DbType.Int64).Value = c.type; } @@ -527,13 +530,9 @@ public static string GetSelectCondition(Card c, SQLiteParameterCollection parame parameters.Add("@category", System.Data.DbType.Int64).Value = c.category; } - if (c.atk == -1) - { - sb.Append(@" AND datas.type & @monster AND datas.atk = 0"); - } - else if (c.atk < 0 || c.atk > 0) + if (c.atk != -1) { - sb.Append(@" AND datas.atk = @atk"); + sb.Append(@" AND datas.type & @monster AND datas.atk = @atk"); parameters.Add("@atk", System.Data.DbType.Int64).Value = c.atk; } @@ -544,13 +543,9 @@ public static string GetSelectCondition(Card c, SQLiteParameterCollection parame } else { - if (c.def == -1) - { - sb.Append(@" AND datas.type & @monster AND datas.def = 0"); - } - else if (c.def < 0 || c.def > 0) + if (c.def != -1) { - sb.Append(@" AND datas.def = @def"); + sb.Append(@" AND datas.type & @monster AND datas.def = @def"); parameters.Add("@def", System.Data.DbType.Int64).Value = c.def; } } diff --git a/DataEditorX/DataEditForm.Designer.cs b/DataEditorX/DataEditForm.Designer.cs index 680a066..6238557 100644 --- a/DataEditorX/DataEditForm.Designer.cs +++ b/DataEditorX/DataEditForm.Designer.cs @@ -296,7 +296,7 @@ private void InitializeComponent() // // cb_cardattribute // - this.cb_cardattribute.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_cardattribute.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_cardattribute.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cb_cardattribute.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F); @@ -308,7 +308,7 @@ private void InitializeComponent() // // tb_cardname // - this.tb_cardname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.tb_cardname.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tb_cardname.Font = new System.Drawing.Font("Microsoft JhengHei", 11F); this.tb_cardname.Location = new System.Drawing.Point(5, 1); @@ -320,7 +320,7 @@ private void InitializeComponent() // // cb_cardrule // - this.cb_cardrule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_cardrule.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_cardrule.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cb_cardrule.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F); @@ -332,7 +332,7 @@ private void InitializeComponent() // // cb_cardlevel // - this.cb_cardlevel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_cardlevel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_cardlevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cb_cardlevel.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F); @@ -344,7 +344,7 @@ private void InitializeComponent() // // cb_cardrace // - this.cb_cardrace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_cardrace.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_cardrace.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cb_cardrace.DropDownWidth = 107; @@ -357,7 +357,7 @@ private void InitializeComponent() // // cb_setname2 // - this.cb_setname2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_setname2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_setname2.DropDownHeight = 320; this.cb_setname2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -373,7 +373,7 @@ private void InitializeComponent() // // cb_setname1 // - this.cb_setname1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_setname1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_setname1.DropDownHeight = 320; this.cb_setname1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -389,7 +389,7 @@ private void InitializeComponent() // // cb_setname4 // - this.cb_setname4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_setname4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_setname4.DropDownHeight = 320; this.cb_setname4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -405,7 +405,7 @@ private void InitializeComponent() // // cb_setname3 // - this.cb_setname3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.cb_setname3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_setname3.DropDownHeight = 320; this.cb_setname3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -423,8 +423,8 @@ private void InitializeComponent() // this.tb_cardtext.AcceptsReturn = true; this.tb_cardtext.AcceptsTab = true; - this.tb_cardtext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.tb_cardtext.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tb_cardtext.Font = new System.Drawing.Font("Microsoft JhengHei", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.tb_cardtext.Location = new System.Drawing.Point(4, 349); @@ -572,7 +572,6 @@ private void InitializeComponent() this.tb_atk.Name = "tb_atk"; this.tb_atk.Size = new System.Drawing.Size(40, 21); this.tb_atk.TabIndex = 117; - this.tb_atk.Text = "0"; this.tb_atk.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // tb_def @@ -582,7 +581,6 @@ private void InitializeComponent() this.tb_def.Name = "tb_def"; this.tb_def.Size = new System.Drawing.Size(40, 21); this.tb_def.TabIndex = 118; - this.tb_def.Text = "0"; this.tb_def.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // tb_cardcode @@ -593,7 +591,6 @@ private void InitializeComponent() this.tb_cardcode.Name = "tb_cardcode"; this.tb_cardcode.Size = new System.Drawing.Size(67, 21); this.tb_cardcode.TabIndex = 120; - this.tb_cardcode.Text = "0"; this.tb_cardcode.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.tb_cardcode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tb_cardcode_KeyDown); // @@ -615,7 +612,6 @@ private void InitializeComponent() this.tb_cardalias.Name = "tb_cardalias"; this.tb_cardalias.Size = new System.Drawing.Size(67, 21); this.tb_cardalias.TabIndex = 119; - this.tb_cardalias.Text = "0"; this.tb_cardalias.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // btn_mod @@ -883,8 +879,8 @@ private void InitializeComponent() // // splitContainer // - this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.splitContainer.Location = new System.Drawing.Point(3, 3); this.splitContainer.Name = "splitContainer"; @@ -938,8 +934,8 @@ private void InitializeComponent() // // lv_cardlist // - this.lv_cardlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.lv_cardlist.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lv_cardlist.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.lv_cardlist.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -1007,7 +1003,7 @@ private void InitializeComponent() // // lb_scripttext // - this.lb_scripttext.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.lb_scripttext.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.lb_scripttext.BorderStyle = System.Windows.Forms.BorderStyle.None; this.lb_scripttext.Font = new System.Drawing.Font("Microsoft JhengHei UI", 9F); diff --git a/DataEditorX/DataEditForm.cs b/DataEditorX/DataEditForm.cs index 7fc54c7..ec6d650 100644 --- a/DataEditorX/DataEditForm.cs +++ b/DataEditorX/DataEditForm.cs @@ -54,10 +54,9 @@ public string DefaultScriptName //目录 readonly YgoPath ygopath = new(Application.StartupPath); /// 当前卡片 - Card oldCard = new(0); + Card oldCard = Card.Empty; /// 搜索条件 - Card srcCard = new(0); - //卡片编辑 + Card srcCard = Card.Empty; readonly CardEdit cardedit; readonly BindingList strs = new(Enumerable.Repeat("", Card.STR_SIZE).ToList()); /// @@ -128,7 +127,7 @@ void DataEditForm_Load(object sender, EventArgs e) { HideMenu();//是否需要隐藏菜单 SetTitle();//设置标题 - LoadCard(oldCard); + LoadCard(Card.Empty); menuitem_operacardsfile.Checked = MyConfig.ReadBoolean(MyConfig.TAG_SYNC_WITH_CARD); menuitem_autocheckupdate.Checked = MyConfig.ReadBoolean(MyConfig.TAG_AUTO_CHECK_UPDATE); GetLanguageItem(); @@ -463,7 +462,7 @@ void AddListView(int p) }; if (mcard.id == oldCard.id) { - items[j].Checked = true; + items[j].Selected = true; } if (i % 2 == 0) @@ -510,10 +509,13 @@ public void LoadCard(Card c) tb_cardname.Text = c.name; tb_cardtext.Text = c.NormalizedDesc; + strs.RaiseListChangedEvents = false; for (int i = 0; i < strs.Count; i++) { strs[i] = c.Str[i]; } + strs.RaiseListChangedEvents = true; + strs.ResetBindings(); lb_scripttext.ClearSelected(); //data SetSelect(cb_cardrule, c.ot); @@ -542,7 +544,7 @@ public void LoadCard(Card c) tb_pleft.Text = c.GetLeftScale().ToString(); tb_pright.Text = c.GetRightScale().ToString(); //atk,def - tb_atk.Text = c.atk.ToString(); + tb_atk.Text = (c.atk == -1) ? "" : c.atk.ToString(); if (c.IsType(Core.Info.CardType.TYPE_LINK)) { tb_def.Text = "0"; @@ -550,12 +552,12 @@ public void LoadCard(Card c) } else { - tb_def.Text = c.def.ToString(); + tb_def.Text = (c.def == -1) ? "" : c.def.ToString(); tb_def.Enabled = true; } - tb_cardcode.Text = c.id.ToString(); - tb_cardalias.Text = c.alias.ToString(); + tb_cardcode.Text = (c.id == 0) ? "" : c.id.ToString(); + tb_cardalias.Text = (c.alias == 0) ? "" : c.alias.ToString(); SetImage(c.id.ToString()); } #endregion @@ -581,18 +583,18 @@ public Card GetCard() c.category = GetCheck(pl_category); long level = GetSelect(cb_cardlevel) & 0xffffL; - uint.TryParse(tb_pleft.Text, out uint temp); - level |= (temp & 0xffU) << 24; - uint.TryParse(tb_pright.Text, out temp); - level |= (temp & 0xffU) << 16; + uint.TryParse(tb_pleft.Text, out uint left); + level |= (left & 0xffU) << 24; + uint.TryParse(tb_pright.Text, out uint right); + level |= (right & 0xffU) << 16; c.level = level; - if (tb_atk.Text == "?" || tb_atk.Text == "?") + if (String.IsNullOrWhiteSpace(tb_atk.Text)) { - c.atk = -2; + c.atk = -1; } - else if (tb_atk.Text == ".") + else if (tb_atk.Text == "?" || tb_atk.Text == "?") { - c.atk = -1; + c.atk = -2; } else { @@ -605,13 +607,13 @@ public Card GetCard() } else { - if (tb_def.Text == "?" || tb_def.Text == "?") + if (String.IsNullOrWhiteSpace(tb_def.Text)) { - c.def = -2; + c.def = -1; } - else if (tb_def.Text == ".") + else if (tb_def.Text == "?" || tb_def.Text == "?") { - c.def = -1; + c.def = -2; } else { @@ -792,8 +794,7 @@ void Search(Card c, bool preservePage) //更新临时卡片 public void Reset() { - oldCard = new Card(0); - LoadCard(oldCard); + LoadCard(Card.Empty); } #endregion diff --git a/DataEditorX/readme.txt b/DataEditorX/readme.txt index d706b98..fcb0b52 100644 --- a/DataEditorX/readme.txt +++ b/DataEditorX/readme.txt @@ -35,8 +35,8 @@ data/cardinfo_xxx.txt ★卡片搜索 1.仅支持一个系列名搜索 + 2.ATK,DEF搜索: -0: 输入-1或. ?: 输入-2或? 3.卡片名称搜索: diff --git a/DataEditorX/readme_english.txt b/DataEditorX/readme_english.txt index 03d20be..a5d653c 100644 --- a/DataEditorX/readme_english.txt +++ b/DataEditorX/readme_english.txt @@ -58,17 +58,15 @@ Copy and Replace: If there's a card with same name, replace it. Copy without Replace: If there's a card with same name, ignore it. ★Card search -1. Now it can not support search by Pendulum Scale -2. You can search card with card name/effect/Attribute/Types/Level(racnk)/effect type/card number -3. Search by ATK,DEF: - If there is a "0", input"-1"or"." - If there is a "?", input"-2"or"?" -4. Search by card name: +1. You can search a card with id, name, effect, Attribute, Type, Level (Rank) +2. Search by ATK,DEF: + ?: -2 or ? +3. Search by card name: AOJ%% start with AOJ Shooting%%Dragon start with “Shooting” and end with “Dragon” %%Warrior end with “Warrior” -5.Search by card id +4.Search by card id id or alias = 10000000 id: 10000000, alias: 0