Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
genre strings
progress on OCG packs
add options:
  * Read Cards from Scripts path
  * Read difference between Images/Scripts path (instead of intersection)
  • Loading branch information
Lyris12 committed May 29, 2023
1 parent 614328e commit 9c3c226
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 60 deletions.
6 changes: 3 additions & 3 deletions DataEditorX/Core/Mse/MseMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ string GetMonster(Card c, string img, CardPack cardpack = null, bool rarity = tr
string ptx = "";
if (!string.IsNullOrEmpty(txt))
{
string[] t0 = Regex.Split(txt, "\r?\n--+\r?\n");
string[] t0 = Regex.Split(txt, "\r?\n\r?\n");
if (t0.Length > 2)
{
txt = txt[..(txt.Length - t0[2].Length - 1)];
Expand Down Expand Up @@ -548,7 +548,7 @@ string GetSpellTrap(Card c, string img, bool isSpell, CardPack cardpack = null,
}
}
string txt = c.desc;
if (!string.IsNullOrEmpty(txt)) txt = Regex.Split(txt, "\r?\n--+\r?\n")[0];
if (!string.IsNullOrEmpty(txt)) txt = Regex.Split(txt, "\r?\n\r?\n")[0];
_ = sb.AppendLine(" " + TAG_TEXT + ":");
_ = sb.AppendLine(" " + ReText(ReItalic(txt)));
_ = sb.AppendLine(GetLine(TAG_CODE, c.IdString));
Expand Down Expand Up @@ -1036,7 +1036,7 @@ public static List<string> GetMPText(string desc)
else
{
if (ptext == text) ptext = "";
text = Regex.Split(text, "\r?\n--+\r?\n")[0];
text = Regex.Split(text, "\r?\n-*?\r?\n")[0];
}

List<string> val = new()
Expand Down
20 changes: 15 additions & 5 deletions DataEditorX/Core/YGOUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static string[] ReadYDK(string ydkfile)
str = sr.ReadLine();
while (str != null)
{
if (!str.StartsWith("!") && !str.StartsWith("#") && str.Length > 0)
if (int.TryParse(str.Trim(), out _) && str.Length > 0)
{
if (IDs.IndexOf(str) < 0)
{
Expand Down Expand Up @@ -228,10 +228,20 @@ public static string[] ReadImage(string path)
for (int i = 0; i < n; i++)
{
string ex = Path.GetExtension(files[i]).ToLower();
if (ex == ".jpg" || ex == ".png" || ex == ".bmp")
{
list.Add(Path.GetFileNameWithoutExtension(files[i]));
}
if ((ex == ".jpg" || ex == ".png" || ex == ".bmp") && int.TryParse(Path.GetFileNameWithoutExtension(files[i]), out int s))
list.Add(s.ToString());
}
return list.ToArray();
}
public static string[] ReadScript(string path)
{
List<string> list = new();
string[] files = Directory.GetFiles(path, "*.lua");
int n = files.Length;
for (int i = 0; i < n; i++)
{
if (int.TryParse(Path.GetFileNameWithoutExtension(files[i])[(Path.GetFileName(files[i])[0] == 'c' ? 1 : 0)..], out int s))
list.Add(s.ToString());
}
return list.ToArray();
}
Expand Down
17 changes: 17 additions & 0 deletions DataEditorX/DataEditForm.Designer.cs

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

94 changes: 88 additions & 6 deletions DataEditorX/DataEditForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using WeifenLuo.WinFormsUI.Docking;
using Microsoft.Data.Sqlite;
using System.Text.RegularExpressions;
using System.Text;

namespace DataEditorX
{
Expand Down Expand Up @@ -1275,9 +1276,59 @@ void Menuitem_readydkClick(object sender, EventArgs e)
{
tmpCodes.Clear();
string[] ids = YGOUtil.ReadYDK(dlg.FileName);
tmpCodes.AddRange(ids);
SetCards(DataBase.Read(nowCdbFile, true,
ids), false);
if (MessageBox.Show("Show cards outside of this YDK?", null, MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {
SetCards(DataBase.Read(nowCdbFile, true, "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id and datas.id not in ("
+ string.Join(",", ids) + ");"), false);
foreach (Card c in cardlist)
tmpCodes.Add(c.id.ToString());
} else {
tmpCodes.AddRange(ids);
SetCards(DataBase.Read(nowCdbFile, true,
ids), false);
}
}
}
void Menuitem_readlistClick(object sender, EventArgs e)
{
if (!CheckOpen())
{
return;
}

using OpenFileDialog dlg = new();
dlg.Title = "Select decklist file";
dlg.Filter = "Plain text files (*.txt)|*.txt|all files(*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
tmpCodes.Clear();
List<string> IDs = new();
string ydkfile = dlg.FileName;
string str;
if (File.Exists(ydkfile))
{
using FileStream f = new(ydkfile, FileMode.Open, FileAccess.Read);
StreamReader sr = new(f, Encoding.Default);
str = sr.ReadLine();
while (str != null)
{
if (str.Length > 0)
if (IDs.IndexOf(str) < 0)
IDs.Add(str.Replace("\"", "\"\"").ToLowerInvariant());
str = sr.ReadLine();
}
sr.Close();
f.Close();
}
if (IDs.Count == 0)
return;
string[] names = IDs.ToArray();
if (MessageBox.Show("Show cards outside of this YDK?", null, MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {
SetCards(DataBase.Read(nowCdbFile, true, "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id and lower(name) not in (\"" + string.Join("\",\"", names) + "\");"), false);
} else {
SetCards(DataBase.Read(nowCdbFile, true, "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id and lower(name) in (\"" + string.Join("\",\"", names) + "\");"), false);
}
foreach (Card c in cardlist)
tmpCodes.Add(c.id.ToString());
}
}
//从图片文件夹读取
Expand All @@ -1294,9 +1345,40 @@ void Menuitem_readimagesClick(object sender, EventArgs e)
{
tmpCodes.Clear();
string[] ids = YGOUtil.ReadImage(fdlg.SelectedPath);
tmpCodes.AddRange(ids);
SetCards(DataBase.Read(nowCdbFile, true,
ids), false);
if (MessageBox.Show("Show cards without an image?", null, MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {
SetCards(DataBase.Read(nowCdbFile, true, "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id and alias=0 and datas.id not in (" + string.Join(",", ids) + ");"), false);
foreach(Card c in cardlist)
tmpCodes.Add(c.id.ToString());
} else {
tmpCodes.AddRange(ids);
SetCards(DataBase.Read(nowCdbFile, true,
ids.OrderBy(int.Parse).ToArray()), false);
}
}
}
void Menuitem_readscriptsClick(object sender, EventArgs e)
{
if (!CheckOpen())
{
return;
}

using FolderBrowserDialog fdlg = new();
fdlg.Description = "Select script folder";
if (fdlg.ShowDialog() == DialogResult.OK)
{
tmpCodes.Clear();
string[] ids = YGOUtil.ReadScript(fdlg.SelectedPath);
if (MessageBox.Show("Show cards without a script?", null,
MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2) == DialogResult.Yes) {
SetCards(DataBase.Read(nowCdbFile, true, "SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id and type & 17 != 17 and alias = 0 and datas.id not in (4005,4006,4007,4010,4011,4012,4017,4018,4019,10000050,10000060,10000070," + string.Join(",", ids) + ");"), false);
foreach (Card c in cardlist)
tmpCodes.Add(c.id.ToString());
} else {
tmpCodes.AddRange(ids);
SetCards(DataBase.Read(nowCdbFile, true,
ids.OrderBy(int.Parse).ToArray()), false);
}
}
}
//关闭
Expand Down
6 changes: 3 additions & 3 deletions DataEditorX/DataEditorX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<RepositoryUrl>https://github.com/Lyris12/DataEditorX</RepositoryUrl>
<Title></Title>
<Version>4.0.2.5</Version>
<AssemblyVersion>4.0.2.5</AssemblyVersion>
<FileVersion>4.0.2.5</FileVersion>
<Version>4.0.2.6</Version>
<AssemblyVersion>4.0.2.6</AssemblyVersion>
<FileVersion>4.0.2.6</FileVersion>
<PackageId />
<ApplicationIcon>icon.ico</ApplicationIcon>
<BaseOutputPath>..\bin\</BaseOutputPath>
Expand Down
85 changes: 43 additions & 42 deletions DataEditorX/data/cardinfo_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,42 @@
0x2
0x4
##category
0x1 S/T Destroy
0x2 Destroy Monster
0x4 Banish
0x8 Graveyard
0x10 Back to Hand
0x20 Back to Deck
0x40 Destroy Hand
0x80 Destroy Deck
0x100 Draw
0x200 Search
0x400 Recovery
0x800 Position
0x1000 Control
0x2000 Change ATK/DEF
0x4000 Piercing
0x8000 Repeat Attack
0x10000 Limit Attack
0x20000 Direct Attack
0x40000 Special Summon
0x80000 Token
0x100000 Type-Related
0x200000 Property-Related
0x400000 Damage LP
0x800000 Recover LP
0x1000000 Destroy
0x2000000 Select
0x4000000 Counter
0x8000000 Gamble
0x10000000 Fusion-Related
0x20000000 Tuner-Related
0x40000000 Xyz-Related
0x80000000 Negate Effect
0x100000000 Ritual-Related
0x200000000 Pendulum-Related
0x400000000 Link-Related
0x800000000 Hand Trap
0x1 S/T Destroy
0x2 Destroy Monster
0x4 Banish
0x8 Graveyard
0x10 Back to Hand
0x20 Back to Deck
0x40 Destroy Hand
0x80 Destroy Deck
0x100 Draw
0x200 Search
0x400 Recovery
0x800 Position
0x1000 Control
0x2000 Change ATK/DEF
0x4000 Piercing
0x8000 Repeat Attack
0x10000 Limit Attack
0x20000 Direct Attack
0x40000 Special Summon
0x80000 Token
0x100000 Type-Related
0x200000 Attribute-Related
0x400000 Damage LP
0x800000 Recover LP
0x1000000 Destroy
0x2000000 Select
0x4000000 Counter
0x8000000 Gamble
0x10000000 Fusion-Related
0x20000000 Tuner-Related
0x40000000 Xyz-Related
0x80000000 Negate Effect
0x100000000 Ritual-Related
0x200000000 Pendulum-Related
0x400000000 Link-Related
0x800000000 Hand Trap
##race
0x0 Race
0x1 Warrior
Expand Down Expand Up @@ -103,12 +103,13 @@
0x400000 Creator God
0x800000 Wyrm
0x1000000 Cyberse
0x2000000 Cyborg
0x4000000 Magical Knight
0x8000000 High Dragon
0x10000000 Omega Psychic
0x20000000 Celestial Warrior
0x40000000 Galaxy
0x2000000 Illusion
0x4000000 Cyborg
0x8000000 Magical Knight
0x10000000 High Dragon
0x20000000 Omega Psychic
0x40000000 Celestial Warrior
0x80000000 Galaxy
##type
0x1 Monster
0x2 Spell
Expand Down
2 changes: 2 additions & 0 deletions DataEditorX/data/language_english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ DataEditForm.mainMenu.menuitem_openfileinthis Open Lua with CodeEditor
DataEditForm.mainMenu.menuitem_addrequire Auto Add Requires
DataEditForm.mainMenu.menuitem_findluafunc Find Lua Functions from C++ Code
DataEditForm.mainMenu.menuitem_readydk Read Cards from YDK File(&Y)
DataEditForm.mainMenu.menuitem_readlist Read from Deck List
DataEditForm.mainMenu.menuitem_readimages Read from Images Path(&I)
DataEditForm.mainMenu.menuitem_readscripts Read from Scripts Path
DataEditForm.mainMenu.menuitem_compdb Compress Database
DataEditForm.mainMenu.menuitem_exportdata Export Data as ZIP File
DataEditForm.mainMenu.menuitem_mseconfig Set MSE Config
Expand Down
Binary file modified DataEditorX/pack.db
Binary file not shown.
2 changes: 1 addition & 1 deletion DataEditorX/readme.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[DataEditorX]4.0.2.5[DataEditorX]
[DataEditorX]4.0.2.6[DataEditorX]
[URL]https://github.com/Lyris12/DataEditorX/releases/download/omega/win32.zip [URL]
[URL]https://github.com/Lyris12/DataEditorX/releases/download/omega/win64.zip [URL]

0 comments on commit 9c3c226

Please sign in to comment.