Commit 5cf7bf28 authored by keyongyu's avatar keyongyu

2.4.1.1

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