Commit 5cf7bf28 authored by keyongyu's avatar keyongyu

2.4.1.1

parent 95e53e76
......@@ -228,3 +228,4 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
/win32/*.cdb
......@@ -246,12 +246,16 @@ public static Area readArea(string key)
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static bool readBoolean(string key)
public static bool readBoolean(string key,bool def=false)
{
if (readString(key).ToLower() == "true")
return true;
else
return false;
string val= readString(key);
if("true".Equals(val, StringComparison.OrdinalIgnoreCase)){
return true;
}
if("false".Equals(val, StringComparison.OrdinalIgnoreCase)){
return false;
}
return def;
}
#endregion
......
......@@ -492,5 +492,34 @@ public static string GetDeleteSQL(Card c)
sw.Close();
}
}
public static CardPack findPack(string db, long id){
CardPack cardpack=null;
if ( File.Exists(db) && id>=0)
{
using ( SQLiteConnection sqliteconn = new SQLiteConnection(@"Data Source=" + db) )
{
sqliteconn.Open();
using ( SQLiteCommand sqlitecommand = new SQLiteCommand(sqliteconn) )
{
sqlitecommand.CommandText = "select id,pack_id,pack,rarity,date from pack where id="+id+" order by date desc";
using ( SQLiteDataReader reader = sqlitecommand.ExecuteReader() )
{
if(reader.Read())
{
cardpack=new CardPack(id);
cardpack.pack_id=reader.GetString(1);
cardpack.pack_name=reader.GetString(2);
cardpack.rarity=reader.GetString(3);
cardpack.date=reader.GetString(4);
}
reader.Close();
}
}
sqliteconn.Close();
}
}
return cardpack;
}
}
}
/*
* 由SharpDevelop创建。
* 用户: Hasee
* 日期: 2016/2/27
* 时间: 7:55
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using System;
namespace DataEditorX.Core
{
/// <summary>
/// Description of CardPack.
/// </summary>
public class CardPack
{
public CardPack(long id)
{
this.card_id=id;
}
public long card_id{
get;
private set;
}
public string pack_id;
public string pack_name;
public string rarity;
public string date;
public string getMseRarity(){
if(rarity==null)
return "common";
rarity=rarity.Trim().ToLower();
if(rarity.Equals("common")){
return "common";
}
if(rarity.Equals("rare")){
return "rare";
}
if(rarity.Equals("super") ||rarity.Equals("super rare")){
return "super rare";
}
if(rarity.Contains("secret")){
return "secret rare";
}
if(rarity.Contains("parallel")){
return "parallel rare";
}
if(rarity.Contains("ultimate")){
return "ultimate rare";
}
if(rarity.Contains("ultra")){
return "ultra rare";
}
if(rarity.Contains("gold")){
return "gold tech";
}
if(rarity.Contains("promo")){
return "promo";
}
return "common";
}
}
}
......@@ -45,6 +45,8 @@ public class MseMaker
public const string TAG_TEXT = "rule text";
public const string TAG_ATK = "attack";
public const string TAG_DEF = "defense";
public const string TAG_NUMBER = "number";
public const string TAG_RARITY = "rarity";
public const string TAG_PENDULUM = "pendulum";
public const string TAG_PSCALE1 = "pendulum scale 1";
public const string TAG_PSCALE2 = "pendulum scale 2";
......@@ -368,7 +370,7 @@ public string[] GetTypes(Card c)
#region 写存档
//写存档
public Dictionary<Card, string> WriteSet(string file, Card[] cards)
public Dictionary<Card, string> WriteSet(string file, Card[] cards,string cardpack_db,bool rarity=true)
{
// MessageBox.Show(""+cfg.replaces.Keys[0]+"/"+cfg.replaces[cfg.replaces.Keys[0]]);
Dictionary<Card, string> list = new Dictionary<Card, string>();
......@@ -386,10 +388,11 @@ public string[] GetTypes(Card c)
list.Add(c, jpg);
jpg = Path.GetFileName(jpg);
}
CardPack cardpack=DataBase.findPack(cardpack_db, c.id);
if (c.IsType(CardType.TYPE_SPELL) || c.IsType(CardType.TYPE_TRAP))
sw.WriteLine(getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL)));
sw.WriteLine(getSpellTrap(c, jpg, c.IsType(CardType.TYPE_SPELL), cardpack,rarity));
else
sw.WriteLine(getMonster(c, jpg, c.IsType(CardType.TYPE_PENDULUM)));
sw.WriteLine(getMonster(c, jpg, c.IsType(CardType.TYPE_PENDULUM),cardpack,rarity));
}
sw.WriteLine(cfg.end);
sw.Close();
......@@ -398,7 +401,7 @@ public string[] GetTypes(Card c)
return list;
}
//怪兽,pendulum怪兽
string getMonster(Card c, string img, bool isPendulum)
string getMonster(Card c, string img, bool isPendulum,CardPack cardpack=null,bool rarity=true)
{
StringBuilder sb = new StringBuilder();
string[] types = GetTypes(c);
......@@ -413,6 +416,12 @@ string getMonster(Card c, string img, bool isPendulum)
sb.AppendLine(GetLine(TAG_TYPE2, cn2tw(types[1])));
sb.AppendLine(GetLine(TAG_TYPE3, cn2tw(types[2])));
sb.AppendLine(GetLine(TAG_TYPE4, cn2tw(types[3])));
if(cardpack!=null){
sb.AppendLine(GetLine(TAG_NUMBER, cardpack.pack_id));
if(rarity){
sb.AppendLine(GetLine(TAG_RARITY, cardpack.getMseRarity()));
}
}
if (isPendulum)//P怪兽
{
string text = GetDesc(c.desc, cfg.regx_monster);
......@@ -439,7 +448,7 @@ string getMonster(Card c, string img, bool isPendulum)
return sb.ToString();
}
//魔法陷阱
string getSpellTrap(Card c, string img, bool isSpell)
string getSpellTrap(Card c, string img, bool isSpell,CardPack cardpack=null,bool rarity=true)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(TAG_CARD + ":");
......@@ -448,6 +457,12 @@ string getSpellTrap(Card c, string img, bool isSpell)
sb.AppendLine(GetLine(TAG_ATTRIBUTE, isSpell ? "spell" : "trap"));
sb.AppendLine(GetLine(TAG_LEVEL, GetSpellTrapSymbol(c, isSpell)));
sb.AppendLine(GetLine(TAG_IMAGE, img));
if(cardpack!=null){
sb.AppendLine(GetLine(TAG_NUMBER, cardpack.pack_id));
if(rarity){
sb.AppendLine(GetLine(TAG_RARITY, cardpack.getMseRarity()));
}
}
sb.AppendLine(" " + TAG_TEXT + ":");
sb.AppendLine(" " + ReText(reItalic(c.desc)));
sb.AppendLine(GetLine(TAG_CODE, c.idString));
......
......@@ -20,441 +20,447 @@
using DataEditorX.Config;
using DataEditorX.Core.Mse;
using DataEditorX.Core.Info;
using System.Xml;
namespace DataEditorX.Core
{
/// <summary>
/// 任务
/// </summary>
public class TaskHelper
{
#region Member
/// <summary>
/// 当前任务
/// </summary>
private MyTask nowTask = MyTask.NONE;
/// <summary>
/// 上一次任务
/// </summary>
private MyTask lastTask = MyTask.NONE;
/// <summary>
/// 当前卡片列表
/// </summary>
private Card[] cardlist;
/// <summary>
/// 当前卡片列表
/// </summary>
public Card[] CardList
{
get { return cardlist; }
}
/// <summary>
/// 任务参数
/// </summary>
private string[] mArgs;
/// <summary>
/// 图片设置
/// </summary>
private ImageSet imgSet;
/// <summary>
/// MSE转换
/// </summary>
private MseMaker mseHelper;
/// <summary>
/// 是否取消
/// </summary>
private bool isCancel = false;
/// <summary>
/// 是否在运行
/// </summary>
private bool isRun = false;
/// <summary>
/// 后台工作线程
/// </summary>
private BackgroundWorker worker;
/// <summary>
/// 任务
/// </summary>
public class TaskHelper
{
#region Member
/// <summary>
/// 当前任务
/// </summary>
private MyTask nowTask = MyTask.NONE;
/// <summary>
/// 上一次任务
/// </summary>
private MyTask lastTask = MyTask.NONE;
/// <summary>
/// 当前卡片列表
/// </summary>
private Card[] cardlist;
/// <summary>
/// 当前卡片列表
/// </summary>
public Card[] CardList
{
get { return cardlist; }
}
/// <summary>
/// 任务参数
/// </summary>
private string[] mArgs;
/// <summary>
/// 图片设置
/// </summary>
private ImageSet imgSet;
/// <summary>
/// MSE转换
/// </summary>
private MseMaker mseHelper;
/// <summary>
/// 是否取消
/// </summary>
private bool isCancel = false;
/// <summary>
/// 是否在运行
/// </summary>
private bool isRun = false;
/// <summary>
/// 后台工作线程
/// </summary>
private BackgroundWorker worker;
public TaskHelper(string datapath, BackgroundWorker worker, MSEConfig mcfg)
{
this.worker = worker;
mseHelper = new MseMaker(mcfg);
imgSet = new ImageSet();
}
public MseMaker MseHelper
{
get { return mseHelper; }
}
public bool IsRuning()
{
return isRun;
}
public bool IsCancel()
{
return isCancel;
}
public void Cancel()
{
isRun = false;
isCancel = true;
}
public MyTask getLastTask()
{
return lastTask;
}
public void testPendulumText(string desc){
mseHelper.testPendulum(desc);
}
#endregion
public TaskHelper(string datapath, BackgroundWorker worker, MSEConfig mcfg)
{
this.worker = worker;
mseHelper = new MseMaker(mcfg);
imgSet = new ImageSet();
}
public MseMaker MseHelper
{
get { return mseHelper; }
}
public bool IsRuning()
{
return isRun;
}
public bool IsCancel()
{
return isCancel;
}
public void Cancel()
{
isRun = false;
isCancel = true;
}
public MyTask getLastTask()
{
return lastTask;
}
public void testPendulumText(string desc){
mseHelper.testPendulum(desc);
}
#endregion
#region Other
//设置任务
public void SetTask(MyTask myTask, Card[] cards, params string[] args)
{
nowTask = myTask;
cardlist = cards;
mArgs = args;
}
//转换图片
public void ToImg(string img, string saveimg1, string saveimg2)
{
if (!File.Exists(img))
return;
Bitmap bmp = new Bitmap(img);
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.W, imgSet.H),
saveimg1, imgSet.quilty);
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
saveimg2, imgSet.quilty);
#region Other
//设置任务
public void SetTask(MyTask myTask, Card[] cards, params string[] args)
{
nowTask = myTask;
cardlist = cards;
mArgs = args;
}
//转换图片
public void ToImg(string img, string saveimg1, string saveimg2)
{
if (!File.Exists(img))
return;
Bitmap bmp = new Bitmap(img);
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.W, imgSet.H),
saveimg1, imgSet.quilty);
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
saveimg2, imgSet.quilty);
bmp.Dispose();
}
#endregion
}
#endregion
#region 检查更新
public static void CheckVersion(bool showNew)
{
string newver = CheckUpdate.GetNewVersion(MyConfig.readString(MyConfig.TAG_UPDATE_URL));
if (newver == CheckUpdate.DEFALUT)
{ //检查失败
if (!showNew)
return;
MyMsg.Error(LMSG.CheckUpdateFail);
return;
}
#region 检查更新
public static void CheckVersion(bool showNew)
{
string newver = CheckUpdate.GetNewVersion(MyConfig.readString(MyConfig.TAG_UPDATE_URL));
if (newver == CheckUpdate.DEFALUT)
{ //检查失败
if (!showNew)
return;
MyMsg.Error(LMSG.CheckUpdateFail);
return;
}
if (CheckUpdate.CheckVersion(newver, Application.ProductVersion))
{//有最新版本
if (!MyMsg.Question(LMSG.HaveNewVersion))
return;
}
else
{//现在就是最新版本
if (!showNew)
return;
if (!MyMsg.Question(LMSG.NowIsNewVersion))
return;
}
//下载文件
if (CheckUpdate.DownLoad(
MyPath.Combine(Application.StartupPath, newver + ".zip")))
MyMsg.Show(LMSG.DownloadSucceed);
else
MyMsg.Show(LMSG.DownloadFail);
}
public void OnCheckUpdate(bool showNew)
{
TaskHelper.CheckVersion(showNew);
}
#endregion
if (CheckUpdate.CheckVersion(newver, Application.ProductVersion))
{//有最新版本
if (!MyMsg.Question(LMSG.HaveNewVersion))
return;
}
else
{//现在就是最新版本
if (!showNew)
return;
if (!MyMsg.Question(LMSG.NowIsNewVersion))
return;
}
//下载文件
if (CheckUpdate.DownLoad(
MyPath.Combine(Application.StartupPath, newver + ".zip")))
MyMsg.Show(LMSG.DownloadSucceed);
else
MyMsg.Show(LMSG.DownloadFail);
}
public void OnCheckUpdate(bool showNew)
{
TaskHelper.CheckVersion(showNew);
}
#endregion
#region 裁剪图片
public void CutImages(string imgpath, bool isreplace)
{
int count = cardlist.Length;
int i = 0;
foreach (Card c in cardlist)
{
if (isCancel)
break;
i++;
worker.ReportProgress((i / count), string.Format("{0}/{1}", i, count));
string jpg = MyPath.Combine(imgpath, c.id + ".jpg");
string savejpg = MyPath.Combine(mseHelper.ImagePath, c.id + ".jpg");
if (File.Exists(jpg) && (isreplace || !File.Exists(savejpg)))
{
Bitmap bp = new Bitmap(jpg);
Bitmap bmp = null;
if (c.IsType(CardType.TYPE_XYZ))//超量
{
bmp = MyBitmap.Cut(bp, imgSet.xyzArea);
}
else if (c.IsType(CardType.TYPE_PENDULUM))//P怪兽
{
bmp = MyBitmap.Cut(bp, imgSet.pendulumArea);
}
else//一般
{
bmp = MyBitmap.Cut(bp, imgSet.normalArea);
}
#region 裁剪图片
public void CutImages(string imgpath, bool isreplace)
{
int count = cardlist.Length;
int i = 0;
foreach (Card c in cardlist)
{
if (isCancel)
break;
i++;
worker.ReportProgress((i / count), string.Format("{0}/{1}", i, count));
string jpg = MyPath.Combine(imgpath, c.id + ".jpg");
string savejpg = MyPath.Combine(mseHelper.ImagePath, c.id + ".jpg");
if (File.Exists(jpg) && (isreplace || !File.Exists(savejpg)))
{
Bitmap bp = new Bitmap(jpg);
Bitmap bmp = null;
if (c.IsType(CardType.TYPE_XYZ))//超量
{
bmp = MyBitmap.Cut(bp, imgSet.xyzArea);
}
else if (c.IsType(CardType.TYPE_PENDULUM))//P怪兽
{
bmp = MyBitmap.Cut(bp, imgSet.pendulumArea);
}
else//一般
{
bmp = MyBitmap.Cut(bp, imgSet.normalArea);
}
bp.Dispose();
MyBitmap.SaveAsJPEG(bmp, savejpg, imgSet.quilty);
//bmp.Save(savejpg, ImageFormat.Png);
}
}
}
#endregion
#region 转换图片
public void ConvertImages(string imgpath, string gamepath, bool isreplace)
{
string picspath = MyPath.Combine(gamepath, "pics");
string thubpath = MyPath.Combine(picspath, "thumbnail");
string[] files = Directory.GetFiles(imgpath);
int i = 0;
int count = files.Length;
MyBitmap.SaveAsJPEG(bmp, savejpg, imgSet.quilty);
//bmp.Save(savejpg, ImageFormat.Png);
}
}
}
#endregion
#region 转换图片
public void ConvertImages(string imgpath, string gamepath, bool isreplace)
{
string picspath = MyPath.Combine(gamepath, "pics");
string thubpath = MyPath.Combine(picspath, "thumbnail");
string[] files = Directory.GetFiles(imgpath);
int i = 0;
int count = files.Length;
foreach (string f in files)
{
if (isCancel)
break;
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string ex = Path.GetExtension(f).ToLower();
string name = Path.GetFileNameWithoutExtension(f);
string jpg_b = MyPath.Combine(picspath, name + ".jpg");
string jpg_s = MyPath.Combine(thubpath, name + ".jpg");
if (ex == ".jpg" || ex == ".png" || ex == ".bmp")
{
if (File.Exists(f))
{
Bitmap bmp = new Bitmap(f);
//大图,如果替换,或者不存在
if (isreplace || !File.Exists(jpg_b))
{
foreach (string f in files)
{
if (isCancel)
break;
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string ex = Path.GetExtension(f).ToLower();
string name = Path.GetFileNameWithoutExtension(f);
string jpg_b = MyPath.Combine(picspath, name + ".jpg");
string jpg_s = MyPath.Combine(thubpath, name + ".jpg");
if (ex == ".jpg" || ex == ".png" || ex == ".bmp")
{
if (File.Exists(f))
{
Bitmap bmp = new Bitmap(f);
//大图,如果替换,或者不存在
if (isreplace || !File.Exists(jpg_b))
{
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.W, imgSet.H),
jpg_b, imgSet.quilty);
}
//小图,如果替换,或者不存在
if (isreplace || !File.Exists(jpg_s))
{
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
jpg_s, imgSet.quilty);
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.W, imgSet.H),
jpg_b, imgSet.quilty);
}
//小图,如果替换,或者不存在
if (isreplace || !File.Exists(jpg_s))
{
MyBitmap.SaveAsJPEG(MyBitmap.Zoom(bmp, imgSet.w, imgSet.h),
jpg_s, imgSet.quilty);
}
}
}
}
}
#endregion
}
}
}
}
}
#endregion
#region MSE存档
public string MSEImagePath
{
get { return mseHelper.ImagePath; }
}
public void SaveMSEs(string file, Card[] cards, bool isUpdate)
{
if(cards == null)
return;
int c = cards.Length;
//不分开,或者卡片数小于单个存档的最大值
if (mseHelper.MaxNum == 0 || c < mseHelper.MaxNum)
SaveMSE(1, file, cards, isUpdate);
else
{
int nums = c / mseHelper.MaxNum;
if (nums * mseHelper.MaxNum < c)//计算需要分多少个存档
nums++;
List<Card> clist = new List<Card>();
for (int i = 0; i < nums; i++)//分别生成存档
{
clist.Clear();
for (int j = 0; j < mseHelper.MaxNum; j++)
{
int index = i * mseHelper.MaxNum + j;
if (index < c)
clist.Add(cards[index]);
}
int t = file.LastIndexOf(".mse-set");
string fname = (t > 0) ? file.Substring(0, t) : file;
fname = fname + string.Format("_{0}.mse-set", i + 1);
SaveMSE(i + 1, fname, clist.ToArray(), isUpdate);
}
}
}
public void SaveMSE(int num, string file, Card[] cards, bool isUpdate)
{
string setFile = file + ".txt";
Dictionary<Card, string> images = mseHelper.WriteSet(setFile, cards);
if (isUpdate)//仅更新文字
return;
int i = 0;
int count = images.Count;
using (ZipStorer zips = ZipStorer.Create(file, ""))
{
zips.EncodeUTF8 = true;//zip里面的文件名为utf8
zips.AddFile(setFile, "set", "");
foreach (Card c in images.Keys)
{
string img=images[c];
if (isCancel)
break;
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}-{2}", i, count, num));
//TODO 先裁剪图片
zips.AddFile(mseHelper.getImageCache(img,c), Path.GetFileName(img), "");
}
}
File.Delete(setFile);
}
public Card[] ReadMSE(string mseset, bool repalceOld)
{
//解压所有文件
using (ZipStorer zips = ZipStorer.Open(mseset,FileAccess.Read))
{
zips.EncodeUTF8 = true;
List<ZipStorer.ZipFileEntry> files = zips.ReadCentralDir();
int count = files.Count;
int i = 0;
foreach (ZipStorer.ZipFileEntry file in files)
{
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string savefilename = MyPath.Combine(mseHelper.ImagePath, file.FilenameInZip);
zips.ExtractFile(file, savefilename);
}
}
string setfile = MyPath.Combine(mseHelper.ImagePath, "set");
return mseHelper.ReadCards(setfile, repalceOld);
}
#endregion
#region MSE存档
public string MSEImagePath
{
get { return mseHelper.ImagePath; }
}
public void SaveMSEs(string file, Card[] cards,bool isUpdate)
{
if(cards == null)
return;
string pack_db=MyPath.GetRealPath(MyConfig.readString("pack_db"));
bool rarity=MyConfig.readBoolean("mse_auto_rarity", false);
#if DEBUG
MessageBox.Show("db = "+pack_db+",auto rarity="+rarity);
#endif
int c = cards.Length;
//不分开,或者卡片数小于单个存档的最大值
if (mseHelper.MaxNum == 0 || c < mseHelper.MaxNum)
SaveMSE(1, file, cards,pack_db, rarity, isUpdate);
else
{
int nums = c / mseHelper.MaxNum;
if (nums * mseHelper.MaxNum < c)//计算需要分多少个存档
nums++;
List<Card> clist = new List<Card>();
for (int i = 0; i < nums; i++)//分别生成存档
{
clist.Clear();
for (int j = 0; j < mseHelper.MaxNum; j++)
{
int index = i * mseHelper.MaxNum + j;
if (index < c)
clist.Add(cards[index]);
}
int t = file.LastIndexOf(".mse-set");
string fname = (t > 0) ? file.Substring(0, t) : file;
fname = fname + string.Format("_{0}.mse-set", i + 1);
SaveMSE(i + 1, fname, clist.ToArray(),pack_db, rarity, isUpdate);
}
}
}
public void SaveMSE(int num, string file, Card[] cards,string pack_db,bool rarity, bool isUpdate)
{
string setFile = file + ".txt";
Dictionary<Card, string> images = mseHelper.WriteSet(setFile, cards,pack_db,rarity);
if (isUpdate)//仅更新文字
return;
int i = 0;
int count = images.Count;
using (ZipStorer zips = ZipStorer.Create(file, ""))
{
zips.EncodeUTF8 = true;//zip里面的文件名为utf8
zips.AddFile(setFile, "set", "");
foreach (Card c in images.Keys)
{
string img=images[c];
if (isCancel)
break;
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}-{2}", i, count, num));
//TODO 先裁剪图片
zips.AddFile(mseHelper.getImageCache(img,c), Path.GetFileName(img), "");
}
}
File.Delete(setFile);
}
public Card[] ReadMSE(string mseset, bool repalceOld)
{
//解压所有文件
using (ZipStorer zips = ZipStorer.Open(mseset,FileAccess.Read))
{
zips.EncodeUTF8 = true;
List<ZipStorer.ZipFileEntry> files = zips.ReadCentralDir();
int count = files.Count;
int i = 0;
foreach (ZipStorer.ZipFileEntry file in files)
{
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string savefilename = MyPath.Combine(mseHelper.ImagePath, file.FilenameInZip);
zips.ExtractFile(file, savefilename);
}
}
string setfile = MyPath.Combine(mseHelper.ImagePath, "set");
return mseHelper.ReadCards(setfile, repalceOld);
}
#endregion
#region 导出数据
public void ExportData(string path, string zipname)
{
int i = 0;
Card[] cards = cardlist;
if (cards == null || cards.Length == 0)
return;
int count = cards.Length;
YgoPath ygopath = new YgoPath(path);
string name = Path.GetFileNameWithoutExtension(zipname);
//数据库
string cdbfile = zipname + ".cdb";
//说明
string readme = MyPath.Combine(path, name + ".txt");
//新卡ydk
string deckydk = ygopath.GetYdk(name);
#region 导出数据
public void ExportData(string path, string zipname)
{
int i = 0;
Card[] cards = cardlist;
if (cards == null || cards.Length == 0)
return;
int count = cards.Length;
YgoPath ygopath = new YgoPath(path);
string name = Path.GetFileNameWithoutExtension(zipname);
//数据库
string cdbfile = zipname + ".cdb";
//说明
string readme = MyPath.Combine(path, name + ".txt");
//新卡ydk
string deckydk = ygopath.GetYdk(name);
File.Delete(cdbfile);
DataBase.Create(cdbfile);
DataBase.CopyDB(cdbfile, false, cardlist);
File.Delete(cdbfile);
DataBase.Create(cdbfile);
DataBase.CopyDB(cdbfile, false, cardlist);
if (File.Exists(zipname))
File.Delete(zipname);
using (ZipStorer zips = ZipStorer.Create(zipname, ""))
{
zips.AddFile(cdbfile, name + ".cdb", "");
if (File.Exists(readme))
zips.AddFile(readme, "readme_" + name + ".txt", "");
if (File.Exists(deckydk))
zips.AddFile(deckydk, "deck/" + name + ".ydk", "");
foreach (Card c in cards)
{
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string[] files = ygopath.GetCardfiles(c.id);
foreach (string file in files)
{
if (File.Exists(file))
{
zips.AddFile(file, file.Replace(path,""),"");
}
}
}
}
File.Delete(cdbfile);
}
#endregion
if (File.Exists(zipname))
File.Delete(zipname);
using (ZipStorer zips = ZipStorer.Create(zipname, ""))
{
zips.AddFile(cdbfile, name + ".cdb", "");
if (File.Exists(readme))
zips.AddFile(readme, "readme_" + name + ".txt", "");
if (File.Exists(deckydk))
zips.AddFile(deckydk, "deck/" + name + ".ydk", "");
foreach (Card c in cards)
{
i++;
worker.ReportProgress(i / count, string.Format("{0}/{1}", i, count));
string[] files = ygopath.GetCardfiles(c.id);
foreach (string file in files)
{
if (File.Exists(file))
{
zips.AddFile(file, file.Replace(path,""),"");
}
}
}
}
File.Delete(cdbfile);
}
#endregion
#region 运行
public void Run()
{
isCancel = false;
isRun = true;
bool replace;
bool showNew;
switch (nowTask)
{
case MyTask.ExportData:
if (mArgs != null && mArgs.Length >= 2)
{
ExportData(mArgs[0], mArgs[1]);
}
break;
case MyTask.CheckUpdate:
showNew = false;
if (mArgs != null && mArgs.Length >= 1)
{
showNew = (mArgs[0] == Boolean.TrueString) ? true : false;
}
OnCheckUpdate(showNew);
break;
case MyTask.CutImages:
if (mArgs != null && mArgs.Length >= 2)
{
replace = true;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.FalseString)
replace = false;
}
CutImages(mArgs[0], replace);
}
break;
case MyTask.SaveAsMSE:
if (mArgs != null && mArgs.Length >= 2)
{
replace = false;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.TrueString)
replace = true;
}
SaveMSEs(mArgs[0], cardlist, replace);
}
break;
case MyTask.ReadMSE:
if (mArgs != null && mArgs.Length >= 2)
{
replace = false;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.TrueString)
replace = true;
}
cardlist = ReadMSE(mArgs[0], replace);
}
break;
case MyTask.ConvertImages:
if (mArgs != null && mArgs.Length >= 2)
{
replace = true;
if (mArgs.Length >= 3)
{
if (mArgs[2] == Boolean.FalseString)
replace = false;
}
ConvertImages(mArgs[0], mArgs[1], replace);
}
break;
}
isRun = false;
lastTask = nowTask;
nowTask = MyTask.NONE;
if(lastTask != MyTask.ReadMSE)
cardlist = null;
mArgs = null;
}
#endregion
}
#region 运行
public void Run()
{
isCancel = false;
isRun = true;
bool replace;
bool showNew;
switch (nowTask)
{
case MyTask.ExportData:
if (mArgs != null && mArgs.Length >= 2)
{
ExportData(mArgs[0], mArgs[1]);
}
break;
case MyTask.CheckUpdate:
showNew = false;
if (mArgs != null && mArgs.Length >= 1)
{
showNew = (mArgs[0] == Boolean.TrueString) ? true : false;
}
OnCheckUpdate(showNew);
break;
case MyTask.CutImages:
if (mArgs != null && mArgs.Length >= 2)
{
replace = true;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.FalseString)
replace = false;
}
CutImages(mArgs[0], replace);
}
break;
case MyTask.SaveAsMSE:
if (mArgs != null && mArgs.Length >= 2)
{
replace = false;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.TrueString)
replace = true;
}
SaveMSEs(mArgs[0], cardlist, replace);
}
break;
case MyTask.ReadMSE:
if (mArgs != null && mArgs.Length >= 2)
{
replace = false;
if (mArgs.Length >= 2)
{
if (mArgs[1] == Boolean.TrueString)
replace = true;
}
cardlist = ReadMSE(mArgs[0], replace);
}
break;
case MyTask.ConvertImages:
if (mArgs != null && mArgs.Length >= 2)
{
replace = true;
if (mArgs.Length >= 3)
{
if (mArgs[2] == Boolean.FalseString)
replace = false;
}
ConvertImages(mArgs[0], mArgs[1], replace);
}
break;
}
isRun = false;
lastTask = nowTask;
nowTask = MyTask.NONE;
if(lastTask != MyTask.ReadMSE)
cardlist = null;
mArgs = null;
}
#endregion
}
}
......@@ -108,6 +108,7 @@
<Compile Include="Config\DataManager.cs" />
<Compile Include="Config\ImageSet.cs" />
<Compile Include="Core\LuaFunction.cs" />
<Compile Include="Core\Mse\CardPack.cs" />
<Compile Include="Core\Mse\MSECons.cs" />
<Compile Include="Core\Mse\MseMaker.cs" />
<Compile Include="Core\Mse\MSEConfig.cs" />
......
......@@ -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.4.1.0")]
[assembly: AssemblyVersion("2.4.1.1")]
......@@ -46,5 +46,7 @@
<!-- MSE path-->
<add key="mse_path" value="./MagicSetEditor2/mse.exe"/>
<add key="mse_exprotpath" value="./exprot"/>
<add key="mse_auto_rarity" value="true"/>
<add key="pack_db" value="./pack.cdb"/>
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.4.1.1
新增卡包数据库,支持导出带卡包信息和rarity
2.4.1.0
更新数据
2.4.0.9
......
[DataEditorX]2.4.1.0[DataEditorX]
[DataEditorX]2.4.1.1[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
......@@ -46,5 +46,7 @@
<!-- MSE path-->
<add key="mse_path" value="./MagicSetEditor2/mse.exe"/>
<add key="mse_exprotpath" value="./exprot"/>
<add key="mse_auto_rarity" value="true"/>
<add key="pack_db" value="./pack.cdb"/>
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.4.1.1
新增卡包数据库,支持导出带卡包信息和rarity
2.4.1.0
更新数据
2.4.0.9
......
# database history
D:\code\a.cdb
D:\code\italian.cdb
# script history
\ No newline at end of file
[DataEditorX]2.4.1.0[DataEditorX]
[DataEditorX]2.4.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