Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DataEditorX/Core/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public sealed class Card : IEquatable<Card>
{
public const int STR_SIZE = 16;
public const int SETCODE_SIZE = 4;
public static Card Empty => new(0);

#region 构造
/// <summary>
Expand All @@ -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;
Expand Down
25 changes: 10 additions & 15 deletions DataEditorX/Core/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand Down
36 changes: 16 additions & 20 deletions DataEditorX/DataEditForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 24 additions & 23 deletions DataEditorX/DataEditForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public string DefaultScriptName
//目录
readonly YgoPath ygopath = new(Application.StartupPath);
/// <summary>当前卡片</summary>
Card oldCard = new(0);
Card oldCard = Card.Empty;
/// <summary>搜索条件</summary>
Card srcCard = new(0);
//卡片编辑
Card srcCard = Card.Empty;
readonly CardEdit cardedit;
readonly BindingList<string> strs = new(Enumerable.Repeat("", Card.STR_SIZE).ToList());
/// <summary>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -542,20 +544,20 @@ 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))
Comment thread
salix5 marked this conversation as resolved.
{
tb_def.Text = "0";
tb_def.Enabled = false;
}
else
{
tb_def.Text = c.def.ToString();
tb_def.Text = (c.def == -1) ? "" : c.def.ToString();
tb_def.Enabled = true;
Comment thread
salix5 marked this conversation as resolved.
}

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
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -792,8 +794,7 @@ void Search(Card c, bool preservePage)
//更新临时卡片
public void Reset()
{
oldCard = new Card(0);
LoadCard(oldCard);
LoadCard(Card.Empty);
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion DataEditorX/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ data/cardinfo_xxx.txt

★卡片搜索
1.仅支持一个系列名搜索

2.ATK,DEF搜索:
0: 输入-1或.
?: 输入-2或?

Comment thread
salix5 marked this conversation as resolved.
3.卡片名称搜索:
Expand Down
12 changes: 5 additions & 7 deletions DataEditorX/readme_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
salix5 marked this conversation as resolved.
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

Expand Down