Commit 463a6a71 authored by DailyShana's avatar DailyShana

2.3.1.1

parent 981886ff
......@@ -36,61 +36,69 @@ public void SetPath(string gamepath)
/// <summary>录像目录</summary>
public string replaypath;
public string GetImage(long id)
public string GetImage(long id, bool bak = false)
{
return GetImage(id.ToString());
return GetImage(id.ToString(), bak);
}
public string GetImageThum(long id)
public string GetImageThum(long id, bool bak = false)
{
return GetImageThum(id.ToString());
return GetImageThum(id.ToString(), bak);
}
public string GetImageField(long id)
public string GetImageField(long id, bool bak = false)
{
return GetImageField(id.ToString());//场地图
return GetImageField(id.ToString(), bak);//场地图
}
public string GetScript(long id)
public string GetScript(long id, bool bak = false)
{
return GetScript(id.ToString());
return GetScript(id.ToString(), bak);
}
public string GetYdk(string name)
{
return MyPath.Combine(ydkpath, name + ".ydk");
}
//字符串id
public string GetImage(string id)
public string GetImage(string id, bool bak = false)
{
if (bak)
return MyPath.Combine(picpath, id + ".jpg.bak");
return MyPath.Combine(picpath, id + ".jpg");
}
public string GetImageThum(string id)
public string GetImageThum(string id, bool bak = false)
{
if (bak)
return MyPath.Combine(picpath2, id + ".jpg.bak");
return MyPath.Combine(picpath2, id + ".jpg");
}
public string GetImageField(string id)
public string GetImageField(string id, bool bak = false)
{
if (bak)
return MyPath.Combine(fieldpath, id + ".png.bak");
return MyPath.Combine(fieldpath, id+ ".png");//场地图
}
public string GetScript(string id)
public string GetScript(string id, bool bak = false)
{
if (bak)
return MyPath.Combine(luapath, "c" + id + ".lua.bak");
return MyPath.Combine(luapath, "c" + id + ".lua");
}
public string[] GetCardfiles(long id)
public string[] GetCardfiles(long id, bool bak = false)
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
GetImage(id, bak),//大图
GetImageThum(id, bak),//小图
GetImageField(id, bak),//场地图
GetScript(id, bak)
};
return files;
}
public string[] GetCardfiles(string id)
public string[] GetCardfiles(string id, bool bak = false)
{
string[] files = new string[]{
GetImage(id),//大图
GetImageThum(id),//小图
GetImageField(id),//场地图
GetScript(id)
GetImage(id, bak),//大图
GetImageThum(id, bak),//小图
GetImageField(id, bak),//场地图
GetScript(id, bak)
};
return files;
}
......
......@@ -10,10 +10,27 @@ namespace DataEditorX.Core
public class CardEdit
{
IDataForm dataform;
string undoSQL;
public List<string> undoSQL;
public class FileModified
{
public bool modifiled = false;
public long oldid;
public long newid;
public bool delold;
}
public class FileDeleted
{
public bool deleted = false;
public List<long> ids = new List<long>();
}
public List<FileModified> undoModified;
public List<FileDeleted> undoDeleted;
public CardEdit(IDataForm dataform)
{
this.dataform = dataform;
this.undoSQL = new List<string>();
this.undoModified = new List<FileModified>();
this.undoDeleted = new List<FileDeleted>();
}
#region 添加
......@@ -41,7 +58,9 @@ public bool AddCard()
DataBase.GetInsertSQL(c, true)) >= 2)
{
MyMsg.Show(LMSG.AddSucceed);
undoSQL = DataBase.GetDeleteSQL(c);
undoSQL.Add(DataBase.GetDeleteSQL(c));
undoModified.Add(new FileModified());
undoDeleted.Add(new FileDeleted());
dataform.Search(true);
dataform.SetCard(c);
return true;
......@@ -73,7 +92,6 @@ public bool ModCard(bool modfiles)
if (c.id != oldCard.id)//修改了id
{
sql = DataBase.GetInsertSQL(c, false);//插入
undoSQL = DataBase.GetDeleteSQL(c);//还原就是删除
bool delold = MyMsg.Question(LMSG.IfDeleteCard);
if (delold)//是否删除旧卡片
{
......@@ -85,17 +103,34 @@ public bool ModCard(bool modfiles)
}
else
{//删除成功,添加还原sql
undoSQL += DataBase.GetInsertSQL(oldCard, false);
undoSQL.Add(DataBase.GetDeleteSQL(c)+DataBase.GetInsertSQL(oldCard, false));
}
}
} else
undoSQL.Add(DataBase.GetDeleteSQL(c));//还原就是删除
//如果删除旧卡片,则把资源修改名字,否则复制资源
if (modfiles)
YGOUtil.CardRename(c.id, oldCard.id, dataform.GetPath(), delold);
if (modfiles)
{
YGOUtil.CardRename(c.id, oldCard.id, dataform.GetPath(), delold);
FileModified modify = new FileModified();
modify.modifiled = true;
modify.oldid = oldCard.id;
modify.newid = c.id;
modify.delold = delold;
undoModified.Add(modify);
undoDeleted.Add(new FileDeleted());
}
else
{
undoModified.Add(new FileModified());
undoDeleted.Add(new FileDeleted());
}
}
else
{//更新数据
sql = DataBase.GetUpdateSQL(c);
undoSQL = DataBase.GetUpdateSQL(oldCard);
undoSQL.Add(DataBase.GetUpdateSQL(oldCard));
undoModified.Add(new FileModified());
undoDeleted.Add(new FileDeleted());
}
if (DataBase.Command(dataform.GetOpenFile(), sql) > 0)
{
......@@ -119,24 +154,30 @@ public bool DelCards(bool deletefiles)
Card[] cards = dataform.GetCardList(true);
if (cards == null || cards.Length == 0)
return false;
string undo = "";
if (!MyMsg.Question(LMSG.IfDeleteCard))
return false;
undoSQL = "";//还原
List<string> sql = new List<string>();
FileDeleted delete = new FileDeleted();
foreach (Card c in cards)
{
sql.Add(DataBase.GetDeleteSQL(c));//删除
undoSQL += DataBase.GetInsertSQL(c, true);
undo += DataBase.GetInsertSQL(c, true);
//删除资源
if (deletefiles && MyMsg.Question(LMSG.IfDeleteFiles))
if (deletefiles)
{
YGOUtil.CardDelete(c.id, dataform.GetPath(), false);
YGOUtil.CardDelete(c.id, dataform.GetPath(), true);
delete.deleted = true;
delete.ids.Add(c.id);
}
}
if (DataBase.Command(dataform.GetOpenFile(), sql.ToArray()) >= (sql.Count * 2))
{
MyMsg.Show(LMSG.DeleteSucceed);
dataform.Search(true);
undoSQL.Add(undo);
undoDeleted.Add(delete);
undoModified.Add(new FileModified());
return true;
}
else
......@@ -192,12 +233,26 @@ public bool OpenScript(bool openinthis)
//撤销
public void Undo()
{
if (string.IsNullOrEmpty(undoSQL))
if (undoSQL.Count == 0)
{
return;
return;
}
DataBase.Command(dataform.GetOpenFile(), undoSQL);
dataform.Search(true);
DataBase.Command(dataform.GetOpenFile(), undoSQL[undoSQL.Count - 1]);
undoSQL.RemoveAt(undoSQL.Count-1);
if (undoModified[undoModified.Count - 1].modifiled)
{
FileModified lastmodify = undoModified[undoModified.Count - 1];
YGOUtil.CardRename(lastmodify.oldid, lastmodify.newid, dataform.GetPath(), lastmodify.delold);
}
undoModified.RemoveAt(undoModified.Count - 1);
if (undoDeleted[undoDeleted.Count - 1].deleted)
{
FileDeleted lastdelete = undoDeleted[undoDeleted.Count - 1];
foreach (long id in lastdelete.ids)
YGOUtil.CardDelete(id, dataform.GetPath(), false, true);
}
undoDeleted.RemoveAt(undoDeleted.Count - 1);
dataform.Search(true);
}
#endregion
}
......
......@@ -205,17 +205,27 @@ public static string[] ReadImage(string path)
#region 删除资源
//删除资源
public static void CardDelete(long id, YgoPath ygopath, bool bak)
public static void CardDelete(long id, YgoPath ygopath, bool bak, bool restore = false)
{
string[] files = ygopath.GetCardfiles(id);
string[] files = ygopath.GetCardfiles(id, restore);
string[] bakfiles = ygopath.GetCardfiles(id, true);
for (int i = 0; i < files.Length; i++)
{
if (File.Exists(files[i]))
{
if (bak)
File.Move(files[i], files[i] + ".bak");
else
File.Delete(files[i]);//删除文件
if (restore)
{
File.Move(files[i], files[i].Replace("bak", ""));
return;
}
if (bak)
{
if (File.Exists(bakfiles[i]))
File.Delete(bakfiles[i]);
File.Move(files[i], files[i] + ".bak");
}
else
File.Delete(files[i]);//删除文件
}
}
......@@ -241,5 +251,5 @@ public static void CardRename(long newid, long oldid, YgoPath ygopath, bool delo
}
}
#endregion
}
}
}
......@@ -72,6 +72,7 @@ private void InitializeComponent()
this.menuitem_cancelTask = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_help = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_about = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_language = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_checkupdate = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_autocheckupdate = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_github = new System.Windows.Forms.ToolStripMenuItem();
......@@ -126,7 +127,6 @@ private void InitializeComponent()
this.lv_cardlist = new System.Windows.Forms.DListView();
this.ch_cardcode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ch_cardname = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.menuitem_language = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenu.SuspendLayout();
this.SuspendLayout();
//
......@@ -409,6 +409,12 @@ private void InitializeComponent()
this.menuitem_about.Text = "About";
this.menuitem_about.Click += new System.EventHandler(this.Menuitem_aboutClick);
//
// menuitem_language
//
this.menuitem_language.Name = "menuitem_language";
this.menuitem_language.Size = new System.Drawing.Size(189, 22);
this.menuitem_language.Text = "Language";
//
// menuitem_checkupdate
//
this.menuitem_checkupdate.Name = "menuitem_checkupdate";
......@@ -882,6 +888,7 @@ private void InitializeComponent()
// btn_undo
//
this.btn_undo.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btn_undo.Enabled = false;
this.btn_undo.Location = new System.Drawing.Point(704, 542);
this.btn_undo.Name = "btn_undo";
this.btn_undo.Size = new System.Drawing.Size(75, 28);
......@@ -1030,12 +1037,6 @@ private void InitializeComponent()
this.ch_cardname.Text = "Card Name";
this.ch_cardname.Width = 140;
//
// menuitem_language
//
this.menuitem_language.Name = "menuitem_language";
this.menuitem_language.Size = new System.Drawing.Size(189, 22);
this.menuitem_language.Text = "Language";
//
// DataEditForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......
......@@ -712,12 +712,16 @@ void Btn_addClick(object sender, EventArgs e)
{
if(cardedit != null)
cardedit.AddCard();
if (cardedit.undoSQL.Count != 0)
btn_undo.Enabled = true;
}
//修改
void Btn_modClick(object sender, EventArgs e)
{
if (cardedit != null)
cardedit.ModCard(menuitem_operacardsfile.Checked);
cardedit.ModCard(menuitem_operacardsfile.Checked);
if (cardedit.undoSQL.Count != 0)
btn_undo.Enabled = true;
}
//打开脚本
void Btn_luaClick(object sender, EventArgs e)
......@@ -729,12 +733,16 @@ void Btn_luaClick(object sender, EventArgs e)
void Btn_delClick(object sender, EventArgs e)
{
if (cardedit != null)
cardedit.DelCards(menuitem_operacardsfile.Checked);
cardedit.DelCards(menuitem_operacardsfile.Checked);
if (cardedit.undoSQL.Count != 0)
btn_undo.Enabled = true;
}
void Btn_undoClick(object sender, EventArgs e)
{
if (cardedit != null)
cardedit.Undo();
cardedit.Undo();
if (cardedit.undoSQL.Count == 0)
btn_undo.Enabled = false;
}
//导入卡图
void Btn_imgClick(object sender, EventArgs e)
......@@ -1083,6 +1091,20 @@ public void SaveCards(Card[] cards)
if (cards == null || cards.Length == 0)
return;
bool replace = MyMsg.Question(LMSG.IfReplaceExistingCard);
Card[] oldcards = DataBase.Read(nowCdbFile, true, "");
string undo = "";
foreach (Card c in cards)
{
undo += DataBase.GetDeleteSQL(c);
}
foreach (Card c in oldcards)
{
undo += DataBase.GetInsertSQL(c, !replace);
}
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);
}
......
......@@ -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.0")]
[assembly: AssemblyVersion("2.3.1.1")]
★更新历史
2.3.1.1
完善撤销功能
2.3.1.0
更新系列名,函数列表,常数列表等
添加脚本参考资料
......
......@@ -25,7 +25,7 @@ DataEditForm.btn_reset 重置
DataEditForm.btn_lua 脚本
DataEditForm.btn_serach 搜索
DataEditForm.btn_del 删除
DataEditForm.btn_undo 还原
DataEditForm.btn_undo 撤销
DataEditForm.btn_mod 修改
DataEditForm.btn_add 添加
DataEditForm.btn_PageDown 下一页
......
......@@ -63,24 +63,24 @@ DataEditForm.mainMenu.menuitem_checkupdate Check Update
DataEditForm.mainMenu.menuitem_autocheckupdate Auto Check Update
DataEditForm.mainMenu.menuitem_github Sourse Code in GitHub
#
MainForm.mainMenu.menuitem_fileFile(&F)
MainForm.mainMenu.menuitem_openOpen
MainForm.mainMenu.menuitem_newNew
MainForm.mainMenu.menuitem_saveSave
MainForm.mainMenu.menuitem_copyselectCopy Selected
MainForm.mainMenu.menuitem_copyallCopy All Search
MainForm.mainMenu.menuitem_pastecardsPaste Cards
MainForm.mainMenu.menuitem_file File(&F)
MainForm.mainMenu.menuitem_open Open
MainForm.mainMenu.menuitem_new New
MainForm.mainMenu.menuitem_save Save
MainForm.mainMenu.menuitem_copyselect Copy Selected
MainForm.mainMenu.menuitem_copyall Copy All Search
MainForm.mainMenu.menuitem_pastecards Paste Cards
MainForm.mainMenu.menuitem_comp1Set Compare Database 1
MainForm.mainMenu.menuitem_comp2Set Compare Database 2
MainForm.mainMenu.menuitem_historyDataBase Histroy
MainForm.mainMenu.menuitem_shistoryScript History
MainForm.mainMenu.menuitem_quitQuit
MainForm.mainMenu.menuitem_windowsWindows(&W)
MainForm.mainMenu.menuitem_dataeditorDataEditor
MainForm.mainMenu.menuitem_codeeditorCodeEditor
MainForm.mainMenu.menuitem_closeClose
MainForm.mainMenu.menuitem_closeotherClose Others
MainForm.mainMenu.menuitem_closeallClose All
MainForm.mainMenu.menuitem_history DataBase Histroy
MainForm.mainMenu.menuitem_shistory Script History
MainForm.mainMenu.menuitem_quit Quit
MainForm.mainMenu.menuitem_windows Windows(&W)
MainForm.mainMenu.menuitem_dataeditor DataEditor
MainForm.mainMenu.menuitem_codeeditor CodeEditor
MainForm.mainMenu.menuitem_close Close
MainForm.mainMenu.menuitem_closeother Close Others
MainForm.mainMenu.menuitem_closeall Close All
#
0x0 Info
0x1 Error
......@@ -94,11 +94,11 @@ MainForm.mainMenu.menuitem_closeallClose All
0x9 It's exitis!
0xa It's no changed.
0xb If delete Card(s)?
0xc If create script file
0xc If create script file?
0xd If open database?
0xe If replace exitis cards?
0xf It's new version.\nWhether you need to download again?
0x10 Check update fail.Please Check Network.
0x10 Check update fail. Please Check Network.
0x11 Find a new version,\nIf Download it?
0x12 File is't exitis!
0x13 No select database!
......@@ -106,7 +106,7 @@ MainForm.mainMenu.menuitem_closeallClose All
0x15 select ydk file
0x16 selcet image folder
0x17 Download succeed!
0x18 Download fail
0x18 Download fail?
0x19 No slect script text!
0x1a Delete succeed!
0x1b Delete fail!
......@@ -117,7 +117,7 @@ MainForm.mainMenu.menuitem_closeallClose All
0x20 Author :
0x21 cdb file(*.cdb)|*.cdb|all files(*.*)|*.*
0x22 ydk file(*.ydk)|*.ydk|all files(*.*)|*.*
0x23 SetCode Input Error
0x23 SetCode Input Error?
0x24 Select Image For Card
0x25 jpg(*.jpg)|*.jpg|bmp(*.bmp)|*.bmp|png(*.png)|*.png|all files(*.*)|*.*
0x26 The Task is runing.
......
[DataEditorX]2.3.1.0[DataEditorX]
[DataEditorX]2.3.1.1[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
★更新历史
2.3.1.1
完善撤销功能
2.3.1.0
更新系列名,函数列表,常数列表等
添加脚本参考资料
......
......@@ -25,7 +25,7 @@ DataEditForm.btn_reset 重置
DataEditForm.btn_lua 脚本
DataEditForm.btn_serach 搜索
DataEditForm.btn_del 删除
DataEditForm.btn_undo 还原
DataEditForm.btn_undo 撤销
DataEditForm.btn_mod 修改
DataEditForm.btn_add 添加
DataEditForm.btn_PageDown 下一页
......
#
#
CodeEditForm.mainMenu.menuitem_file File(&F)
CodeEditForm.mainMenu.menuitem_open Open
CodeEditForm.mainMenu.menuitem_save Save
CodeEditForm.mainMenu.menuitem_saveas Save As
CodeEditForm.mainMenu.menuitem_quit Quit
CodeEditForm.mainMenu.menuitem_setting Tools(&S)
CodeEditForm.mainMenu.menuitem_showmap Show/Hide Document Maps
CodeEditForm.mainMenu.menuitem_showinput Show/Hide TextBox
CodeEditForm.mainMenu.menuitem_showmap Display/Hide Document Maps
CodeEditForm.mainMenu.menuitem_showinput Display/Hide TextBox
CodeEditForm.mainMenu.menuitem_find Find String
CodeEditForm.mainMenu.menuitem_replace Replace
CodeEditForm.mainMenu.menuitem_setcard Set DataBase
......@@ -67,12 +67,11 @@ MainForm.mainMenu.menuitem_file File(&F)
MainForm.mainMenu.menuitem_open Open
MainForm.mainMenu.menuitem_new New
MainForm.mainMenu.menuitem_save Save
MainForm.mainMenu.menuitem_findluafunc Find Lua Functions By C++
MainForm.mainMenu.menuitem_copyselect Copy Selected
MainForm.mainMenu.menuitem_copyall Copy All Search
MainForm.mainMenu.menuitem_pastecards Paste Cards
MainForm.mainMenu.menuitem_comp1 Set Compare Database 1
MainForm.mainMenu.menuitem_comp2 Set Compare Database 2
MainForm.mainMenu.menuitem_comp1Set Compare Database 1
MainForm.mainMenu.menuitem_comp2Set Compare Database 2
MainForm.mainMenu.menuitem_history DataBase Histroy
MainForm.mainMenu.menuitem_shistory Script History
MainForm.mainMenu.menuitem_quit Quit
......@@ -80,7 +79,7 @@ MainForm.mainMenu.menuitem_windows Windows(&W)
MainForm.mainMenu.menuitem_dataeditor DataEditor
MainForm.mainMenu.menuitem_codeeditor CodeEditor
MainForm.mainMenu.menuitem_close Close
MainForm.mainMenu.menuitem_closeother Close Other
MainForm.mainMenu.menuitem_closeother Close Others
MainForm.mainMenu.menuitem_closeall Close All
#
0x0 Info
......@@ -95,11 +94,11 @@ MainForm.mainMenu.menuitem_closeall Close All
0x9 It's exitis!
0xa It's no changed.
0xb If delete Card(s)?
0xc If create script file
0xc If create script file?
0xd If open database?
0xe If replace exitis cards?
0xf It's new version.\nWhether you need to download again?
0x10 Check update fail,\nPlease Check Network.
0x10 Check update fail. Please Check Network.
0x11 Find a new version,\nIf Download it?
0x12 File is't exitis!
0x13 No select database!
......@@ -107,7 +106,7 @@ MainForm.mainMenu.menuitem_closeall Close All
0x15 select ydk file
0x16 selcet image folder
0x17 Download succeed!
0x18 Download fail
0x18 Download fail?
0x19 No slect script text!
0x1a Delete succeed!
0x1b Delete fail!
......@@ -118,7 +117,7 @@ MainForm.mainMenu.menuitem_closeall Close All
0x20 Author :
0x21 cdb file(*.cdb)|*.cdb|all files(*.*)|*.*
0x22 ydk file(*.ydk)|*.ydk|all files(*.*)|*.*
0x23 SetCode Input Error
0x23 SetCode Input Error?
0x24 Select Image For Card
0x25 jpg(*.jpg)|*.jpg|bmp(*.bmp)|*.bmp|png(*.png)|*.png|all files(*.*)|*.*
0x26 The Task is runing.
......
[DataEditorX]2.3.1.0[DataEditorX]
[DataEditorX]2.3.1.1[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