Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
DataEditorX
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
聖園ミカ
DataEditorX
Commits
5cf7bf28
Commit
5cf7bf28
authored
Feb 27, 2016
by
keyongyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.4.1.1
parent
95e53e76
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
561 additions
and
435 deletions
+561
-435
.gitignore
.gitignore
+1
-0
DataEditorX/Config/MyConfig.cs
DataEditorX/Config/MyConfig.cs
+9
-5
DataEditorX/Core/DataBase.cs
DataEditorX/Core/DataBase.cs
+29
-0
DataEditorX/Core/Mse/CardPack.cs
DataEditorX/Core/Mse/CardPack.cs
+66
-0
DataEditorX/Core/Mse/MseMaker.cs
DataEditorX/Core/Mse/MseMaker.cs
+20
-5
DataEditorX/Core/TaskHelper.cs
DataEditorX/Core/TaskHelper.cs
+424
-418
DataEditorX/DataEditorX.csproj
DataEditorX/DataEditorX.csproj
+1
-0
DataEditorX/Properties/AssemblyInfo.cs
DataEditorX/Properties/AssemblyInfo.cs
+1
-1
DataEditorX/app.config
DataEditorX/app.config
+2
-0
DataEditorX/changed.txt
DataEditorX/changed.txt
+2
-0
DataEditorX/readme.txt
DataEditorX/readme.txt
+1
-1
win32/DataEditorX.exe
win32/DataEditorX.exe
+0
-0
win32/DataEditorX.exe.config
win32/DataEditorX.exe.config
+2
-0
win32/changed.txt
win32/changed.txt
+2
-0
win32/data/history.txt
win32/data/history.txt
+0
-4
win32/readme.txt
win32/readme.txt
+1
-1
win32/win32.zip
win32/win32.zip
+0
-0
No files found.
.gitignore
View file @
5cf7bf28
...
...
@@ -228,3 +228,4 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
/win32/*.cdb
DataEditorX/Config/MyConfig.cs
View file @
5cf7bf28
...
...
@@ -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
...
...
DataEditorX/Core/DataBase.cs
View file @
5cf7bf28
...
...
@@ -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
;
}
}
}
DataEditorX/Core/Mse/CardPack.cs
0 → 100644
View file @
5cf7bf28
/*
* 由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"
;
}
}
}
DataEditorX/Core/Mse/MseMaker.cs
View file @
5cf7bf28
...
...
@@ -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
));
...
...
DataEditorX/Core/TaskHelper.cs
View file @
5cf7bf28
...
...
@@ -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
}
}
DataEditorX/DataEditorX.csproj
View file @
5cf7bf28
...
...
@@ -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"
/>
...
...
DataEditorX/Properties/AssemblyInfo.cs
View file @
5cf7bf28
...
...
@@ -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
"
)]
DataEditorX/app.config
View file @
5cf7bf28
...
...
@@ -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
DataEditorX/changed.txt
View file @
5cf7bf28
★更新历史
2.4.1.1
新增卡包数据库,支持导出带卡包信息和rarity
2.4.1.0
更新数据
2.4.0.9
...
...
DataEditorX/readme.txt
View file @
5cf7bf28
[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)
...
...
win32/DataEditorX.exe
View file @
5cf7bf28
No preview for this file type
win32/DataEditorX.exe.config
View file @
5cf7bf28
...
...
@@ -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
win32/changed.txt
View file @
5cf7bf28
★更新历史
2.4.1.1
新增卡包数据库,支持导出带卡包信息和rarity
2.4.1.0
更新数据
2.4.0.9
...
...
win32/data/history.txt
deleted
100644 → 0
View file @
95e53e76
# database history
D:\code\a.cdb
D:\code\italian.cdb
# script history
\ No newline at end of file
win32/readme.txt
View file @
5cf7bf28
[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)
...
...
win32/win32.zip
View file @
5cf7bf28
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment