Commit 6b85b033 authored by keyongyu's avatar keyongyu

2.3.3.0 导出MSE图片

parent 2ce57c68
......@@ -17,6 +17,7 @@ public class MyConfig : XMLReader
#region 常量
public const string TAG_SAVE_LAGN = "-savelanguage";
public const string TAG_SAVE_LAGN2 = "-sl";
public const string TAG_MSE_PATH="mse_path";
/// <summary>
/// 窗口消息 打开文件
/// </summary>
......
......@@ -41,6 +41,10 @@ public class MSEConfig
public const string TAG_TYPE = "type";
public const string TAG_WIDTH="width";
public const string TAG_HEIGHT="height";
public const string TAG_PEND_WIDTH="pwidth";
public const string TAG_PEND_HEIGHT="pheight";
public const string TAG_IMAGE = "imagepath";
public const string TAG_REPALCE = "replace";
......@@ -99,6 +103,12 @@ public void SetConfig(string config, string path)
else if (line.StartsWith(TAG_HEIGHT)){
height=ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_PEND_WIDTH)){
pwidth=ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_PEND_HEIGHT)){
pheight=ConfHelper.getIntegerValue(line,0);
}
else if (line.StartsWith(TAG_IMAGE))
{
//如果路径不合法,则为后面的路径
......@@ -149,6 +159,10 @@ public void init(string path)
/// 中间图高度
/// </summary>
public int height;
public int pwidth;
public int pheight;
//每个存档最大数
public int maxcount;
//图片路径
......
......@@ -5,6 +5,7 @@
* 时间: 12:48
*
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
......@@ -16,6 +17,8 @@
using DataEditorX.Config;
using DataEditorX.Language;
using DataEditorX.Common;
using System.Windows.Forms;
using System.Threading;
namespace DataEditorX.Core.Mse
{
......@@ -366,9 +369,9 @@ public string[] GetTypes(Card c)
#region 写存档
//写存档
public string[] WriteSet(string file, Card[] cards)
public Dictionary<Card, string> WriteSet(string file, Card[] cards)
{
List<string> list = new List<string>();
Dictionary<Card, string> list = new Dictionary<Card, string>();
string pic = cfg.imagepath;
using (FileStream fs = new FileStream(file,
FileMode.Create, FileAccess.Write))
......@@ -380,7 +383,7 @@ public string[] WriteSet(string file, Card[] cards)
string jpg = GetCardImagePath(pic, c);
if (!string.IsNullOrEmpty(jpg))
{
list.Add(jpg);
list.Add(c, jpg);
jpg = Path.GetFileName(jpg);
}
if (c.IsType(CardType.TYPE_SPELL) || c.IsType(CardType.TYPE_TRAP))
......@@ -392,7 +395,7 @@ public string[] WriteSet(string file, Card[] cards)
sw.Close();
}
return list.ToArray();
return list;
}
//怪兽,pendulum怪兽
string getMonster(Card c, string img, bool isPendulum)
......@@ -723,7 +726,12 @@ public Card[] ReadCards(string set, bool repalceOld)
}
#endregion
public string getImageCache(string img){
/// <summary>
/// 图片缓存
/// </summary>
/// <param name="img"></param>
/// <returns></returns>
public string getImageCache(string img,Card card){
if(cfg.width<=0 && cfg.height<=0)
return img;
string md5=MyUtils.GetMD5HashFromFile(img);
......@@ -733,14 +741,57 @@ public Card[] ReadCards(string set, bool repalceOld)
}
string file = MyPath.Combine(cfg.imagecache, md5);
if(!File.Exists(file)){
//生成缓存
//生成缓存
Bitmap bmp=MyBitmap.readImage(file);
//缩放
bmp=MyBitmap.Zoom(bmp, cfg.width,cfg.height);
if(card!=null && card.IsType(CardType.TYPE_PENDULUM)){
bmp=MyBitmap.Zoom(bmp, cfg.pwidth,cfg.pheight);
}else{
bmp=MyBitmap.Zoom(bmp, cfg.width,cfg.height);
}
//保存文件
MyBitmap.SaveAsJPEG(bmp, file,100);
}
return img;
}
private static void exportSetThread(object obj){
string[] args=(string[])obj;
if(args==null||args.Length<3){
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}
string mse_path=args[0];
string setfile=args[1];
string path=args[2];
if(mse_path==null||mse_path.Length==0||setfile==null||setfile.Length==0){
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}else{
string cmd=" --export "+setfile.Replace("\\\\","\\").Replace("\\","/")+" {card.gamecode}.png";
System.Diagnostics.Process ie = new System.Diagnostics.Process();
ie.StartInfo.FileName = mse_path;
ie.StartInfo.Arguments = cmd;
ie.StartInfo.WorkingDirectory=path;
MyPath.CreateDir(path);
try{
ie.Start();
//等待结束,需要把当前方法放到线程里面
ie.WaitForExit();
ie.Close();
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImages));
}catch{
}
}
}
public static void exportSet(string mse_path,string setfile,string path){
if(mse_path==null||mse_path.Length==0||setfile==null||setfile.Length==0){
return;
}
ParameterizedThreadStart ParStart = new ParameterizedThreadStart(exportSetThread);
Thread myThread = new Thread(ParStart);
myThread.IsBackground=true;
myThread.Start(new string[]{mse_path,setfile,path});
}
}
}
......@@ -278,23 +278,24 @@ public void SaveMSEs(string file, Card[] cards, bool isUpdate)
public void SaveMSE(int num, string file, Card[] cards, bool isUpdate)
{
string setFile = file + ".txt";
string[] images = mseHelper.WriteSet(setFile, cards);
Dictionary<Card, string> images = mseHelper.WriteSet(setFile, cards);
if (isUpdate)//仅更新文字
return;
int i = 0;
int count = images.Length;
int count = images.Count;
using (ZipStorer zips = ZipStorer.Create(file, ""))
{
zips.EncodeUTF8 = true;//zip里面的文件名为utf8
zips.AddFile(setFile, "set", "");
foreach (string img in images)
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), Path.GetFileName(img), "");
zips.AddFile(mseHelper.getImageCache(img,c), Path.GetFileName(img), "");
}
}
File.Delete(setFile);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -92,6 +92,8 @@ public enum LMSG : uint
ReadMSEisOK = 0x48,
PlzRestart = 0x49,
exportMseImages = 0x4a,
exportMseImagesErr = 0x4b,
COUNT,
}
}
......@@ -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.2.0")]
[assembly: AssemblyVersion("2.3.3.0")]
......@@ -45,5 +45,7 @@
<add key="tabisspace" value="false" />
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
<!-- MSE path-->
<add key="mse_path" value="E:\\git\\MagicSetEditor2\\mse.exe"/>
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.3.3.0
一键导出MSE存档为图片。
注意:
仅支持原始大小导出因此还需要调用批量导入功能。
如果卡片数量多,需要的时间很久,请耐心等待。
原理:
图片会在cmd.exe的当前目录,建议先定位到mse.exe的目录。
把E:/test.mse-set替换为存档所在的目录,分隔符必须为/
(win7右键mse目录的空白处,在此打开命令窗口)
mse.exe --export E:/test.mse-set {card.gamecode}.png
2.3.2.0
MSE存档的中间图缩放
2.3.1.4
......
......@@ -56,6 +56,7 @@ DataEditForm.mainMenu.menuitem_saveasmse_select 把选中导为MSE存档
DataEditForm.mainMenu.menuitem_saveasmse 把结果导为MSE存档
DataEditForm.mainMenu.menuitem_cutimages 批量裁剪卡图
DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_help 帮助(&H)
DataEditForm.mainMenu.menuitem_about 关于
......@@ -156,4 +157,6 @@ MainForm.mainMenu.menuitem_closeall 关闭所有
0x46 是否保存脚本?
0x47 读取MSE存档
0x48 读取MSE存档完成!
0x49 请重启程序使更改生效
0x49 请重启程序使更改生效。
0x4a 从MSE存档导出图片完成。
0x4b 从MSE存档导出图片失败。
......@@ -56,6 +56,7 @@ DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images
DataEditForm.mainMenu.menuitem_help Help(&H)
DataEditForm.mainMenu.menuitem_about About
DataEditForm.mainMenu.menuitem_language Laguage
......@@ -156,3 +157,5 @@ MainForm.mainMenu.menuitem_closeall Close All
0x47 Read MSE-set
0x48 Read MSE-set is OK.
0x49 Please restart program to apply changes.
0x4a Export Mse-set to Images OK.
0x4b Export Mse-set to Images Fail.
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
# spell = %%
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
# spell = %%
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 200
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
spell = [Sepll Card%%]
trap = [Trap Card%%]
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
spell = %%
......
[DataEditorX]2.3.2.0[DataEditorX]
[DataEditorX]2.3.3.0[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!-- Example connection to a SQL Server Database on localhost. -->
<!-- <add name="ExampleConnectionString"
<connectionStrings>
<!-- Example connection to a SQL Server Database on localhost. -->
<!-- <add name="ExampleConnectionString"
connectionString="Data Source=.;Initial Catalog=DBName;Integrated Security=True"
providerName="System.Data.SqlClient" /> -->
</connectionStrings>
<appSettings>
<!-- access these values via the property:
</connectionStrings>
<appSettings>
<!-- access these values via the property:
System.Configuration.ConfigurationManager.AppSettings[key]
-->
<!-- auto enter length -->
<add key="autolength" value="30" />
<!-- MSE language data/mse_xxx.txt -->
<add key="mse" value="Chinese-Simplified" />
<!-- Language data/cardinfo_xxxx.txt data/language_xxx.txt -->
<add key="language" value="english" />
<!-- Check system language when running program first time -->
<add key="check_system_language" value="true" />
<!-- async load data -->
<add key="async" value="false" />
<!-- DataEditorX source code -->
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<!-- DataEditorX update url-->
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
<!-- delete,modify with card's files image script -->
<add key="opera_with_cards_file" value="true" />
<!-- open file in this.such as lua -->
<add key="open_file_in_this" value="true" />
<!-- check update when opening application automatically -->
<add key="auto_check_update" value="true" />
<!-- Cut Images Setting -->
<add key="image_quilty" value="100" />
<add key="image" value="44,64,177,254" />
<add key="image_other" value="25,54,128,128" />
<add key="image_xyz" value="24,51,128,128" />
<add key="image_pendulum" value="14,46,149,120" />
<!-- CodeEdiotr Setting
<!-- auto enter length -->
<add key="autolength" value="30" />
<!-- MSE language data/mse_xxx.txt -->
<add key="mse" value="Chinese-Simplified" />
<!-- Language data/cardinfo_xxxx.txt data/language_xxx.txt -->
<add key="language" value="Chinese" />
<!-- Check system language when running program first time -->
<add key="check_system_language" value="false" />
<!-- async load data -->
<add key="async" value="false" />
<!-- DataEditorX source code -->
<add key="sourceURL" value="https://github.com/247321453/DataEditorX" />
<!-- DataEditorX update url-->
<add key="updateURL" value="https://github.com/247321453/DataEditorX/tree/master/win32/readme.txt" />
<!-- delete,modify with card's files image script -->
<add key="opera_with_cards_file" value="true" />
<!-- open file in this.such as lua -->
<add key="open_file_in_this" value="true" />
<!-- check update when opening application automatically -->
<add key="auto_check_update" value="true" />
<!-- Cut Images Setting -->
<add key="image_quilty" value="100" />
<add key="image" value="44,64,177,254" />
<add key="image_other" value="25,54,128,128" />
<add key="image_xyz" value="24,51,128,128" />
<add key="image_pendulum" value="14,46,149,120" />
<!-- CodeEdiotr Setting
IME = true 使用輸入法,正常顯示文字,反應變慢
IME = false English
-->
<add key="IME" value="false" />
<add key="wordwrap" value="true" />
<add key="tabisspace" value="false" />
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
</appSettings>
<add key="IME" value="false" />
<add key="wordwrap" value="true" />
<add key="tabisspace" value="false" />
<add key="fontname" value="Consolas" />
<add key="fontsize" value="14.5" />
<!-- MSE path-->
<add key="mse_path" value="E:\\git\\MagicSetEditor2\\mse.exe" />
</appSettings>
</configuration>
\ No newline at end of file
★更新历史
2.3.3.0
一键导出MSE存档为图片。
注意:
仅支持原始大小导出因此还需要调用批量导入功能。
如果卡片数量多,需要的时间很久,请耐心等待。
原理:
图片会在cmd.exe的当前目录,建议先定位到mse.exe的目录。
把E:/test.mse-set替换为存档所在的目录,分隔符必须为/
(win7右键mse目录的空白处,在此打开命令窗口)
mse.exe --export E:/test.mse-set {card.gamecode}.png
2.3.2.0
MSE存档的中间图缩放
2.3.1.4
......
......@@ -56,6 +56,7 @@ DataEditForm.mainMenu.menuitem_saveasmse_select 把选中导为MSE存档
DataEditForm.mainMenu.menuitem_saveasmse 把结果导为MSE存档
DataEditForm.mainMenu.menuitem_cutimages 批量裁剪卡图
DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_help 帮助(&H)
DataEditForm.mainMenu.menuitem_about 关于
......@@ -156,4 +157,6 @@ MainForm.mainMenu.menuitem_closeall 关闭所有
0x46 是否保存脚本?
0x47 读取MSE存档
0x48 读取MSE存档完成!
0x49 请重启程序使更改生效
0x49 请重启程序使更改生效。
0x4a 从MSE存档导出图片完成。
0x4b 从MSE存档导出图片失败。
......@@ -56,6 +56,7 @@ DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images
DataEditForm.mainMenu.menuitem_help Help(&H)
DataEditForm.mainMenu.menuitem_about About
DataEditForm.mainMenu.menuitem_language Laguage
......@@ -156,3 +157,5 @@ MainForm.mainMenu.menuitem_closeall Close All
0x47 Read MSE-set
0x48 Read MSE-set is OK.
0x49 Please restart program to apply changes.
0x4a Export Mse-set to Images OK.
0x4b Export Mse-set to Images Fail.
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
# spell = %%
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
# spell = %%
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 200
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
spell = [Sepll Card%%]
trap = [Trap Card%%]
......
......@@ -8,8 +8,10 @@ cn2tw = false
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
width = 319
height = 317
pwidth = 363
pheight= 275
########################### Spell/Trap
#jp setting
spell = %%
......
[DataEditorX]2.3.2.0[DataEditorX]
[DataEditorX]2.3.3.0[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