Commit 522136b9 authored by DailyShana's avatar DailyShana

2.3.1.4

parent 38ae3542
......@@ -121,6 +121,14 @@ public void SetSetCode(params string[] setcodes)
}
}
}
public long GetLeftScale()
{
return (this.level >> 0x18) & 0xff;
}
public long GetRightScale()
{
return (this.level >> 0x10) & 0xff;
}
#endregion
#region 比较、哈希值、操作符
......
......@@ -166,7 +166,7 @@ public bool DelCards(bool deletefiles)
//删除资源
if (deletefiles)
{
YGOUtil.CardDelete(c.id, dataform.GetPath(), true);
YGOUtil.CardDelete(c.id, dataform.GetPath(), YGOUtil.DeleteOption.BACKUP);
delete.deleted = true;
delete.ids.Add(c.id);
}
......@@ -238,7 +238,7 @@ public void Undo()
return;
}
DataBase.Command(dataform.GetOpenFile(), undoSQL[undoSQL.Count - 1]);
undoSQL.RemoveAt(undoSQL.Count-1);
undoSQL.RemoveAt(undoSQL.Count - 1);
if (undoModified[undoModified.Count - 1].modifiled)
{
FileModified lastmodify = undoModified[undoModified.Count - 1];
......@@ -249,7 +249,7 @@ public void Undo()
{
FileDeleted lastdelete = undoDeleted[undoDeleted.Count - 1];
foreach (long id in lastdelete.ids)
YGOUtil.CardDelete(id, dataform.GetPath(), false, true);
YGOUtil.CardDelete(id, dataform.GetPath(), YGOUtil.DeleteOption.RESTORE);
}
undoDeleted.RemoveAt(undoDeleted.Count - 1);
dataform.Search(true);
......
......@@ -312,8 +312,8 @@ public static string GetSelectSQL(Card c)
sb.Append(" and datas.ot = "+c.ot.ToString());
if(c.attribute>0)
sb.Append(" and datas.attribute = "+c.attribute.ToString());
if(c.level>0)
sb.Append(" and (datas.level & 255) = "+toInt(c.level));
if ((c.level & 0xff) > 0)
sb.Append(" and (datas.level & 255) = "+toInt(c.level & 0xff));
if(c.race>0)
sb.Append(" and datas.race = "+toInt(c.race));
if(c.type>0)
......
......@@ -205,30 +205,53 @@ public static string[] ReadImage(string path)
#region 删除资源
//删除资源
public static void CardDelete(long id, YgoPath ygopath, bool bak, bool restore = false)
public enum DeleteOption
{
BACKUP,
RESTORE,
CLEAN,
NONE,
}
public static void CardDelete(long id, YgoPath ygopath, DeleteOption option)
{
string[] files = ygopath.GetCardfiles(id, restore);
string[] files = ygopath.GetCardfiles(id);
string[] bakfiles = ygopath.GetCardfiles(id, true);
for (int i = 0; i < files.Length; i++)
{
if (File.Exists(files[i]))
{
if (restore)
switch (option)
{
case DeleteOption.BACKUP:
for (int i = 0; i < files.Length; i++)
{
File.Move(files[i], files[i].Replace("bak", ""));
return;
if (File.Exists(bakfiles[i]))
File.Delete(bakfiles[i]);
if (File.Exists(files[i]))
File.Move(files[i], files[i] + ".bak");
}
if (bak)
break;
case DeleteOption.RESTORE:
for (int i = 0; i < bakfiles.Length; i++)
{
if (File.Exists(files[i]))
File.Delete(files[i]);
if (File.Exists(bakfiles[i]))
File.Move(bakfiles[i], bakfiles[i].Replace("bak", ""));
}
break;
case DeleteOption.CLEAN:
for (int i = 0; i < bakfiles.Length; i++)
{
if (File.Exists(bakfiles[i]))
File.Delete(bakfiles[i]);
File.Move(files[i], files[i] + ".bak");
}
else
File.Delete(files[i]);//删除文件
}
}
break;
case DeleteOption.NONE:
for (int i = 0; i < files.Length; i++)
{
if (File.Exists(files[i]))
File.Delete(files[i]);
}
break;
}
}
#endregion
......
......@@ -64,7 +64,6 @@ private void InitializeComponent()
this.menuitem_compdb = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_findluafunc = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_exportdata = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_saveasenter = new System.Windows.Forms.ToolStripMenuItem();
this.tsep5 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_cutimages = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_convertimage = new System.Windows.Forms.ToolStripMenuItem();
......@@ -282,7 +281,6 @@ private void InitializeComponent()
this.menuitem_compdb,
this.menuitem_findluafunc,
this.menuitem_exportdata,
this.menuitem_saveasenter,
this.tsep5,
this.menuitem_cutimages,
this.menuitem_convertimage,
......@@ -351,13 +349,6 @@ private void InitializeComponent()
this.menuitem_exportdata.Text = "Export Data";
this.menuitem_exportdata.Click += new System.EventHandler(this.Menuitem_exportdataClick);
//
// menuitem_saveasenter
//
this.menuitem_saveasenter.Name = "menuitem_saveasenter";
this.menuitem_saveasenter.Size = new System.Drawing.Size(212, 22);
this.menuitem_saveasenter.Text = "Save as Auto Enter";
this.menuitem_saveasenter.Click += new System.EventHandler(this.menuitem_saveasenter_Click);
//
// tsep5
//
this.tsep5.Name = "tsep5";
......@@ -1194,8 +1185,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem menuitem_cutimages;
private System.Windows.Forms.ToolStripMenuItem menuitem_operacardsfile;
private System.Windows.Forms.ToolStripSeparator tsep2;
private System.Windows.Forms.ToolStripMenuItem menuitem_openfileinthis;
private System.Windows.Forms.ToolStripMenuItem menuitem_saveasenter;
private System.Windows.Forms.ToolStripMenuItem menuitem_openfileinthis;
private System.Windows.Forms.ToolStripMenuItem menuitem_autocheckupdate;
private System.Windows.Forms.ToolStripMenuItem menuitem_language;
}
......
......@@ -147,7 +147,19 @@ void DataEditFormLoad(object sender, EventArgs e)
}
//窗体关闭
void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
{
{
//清理备份文件
List<long> delids = new List<long>();
foreach (CardEdit.FileDeleted deleted in cardedit.undoDeleted)
{
if (deleted != null && deleted.deleted)
delids.AddRange(deleted.ids);
}
if (delids.Count != 0)
{
foreach (long id in delids)
YGOUtil.CardDelete(id, GetPath(), YGOUtil.DeleteOption.CLEAN);
}
//当前有任务执行,是否结束
if (tasker != null && tasker.IsRuning())
{
......@@ -156,7 +168,6 @@ void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
e.Cancel = true;
return;
}
}
}
//窗体激活
......@@ -626,6 +637,18 @@ public bool Open(string file)
return true;
}
//setcode, 灵摆刻度的搜索
public bool CardFilter(Card c, Card sc)
{
bool res = true;
if (sc.setcode != 0)
res &= c.IsSetCode(sc.setcode & 0xffff);
if (sc.GetLeftScale() != 0 )
res &= (c.GetLeftScale() == sc.GetLeftScale());
if (sc.GetRightScale() != 0 )
res &= (c.GetRightScale() == sc.GetRightScale());
return res;
}
//设置卡片列表的结果
public void SetCards(Card[] cards, bool isfresh)
{
......@@ -634,10 +657,8 @@ public void SetCards(Card[] cards, bool isfresh)
cardlist.Clear();
foreach (Card c in cards)
{
if (srcCard.setcode == 0)
cardlist.Add(c);//setcode搜索在这里进行
else if (c.IsSetCode(srcCard.setcode & 0xffff))
cardlist.Add(c);
if (CardFilter(c, srcCard))
cardlist.Add(c);
}
cardcount = cardlist.Count;
pageNum = cardcount / MaxRow;
......@@ -1117,9 +1138,9 @@ public void SaveCards(Card[] cards)
cardedit.undoSQL.Add(undo);
cardedit.undoModified.Add(new CardEdit.FileModified());
cardedit.undoDeleted.Add(new CardEdit.FileDeleted());
btn_undo.Enabled = true;
DataBase.CopyDB(nowCdbFile, !replace, cards);
Search(srcCard, true);
Search(srcCard, true);
btn_undo.Enabled = true;
}
//卡片另存为
void CopyTo(Card[] cards)
......@@ -1601,38 +1622,5 @@ void SetLanguage_Click(object sender, EventArgs e)
}
}
#endregion
#region 空格
private void menuitem_saveasenter_Click(object sender, EventArgs e)
{
using (SaveFileDialog dlg = new SaveFileDialog())
{
dlg.Title = LanguageHelper.GetMsg(LMSG.SelectDataBasePath);
dlg.Filter = LanguageHelper.GetMsg(LMSG.CdbType);
if (dlg.ShowDialog() == DialogResult.OK)
{
Card[] cards = DataBase.Read(nowCdbFile, true, "");
int count = cards.Length;
if (cards == null || cards.Length == 0)
return;
if (DataBase.Create(dlg.FileName))
{
//
int len = MyConfig.readInteger(MyConfig.TAG_AUTO_LEN, 30);
for (int i = 0; i < count; i++)
{
cards[i].desc = StrUtil.AutoEnter(cards[i].desc, len, ' ');
for (int j = 0; j < Card.STR_MAX; j++)
{
cards[i].Str[j] = StrUtil.AutoEnter(cards[i].Str[j], len, ' ');
}
}
DataBase.CopyDB(dlg.FileName, false, cards);
MyMsg.Show(LMSG.CopyCardsToDBIsOK);
}
}
}
}
#endregion
}
}
......@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.3.1.3")]
[assembly: AssemblyVersion("2.3.1.4")]
★更新历史
2.3.1.4
增加灵摆刻度的搜索功能
关闭数据库时清理备份文件
移除分行功能
2.3.1.3
优化复制卡片的撤销
2.3.1.2
......
[DataEditorX]2.3.1.3[DataEditorX]
[DataEditorX]2.3.1.4[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
★更新历史
2.3.1.4
增加灵摆刻度的搜索功能
关闭数据库时清理备份文件
移除分行功能
2.3.1.3
优化复制卡片的撤销
2.3.1.2
......
[DataEditorX]2.3.1.3[DataEditorX]
[DataEditorX]2.3.1.4[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment