Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions DataEditorX/Config/MyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public static class MyConfig
/// </summary>
public const string PATH_DATA = "data";
/// <summary>
/// images directory
/// </summary>
public const string PATH_IMAGES = "Images";
/// <summary>
/// MSE
/// </summary>
public const string TAG_MSE_LANGUAGE = "mse_language";
Expand Down
2 changes: 0 additions & 2 deletions DataEditorX/Core/MyTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public enum MyTask
CheckUpdate,
///<summary>导出数据</summary>
ExportData,
///<summary>保存为MSE存档</summary>
SaveAsMSE,
///<summary>裁剪图片</summary>
CutImages,
///<summary>转换图片</summary>
Expand Down
116 changes: 4 additions & 112 deletions DataEditorX/Core/TaskHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core.Info;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Windows.Forms;

namespace DataEditorX.Core
Expand Down Expand Up @@ -48,10 +45,6 @@ public class TaskHelper
/// </summary>
private readonly ImageSet imgSet = new();
/// <summary>
/// MSE转换
/// </summary>
private readonly MseMaker mseHelper = new();
/// <summary>
/// 是否取消
/// </summary>
private bool isCancel = false;
Expand All @@ -69,10 +62,7 @@ public TaskHelper(string datapath, BackgroundWorker worker)
Datapath = datapath;
this.worker = worker;
}
public MseMaker MseHelper
{
get { return mseHelper; }
}
public string Datapath { get; }
public bool IsRuning()
{
return isRun;
Expand Down Expand Up @@ -166,9 +156,10 @@ public void CutImages(string imgpath, bool isreplace)
}

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 savejpg = MyPath.Combine(mseHelper.ImagePath, $"{c.id}.jpg");
string outputPath = MyPath.Combine(Application.StartupPath, MyConfig.PATH_IMAGES);
string savejpg = MyPath.Combine(outputPath, $"{c.id}.jpg");
Comment thread
salix5 marked this conversation as resolved.
if (File.Exists(jpg) && (isreplace || !File.Exists(savejpg)))
{
using Bitmap bp = new(jpg);
Expand Down Expand Up @@ -223,98 +214,6 @@ public void ConvertImages(string imgpath, string gamepath, bool isreplace)
}
#endregion

#region MSE存档
public string Datapath { get; }

public void SaveMSEs(string file, Card[] cards, bool isUpdate)
{
if (cards is null || cards.Length == 0)
{
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();
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 += 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;
}

try
{
using FileStream fs = new(file, FileMode.Create, FileAccess.Write);
using ZipArchive archive = new(fs, ZipArchiveMode.Create, false);
// 添加文字到压缩包,内部文件名固定为 "set"
archive.CreateEntryFromFile(setFile, "set");

int i = 0;
foreach (var kvp in images)
{
Card c = kvp.Key;
string img = kvp.Value;
if (isCancel)
{
break;
}

i++;
worker.ReportProgress(i * 100 / images.Count, string.Format("{0}/{1}-{2}", i, images.Count, num));

// 获取需要写入的最终图片(可包含裁剪/缓存逻辑)
string cachePath = mseHelper.GetImageCache(img, c);
string entryName = Path.GetFileName(img);
if (File.Exists(cachePath))
{
archive.CreateEntryFromFile(cachePath, entryName);
}
}
}
catch (Exception)
{
}
}
#endregion

#region 导出数据
public void ExportData(string path, string zipname, string _cdbfile, string modulescript)
{
Expand Down Expand Up @@ -409,13 +308,6 @@ public void Run()
CutImages(mArgs[0], replace);
}
break;
case MyTask.SaveAsMSE:
if (mArgs.Length >= 2)
{
bool replace = (mArgs.Length >= 2) ? (mArgs[1] == bool.TrueString) : false;
SaveMSEs(mArgs[0], CardList, replace);
}
break;
case MyTask.ConvertImages:
if (mArgs.Length >= 2)
{
Comment thread
salix5 marked this conversation as resolved.
Expand Down
30 changes: 0 additions & 30 deletions DataEditorX/DataEditForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 1 addition & 47 deletions DataEditorX/DataEditForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using DataEditorX.Common;
using DataEditorX.Config;
using DataEditorX.Core;
using DataEditorX.Core.Mse;
using DataEditorX.Language;
using System;
using System.Collections;
Expand Down Expand Up @@ -1143,9 +1142,6 @@ void BgWorker1RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerC
case MyTask.CutImages:
MyMsg.Show(LMSG.CutImageOK);
break;
case MyTask.SaveAsMSE:
MyMsg.Show(LMSG.SaveMseOK);
break;
case MyTask.ConvertImages:
MyMsg.Show(LMSG.ConvertImageOK);
break;
Expand Down Expand Up @@ -1197,7 +1193,7 @@ public void SaveCards(Card[] cards)
}
#endregion

#region MSE存档/裁剪图片
#region 裁剪图片
//裁剪图片
void Menuitem_cutimagesClick(object sender, EventArgs e)
{
Expand All @@ -1215,48 +1211,6 @@ void Menuitem_cutimagesClick(object sender, EventArgs e)
tasker.SetTask(MyTask.CutImages, cardlist.ToArray(), ygopath.picpath, isreplace.ToString());
Run(LanguageHelper.GetMsg(LMSG.CutImage));
}
void Menuitem_saveasmse_selectClick(object sender, EventArgs e)
{
//选择
SaveAsMSE(true);
}

void Menuitem_saveasmseClick(object sender, EventArgs e)
{
//全部
SaveAsMSE(false);
}
void SaveAsMSE(bool onlyselect)
{
if (!IsOpened())
{
return;
}

if (isRun())
{
return;
}

Card[] cards = GetCardList(onlyselect);
if (cards.Length == 0)
{
return;
}
//select save mse-set
using SaveFileDialog dlg = new();
dlg.Title = LanguageHelper.GetMsg(LMSG.SelectMseSet);
dlg.Filter = MyConfig.MSE_TYPE;
if (dlg.ShowDialog() == DialogResult.OK)
{
bool isUpdate = false;
#if DEBUG
isUpdate = MyMsg.Question(LMSG.OnlySet);
#endif
tasker.SetTask(MyTask.SaveAsMSE, cards, dlg.FileName, isUpdate.ToString());
Run(LanguageHelper.GetMsg(LMSG.SaveMse));
}
}
#endregion

#region 导入卡图
Expand Down
2 changes: 1 addition & 1 deletion DataEditorX/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public MainForm(string datapath)
this.datapath = datapath;
//文件路径
conflang = MyConfig.GetLanguageFile(datapath);
//游戏数据,MSE数据
//游戏数据
datacfg = new DataConfig(MyConfig.GetCardInfoFile(datapath));
history = new History(this);
YGOUtil.SetConfig(datacfg);
Expand Down
3 changes: 0 additions & 3 deletions DataEditorX/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<add key="image_other" value="25,54,128,128" />
<add key="image_xyz" value="24,51,128,128" />
<add key="image_pendulum" value="16,50,147,109" />
<!-- MSE path-->
<add key="mse_auto_rarity" value="true" />
<add key="pack_db" value="./pack.db" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
Expand Down
16 changes: 5 additions & 11 deletions DataEditorX/data/language_chinese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ DataEditForm.pl_bottom.btn_add 新增
DataEditForm.pl_bottom.btn_mod 修改
DataEditForm.pl_bottom.btn_undo N/A
#
DataEditForm.mainMenu.menu_image MSE(&M)
DataEditForm.mainMenu.menuitem_mseconfig 设置MSE的配置文件
DataEditForm.mainMenu.menuitem_saveasmse_select 把选中导为MSE存档
DataEditForm.mainMenu.menuitem_saveasmse 把结果导为MSE存档
DataEditForm.mainMenu.menuitem_testpendulumtext 测试灵摆效果文本
#
DataEditForm.mainMenu.menu_data 数据(&D)
DataEditForm.mainMenu.menuitem_operacardsfile 同步操作卡片图片和脚本
DataEditForm.mainMenu.menuitem_default_script Set default script name
Expand Down Expand Up @@ -104,12 +98,12 @@ MainForm.mainMenu.menuitem_closeall 关闭所有
0x25 N/A
0x26 当前有其他任务正在进行
0x27 正在检查更新
0x28 正在复制卡片
0x29 卡片复制完成
0x2a MSE存档
0x28 N/A
0x29 N/A
0x2a N/A
0x2b N/A
0x2c 正在导出MSE存档
0x2d 导出MSE存档完成
0x2c N/A
0x2d N/A
0x2e 正在裁剪图片
0x2f 裁剪图片完成
0x30 没有选中一张卡片
Expand Down
Loading